diff options
Diffstat (limited to 'include/uapi/linux')
468 files changed, 41560 insertions, 8622 deletions
diff --git a/include/uapi/linux/acct.h b/include/uapi/linux/acct.h index 985b89068591..0e591152aa8a 100644 --- a/include/uapi/linux/acct.h +++ b/include/uapi/linux/acct.h @@ -103,12 +103,13 @@ struct acct_v3  /*   *  accounting flags   */ -				/* bit set when the process ... */ +				/* bit set when the process/task ... */  #define AFORK		0x01	/* ... executed fork, but did not exec */  #define ASU		0x02	/* ... used super-user privileges */  #define ACOMPAT		0x04	/* ... used compatibility mode (VAX only not used) */  #define ACORE		0x08	/* ... dumped core */  #define AXSIG		0x10	/* ... was killed by a signal */ +#define AGROUP		0x20	/* ... was the last task of the process (task group) */  #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)  #define ACCT_BYTEORDER	0x80	/* accounting file is big endian */ diff --git a/include/uapi/linux/acrn.h b/include/uapi/linux/acrn.h new file mode 100644 index 000000000000..7b714c1902eb --- /dev/null +++ b/include/uapi/linux/acrn.h @@ -0,0 +1,649 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Userspace interface for /dev/acrn_hsm - ACRN Hypervisor Service Module + * + * This file can be used by applications that need to communicate with the HSM + * via the ioctl interface. + * + * Copyright (C) 2021 Intel Corporation. All rights reserved. + */ + +#ifndef _UAPI_ACRN_H +#define _UAPI_ACRN_H + +#include <linux/types.h> + +#define ACRN_IO_REQUEST_MAX		16 + +#define ACRN_IOREQ_STATE_PENDING	0 +#define ACRN_IOREQ_STATE_COMPLETE	1 +#define ACRN_IOREQ_STATE_PROCESSING	2 +#define ACRN_IOREQ_STATE_FREE		3 + +#define ACRN_IOREQ_TYPE_PORTIO		0 +#define ACRN_IOREQ_TYPE_MMIO		1 +#define ACRN_IOREQ_TYPE_PCICFG		2 + +#define ACRN_IOREQ_DIR_READ		0 +#define ACRN_IOREQ_DIR_WRITE		1 + +/** + * struct acrn_mmio_request - Info of a MMIO I/O request + * @direction:	Access direction of this request (ACRN_IOREQ_DIR_*) + * @reserved:	Reserved for alignment and should be 0 + * @address:	Access address of this MMIO I/O request + * @size:	Access size of this MMIO I/O request + * @value:	Read/write value of this MMIO I/O request + */ +struct acrn_mmio_request { +	__u32	direction; +	__u32	reserved; +	__u64	address; +	__u64	size; +	__u64	value; +}; + +/** + * struct acrn_pio_request - Info of a PIO I/O request + * @direction:	Access direction of this request (ACRN_IOREQ_DIR_*) + * @reserved:	Reserved for alignment and should be 0 + * @address:	Access address of this PIO I/O request + * @size:	Access size of this PIO I/O request + * @value:	Read/write value of this PIO I/O request + */ +struct acrn_pio_request { +	__u32	direction; +	__u32	reserved; +	__u64	address; +	__u64	size; +	__u32	value; +}; + +/** + * struct acrn_pci_request - Info of a PCI I/O request + * @direction:	Access direction of this request (ACRN_IOREQ_DIR_*) + * @reserved:	Reserved for alignment and should be 0 + * @size:	Access size of this PCI I/O request + * @value:	Read/write value of this PIO I/O request + * @bus:	PCI bus value of this PCI I/O request + * @dev:	PCI device value of this PCI I/O request + * @func:	PCI function value of this PCI I/O request + * @reg:	PCI config space offset of this PCI I/O request + * + * Need keep same header layout with &struct acrn_pio_request. + */ +struct acrn_pci_request { +	__u32	direction; +	__u32	reserved[3]; +	__u64	size; +	__u32	value; +	__u32	bus; +	__u32	dev; +	__u32	func; +	__u32	reg; +}; + +/** + * struct acrn_io_request - 256-byte ACRN I/O request + * @type:		Type of this request (ACRN_IOREQ_TYPE_*). + * @completion_polling:	Polling flag. Hypervisor will poll completion of the + *			I/O request if this flag set. + * @reserved0:		Reserved fields. + * @reqs:		Union of different types of request. Byte offset: 64. + * @reqs.pio_request:	PIO request data of the I/O request. + * @reqs.pci_request:	PCI configuration space request data of the I/O request. + * @reqs.mmio_request:	MMIO request data of the I/O request. + * @reqs.data:		Raw data of the I/O request. + * @reserved1:		Reserved fields. + * @kernel_handled:	Flag indicates this request need be handled in kernel. + * @processed:		The status of this request (ACRN_IOREQ_STATE_*). + * + * The state transitions of ACRN I/O request: + * + *    FREE -> PENDING -> PROCESSING -> COMPLETE -> FREE -> ... + * + * An I/O request in COMPLETE or FREE state is owned by the hypervisor. HSM and + * ACRN userspace are in charge of processing the others. + * + * On basis of the states illustrated above, a typical lifecycle of ACRN IO + * request would look like: + * + * Flow                 (assume the initial state is FREE) + * | + * |   Service VM vCPU 0     Service VM vCPU x      User vCPU y + * | + * |                                             hypervisor: + * |                                               fills in type, addr, etc. + * |                                               pauses the User VM vCPU y + * |                                               sets the state to PENDING (a) + * |                                               fires an upcall to Service VM + * | + * | HSM: + * |  scans for PENDING requests + * |  sets the states to PROCESSING (b) + * |  assigns the requests to clients (c) + * V + * |                     client: + * |                       scans for the assigned requests + * |                       handles the requests (d) + * |                     HSM: + * |                       sets states to COMPLETE + * |                       notifies the hypervisor + * | + * |                     hypervisor: + * |                       resumes User VM vCPU y (e) + * | + * |                                             hypervisor: + * |                                               post handling (f) + * V                                               sets states to FREE + * + * Note that the procedures (a) to (f) in the illustration above require to be + * strictly processed in the order.  One vCPU cannot trigger another request of + * I/O emulation before completing the previous one. + * + * Atomic and barriers are required when HSM and hypervisor accessing the state + * of &struct acrn_io_request. + * + */ +struct acrn_io_request { +	__u32	type; +	__u32	completion_polling; +	__u32	reserved0[14]; +	union { +		struct acrn_pio_request		pio_request; +		struct acrn_pci_request		pci_request; +		struct acrn_mmio_request	mmio_request; +		__u64				data[8]; +	} reqs; +	__u32	reserved1; +	__u32	kernel_handled; +	__u32	processed; +} __attribute__((aligned(256))); + +struct acrn_io_request_buffer { +	union { +		struct acrn_io_request	req_slot[ACRN_IO_REQUEST_MAX]; +		__u8			reserved[4096]; +	}; +}; + +/** + * struct acrn_ioreq_notify - The structure of ioreq completion notification + * @vmid:	User VM ID + * @reserved:	Reserved and should be 0 + * @vcpu:	vCPU ID + */ +struct acrn_ioreq_notify { +	__u16	vmid; +	__u16	reserved; +	__u32	vcpu; +}; + +/** + * struct acrn_vm_creation - Info to create a User VM + * @vmid:		User VM ID returned from the hypervisor + * @reserved0:		Reserved and must be 0 + * @vcpu_num:		Number of vCPU in the VM. Return from hypervisor. + * @reserved1:		Reserved and must be 0 + * @uuid:		Empty space never to be used again (used to be UUID of the VM) + * @vm_flag:		Flag of the VM creating. Pass to hypervisor directly. + * @ioreq_buf:		Service VM GPA of I/O request buffer. Pass to + *			hypervisor directly. + * @cpu_affinity:	CPU affinity of the VM. Pass to hypervisor directly. + * 			It's a bitmap which indicates CPUs used by the VM. + */ +struct acrn_vm_creation { +	__u16	vmid; +	__u16	reserved0; +	__u16	vcpu_num; +	__u16	reserved1; +	__u8	uuid[16]; +	__u64	vm_flag; +	__u64	ioreq_buf; +	__u64	cpu_affinity; +}; + +/** + * struct acrn_gp_regs - General registers of a User VM + * @rax:	Value of register RAX + * @rcx:	Value of register RCX + * @rdx:	Value of register RDX + * @rbx:	Value of register RBX + * @rsp:	Value of register RSP + * @rbp:	Value of register RBP + * @rsi:	Value of register RSI + * @rdi:	Value of register RDI + * @r8:		Value of register R8 + * @r9:		Value of register R9 + * @r10:	Value of register R10 + * @r11:	Value of register R11 + * @r12:	Value of register R12 + * @r13:	Value of register R13 + * @r14:	Value of register R14 + * @r15:	Value of register R15 + */ +struct acrn_gp_regs { +	__le64	rax; +	__le64	rcx; +	__le64	rdx; +	__le64	rbx; +	__le64	rsp; +	__le64	rbp; +	__le64	rsi; +	__le64	rdi; +	__le64	r8; +	__le64	r9; +	__le64	r10; +	__le64	r11; +	__le64	r12; +	__le64	r13; +	__le64	r14; +	__le64	r15; +}; + +/** + * struct acrn_descriptor_ptr - Segment descriptor table of a User VM. + * @limit:	Limit field. + * @base:	Base field. + * @reserved:	Reserved and must be 0. + */ +struct acrn_descriptor_ptr { +	__le16	limit; +	__le64	base; +	__le16	reserved[3]; +} __attribute__ ((__packed__)); + +/** + * struct acrn_regs - Registers structure of a User VM + * @gprs:		General registers + * @gdt:		Global Descriptor Table + * @idt:		Interrupt Descriptor Table + * @rip:		Value of register RIP + * @cs_base:		Base of code segment selector + * @cr0:		Value of register CR0 + * @cr4:		Value of register CR4 + * @cr3:		Value of register CR3 + * @ia32_efer:		Value of IA32_EFER MSR + * @rflags:		Value of regsiter RFLAGS + * @reserved_64:	Reserved and must be 0 + * @cs_ar:		Attribute field of code segment selector + * @cs_limit:		Limit field of code segment selector + * @reserved_32:	Reserved and must be 0 + * @cs_sel:		Value of code segment selector + * @ss_sel:		Value of stack segment selector + * @ds_sel:		Value of data segment selector + * @es_sel:		Value of extra segment selector + * @fs_sel:		Value of FS selector + * @gs_sel:		Value of GS selector + * @ldt_sel:		Value of LDT descriptor selector + * @tr_sel:		Value of TSS descriptor selector + */ +struct acrn_regs { +	struct acrn_gp_regs		gprs; +	struct acrn_descriptor_ptr	gdt; +	struct acrn_descriptor_ptr	idt; + +	__le64				rip; +	__le64				cs_base; +	__le64				cr0; +	__le64				cr4; +	__le64				cr3; +	__le64				ia32_efer; +	__le64				rflags; +	__le64				reserved_64[4]; + +	__le32				cs_ar; +	__le32				cs_limit; +	__le32				reserved_32[3]; + +	__le16				cs_sel; +	__le16				ss_sel; +	__le16				ds_sel; +	__le16				es_sel; +	__le16				fs_sel; +	__le16				gs_sel; +	__le16				ldt_sel; +	__le16				tr_sel; +}; + +/** + * struct acrn_vcpu_regs - Info of vCPU registers state + * @vcpu_id:	vCPU ID + * @reserved:	Reserved and must be 0 + * @vcpu_regs:	vCPU registers state + * + * This structure will be passed to hypervisor directly. + */ +struct acrn_vcpu_regs { +	__u16			vcpu_id; +	__u16			reserved[3]; +	struct acrn_regs	vcpu_regs; +}; + +#define	ACRN_MEM_ACCESS_RIGHT_MASK	0x00000007U +#define	ACRN_MEM_ACCESS_READ		0x00000001U +#define	ACRN_MEM_ACCESS_WRITE		0x00000002U +#define	ACRN_MEM_ACCESS_EXEC		0x00000004U +#define	ACRN_MEM_ACCESS_RWX		(ACRN_MEM_ACCESS_READ  | \ +					 ACRN_MEM_ACCESS_WRITE | \ +					 ACRN_MEM_ACCESS_EXEC) + +#define	ACRN_MEM_TYPE_MASK		0x000007C0U +#define	ACRN_MEM_TYPE_WB		0x00000040U +#define	ACRN_MEM_TYPE_WT		0x00000080U +#define	ACRN_MEM_TYPE_UC		0x00000100U +#define	ACRN_MEM_TYPE_WC		0x00000200U +#define	ACRN_MEM_TYPE_WP		0x00000400U + +/* Memory mapping types */ +#define	ACRN_MEMMAP_RAM			0 +#define	ACRN_MEMMAP_MMIO		1 + +/** + * struct acrn_vm_memmap - A EPT memory mapping info for a User VM. + * @type:		Type of the memory mapping (ACRM_MEMMAP_*). + *			Pass to hypervisor directly. + * @attr:		Attribute of the memory mapping. + *			Pass to hypervisor directly. + * @user_vm_pa:		Physical address of User VM. + *			Pass to hypervisor directly. + * @service_vm_pa:	Physical address of Service VM. + *			Pass to hypervisor directly. + * @vma_base:		VMA address of Service VM. Pass to hypervisor directly. + * @len:		Length of the memory mapping. + *			Pass to hypervisor directly. + */ +struct acrn_vm_memmap { +	__u32	type; +	__u32	attr; +	__u64	user_vm_pa; +	union { +		__u64	service_vm_pa; +		__u64	vma_base; +	}; +	__u64	len; +}; + +/* Type of interrupt of a passthrough device */ +#define ACRN_PTDEV_IRQ_INTX	0 +#define ACRN_PTDEV_IRQ_MSI	1 +#define ACRN_PTDEV_IRQ_MSIX	2 +/** + * struct acrn_ptdev_irq - Interrupt data of a passthrough device. + * @type:		Type (ACRN_PTDEV_IRQ_*) + * @virt_bdf:		Virtual Bus/Device/Function + * @phys_bdf:		Physical Bus/Device/Function + * @intx:		Info of interrupt + * @intx.virt_pin:	Virtual IOAPIC pin + * @intx.phys_pin:	Physical IOAPIC pin + * @intx.is_pic_pin:	Is PIC pin or not + * + * This structure will be passed to hypervisor directly. + */ +struct acrn_ptdev_irq { +	__u32	type; +	__u16	virt_bdf; +	__u16	phys_bdf; + +	struct { +		__u32	virt_pin; +		__u32	phys_pin; +		__u32	is_pic_pin; +	} intx; +}; + +/* Type of PCI device assignment */ +#define ACRN_PTDEV_QUIRK_ASSIGN	(1U << 0) + +#define ACRN_MMIODEV_RES_NUM	3 +#define ACRN_PCI_NUM_BARS	6 +/** + * struct acrn_pcidev - Info for assigning or de-assigning a PCI device + * @type:	Type of the assignment + * @virt_bdf:	Virtual Bus/Device/Function + * @phys_bdf:	Physical Bus/Device/Function + * @intr_line:	PCI interrupt line + * @intr_pin:	PCI interrupt pin + * @bar:	PCI BARs. + * + * This structure will be passed to hypervisor directly. + */ +struct acrn_pcidev { +	__u32	type; +	__u16	virt_bdf; +	__u16	phys_bdf; +	__u8	intr_line; +	__u8	intr_pin; +	__u32	bar[ACRN_PCI_NUM_BARS]; +}; + +/** + * struct acrn_mmiodev - Info for assigning or de-assigning a MMIO device + * @name:			Name of the MMIO device. + * @res[].user_vm_pa:		Physical address of User VM of the MMIO region + *				for the MMIO device. + * @res[].service_vm_pa:	Physical address of Service VM of the MMIO + *				region for the MMIO device. + * @res[].size:			Size of the MMIO region for the MMIO device. + * @res[].mem_type:		Memory type of the MMIO region for the MMIO + *				device. + * + * This structure will be passed to hypervisor directly. + */ +struct acrn_mmiodev { +	__u8	name[8]; +	struct { +		__u64	user_vm_pa; +		__u64	service_vm_pa; +		__u64	size; +		__u64	mem_type; +	} res[ACRN_MMIODEV_RES_NUM]; +}; + +/** + * struct acrn_vdev - Info for creating or destroying a virtual device + * @id:				Union of identifier of the virtual device + * @id.value:			Raw data of the identifier + * @id.fields.vendor:		Vendor id of the virtual PCI device + * @id.fields.device:		Device id of the virtual PCI device + * @id.fields.legacy_id:	ID of the virtual device if not a PCI device + * @slot:			Virtual Bus/Device/Function of the virtual + *				device + * @io_base:			IO resource base address of the virtual device + * @io_size:			IO resource size of the virtual device + * @args:			Arguments for the virtual device creation + * + * The created virtual device can be a PCI device or a legacy device (e.g. + * a virtual UART controller) and it is emulated by the hypervisor. This + * structure will be passed to hypervisor directly. + */ +struct acrn_vdev { +	/* +	 * the identifier of the device, the low 32 bits represent the vendor +	 * id and device id of PCI device and the high 32 bits represent the +	 * device number of the legacy device +	 */ +	union { +		__u64 value; +		struct { +			__le16 vendor; +			__le16 device; +			__le32 legacy_id; +		} fields; +	} id; + +	__u64	slot; +	__u32	io_addr[ACRN_PCI_NUM_BARS]; +	__u32	io_size[ACRN_PCI_NUM_BARS]; +	__u8	args[128]; +}; + +/** + * struct acrn_msi_entry - Info for injecting a MSI interrupt to a VM + * @msi_addr:	MSI addr[19:12] with dest vCPU ID + * @msi_data:	MSI data[7:0] with vector + */ +struct acrn_msi_entry { +	__u64	msi_addr; +	__u64	msi_data; +}; + +struct acrn_acpi_generic_address { +	__u8	space_id; +	__u8	bit_width; +	__u8	bit_offset; +	__u8	access_size; +	__u64	address; +} __attribute__ ((__packed__)); + +/** + * struct acrn_cstate_data - A C state package defined in ACPI + * @cx_reg:	Register of the C state object + * @type:	Type of the C state object + * @latency:	The worst-case latency to enter and exit this C state + * @power:	The average power consumption when in this C state + */ +struct acrn_cstate_data { +	struct acrn_acpi_generic_address	cx_reg; +	__u8					type; +	__u32					latency; +	__u64					power; +}; + +/** + * struct acrn_pstate_data - A P state package defined in ACPI + * @core_frequency:	CPU frequency (in MHz). + * @power:		Power dissipation (in milliwatts). + * @transition_latency:	The worst-case latency in microseconds that CPU is + * 			unavailable during a transition from any P state to + * 			this P state. + * @bus_master_latency:	The worst-case latency in microseconds that Bus Masters + * 			are prevented from accessing memory during a transition + * 			from any P state to this P state. + * @control:		The value to be written to Performance Control Register + * @status:		Transition status. + */ +struct acrn_pstate_data { +	__u64	core_frequency; +	__u64	power; +	__u64	transition_latency; +	__u64	bus_master_latency; +	__u64	control; +	__u64	status; +}; + +#define PMCMD_TYPE_MASK		0x000000ff +enum acrn_pm_cmd_type { +	ACRN_PMCMD_GET_PX_CNT, +	ACRN_PMCMD_GET_PX_DATA, +	ACRN_PMCMD_GET_CX_CNT, +	ACRN_PMCMD_GET_CX_DATA, +}; + +#define ACRN_IOEVENTFD_FLAG_PIO		0x01 +#define ACRN_IOEVENTFD_FLAG_DATAMATCH	0x02 +#define ACRN_IOEVENTFD_FLAG_DEASSIGN	0x04 +/** + * struct acrn_ioeventfd - Data to operate a &struct hsm_ioeventfd + * @fd:		The fd of eventfd associated with a hsm_ioeventfd + * @flags:	Logical-OR of ACRN_IOEVENTFD_FLAG_* + * @addr:	The start address of IO range of ioeventfd + * @len:	The length of IO range of ioeventfd + * @reserved:	Reserved and should be 0 + * @data:	Data for data matching + * + * Without flag ACRN_IOEVENTFD_FLAG_DEASSIGN, ioctl ACRN_IOCTL_IOEVENTFD + * creates a &struct hsm_ioeventfd with properties originated from &struct + * acrn_ioeventfd. With flag ACRN_IOEVENTFD_FLAG_DEASSIGN, ioctl + * ACRN_IOCTL_IOEVENTFD destroys the &struct hsm_ioeventfd matching the fd. + */ +struct acrn_ioeventfd { +	__u32	fd; +	__u32	flags; +	__u64	addr; +	__u32	len; +	__u32	reserved; +	__u64	data; +}; + +#define ACRN_IRQFD_FLAG_DEASSIGN	0x01 +/** + * struct acrn_irqfd - Data to operate a &struct hsm_irqfd + * @fd:		The fd of eventfd associated with a hsm_irqfd + * @flags:	Logical-OR of ACRN_IRQFD_FLAG_* + * @msi:	Info of MSI associated with the irqfd + */ +struct acrn_irqfd { +	__s32			fd; +	__u32			flags; +	struct acrn_msi_entry	msi; +}; + +/* The ioctl type, documented in ioctl-number.rst */ +#define ACRN_IOCTL_TYPE			0xA2 + +/* + * Common IOCTL IDs definition for ACRN userspace + */ +#define ACRN_IOCTL_CREATE_VM		\ +	_IOWR(ACRN_IOCTL_TYPE, 0x10, struct acrn_vm_creation) +#define ACRN_IOCTL_DESTROY_VM		\ +	_IO(ACRN_IOCTL_TYPE, 0x11) +#define ACRN_IOCTL_START_VM		\ +	_IO(ACRN_IOCTL_TYPE, 0x12) +#define ACRN_IOCTL_PAUSE_VM		\ +	_IO(ACRN_IOCTL_TYPE, 0x13) +#define ACRN_IOCTL_RESET_VM		\ +	_IO(ACRN_IOCTL_TYPE, 0x15) +#define ACRN_IOCTL_SET_VCPU_REGS	\ +	_IOW(ACRN_IOCTL_TYPE, 0x16, struct acrn_vcpu_regs) + +#define ACRN_IOCTL_INJECT_MSI		\ +	_IOW(ACRN_IOCTL_TYPE, 0x23, struct acrn_msi_entry) +#define ACRN_IOCTL_VM_INTR_MONITOR	\ +	_IOW(ACRN_IOCTL_TYPE, 0x24, unsigned long) +#define ACRN_IOCTL_SET_IRQLINE		\ +	_IOW(ACRN_IOCTL_TYPE, 0x25, __u64) + +#define ACRN_IOCTL_NOTIFY_REQUEST_FINISH \ +	_IOW(ACRN_IOCTL_TYPE, 0x31, struct acrn_ioreq_notify) +#define ACRN_IOCTL_CREATE_IOREQ_CLIENT	\ +	_IO(ACRN_IOCTL_TYPE, 0x32) +#define ACRN_IOCTL_ATTACH_IOREQ_CLIENT	\ +	_IO(ACRN_IOCTL_TYPE, 0x33) +#define ACRN_IOCTL_DESTROY_IOREQ_CLIENT	\ +	_IO(ACRN_IOCTL_TYPE, 0x34) +#define ACRN_IOCTL_CLEAR_VM_IOREQ	\ +	_IO(ACRN_IOCTL_TYPE, 0x35) + +#define ACRN_IOCTL_SET_MEMSEG		\ +	_IOW(ACRN_IOCTL_TYPE, 0x41, struct acrn_vm_memmap) +#define ACRN_IOCTL_UNSET_MEMSEG		\ +	_IOW(ACRN_IOCTL_TYPE, 0x42, struct acrn_vm_memmap) + +#define ACRN_IOCTL_SET_PTDEV_INTR	\ +	_IOW(ACRN_IOCTL_TYPE, 0x53, struct acrn_ptdev_irq) +#define ACRN_IOCTL_RESET_PTDEV_INTR	\ +	_IOW(ACRN_IOCTL_TYPE, 0x54, struct acrn_ptdev_irq) +#define ACRN_IOCTL_ASSIGN_PCIDEV	\ +	_IOW(ACRN_IOCTL_TYPE, 0x55, struct acrn_pcidev) +#define ACRN_IOCTL_DEASSIGN_PCIDEV	\ +	_IOW(ACRN_IOCTL_TYPE, 0x56, struct acrn_pcidev) +#define ACRN_IOCTL_ASSIGN_MMIODEV	\ +	_IOW(ACRN_IOCTL_TYPE, 0x57, struct acrn_mmiodev) +#define ACRN_IOCTL_DEASSIGN_MMIODEV	\ +	_IOW(ACRN_IOCTL_TYPE, 0x58, struct acrn_mmiodev) +#define ACRN_IOCTL_CREATE_VDEV	\ +	_IOW(ACRN_IOCTL_TYPE, 0x59, struct acrn_vdev) +#define ACRN_IOCTL_DESTROY_VDEV	\ +	_IOW(ACRN_IOCTL_TYPE, 0x5A, struct acrn_vdev) + +#define ACRN_IOCTL_PM_GET_CPU_STATE	\ +	_IOWR(ACRN_IOCTL_TYPE, 0x60, __u64) + +#define ACRN_IOCTL_IOEVENTFD		\ +	_IOW(ACRN_IOCTL_TYPE, 0x70, struct acrn_ioeventfd) +#define ACRN_IOCTL_IRQFD		\ +	_IOW(ACRN_IOCTL_TYPE, 0x71, struct acrn_irqfd) + +#endif /* _UAPI_ACRN_H */ diff --git a/include/uapi/linux/affs_hardblocks.h b/include/uapi/linux/affs_hardblocks.h index 5e2fb8481252..a5aff2eb5f70 100644 --- a/include/uapi/linux/affs_hardblocks.h +++ b/include/uapi/linux/affs_hardblocks.h @@ -7,42 +7,42 @@  /* Just the needed definitions for the RDB of an Amiga HD. */  struct RigidDiskBlock { -	__u32	rdb_ID; +	__be32	rdb_ID;  	__be32	rdb_SummedLongs; -	__s32	rdb_ChkSum; -	__u32	rdb_HostID; +	__be32	rdb_ChkSum; +	__be32	rdb_HostID;  	__be32	rdb_BlockBytes; -	__u32	rdb_Flags; -	__u32	rdb_BadBlockList; +	__be32	rdb_Flags; +	__be32	rdb_BadBlockList;  	__be32	rdb_PartitionList; -	__u32	rdb_FileSysHeaderList; -	__u32	rdb_DriveInit; -	__u32	rdb_Reserved1[6]; -	__u32	rdb_Cylinders; -	__u32	rdb_Sectors; -	__u32	rdb_Heads; -	__u32	rdb_Interleave; -	__u32	rdb_Park; -	__u32	rdb_Reserved2[3]; -	__u32	rdb_WritePreComp; -	__u32	rdb_ReducedWrite; -	__u32	rdb_StepRate; -	__u32	rdb_Reserved3[5]; -	__u32	rdb_RDBBlocksLo; -	__u32	rdb_RDBBlocksHi; -	__u32	rdb_LoCylinder; -	__u32	rdb_HiCylinder; -	__u32	rdb_CylBlocks; -	__u32	rdb_AutoParkSeconds; -	__u32	rdb_HighRDSKBlock; -	__u32	rdb_Reserved4; +	__be32	rdb_FileSysHeaderList; +	__be32	rdb_DriveInit; +	__be32	rdb_Reserved1[6]; +	__be32	rdb_Cylinders; +	__be32	rdb_Sectors; +	__be32	rdb_Heads; +	__be32	rdb_Interleave; +	__be32	rdb_Park; +	__be32	rdb_Reserved2[3]; +	__be32	rdb_WritePreComp; +	__be32	rdb_ReducedWrite; +	__be32	rdb_StepRate; +	__be32	rdb_Reserved3[5]; +	__be32	rdb_RDBBlocksLo; +	__be32	rdb_RDBBlocksHi; +	__be32	rdb_LoCylinder; +	__be32	rdb_HiCylinder; +	__be32	rdb_CylBlocks; +	__be32	rdb_AutoParkSeconds; +	__be32	rdb_HighRDSKBlock; +	__be32	rdb_Reserved4;  	char	rdb_DiskVendor[8];  	char	rdb_DiskProduct[16];  	char	rdb_DiskRevision[4];  	char	rdb_ControllerVendor[8];  	char	rdb_ControllerProduct[16];  	char	rdb_ControllerRevision[4]; -	__u32	rdb_Reserved5[10]; +	__be32	rdb_Reserved5[10];  };  #define	IDNAME_RIGIDDISK	0x5244534B	/* "RDSK" */ @@ -50,16 +50,16 @@ struct RigidDiskBlock {  struct PartitionBlock {  	__be32	pb_ID;  	__be32	pb_SummedLongs; -	__s32	pb_ChkSum; -	__u32	pb_HostID; +	__be32	pb_ChkSum; +	__be32	pb_HostID;  	__be32	pb_Next; -	__u32	pb_Flags; -	__u32	pb_Reserved1[2]; -	__u32	pb_DevFlags; +	__be32	pb_Flags; +	__be32	pb_Reserved1[2]; +	__be32	pb_DevFlags;  	__u8	pb_DriveName[32]; -	__u32	pb_Reserved2[15]; +	__be32	pb_Reserved2[15];  	__be32	pb_Environment[17]; -	__u32	pb_EReserved[15]; +	__be32	pb_EReserved[15];  };  #define	IDNAME_PARTITION	0x50415254	/* "PART" */ diff --git a/include/uapi/linux/agpgart.h b/include/uapi/linux/agpgart.h index f5251045181a..9cc3448c0b5b 100644 --- a/include/uapi/linux/agpgart.h +++ b/include/uapi/linux/agpgart.h @@ -52,7 +52,6 @@  #ifndef __KERNEL__  #include <linux/types.h> -#include <stdlib.h>  struct agp_version {  	__u16 major; @@ -64,10 +63,10 @@ typedef struct _agp_info {  	__u32 bridge_id;	/* bridge vendor/device         */  	__u32 agp_mode;		/* mode info of bridge          */  	unsigned long aper_base;/* base of aperture             */ -	size_t aper_size;	/* size of aperture             */ -	size_t pg_total;	/* max pages (swap + system)    */ -	size_t pg_system;	/* max pages (system)           */ -	size_t pg_used;		/* current pages used           */ +	__kernel_size_t aper_size;	/* size of aperture             */ +	__kernel_size_t pg_total;	/* max pages (swap + system)    */ +	__kernel_size_t pg_system;	/* max pages (system)           */ +	__kernel_size_t pg_used;	/* current pages used           */  } agp_info;  typedef struct _agp_setup { diff --git a/include/uapi/linux/amt.h b/include/uapi/linux/amt.h new file mode 100644 index 000000000000..2dccff417195 --- /dev/null +++ b/include/uapi/linux/amt.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * Copyright (c) 2021 Taehee Yoo <ap420073@gmail.com> + */ +#ifndef _UAPI_AMT_H_ +#define _UAPI_AMT_H_ + +enum ifla_amt_mode { +	/* AMT interface works as Gateway mode. +	 * The Gateway mode encapsulates IGMP/MLD traffic and decapsulates +	 * multicast traffic. +	 */ +	AMT_MODE_GATEWAY = 0, +	/* AMT interface works as Relay mode. +	 * The Relay mode encapsulates multicast traffic and decapsulates +	 * IGMP/MLD traffic. +	 */ +	AMT_MODE_RELAY, +	__AMT_MODE_MAX, +}; + +#define AMT_MODE_MAX (__AMT_MODE_MAX - 1) + +enum { +	IFLA_AMT_UNSPEC, +	/* This attribute specify mode etier Gateway or Relay. */ +	IFLA_AMT_MODE, +	/* This attribute specify Relay port. +	 * AMT interface is created as Gateway mode, this attribute is used +	 * to specify relay(remote) port. +	 * AMT interface is created as Relay mode, this attribute is used +	 * as local port. +	 */ +	IFLA_AMT_RELAY_PORT, +	/* This attribute specify Gateway port. +	 * AMT interface is created as Gateway mode, this attribute is used +	 * as local port. +	 * AMT interface is created as Relay mode, this attribute is not used. +	 */ +	IFLA_AMT_GATEWAY_PORT, +	/* This attribute specify physical device */ +	IFLA_AMT_LINK, +	/* This attribute specify local ip address */ +	IFLA_AMT_LOCAL_IP, +	/* This attribute specify Relay ip address. +	 * So, this is not used by Relay. +	 */ +	IFLA_AMT_REMOTE_IP, +	/* This attribute specify Discovery ip address. +	 * When Gateway get started, it send discovery message to find the +	 * Relay's ip address. +	 * So, this is not used by Relay. +	 */ +	IFLA_AMT_DISCOVERY_IP, +	/* This attribute specify number of maximum tunnel. */ +	IFLA_AMT_MAX_TUNNELS, +	__IFLA_AMT_MAX, +}; + +#define IFLA_AMT_MAX (__IFLA_AMT_MAX - 1) + +#endif /* _UAPI_AMT_H_ */ diff --git a/include/uapi/linux/android/binder.h b/include/uapi/linux/android/binder.h index f1ce2c4c077e..1fd92021a573 100644 --- a/include/uapi/linux/android/binder.h +++ b/include/uapi/linux/android/binder.h @@ -217,16 +217,62 @@ struct binder_node_info_for_ref {  	__u32            reserved3;  }; -#define BINDER_WRITE_READ		_IOWR('b', 1, struct binder_write_read) -#define BINDER_SET_IDLE_TIMEOUT		_IOW('b', 3, __s64) -#define BINDER_SET_MAX_THREADS		_IOW('b', 5, __u32) -#define BINDER_SET_IDLE_PRIORITY	_IOW('b', 6, __s32) -#define BINDER_SET_CONTEXT_MGR		_IOW('b', 7, __s32) -#define BINDER_THREAD_EXIT		_IOW('b', 8, __s32) -#define BINDER_VERSION			_IOWR('b', 9, struct binder_version) -#define BINDER_GET_NODE_DEBUG_INFO	_IOWR('b', 11, struct binder_node_debug_info) -#define BINDER_GET_NODE_INFO_FOR_REF	_IOWR('b', 12, struct binder_node_info_for_ref) -#define BINDER_SET_CONTEXT_MGR_EXT	_IOW('b', 13, struct flat_binder_object) +struct binder_freeze_info { +	__u32            pid; +	__u32            enable; +	__u32            timeout_ms; +}; + +struct binder_frozen_status_info { +	__u32            pid; + +	/* process received sync transactions since last frozen +	 * bit 0: received sync transaction after being frozen +	 * bit 1: new pending sync transaction during freezing +	 */ +	__u32            sync_recv; + +	/* process received async transactions since last frozen */ +	__u32            async_recv; +}; + +struct binder_frozen_state_info { +	binder_uintptr_t cookie; +	__u32            is_frozen; +	__u32            reserved; +}; + +/* struct binder_extened_error - extended error information + * @id:		identifier for the failed operation + * @command:	command as defined by binder_driver_return_protocol + * @param:	parameter holding a negative errno value + * + * Used with BINDER_GET_EXTENDED_ERROR. This extends the error information + * returned by the driver upon a failed operation. Userspace can pull this + * data to properly handle specific error scenarios. + */ +struct binder_extended_error { +	__u32	id; +	__u32	command; +	__s32	param; +}; + +enum { +	BINDER_WRITE_READ		= _IOWR('b', 1, struct binder_write_read), +	BINDER_SET_IDLE_TIMEOUT		= _IOW('b', 3, __s64), +	BINDER_SET_MAX_THREADS		= _IOW('b', 5, __u32), +	BINDER_SET_IDLE_PRIORITY	= _IOW('b', 6, __s32), +	BINDER_SET_CONTEXT_MGR		= _IOW('b', 7, __s32), +	BINDER_THREAD_EXIT		= _IOW('b', 8, __s32), +	BINDER_VERSION			= _IOWR('b', 9, struct binder_version), +	BINDER_GET_NODE_DEBUG_INFO	= _IOWR('b', 11, struct binder_node_debug_info), +	BINDER_GET_NODE_INFO_FOR_REF	= _IOWR('b', 12, struct binder_node_info_for_ref), +	BINDER_SET_CONTEXT_MGR_EXT	= _IOW('b', 13, struct flat_binder_object), +	BINDER_FREEZE			= _IOW('b', 14, struct binder_freeze_info), +	BINDER_GET_FROZEN_INFO		= _IOWR('b', 15, struct binder_frozen_status_info), +	BINDER_ENABLE_ONEWAY_SPAM_DETECTION	= _IOW('b', 16, __u32), +	BINDER_GET_EXTENDED_ERROR	= _IOWR('b', 17, struct binder_extended_error), +};  /*   * NOTE: Two special error codes you should check for when calling @@ -248,6 +294,8 @@ enum transaction_flags {  	TF_ROOT_OBJECT	= 0x04,	/* contents are the component's root object */  	TF_STATUS_CODE	= 0x08,	/* contents are a 32-bit status code */  	TF_ACCEPT_FDS	= 0x10,	/* allow replies with file descriptors */ +	TF_CLEAR_BUF	= 0x20,	/* clear buffer on txn complete */ +	TF_UPDATE_TXN	= 0x40,	/* update the outdated pending async txn */  };  struct binder_transaction_data { @@ -265,8 +313,8 @@ struct binder_transaction_data {  	/* General information about the transaction. */  	__u32	        flags; -	pid_t		sender_pid; -	uid_t		sender_euid; +	__kernel_pid_t	sender_pid; +	__kernel_uid32_t	sender_euid;  	binder_size_t	data_size;	/* number of bytes of data */  	binder_size_t	offsets_size;	/* number of bytes of offsets */ @@ -407,6 +455,35 @@ enum binder_driver_return_protocol {  	 * The last transaction (either a bcTRANSACTION or  	 * a bcATTEMPT_ACQUIRE) failed (e.g. out of memory).  No parameters.  	 */ + +	BR_FROZEN_REPLY = _IO('r', 18), +	/* +	 * The target of the last sync transaction (either a bcTRANSACTION or +	 * a bcATTEMPT_ACQUIRE) is frozen.  No parameters. +	 */ + +	BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19), +	/* +	 * Current process sent too many oneway calls to target, and the last +	 * asynchronous transaction makes the allocated async buffer size exceed +	 * detection threshold.  No parameters. +	 */ + +	BR_TRANSACTION_PENDING_FROZEN = _IO('r', 20), +	/* +	 * The target of the last async transaction is frozen.  No parameters. +	 */ + +	BR_FROZEN_BINDER = _IOR('r', 21, struct binder_frozen_state_info), +	/* +	 * The cookie and a boolean (is_frozen) that indicates whether the process +	 * transitioned into a frozen or an unfrozen state. +	 */ + +	BR_CLEAR_FREEZE_NOTIFICATION_DONE = _IOR('r', 22, binder_uintptr_t), +	/* +	 * void *: cookie +	 */  };  enum binder_driver_command_protocol { @@ -490,6 +567,25 @@ enum binder_driver_command_protocol {  	/*  	 * binder_transaction_data_sg: the sent command.  	 */ + +	BC_REQUEST_FREEZE_NOTIFICATION = +			_IOW('c', 19, struct binder_handle_cookie), +	/* +	 * int: handle +	 * void *: cookie +	 */ + +	BC_CLEAR_FREEZE_NOTIFICATION = _IOW('c', 20, +					    struct binder_handle_cookie), +	/* +	 * int: handle +	 * void *: cookie +	 */ + +	BC_FREEZE_NOTIFICATION_DONE = _IOW('c', 21, binder_uintptr_t), +	/* +	 * void *: cookie +	 */  };  #endif /* _UAPI_LINUX_BINDER_H */ diff --git a/include/uapi/linux/aspeed-video.h b/include/uapi/linux/aspeed-video.h new file mode 100644 index 000000000000..6586a65548c4 --- /dev/null +++ b/include/uapi/linux/aspeed-video.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Copyright (C) 2021 ASPEED Technology Inc. + */ + +#ifndef _UAPI_LINUX_ASPEED_VIDEO_H +#define _UAPI_LINUX_ASPEED_VIDEO_H + +#include <linux/v4l2-controls.h> + +#define V4L2_CID_ASPEED_HQ_MODE			(V4L2_CID_USER_ASPEED_BASE  + 1) +#define V4L2_CID_ASPEED_HQ_JPEG_QUALITY		(V4L2_CID_USER_ASPEED_BASE  + 2) + +#endif /* _UAPI_LINUX_ASPEED_VIDEO_H */ diff --git a/include/uapi/linux/atmbr2684.h b/include/uapi/linux/atmbr2684.h index a9e2250cd720..d47c47d06f11 100644 --- a/include/uapi/linux/atmbr2684.h +++ b/include/uapi/linux/atmbr2684.h @@ -38,7 +38,7 @@   */  #define BR2684_ENCAPS_VC	(0)	/* VC-mux */  #define BR2684_ENCAPS_LLC	(1) -#define BR2684_ENCAPS_AUTODETECT (2)	/* Unsuported */ +#define BR2684_ENCAPS_AUTODETECT (2)	/* Unsupported */  /*   * Is this VC bridged or routed? diff --git a/include/uapi/linux/atmdev.h b/include/uapi/linux/atmdev.h index a5c15cf23bd7..20b0215084fc 100644 --- a/include/uapi/linux/atmdev.h +++ b/include/uapi/linux/atmdev.h @@ -101,10 +101,6 @@ struct atm_dev_stats {  					/* use backend to make new if */  #define ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct atm_iobuf)   					/* add party to p2mp call */ -#ifdef CONFIG_COMPAT -/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */ -#define COMPAT_ATM_ADDPARTY  	_IOW('a', ATMIOC_SPECIAL+4,struct compat_atm_iobuf) -#endif  #define ATM_DROPPARTY 	_IOW('a', ATMIOC_SPECIAL+5,int)  					/* drop party from p2mp call */ diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h index cd2d8279a5e4..9a4ecc9f6dc5 100644 --- a/include/uapi/linux/audit.h +++ b/include/uapi/linux/audit.h @@ -33,7 +33,7 @@   * 1100 - 1199 user space trusted application messages   * 1200 - 1299 messages internal to the audit daemon   * 1300 - 1399 audit event messages - * 1400 - 1499 SE Linux use + * 1400 - 1499 access control messages   * 1500 - 1599 kernel LSPP events   * 1600 - 1699 kernel crypto events   * 1700 - 1799 kernel anomaly records @@ -48,7 +48,7 @@   * 2500 - 2999 future user space (maybe integrity labels and related events)   *   * Messages from 1000-1199 are bi-directional. 1200-1299 & 2100 - 2999 are - * exclusively user space. 1300-2099 is kernel --> user space  + * exclusively user space. 1300-2099 is kernel --> user space   * communication.   */  #define AUDIT_GET		1000	/* Get status */ @@ -78,7 +78,7 @@  #define AUDIT_LAST_USER_MSG	1199  #define AUDIT_FIRST_USER_MSG2	2100	/* More user space messages */  #define AUDIT_LAST_USER_MSG2	2999 -  +  #define AUDIT_DAEMON_START      1200    /* Daemon startup record */  #define AUDIT_DAEMON_END        1201    /* Daemon normal stop record */  #define AUDIT_DAEMON_ABORT      1202    /* Daemon error stop record */ @@ -118,6 +118,10 @@  #define AUDIT_TIME_ADJNTPVAL	1333	/* NTP value adjustment */  #define AUDIT_BPF		1334	/* BPF subsystem */  #define AUDIT_EVENT_LISTENER	1335	/* Task joined multicast read socket */ +#define AUDIT_URINGOP		1336	/* io_uring operation */ +#define AUDIT_OPENAT2		1337	/* Record showing openat2 how args */ +#define AUDIT_DM_CTRL		1338	/* Device Mapper target control */ +#define AUDIT_DM_EVENT		1339	/* Device Mapper events */  #define AUDIT_AVC		1400	/* SE Linux avc denial or grant */  #define AUDIT_SELINUX_ERR	1401	/* Internal SE Linux Errors */ @@ -139,6 +143,11 @@  #define AUDIT_MAC_UNLBL_STCDEL	1417	/* NetLabel: del a static label */  #define AUDIT_MAC_CALIPSO_ADD	1418	/* NetLabel: add CALIPSO DOI entry */  #define AUDIT_MAC_CALIPSO_DEL	1419	/* NetLabel: del CALIPSO DOI entry */ +#define AUDIT_IPE_ACCESS	1420	/* IPE denial or grant */ +#define AUDIT_IPE_CONFIG_CHANGE	1421	/* IPE config change */ +#define AUDIT_IPE_POLICY_LOAD	1422	/* IPE policy load */ +#define AUDIT_LANDLOCK_ACCESS	1423	/* Landlock denial */ +#define AUDIT_LANDLOCK_DOMAIN	1424	/* Landlock domain status */  #define AUDIT_FIRST_KERN_ANOM_MSG   1700  #define AUDIT_LAST_KERN_ANOM_MSG    1799 @@ -154,6 +163,7 @@  #define AUDIT_INTEGRITY_RULE	    1805 /* policy rule */  #define AUDIT_INTEGRITY_EVM_XATTR   1806 /* New EVM-covered xattr */  #define AUDIT_INTEGRITY_POLICY_RULE 1807 /* IMA policy rules */ +#define AUDIT_INTEGRITY_USERSPACE   1808 /* Userspace enforced data integrity */  #define AUDIT_KERNEL		2000	/* Asynchronous audit record. NOT A REQUEST. */ @@ -166,8 +176,9 @@  #define AUDIT_FILTER_EXCLUDE	0x05	/* Apply rule before record creation */  #define AUDIT_FILTER_TYPE	AUDIT_FILTER_EXCLUDE /* obsolete misleading naming */  #define AUDIT_FILTER_FS		0x06	/* Apply rule at __audit_inode_child */ +#define AUDIT_FILTER_URING_EXIT	0x07	/* Apply rule at io_uring op exit */ -#define AUDIT_NR_FILTERS	7 +#define AUDIT_NR_FILTERS	8  #define AUDIT_FILTER_PREPEND	0x10	/* Prepend to front of list */ @@ -182,7 +193,7 @@  #define AUDIT_MAX_KEY_LEN  256  #define AUDIT_BITMASK_SIZE 64  #define AUDIT_WORD(nr) ((__u32)((nr)/32)) -#define AUDIT_BIT(nr)  (1 << ((nr) - AUDIT_WORD(nr)*32)) +#define AUDIT_BIT(nr)  (1U << ((nr) - AUDIT_WORD(nr)*32))  #define AUDIT_SYSCALL_CLASSES 16  #define AUDIT_CLASS_DIR_WRITE 0 @@ -434,6 +445,8 @@ enum {  #define AUDIT_ARCH_UNICORE	(EM_UNICORE|__AUDIT_ARCH_LE)  #define AUDIT_ARCH_X86_64	(EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)  #define AUDIT_ARCH_XTENSA	(EM_XTENSA) +#define AUDIT_ARCH_LOONGARCH32	(EM_LOONGARCH|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_LOONGARCH64	(EM_LOONGARCH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)  #define AUDIT_PERM_EXEC		1  #define AUDIT_PERM_WRITE	2 @@ -509,7 +522,7 @@ struct audit_rule_data {  	__u32		values[AUDIT_MAX_FIELDS];  	__u32		fieldflags[AUDIT_MAX_FIELDS];  	__u32		buflen;	/* total length of string fields */ -	char		buf[0];	/* string fields buffer */ +	char		buf[];	/* string fields buffer */  };  #endif /* _UAPI_LINUX_AUDIT_H_ */ diff --git a/include/uapi/linux/auto_dev-ioctl.h b/include/uapi/linux/auto_dev-ioctl.h index 62e625356dc8..08be539605fc 100644 --- a/include/uapi/linux/auto_dev-ioctl.h +++ b/include/uapi/linux/auto_dev-ioctl.h @@ -109,7 +109,7 @@ struct autofs_dev_ioctl {  		struct args_ismountpoint	ismountpoint;  	}; -	char path[0]; +	char path[];  };  static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in) diff --git a/include/uapi/linux/auto_fs.h b/include/uapi/linux/auto_fs.h index 1f7925afad2d..8081df849743 100644 --- a/include/uapi/linux/auto_fs.h +++ b/include/uapi/linux/auto_fs.h @@ -23,7 +23,7 @@  #define AUTOFS_MIN_PROTO_VERSION	3  #define AUTOFS_MAX_PROTO_VERSION	5 -#define AUTOFS_PROTO_SUBVERSION		5 +#define AUTOFS_PROTO_SUBVERSION		6  /*   * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed diff --git a/include/uapi/linux/auxvec.h b/include/uapi/linux/auxvec.h index abe5f2b6581b..cc61cb9b3e9a 100644 --- a/include/uapi/linux/auxvec.h +++ b/include/uapi/linux/auxvec.h @@ -30,8 +30,15 @@  				 * differ from AT_PLATFORM. */  #define AT_RANDOM 25	/* address of 16 random bytes */  #define AT_HWCAP2 26	/* extension of AT_HWCAP */ +#define AT_RSEQ_FEATURE_SIZE	27	/* rseq supported feature size */ +#define AT_RSEQ_ALIGN		28	/* rseq allocation alignment */ +#define AT_HWCAP3 29	/* extension of AT_HWCAP */ +#define AT_HWCAP4 30	/* extension of AT_HWCAP */  #define AT_EXECFN  31	/* filename of program */ +#ifndef AT_MINSIGSTKSZ +#define AT_MINSIGSTKSZ	51	/* minimal stack size for signal delivery */ +#endif  #endif /* _UAPI_LINUX_AUXVEC_H */ diff --git a/include/uapi/linux/batadv_packet.h b/include/uapi/linux/batadv_packet.h index 9c8604c5b5f6..439132a819ea 100644 --- a/include/uapi/linux/batadv_packet.h +++ b/include/uapi/linux/batadv_packet.h @@ -1,5 +1,5 @@  /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) */ -/* Copyright (C) 2007-2020  B.A.T.M.A.N. contributors: +/* Copyright (C) B.A.T.M.A.N. contributors:   *   * Marek Lindner, Simon Wunderlich   */ @@ -9,6 +9,7 @@  #include <asm/byteorder.h>  #include <linux/if_ether.h> +#include <linux/stddef.h>  #include <linux/types.h>  /** @@ -26,6 +27,7 @@   * @BATADV_CODED: network coded packets   * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V   * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V + * @BATADV_MCAST: multicast packet with multiple destination addresses   *   * @BATADV_UNICAST: unicast packets carrying unicast payload traffic   * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original @@ -42,6 +44,7 @@ enum batadv_packettype {  	BATADV_CODED            = 0x02,  	BATADV_ELP		= 0x03,  	BATADV_OGM2		= 0x04, +	BATADV_MCAST            = 0x05,  	/* 0x40 - 0x7f: unicast */  #define BATADV_UNICAST_MIN     0x40  	BATADV_UNICAST          = 0x40, @@ -114,6 +117,9 @@ enum batadv_icmp_packettype {   * only need routable IPv4 multicast packets we signed up for explicitly   * @BATADV_MCAST_WANT_NO_RTR6: we have no IPv6 multicast router and therefore   * only need routable IPv6 multicast packets we signed up for explicitly + * @BATADV_MCAST_HAVE_MC_PTYPE_CAPA: we can parse, receive and forward + * batman-adv multicast packets with a multicast tracker TVLV. And all our + * hard interfaces have an MTU of at least 1280 bytes.   */  enum batadv_mcast_flags {  	BATADV_MCAST_WANT_ALL_UNSNOOPABLES	= 1UL << 0, @@ -121,6 +127,7 @@ enum batadv_mcast_flags {  	BATADV_MCAST_WANT_ALL_IPV6		= 1UL << 2,  	BATADV_MCAST_WANT_NO_RTR4		= 1UL << 3,  	BATADV_MCAST_WANT_NO_RTR6		= 1UL << 4, +	BATADV_MCAST_HAVE_MC_PTYPE_CAPA		= 1UL << 5,  };  /* tt data subtypes */ @@ -172,14 +179,16 @@ enum batadv_bla_claimframe {   * @BATADV_TVLV_TT: translation table tvlv   * @BATADV_TVLV_ROAM: roaming advertisement tvlv   * @BATADV_TVLV_MCAST: multicast capability tvlv + * @BATADV_TVLV_MCAST_TRACKER: multicast tracker tvlv   */  enum batadv_tvlv_type { -	BATADV_TVLV_GW		= 0x01, -	BATADV_TVLV_DAT		= 0x02, -	BATADV_TVLV_NC		= 0x03, -	BATADV_TVLV_TT		= 0x04, -	BATADV_TVLV_ROAM	= 0x05, -	BATADV_TVLV_MCAST	= 0x06, +	BATADV_TVLV_GW			= 0x01, +	BATADV_TVLV_DAT			= 0x02, +	BATADV_TVLV_NC			= 0x03, +	BATADV_TVLV_TT			= 0x04, +	BATADV_TVLV_ROAM		= 0x05, +	BATADV_TVLV_MCAST		= 0x06, +	BATADV_TVLV_MCAST_TRACKER	= 0x07,  };  #pragma pack(2) @@ -486,6 +495,25 @@ struct batadv_bcast_packet {  };  /** + * struct batadv_mcast_packet - multicast packet for network payload + * @packet_type: batman-adv packet type, part of the general header + * @version: batman-adv protocol version, part of the general header + * @ttl: time to live for this packet, part of the general header + * @reserved: reserved byte for alignment + * @tvlv_len: length of the appended tvlv buffer (in bytes) + */ +struct batadv_mcast_packet { +	__u8 packet_type; +	__u8 version; +	__u8 ttl; +	__u8 reserved; +	__be16 tvlv_len; +	/* "4 bytes boundary + 2 bytes" long to make the payload after the +	 * following ethernet header again 4 bytes boundary aligned +	 */ +}; + +/**   * struct batadv_coded_packet - network coded packet   * @packet_type: batman-adv packet type, part of the general header   * @version: batman-adv protocol version, part of the general header @@ -566,19 +594,6 @@ struct batadv_tvlv_gateway_data {  };  /** - * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container - * @flags: translation table flags (see batadv_tt_data_flags) - * @ttvn: translation table version number - * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by - *  one batadv_tvlv_tt_vlan_data object per announced vlan - */ -struct batadv_tvlv_tt_data { -	__u8   flags; -	__u8   ttvn; -	__be16 num_vlan; -}; - -/**   * struct batadv_tvlv_tt_vlan_data - vlan specific tt data propagated through   *  the tt tvlv container   * @crc: crc32 checksum of the entries belonging to this vlan @@ -592,6 +607,21 @@ struct batadv_tvlv_tt_vlan_data {  };  /** + * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container + * @flags: translation table flags (see batadv_tt_data_flags) + * @ttvn: translation table version number + * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by + *  one batadv_tvlv_tt_vlan_data object per announced vlan + * @vlan_data: array of batadv_tvlv_tt_vlan_data objects + */ +struct batadv_tvlv_tt_data { +	__u8   flags; +	__u8   ttvn; +	__be16 num_vlan; +	struct batadv_tvlv_tt_vlan_data vlan_data[] __counted_by_be(num_vlan); +}; + +/**   * struct batadv_tvlv_tt_change - translation table diff data   * @flags: status indicators concerning the non-mesh client (see   *  batadv_tt_client_flags) @@ -626,6 +656,14 @@ struct batadv_tvlv_mcast_data {  	__u8 reserved[3];  }; +/** + * struct batadv_tvlv_mcast_tracker - payload of a multicast tracker tvlv + * @num_dests: number of subsequent destination originator MAC addresses + */ +struct batadv_tvlv_mcast_tracker { +	__be16	num_dests; +}; +  #pragma pack()  #endif /* _UAPI_LINUX_BATADV_PACKET_H_ */ diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h index bb0ae945b36a..936bcac270b5 100644 --- a/include/uapi/linux/batman_adv.h +++ b/include/uapi/linux/batman_adv.h @@ -1,5 +1,5 @@  /* SPDX-License-Identifier: MIT */ -/* Copyright (C) 2016-2020  B.A.T.M.A.N. contributors: +/* Copyright (C) B.A.T.M.A.N. contributors:   *   * Matthias Schiffer   */ @@ -342,7 +342,7 @@ enum batadv_nl_attrs {  	BATADV_ATTR_MCAST_FLAGS_PRIV,  	/** -	 * @BATADV_ATTR_VLANID: VLAN id on top of soft interface +	 * @BATADV_ATTR_VLANID: VLAN id on top of mesh interface  	 */  	BATADV_ATTR_VLANID, @@ -380,7 +380,7 @@ enum batadv_nl_attrs {  	/**  	 * @BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED: whether the bridge loop  	 *  avoidance feature is enabled. This feature detects and avoids loops -	 *  between the mesh and devices bridged with the soft interface +	 *  between the mesh and devices bridged with the mesh interface  	 */  	BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED, @@ -509,7 +509,7 @@ enum batadv_nl_commands {  	BATADV_CMD_UNSPEC,  	/** -	 * @BATADV_CMD_GET_MESH: Get attributes from softif/mesh +	 * @BATADV_CMD_GET_MESH: Get attributes from mesh(if)  	 */  	BATADV_CMD_GET_MESH, @@ -535,7 +535,7 @@ enum batadv_nl_commands {  	/**  	 * @BATADV_CMD_GET_HARDIF: Get attributes from a hardif of the -	 *  current softif +	 *  current mesh(if)  	 */  	BATADV_CMD_GET_HARDIF, @@ -591,25 +591,25 @@ enum batadv_nl_commands {  	BATADV_CMD_GET_MCAST_FLAGS,  	/** -	 * @BATADV_CMD_SET_MESH: Set attributes for softif/mesh +	 * @BATADV_CMD_SET_MESH: Set attributes for mesh(if)  	 */  	BATADV_CMD_SET_MESH,  	/**  	 * @BATADV_CMD_SET_HARDIF: Set attributes for hardif of the -	 *  current softif +	 *  current mesh(if)  	 */  	BATADV_CMD_SET_HARDIF,  	/**  	 * @BATADV_CMD_GET_VLAN: Get attributes from a VLAN of the -	 *  current softif +	 *  current mesh(if)  	 */  	BATADV_CMD_GET_VLAN,  	/**  	 * @BATADV_CMD_SET_VLAN: Set attributes for VLAN of the -	 *  current softif +	 *  current mesh(if)  	 */  	BATADV_CMD_SET_VLAN, @@ -675,4 +675,30 @@ enum batadv_tp_meter_reason {  	BATADV_TP_REASON_TOO_MANY		= 133,  }; +/** + * enum batadv_ifla_attrs - batman-adv ifla nested attributes + */ +enum batadv_ifla_attrs { +	/** +	 * @IFLA_BATADV_UNSPEC: unspecified attribute which is not parsed by +	 *  rtnetlink +	 */ +	IFLA_BATADV_UNSPEC, + +	/** +	 * @IFLA_BATADV_ALGO_NAME: routing algorithm (name) which should be +	 *  used by the newly registered batadv net_device. +	 */ +	IFLA_BATADV_ALGO_NAME, + +	/* add attributes above here, update the policy in mesh-interface.c */ + +	/** +	 * @__IFLA_BATADV_MAX: internal use +	 */ +	__IFLA_BATADV_MAX, +}; + +#define IFLA_BATADV_MAX (__IFLA_BATADV_MAX - 1) +  #endif /* _UAPI_LINUX_BATMAN_ADV_H_ */ diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h deleted file mode 100644 index 52e8bcb33981..000000000000 --- a/include/uapi/linux/bcache.h +++ /dev/null @@ -1,445 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _LINUX_BCACHE_H -#define _LINUX_BCACHE_H - -/* - * Bcache on disk data structures - */ - -#include <linux/types.h> - -#define BITMASK(name, type, field, offset, size)		\ -static inline __u64 name(const type *k)				\ -{ return (k->field >> offset) & ~(~0ULL << size); }		\ -								\ -static inline void SET_##name(type *k, __u64 v)			\ -{								\ -	k->field &= ~(~(~0ULL << size) << offset);		\ -	k->field |= (v & ~(~0ULL << size)) << offset;		\ -} - -/* Btree keys - all units are in sectors */ - -struct bkey { -	__u64	high; -	__u64	low; -	__u64	ptr[]; -}; - -#define KEY_FIELD(name, field, offset, size)				\ -	BITMASK(name, struct bkey, field, offset, size) - -#define PTR_FIELD(name, offset, size)					\ -static inline __u64 name(const struct bkey *k, unsigned int i)		\ -{ return (k->ptr[i] >> offset) & ~(~0ULL << size); }			\ -									\ -static inline void SET_##name(struct bkey *k, unsigned int i, __u64 v)	\ -{									\ -	k->ptr[i] &= ~(~(~0ULL << size) << offset);			\ -	k->ptr[i] |= (v & ~(~0ULL << size)) << offset;			\ -} - -#define KEY_SIZE_BITS		16 -#define KEY_MAX_U64S		8 - -KEY_FIELD(KEY_PTRS,	high, 60, 3) -KEY_FIELD(HEADER_SIZE,	high, 58, 2) -KEY_FIELD(KEY_CSUM,	high, 56, 2) -KEY_FIELD(KEY_PINNED,	high, 55, 1) -KEY_FIELD(KEY_DIRTY,	high, 36, 1) - -KEY_FIELD(KEY_SIZE,	high, 20, KEY_SIZE_BITS) -KEY_FIELD(KEY_INODE,	high, 0,  20) - -/* Next time I change the on disk format, KEY_OFFSET() won't be 64 bits */ - -static inline __u64 KEY_OFFSET(const struct bkey *k) -{ -	return k->low; -} - -static inline void SET_KEY_OFFSET(struct bkey *k, __u64 v) -{ -	k->low = v; -} - -/* - * The high bit being set is a relic from when we used it to do binary - * searches - it told you where a key started. It's not used anymore, - * and can probably be safely dropped. - */ -#define KEY(inode, offset, size)					\ -((struct bkey) {							\ -	.high = (1ULL << 63) | ((__u64) (size) << 20) | (inode),	\ -	.low = (offset)							\ -}) - -#define ZERO_KEY			KEY(0, 0, 0) - -#define MAX_KEY_INODE			(~(~0 << 20)) -#define MAX_KEY_OFFSET			(~0ULL >> 1) -#define MAX_KEY				KEY(MAX_KEY_INODE, MAX_KEY_OFFSET, 0) - -#define KEY_START(k)			(KEY_OFFSET(k) - KEY_SIZE(k)) -#define START_KEY(k)			KEY(KEY_INODE(k), KEY_START(k), 0) - -#define PTR_DEV_BITS			12 - -PTR_FIELD(PTR_DEV,			51, PTR_DEV_BITS) -PTR_FIELD(PTR_OFFSET,			8,  43) -PTR_FIELD(PTR_GEN,			0,  8) - -#define PTR_CHECK_DEV			((1 << PTR_DEV_BITS) - 1) - -#define MAKE_PTR(gen, offset, dev)					\ -	((((__u64) dev) << 51) | ((__u64) offset) << 8 | gen) - -/* Bkey utility code */ - -static inline unsigned long bkey_u64s(const struct bkey *k) -{ -	return (sizeof(struct bkey) / sizeof(__u64)) + KEY_PTRS(k); -} - -static inline unsigned long bkey_bytes(const struct bkey *k) -{ -	return bkey_u64s(k) * sizeof(__u64); -} - -#define bkey_copy(_dest, _src)	memcpy(_dest, _src, bkey_bytes(_src)) - -static inline void bkey_copy_key(struct bkey *dest, const struct bkey *src) -{ -	SET_KEY_INODE(dest, KEY_INODE(src)); -	SET_KEY_OFFSET(dest, KEY_OFFSET(src)); -} - -static inline struct bkey *bkey_next(const struct bkey *k) -{ -	__u64 *d = (void *) k; - -	return (struct bkey *) (d + bkey_u64s(k)); -} - -static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys) -{ -	__u64 *d = (void *) k; - -	return (struct bkey *) (d + nr_keys); -} -/* Enough for a key with 6 pointers */ -#define BKEY_PAD		8 - -#define BKEY_PADDED(key)					\ -	union { struct bkey key; __u64 key ## _pad[BKEY_PAD]; } - -/* Superblock */ - -/* Version 0: Cache device - * Version 1: Backing device - * Version 2: Seed pointer into btree node checksum - * Version 3: Cache device with new UUID format - * Version 4: Backing device with data offset - */ -#define BCACHE_SB_VERSION_CDEV			0 -#define BCACHE_SB_VERSION_BDEV			1 -#define BCACHE_SB_VERSION_CDEV_WITH_UUID	3 -#define BCACHE_SB_VERSION_BDEV_WITH_OFFSET	4 -#define BCACHE_SB_VERSION_CDEV_WITH_FEATURES	5 -#define BCACHE_SB_VERSION_BDEV_WITH_FEATURES	6 -#define BCACHE_SB_MAX_VERSION			6 - -#define SB_SECTOR			8 -#define SB_OFFSET			(SB_SECTOR << SECTOR_SHIFT) -#define SB_SIZE				4096 -#define SB_LABEL_SIZE			32 -#define SB_JOURNAL_BUCKETS		256U -/* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */ -#define MAX_CACHES_PER_SET		8 - -#define BDEV_DATA_START_DEFAULT		16	/* sectors */ - -struct cache_sb_disk { -	__le64			csum; -	__le64			offset;	/* sector where this sb was written */ -	__le64			version; - -	__u8			magic[16]; - -	__u8			uuid[16]; -	union { -		__u8		set_uuid[16]; -		__le64		set_magic; -	}; -	__u8			label[SB_LABEL_SIZE]; - -	__le64			flags; -	__le64			seq; - -	__le64			feature_compat; -	__le64			feature_incompat; -	__le64			feature_ro_compat; - -	__le64			pad[5]; - -	union { -	struct { -		/* Cache devices */ -		__le64		nbuckets;	/* device size */ - -		__le16		block_size;	/* sectors */ -		__le16		bucket_size;	/* sectors */ - -		__le16		nr_in_set; -		__le16		nr_this_dev; -	}; -	struct { -		/* Backing devices */ -		__le64		data_offset; - -		/* -		 * block_size from the cache device section is still used by -		 * backing devices, so don't add anything here until we fix -		 * things to not need it for backing devices anymore -		 */ -	}; -	}; - -	__le32			last_mount;	/* time overflow in y2106 */ - -	__le16			first_bucket; -	union { -		__le16		njournal_buckets; -		__le16		keys; -	}; -	__le64			d[SB_JOURNAL_BUCKETS];	/* journal buckets */ -	__le16			bucket_size_hi; -}; - -/* - * This is for in-memory bcache super block. - * NOTE: cache_sb is NOT exactly mapping to cache_sb_disk, the member - *       size, ordering and even whole struct size may be different - *       from cache_sb_disk. - */ -struct cache_sb { -	__u64			offset;	/* sector where this sb was written */ -	__u64			version; - -	__u8			magic[16]; - -	__u8			uuid[16]; -	union { -		__u8		set_uuid[16]; -		__u64		set_magic; -	}; -	__u8			label[SB_LABEL_SIZE]; - -	__u64			flags; -	__u64			seq; - -	__u64			feature_compat; -	__u64			feature_incompat; -	__u64			feature_ro_compat; - -	union { -	struct { -		/* Cache devices */ -		__u64		nbuckets;	/* device size */ - -		__u16		block_size;	/* sectors */ -		__u16		nr_in_set; -		__u16		nr_this_dev; -		__u32		bucket_size;	/* sectors */ -	}; -	struct { -		/* Backing devices */ -		__u64		data_offset; - -		/* -		 * block_size from the cache device section is still used by -		 * backing devices, so don't add anything here until we fix -		 * things to not need it for backing devices anymore -		 */ -	}; -	}; - -	__u32			last_mount;	/* time overflow in y2106 */ - -	__u16			first_bucket; -	union { -		__u16		njournal_buckets; -		__u16		keys; -	}; -	__u64			d[SB_JOURNAL_BUCKETS];	/* journal buckets */ -}; - -static inline _Bool SB_IS_BDEV(const struct cache_sb *sb) -{ -	return sb->version == BCACHE_SB_VERSION_BDEV -		|| sb->version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET -		|| sb->version == BCACHE_SB_VERSION_BDEV_WITH_FEATURES; -} - -BITMASK(CACHE_SYNC,			struct cache_sb, flags, 0, 1); -BITMASK(CACHE_DISCARD,			struct cache_sb, flags, 1, 1); -BITMASK(CACHE_REPLACEMENT,		struct cache_sb, flags, 2, 3); -#define CACHE_REPLACEMENT_LRU		0U -#define CACHE_REPLACEMENT_FIFO		1U -#define CACHE_REPLACEMENT_RANDOM	2U - -BITMASK(BDEV_CACHE_MODE,		struct cache_sb, flags, 0, 4); -#define CACHE_MODE_WRITETHROUGH		0U -#define CACHE_MODE_WRITEBACK		1U -#define CACHE_MODE_WRITEAROUND		2U -#define CACHE_MODE_NONE			3U -BITMASK(BDEV_STATE,			struct cache_sb, flags, 61, 2); -#define BDEV_STATE_NONE			0U -#define BDEV_STATE_CLEAN		1U -#define BDEV_STATE_DIRTY		2U -#define BDEV_STATE_STALE		3U - -/* - * Magic numbers - * - * The various other data structures have their own magic numbers, which are - * xored with the first part of the cache set's UUID - */ - -#define JSET_MAGIC			0x245235c1a3625032ULL -#define PSET_MAGIC			0x6750e15f87337f91ULL -#define BSET_MAGIC			0x90135c78b99e07f5ULL - -static inline __u64 jset_magic(struct cache_sb *sb) -{ -	return sb->set_magic ^ JSET_MAGIC; -} - -static inline __u64 pset_magic(struct cache_sb *sb) -{ -	return sb->set_magic ^ PSET_MAGIC; -} - -static inline __u64 bset_magic(struct cache_sb *sb) -{ -	return sb->set_magic ^ BSET_MAGIC; -} - -/* - * Journal - * - * On disk format for a journal entry: - * seq is monotonically increasing; every journal entry has its own unique - * sequence number. - * - * last_seq is the oldest journal entry that still has keys the btree hasn't - * flushed to disk yet. - * - * version is for on disk format changes. - */ - -#define BCACHE_JSET_VERSION_UUIDv1	1 -#define BCACHE_JSET_VERSION_UUID	1	/* Always latest UUID format */ -#define BCACHE_JSET_VERSION		1 - -struct jset { -	__u64			csum; -	__u64			magic; -	__u64			seq; -	__u32			version; -	__u32			keys; - -	__u64			last_seq; - -	BKEY_PADDED(uuid_bucket); -	BKEY_PADDED(btree_root); -	__u16			btree_level; -	__u16			pad[3]; - -	__u64			prio_bucket[MAX_CACHES_PER_SET]; - -	union { -		struct bkey	start[0]; -		__u64		d[0]; -	}; -}; - -/* Bucket prios/gens */ - -struct prio_set { -	__u64			csum; -	__u64			magic; -	__u64			seq; -	__u32			version; -	__u32			pad; - -	__u64			next_bucket; - -	struct bucket_disk { -		__u16		prio; -		__u8		gen; -	} __attribute((packed)) data[]; -}; - -/* UUIDS - per backing device/flash only volume metadata */ - -struct uuid_entry { -	union { -		struct { -			__u8	uuid[16]; -			__u8	label[32]; -			__u32	first_reg; /* time overflow in y2106 */ -			__u32	last_reg; -			__u32	invalidated; - -			__u32	flags; -			/* Size of flash only volumes */ -			__u64	sectors; -		}; - -		__u8		pad[128]; -	}; -}; - -BITMASK(UUID_FLASH_ONLY,	struct uuid_entry, flags, 0, 1); - -/* Btree nodes */ - -/* Version 1: Seed pointer into btree node checksum - */ -#define BCACHE_BSET_CSUM		1 -#define BCACHE_BSET_VERSION		1 - -/* - * Btree nodes - * - * On disk a btree node is a list/log of these; within each set the keys are - * sorted - */ -struct bset { -	__u64			csum; -	__u64			magic; -	__u64			seq; -	__u32			version; -	__u32			keys; - -	union { -		struct bkey	start[0]; -		__u64		d[0]; -	}; -}; - -/* OBSOLETE */ - -/* UUIDS - per backing device/flash only volume metadata */ - -struct uuid_entry_v0 { -	__u8		uuid[16]; -	__u8		label[32]; -	__u32		first_reg; -	__u32		last_reg; -	__u32		invalidated; -	__u32		pad; -}; - -#endif /* _LINUX_BCACHE_H */ diff --git a/include/uapi/linux/binfmts.h b/include/uapi/linux/binfmts.h index 689025d9c185..c6f9450efc12 100644 --- a/include/uapi/linux/binfmts.h +++ b/include/uapi/linux/binfmts.h @@ -18,4 +18,8 @@ struct pt_regs;  /* sizeof(linux_binprm->buf) */  #define BINPRM_BUF_SIZE 256 +/* preserve argv0 for the interpreter  */ +#define AT_FLAGS_PRESERVE_ARGV0_BIT 0 +#define AT_FLAGS_PRESERVE_ARGV0 (1 << AT_FLAGS_PRESERVE_ARGV0_BIT) +  #endif /* _UAPI_LINUX_BINFMTS_H */ diff --git a/include/uapi/linux/bits.h b/include/uapi/linux/bits.h new file mode 100644 index 000000000000..a04afef9efca --- /dev/null +++ b/include/uapi/linux/bits.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* bits.h: Macros for dealing with bitmasks.  */ + +#ifndef _UAPI_LINUX_BITS_H +#define _UAPI_LINUX_BITS_H + +#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h)))) + +#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h)))) + +#define __GENMASK_U128(h, l) \ +	((_BIT128((h)) << 1) - (_BIT128(l))) + +#endif /* _UAPI_LINUX_BITS_H */ diff --git a/include/uapi/linux/blk-crypto.h b/include/uapi/linux/blk-crypto.h new file mode 100644 index 000000000000..97302c6eb6af --- /dev/null +++ b/include/uapi/linux/blk-crypto.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_BLK_CRYPTO_H +#define _UAPI_LINUX_BLK_CRYPTO_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +struct blk_crypto_import_key_arg { +	/* Raw key (input) */ +	__u64 raw_key_ptr; +	__u64 raw_key_size; +	/* Long-term wrapped key blob (output) */ +	__u64 lt_key_ptr; +	__u64 lt_key_size; +	__u64 reserved[4]; +}; + +struct blk_crypto_generate_key_arg { +	/* Long-term wrapped key blob (output) */ +	__u64 lt_key_ptr; +	__u64 lt_key_size; +	__u64 reserved[4]; +}; + +struct blk_crypto_prepare_key_arg { +	/* Long-term wrapped key blob (input) */ +	__u64 lt_key_ptr; +	__u64 lt_key_size; +	/* Ephemerally-wrapped key blob (output) */ +	__u64 eph_key_ptr; +	__u64 eph_key_size; +	__u64 reserved[4]; +}; + +/* + * These ioctls share the block device ioctl space; see uapi/linux/fs.h. + * 140-141 are reserved for future blk-crypto ioctls; any more than that would + * require an additional allocation from the block device ioctl space. + */ +#define BLKCRYPTOIMPORTKEY _IOWR(0x12, 137, struct blk_crypto_import_key_arg) +#define BLKCRYPTOGENERATEKEY _IOWR(0x12, 138, struct blk_crypto_generate_key_arg) +#define BLKCRYPTOPREPAREKEY _IOWR(0x12, 139, struct blk_crypto_prepare_key_arg) + +#endif /* _UAPI_LINUX_BLK_CRYPTO_H */ diff --git a/include/uapi/linux/blkdev.h b/include/uapi/linux/blkdev.h new file mode 100644 index 000000000000..66373cd1a83a --- /dev/null +++ b/include/uapi/linux/blkdev.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_BLKDEV_H +#define _UAPI_LINUX_BLKDEV_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +/* + * io_uring block file commands, see IORING_OP_URING_CMD. + * It's a different number space from ioctl(), reuse the block's code 0x12. + */ +#define BLOCK_URING_CMD_DISCARD			_IO(0x12, 0) + +#endif diff --git a/include/uapi/linux/blkpg.h b/include/uapi/linux/blkpg.h index ac6474e4f29d..d0a64ee97c6d 100644 --- a/include/uapi/linux/blkpg.h +++ b/include/uapi/linux/blkpg.h @@ -2,29 +2,6 @@  #ifndef _UAPI__LINUX_BLKPG_H  #define _UAPI__LINUX_BLKPG_H -/* - * Partition table and disk geometry handling - * - * A single ioctl with lots of subfunctions: - * - * Device number stuff: - *    get_whole_disk()		(given the device number of a partition, - *                               find the device number of the encompassing disk) - *    get_all_partitions()	(given the device number of a disk, return the - *				 device numbers of all its known partitions) - * - * Partition stuff: - *    add_partition() - *    delete_partition() - *    test_partition_in_use()	(also for test_disk_in_use) - * - * Geometry stuff: - *    get_geometry() - *    set_geometry() - *    get_bios_drivedata() - * - * For today, only the partition stuff - aeb, 990515 - */  #include <linux/compiler.h>  #include <linux/ioctl.h> @@ -52,9 +29,8 @@ struct blkpg_partition {  	long long start;		/* starting offset in bytes */  	long long length;		/* length in bytes */  	int pno;			/* partition number */ -	char devname[BLKPG_DEVNAMELTH];	/* partition name, like sda5 or c0d1p2, -					   to be used in kernel messages */ -	char volname[BLKPG_VOLNAMELTH];	/* volume label */ +	char devname[BLKPG_DEVNAMELTH];	/* unused / ignored */ +	char volname[BLKPG_VOLNAMELTH];	/* unused / ignore */  };  #endif /* _UAPI__LINUX_BLKPG_H */ diff --git a/include/uapi/linux/blktrace_api.h b/include/uapi/linux/blktrace_api.h index 690621b610e5..1bfb635e309b 100644 --- a/include/uapi/linux/blktrace_api.h +++ b/include/uapi/linux/blktrace_api.h @@ -49,7 +49,7 @@ enum blktrace_act {  	__BLK_TA_UNPLUG_TIMER,		/* queue was unplugged by timer */  	__BLK_TA_INSERT,		/* insert request */  	__BLK_TA_SPLIT,			/* bio was split */ -	__BLK_TA_BOUNCE,		/* bio was bounced */ +	__BLK_TA_BOUNCE,		/* unused, was: bio was bounced */  	__BLK_TA_REMAP,			/* bio was remapped */  	__BLK_TA_ABORT,			/* request aborted */  	__BLK_TA_DRV_DATA,		/* driver-specific binary data */ diff --git a/include/uapi/linux/blkzoned.h b/include/uapi/linux/blkzoned.h index 42c3366cc25f..f85743ef6e7d 100644 --- a/include/uapi/linux/blkzoned.h +++ b/include/uapi/linux/blkzoned.h @@ -51,13 +51,13 @@ enum blk_zone_type {   *   * The Zone Condition state machine in the ZBC/ZAC standards maps the above   * deinitions as: - *   - ZC1: Empty         | BLK_ZONE_EMPTY + *   - ZC1: Empty         | BLK_ZONE_COND_EMPTY   *   - ZC2: Implicit Open | BLK_ZONE_COND_IMP_OPEN   *   - ZC3: Explicit Open | BLK_ZONE_COND_EXP_OPEN - *   - ZC4: Closed        | BLK_ZONE_CLOSED - *   - ZC5: Full          | BLK_ZONE_FULL - *   - ZC6: Read Only     | BLK_ZONE_READONLY - *   - ZC7: Offline       | BLK_ZONE_OFFLINE + *   - ZC4: Closed        | BLK_ZONE_COND_CLOSED + *   - ZC5: Full          | BLK_ZONE_COND_FULL + *   - ZC6: Read Only     | BLK_ZONE_COND_READONLY + *   - ZC7: Offline       | BLK_ZONE_COND_OFFLINE   *   * Conditions 0x5 to 0xC are reserved by the current ZBC/ZAC spec and should   * be considered invalid. @@ -93,12 +93,15 @@ enum blk_zone_report_flags {   * @non_seq: Flag indicating that the zone is using non-sequential resources   *           (for host-aware zoned block devices only).   * @reset: Flag indicating that a zone reset is recommended. - * @reserved: Padding to 64 B to match the ZBC/ZAC defined zone descriptor size. + * @resv: Padding for 8B alignment. + * @capacity: Zone usable capacity in 512 B sector units + * @reserved: Padding to 64 B to match the ZBC, ZAC and ZNS defined zone + *            descriptor size.   * - * start, len and wp use the regular 512 B sector unit, regardless of the - * device logical block size. The overall structure size is 64 B to match the - * ZBC/ZAC defined zone descriptor and allow support for future additional - * zone information. + * start, len, capacity and wp use the regular 512 B sector unit, regardless + * of the device logical block size. The overall structure size is 64 B to + * match the ZBC, ZAC and ZNS defined zone descriptor and allow support for + * future additional zone information.   */  struct blk_zone {  	__u64	start;		/* Zone start sector */ @@ -118,7 +121,7 @@ struct blk_zone {   *   * @sector: starting sector of report   * @nr_zones: IN maximum / OUT actual - * @reserved: padding to 16 byte alignment + * @flags: one or more flags as defined by enum blk_zone_report_flags.   * @zones: Space to hold @nr_zones @zones entries on reply.   *   * The array of at most @nr_zones must follow this structure in memory. @@ -127,7 +130,7 @@ struct blk_zone_report {  	__u64		sector;  	__u32		nr_zones;  	__u32		flags; -	struct blk_zone zones[0]; +	struct blk_zone zones[];  };  /** diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index b6238b2209b7..233de8677382 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -19,7 +19,9 @@  /* ld/ldx fields */  #define BPF_DW		0x18	/* double word (64-bit) */ -#define BPF_XADD	0xc0	/* exclusive add */ +#define BPF_MEMSX	0x80	/* load with sign extension */ +#define BPF_ATOMIC	0xc0	/* atomic memory ops - op type in immediate */ +#define BPF_XADD	0xc0	/* exclusive add - legacy name */  /* alu/jmp fields */  #define BPF_MOV		0xb0	/* mov reg to reg */ @@ -40,9 +42,22 @@  #define BPF_JSGE	0x70	/* SGE is signed '>=', GE in x86 */  #define BPF_JSLT	0xc0	/* SLT is signed, '<' */  #define BPF_JSLE	0xd0	/* SLE is signed, '<=' */ +#define BPF_JCOND	0xe0	/* conditional pseudo jumps: may_goto, goto_or_nop */  #define BPF_CALL	0x80	/* function call */  #define BPF_EXIT	0x90	/* function return */ +/* atomic op type fields (stored in immediate) */ +#define BPF_FETCH	0x01	/* not an opcode on its own, used to build others */ +#define BPF_XCHG	(0xe0 | BPF_FETCH)	/* atomic exchange */ +#define BPF_CMPXCHG	(0xf0 | BPF_FETCH)	/* atomic compare-and-write */ + +#define BPF_LOAD_ACQ	0x100	/* load-acquire */ +#define BPF_STORE_REL	0x110	/* store-release */ + +enum bpf_cond_pseudo_jmp { +	BPF_MAY_GOTO = 0, +}; +  /* Register numbers */  enum {  	BPF_REG_0 = 0, @@ -70,24 +85,855 @@ struct bpf_insn {  	__s32	imm;		/* signed immediate constant */  }; -/* Key of an a BPF_MAP_TYPE_LPM_TRIE entry */ +/* Deprecated: use struct bpf_lpm_trie_key_u8 (when the "data" member is needed for + * byte access) or struct bpf_lpm_trie_key_hdr (when using an alternative type for + * the trailing flexible array member) instead. + */  struct bpf_lpm_trie_key {  	__u32	prefixlen;	/* up to 32 for AF_INET, 128 for AF_INET6 */  	__u8	data[0];	/* Arbitrary size */  }; +/* Header for bpf_lpm_trie_key structs */ +struct bpf_lpm_trie_key_hdr { +	__u32	prefixlen; +}; + +/* Key of an a BPF_MAP_TYPE_LPM_TRIE entry, with trailing byte array. */ +struct bpf_lpm_trie_key_u8 { +	union { +		struct bpf_lpm_trie_key_hdr	hdr; +		__u32				prefixlen; +	}; +	__u8	data[];		/* Arbitrary size */ +}; +  struct bpf_cgroup_storage_key {  	__u64	cgroup_inode_id;	/* cgroup inode id */ -	__u32	attach_type;		/* program attach type */ +	__u32	attach_type;		/* program attach type (enum bpf_attach_type) */ +}; + +enum bpf_cgroup_iter_order { +	BPF_CGROUP_ITER_ORDER_UNSPEC = 0, +	BPF_CGROUP_ITER_SELF_ONLY,		/* process only a single object. */ +	BPF_CGROUP_ITER_DESCENDANTS_PRE,	/* walk descendants in pre-order. */ +	BPF_CGROUP_ITER_DESCENDANTS_POST,	/* walk descendants in post-order. */ +	BPF_CGROUP_ITER_ANCESTORS_UP,		/* walk ancestors upward. */  };  union bpf_iter_link_info {  	struct {  		__u32	map_fd;  	} map; +	struct { +		enum bpf_cgroup_iter_order order; + +		/* At most one of cgroup_fd and cgroup_id can be non-zero. If +		 * both are zero, the walk starts from the default cgroup v2 +		 * root. For walking v1 hierarchy, one should always explicitly +		 * specify cgroup_fd. +		 */ +		__u32	cgroup_fd; +		__u64	cgroup_id; +	} cgroup; +	/* Parameters of task iterators. */ +	struct { +		__u32	tid; +		__u32	pid; +		__u32	pid_fd; +	} task;  }; -/* BPF syscall commands, see bpf(2) man-page for details. */ +/* BPF syscall commands, see bpf(2) man-page for more details. */ +/** + * DOC: eBPF Syscall Preamble + * + * The operation to be performed by the **bpf**\ () system call is determined + * by the *cmd* argument. Each operation takes an accompanying argument, + * provided via *attr*, which is a pointer to a union of type *bpf_attr* (see + * below). The size argument is the size of the union pointed to by *attr*. + */ +/** + * DOC: eBPF Syscall Commands + * + * BPF_MAP_CREATE + *	Description + *		Create a map and return a file descriptor that refers to the + *		map. The close-on-exec file descriptor flag (see **fcntl**\ (2)) + *		is automatically enabled for the new file descriptor. + * + *		Applying **close**\ (2) to the file descriptor returned by + *		**BPF_MAP_CREATE** will delete the map (but see NOTES). + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_MAP_LOOKUP_ELEM + *	Description + *		Look up an element with a given *key* in the map referred to + *		by the file descriptor *map_fd*. + * + *		The *flags* argument may be specified as one of the + *		following: + * + *		**BPF_F_LOCK** + *			Look up the value of a spin-locked map without + *			returning the lock. This must be specified if the + *			elements contain a spinlock. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_MAP_UPDATE_ELEM + *	Description + *		Create or update an element (key/value pair) in a specified map. + * + *		The *flags* argument should be specified as one of the + *		following: + * + *		**BPF_ANY** + *			Create a new element or update an existing element. + *		**BPF_NOEXIST** + *			Create a new element only if it did not exist. + *		**BPF_EXIST** + *			Update an existing element. + *		**BPF_F_LOCK** + *			Update a spin_lock-ed map element. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + *		May set *errno* to **EINVAL**, **EPERM**, **ENOMEM**, + *		**E2BIG**, **EEXIST**, or **ENOENT**. + * + *		**E2BIG** + *			The number of elements in the map reached the + *			*max_entries* limit specified at map creation time. + *		**EEXIST** + *			If *flags* specifies **BPF_NOEXIST** and the element + *			with *key* already exists in the map. + *		**ENOENT** + *			If *flags* specifies **BPF_EXIST** and the element with + *			*key* does not exist in the map. + * + * BPF_MAP_DELETE_ELEM + *	Description + *		Look up and delete an element by key in a specified map. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_MAP_GET_NEXT_KEY + *	Description + *		Look up an element by key in a specified map and return the key + *		of the next element. Can be used to iterate over all elements + *		in the map. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + *		The following cases can be used to iterate over all elements of + *		the map: + * + *		* If *key* is not found, the operation returns zero and sets + *		  the *next_key* pointer to the key of the first element. + *		* If *key* is found, the operation returns zero and sets the + *		  *next_key* pointer to the key of the next element. + *		* If *key* is the last element, returns -1 and *errno* is set + *		  to **ENOENT**. + * + *		May set *errno* to **ENOMEM**, **EFAULT**, **EPERM**, or + *		**EINVAL** on error. + * + * BPF_PROG_LOAD + *	Description + *		Verify and load an eBPF program, returning a new file + *		descriptor associated with the program. + * + *		Applying **close**\ (2) to the file descriptor returned by + *		**BPF_PROG_LOAD** will unload the eBPF program (but see NOTES). + * + *		The close-on-exec file descriptor flag (see **fcntl**\ (2)) is + *		automatically enabled for the new file descriptor. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_OBJ_PIN + *	Description + *		Pin an eBPF program or map referred by the specified *bpf_fd* + *		to the provided *pathname* on the filesystem. + * + *		The *pathname* argument must not contain a dot ("."). + * + *		On success, *pathname* retains a reference to the eBPF object, + *		preventing deallocation of the object when the original + *		*bpf_fd* is closed. This allow the eBPF object to live beyond + *		**close**\ (\ *bpf_fd*\ ), and hence the lifetime of the parent + *		process. + * + *		Applying **unlink**\ (2) or similar calls to the *pathname* + *		unpins the object from the filesystem, removing the reference. + *		If no other file descriptors or filesystem nodes refer to the + *		same object, it will be deallocated (see NOTES). + * + *		The filesystem type for the parent directory of *pathname* must + *		be **BPF_FS_MAGIC**. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_OBJ_GET + *	Description + *		Open a file descriptor for the eBPF object pinned to the + *		specified *pathname*. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_PROG_ATTACH + *	Description + *		Attach an eBPF program to a *target_fd* at the specified + *		*attach_type* hook. + * + *		The *attach_type* specifies the eBPF attachment point to + *		attach the program to, and must be one of *bpf_attach_type* + *		(see below). + * + *		The *attach_bpf_fd* must be a valid file descriptor for a + *		loaded eBPF program of a cgroup, flow dissector, LIRC, sockmap + *		or sock_ops type corresponding to the specified *attach_type*. + * + *		The *target_fd* must be a valid file descriptor for a kernel + *		object which depends on the attach type of *attach_bpf_fd*: + * + *		**BPF_PROG_TYPE_CGROUP_DEVICE**, + *		**BPF_PROG_TYPE_CGROUP_SKB**, + *		**BPF_PROG_TYPE_CGROUP_SOCK**, + *		**BPF_PROG_TYPE_CGROUP_SOCK_ADDR**, + *		**BPF_PROG_TYPE_CGROUP_SOCKOPT**, + *		**BPF_PROG_TYPE_CGROUP_SYSCTL**, + *		**BPF_PROG_TYPE_SOCK_OPS** + * + *			Control Group v2 hierarchy with the eBPF controller + *			enabled. Requires the kernel to be compiled with + *			**CONFIG_CGROUP_BPF**. + * + *		**BPF_PROG_TYPE_FLOW_DISSECTOR** + * + *			Network namespace (eg /proc/self/ns/net). + * + *		**BPF_PROG_TYPE_LIRC_MODE2** + * + *			LIRC device path (eg /dev/lircN). Requires the kernel + *			to be compiled with **CONFIG_BPF_LIRC_MODE2**. + * + *		**BPF_PROG_TYPE_SK_SKB**, + *		**BPF_PROG_TYPE_SK_MSG** + * + *			eBPF map of socket type (eg **BPF_MAP_TYPE_SOCKHASH**). + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_PROG_DETACH + *	Description + *		Detach the eBPF program associated with the *target_fd* at the + *		hook specified by *attach_type*. The program must have been + *		previously attached using **BPF_PROG_ATTACH**. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_PROG_TEST_RUN + *	Description + *		Run the eBPF program associated with the *prog_fd* a *repeat* + *		number of times against a provided program context *ctx_in* and + *		data *data_in*, and return the modified program context + *		*ctx_out*, *data_out* (for example, packet data), result of the + *		execution *retval*, and *duration* of the test run. + * + *		The sizes of the buffers provided as input and output + *		parameters *ctx_in*, *ctx_out*, *data_in*, and *data_out* must + *		be provided in the corresponding variables *ctx_size_in*, + *		*ctx_size_out*, *data_size_in*, and/or *data_size_out*. If any + *		of these parameters are not provided (ie set to NULL), the + *		corresponding size field must be zero. + * + *		Some program types have particular requirements: + * + *		**BPF_PROG_TYPE_SK_LOOKUP** + *			*data_in* and *data_out* must be NULL. + * + *		**BPF_PROG_TYPE_RAW_TRACEPOINT**, + *		**BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE** + * + *			*ctx_out*, *data_in* and *data_out* must be NULL. + *			*repeat* must be zero. + * + *		BPF_PROG_RUN is an alias for BPF_PROG_TEST_RUN. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + *		**ENOSPC** + *			Either *data_size_out* or *ctx_size_out* is too small. + *		**ENOTSUPP** + *			This command is not supported by the program type of + *			the program referred to by *prog_fd*. + * + * BPF_PROG_GET_NEXT_ID + *	Description + *		Fetch the next eBPF program currently loaded into the kernel. + * + *		Looks for the eBPF program with an id greater than *start_id* + *		and updates *next_id* on success. If no other eBPF programs + *		remain with ids higher than *start_id*, returns -1 and sets + *		*errno* to **ENOENT**. + * + *	Return + *		Returns zero on success. On error, or when no id remains, -1 + *		is returned and *errno* is set appropriately. + * + * BPF_MAP_GET_NEXT_ID + *	Description + *		Fetch the next eBPF map currently loaded into the kernel. + * + *		Looks for the eBPF map with an id greater than *start_id* + *		and updates *next_id* on success. If no other eBPF maps + *		remain with ids higher than *start_id*, returns -1 and sets + *		*errno* to **ENOENT**. + * + *	Return + *		Returns zero on success. On error, or when no id remains, -1 + *		is returned and *errno* is set appropriately. + * + * BPF_PROG_GET_FD_BY_ID + *	Description + *		Open a file descriptor for the eBPF program corresponding to + *		*prog_id*. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_MAP_GET_FD_BY_ID + *	Description + *		Open a file descriptor for the eBPF map corresponding to + *		*map_id*. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_OBJ_GET_INFO_BY_FD + *	Description + *		Obtain information about the eBPF object corresponding to + *		*bpf_fd*. + * + *		Populates up to *info_len* bytes of *info*, which will be in + *		one of the following formats depending on the eBPF object type + *		of *bpf_fd*: + * + *		* **struct bpf_prog_info** + *		* **struct bpf_map_info** + *		* **struct bpf_btf_info** + *		* **struct bpf_link_info** + *		* **struct bpf_token_info** + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_PROG_QUERY + *	Description + *		Obtain information about eBPF programs associated with the + *		specified *attach_type* hook. + * + *		The *target_fd* must be a valid file descriptor for a kernel + *		object which depends on the attach type of *attach_bpf_fd*: + * + *		**BPF_PROG_TYPE_CGROUP_DEVICE**, + *		**BPF_PROG_TYPE_CGROUP_SKB**, + *		**BPF_PROG_TYPE_CGROUP_SOCK**, + *		**BPF_PROG_TYPE_CGROUP_SOCK_ADDR**, + *		**BPF_PROG_TYPE_CGROUP_SOCKOPT**, + *		**BPF_PROG_TYPE_CGROUP_SYSCTL**, + *		**BPF_PROG_TYPE_SOCK_OPS** + * + *			Control Group v2 hierarchy with the eBPF controller + *			enabled. Requires the kernel to be compiled with + *			**CONFIG_CGROUP_BPF**. + * + *		**BPF_PROG_TYPE_FLOW_DISSECTOR** + * + *			Network namespace (eg /proc/self/ns/net). + * + *		**BPF_PROG_TYPE_LIRC_MODE2** + * + *			LIRC device path (eg /dev/lircN). Requires the kernel + *			to be compiled with **CONFIG_BPF_LIRC_MODE2**. + * + *		**BPF_PROG_QUERY** always fetches the number of programs + *		attached and the *attach_flags* which were used to attach those + *		programs. Additionally, if *prog_ids* is nonzero and the number + *		of attached programs is less than *prog_cnt*, populates + *		*prog_ids* with the eBPF program ids of the programs attached + *		at *target_fd*. + * + *		The following flags may alter the result: + * + *		**BPF_F_QUERY_EFFECTIVE** + *			Only return information regarding programs which are + *			currently effective at the specified *target_fd*. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_RAW_TRACEPOINT_OPEN + *	Description + *		Attach an eBPF program to a tracepoint *name* to access kernel + *		internal arguments of the tracepoint in their raw form. + * + *		The *prog_fd* must be a valid file descriptor associated with + *		a loaded eBPF program of type **BPF_PROG_TYPE_RAW_TRACEPOINT**. + * + *		No ABI guarantees are made about the content of tracepoint + *		arguments exposed to the corresponding eBPF program. + * + *		Applying **close**\ (2) to the file descriptor returned by + *		**BPF_RAW_TRACEPOINT_OPEN** will delete the map (but see NOTES). + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_BTF_LOAD + *	Description + *		Verify and load BPF Type Format (BTF) metadata into the kernel, + *		returning a new file descriptor associated with the metadata. + *		BTF is described in more detail at + *		https://www.kernel.org/doc/html/latest/bpf/btf.html. + * + *		The *btf* parameter must point to valid memory providing + *		*btf_size* bytes of BTF binary metadata. + * + *		The returned file descriptor can be passed to other **bpf**\ () + *		subcommands such as **BPF_PROG_LOAD** or **BPF_MAP_CREATE** to + *		associate the BTF with those objects. + * + *		Similar to **BPF_PROG_LOAD**, **BPF_BTF_LOAD** has optional + *		parameters to specify a *btf_log_buf*, *btf_log_size* and + *		*btf_log_level* which allow the kernel to return freeform log + *		output regarding the BTF verification process. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_BTF_GET_FD_BY_ID + *	Description + *		Open a file descriptor for the BPF Type Format (BTF) + *		corresponding to *btf_id*. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_TASK_FD_QUERY + *	Description + *		Obtain information about eBPF programs associated with the + *		target process identified by *pid* and *fd*. + * + *		If the *pid* and *fd* are associated with a tracepoint, kprobe + *		or uprobe perf event, then the *prog_id* and *fd_type* will + *		be populated with the eBPF program id and file descriptor type + *		of type **bpf_task_fd_type**. If associated with a kprobe or + *		uprobe, the  *probe_offset* and *probe_addr* will also be + *		populated. Optionally, if *buf* is provided, then up to + *		*buf_len* bytes of *buf* will be populated with the name of + *		the tracepoint, kprobe or uprobe. + * + *		The resulting *prog_id* may be introspected in deeper detail + *		using **BPF_PROG_GET_FD_BY_ID** and **BPF_OBJ_GET_INFO_BY_FD**. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_MAP_LOOKUP_AND_DELETE_ELEM + *	Description + *		Look up an element with the given *key* in the map referred to + *		by the file descriptor *fd*, and if found, delete the element. + * + *		For **BPF_MAP_TYPE_QUEUE** and **BPF_MAP_TYPE_STACK** map + *		types, the *flags* argument needs to be set to 0, but for other + *		map types, it may be specified as: + * + *		**BPF_F_LOCK** + *			Look up and delete the value of a spin-locked map + *			without returning the lock. This must be specified if + *			the elements contain a spinlock. + * + *		The **BPF_MAP_TYPE_QUEUE** and **BPF_MAP_TYPE_STACK** map types + *		implement this command as a "pop" operation, deleting the top + *		element rather than one corresponding to *key*. + *		The *key* and *key_len* parameters should be zeroed when + *		issuing this operation for these map types. + * + *		This command is only valid for the following map types: + *		* **BPF_MAP_TYPE_QUEUE** + *		* **BPF_MAP_TYPE_STACK** + *		* **BPF_MAP_TYPE_HASH** + *		* **BPF_MAP_TYPE_PERCPU_HASH** + *		* **BPF_MAP_TYPE_LRU_HASH** + *		* **BPF_MAP_TYPE_LRU_PERCPU_HASH** + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_MAP_FREEZE + *	Description + *		Freeze the permissions of the specified map. + * + *		Write permissions may be frozen by passing zero *flags*. + *		Upon success, no future syscall invocations may alter the + *		map state of *map_fd*. Write operations from eBPF programs + *		are still possible for a frozen map. + * + *		Not supported for maps of type **BPF_MAP_TYPE_STRUCT_OPS**. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_BTF_GET_NEXT_ID + *	Description + *		Fetch the next BPF Type Format (BTF) object currently loaded + *		into the kernel. + * + *		Looks for the BTF object with an id greater than *start_id* + *		and updates *next_id* on success. If no other BTF objects + *		remain with ids higher than *start_id*, returns -1 and sets + *		*errno* to **ENOENT**. + * + *	Return + *		Returns zero on success. On error, or when no id remains, -1 + *		is returned and *errno* is set appropriately. + * + * BPF_MAP_LOOKUP_BATCH + *	Description + *		Iterate and fetch multiple elements in a map. + * + *		Two opaque values are used to manage batch operations, + *		*in_batch* and *out_batch*. Initially, *in_batch* must be set + *		to NULL to begin the batched operation. After each subsequent + *		**BPF_MAP_LOOKUP_BATCH**, the caller should pass the resultant + *		*out_batch* as the *in_batch* for the next operation to + *		continue iteration from the current point. Both *in_batch* and + *		*out_batch* must point to memory large enough to hold a key, + *		except for maps of type **BPF_MAP_TYPE_{HASH, PERCPU_HASH, + *		LRU_HASH, LRU_PERCPU_HASH}**, for which batch parameters + *		must be at least 4 bytes wide regardless of key size. + * + *		The *keys* and *values* are output parameters which must point + *		to memory large enough to hold *count* items based on the key + *		and value size of the map *map_fd*. The *keys* buffer must be + *		of *key_size* * *count*. The *values* buffer must be of + *		*value_size* * *count*. + * + *		The *elem_flags* argument may be specified as one of the + *		following: + * + *		**BPF_F_LOCK** + *			Look up the value of a spin-locked map without + *			returning the lock. This must be specified if the + *			elements contain a spinlock. + * + *		On success, *count* elements from the map are copied into the + *		user buffer, with the keys copied into *keys* and the values + *		copied into the corresponding indices in *values*. + * + *		If an error is returned and *errno* is not **EFAULT**, *count* + *		is set to the number of successfully processed elements. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + *		May set *errno* to **ENOSPC** to indicate that *keys* or + *		*values* is too small to dump an entire bucket during + *		iteration of a hash-based map type. + * + * BPF_MAP_LOOKUP_AND_DELETE_BATCH + *	Description + *		Iterate and delete all elements in a map. + * + *		This operation has the same behavior as + *		**BPF_MAP_LOOKUP_BATCH** with two exceptions: + * + *		* Every element that is successfully returned is also deleted + *		  from the map. This is at least *count* elements. Note that + *		  *count* is both an input and an output parameter. + *		* Upon returning with *errno* set to **EFAULT**, up to + *		  *count* elements may be deleted without returning the keys + *		  and values of the deleted elements. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_MAP_UPDATE_BATCH + *	Description + *		Update multiple elements in a map by *key*. + * + *		The *keys* and *values* are input parameters which must point + *		to memory large enough to hold *count* items based on the key + *		and value size of the map *map_fd*. The *keys* buffer must be + *		of *key_size* * *count*. The *values* buffer must be of + *		*value_size* * *count*. + * + *		Each element specified in *keys* is sequentially updated to the + *		value in the corresponding index in *values*. The *in_batch* + *		and *out_batch* parameters are ignored and should be zeroed. + * + *		The *elem_flags* argument should be specified as one of the + *		following: + * + *		**BPF_ANY** + *			Create new elements or update a existing elements. + *		**BPF_NOEXIST** + *			Create new elements only if they do not exist. + *		**BPF_EXIST** + *			Update existing elements. + *		**BPF_F_LOCK** + *			Update spin_lock-ed map elements. This must be + *			specified if the map value contains a spinlock. + * + *		On success, *count* elements from the map are updated. + * + *		If an error is returned and *errno* is not **EFAULT**, *count* + *		is set to the number of successfully processed elements. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + *		May set *errno* to **EINVAL**, **EPERM**, **ENOMEM**, or + *		**E2BIG**. **E2BIG** indicates that the number of elements in + *		the map reached the *max_entries* limit specified at map + *		creation time. + * + *		May set *errno* to one of the following error codes under + *		specific circumstances: + * + *		**EEXIST** + *			If *flags* specifies **BPF_NOEXIST** and the element + *			with *key* already exists in the map. + *		**ENOENT** + *			If *flags* specifies **BPF_EXIST** and the element with + *			*key* does not exist in the map. + * + * BPF_MAP_DELETE_BATCH + *	Description + *		Delete multiple elements in a map by *key*. + * + *		The *keys* parameter is an input parameter which must point + *		to memory large enough to hold *count* items based on the key + *		size of the map *map_fd*, that is, *key_size* * *count*. + * + *		Each element specified in *keys* is sequentially deleted. The + *		*in_batch*, *out_batch*, and *values* parameters are ignored + *		and should be zeroed. + * + *		The *elem_flags* argument may be specified as one of the + *		following: + * + *		**BPF_F_LOCK** + *			Look up the value of a spin-locked map without + *			returning the lock. This must be specified if the + *			elements contain a spinlock. + * + *		On success, *count* elements from the map are updated. + * + *		If an error is returned and *errno* is not **EFAULT**, *count* + *		is set to the number of successfully processed elements. If + *		*errno* is **EFAULT**, up to *count* elements may be been + *		deleted. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_LINK_CREATE + *	Description + *		Attach an eBPF program to a *target_fd* at the specified + *		*attach_type* hook and return a file descriptor handle for + *		managing the link. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_LINK_UPDATE + *	Description + *		Update the eBPF program in the specified *link_fd* to + *		*new_prog_fd*. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_LINK_GET_FD_BY_ID + *	Description + *		Open a file descriptor for the eBPF Link corresponding to + *		*link_id*. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_LINK_GET_NEXT_ID + *	Description + *		Fetch the next eBPF link currently loaded into the kernel. + * + *		Looks for the eBPF link with an id greater than *start_id* + *		and updates *next_id* on success. If no other eBPF links + *		remain with ids higher than *start_id*, returns -1 and sets + *		*errno* to **ENOENT**. + * + *	Return + *		Returns zero on success. On error, or when no id remains, -1 + *		is returned and *errno* is set appropriately. + * + * BPF_ENABLE_STATS + *	Description + *		Enable eBPF runtime statistics gathering. + * + *		Runtime statistics gathering for the eBPF runtime is disabled + *		by default to minimize the corresponding performance overhead. + *		This command enables statistics globally. + * + *		Multiple programs may independently enable statistics. + *		After gathering the desired statistics, eBPF runtime statistics + *		may be disabled again by calling **close**\ (2) for the file + *		descriptor returned by this function. Statistics will only be + *		disabled system-wide when all outstanding file descriptors + *		returned by prior calls for this subcommand are closed. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_ITER_CREATE + *	Description + *		Create an iterator on top of the specified *link_fd* (as + *		previously created using **BPF_LINK_CREATE**) and return a + *		file descriptor that can be used to trigger the iteration. + * + *		If the resulting file descriptor is pinned to the filesystem + *		using  **BPF_OBJ_PIN**, then subsequent **read**\ (2) syscalls + *		for that path will trigger the iterator to read kernel state + *		using the eBPF program attached to *link_fd*. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_LINK_DETACH + *	Description + *		Forcefully detach the specified *link_fd* from its + *		corresponding attachment point. + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_PROG_BIND_MAP + *	Description + *		Bind a map to the lifetime of an eBPF program. + * + *		The map identified by *map_fd* is bound to the program + *		identified by *prog_fd* and only released when *prog_fd* is + *		released. This may be used in cases where metadata should be + *		associated with a program which otherwise does not contain any + *		references to the map (for example, embedded in the eBPF + *		program instructions). + * + *	Return + *		Returns zero on success. On error, -1 is returned and *errno* + *		is set appropriately. + * + * BPF_TOKEN_CREATE + *	Description + *		Create BPF token with embedded information about what + *		BPF-related functionality it allows: + *		- a set of allowed bpf() syscall commands; + *		- a set of allowed BPF map types to be created with + *		BPF_MAP_CREATE command, if BPF_MAP_CREATE itself is allowed; + *		- a set of allowed BPF program types and BPF program attach + *		types to be loaded with BPF_PROG_LOAD command, if + *		BPF_PROG_LOAD itself is allowed. + * + *		BPF token is created (derived) from an instance of BPF FS, + *		assuming it has necessary delegation mount options specified. + *		This BPF token can be passed as an extra parameter to various + *		bpf() syscall commands to grant BPF subsystem functionality to + *		unprivileged processes. + * + *		When created, BPF token is "associated" with the owning + *		user namespace of BPF FS instance (super block) that it was + *		derived from, and subsequent BPF operations performed with + *		BPF token would be performing capabilities checks (i.e., + *		CAP_BPF, CAP_PERFMON, CAP_NET_ADMIN, CAP_SYS_ADMIN) within + *		that user namespace. Without BPF token, such capabilities + *		have to be granted in init user namespace, making bpf() + *		syscall incompatible with user namespace, for the most part. + * + *	Return + *		A new file descriptor (a nonnegative integer), or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * BPF_PROG_STREAM_READ_BY_FD + *	Description + *		Read data of a program's BPF stream. The program is identified + *		by *prog_fd*, and the stream is identified by the *stream_id*. + *		The data is copied to a buffer pointed to by *stream_buf*, and + *		filled less than or equal to *stream_buf_len* bytes. + * + *	Return + *		Number of bytes read from the stream on success, or -1 if an + *		error occurred (in which case, *errno* is set appropriately). + * + * NOTES + *	eBPF objects (maps and programs) can be shared between processes. + * + *	* After **fork**\ (2), the child inherits file descriptors + *	  referring to the same eBPF objects. + *	* File descriptors referring to eBPF objects can be transferred over + *	  **unix**\ (7) domain sockets. + *	* File descriptors referring to eBPF objects can be duplicated in the + *	  usual way, using **dup**\ (2) and similar calls. + *	* File descriptors referring to eBPF objects can be pinned to the + *	  filesystem using the **BPF_OBJ_PIN** command of **bpf**\ (2). + * + *	An eBPF object is deallocated only after all file descriptors referring + *	to the object have been closed and no references remain pinned to the + *	filesystem or attached (for example, bound to a program or device). + */  enum bpf_cmd {  	BPF_MAP_CREATE,  	BPF_MAP_LOOKUP_ELEM, @@ -100,6 +946,7 @@ enum bpf_cmd {  	BPF_PROG_ATTACH,  	BPF_PROG_DETACH,  	BPF_PROG_TEST_RUN, +	BPF_PROG_RUN = BPF_PROG_TEST_RUN,  	BPF_PROG_GET_NEXT_ID,  	BPF_MAP_GET_NEXT_ID,  	BPF_PROG_GET_FD_BY_ID, @@ -124,6 +971,10 @@ enum bpf_cmd {  	BPF_ENABLE_STATS,  	BPF_ITER_CREATE,  	BPF_LINK_DETACH, +	BPF_PROG_BIND_MAP, +	BPF_TOKEN_CREATE, +	BPF_PROG_STREAM_READ_BY_FD, +	__MAX_BPF_CMD,  };  enum bpf_map_type { @@ -146,15 +997,36 @@ enum bpf_map_type {  	BPF_MAP_TYPE_CPUMAP,  	BPF_MAP_TYPE_XSKMAP,  	BPF_MAP_TYPE_SOCKHASH, -	BPF_MAP_TYPE_CGROUP_STORAGE, +	BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED, +	/* BPF_MAP_TYPE_CGROUP_STORAGE is available to bpf programs attaching +	 * to a cgroup. The newer BPF_MAP_TYPE_CGRP_STORAGE is available to +	 * both cgroup-attached and other progs and supports all functionality +	 * provided by BPF_MAP_TYPE_CGROUP_STORAGE. So mark +	 * BPF_MAP_TYPE_CGROUP_STORAGE deprecated. +	 */ +	BPF_MAP_TYPE_CGROUP_STORAGE = BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED,  	BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, -	BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE, +	BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED, +	/* BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE is available to bpf programs +	 * attaching to a cgroup. The new mechanism (BPF_MAP_TYPE_CGRP_STORAGE + +	 * local percpu kptr) supports all BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE +	 * functionality and more. So mark * BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE +	 * deprecated. +	 */ +	BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE_DEPRECATED,  	BPF_MAP_TYPE_QUEUE,  	BPF_MAP_TYPE_STACK,  	BPF_MAP_TYPE_SK_STORAGE,  	BPF_MAP_TYPE_DEVMAP_HASH,  	BPF_MAP_TYPE_STRUCT_OPS,  	BPF_MAP_TYPE_RINGBUF, +	BPF_MAP_TYPE_INODE_STORAGE, +	BPF_MAP_TYPE_TASK_STORAGE, +	BPF_MAP_TYPE_BLOOM_FILTER, +	BPF_MAP_TYPE_USER_RINGBUF, +	BPF_MAP_TYPE_CGRP_STORAGE, +	BPF_MAP_TYPE_ARENA, +	__MAX_BPF_MAP_TYPE  };  /* Note that tracing related programs such as @@ -197,6 +1069,9 @@ enum bpf_prog_type {  	BPF_PROG_TYPE_EXT,  	BPF_PROG_TYPE_LSM,  	BPF_PROG_TYPE_SK_LOOKUP, +	BPF_PROG_TYPE_SYSCALL, /* a program that can execute syscalls */ +	BPF_PROG_TYPE_NETFILTER, +	__MAX_BPF_PROG_TYPE  };  enum bpf_attach_type { @@ -238,11 +1113,34 @@ enum bpf_attach_type {  	BPF_XDP_CPUMAP,  	BPF_SK_LOOKUP,  	BPF_XDP, +	BPF_SK_SKB_VERDICT, +	BPF_SK_REUSEPORT_SELECT, +	BPF_SK_REUSEPORT_SELECT_OR_MIGRATE, +	BPF_PERF_EVENT, +	BPF_TRACE_KPROBE_MULTI, +	BPF_LSM_CGROUP, +	BPF_STRUCT_OPS, +	BPF_NETFILTER, +	BPF_TCX_INGRESS, +	BPF_TCX_EGRESS, +	BPF_TRACE_UPROBE_MULTI, +	BPF_CGROUP_UNIX_CONNECT, +	BPF_CGROUP_UNIX_SENDMSG, +	BPF_CGROUP_UNIX_RECVMSG, +	BPF_CGROUP_UNIX_GETPEERNAME, +	BPF_CGROUP_UNIX_GETSOCKNAME, +	BPF_NETKIT_PRIMARY, +	BPF_NETKIT_PEER, +	BPF_TRACE_KPROBE_SESSION, +	BPF_TRACE_UPROBE_SESSION,  	__MAX_BPF_ATTACH_TYPE  };  #define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE +/* Add BPF_LINK_TYPE(type, name) in bpf_types.h to keep bpf_link_type_strs[] + * in sync with the definitions below. + */  enum bpf_link_type {  	BPF_LINK_TYPE_UNSPEC = 0,  	BPF_LINK_TYPE_RAW_TRACEPOINT = 1, @@ -251,8 +1149,27 @@ enum bpf_link_type {  	BPF_LINK_TYPE_ITER = 4,  	BPF_LINK_TYPE_NETNS = 5,  	BPF_LINK_TYPE_XDP = 6, +	BPF_LINK_TYPE_PERF_EVENT = 7, +	BPF_LINK_TYPE_KPROBE_MULTI = 8, +	BPF_LINK_TYPE_STRUCT_OPS = 9, +	BPF_LINK_TYPE_NETFILTER = 10, +	BPF_LINK_TYPE_TCX = 11, +	BPF_LINK_TYPE_UPROBE_MULTI = 12, +	BPF_LINK_TYPE_NETKIT = 13, +	BPF_LINK_TYPE_SOCKMAP = 14, +	__MAX_BPF_LINK_TYPE, +}; -	MAX_BPF_LINK_TYPE, +#define MAX_BPF_LINK_TYPE __MAX_BPF_LINK_TYPE + +enum bpf_perf_event_type { +	BPF_PERF_EVENT_UNSPEC = 0, +	BPF_PERF_EVENT_UPROBE = 1, +	BPF_PERF_EVENT_URETPROBE = 2, +	BPF_PERF_EVENT_KPROBE = 3, +	BPF_PERF_EVENT_KRETPROBE = 4, +	BPF_PERF_EVENT_TRACEPOINT = 5, +	BPF_PERF_EVENT_EVENT = 6,  };  /* cgroup-bpf attach flags used in BPF_PROG_ATTACH command @@ -301,7 +1218,13 @@ enum bpf_link_type {   */  #define BPF_F_ALLOW_OVERRIDE	(1U << 0)  #define BPF_F_ALLOW_MULTI	(1U << 1) +/* Generic attachment flags. */  #define BPF_F_REPLACE		(1U << 2) +#define BPF_F_BEFORE		(1U << 3) +#define BPF_F_AFTER		(1U << 4) +#define BPF_F_ID		(1U << 5) +#define BPF_F_PREORDER		(1U << 6) +#define BPF_F_LINK		BPF_F_LINK /* 1 << 13 */  /* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the   * verifier will perform strict alignment checking as if the kernel @@ -310,7 +1233,7 @@ enum bpf_link_type {   */  #define BPF_F_STRICT_ALIGNMENT	(1U << 0) -/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the +/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROG_LOAD command, the   * verifier will allow any alignment whatsoever.  On platforms   * with strict alignment requirements for loads ands stores (such   * as sparc and mips) the verifier validates that all loads and @@ -345,24 +1268,103 @@ enum bpf_link_type {  /* The verifier internal test flag. Behavior is undefined */  #define BPF_F_TEST_STATE_FREQ	(1U << 3) +/* If BPF_F_SLEEPABLE is used in BPF_PROG_LOAD command, the verifier will + * restrict map and helper usage for such programs. Sleepable BPF programs can + * only be attached to hooks where kernel execution context allows sleeping. + * Such programs are allowed to use helpers that may sleep like + * bpf_copy_from_user(). + */ +#define BPF_F_SLEEPABLE		(1U << 4) + +/* If BPF_F_XDP_HAS_FRAGS is used in BPF_PROG_LOAD command, the loaded program + * fully support xdp frags. + */ +#define BPF_F_XDP_HAS_FRAGS	(1U << 5) + +/* If BPF_F_XDP_DEV_BOUND_ONLY is used in BPF_PROG_LOAD command, the loaded + * program becomes device-bound but can access XDP metadata. + */ +#define BPF_F_XDP_DEV_BOUND_ONLY	(1U << 6) + +/* The verifier internal test flag. Behavior is undefined */ +#define BPF_F_TEST_REG_INVARIANTS	(1U << 7) + +/* link_create.kprobe_multi.flags used in LINK_CREATE command for + * BPF_TRACE_KPROBE_MULTI attach type to create return probe. + */ +enum { +	BPF_F_KPROBE_MULTI_RETURN = (1U << 0) +}; + +/* link_create.uprobe_multi.flags used in LINK_CREATE command for + * BPF_TRACE_UPROBE_MULTI attach type to create return probe. + */ +enum { +	BPF_F_UPROBE_MULTI_RETURN = (1U << 0) +}; + +/* link_create.netfilter.flags used in LINK_CREATE command for + * BPF_PROG_TYPE_NETFILTER to enable IP packet defragmentation. + */ +#define BPF_F_NETFILTER_IP_DEFRAG (1U << 0) +  /* When BPF ldimm64's insn[0].src_reg != 0 then this can have - * two extensions: - * - * insn[0].src_reg:  BPF_PSEUDO_MAP_FD   BPF_PSEUDO_MAP_VALUE - * insn[0].imm:      map fd              map fd - * insn[1].imm:      0                   offset into value - * insn[0].off:      0                   0 - * insn[1].off:      0                   0 - * ldimm64 rewrite:  address of map      address of map[0]+offset - * verifier type:    CONST_PTR_TO_MAP    PTR_TO_MAP_VALUE + * the following extensions: + * + * insn[0].src_reg:  BPF_PSEUDO_MAP_[FD|IDX] + * insn[0].imm:      map fd or fd_idx + * insn[1].imm:      0 + * insn[0].off:      0 + * insn[1].off:      0 + * ldimm64 rewrite:  address of map + * verifier type:    CONST_PTR_TO_MAP   */  #define BPF_PSEUDO_MAP_FD	1 -#define BPF_PSEUDO_MAP_VALUE	2 +#define BPF_PSEUDO_MAP_IDX	5 + +/* insn[0].src_reg:  BPF_PSEUDO_MAP_[IDX_]VALUE + * insn[0].imm:      map fd or fd_idx + * insn[1].imm:      offset into value + * insn[0].off:      0 + * insn[1].off:      0 + * ldimm64 rewrite:  address of map[0]+offset + * verifier type:    PTR_TO_MAP_VALUE + */ +#define BPF_PSEUDO_MAP_VALUE		2 +#define BPF_PSEUDO_MAP_IDX_VALUE	6 + +/* insn[0].src_reg:  BPF_PSEUDO_BTF_ID + * insn[0].imm:      kernel btd id of VAR + * insn[1].imm:      0 + * insn[0].off:      0 + * insn[1].off:      0 + * ldimm64 rewrite:  address of the kernel variable + * verifier type:    PTR_TO_BTF_ID or PTR_TO_MEM, depending on whether the var + *                   is struct/union. + */ +#define BPF_PSEUDO_BTF_ID	3 +/* insn[0].src_reg:  BPF_PSEUDO_FUNC + * insn[0].imm:      insn offset to the func + * insn[1].imm:      0 + * insn[0].off:      0 + * insn[1].off:      0 + * ldimm64 rewrite:  address of the function + * verifier type:    PTR_TO_FUNC. + */ +#define BPF_PSEUDO_FUNC		4  /* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative   * offset to another bpf function   */  #define BPF_PSEUDO_CALL		1 +/* when bpf_call->src_reg == BPF_PSEUDO_KFUNC_CALL, + * bpf_call->imm == btf_id of a BTF_KIND_FUNC in the running kernel + */ +#define BPF_PSEUDO_KFUNC_CALL	2 + +enum bpf_addr_space_cast { +	BPF_ADDR_SPACE_CAST = 1, +};  /* flags for BPF_MAP_UPDATE_ELEM command */  enum { @@ -404,16 +1406,49 @@ enum {  /* Enable memory-mapping BPF map */  	BPF_F_MMAPABLE		= (1U << 10), + +/* Share perf_event among processes */ +	BPF_F_PRESERVE_ELEMS	= (1U << 11), + +/* Create a map that is suitable to be an inner map with dynamic max entries */ +	BPF_F_INNER_MAP		= (1U << 12), + +/* Create a map that will be registered/unregesitered by the backed bpf_link */ +	BPF_F_LINK		= (1U << 13), + +/* Get path from provided FD in BPF_OBJ_PIN/BPF_OBJ_GET commands */ +	BPF_F_PATH_FD		= (1U << 14), + +/* Flag for value_type_btf_obj_fd, the fd is available */ +	BPF_F_VTYPE_BTF_OBJ_FD	= (1U << 15), + +/* BPF token FD is passed in a corresponding command's token_fd field */ +	BPF_F_TOKEN_FD          = (1U << 16), + +/* When user space page faults in bpf_arena send SIGSEGV instead of inserting new page */ +	BPF_F_SEGV_ON_FAULT	= (1U << 17), + +/* Do not translate kernel bpf_arena pointers to user pointers */ +	BPF_F_NO_USER_CONV	= (1U << 18),  };  /* Flags for BPF_PROG_QUERY. */  /* Query effective (directly attached + inherited from ancestor cgroups)   * programs that will be executed for events within a cgroup. - * attach_flags with this flag are returned only for directly attached programs. + * attach_flags with this flag are always returned 0.   */  #define BPF_F_QUERY_EFFECTIVE	(1U << 0) +/* Flags for BPF_PROG_TEST_RUN */ + +/* If set, run the test on the cpu specified by bpf_attr.test.cpu */ +#define BPF_F_TEST_RUN_ON_CPU	(1U << 0) +/* If set, XDP frames will be transmitted after processing */ +#define BPF_F_TEST_XDP_LIVE_FRAMES	(1U << 1) +/* If set, apply CHECKSUM_COMPLETE to skb and validate the checksum */ +#define BPF_F_TEST_SKB_CHECKSUM_COMPLETE	(1U << 2) +  /* type for BPF_ENABLE_STATS */  enum bpf_stats_type {  	/* enabled run_time_ns and run_cnt */ @@ -441,6 +1476,11 @@ struct bpf_stack_build_id {  #define BPF_OBJ_NAME_LEN 16U +enum { +	BPF_STREAM_STDOUT = 1, +	BPF_STREAM_STDERR = 2, +}; +  union bpf_attr {  	struct { /* anonymous struct used by BPF_MAP_CREATE command */  		__u32	map_type;	/* one of enum bpf_map_type */ @@ -463,9 +1503,28 @@ union bpf_attr {  						   * struct stored as the  						   * map value  						   */ +		/* Any per-map-type extra fields +		 * +		 * BPF_MAP_TYPE_BLOOM_FILTER - the lowest 4 bits indicate the +		 * number of hash functions (if 0, the bloom filter will default +		 * to using 5 hash functions). +		 * +		 * BPF_MAP_TYPE_ARENA - contains the address where user space +		 * is going to mmap() the arena. It has to be page aligned. +		 */ +		__u64	map_extra; + +		__s32   value_type_btf_obj_fd;	/* fd pointing to a BTF +						 * type data for +						 * btf_vmlinux_value_type_id. +						 */ +		/* BPF token FD to use with BPF_MAP_CREATE operation. +		 * If provided, map_flags should have BPF_F_TOKEN_FD flag set. +		 */ +		__s32	map_token_fd;  	}; -	struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */ +	struct { /* anonymous struct used by BPF_MAP_*_ELEM and BPF_MAP_FREEZE commands */  		__u32		map_fd;  		__aligned_u64	key;  		union { @@ -517,24 +1576,64 @@ union bpf_attr {  		__aligned_u64	line_info;	/* line info */  		__u32		line_info_cnt;	/* number of bpf_line_info records */  		__u32		attach_btf_id;	/* in-kernel BTF type id to attach to */ -		__u32		attach_prog_fd; /* 0 to attach to vmlinux */ +		union { +			/* valid prog_fd to attach to bpf prog */ +			__u32		attach_prog_fd; +			/* or valid module BTF object fd or 0 to attach to vmlinux */ +			__u32		attach_btf_obj_fd; +		}; +		__u32		core_relo_cnt;	/* number of bpf_core_relo */ +		__aligned_u64	fd_array;	/* array of FDs */ +		__aligned_u64	core_relos; +		__u32		core_relo_rec_size; /* sizeof(struct bpf_core_relo) */ +		/* output: actual total log contents size (including termintaing zero). +		 * It could be both larger than original log_size (if log was +		 * truncated), or smaller (if log buffer wasn't filled completely). +		 */ +		__u32		log_true_size; +		/* BPF token FD to use with BPF_PROG_LOAD operation. +		 * If provided, prog_flags should have BPF_F_TOKEN_FD flag set. +		 */ +		__s32		prog_token_fd; +		/* The fd_array_cnt can be used to pass the length of the +		 * fd_array array. In this case all the [map] file descriptors +		 * passed in this array will be bound to the program, even if +		 * the maps are not referenced directly. The functionality is +		 * similar to the BPF_PROG_BIND_MAP syscall, but maps can be +		 * used by the verifier during the program load. If provided, +		 * then the fd_array[0,...,fd_array_cnt-1] is expected to be +		 * continuous. +		 */ +		__u32		fd_array_cnt;  	};  	struct { /* anonymous struct used by BPF_OBJ_* commands */  		__aligned_u64	pathname;  		__u32		bpf_fd;  		__u32		file_flags; +		/* Same as dirfd in openat() syscall; see openat(2) +		 * manpage for details of path FD and pathname semantics; +		 * path_fd should accompanied by BPF_F_PATH_FD flag set in +		 * file_flags field, otherwise it should be set to zero; +		 * if BPF_F_PATH_FD flag is not set, AT_FDCWD is assumed. +		 */ +		__s32		path_fd;  	};  	struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */ -		__u32		target_fd;	/* container object to attach to */ -		__u32		attach_bpf_fd;	/* eBPF program to attach */ +		union { +			__u32	target_fd;	/* target object to attach to or ... */ +			__u32	target_ifindex;	/* target ifindex */ +		}; +		__u32		attach_bpf_fd;  		__u32		attach_type;  		__u32		attach_flags; -		__u32		replace_bpf_fd;	/* previously attached eBPF -						 * program to replace if -						 * BPF_F_REPLACE is used -						 */ +		__u32		replace_bpf_fd; +		union { +			__u32	relative_fd; +			__u32	relative_id; +		}; +		__u64		expected_revision;  	};  	struct { /* anonymous struct used by BPF_PROG_TEST_RUN command */ @@ -556,6 +1655,9 @@ union bpf_attr {  						 */  		__aligned_u64	ctx_in;  		__aligned_u64	ctx_out; +		__u32		flags; +		__u32		cpu; +		__u32		batch_size;  	} test;  	struct { /* anonymous struct used by BPF_*_GET_*_ID */ @@ -568,6 +1670,7 @@ union bpf_attr {  		};  		__u32		next_id;  		__u32		open_flags; +		__s32		fd_by_id_token_fd;  	};  	struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */ @@ -577,17 +1680,33 @@ union bpf_attr {  	} info;  	struct { /* anonymous struct used by BPF_PROG_QUERY command */ -		__u32		target_fd;	/* container object to query */ +		union { +			__u32	target_fd;	/* target object to query or ... */ +			__u32	target_ifindex;	/* target ifindex */ +		};  		__u32		attach_type;  		__u32		query_flags;  		__u32		attach_flags;  		__aligned_u64	prog_ids; -		__u32		prog_cnt; +		union { +			__u32	prog_cnt; +			__u32	count; +		}; +		__u32		:32; +		/* output: per-program attach_flags. +		 * not allowed to be set during effective query. +		 */ +		__aligned_u64	prog_attach_flags; +		__aligned_u64	link_ids; +		__aligned_u64	link_attach_flags; +		__u64		revision;  	} query;  	struct { /* anonymous struct used by BPF_RAW_TRACEPOINT_OPEN command */ -		__u64 name; -		__u32 prog_fd; +		__u64		name; +		__u32		prog_fd; +		__u32		:32; +		__aligned_u64	cookie;  	} raw_tracepoint;  	struct { /* anonymous struct for BPF_BTF_LOAD */ @@ -596,6 +1715,16 @@ union bpf_attr {  		__u32		btf_size;  		__u32		btf_log_size;  		__u32		btf_log_level; +		/* output: actual total log contents size (including termintaing zero). +		 * It could be both larger than original log_size (if log was +		 * truncated), or smaller (if log buffer wasn't filled completely). +		 */ +		__u32		btf_log_true_size; +		__u32		btf_flags; +		/* BPF token FD to use with BPF_BTF_LOAD operation. +		 * If provided, btf_flags should have BPF_F_TOKEN_FD flag set. +		 */ +		__s32		btf_token_fd;  	};  	struct { @@ -615,25 +1744,103 @@ union bpf_attr {  	} task_fd_query;  	struct { /* struct used by BPF_LINK_CREATE command */ -		__u32		prog_fd;	/* eBPF program to attach */  		union { -			__u32		target_fd;	/* object to attach to */ -			__u32		target_ifindex; /* target ifindex */ +			__u32		prog_fd;	/* eBPF program to attach */ +			__u32		map_fd;		/* struct_ops to attach */ +		}; +		union { +			__u32	target_fd;	/* target object to attach to or ... */ +			__u32	target_ifindex; /* target ifindex */  		};  		__u32		attach_type;	/* attach type */  		__u32		flags;		/* extra flags */ -		__aligned_u64	iter_info;	/* extra bpf_iter_link_info */ -		__u32		iter_info_len;	/* iter_info length */ +		union { +			__u32	target_btf_id;	/* btf_id of target to attach to */ +			struct { +				__aligned_u64	iter_info;	/* extra bpf_iter_link_info */ +				__u32		iter_info_len;	/* iter_info length */ +			}; +			struct { +				/* black box user-provided value passed through +				 * to BPF program at the execution time and +				 * accessible through bpf_get_attach_cookie() BPF helper +				 */ +				__u64		bpf_cookie; +			} perf_event; +			struct { +				__u32		flags; +				__u32		cnt; +				__aligned_u64	syms; +				__aligned_u64	addrs; +				__aligned_u64	cookies; +			} kprobe_multi; +			struct { +				/* this is overlaid with the target_btf_id above. */ +				__u32		target_btf_id; +				/* black box user-provided value passed through +				 * to BPF program at the execution time and +				 * accessible through bpf_get_attach_cookie() BPF helper +				 */ +				__u64		cookie; +			} tracing; +			struct { +				__u32		pf; +				__u32		hooknum; +				__s32		priority; +				__u32		flags; +			} netfilter; +			struct { +				union { +					__u32	relative_fd; +					__u32	relative_id; +				}; +				__u64		expected_revision; +			} tcx; +			struct { +				__aligned_u64	path; +				__aligned_u64	offsets; +				__aligned_u64	ref_ctr_offsets; +				__aligned_u64	cookies; +				__u32		cnt; +				__u32		flags; +				__u32		pid; +			} uprobe_multi; +			struct { +				union { +					__u32	relative_fd; +					__u32	relative_id; +				}; +				__u64		expected_revision; +			} netkit; +			struct { +				union { +					__u32	relative_fd; +					__u32	relative_id; +				}; +				__u64		expected_revision; +			} cgroup; +		};  	} link_create;  	struct { /* struct used by BPF_LINK_UPDATE command */  		__u32		link_fd;	/* link fd */ -		/* new program fd to update link with */ -		__u32		new_prog_fd; +		union { +			/* new program fd to update link with */ +			__u32		new_prog_fd; +			/* new struct_ops map fd to update link with */ +			__u32           new_map_fd; +		};  		__u32		flags;		/* extra flags */ -		/* expected link's program fd; is specified only if -		 * BPF_F_REPLACE flag is set in flags */ -		__u32		old_prog_fd; +		union { +			/* expected link's program fd; is specified only if +			 * BPF_F_REPLACE flag is set in flags. +			 */ +			__u32		old_prog_fd; +			/* expected link's map fd; is specified only +			 * if BPF_F_REPLACE flag is set. +			 */ +			__u32           old_map_fd; +		};  	} link_update;  	struct { @@ -649,6 +1856,24 @@ union bpf_attr {  		__u32		flags;  	} iter_create; +	struct { /* struct used by BPF_PROG_BIND_MAP command */ +		__u32		prog_fd; +		__u32		map_fd; +		__u32		flags;		/* extra flags */ +	} prog_bind_map; + +	struct { /* struct used by BPF_TOKEN_CREATE command */ +		__u32		flags; +		__u32		bpffs_fd; +	} token_create; + +	struct { +		__aligned_u64	stream_buf; +		__u32		stream_buf_len; +		__u32		stream_id; +		__u32		prog_fd; +	} prog_stream_read; +  } __attribute__((aligned(8)));  /* The description below is an attempt at providing documentation to eBPF @@ -656,7 +1881,7 @@ union bpf_attr {   * parsed and used to produce a manual page. The workflow is the following,   * and requires the rst2man utility:   * - *     $ ./scripts/bpf_helpers_doc.py \ + *     $ ./scripts/bpf_doc.py \   *             --filename include/uapi/linux/bpf.h > /tmp/bpf-helpers.rst   *     $ rst2man /tmp/bpf-helpers.rst > /tmp/bpf-helpers.7   *     $ man /tmp/bpf-helpers.7 @@ -721,17 +1946,17 @@ union bpf_attr {   * 	Description   * 		This helper is a "printk()-like" facility for debugging. It   * 		prints a message defined by format *fmt* (of size *fmt_size*) - * 		to file *\/sys/kernel/debug/tracing/trace* from DebugFS, if + * 		to file *\/sys/kernel/tracing/trace* from TraceFS, if   * 		available. It can take up to three additional **u64**   * 		arguments (as an eBPF helpers, the total number of arguments is   * 		limited to five).   *   * 		Each time the helper is called, it appends a line to the trace. - * 		Lines are discarded while *\/sys/kernel/debug/tracing/trace* is - * 		open, use *\/sys/kernel/debug/tracing/trace_pipe* to avoid this. + * 		Lines are discarded while *\/sys/kernel/tracing/trace* is + * 		open, use *\/sys/kernel/tracing/trace_pipe* to avoid this.   * 		The format of the trace is customizable, and the exact output   * 		one will get depends on the options set in - * 		*\/sys/kernel/debug/tracing/trace_options* (see also the + * 		*\/sys/kernel/tracing/trace_options* (see also the   * 		*README* file under the same directory). However, it usually   * 		defaults to something like:   * @@ -791,20 +2016,26 @@ union bpf_attr {   * u32 bpf_get_smp_processor_id(void)   * 	Description   * 		Get the SMP (symmetric multiprocessing) processor id. Note that - * 		all programs run with preemption disabled, which means that the + * 		all programs run with migration disabled, which means that the   * 		SMP processor id is stable during all the execution of the   * 		program.   * 	Return   * 		The SMP id of the processor running the program. + * 	Attributes + * 		__bpf_fastcall   *   * long bpf_skb_store_bytes(struct sk_buff *skb, u32 offset, const void *from, u32 len, u64 flags)   * 	Description   * 		Store *len* bytes from address *from* into the packet - * 		associated to *skb*, at *offset*. *flags* are a combination of - * 		**BPF_F_RECOMPUTE_CSUM** (automatically recompute the - * 		checksum for the packet after storing the bytes) and - * 		**BPF_F_INVALIDATE_HASH** (set *skb*\ **->hash**, *skb*\ - * 		**->swhash** and *skb*\ **->l4hash** to 0). + * 		associated to *skb*, at *offset*. The *flags* are a combination + * 		of the following values: + * + * 		**BPF_F_RECOMPUTE_CSUM** + * 			Automatically update *skb*\ **->csum** after storing the + * 			bytes. + * 		**BPF_F_INVALIDATE_HASH** + * 			Set *skb*\ **->hash**, *skb*\ **->swhash** and *skb*\ + * 			**->l4hash** to 0.   *   * 		A call to this helper is susceptible to change the underlying   * 		packet buffer. Therefore, at load time, all checks on pointers @@ -856,7 +2087,8 @@ union bpf_attr {   * 		untouched (unless **BPF_F_MARK_ENFORCE** is added as well), and   * 		for updates resulting in a null checksum the value is set to   * 		**CSUM_MANGLED_0** instead. Flag **BPF_F_PSEUDO_HDR** indicates - * 		the checksum is to be computed against a pseudo-header. + * 		that the modified header field is part of the pseudo-header. + * 		Flag **BPF_F_IPV6** should be set for IPv6 packets.   *   * 		This helper works in combination with **bpf_csum_diff**\ (),   * 		which does not update the checksum in-place, but offers more @@ -898,7 +2130,7 @@ union bpf_attr {   * 		if the maximum number of tail calls has been reached for this   * 		chain of programs. This limit is defined in the kernel by the   * 		macro **MAX_TAIL_CALL_CNT** (not accessible to user space), - * 		which is currently set to 32. + *		which is currently set to 33.   * 	Return   * 		0 on success, or a negative error in case of failure.   * @@ -924,9 +2156,13 @@ union bpf_attr {   * 		performed again, if the helper is used in combination with   * 		direct packet access.   * 	Return - * 		0 on success, or a negative error in case of failure. + * 		0 on success, or a negative error in case of failure. Positive + * 		error indicates a potential drop or congestion in the target + * 		device. The particular positive error codes are not defined.   *   * u64 bpf_get_current_pid_tgid(void) + * 	Description + * 		Get the current pid and tgid.   * 	Return   * 		A 64-bit integer containing the current tgid and pid, and   * 		created as such: @@ -934,6 +2170,8 @@ union bpf_attr {   * 		*current_task*\ **->pid**.   *   * u64 bpf_get_current_uid_gid(void) + * 	Description + * 		Get the current uid and gid.   * 	Return   * 		A 64-bit integer containing the current GID and UID, and   * 		created as such: *current_gid* **<< 32 \|** *current_uid*. @@ -1076,6 +2314,9 @@ union bpf_attr {   * 			sending the packet. This flag was added for GRE   * 			encapsulation, but might be used with other protocols   * 			as well in the future. + * 		**BPF_F_NO_TUNNEL_KEY** + * 			Add a flag to tunnel metadata indicating that no tunnel + * 			key should be set in the resulting tunnel header.   *   * 		Here is a typical usage on the transmit path:   * @@ -1194,7 +2435,7 @@ union bpf_attr {   * 		into it. An example is available in file   * 		*samples/bpf/trace_output_user.c* in the Linux kernel source   * 		tree (the eBPF program counterpart is in - * 		*samples/bpf/trace_output_kern.c*). + *		*samples/bpf/trace_output.bpf.c*).   *   * 		**bpf_perf_event_output**\ () achieves better performance   * 		than **bpf_trace_printk**\ () for sharing data with user @@ -1408,6 +2649,8 @@ union bpf_attr {   * 		The 32-bit hash.   *   * u64 bpf_get_current_task(void) + * 	Description + * 		Get the current task.   * 	Return   * 		A pointer to the current task struct.   * @@ -1438,8 +2681,8 @@ union bpf_attr {   * 	Return   * 		The return value depends on the result of the test, and can be:   * - * 		* 0, if the *skb* task belongs to the cgroup2. - * 		* 1, if the *skb* task does not belong to the cgroup2. + *		* 1, if current task belongs to the cgroup2. + *		* 0, if current task does not belong to the cgroup2.   * 		* A negative error code, if an error occurred.   *   * long bpf_skb_change_tail(struct sk_buff *skb, u32 len, u64 flags) @@ -1471,7 +2714,8 @@ union bpf_attr {   * 		Pull in non-linear data in case the *skb* is non-linear and not   * 		all of *len* are part of the linear section. Make *len* bytes   * 		from *skb* readable and writable. If a zero value is passed for - * 		*len*, then the whole length of the *skb* is pulled. + *		*len*, then all bytes in the linear part of *skb* will be made + *		readable and writable.   *   * 		This helper is only needed for reading and writing with direct   * 		packet access. @@ -1521,6 +2765,8 @@ union bpf_attr {   * 		indicate that the hash is outdated and to trigger a   * 		recalculation the next time the kernel tries to access this   * 		hash or when the **bpf_get_hash_recalc**\ () helper is called. + * 	Return + * 		void.   *   * long bpf_get_numa_node_id(void)   * 	Description @@ -1592,24 +2838,34 @@ union bpf_attr {   * 		networking traffic statistics as it provides a global socket   * 		identifier that can be assumed unique.   * 	Return - * 		A 8-byte long non-decreasing number on success, or 0 if the - * 		socket field is missing inside *skb*. + * 		A 8-byte long unique number on success, or 0 if the socket + * 		field is missing inside *skb*.   *   * u64 bpf_get_socket_cookie(struct bpf_sock_addr *ctx)   * 	Description   * 		Equivalent to bpf_get_socket_cookie() helper that accepts   * 		*skb*, but gets socket from **struct bpf_sock_addr** context.   * 	Return - * 		A 8-byte long non-decreasing number. + * 		A 8-byte long unique number.   *   * u64 bpf_get_socket_cookie(struct bpf_sock_ops *ctx)   * 	Description   * 		Equivalent to **bpf_get_socket_cookie**\ () helper that accepts   * 		*skb*, but gets socket from **struct bpf_sock_ops** context.   * 	Return - * 		A 8-byte long non-decreasing number. + * 		A 8-byte long unique number. + * + * u64 bpf_get_socket_cookie(struct sock *sk) + * 	Description + * 		Equivalent to **bpf_get_socket_cookie**\ () helper that accepts + * 		*sk*, but gets socket from a BTF **struct sock**. This helper + * 		also works for sleepable programs. + * 	Return + * 		A 8-byte long unique number or 0 if *sk* is NULL.   *   * u32 bpf_get_socket_uid(struct sk_buff *skb) + * 	Description + * 		Get the owner UID of the socked associated to *skb*.   * 	Return   * 		The owner UID of the socket associated to *skb*. If the socket   * 		is **NULL**, or if it is not a full socket (i.e. if it is a @@ -1635,8 +2891,8 @@ union bpf_attr {   * 		*bpf_socket* should be one of the following:   *   * 		* **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**. - * 		* **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT** - * 		  and **BPF_CGROUP_INET6_CONNECT**. + *		* **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT**, + *		  **BPF_CGROUP_INET6_CONNECT** and **BPF_CGROUP_UNIX_CONNECT**.   *   * 		This helper actually implements a subset of **setsockopt()**.   * 		It supports the following *level*\ s: @@ -1644,14 +2900,19 @@ union bpf_attr {   * 		* **SOL_SOCKET**, which supports the following *optname*\ s:   * 		  **SO_RCVBUF**, **SO_SNDBUF**, **SO_MAX_PACING_RATE**,   * 		  **SO_PRIORITY**, **SO_RCVLOWAT**, **SO_MARK**, - * 		  **SO_BINDTODEVICE**, **SO_KEEPALIVE**. + * 		  **SO_BINDTODEVICE**, **SO_KEEPALIVE**, **SO_REUSEADDR**, + * 		  **SO_REUSEPORT**, **SO_BINDTOIFINDEX**, **SO_TXREHASH**.   * 		* **IPPROTO_TCP**, which supports the following *optname*\ s:   * 		  **TCP_CONGESTION**, **TCP_BPF_IW**,   * 		  **TCP_BPF_SNDCWND_CLAMP**, **TCP_SAVE_SYN**,   * 		  **TCP_KEEPIDLE**, **TCP_KEEPINTVL**, **TCP_KEEPCNT**, - * 		  **TCP_SYNCNT**, **TCP_USER_TIMEOUT**. + * 		  **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**, + * 		  **TCP_NODELAY**, **TCP_MAXSEG**, **TCP_WINDOW_CLAMP**, + * 		  **TCP_THIN_LINEAR_TIMEOUTS**, **TCP_BPF_DELACK_MAX**, + *		  **TCP_BPF_RTO_MIN**, **TCP_BPF_SOCK_OPS_CB_FLAGS**.   * 		* **IPPROTO_IP**, which supports *optname* **IP_TOS**. - * 		* **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**. + * 		* **IPPROTO_IPV6**, which supports the following *optname*\ s: + * 		  **IPV6_TCLASS**, **IPV6_AUTOFLOWLABEL**.   * 	Return   * 		0 on success, or a negative error in case of failure.   * @@ -1670,10 +2931,12 @@ union bpf_attr {   *		There are two supported modes at this time:   *   *		* **BPF_ADJ_ROOM_MAC**: Adjust room at the mac layer - *		  (room space is added or removed below the layer 2 header). + * 		  (room space is added or removed between the layer 2 and + * 		  layer 3 headers).   *   * 		* **BPF_ADJ_ROOM_NET**: Adjust room at the network layer - * 		  (room space is added or removed below the layer 3 header). + * 		  (room space is added or removed between the layer 3 and + * 		  layer 4 headers).   *   *		The following flags are supported at this time:   * @@ -1693,6 +2956,15 @@ union bpf_attr {   *		  Use with ENCAP_L3/L4 flags to further specify the tunnel   *		  type; *len* is the length of the inner MAC header.   * + *		* **BPF_F_ADJ_ROOM_ENCAP_L2_ETH**: + *		  Use with BPF_F_ADJ_ROOM_ENCAP_L2 flag to further specify the + *		  L2 type as Ethernet. + * + *		* **BPF_F_ADJ_ROOM_DECAP_L3_IPV4**, + *		  **BPF_F_ADJ_ROOM_DECAP_L3_IPV6**: + *		  Indicate the new IP header version after decapsulating the outer + *		  IP header. Used when the inner and outer IP versions are different. + *   * 		A call to this helper is susceptible to change the underlying   * 		packet buffer. Therefore, at load time, all checks on pointers   * 		previously done by the verifier are invalidated and must be @@ -1701,7 +2973,7 @@ union bpf_attr {   * 	Return   * 		0 on success, or a negative error in case of failure.   * - * long bpf_redirect_map(struct bpf_map *map, u32 key, u64 flags) + * long bpf_redirect_map(struct bpf_map *map, u64 key, u64 flags)   * 	Description   * 		Redirect the packet to the endpoint referenced by *map* at   * 		index *key*. Depending on its type, this *map* can contain @@ -1713,8 +2985,12 @@ union bpf_attr {   * 		The lower two bits of *flags* are used as the return code if   * 		the map lookup fails. This is so that the return value can be   * 		one of the XDP program return codes up to **XDP_TX**, as chosen - * 		by the caller. Any higher bits in the *flags* argument must be - * 		unset. + * 		by the caller. The higher bits of *flags* can be set to + * 		BPF_F_BROADCAST or BPF_F_EXCLUDE_INGRESS as defined below. + * + * 		With BPF_F_BROADCAST the packet will be broadcasted to all the + * 		interfaces in the map, with BPF_F_EXCLUDE_INGRESS the ingress + * 		interface will be excluded when do broadcasting.   *   * 		See also **bpf_redirect**\ (), which only supports redirecting   * 		to an ifindex, but doesn't require a map to do so. @@ -1833,7 +3109,7 @@ union bpf_attr {   *   * long bpf_perf_prog_read_value(struct bpf_perf_event_data *ctx, struct bpf_perf_event_value *buf, u32 buf_size)   * 	Description - * 		For en eBPF program attached to a perf event, retrieve the + * 		For an eBPF program attached to a perf event, retrieve the   * 		value of the event counter associated to *ctx* and store it in   * 		the structure pointed by *buf* and of size *buf_size*. Enabled   * 		and running times are also stored in the structure (see @@ -1854,16 +3130,14 @@ union bpf_attr {   * 		*bpf_socket* should be one of the following:   *   * 		* **struct bpf_sock_ops** for **BPF_PROG_TYPE_SOCK_OPS**. - * 		* **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT** - * 		  and **BPF_CGROUP_INET6_CONNECT**. + *		* **struct bpf_sock_addr** for **BPF_CGROUP_INET4_CONNECT**, + *		  **BPF_CGROUP_INET6_CONNECT** and **BPF_CGROUP_UNIX_CONNECT**.   *   * 		This helper actually implements a subset of **getsockopt()**. - * 		It supports the following *level*\ s: - * - * 		* **IPPROTO_TCP**, which supports *optname* - * 		  **TCP_CONGESTION**. - * 		* **IPPROTO_IP**, which supports *optname* **IP_TOS**. - * 		* **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**. + * 		It supports the same set of *optname*\ s that is supported by + * 		the **bpf_setsockopt**\ () helper.  The exceptions are + * 		**TCP_BPF_*** is **bpf_setsockopt**\ () only and + * 		**TCP_SAVED_SYN** is **bpf_getsockopt**\ () only.   * 	Return   * 		0 on success, or a negative error in case of failure.   * @@ -1885,10 +3159,6 @@ union bpf_attr {   * 		with the **CONFIG_BPF_KPROBE_OVERRIDE** configuration   * 		option, and in this case it only works on functions tagged with   * 		**ALLOW_ERROR_INJECTION** in the kernel code. - * - * 		Also, the helper is only available for the architectures having - * 		the CONFIG_FUNCTION_ERROR_INJECTION option. As of this writing, - * 		x86 architecture is the only one to support this feature.   * 	Return   * 		0   * @@ -2097,8 +3367,18 @@ union bpf_attr {   * 		**BPF_F_USER_STACK**   * 			Collect a user space stack instead of a kernel stack.   * 		**BPF_F_USER_BUILD_ID** - * 			Collect buildid+offset instead of ips for user stack, - * 			only valid if **BPF_F_USER_STACK** is also specified. + * 			Collect (build_id, file_offset) instead of ips for user + * 			stack, only valid if **BPF_F_USER_STACK** is also + * 			specified. + * + * 			*file_offset* is an offset relative to the beginning + * 			of the executable or shared object file backing the vma + * 			which the *ip* falls in. It is *not* an offset relative + * 			to that object's base address. Accordingly, it must be + * 			adjusted by adding (sh_addr - sh_offset), where + * 			sh_{addr,offset} correspond to the executable section + * 			containing *file_offset* in the object, for comparisons + * 			to symbols' st_value to be valid.   *   * 		**bpf_get_stack**\ () can collect up to   * 		**PERF_MAX_STACK_DEPTH** both kernel and user frames, subject @@ -2111,8 +3391,8 @@ union bpf_attr {   *   * 			# sysctl kernel.perf_event_max_stack=<new value>   * 	Return - * 		A non-negative value equal to or less than *size* on success, - * 		or a negative error in case of failure. + * 		The non-negative copied *buf* length equal to or less than + * 		*size* on success, or a negative error in case of failure.   *   * long bpf_skb_load_bytes_relative(const void *skb, u32 offset, void *to, u32 len, u32 start_header)   * 	Description @@ -2155,9 +3435,27 @@ union bpf_attr {   *		**BPF_FIB_LOOKUP_DIRECT**   *			Do a direct table lookup vs full lookup using FIB   *			rules. + *		**BPF_FIB_LOOKUP_TBID** + *			Used with BPF_FIB_LOOKUP_DIRECT. + *			Use the routing table ID present in *params*->tbid + *			for the fib lookup.   *		**BPF_FIB_LOOKUP_OUTPUT**   *			Perform lookup from an egress perspective (default is   *			ingress). + *		**BPF_FIB_LOOKUP_SKIP_NEIGH** + *			Skip the neighbour table lookup. *params*->dmac + *			and *params*->smac will not be set as output. A common + *			use case is to call **bpf_redirect_neigh**\ () after + *			doing **bpf_fib_lookup**\ (). + *		**BPF_FIB_LOOKUP_SRC** + *			Derive and set source IP addr in *params*->ipv{4,6}_src + *			for the nexthop. If the src addr cannot be derived, + *			**BPF_FIB_LKUP_RET_NO_SRC_ADDR** is returned. In this + *			case, *params*->dmac and *params*->smac are not set either. + *		**BPF_FIB_LOOKUP_MARK** + *			Use the mark present in *params*->mark for the fib lookup. + *			This option should not be used with BPF_FIB_LOOKUP_DIRECT, + *			as it only has meaning for full lookups.   *   *		*ctx* is either **struct xdp_md** for XDP programs or   *		**struct sk_buff** tc cls_act programs. @@ -2167,6 +3465,9 @@ union bpf_attr {   *		* > 0 one of **BPF_FIB_LKUP_RET_** codes explaining why the   *		  packet is not forwarded or needs assist from full stack   * + *		If lookup fails with BPF_FIB_LKUP_RET_FRAG_NEEDED, then the MTU + *		was exceeded and output params->mtu_result contains the MTU. + *   * long bpf_sock_hash_update(struct bpf_sock_ops *skops, struct bpf_map *map, void *key, u64 flags)   *	Description   *		Add an entry to, or update a sockhash *map* referencing sockets. @@ -2204,7 +3505,7 @@ union bpf_attr {   *	Description   *		This helper is used in programs implementing policies at the   *		skb socket level. If the sk_buff *skb* is allowed to pass (i.e. - *		if the verdeict eBPF program returns **SK_PASS**), redirect it + *		if the verdict eBPF program returns **SK_PASS**), redirect it   *		to the socket referenced by *map* (of type   *		**BPF_MAP_TYPE_SOCKHASH**) using hash *key*. Both ingress and   *		egress interfaces can be used for redirection. The @@ -2373,6 +3674,9 @@ union bpf_attr {   * 		The id is returned or 0 in case the id could not be retrieved.   *   * u64 bpf_get_current_cgroup_id(void) + * 	Description + * 		Get the current cgroup id based on the cgroup within which + * 		the current task is running.   * 	Return   * 		A 64-bit integer containing the current cgroup id based   * 		on the cgroup within which the current task is running. @@ -2390,7 +3694,7 @@ union bpf_attr {   *		running simultaneously.   *   *		A user should care about the synchronization by himself. - *		For example, by using the **BPF_STX_XADD** instruction to alter + *		For example, by using the **BPF_ATOMIC** instructions to alter   *		the shared data.   *	Return   *		A pointer to the local storage area. @@ -2398,7 +3702,7 @@ union bpf_attr {   * long bpf_sk_select_reuseport(struct sk_reuseport_md *reuse, struct bpf_map *map, void *key, u64 flags)   *	Description   *		Select a **SO_REUSEPORT** socket from a - *		**BPF_MAP_TYPE_REUSEPORT_ARRAY** *map*. + *		**BPF_MAP_TYPE_REUSEPORT_SOCKARRAY** *map*.   *		It checks the selected socket is matching the incoming   *		request in the socket buffer.   *	Return @@ -2496,7 +3800,7 @@ union bpf_attr {   *		result is from *reuse*\ **->socks**\ [] using the hash of the   *		tuple.   * - * long bpf_sk_release(struct bpf_sock *sock) + * long bpf_sk_release(void *sock)   *	Description   *		Release the reference held by *sock*. *sock* must be a   *		non-**NULL** pointer that was returned from @@ -2676,17 +3980,18 @@ union bpf_attr {   *		result is from *reuse*\ **->socks**\ [] using the hash of the   *		tuple.   * - * long bpf_tcp_check_syncookie(struct bpf_sock *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len) + * long bpf_tcp_check_syncookie(void *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len)   * 	Description   * 		Check whether *iph* and *th* contain a valid SYN cookie ACK for   * 		the listening socket in *sk*.   *   * 		*iph* points to the start of the IPv4 or IPv6 header, while   * 		*iph_len* contains **sizeof**\ (**struct iphdr**) or - * 		**sizeof**\ (**struct ip6hdr**). + * 		**sizeof**\ (**struct ipv6hdr**).   *   * 		*th* points to the start of the TCP header, while *th_len* - * 		contains **sizeof**\ (**struct tcphdr**). + *		contains the length of the TCP header (at least + *		**sizeof**\ (**struct tcphdr**)).   * 	Return   * 		0 if *iph* and *th* are a valid SYN cookie ACK, or a negative   * 		error otherwise. @@ -2807,7 +4112,7 @@ union bpf_attr {   *   *		**-ERANGE** if resulting value was out of range.   * - * void *bpf_sk_storage_get(struct bpf_map *map, struct bpf_sock *sk, void *value, u64 flags) + * void *bpf_sk_storage_get(struct bpf_map *map, void *sk, void *value, u64 flags)   *	Description   *		Get a bpf-local-storage from a *sk*.   * @@ -2823,6 +4128,9 @@ union bpf_attr {   *		"type". The bpf-local-storage "type" (i.e. the *map*) is   *		searched against all bpf-local-storages residing at *sk*.   * + *		*sk* is a kernel **struct sock** pointer for LSM program. + *		*sk* is a **struct bpf_sock** pointer for other program types. + *   *		An optional *flags* (**BPF_SK_STORAGE_GET_F_CREATE**) can be   *		used such that a new bpf-local-storage will be   *		created if one does not exist.  *value* can be used @@ -2835,13 +4143,14 @@ union bpf_attr {   *		**NULL** if not found or there was an error in adding   *		a new bpf-local-storage.   * - * long bpf_sk_storage_delete(struct bpf_map *map, struct bpf_sock *sk) + * long bpf_sk_storage_delete(struct bpf_map *map, void *sk)   *	Description   *		Delete a bpf-local-storage from a *sk*.   *	Return   *		0 on success.   *   *		**-ENOENT** if the bpf-local-storage cannot be found. + *		**-EINVAL** if sk is not a fullsock (e.g. a request_sock).   *   * long bpf_send_signal(u32 sig)   *	Description @@ -2858,17 +4167,18 @@ union bpf_attr {   *   *		**-EAGAIN** if bpf program can try again.   * - * s64 bpf_tcp_gen_syncookie(struct bpf_sock *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len) + * s64 bpf_tcp_gen_syncookie(void *sk, void *iph, u32 iph_len, struct tcphdr *th, u32 th_len)   *	Description   *		Try to issue a SYN cookie for the packet with corresponding   *		IP/TCP headers, *iph* and *th*, on the listening socket in *sk*.   *   *		*iph* points to the start of the IPv4 or IPv6 header, while   *		*iph_len* contains **sizeof**\ (**struct iphdr**) or - *		**sizeof**\ (**struct ip6hdr**). + *		**sizeof**\ (**struct ipv6hdr**).   *   *		*th* points to the start of the TCP header, while *th_len* - *		contains the length of the TCP header. + *		contains the length of the TCP header with options (at least + *		**sizeof**\ (**struct tcphdr**)).   *	Return   *		On success, lower 32 bits hold the generated SYN cookie in   *		followed by 16 bits which hold the MSS value for that cookie, @@ -2931,10 +4241,10 @@ union bpf_attr {   * 		string length is larger than *size*, just *size*-1 bytes are   * 		copied and the last byte is set to NUL.   * - * 		On success, the length of the copied string is returned. This - * 		makes this helper useful in tracing programs for reading - * 		strings, and more importantly to get its length at runtime. See - * 		the following snippet: + * 		On success, returns the number of bytes that were written, + * 		including the terminal NUL. This makes this helper useful in + * 		tracing programs for reading strings, and more importantly to + * 		get its length at runtime. See the following snippet:   *   * 		::   * @@ -2962,7 +4272,7 @@ union bpf_attr {   * 		**->mm->env_start**: using this helper and the return value,   * 		one can quickly iterate at the right offset of the memory area.   * 	Return - * 		On success, the strictly positive length of the string, + * 		On success, the strictly positive length of the output string,   * 		including the trailing NUL character. On error, a negative   * 		value.   * @@ -3087,7 +4397,7 @@ union bpf_attr {   * 	Return   * 		The id is returned or 0 in case the id could not be retrieved.   * - * long bpf_sk_assign(struct sk_buff *skb, struct bpf_sock *sk, u64 flags) + * long bpf_sk_assign(struct sk_buff *skb, void *sk, u64 flags)   *	Description   *		Helper is overloaded depending on BPF program type. This   *		description applies to **BPF_PROG_TYPE_SCHED_CLS** and @@ -3115,9 +4425,6 @@ union bpf_attr {   *		**-EOPNOTSUPP** if the operation is not supported, for example   *		a call from outside of TC ingress.   * - *		**-ESOCKTNOSUPPORT** if the socket type is not supported - *		(reuseport). - *   * long bpf_sk_assign(struct bpf_sk_lookup *ctx, struct bpf_sock *sk, u64 flags)   *	Description   *		Helper is overloaded depending on BPF program type. This @@ -3185,7 +4492,7 @@ union bpf_attr {   * 		arguments. The *data* are a **u64** array and corresponding format string   * 		values are stored in the array. For strings and pointers where pointees   * 		are accessed, only the pointer values are stored in the *data* array. - * 		The *data_len* is the size of *data* in bytes. + * 		The *data_len* is the size of *data* in bytes - must be a multiple of 8.   *   *		Formats **%s**, **%p{i,I}{4,6}** requires to read kernel memory.   *		Reading kernel memory may fail due to either invalid address or @@ -3215,11 +4522,11 @@ union bpf_attr {   *   *		**-EOVERFLOW** if an overflow happened: The same object will be tried again.   * - * u64 bpf_sk_cgroup_id(struct bpf_sock *sk) + * u64 bpf_sk_cgroup_id(void *sk)   *	Description   *		Return the cgroup v2 id of the socket *sk*.   * - *		*sk* must be a non-**NULL** pointer to a full socket, e.g. one + *		*sk* must be a non-**NULL** pointer to a socket, e.g. one   *		returned from **bpf_sk_lookup_xxx**\ (),   *		**bpf_sk_fullsock**\ (), etc. The format of returned id is   *		same as in **bpf_skb_cgroup_id**\ (). @@ -3229,7 +4536,7 @@ union bpf_attr {   *	Return   *		The id is returned or 0 in case the id could not be retrieved.   * - * u64 bpf_sk_ancestor_cgroup_id(struct bpf_sock *sk, int ancestor_level) + * u64 bpf_sk_ancestor_cgroup_id(void *sk, int ancestor_level)   *	Description   *		Return id of cgroup v2 that is ancestor of cgroup associated   *		with the *sk* at the *ancestor_level*.  The root cgroup is at @@ -3254,12 +4561,20 @@ union bpf_attr {   * 		of new data availability is sent.   * 		If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification   * 		of new data availability is sent unconditionally. + * 		If **0** is specified in *flags*, an adaptive notification + * 		of new data availability is sent. + * + * 		An adaptive notification is a notification sent whenever the user-space + * 		process has caught up and consumed all available payloads. In case the user-space + * 		process is still processing a previous payload, then no notification is needed + * 		as it will process the newly added payload automatically.   * 	Return   * 		0 on success, or a negative error in case of failure.   *   * void *bpf_ringbuf_reserve(void *ringbuf, u64 size, u64 flags)   * 	Description   * 		Reserve *size* bytes of payload in a ring buffer *ringbuf*. + * 		*flags* must be 0.   * 	Return   * 		Valid pointer with *size* bytes of memory available; NULL,   * 		otherwise. @@ -3271,6 +4586,10 @@ union bpf_attr {   * 		of new data availability is sent.   * 		If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification   * 		of new data availability is sent unconditionally. + * 		If **0** is specified in *flags*, an adaptive notification + * 		of new data availability is sent. + * + * 		See 'bpf_ringbuf_output()' for the definition of adaptive notification.   * 	Return   * 		Nothing. Always succeeds.   * @@ -3281,6 +4600,10 @@ union bpf_attr {   * 		of new data availability is sent.   * 		If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification   * 		of new data availability is sent unconditionally. + * 		If **0** is specified in *flags*, an adaptive notification + * 		of new data availability is sent. + * + * 		See 'bpf_ringbuf_output()' for the definition of adaptive notification.   * 	Return   * 		Nothing. Always succeeds.   * @@ -3337,38 +4660,40 @@ union bpf_attr {   *	Description   *		Dynamically cast a *sk* pointer to a *tcp6_sock* pointer.   *	Return - *		*sk* if casting is valid, or NULL otherwise. + *		*sk* if casting is valid, or **NULL** otherwise.   *   * struct tcp_sock *bpf_skc_to_tcp_sock(void *sk)   *	Description   *		Dynamically cast a *sk* pointer to a *tcp_sock* pointer.   *	Return - *		*sk* if casting is valid, or NULL otherwise. + *		*sk* if casting is valid, or **NULL** otherwise.   *   * struct tcp_timewait_sock *bpf_skc_to_tcp_timewait_sock(void *sk)   * 	Description   *		Dynamically cast a *sk* pointer to a *tcp_timewait_sock* pointer.   *	Return - *		*sk* if casting is valid, or NULL otherwise. + *		*sk* if casting is valid, or **NULL** otherwise.   *   * struct tcp_request_sock *bpf_skc_to_tcp_request_sock(void *sk)   * 	Description   *		Dynamically cast a *sk* pointer to a *tcp_request_sock* pointer.   *	Return - *		*sk* if casting is valid, or NULL otherwise. + *		*sk* if casting is valid, or **NULL** otherwise.   *   * struct udp6_sock *bpf_skc_to_udp6_sock(void *sk)   * 	Description   *		Dynamically cast a *sk* pointer to a *udp6_sock* pointer.   *	Return - *		*sk* if casting is valid, or NULL otherwise. + *		*sk* if casting is valid, or **NULL** otherwise.   *   * long bpf_get_task_stack(struct task_struct *task, void *buf, u32 size, u64 flags)   *	Description   *		Return a user or a kernel stack in bpf program provided buffer. + *		Note: the user stack will only be populated if the *task* is + *		the current task; all other tasks will return -EOPNOTSUPP.   *		To achieve this, the helper needs *task*, which is a valid - *		pointer to struct task_struct. To store the stacktrace, the - *		bpf program provides *buf* with	a nonnegative *size*. + *		pointer to **struct task_struct**. To store the stacktrace, the + *		bpf program provides *buf* with a nonnegative *size*.   *   *		The last argument, *flags*, holds the number of stack frames to   *		skip (from 0 to 255), masked with @@ -3377,6 +4702,7 @@ union bpf_attr {   *   *		**BPF_F_USER_STACK**   *			Collect a user space stack instead of a kernel stack. + *			The *task* must be the current task.   *		**BPF_F_USER_BUILD_ID**   *			Collect buildid+offset instead of ips for user stack,   *			only valid if **BPF_F_USER_STACK** is also specified. @@ -3392,161 +4718,1369 @@ union bpf_attr {   *   *			# sysctl kernel.perf_event_max_stack=<new value>   *	Return - *		A non-negative value equal to or less than *size* on success, - *		or a negative error in case of failure. + * 		The non-negative copied *buf* length equal to or less than + * 		*size* on success, or a negative error in case of failure. + * + * long bpf_load_hdr_opt(struct bpf_sock_ops *skops, void *searchby_res, u32 len, u64 flags) + *	Description + *		Load header option.  Support reading a particular TCP header + *		option for bpf program (**BPF_PROG_TYPE_SOCK_OPS**). + * + *		If *flags* is 0, it will search the option from the + *		*skops*\ **->skb_data**.  The comment in **struct bpf_sock_ops** + *		has details on what skb_data contains under different + *		*skops*\ **->op**. + * + *		The first byte of the *searchby_res* specifies the + *		kind that it wants to search. + * + *		If the searching kind is an experimental kind + *		(i.e. 253 or 254 according to RFC6994).  It also + *		needs to specify the "magic" which is either + *		2 bytes or 4 bytes.  It then also needs to + *		specify the size of the magic by using + *		the 2nd byte which is "kind-length" of a TCP + *		header option and the "kind-length" also + *		includes the first 2 bytes "kind" and "kind-length" + *		itself as a normal TCP header option also does. + * + *		For example, to search experimental kind 254 with + *		2 byte magic 0xeB9F, the searchby_res should be + *		[ 254, 4, 0xeB, 0x9F, 0, 0, .... 0 ]. + * + *		To search for the standard window scale option (3), + *		the *searchby_res* should be [ 3, 0, 0, .... 0 ]. + *		Note, kind-length must be 0 for regular option. + * + *		Searching for No-Op (0) and End-of-Option-List (1) are + *		not supported. + * + *		*len* must be at least 2 bytes which is the minimal size + *		of a header option. + * + *		Supported flags: + * + *		* **BPF_LOAD_HDR_OPT_TCP_SYN** to search from the + *		  saved_syn packet or the just-received syn packet. + * + *	Return + *		> 0 when found, the header option is copied to *searchby_res*. + *		The return value is the total length copied. On failure, a + *		negative error code is returned: + * + *		**-EINVAL** if a parameter is invalid. + * + *		**-ENOMSG** if the option is not found. + * + *		**-ENOENT** if no syn packet is available when + *		**BPF_LOAD_HDR_OPT_TCP_SYN** is used. + * + *		**-ENOSPC** if there is not enough space.  Only *len* number of + *		bytes are copied. + * + *		**-EFAULT** on failure to parse the header options in the + *		packet. + * + *		**-EPERM** if the helper cannot be used under the current + *		*skops*\ **->op**. + * + * long bpf_store_hdr_opt(struct bpf_sock_ops *skops, const void *from, u32 len, u64 flags) + *	Description + *		Store header option.  The data will be copied + *		from buffer *from* with length *len* to the TCP header. + * + *		The buffer *from* should have the whole option that + *		includes the kind, kind-length, and the actual + *		option data.  The *len* must be at least kind-length + *		long.  The kind-length does not have to be 4 byte + *		aligned.  The kernel will take care of the padding + *		and setting the 4 bytes aligned value to th->doff. + * + *		This helper will check for duplicated option + *		by searching the same option in the outgoing skb. + * + *		This helper can only be called during + *		**BPF_SOCK_OPS_WRITE_HDR_OPT_CB**. + * + *	Return + *		0 on success, or negative error in case of failure: + * + *		**-EINVAL** If param is invalid. + * + *		**-ENOSPC** if there is not enough space in the header. + *		Nothing has been written   * + *		**-EEXIST** if the option already exists. + * + *		**-EFAULT** on failure to parse the existing header options. + * + *		**-EPERM** if the helper cannot be used under the current + *		*skops*\ **->op**. + * + * long bpf_reserve_hdr_opt(struct bpf_sock_ops *skops, u32 len, u64 flags) + *	Description + *		Reserve *len* bytes for the bpf header option.  The + *		space will be used by **bpf_store_hdr_opt**\ () later in + *		**BPF_SOCK_OPS_WRITE_HDR_OPT_CB**. + * + *		If **bpf_reserve_hdr_opt**\ () is called multiple times, + *		the total number of bytes will be reserved. + * + *		This helper can only be called during + *		**BPF_SOCK_OPS_HDR_OPT_LEN_CB**. + * + *	Return + *		0 on success, or negative error in case of failure: + * + *		**-EINVAL** if a parameter is invalid. + * + *		**-ENOSPC** if there is not enough space in the header. + * + *		**-EPERM** if the helper cannot be used under the current + *		*skops*\ **->op**. + * + * void *bpf_inode_storage_get(struct bpf_map *map, void *inode, void *value, u64 flags) + *	Description + *		Get a bpf_local_storage from an *inode*. + * + *		Logically, it could be thought of as getting the value from + *		a *map* with *inode* as the **key**.  From this + *		perspective,  the usage is not much different from + *		**bpf_map_lookup_elem**\ (*map*, **&**\ *inode*) except this + *		helper enforces the key must be an inode and the map must also + *		be a **BPF_MAP_TYPE_INODE_STORAGE**. + * + *		Underneath, the value is stored locally at *inode* instead of + *		the *map*.  The *map* is used as the bpf-local-storage + *		"type". The bpf-local-storage "type" (i.e. the *map*) is + *		searched against all bpf_local_storage residing at *inode*. + * + *		An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be + *		used such that a new bpf_local_storage will be + *		created if one does not exist.  *value* can be used + *		together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify + *		the initial value of a bpf_local_storage.  If *value* is + *		**NULL**, the new bpf_local_storage will be zero initialized. + *	Return + *		A bpf_local_storage pointer is returned on success. + * + *		**NULL** if not found or there was an error in adding + *		a new bpf_local_storage. + * + * int bpf_inode_storage_delete(struct bpf_map *map, void *inode) + *	Description + *		Delete a bpf_local_storage from an *inode*. + *	Return + *		0 on success. + * + *		**-ENOENT** if the bpf_local_storage cannot be found. + * + * long bpf_d_path(struct path *path, char *buf, u32 sz) + *	Description + *		Return full path for given **struct path** object, which + *		needs to be the kernel BTF *path* object. The path is + *		returned in the provided buffer *buf* of size *sz* and + *		is zero terminated. + * + *	Return + *		On success, the strictly positive length of the string, + *		including the trailing NUL character. On error, a negative + *		value. + * + * long bpf_copy_from_user(void *dst, u32 size, const void *user_ptr) + * 	Description + * 		Read *size* bytes from user space address *user_ptr* and store + * 		the data in *dst*. This is a wrapper of **copy_from_user**\ (). + * 	Return + * 		0 on success, or a negative error in case of failure. + * + * long bpf_snprintf_btf(char *str, u32 str_size, struct btf_ptr *ptr, u32 btf_ptr_size, u64 flags) + *	Description + *		Use BTF to store a string representation of *ptr*->ptr in *str*, + *		using *ptr*->type_id.  This value should specify the type + *		that *ptr*->ptr points to. LLVM __builtin_btf_type_id(type, 1) + *		can be used to look up vmlinux BTF type ids. Traversing the + *		data structure using BTF, the type information and values are + *		stored in the first *str_size* - 1 bytes of *str*.  Safe copy of + *		the pointer data is carried out to avoid kernel crashes during + *		operation.  Smaller types can use string space on the stack; + *		larger programs can use map data to store the string + *		representation. + * + *		The string can be subsequently shared with userspace via + *		bpf_perf_event_output() or ring buffer interfaces. + *		bpf_trace_printk() is to be avoided as it places too small + *		a limit on string size to be useful. + * + *		*flags* is a combination of + * + *		**BTF_F_COMPACT** + *			no formatting around type information + *		**BTF_F_NONAME** + *			no struct/union member names/types + *		**BTF_F_PTR_RAW** + *			show raw (unobfuscated) pointer values; + *			equivalent to printk specifier %px. + *		**BTF_F_ZERO** + *			show zero-valued struct/union members; they + *			are not displayed by default + * + *	Return + *		The number of bytes that were written (or would have been + *		written if output had to be truncated due to string size), + *		or a negative error in cases of failure. + * + * long bpf_seq_printf_btf(struct seq_file *m, struct btf_ptr *ptr, u32 ptr_size, u64 flags) + *	Description + *		Use BTF to write to seq_write a string representation of + *		*ptr*->ptr, using *ptr*->type_id as per bpf_snprintf_btf(). + *		*flags* are identical to those used for bpf_snprintf_btf. + *	Return + *		0 on success or a negative error in case of failure. + * + * u64 bpf_skb_cgroup_classid(struct sk_buff *skb) + * 	Description + * 		See **bpf_get_cgroup_classid**\ () for the main description. + * 		This helper differs from **bpf_get_cgroup_classid**\ () in that + * 		the cgroup v1 net_cls class is retrieved only from the *skb*'s + * 		associated socket instead of the current process. + * 	Return + * 		The id is returned or 0 in case the id could not be retrieved. + * + * long bpf_redirect_neigh(u32 ifindex, struct bpf_redir_neigh *params, int plen, u64 flags) + * 	Description + * 		Redirect the packet to another net device of index *ifindex* + * 		and fill in L2 addresses from neighboring subsystem. This helper + * 		is somewhat similar to **bpf_redirect**\ (), except that it + * 		populates L2 addresses as well, meaning, internally, the helper + * 		relies on the neighbor lookup for the L2 address of the nexthop. + * + * 		The helper will perform a FIB lookup based on the skb's + * 		networking header to get the address of the next hop, unless + * 		this is supplied by the caller in the *params* argument. The + * 		*plen* argument indicates the len of *params* and should be set + * 		to 0 if *params* is NULL. + * + * 		The *flags* argument is reserved and must be 0. The helper is + * 		currently only supported for tc BPF program types, and enabled + * 		for IPv4 and IPv6 protocols. + * 	Return + * 		The helper returns **TC_ACT_REDIRECT** on success or + * 		**TC_ACT_SHOT** on error. + * + * void *bpf_per_cpu_ptr(const void *percpu_ptr, u32 cpu) + *     Description + *             Take a pointer to a percpu ksym, *percpu_ptr*, and return a + *             pointer to the percpu kernel variable on *cpu*. A ksym is an + *             extern variable decorated with '__ksym'. For ksym, there is a + *             global var (either static or global) defined of the same name + *             in the kernel. The ksym is percpu if the global var is percpu. + *             The returned pointer points to the global percpu var on *cpu*. + * + *             bpf_per_cpu_ptr() has the same semantic as per_cpu_ptr() in the + *             kernel, except that bpf_per_cpu_ptr() may return NULL. This + *             happens if *cpu* is larger than nr_cpu_ids. The caller of + *             bpf_per_cpu_ptr() must check the returned value. + *     Return + *             A pointer pointing to the kernel percpu variable on *cpu*, or + *             NULL, if *cpu* is invalid. + * + * void *bpf_this_cpu_ptr(const void *percpu_ptr) + *	Description + *		Take a pointer to a percpu ksym, *percpu_ptr*, and return a + *		pointer to the percpu kernel variable on this cpu. See the + *		description of 'ksym' in **bpf_per_cpu_ptr**\ (). + * + *		bpf_this_cpu_ptr() has the same semantic as this_cpu_ptr() in + *		the kernel. Different from **bpf_per_cpu_ptr**\ (), it would + *		never return NULL. + *	Return + *		A pointer pointing to the kernel percpu variable on this cpu. + * + * long bpf_redirect_peer(u32 ifindex, u64 flags) + * 	Description + * 		Redirect the packet to another net device of index *ifindex*. + * 		This helper is somewhat similar to **bpf_redirect**\ (), except + * 		that the redirection happens to the *ifindex*' peer device and + * 		the netns switch takes place from ingress to ingress without + * 		going through the CPU's backlog queue. + * + * 		*skb*\ **->mark** and *skb*\ **->tstamp** are not cleared during + * 		the netns switch. + * + * 		The *flags* argument is reserved and must be 0. The helper is + * 		currently only supported for tc BPF program types at the + * 		ingress hook and for veth and netkit target device types. The + * 		peer device must reside in a different network namespace. + * 	Return + * 		The helper returns **TC_ACT_REDIRECT** on success or + * 		**TC_ACT_SHOT** on error. + * + * void *bpf_task_storage_get(struct bpf_map *map, struct task_struct *task, void *value, u64 flags) + *	Description + *		Get a bpf_local_storage from the *task*. + * + *		Logically, it could be thought of as getting the value from + *		a *map* with *task* as the **key**.  From this + *		perspective,  the usage is not much different from + *		**bpf_map_lookup_elem**\ (*map*, **&**\ *task*) except this + *		helper enforces the key must be a task_struct and the map must also + *		be a **BPF_MAP_TYPE_TASK_STORAGE**. + * + *		Underneath, the value is stored locally at *task* instead of + *		the *map*.  The *map* is used as the bpf-local-storage + *		"type". The bpf-local-storage "type" (i.e. the *map*) is + *		searched against all bpf_local_storage residing at *task*. + * + *		An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be + *		used such that a new bpf_local_storage will be + *		created if one does not exist.  *value* can be used + *		together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify + *		the initial value of a bpf_local_storage.  If *value* is + *		**NULL**, the new bpf_local_storage will be zero initialized. + *	Return + *		A bpf_local_storage pointer is returned on success. + * + *		**NULL** if not found or there was an error in adding + *		a new bpf_local_storage. + * + * long bpf_task_storage_delete(struct bpf_map *map, struct task_struct *task) + *	Description + *		Delete a bpf_local_storage from a *task*. + *	Return + *		0 on success. + * + *		**-ENOENT** if the bpf_local_storage cannot be found. + * + * struct task_struct *bpf_get_current_task_btf(void) + *	Description + *		Return a BTF pointer to the "current" task. + *		This pointer can also be used in helpers that accept an + *		*ARG_PTR_TO_BTF_ID* of type *task_struct*. + *	Return + *		Pointer to the current task. + * + * long bpf_bprm_opts_set(struct linux_binprm *bprm, u64 flags) + *	Description + *		Set or clear certain options on *bprm*: + * + *		**BPF_F_BPRM_SECUREEXEC** Set the secureexec bit + *		which sets the **AT_SECURE** auxv for glibc. The bit + *		is cleared if the flag is not specified. + *	Return + *		**-EINVAL** if invalid *flags* are passed, zero otherwise. + * + * u64 bpf_ktime_get_coarse_ns(void) + * 	Description + * 		Return a coarse-grained version of the time elapsed since + * 		system boot, in nanoseconds. Does not include time the system + * 		was suspended. + * + * 		See: **clock_gettime**\ (**CLOCK_MONOTONIC_COARSE**) + * 	Return + * 		Current *ktime*. + * + * long bpf_ima_inode_hash(struct inode *inode, void *dst, u32 size) + *	Description + *		Returns the stored IMA hash of the *inode* (if it's available). + *		If the hash is larger than *size*, then only *size* + *		bytes will be copied to *dst* + *	Return + *		The **hash_algo** is returned on success, + *		**-EOPNOTSUPP** if IMA is disabled or **-EINVAL** if + *		invalid arguments are passed. + * + * struct socket *bpf_sock_from_file(struct file *file) + *	Description + *		If the given file represents a socket, returns the associated + *		socket. + *	Return + *		A pointer to a struct socket on success or NULL if the file is + *		not a socket. + * + * long bpf_check_mtu(void *ctx, u32 ifindex, u32 *mtu_len, s32 len_diff, u64 flags) + *	Description + *		Check packet size against exceeding MTU of net device (based + *		on *ifindex*).  This helper will likely be used in combination + *		with helpers that adjust/change the packet size. + * + *		The argument *len_diff* can be used for querying with a planned + *		size change. This allows to check MTU prior to changing packet + *		ctx. Providing a *len_diff* adjustment that is larger than the + *		actual packet size (resulting in negative packet size) will in + *		principle not exceed the MTU, which is why it is not considered + *		a failure.  Other BPF helpers are needed for performing the + *		planned size change; therefore the responsibility for catching + *		a negative packet size belongs in those helpers. + * + *		Specifying *ifindex* zero means the MTU check is performed + *		against the current net device.  This is practical if this isn't + *		used prior to redirect. + * + *		On input *mtu_len* must be a valid pointer, else verifier will + *		reject BPF program.  If the value *mtu_len* is initialized to + *		zero then the ctx packet size is use.  When value *mtu_len* is + *		provided as input this specify the L3 length that the MTU check + *		is done against. Remember XDP and TC length operate at L2, but + *		this value is L3 as this correlate to MTU and IP-header tot_len + *		values which are L3 (similar behavior as bpf_fib_lookup). + * + *		The Linux kernel route table can configure MTUs on a more + *		specific per route level, which is not provided by this helper. + *		For route level MTU checks use the **bpf_fib_lookup**\ () + *		helper. + * + *		*ctx* is either **struct xdp_md** for XDP programs or + *		**struct sk_buff** for tc cls_act programs. + * + *		The *flags* argument can be a combination of one or more of the + *		following values: + * + *		**BPF_MTU_CHK_SEGS** + *			This flag will only works for *ctx* **struct sk_buff**. + *			If packet context contains extra packet segment buffers + *			(often knows as GSO skb), then MTU check is harder to + *			check at this point, because in transmit path it is + *			possible for the skb packet to get re-segmented + *			(depending on net device features).  This could still be + *			a MTU violation, so this flag enables performing MTU + *			check against segments, with a different violation + *			return code to tell it apart. Check cannot use len_diff. + * + *		On return *mtu_len* pointer contains the MTU value of the net + *		device.  Remember the net device configured MTU is the L3 size, + *		which is returned here and XDP and TC length operate at L2. + *		Helper take this into account for you, but remember when using + *		MTU value in your BPF-code. + * + *	Return + *		* 0 on success, and populate MTU value in *mtu_len* pointer. + * + *		* < 0 if any input argument is invalid (*mtu_len* not updated) + * + *		MTU violations return positive values, but also populate MTU + *		value in *mtu_len* pointer, as this can be needed for + *		implementing PMTU handing: + * + *		* **BPF_MTU_CHK_RET_FRAG_NEEDED** + *		* **BPF_MTU_CHK_RET_SEGS_TOOBIG** + * + * long bpf_for_each_map_elem(struct bpf_map *map, void *callback_fn, void *callback_ctx, u64 flags) + *	Description + *		For each element in **map**, call **callback_fn** function with + *		**map**, **callback_ctx** and other map-specific parameters. + *		The **callback_fn** should be a static function and + *		the **callback_ctx** should be a pointer to the stack. + *		The **flags** is used to control certain aspects of the helper. + *		Currently, the **flags** must be 0. + * + *		The following are a list of supported map types and their + *		respective expected callback signatures: + * + *		BPF_MAP_TYPE_HASH, BPF_MAP_TYPE_PERCPU_HASH, + *		BPF_MAP_TYPE_LRU_HASH, BPF_MAP_TYPE_LRU_PERCPU_HASH, + *		BPF_MAP_TYPE_ARRAY, BPF_MAP_TYPE_PERCPU_ARRAY + * + *		long (\*callback_fn)(struct bpf_map \*map, const void \*key, void \*value, void \*ctx); + * + *		For per_cpu maps, the map_value is the value on the cpu where the + *		bpf_prog is running. + * + *		If **callback_fn** return 0, the helper will continue to the next + *		element. If return value is 1, the helper will skip the rest of + *		elements and return. Other return values are not used now. + * + *	Return + *		The number of traversed map elements for success, **-EINVAL** for + *		invalid **flags**. + * + * long bpf_snprintf(char *str, u32 str_size, const char *fmt, u64 *data, u32 data_len) + *	Description + *		Outputs a string into the **str** buffer of size **str_size** + *		based on a format string stored in a read-only map pointed by + *		**fmt**. + * + *		Each format specifier in **fmt** corresponds to one u64 element + *		in the **data** array. For strings and pointers where pointees + *		are accessed, only the pointer values are stored in the *data* + *		array. The *data_len* is the size of *data* in bytes - must be + *		a multiple of 8. + * + *		Formats **%s** and **%p{i,I}{4,6}** require to read kernel + *		memory. Reading kernel memory may fail due to either invalid + *		address or valid address but requiring a major memory fault. If + *		reading kernel memory fails, the string for **%s** will be an + *		empty string, and the ip address for **%p{i,I}{4,6}** will be 0. + *		Not returning error to bpf program is consistent with what + *		**bpf_trace_printk**\ () does for now. + * + *	Return + *		The strictly positive length of the formatted string, including + *		the trailing zero character. If the return value is greater than + *		**str_size**, **str** contains a truncated string, guaranteed to + *		be zero-terminated except when **str_size** is 0. + * + *		Or **-EBUSY** if the per-CPU memory copy buffer is busy. + * + * long bpf_sys_bpf(u32 cmd, void *attr, u32 attr_size) + * 	Description + * 		Execute bpf syscall with given arguments. + * 	Return + * 		A syscall result. + * + * long bpf_btf_find_by_name_kind(char *name, int name_sz, u32 kind, int flags) + * 	Description + * 		Find BTF type with given name and kind in vmlinux BTF or in module's BTFs. + * 	Return + * 		Returns btf_id and btf_obj_fd in lower and upper 32 bits. + * + * long bpf_sys_close(u32 fd) + * 	Description + * 		Execute close syscall for given FD. + * 	Return + * 		A syscall result. + * + * long bpf_timer_init(struct bpf_timer *timer, struct bpf_map *map, u64 flags) + *	Description + *		Initialize the timer. + *		First 4 bits of *flags* specify clockid. + *		Only CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_BOOTTIME are allowed. + *		All other bits of *flags* are reserved. + *		The verifier will reject the program if *timer* is not from + *		the same *map*. + *	Return + *		0 on success. + *		**-EBUSY** if *timer* is already initialized. + *		**-EINVAL** if invalid *flags* are passed. + *		**-EPERM** if *timer* is in a map that doesn't have any user references. + *		The user space should either hold a file descriptor to a map with timers + *		or pin such map in bpffs. When map is unpinned or file descriptor is + *		closed all timers in the map will be cancelled and freed. + * + * long bpf_timer_set_callback(struct bpf_timer *timer, void *callback_fn) + *	Description + *		Configure the timer to call *callback_fn* static function. + *	Return + *		0 on success. + *		**-EINVAL** if *timer* was not initialized with bpf_timer_init() earlier. + *		**-EPERM** if *timer* is in a map that doesn't have any user references. + *		The user space should either hold a file descriptor to a map with timers + *		or pin such map in bpffs. When map is unpinned or file descriptor is + *		closed all timers in the map will be cancelled and freed. + * + * long bpf_timer_start(struct bpf_timer *timer, u64 nsecs, u64 flags) + *	Description + *		Set timer expiration N nanoseconds from the current time. The + *		configured callback will be invoked in soft irq context on some cpu + *		and will not repeat unless another bpf_timer_start() is made. + *		In such case the next invocation can migrate to a different cpu. + *		Since struct bpf_timer is a field inside map element the map + *		owns the timer. The bpf_timer_set_callback() will increment refcnt + *		of BPF program to make sure that callback_fn code stays valid. + *		When user space reference to a map reaches zero all timers + *		in a map are cancelled and corresponding program's refcnts are + *		decremented. This is done to make sure that Ctrl-C of a user + *		process doesn't leave any timers running. If map is pinned in + *		bpffs the callback_fn can re-arm itself indefinitely. + *		bpf_map_update/delete_elem() helpers and user space sys_bpf commands + *		cancel and free the timer in the given map element. + *		The map can contain timers that invoke callback_fn-s from different + *		programs. The same callback_fn can serve different timers from + *		different maps if key/value layout matches across maps. + *		Every bpf_timer_set_callback() can have different callback_fn. + * + *		*flags* can be one of: + * + *		**BPF_F_TIMER_ABS** + *			Start the timer in absolute expire value instead of the + *			default relative one. + *		**BPF_F_TIMER_CPU_PIN** + *			Timer will be pinned to the CPU of the caller. + * + *	Return + *		0 on success. + *		**-EINVAL** if *timer* was not initialized with bpf_timer_init() earlier + *		or invalid *flags* are passed. + * + * long bpf_timer_cancel(struct bpf_timer *timer) + *	Description + *		Cancel the timer and wait for callback_fn to finish if it was running. + *	Return + *		0 if the timer was not active. + *		1 if the timer was active. + *		**-EINVAL** if *timer* was not initialized with bpf_timer_init() earlier. + *		**-EDEADLK** if callback_fn tried to call bpf_timer_cancel() on its + *		own timer which would have led to a deadlock otherwise. + * + * u64 bpf_get_func_ip(void *ctx) + * 	Description + * 		Get address of the traced function (for tracing and kprobe programs). + * + * 		When called for kprobe program attached as uprobe it returns + * 		probe address for both entry and return uprobe. + * + * 	Return + * 		Address of the traced function for kprobe. + * 		0 for kprobes placed within the function (not at the entry). + * 		Address of the probe for uprobe and return uprobe. + * + * u64 bpf_get_attach_cookie(void *ctx) + * 	Description + * 		Get bpf_cookie value provided (optionally) during the program + * 		attachment. It might be different for each individual + * 		attachment, even if BPF program itself is the same. + * 		Expects BPF program context *ctx* as a first argument. + * + * 		Supported for the following program types: + *			- kprobe/uprobe; + *			- tracepoint; + *			- perf_event. + * 	Return + *		Value specified by user at BPF link creation/attachment time + *		or 0, if it was not specified. + * + * long bpf_task_pt_regs(struct task_struct *task) + *	Description + *		Get the struct pt_regs associated with **task**. + *	Return + *		A pointer to struct pt_regs. + * + * long bpf_get_branch_snapshot(void *entries, u32 size, u64 flags) + *	Description + *		Get branch trace from hardware engines like Intel LBR. The + *		hardware engine is stopped shortly after the helper is + *		called. Therefore, the user need to filter branch entries + *		based on the actual use case. To capture branch trace + *		before the trigger point of the BPF program, the helper + *		should be called at the beginning of the BPF program. + * + *		The data is stored as struct perf_branch_entry into output + *		buffer *entries*. *size* is the size of *entries* in bytes. + *		*flags* is reserved for now and must be zero. + * + *	Return + *		On success, number of bytes written to *buf*. On error, a + *		negative value. + * + *		**-EINVAL** if *flags* is not zero. + * + *		**-ENOENT** if architecture does not support branch records. + * + * long bpf_trace_vprintk(const char *fmt, u32 fmt_size, const void *data, u32 data_len) + *	Description + *		Behaves like **bpf_trace_printk**\ () helper, but takes an array of u64 + *		to format and can handle more format args as a result. + * + *		Arguments are to be used as in **bpf_seq_printf**\ () helper. + *	Return + *		The number of bytes written to the buffer, or a negative error + *		in case of failure. + * + * struct unix_sock *bpf_skc_to_unix_sock(void *sk) + * 	Description + *		Dynamically cast a *sk* pointer to a *unix_sock* pointer. + *	Return + *		*sk* if casting is valid, or **NULL** otherwise. + * + * long bpf_kallsyms_lookup_name(const char *name, int name_sz, int flags, u64 *res) + *	Description + *		Get the address of a kernel symbol, returned in *res*. *res* is + *		set to 0 if the symbol is not found. + *	Return + *		On success, zero. On error, a negative value. + * + *		**-EINVAL** if *flags* is not zero. + * + *		**-EINVAL** if string *name* is not the same size as *name_sz*. + * + *		**-ENOENT** if symbol is not found. + * + *		**-EPERM** if caller does not have permission to obtain kernel address. + * + * long bpf_find_vma(struct task_struct *task, u64 addr, void *callback_fn, void *callback_ctx, u64 flags) + *	Description + *		Find vma of *task* that contains *addr*, call *callback_fn* + *		function with *task*, *vma*, and *callback_ctx*. + *		The *callback_fn* should be a static function and + *		the *callback_ctx* should be a pointer to the stack. + *		The *flags* is used to control certain aspects of the helper. + *		Currently, the *flags* must be 0. + * + *		The expected callback signature is + * + *		long (\*callback_fn)(struct task_struct \*task, struct vm_area_struct \*vma, void \*callback_ctx); + * + *	Return + *		0 on success. + *		**-ENOENT** if *task->mm* is NULL, or no vma contains *addr*. + *		**-EBUSY** if failed to try lock mmap_lock. + *		**-EINVAL** for invalid **flags**. + * + * long bpf_loop(u32 nr_loops, void *callback_fn, void *callback_ctx, u64 flags) + *	Description + *		For **nr_loops**, call **callback_fn** function + *		with **callback_ctx** as the context parameter. + *		The **callback_fn** should be a static function and + *		the **callback_ctx** should be a pointer to the stack. + *		The **flags** is used to control certain aspects of the helper. + *		Currently, the **flags** must be 0. Currently, nr_loops is + *		limited to 1 << 23 (~8 million) loops. + * + *		long (\*callback_fn)(u64 index, void \*ctx); + * + *		where **index** is the current index in the loop. The index + *		is zero-indexed. + * + *		If **callback_fn** returns 0, the helper will continue to the next + *		loop. If return value is 1, the helper will skip the rest of + *		the loops and return. Other return values are not used now, + *		and will be rejected by the verifier. + * + *	Return + *		The number of loops performed, **-EINVAL** for invalid **flags**, + *		**-E2BIG** if **nr_loops** exceeds the maximum number of loops. + * + * long bpf_strncmp(const char *s1, u32 s1_sz, const char *s2) + *	Description + *		Do strncmp() between **s1** and **s2**. **s1** doesn't need + *		to be null-terminated and **s1_sz** is the maximum storage + *		size of **s1**. **s2** must be a read-only string. + *	Return + *		An integer less than, equal to, or greater than zero + *		if the first **s1_sz** bytes of **s1** is found to be + *		less than, to match, or be greater than **s2**. + * + * long bpf_get_func_arg(void *ctx, u32 n, u64 *value) + *	Description + *		Get **n**-th argument register (zero based) of the traced function (for tracing programs) + *		returned in **value**. + * + *	Return + *		0 on success. + *		**-EINVAL** if n >= argument register count of traced function. + * + * long bpf_get_func_ret(void *ctx, u64 *value) + *	Description + *		Get return value of the traced function (for tracing programs) + *		in **value**. + * + *	Return + *		0 on success. + *		**-EOPNOTSUPP** for tracing programs other than BPF_TRACE_FEXIT or BPF_MODIFY_RETURN. + * + * long bpf_get_func_arg_cnt(void *ctx) + *	Description + *		Get number of registers of the traced function (for tracing programs) where + *		function arguments are stored in these registers. + * + *	Return + *		The number of argument registers of the traced function. + * + * int bpf_get_retval(void) + *	Description + *		Get the BPF program's return value that will be returned to the upper layers. + * + *		This helper is currently supported by cgroup programs and only by the hooks + *		where BPF program's return value is returned to the userspace via errno. + *	Return + *		The BPF program's return value. + * + * int bpf_set_retval(int retval) + *	Description + *		Set the BPF program's return value that will be returned to the upper layers. + * + *		This helper is currently supported by cgroup programs and only by the hooks + *		where BPF program's return value is returned to the userspace via errno. + * + *		Note that there is the following corner case where the program exports an error + *		via bpf_set_retval but signals success via 'return 1': + * + *			bpf_set_retval(-EPERM); + *			return 1; + * + *		In this case, the BPF program's return value will use helper's -EPERM. This + *		still holds true for cgroup/bind{4,6} which supports extra 'return 3' success case. + * + *	Return + *		0 on success, or a negative error in case of failure. + * + * u64 bpf_xdp_get_buff_len(struct xdp_buff *xdp_md) + *	Description + *		Get the total size of a given xdp buff (linear and paged area) + *	Return + *		The total size of a given xdp buffer. + * + * long bpf_xdp_load_bytes(struct xdp_buff *xdp_md, u32 offset, void *buf, u32 len) + *	Description + *		This helper is provided as an easy way to load data from a + *		xdp buffer. It can be used to load *len* bytes from *offset* from + *		the frame associated to *xdp_md*, into the buffer pointed by + *		*buf*. + *	Return + *		0 on success, or a negative error in case of failure. + * + * long bpf_xdp_store_bytes(struct xdp_buff *xdp_md, u32 offset, void *buf, u32 len) + *	Description + *		Store *len* bytes from buffer *buf* into the frame + *		associated to *xdp_md*, at *offset*. + *	Return + *		0 on success, or a negative error in case of failure. + * + * long bpf_copy_from_user_task(void *dst, u32 size, const void *user_ptr, struct task_struct *tsk, u64 flags) + *	Description + *		Read *size* bytes from user space address *user_ptr* in *tsk*'s + *		address space, and stores the data in *dst*. *flags* is not + *		used yet and is provided for future extensibility. This helper + *		can only be used by sleepable programs. + *	Return + *		0 on success, or a negative error in case of failure. On error + *		*dst* buffer is zeroed out. + * + * long bpf_skb_set_tstamp(struct sk_buff *skb, u64 tstamp, u32 tstamp_type) + *	Description + *		Change the __sk_buff->tstamp_type to *tstamp_type* + *		and set *tstamp* to the __sk_buff->tstamp together. + * + *		If there is no need to change the __sk_buff->tstamp_type, + *		the tstamp value can be directly written to __sk_buff->tstamp + *		instead. + * + *		BPF_SKB_TSTAMP_DELIVERY_MONO is the only tstamp that + *		will be kept during bpf_redirect_*().  A non zero + *		*tstamp* must be used with the BPF_SKB_TSTAMP_DELIVERY_MONO + *		*tstamp_type*. + * + *		A BPF_SKB_TSTAMP_UNSPEC *tstamp_type* can only be used + *		with a zero *tstamp*. + * + *		Only IPv4 and IPv6 skb->protocol are supported. + * + *		This function is most useful when it needs to set a + *		mono delivery time to __sk_buff->tstamp and then + *		bpf_redirect_*() to the egress of an iface.  For example, + *		changing the (rcv) timestamp in __sk_buff->tstamp at + *		ingress to a mono delivery time and then bpf_redirect_*() + *		to sch_fq@phy-dev. + *	Return + *		0 on success. + *		**-EINVAL** for invalid input + *		**-EOPNOTSUPP** for unsupported protocol + * + * long bpf_ima_file_hash(struct file *file, void *dst, u32 size) + *	Description + *		Returns a calculated IMA hash of the *file*. + *		If the hash is larger than *size*, then only *size* + *		bytes will be copied to *dst* + *	Return + *		The **hash_algo** is returned on success, + *		**-EOPNOTSUPP** if the hash calculation failed or **-EINVAL** if + *		invalid arguments are passed. + * + * void *bpf_kptr_xchg(void *dst, void *ptr) + *	Description + *		Exchange kptr at pointer *dst* with *ptr*, and return the old value. + *		*dst* can be map value or local kptr. *ptr* can be NULL, otherwise + *		it must be a referenced pointer which will be released when this helper + *		is called. + *	Return + *		The old value of kptr (which can be NULL). The returned pointer + *		if not NULL, is a reference which must be released using its + *		corresponding release function, or moved into a BPF map before + *		program exit. + * + * void *bpf_map_lookup_percpu_elem(struct bpf_map *map, const void *key, u32 cpu) + * 	Description + * 		Perform a lookup in *percpu map* for an entry associated to + * 		*key* on *cpu*. + * 	Return + * 		Map value associated to *key* on *cpu*, or **NULL** if no entry + * 		was found or *cpu* is invalid. + * + * struct mptcp_sock *bpf_skc_to_mptcp_sock(void *sk) + *	Description + *		Dynamically cast a *sk* pointer to a *mptcp_sock* pointer. + *	Return + *		*sk* if casting is valid, or **NULL** otherwise. + * + * long bpf_dynptr_from_mem(void *data, u32 size, u64 flags, struct bpf_dynptr *ptr) + *	Description + *		Get a dynptr to local memory *data*. + * + *		*data* must be a ptr to a map value. + *		The maximum *size* supported is DYNPTR_MAX_SIZE. + *		*flags* is currently unused. + *	Return + *		0 on success, -E2BIG if the size exceeds DYNPTR_MAX_SIZE, + *		-EINVAL if flags is not 0. + * + * long bpf_ringbuf_reserve_dynptr(void *ringbuf, u32 size, u64 flags, struct bpf_dynptr *ptr) + *	Description + *		Reserve *size* bytes of payload in a ring buffer *ringbuf* + *		through the dynptr interface. *flags* must be 0. + * + *		Please note that a corresponding bpf_ringbuf_submit_dynptr or + *		bpf_ringbuf_discard_dynptr must be called on *ptr*, even if the + *		reservation fails. This is enforced by the verifier. + *	Return + *		0 on success, or a negative error in case of failure. + * + * void bpf_ringbuf_submit_dynptr(struct bpf_dynptr *ptr, u64 flags) + *	Description + *		Submit reserved ring buffer sample, pointed to by *data*, + *		through the dynptr interface. This is a no-op if the dynptr is + *		invalid/null. + * + *		For more information on *flags*, please see + *		'bpf_ringbuf_submit'. + *	Return + *		Nothing. Always succeeds. + * + * void bpf_ringbuf_discard_dynptr(struct bpf_dynptr *ptr, u64 flags) + *	Description + *		Discard reserved ring buffer sample through the dynptr + *		interface. This is a no-op if the dynptr is invalid/null. + * + *		For more information on *flags*, please see + *		'bpf_ringbuf_discard'. + *	Return + *		Nothing. Always succeeds. + * + * long bpf_dynptr_read(void *dst, u32 len, const struct bpf_dynptr *src, u32 offset, u64 flags) + *	Description + *		Read *len* bytes from *src* into *dst*, starting from *offset* + *		into *src*. + *		*flags* is currently unused. + *	Return + *		0 on success, -E2BIG if *offset* + *len* exceeds the length + *		of *src*'s data, -EINVAL if *src* is an invalid dynptr or if + *		*flags* is not 0. + * + * long bpf_dynptr_write(const struct bpf_dynptr *dst, u32 offset, void *src, u32 len, u64 flags) + *	Description + *		Write *len* bytes from *src* into *dst*, starting from *offset* + *		into *dst*. + * + *		*flags* must be 0 except for skb-type dynptrs. + * + *		For skb-type dynptrs: + *		    *  All data slices of the dynptr are automatically + *		       invalidated after **bpf_dynptr_write**\ (). This is + *		       because writing may pull the skb and change the + *		       underlying packet buffer. + * + *		    *  For *flags*, please see the flags accepted by + *		       **bpf_skb_store_bytes**\ (). + *	Return + *		0 on success, -E2BIG if *offset* + *len* exceeds the length + *		of *dst*'s data, -EINVAL if *dst* is an invalid dynptr or if *dst* + *		is a read-only dynptr or if *flags* is not correct. For skb-type dynptrs, + *		other errors correspond to errors returned by **bpf_skb_store_bytes**\ (). + * + * void *bpf_dynptr_data(const struct bpf_dynptr *ptr, u32 offset, u32 len) + *	Description + *		Get a pointer to the underlying dynptr data. + * + *		*len* must be a statically known value. The returned data slice + *		is invalidated whenever the dynptr is invalidated. + * + *		skb and xdp type dynptrs may not use bpf_dynptr_data. They should + *		instead use bpf_dynptr_slice and bpf_dynptr_slice_rdwr. + *	Return + *		Pointer to the underlying dynptr data, NULL if the dynptr is + *		read-only, if the dynptr is invalid, or if the offset and length + *		is out of bounds. + * + * s64 bpf_tcp_raw_gen_syncookie_ipv4(struct iphdr *iph, struct tcphdr *th, u32 th_len) + *	Description + *		Try to issue a SYN cookie for the packet with corresponding + *		IPv4/TCP headers, *iph* and *th*, without depending on a + *		listening socket. + * + *		*iph* points to the IPv4 header. + * + *		*th* points to the start of the TCP header, while *th_len* + *		contains the length of the TCP header (at least + *		**sizeof**\ (**struct tcphdr**)). + *	Return + *		On success, lower 32 bits hold the generated SYN cookie in + *		followed by 16 bits which hold the MSS value for that cookie, + *		and the top 16 bits are unused. + * + *		On failure, the returned value is one of the following: + * + *		**-EINVAL** if *th_len* is invalid. + * + * s64 bpf_tcp_raw_gen_syncookie_ipv6(struct ipv6hdr *iph, struct tcphdr *th, u32 th_len) + *	Description + *		Try to issue a SYN cookie for the packet with corresponding + *		IPv6/TCP headers, *iph* and *th*, without depending on a + *		listening socket. + * + *		*iph* points to the IPv6 header. + * + *		*th* points to the start of the TCP header, while *th_len* + *		contains the length of the TCP header (at least + *		**sizeof**\ (**struct tcphdr**)). + *	Return + *		On success, lower 32 bits hold the generated SYN cookie in + *		followed by 16 bits which hold the MSS value for that cookie, + *		and the top 16 bits are unused. + * + *		On failure, the returned value is one of the following: + * + *		**-EINVAL** if *th_len* is invalid. + * + *		**-EPROTONOSUPPORT** if CONFIG_IPV6 is not builtin. + * + * long bpf_tcp_raw_check_syncookie_ipv4(struct iphdr *iph, struct tcphdr *th) + *	Description + *		Check whether *iph* and *th* contain a valid SYN cookie ACK + *		without depending on a listening socket. + * + *		*iph* points to the IPv4 header. + * + *		*th* points to the TCP header. + *	Return + *		0 if *iph* and *th* are a valid SYN cookie ACK. + * + *		On failure, the returned value is one of the following: + * + *		**-EACCES** if the SYN cookie is not valid. + * + * long bpf_tcp_raw_check_syncookie_ipv6(struct ipv6hdr *iph, struct tcphdr *th) + *	Description + *		Check whether *iph* and *th* contain a valid SYN cookie ACK + *		without depending on a listening socket. + * + *		*iph* points to the IPv6 header. + * + *		*th* points to the TCP header. + *	Return + *		0 if *iph* and *th* are a valid SYN cookie ACK. + * + *		On failure, the returned value is one of the following: + * + *		**-EACCES** if the SYN cookie is not valid. + * + *		**-EPROTONOSUPPORT** if CONFIG_IPV6 is not builtin. + * + * u64 bpf_ktime_get_tai_ns(void) + *	Description + *		A nonsettable system-wide clock derived from wall-clock time but + *		ignoring leap seconds.  This clock does not experience + *		discontinuities and backwards jumps caused by NTP inserting leap + *		seconds as CLOCK_REALTIME does. + * + *		See: **clock_gettime**\ (**CLOCK_TAI**) + *	Return + *		Current *ktime*. + * + * long bpf_user_ringbuf_drain(struct bpf_map *map, void *callback_fn, void *ctx, u64 flags) + *	Description + *		Drain samples from the specified user ring buffer, and invoke + *		the provided callback for each such sample: + * + *		long (\*callback_fn)(const struct bpf_dynptr \*dynptr, void \*ctx); + * + *		If **callback_fn** returns 0, the helper will continue to try + *		and drain the next sample, up to a maximum of + *		BPF_MAX_USER_RINGBUF_SAMPLES samples. If the return value is 1, + *		the helper will skip the rest of the samples and return. Other + *		return values are not used now, and will be rejected by the + *		verifier. + *	Return + *		The number of drained samples if no error was encountered while + *		draining samples, or 0 if no samples were present in the ring + *		buffer. If a user-space producer was epoll-waiting on this map, + *		and at least one sample was drained, they will receive an event + *		notification notifying them of available space in the ring + *		buffer. If the BPF_RB_NO_WAKEUP flag is passed to this + *		function, no wakeup notification will be sent. If the + *		BPF_RB_FORCE_WAKEUP flag is passed, a wakeup notification will + *		be sent even if no sample was drained. + * + *		On failure, the returned value is one of the following: + * + *		**-EBUSY** if the ring buffer is contended, and another calling + *		context was concurrently draining the ring buffer. + * + *		**-EINVAL** if user-space is not properly tracking the ring + *		buffer due to the producer position not being aligned to 8 + *		bytes, a sample not being aligned to 8 bytes, or the producer + *		position not matching the advertised length of a sample. + * + *		**-E2BIG** if user-space has tried to publish a sample which is + *		larger than the size of the ring buffer, or which cannot fit + *		within a struct bpf_dynptr. + * + * void *bpf_cgrp_storage_get(struct bpf_map *map, struct cgroup *cgroup, void *value, u64 flags) + *	Description + *		Get a bpf_local_storage from the *cgroup*. + * + *		Logically, it could be thought of as getting the value from + *		a *map* with *cgroup* as the **key**.  From this + *		perspective,  the usage is not much different from + *		**bpf_map_lookup_elem**\ (*map*, **&**\ *cgroup*) except this + *		helper enforces the key must be a cgroup struct and the map must also + *		be a **BPF_MAP_TYPE_CGRP_STORAGE**. + * + *		In reality, the local-storage value is embedded directly inside of the + *		*cgroup* object itself, rather than being located in the + *		**BPF_MAP_TYPE_CGRP_STORAGE** map. When the local-storage value is + *		queried for some *map* on a *cgroup* object, the kernel will perform an + *		O(n) iteration over all of the live local-storage values for that + *		*cgroup* object until the local-storage value for the *map* is found. + * + *		An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be + *		used such that a new bpf_local_storage will be + *		created if one does not exist.  *value* can be used + *		together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify + *		the initial value of a bpf_local_storage.  If *value* is + *		**NULL**, the new bpf_local_storage will be zero initialized. + *	Return + *		A bpf_local_storage pointer is returned on success. + * + *		**NULL** if not found or there was an error in adding + *		a new bpf_local_storage. + * + * long bpf_cgrp_storage_delete(struct bpf_map *map, struct cgroup *cgroup) + *	Description + *		Delete a bpf_local_storage from a *cgroup*. + *	Return + *		0 on success. + * + *		**-ENOENT** if the bpf_local_storage cannot be found.   */ -#define __BPF_FUNC_MAPPER(FN)		\ -	FN(unspec),			\ -	FN(map_lookup_elem),		\ -	FN(map_update_elem),		\ -	FN(map_delete_elem),		\ -	FN(probe_read),			\ -	FN(ktime_get_ns),		\ -	FN(trace_printk),		\ -	FN(get_prandom_u32),		\ -	FN(get_smp_processor_id),	\ -	FN(skb_store_bytes),		\ -	FN(l3_csum_replace),		\ -	FN(l4_csum_replace),		\ -	FN(tail_call),			\ -	FN(clone_redirect),		\ -	FN(get_current_pid_tgid),	\ -	FN(get_current_uid_gid),	\ -	FN(get_current_comm),		\ -	FN(get_cgroup_classid),		\ -	FN(skb_vlan_push),		\ -	FN(skb_vlan_pop),		\ -	FN(skb_get_tunnel_key),		\ -	FN(skb_set_tunnel_key),		\ -	FN(perf_event_read),		\ -	FN(redirect),			\ -	FN(get_route_realm),		\ -	FN(perf_event_output),		\ -	FN(skb_load_bytes),		\ -	FN(get_stackid),		\ -	FN(csum_diff),			\ -	FN(skb_get_tunnel_opt),		\ -	FN(skb_set_tunnel_opt),		\ -	FN(skb_change_proto),		\ -	FN(skb_change_type),		\ -	FN(skb_under_cgroup),		\ -	FN(get_hash_recalc),		\ -	FN(get_current_task),		\ -	FN(probe_write_user),		\ -	FN(current_task_under_cgroup),	\ -	FN(skb_change_tail),		\ -	FN(skb_pull_data),		\ -	FN(csum_update),		\ -	FN(set_hash_invalid),		\ -	FN(get_numa_node_id),		\ -	FN(skb_change_head),		\ -	FN(xdp_adjust_head),		\ -	FN(probe_read_str),		\ -	FN(get_socket_cookie),		\ -	FN(get_socket_uid),		\ -	FN(set_hash),			\ -	FN(setsockopt),			\ -	FN(skb_adjust_room),		\ -	FN(redirect_map),		\ -	FN(sk_redirect_map),		\ -	FN(sock_map_update),		\ -	FN(xdp_adjust_meta),		\ -	FN(perf_event_read_value),	\ -	FN(perf_prog_read_value),	\ -	FN(getsockopt),			\ -	FN(override_return),		\ -	FN(sock_ops_cb_flags_set),	\ -	FN(msg_redirect_map),		\ -	FN(msg_apply_bytes),		\ -	FN(msg_cork_bytes),		\ -	FN(msg_pull_data),		\ -	FN(bind),			\ -	FN(xdp_adjust_tail),		\ -	FN(skb_get_xfrm_state),		\ -	FN(get_stack),			\ -	FN(skb_load_bytes_relative),	\ -	FN(fib_lookup),			\ -	FN(sock_hash_update),		\ -	FN(msg_redirect_hash),		\ -	FN(sk_redirect_hash),		\ -	FN(lwt_push_encap),		\ -	FN(lwt_seg6_store_bytes),	\ -	FN(lwt_seg6_adjust_srh),	\ -	FN(lwt_seg6_action),		\ -	FN(rc_repeat),			\ -	FN(rc_keydown),			\ -	FN(skb_cgroup_id),		\ -	FN(get_current_cgroup_id),	\ -	FN(get_local_storage),		\ -	FN(sk_select_reuseport),	\ -	FN(skb_ancestor_cgroup_id),	\ -	FN(sk_lookup_tcp),		\ -	FN(sk_lookup_udp),		\ -	FN(sk_release),			\ -	FN(map_push_elem),		\ -	FN(map_pop_elem),		\ -	FN(map_peek_elem),		\ -	FN(msg_push_data),		\ -	FN(msg_pop_data),		\ -	FN(rc_pointer_rel),		\ -	FN(spin_lock),			\ -	FN(spin_unlock),		\ -	FN(sk_fullsock),		\ -	FN(tcp_sock),			\ -	FN(skb_ecn_set_ce),		\ -	FN(get_listener_sock),		\ -	FN(skc_lookup_tcp),		\ -	FN(tcp_check_syncookie),	\ -	FN(sysctl_get_name),		\ -	FN(sysctl_get_current_value),	\ -	FN(sysctl_get_new_value),	\ -	FN(sysctl_set_new_value),	\ -	FN(strtol),			\ -	FN(strtoul),			\ -	FN(sk_storage_get),		\ -	FN(sk_storage_delete),		\ -	FN(send_signal),		\ -	FN(tcp_gen_syncookie),		\ -	FN(skb_output),			\ -	FN(probe_read_user),		\ -	FN(probe_read_kernel),		\ -	FN(probe_read_user_str),	\ -	FN(probe_read_kernel_str),	\ -	FN(tcp_send_ack),		\ -	FN(send_signal_thread),		\ -	FN(jiffies64),			\ -	FN(read_branch_records),	\ -	FN(get_ns_current_pid_tgid),	\ -	FN(xdp_output),			\ -	FN(get_netns_cookie),		\ -	FN(get_current_ancestor_cgroup_id),	\ -	FN(sk_assign),			\ -	FN(ktime_get_boot_ns),		\ -	FN(seq_printf),			\ -	FN(seq_write),			\ -	FN(sk_cgroup_id),		\ -	FN(sk_ancestor_cgroup_id),	\ -	FN(ringbuf_output),		\ -	FN(ringbuf_reserve),		\ -	FN(ringbuf_submit),		\ -	FN(ringbuf_discard),		\ -	FN(ringbuf_query),		\ -	FN(csum_level),			\ -	FN(skc_to_tcp6_sock),		\ -	FN(skc_to_tcp_sock),		\ -	FN(skc_to_tcp_timewait_sock),	\ -	FN(skc_to_tcp_request_sock),	\ -	FN(skc_to_udp6_sock),		\ -	FN(get_task_stack),		\ -	/* */ +#define ___BPF_FUNC_MAPPER(FN, ctx...)			\ +	FN(unspec, 0, ##ctx)				\ +	FN(map_lookup_elem, 1, ##ctx)			\ +	FN(map_update_elem, 2, ##ctx)			\ +	FN(map_delete_elem, 3, ##ctx)			\ +	FN(probe_read, 4, ##ctx)			\ +	FN(ktime_get_ns, 5, ##ctx)			\ +	FN(trace_printk, 6, ##ctx)			\ +	FN(get_prandom_u32, 7, ##ctx)			\ +	FN(get_smp_processor_id, 8, ##ctx)		\ +	FN(skb_store_bytes, 9, ##ctx)			\ +	FN(l3_csum_replace, 10, ##ctx)			\ +	FN(l4_csum_replace, 11, ##ctx)			\ +	FN(tail_call, 12, ##ctx)			\ +	FN(clone_redirect, 13, ##ctx)			\ +	FN(get_current_pid_tgid, 14, ##ctx)		\ +	FN(get_current_uid_gid, 15, ##ctx)		\ +	FN(get_current_comm, 16, ##ctx)			\ +	FN(get_cgroup_classid, 17, ##ctx)		\ +	FN(skb_vlan_push, 18, ##ctx)			\ +	FN(skb_vlan_pop, 19, ##ctx)			\ +	FN(skb_get_tunnel_key, 20, ##ctx)		\ +	FN(skb_set_tunnel_key, 21, ##ctx)		\ +	FN(perf_event_read, 22, ##ctx)			\ +	FN(redirect, 23, ##ctx)				\ +	FN(get_route_realm, 24, ##ctx)			\ +	FN(perf_event_output, 25, ##ctx)		\ +	FN(skb_load_bytes, 26, ##ctx)			\ +	FN(get_stackid, 27, ##ctx)			\ +	FN(csum_diff, 28, ##ctx)			\ +	FN(skb_get_tunnel_opt, 29, ##ctx)		\ +	FN(skb_set_tunnel_opt, 30, ##ctx)		\ +	FN(skb_change_proto, 31, ##ctx)			\ +	FN(skb_change_type, 32, ##ctx)			\ +	FN(skb_under_cgroup, 33, ##ctx)			\ +	FN(get_hash_recalc, 34, ##ctx)			\ +	FN(get_current_task, 35, ##ctx)			\ +	FN(probe_write_user, 36, ##ctx)			\ +	FN(current_task_under_cgroup, 37, ##ctx)	\ +	FN(skb_change_tail, 38, ##ctx)			\ +	FN(skb_pull_data, 39, ##ctx)			\ +	FN(csum_update, 40, ##ctx)			\ +	FN(set_hash_invalid, 41, ##ctx)			\ +	FN(get_numa_node_id, 42, ##ctx)			\ +	FN(skb_change_head, 43, ##ctx)			\ +	FN(xdp_adjust_head, 44, ##ctx)			\ +	FN(probe_read_str, 45, ##ctx)			\ +	FN(get_socket_cookie, 46, ##ctx)		\ +	FN(get_socket_uid, 47, ##ctx)			\ +	FN(set_hash, 48, ##ctx)				\ +	FN(setsockopt, 49, ##ctx)			\ +	FN(skb_adjust_room, 50, ##ctx)			\ +	FN(redirect_map, 51, ##ctx)			\ +	FN(sk_redirect_map, 52, ##ctx)			\ +	FN(sock_map_update, 53, ##ctx)			\ +	FN(xdp_adjust_meta, 54, ##ctx)			\ +	FN(perf_event_read_value, 55, ##ctx)		\ +	FN(perf_prog_read_value, 56, ##ctx)		\ +	FN(getsockopt, 57, ##ctx)			\ +	FN(override_return, 58, ##ctx)			\ +	FN(sock_ops_cb_flags_set, 59, ##ctx)		\ +	FN(msg_redirect_map, 60, ##ctx)			\ +	FN(msg_apply_bytes, 61, ##ctx)			\ +	FN(msg_cork_bytes, 62, ##ctx)			\ +	FN(msg_pull_data, 63, ##ctx)			\ +	FN(bind, 64, ##ctx)				\ +	FN(xdp_adjust_tail, 65, ##ctx)			\ +	FN(skb_get_xfrm_state, 66, ##ctx)		\ +	FN(get_stack, 67, ##ctx)			\ +	FN(skb_load_bytes_relative, 68, ##ctx)		\ +	FN(fib_lookup, 69, ##ctx)			\ +	FN(sock_hash_update, 70, ##ctx)			\ +	FN(msg_redirect_hash, 71, ##ctx)		\ +	FN(sk_redirect_hash, 72, ##ctx)			\ +	FN(lwt_push_encap, 73, ##ctx)			\ +	FN(lwt_seg6_store_bytes, 74, ##ctx)		\ +	FN(lwt_seg6_adjust_srh, 75, ##ctx)		\ +	FN(lwt_seg6_action, 76, ##ctx)			\ +	FN(rc_repeat, 77, ##ctx)			\ +	FN(rc_keydown, 78, ##ctx)			\ +	FN(skb_cgroup_id, 79, ##ctx)			\ +	FN(get_current_cgroup_id, 80, ##ctx)		\ +	FN(get_local_storage, 81, ##ctx)		\ +	FN(sk_select_reuseport, 82, ##ctx)		\ +	FN(skb_ancestor_cgroup_id, 83, ##ctx)		\ +	FN(sk_lookup_tcp, 84, ##ctx)			\ +	FN(sk_lookup_udp, 85, ##ctx)			\ +	FN(sk_release, 86, ##ctx)			\ +	FN(map_push_elem, 87, ##ctx)			\ +	FN(map_pop_elem, 88, ##ctx)			\ +	FN(map_peek_elem, 89, ##ctx)			\ +	FN(msg_push_data, 90, ##ctx)			\ +	FN(msg_pop_data, 91, ##ctx)			\ +	FN(rc_pointer_rel, 92, ##ctx)			\ +	FN(spin_lock, 93, ##ctx)			\ +	FN(spin_unlock, 94, ##ctx)			\ +	FN(sk_fullsock, 95, ##ctx)			\ +	FN(tcp_sock, 96, ##ctx)				\ +	FN(skb_ecn_set_ce, 97, ##ctx)			\ +	FN(get_listener_sock, 98, ##ctx)		\ +	FN(skc_lookup_tcp, 99, ##ctx)			\ +	FN(tcp_check_syncookie, 100, ##ctx)		\ +	FN(sysctl_get_name, 101, ##ctx)			\ +	FN(sysctl_get_current_value, 102, ##ctx)	\ +	FN(sysctl_get_new_value, 103, ##ctx)		\ +	FN(sysctl_set_new_value, 104, ##ctx)		\ +	FN(strtol, 105, ##ctx)				\ +	FN(strtoul, 106, ##ctx)				\ +	FN(sk_storage_get, 107, ##ctx)			\ +	FN(sk_storage_delete, 108, ##ctx)		\ +	FN(send_signal, 109, ##ctx)			\ +	FN(tcp_gen_syncookie, 110, ##ctx)		\ +	FN(skb_output, 111, ##ctx)			\ +	FN(probe_read_user, 112, ##ctx)			\ +	FN(probe_read_kernel, 113, ##ctx)		\ +	FN(probe_read_user_str, 114, ##ctx)		\ +	FN(probe_read_kernel_str, 115, ##ctx)		\ +	FN(tcp_send_ack, 116, ##ctx)			\ +	FN(send_signal_thread, 117, ##ctx)		\ +	FN(jiffies64, 118, ##ctx)			\ +	FN(read_branch_records, 119, ##ctx)		\ +	FN(get_ns_current_pid_tgid, 120, ##ctx)		\ +	FN(xdp_output, 121, ##ctx)			\ +	FN(get_netns_cookie, 122, ##ctx)		\ +	FN(get_current_ancestor_cgroup_id, 123, ##ctx)	\ +	FN(sk_assign, 124, ##ctx)			\ +	FN(ktime_get_boot_ns, 125, ##ctx)		\ +	FN(seq_printf, 126, ##ctx)			\ +	FN(seq_write, 127, ##ctx)			\ +	FN(sk_cgroup_id, 128, ##ctx)			\ +	FN(sk_ancestor_cgroup_id, 129, ##ctx)		\ +	FN(ringbuf_output, 130, ##ctx)			\ +	FN(ringbuf_reserve, 131, ##ctx)			\ +	FN(ringbuf_submit, 132, ##ctx)			\ +	FN(ringbuf_discard, 133, ##ctx)			\ +	FN(ringbuf_query, 134, ##ctx)			\ +	FN(csum_level, 135, ##ctx)			\ +	FN(skc_to_tcp6_sock, 136, ##ctx)		\ +	FN(skc_to_tcp_sock, 137, ##ctx)			\ +	FN(skc_to_tcp_timewait_sock, 138, ##ctx)	\ +	FN(skc_to_tcp_request_sock, 139, ##ctx)		\ +	FN(skc_to_udp6_sock, 140, ##ctx)		\ +	FN(get_task_stack, 141, ##ctx)			\ +	FN(load_hdr_opt, 142, ##ctx)			\ +	FN(store_hdr_opt, 143, ##ctx)			\ +	FN(reserve_hdr_opt, 144, ##ctx)			\ +	FN(inode_storage_get, 145, ##ctx)		\ +	FN(inode_storage_delete, 146, ##ctx)		\ +	FN(d_path, 147, ##ctx)				\ +	FN(copy_from_user, 148, ##ctx)			\ +	FN(snprintf_btf, 149, ##ctx)			\ +	FN(seq_printf_btf, 150, ##ctx)			\ +	FN(skb_cgroup_classid, 151, ##ctx)		\ +	FN(redirect_neigh, 152, ##ctx)			\ +	FN(per_cpu_ptr, 153, ##ctx)			\ +	FN(this_cpu_ptr, 154, ##ctx)			\ +	FN(redirect_peer, 155, ##ctx)			\ +	FN(task_storage_get, 156, ##ctx)		\ +	FN(task_storage_delete, 157, ##ctx)		\ +	FN(get_current_task_btf, 158, ##ctx)		\ +	FN(bprm_opts_set, 159, ##ctx)			\ +	FN(ktime_get_coarse_ns, 160, ##ctx)		\ +	FN(ima_inode_hash, 161, ##ctx)			\ +	FN(sock_from_file, 162, ##ctx)			\ +	FN(check_mtu, 163, ##ctx)			\ +	FN(for_each_map_elem, 164, ##ctx)		\ +	FN(snprintf, 165, ##ctx)			\ +	FN(sys_bpf, 166, ##ctx)				\ +	FN(btf_find_by_name_kind, 167, ##ctx)		\ +	FN(sys_close, 168, ##ctx)			\ +	FN(timer_init, 169, ##ctx)			\ +	FN(timer_set_callback, 170, ##ctx)		\ +	FN(timer_start, 171, ##ctx)			\ +	FN(timer_cancel, 172, ##ctx)			\ +	FN(get_func_ip, 173, ##ctx)			\ +	FN(get_attach_cookie, 174, ##ctx)		\ +	FN(task_pt_regs, 175, ##ctx)			\ +	FN(get_branch_snapshot, 176, ##ctx)		\ +	FN(trace_vprintk, 177, ##ctx)			\ +	FN(skc_to_unix_sock, 178, ##ctx)		\ +	FN(kallsyms_lookup_name, 179, ##ctx)		\ +	FN(find_vma, 180, ##ctx)			\ +	FN(loop, 181, ##ctx)				\ +	FN(strncmp, 182, ##ctx)				\ +	FN(get_func_arg, 183, ##ctx)			\ +	FN(get_func_ret, 184, ##ctx)			\ +	FN(get_func_arg_cnt, 185, ##ctx)		\ +	FN(get_retval, 186, ##ctx)			\ +	FN(set_retval, 187, ##ctx)			\ +	FN(xdp_get_buff_len, 188, ##ctx)		\ +	FN(xdp_load_bytes, 189, ##ctx)			\ +	FN(xdp_store_bytes, 190, ##ctx)			\ +	FN(copy_from_user_task, 191, ##ctx)		\ +	FN(skb_set_tstamp, 192, ##ctx)			\ +	FN(ima_file_hash, 193, ##ctx)			\ +	FN(kptr_xchg, 194, ##ctx)			\ +	FN(map_lookup_percpu_elem, 195, ##ctx)		\ +	FN(skc_to_mptcp_sock, 196, ##ctx)		\ +	FN(dynptr_from_mem, 197, ##ctx)			\ +	FN(ringbuf_reserve_dynptr, 198, ##ctx)		\ +	FN(ringbuf_submit_dynptr, 199, ##ctx)		\ +	FN(ringbuf_discard_dynptr, 200, ##ctx)		\ +	FN(dynptr_read, 201, ##ctx)			\ +	FN(dynptr_write, 202, ##ctx)			\ +	FN(dynptr_data, 203, ##ctx)			\ +	FN(tcp_raw_gen_syncookie_ipv4, 204, ##ctx)	\ +	FN(tcp_raw_gen_syncookie_ipv6, 205, ##ctx)	\ +	FN(tcp_raw_check_syncookie_ipv4, 206, ##ctx)	\ +	FN(tcp_raw_check_syncookie_ipv6, 207, ##ctx)	\ +	FN(ktime_get_tai_ns, 208, ##ctx)		\ +	FN(user_ringbuf_drain, 209, ##ctx)		\ +	FN(cgrp_storage_get, 210, ##ctx)		\ +	FN(cgrp_storage_delete, 211, ##ctx)		\ +	/* This helper list is effectively frozen. If you are trying to	\ +	 * add a new helper, you should add a kfunc instead which has	\ +	 * less stability guarantees. See Documentation/bpf/kfuncs.rst	\ +	 */ + +/* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't + * know or care about integer value that is now passed as second argument + */ +#define __BPF_FUNC_MAPPER_APPLY(name, value, FN) FN(name), +#define __BPF_FUNC_MAPPER(FN) ___BPF_FUNC_MAPPER(__BPF_FUNC_MAPPER_APPLY, FN)  /* integer value in 'imm' field of BPF_CALL instruction selects which helper   * function eBPF program intends to call   */ -#define __BPF_ENUM_FN(x) BPF_FUNC_ ## x +#define __BPF_ENUM_FN(x, y) BPF_FUNC_ ## x = y,  enum bpf_func_id { -	__BPF_FUNC_MAPPER(__BPF_ENUM_FN) +	___BPF_FUNC_MAPPER(__BPF_ENUM_FN)  	__BPF_FUNC_MAX_ID,  };  #undef __BPF_ENUM_FN @@ -3571,11 +6105,7 @@ enum {  	BPF_F_PSEUDO_HDR		= (1ULL << 4),  	BPF_F_MARK_MANGLED_0		= (1ULL << 5),  	BPF_F_MARK_ENFORCE		= (1ULL << 6), -}; - -/* BPF_FUNC_clone_redirect and BPF_FUNC_redirect flags. */ -enum { -	BPF_F_INGRESS			= (1ULL << 0), +	BPF_F_IPV6			= (1ULL << 7),  };  /* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */ @@ -3599,6 +6129,12 @@ enum {  	BPF_F_ZERO_CSUM_TX		= (1ULL << 1),  	BPF_F_DONT_FRAGMENT		= (1ULL << 2),  	BPF_F_SEQ_NUMBER		= (1ULL << 3), +	BPF_F_NO_TUNNEL_KEY		= (1ULL << 4), +}; + +/* BPF_FUNC_skb_get_tunnel_key flags. */ +enum { +	BPF_F_TUNINFO_FLAGS		= (1ULL << 4),  };  /* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and @@ -3632,6 +6168,9 @@ enum {  	BPF_F_ADJ_ROOM_ENCAP_L4_GRE	= (1ULL << 3),  	BPF_F_ADJ_ROOM_ENCAP_L4_UDP	= (1ULL << 4),  	BPF_F_ADJ_ROOM_NO_CSUM_RESET	= (1ULL << 5), +	BPF_F_ADJ_ROOM_ENCAP_L2_ETH	= (1ULL << 6), +	BPF_F_ADJ_ROOM_DECAP_L3_IPV4	= (1ULL << 7), +	BPF_F_ADJ_ROOM_DECAP_L3_IPV6	= (1ULL << 8),  };  enum { @@ -3648,9 +6187,13 @@ enum {  	BPF_F_SYSCTL_BASE_NAME		= (1ULL << 0),  }; -/* BPF_FUNC_sk_storage_get flags */ +/* BPF_FUNC_<kernel_obj>_storage_get flags */  enum { -	BPF_SK_STORAGE_GET_F_CREATE	= (1ULL << 0), +	BPF_LOCAL_STORAGE_GET_F_CREATE	= (1ULL << 0), +	/* BPF_SK_STORAGE_GET_F_CREATE is only kept for backward compatibility +	 * and BPF_LOCAL_STORAGE_GET_F_CREATE must be used instead. +	 */ +	BPF_SK_STORAGE_GET_F_CREATE  = BPF_LOCAL_STORAGE_GET_F_CREATE,  };  /* BPF_FUNC_read_branch_records flags. */ @@ -3706,12 +6249,39 @@ enum bpf_lwt_encap_mode {  	BPF_LWT_ENCAP_IP,  }; +/* Flags for bpf_bprm_opts_set helper */ +enum { +	BPF_F_BPRM_SECUREEXEC	= (1ULL << 0), +}; + +/* Flags for bpf_redirect and bpf_redirect_map helpers */ +enum { +	BPF_F_INGRESS		= (1ULL << 0), /* used for skb path */ +	BPF_F_BROADCAST		= (1ULL << 3), /* used for XDP path */ +	BPF_F_EXCLUDE_INGRESS	= (1ULL << 4), /* used for XDP path */ +#define BPF_F_REDIRECT_FLAGS (BPF_F_INGRESS | BPF_F_BROADCAST | BPF_F_EXCLUDE_INGRESS) +}; +  #define __bpf_md_ptr(type, name)	\  union {					\  	type name;			\  	__u64 :64;			\  } __attribute__((aligned(8))) +/* The enum used in skb->tstamp_type. It specifies the clock type + * of the time stored in the skb->tstamp. + */ +enum { +	BPF_SKB_TSTAMP_UNSPEC = 0,		/* DEPRECATED */ +	BPF_SKB_TSTAMP_DELIVERY_MONO = 1,	/* DEPRECATED */ +	BPF_SKB_CLOCK_REALTIME = 0, +	BPF_SKB_CLOCK_MONOTONIC = 1, +	BPF_SKB_CLOCK_TAI = 2, +	/* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle, +	 * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid. +	 */ +}; +  /* user accessible mirror of in-kernel sk_buff.   * new fields can only be added to the end of this structure   */ @@ -3752,6 +6322,9 @@ struct __sk_buff {  	__u32 gso_segs;  	__bpf_md_ptr(struct bpf_sock *, sk);  	__u32 gso_size; +	__u8  tstamp_type; +	__u32 :24;		/* Padding, future use. */ +	__u64 hwtstamp;  };  struct bpf_tunnel_key { @@ -3762,8 +6335,15 @@ struct bpf_tunnel_key {  	};  	__u8 tunnel_tos;  	__u8 tunnel_ttl; -	__u16 tunnel_ext;	/* Padding, future use. */ +	union { +		__u16 tunnel_ext;	/* compat */ +		__be16 tunnel_flags; +	};  	__u32 tunnel_label; +	union { +		__u32 local_ipv4; +		__u32 local_ipv6[4]; +	};  };  /* user accessible mirror of in-kernel xfrm_state. @@ -3802,6 +6382,11 @@ enum bpf_ret_code {  	 *    represented by BPF_REDIRECT above).  	 */  	BPF_LWT_REROUTE = 128, +	/* BPF_FLOW_DISSECTOR_CONTINUE: used by BPF_PROG_TYPE_FLOW_DISSECTOR +	 *   to indicate that no custom dissection was performed, and +	 *   fallback to standard dissector is requested. +	 */ +	BPF_FLOW_DISSECTOR_CONTINUE = 129,  };  struct bpf_sock { @@ -3815,7 +6400,8 @@ struct bpf_sock {  	__u32 src_ip4;  	__u32 src_ip6[4];  	__u32 src_port;		/* host byte order */ -	__u32 dst_port;		/* network byte order */ +	__be16 dst_port;	/* network byte order */ +	__u16 :16;		/* zero padding */  	__u32 dst_ip4;  	__u32 dst_ip6[4];  	__u32 state; @@ -3884,6 +6470,19 @@ struct bpf_sock_tuple {  	};  }; +/* (Simplified) user return codes for tcx prog type. + * A valid tcx program must return one of these defined values. All other + * return codes are reserved for future use. Must remain compatible with + * their TC_ACT_* counter-parts. For compatibility in behavior, unknown + * return codes are mapped to TCX_NEXT. + */ +enum tcx_action_base { +	TCX_NEXT	= -1, +	TCX_PASS	= 0, +	TCX_DROP	= 2, +	TCX_REDIRECT	= 7, +}; +  struct bpf_xdp_sock {  	__u32 queue_id;  }; @@ -3990,6 +6589,20 @@ struct sk_reuseport_md {  	__u32 ip_protocol;	/* IP protocol. e.g. IPPROTO_TCP, IPPROTO_UDP */  	__u32 bind_inany;	/* Is sock bound to an INANY address? */  	__u32 hash;		/* A hash of the packet 4 tuples */ +	/* When reuse->migrating_sk is NULL, it is selecting a sk for the +	 * new incoming connection request (e.g. selecting a listen sk for +	 * the received SYN in the TCP case).  reuse->sk is one of the sk +	 * in the reuseport group. The bpf prog can use reuse->sk to learn +	 * the local listening ip/port without looking into the skb. +	 * +	 * When reuse->migrating_sk is not NULL, reuse->sk is closed and +	 * reuse->migrating_sk is the socket that needs to be migrated +	 * to another listening socket.  migrating_sk could be a fullsock +	 * sk that is fully established or a reqsk that is in-the-middle +	 * of 3-way handshake. +	 */ +	__bpf_md_ptr(struct bpf_sock *, sk); +	__bpf_md_ptr(struct bpf_sock *, migrating_sk);  };  #define BPF_TAG_SIZE	8 @@ -4030,6 +6643,10 @@ struct bpf_prog_info {  	__aligned_u64 prog_tags;  	__u64 run_time_ns;  	__u64 run_cnt; +	__u64 recursion_misses; +	__u32 verified_insns; +	__u32 attach_btf_obj_id; +	__u32 attach_btf_id;  } __attribute__((aligned(8)));  struct bpf_map_info { @@ -4047,12 +6664,17 @@ struct bpf_map_info {  	__u32 btf_id;  	__u32 btf_key_type_id;  	__u32 btf_value_type_id; +	__u32 btf_vmlinux_id; +	__u64 map_extra;  } __attribute__((aligned(8)));  struct bpf_btf_info {  	__aligned_u64 btf;  	__u32 btf_size;  	__u32 id; +	__aligned_u64 name; +	__u32 name_len; +	__u32 kernel_btf;  } __attribute__((aligned(8)));  struct bpf_link_info { @@ -4063,14 +6685,44 @@ struct bpf_link_info {  		struct {  			__aligned_u64 tp_name; /* in/out: tp_name buffer ptr */  			__u32 tp_name_len;     /* in/out: tp_name buffer len */ +			__u32 :32; +			__u64 cookie;  		} raw_tracepoint;  		struct {  			__u32 attach_type; +			__u32 target_obj_id; /* prog_id for PROG_EXT, otherwise btf object id */ +			__u32 target_btf_id; /* BTF type id inside the object */ +			__u32 :32; +			__u64 cookie;  		} tracing;  		struct {  			__u64 cgroup_id;  			__u32 attach_type;  		} cgroup; +		struct { +			__aligned_u64 target_name; /* in/out: target_name buffer ptr */ +			__u32 target_name_len;	   /* in/out: target_name buffer len */ + +			/* If the iter specific field is 32 bits, it can be put +			 * in the first or second union. Otherwise it should be +			 * put in the second union. +			 */ +			union { +				struct { +					__u32 map_id; +				} map; +			}; +			union { +				struct { +					__u64 cgroup_id; +					__u32 order; +				} cgroup; +				struct { +					__u32 tid; +					__u32 pid; +				} task; +			}; +		} iter;  		struct  {  			__u32 netns_ino;  			__u32 attach_type; @@ -4078,9 +6730,87 @@ struct bpf_link_info {  		struct {  			__u32 ifindex;  		} xdp; +		struct { +			__u32 map_id; +		} struct_ops; +		struct { +			__u32 pf; +			__u32 hooknum; +			__s32 priority; +			__u32 flags; +		} netfilter; +		struct { +			__aligned_u64 addrs; +			__u32 count; /* in/out: kprobe_multi function count */ +			__u32 flags; +			__u64 missed; +			__aligned_u64 cookies; +		} kprobe_multi; +		struct { +			__aligned_u64 path; +			__aligned_u64 offsets; +			__aligned_u64 ref_ctr_offsets; +			__aligned_u64 cookies; +			__u32 path_size; /* in/out: real path size on success, including zero byte */ +			__u32 count; /* in/out: uprobe_multi offsets/ref_ctr_offsets/cookies count */ +			__u32 flags; +			__u32 pid; +		} uprobe_multi; +		struct { +			__u32 type; /* enum bpf_perf_event_type */ +			__u32 :32; +			union { +				struct { +					__aligned_u64 file_name; /* in/out */ +					__u32 name_len; +					__u32 offset; /* offset from file_name */ +					__u64 cookie; +					__u64 ref_ctr_offset; +				} uprobe; /* BPF_PERF_EVENT_UPROBE, BPF_PERF_EVENT_URETPROBE */ +				struct { +					__aligned_u64 func_name; /* in/out */ +					__u32 name_len; +					__u32 offset; /* offset from func_name */ +					__u64 addr; +					__u64 missed; +					__u64 cookie; +				} kprobe; /* BPF_PERF_EVENT_KPROBE, BPF_PERF_EVENT_KRETPROBE */ +				struct { +					__aligned_u64 tp_name;   /* in/out */ +					__u32 name_len; +					__u32 :32; +					__u64 cookie; +				} tracepoint; /* BPF_PERF_EVENT_TRACEPOINT */ +				struct { +					__u64 config; +					__u32 type; +					__u32 :32; +					__u64 cookie; +				} event; /* BPF_PERF_EVENT_EVENT */ +			}; +		} perf_event; +		struct { +			__u32 ifindex; +			__u32 attach_type; +		} tcx; +		struct { +			__u32 ifindex; +			__u32 attach_type; +		} netkit; +		struct { +			__u32 map_id; +			__u32 attach_type; +		} sockmap;  	};  } __attribute__((aligned(8))); +struct bpf_token_info { +	__u64 allowed_cmds; +	__u64 allowed_maps; +	__u64 allowed_progs; +	__u64 allowed_attachs; +} __attribute__((aligned(8))); +  /* User bpf_sock_addr struct to access socket fields and sockaddr struct passed   * by user and intended to be used by socket (e.g. to bind to, depends on   * attach type). @@ -4158,6 +6888,37 @@ struct bpf_sock_ops {  	__u64 bytes_received;  	__u64 bytes_acked;  	__bpf_md_ptr(struct bpf_sock *, sk); +	/* [skb_data, skb_data_end) covers the whole TCP header. +	 * +	 * BPF_SOCK_OPS_PARSE_HDR_OPT_CB: The packet received +	 * BPF_SOCK_OPS_HDR_OPT_LEN_CB:   Not useful because the +	 *                                header has not been written. +	 * BPF_SOCK_OPS_WRITE_HDR_OPT_CB: The header and options have +	 *				  been written so far. +	 * BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:  The SYNACK that concludes +	 *					the 3WHS. +	 * BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: The ACK that concludes +	 *					the 3WHS. +	 * +	 * bpf_load_hdr_opt() can also be used to read a particular option. +	 */ +	__bpf_md_ptr(void *, skb_data); +	__bpf_md_ptr(void *, skb_data_end); +	__u32 skb_len;		/* The total length of a packet. +				 * It includes the header, options, +				 * and payload. +				 */ +	__u32 skb_tcp_flags;	/* tcp_flags of the header.  It provides +				 * an easy way to check for tcp_flags +				 * without parsing skb_data. +				 * +				 * In particular, the skb_tcp_flags +				 * will still be available in +				 * BPF_SOCK_OPS_HDR_OPT_LEN even though +				 * the outgoing header has not +				 * been written yet. +				 */ +	__u64 skb_hwtstamp;  };  /* Definitions for bpf_sock_ops_cb_flags */ @@ -4166,8 +6927,57 @@ enum {  	BPF_SOCK_OPS_RETRANS_CB_FLAG	= (1<<1),  	BPF_SOCK_OPS_STATE_CB_FLAG	= (1<<2),  	BPF_SOCK_OPS_RTT_CB_FLAG	= (1<<3), +	/* Call bpf for all received TCP headers.  The bpf prog will be +	 * called under sock_ops->op == BPF_SOCK_OPS_PARSE_HDR_OPT_CB +	 * +	 * Please refer to the comment in BPF_SOCK_OPS_PARSE_HDR_OPT_CB +	 * for the header option related helpers that will be useful +	 * to the bpf programs. +	 * +	 * It could be used at the client/active side (i.e. connect() side) +	 * when the server told it that the server was in syncookie +	 * mode and required the active side to resend the bpf-written +	 * options.  The active side can keep writing the bpf-options until +	 * it received a valid packet from the server side to confirm +	 * the earlier packet (and options) has been received.  The later +	 * example patch is using it like this at the active side when the +	 * server is in syncookie mode. +	 * +	 * The bpf prog will usually turn this off in the common cases. +	 */ +	BPF_SOCK_OPS_PARSE_ALL_HDR_OPT_CB_FLAG	= (1<<4), +	/* Call bpf when kernel has received a header option that +	 * the kernel cannot handle.  The bpf prog will be called under +	 * sock_ops->op == BPF_SOCK_OPS_PARSE_HDR_OPT_CB. +	 * +	 * Please refer to the comment in BPF_SOCK_OPS_PARSE_HDR_OPT_CB +	 * for the header option related helpers that will be useful +	 * to the bpf programs. +	 */ +	BPF_SOCK_OPS_PARSE_UNKNOWN_HDR_OPT_CB_FLAG = (1<<5), +	/* Call bpf when the kernel is writing header options for the +	 * outgoing packet.  The bpf prog will first be called +	 * to reserve space in a skb under +	 * sock_ops->op == BPF_SOCK_OPS_HDR_OPT_LEN_CB.  Then +	 * the bpf prog will be called to write the header option(s) +	 * under sock_ops->op == BPF_SOCK_OPS_WRITE_HDR_OPT_CB. +	 * +	 * Please refer to the comment in BPF_SOCK_OPS_HDR_OPT_LEN_CB +	 * and BPF_SOCK_OPS_WRITE_HDR_OPT_CB for the header option +	 * related helpers that will be useful to the bpf programs. +	 * +	 * The kernel gets its chance to reserve space and write +	 * options first before the BPF program does. +	 */ +	BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG = (1<<6),  /* Mask of all currently supported cb flags */ -	BPF_SOCK_OPS_ALL_CB_FLAGS       = 0xF, +	BPF_SOCK_OPS_ALL_CB_FLAGS       = 0x7F, +}; + +enum { +	SK_BPF_CB_TX_TIMESTAMPING	= 1<<0, +	SK_BPF_CB_MASK			= (SK_BPF_CB_TX_TIMESTAMPING - 1) | +					   SK_BPF_CB_TX_TIMESTAMPING  };  /* List of known BPF sock_ops operators. @@ -4222,6 +7032,88 @@ enum {  					 * socket transition to LISTEN state.  					 */  	BPF_SOCK_OPS_RTT_CB,		/* Called on every RTT. +					 * Arg1: measured RTT input (mrtt) +					 * Arg2: updated srtt +					 */ +	BPF_SOCK_OPS_PARSE_HDR_OPT_CB,	/* Parse the header option. +					 * It will be called to handle +					 * the packets received at +					 * an already established +					 * connection. +					 * +					 * sock_ops->skb_data: +					 * Referring to the received skb. +					 * It covers the TCP header only. +					 * +					 * bpf_load_hdr_opt() can also +					 * be used to search for a +					 * particular option. +					 */ +	BPF_SOCK_OPS_HDR_OPT_LEN_CB,	/* Reserve space for writing the +					 * header option later in +					 * BPF_SOCK_OPS_WRITE_HDR_OPT_CB. +					 * Arg1: bool want_cookie. (in +					 *       writing SYNACK only) +					 * +					 * sock_ops->skb_data: +					 * Not available because no header has +					 * been	written yet. +					 * +					 * sock_ops->skb_tcp_flags: +					 * The tcp_flags of the +					 * outgoing skb. (e.g. SYN, ACK, FIN). +					 * +					 * bpf_reserve_hdr_opt() should +					 * be used to reserve space. +					 */ +	BPF_SOCK_OPS_WRITE_HDR_OPT_CB,	/* Write the header options +					 * Arg1: bool want_cookie. (in +					 *       writing SYNACK only) +					 * +					 * sock_ops->skb_data: +					 * Referring to the outgoing skb. +					 * It covers the TCP header +					 * that has already been written +					 * by the kernel and the +					 * earlier bpf-progs. +					 * +					 * sock_ops->skb_tcp_flags: +					 * The tcp_flags of the outgoing +					 * skb. (e.g. SYN, ACK, FIN). +					 * +					 * bpf_store_hdr_opt() should +					 * be used to write the +					 * option. +					 * +					 * bpf_load_hdr_opt() can also +					 * be used to search for a +					 * particular option that +					 * has already been written +					 * by the kernel or the +					 * earlier bpf-progs. +					 */ +	BPF_SOCK_OPS_TSTAMP_SCHED_CB,	/* Called when skb is passing +					 * through dev layer when +					 * SK_BPF_CB_TX_TIMESTAMPING +					 * feature is on. +					 */ +	BPF_SOCK_OPS_TSTAMP_SND_SW_CB,	/* Called when skb is about to send +					 * to the nic when SK_BPF_CB_TX_TIMESTAMPING +					 * feature is on. +					 */ +	BPF_SOCK_OPS_TSTAMP_SND_HW_CB,	/* Called in hardware phase when +					 * SK_BPF_CB_TX_TIMESTAMPING feature +					 * is on. +					 */ +	BPF_SOCK_OPS_TSTAMP_ACK_CB,	/* Called when all the skbs in the +					 * same sendmsg call are acked +					 * when SK_BPF_CB_TX_TIMESTAMPING +					 * feature is on. +					 */ +	BPF_SOCK_OPS_TSTAMP_SENDMSG_CB,	/* Called when every sendmsg syscall +					 * is triggered. It's used to correlate +					 * sendmsg timestamp with corresponding +					 * tskey.  					 */  }; @@ -4243,6 +7135,7 @@ enum {  	BPF_TCP_LISTEN,  	BPF_TCP_CLOSING,	/* Now a valid state */  	BPF_TCP_NEW_SYN_RECV, +	BPF_TCP_BOUND_INACTIVE,  	BPF_TCP_MAX_STATES	/* Leave at the end! */  }; @@ -4250,6 +7143,65 @@ enum {  enum {  	TCP_BPF_IW		= 1001,	/* Set TCP initial congestion window */  	TCP_BPF_SNDCWND_CLAMP	= 1002,	/* Set sndcwnd_clamp */ +	TCP_BPF_DELACK_MAX	= 1003, /* Max delay ack in usecs */ +	TCP_BPF_RTO_MIN		= 1004, /* Min delay ack in usecs */ +	/* Copy the SYN pkt to optval +	 * +	 * BPF_PROG_TYPE_SOCK_OPS only.  It is similar to the +	 * bpf_getsockopt(TCP_SAVED_SYN) but it does not limit +	 * to only getting from the saved_syn.  It can either get the +	 * syn packet from: +	 * +	 * 1. the just-received SYN packet (only available when writing the +	 *    SYNACK).  It will be useful when it is not necessary to +	 *    save the SYN packet for latter use.  It is also the only way +	 *    to get the SYN during syncookie mode because the syn +	 *    packet cannot be saved during syncookie. +	 * +	 * OR +	 * +	 * 2. the earlier saved syn which was done by +	 *    bpf_setsockopt(TCP_SAVE_SYN). +	 * +	 * The bpf_getsockopt(TCP_BPF_SYN*) option will hide where the +	 * SYN packet is obtained. +	 * +	 * If the bpf-prog does not need the IP[46] header,  the +	 * bpf-prog can avoid parsing the IP header by using +	 * TCP_BPF_SYN.  Otherwise, the bpf-prog can get both +	 * IP[46] and TCP header by using TCP_BPF_SYN_IP. +	 * +	 *      >0: Total number of bytes copied +	 * -ENOSPC: Not enough space in optval. Only optlen number of +	 *          bytes is copied. +	 * -ENOENT: The SYN skb is not available now and the earlier SYN pkt +	 *	    is not saved by setsockopt(TCP_SAVE_SYN). +	 */ +	TCP_BPF_SYN		= 1005, /* Copy the TCP header */ +	TCP_BPF_SYN_IP		= 1006, /* Copy the IP[46] and TCP header */ +	TCP_BPF_SYN_MAC         = 1007, /* Copy the MAC, IP[46], and TCP header */ +	TCP_BPF_SOCK_OPS_CB_FLAGS = 1008, /* Get or Set TCP sock ops flags */ +	SK_BPF_CB_FLAGS		= 1009, /* Get or set sock ops flags in socket */ +}; + +enum { +	BPF_LOAD_HDR_OPT_TCP_SYN = (1ULL << 0), +}; + +/* args[0] value during BPF_SOCK_OPS_HDR_OPT_LEN_CB and + * BPF_SOCK_OPS_WRITE_HDR_OPT_CB. + */ +enum { +	BPF_WRITE_HDR_TCP_CURRENT_MSS = 1,	/* Kernel is finding the +						 * total option spaces +						 * required for an established +						 * sk in order to calculate the +						 * MSS.  No skb is actually +						 * sent. +						 */ +	BPF_WRITE_HDR_TCP_SYNACK_COOKIE = 2,	/* Kernel is in syncookie mode +						 * when sending a SYN. +						 */  };  struct bpf_perf_event_value { @@ -4286,6 +7238,10 @@ struct bpf_raw_tracepoint_args {  enum {  	BPF_FIB_LOOKUP_DIRECT  = (1U << 0),  	BPF_FIB_LOOKUP_OUTPUT  = (1U << 1), +	BPF_FIB_LOOKUP_SKIP_NEIGH = (1U << 2), +	BPF_FIB_LOOKUP_TBID    = (1U << 3), +	BPF_FIB_LOOKUP_SRC     = (1U << 4), +	BPF_FIB_LOOKUP_MARK    = (1U << 5),  };  enum { @@ -4298,6 +7254,7 @@ enum {  	BPF_FIB_LKUP_RET_UNSUPP_LWT,   /* fwd requires encapsulation */  	BPF_FIB_LKUP_RET_NO_NEIGH,     /* no neighbor entry for nh */  	BPF_FIB_LKUP_RET_FRAG_NEEDED,  /* fragmentation required to fwd */ +	BPF_FIB_LKUP_RET_NO_SRC_ADDR,  /* failed to derive IP src addr */  };  struct bpf_fib_lookup { @@ -4311,9 +7268,13 @@ struct bpf_fib_lookup {  	__be16	sport;  	__be16	dport; -	/* total length of packet from network header - used for MTU check */ -	__u16	tot_len; +	union {	/* used for MTU check */ +		/* input to lookup */ +		__u16	tot_len; /* L3 length from network hdr (iph->tot_len) */ +		/* output: MTU value */ +		__u16	mtu_result; +	} __attribute__((packed, aligned(2)));  	/* input: L3 device index for lookup  	 * output: device index from FIB lookup  	 */ @@ -4328,6 +7289,9 @@ struct bpf_fib_lookup {  		__u32	rt_metric;  	}; +	/* input: source address to consider for lookup +	 * output: source address result from lookup +	 */  	union {  		__be32		ipv4_src;  		__u32		ipv6_src[4];  /* in6_addr; network order */ @@ -4342,11 +7306,53 @@ struct bpf_fib_lookup {  		__u32		ipv6_dst[4];  /* in6_addr; network order */  	}; -	/* output */ -	__be16	h_vlan_proto; -	__be16	h_vlan_TCI; -	__u8	smac[6];     /* ETH_ALEN */ -	__u8	dmac[6];     /* ETH_ALEN */ +	union { +		struct { +			/* output */ +			__be16	h_vlan_proto; +			__be16	h_vlan_TCI; +		}; +		/* input: when accompanied with the +		 * 'BPF_FIB_LOOKUP_DIRECT | BPF_FIB_LOOKUP_TBID` flags, a +		 * specific routing table to use for the fib lookup. +		 */ +		__u32	tbid; +	}; + +	union { +		/* input */ +		struct { +			__u32	mark;   /* policy routing */ +			/* 2 4-byte holes for input */ +		}; + +		/* output: source and dest mac */ +		struct { +			__u8	smac[6];	/* ETH_ALEN */ +			__u8	dmac[6];	/* ETH_ALEN */ +		}; +	}; +}; + +struct bpf_redir_neigh { +	/* network family for lookup (AF_INET, AF_INET6) */ +	__u32 nh_family; +	/* network address of nexthop; skips fib lookup to find gateway */ +	union { +		__be32		ipv4_nh; +		__u32		ipv6_nh[4];  /* in6_addr; network order */ +	}; +}; + +/* bpf_check_mtu flags*/ +enum  bpf_check_mtu_flags { +	BPF_MTU_CHK_SEGS  = (1U << 0), +}; + +enum bpf_check_mtu_ret { +	BPF_MTU_CHK_RET_SUCCESS,      /* check and lookup successful */ +	BPF_MTU_CHK_RET_FRAG_NEEDED,  /* fragmentation required to fwd */ +	BPF_MTU_CHK_RET_SEGS_TOOBIG,  /* GSO re-segmentation needed to fwd */  };  enum bpf_task_fd_type { @@ -4408,6 +7414,38 @@ struct bpf_spin_lock {  	__u32	val;  }; +struct bpf_timer { +	__u64 __opaque[2]; +} __attribute__((aligned(8))); + +struct bpf_wq { +	__u64 __opaque[2]; +} __attribute__((aligned(8))); + +struct bpf_dynptr { +	__u64 __opaque[2]; +} __attribute__((aligned(8))); + +struct bpf_list_head { +	__u64 __opaque[2]; +} __attribute__((aligned(8))); + +struct bpf_list_node { +	__u64 __opaque[3]; +} __attribute__((aligned(8))); + +struct bpf_rb_root { +	__u64 __opaque[2]; +} __attribute__((aligned(8))); + +struct bpf_rb_node { +	__u64 __opaque[4]; +} __attribute__((aligned(8))); + +struct bpf_refcount { +	__u32 __opaque[1]; +} __attribute__((aligned(4))); +  struct bpf_sysctl {  	__u32	write;		/* Sysctl is being read (= 0) or written (= 1).  				 * Allows 1,2,4-byte read, but no write. @@ -4435,16 +7473,154 @@ struct bpf_pidns_info {  /* User accessible data for SK_LOOKUP programs. Add new fields at the end. */  struct bpf_sk_lookup { -	__bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */ +	union { +		__bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */ +		__u64 cookie; /* Non-zero if socket was selected in PROG_TEST_RUN */ +	};  	__u32 family;		/* Protocol family (AF_INET, AF_INET6) */  	__u32 protocol;		/* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */  	__u32 remote_ip4;	/* Network byte order */  	__u32 remote_ip6[4];	/* Network byte order */ -	__u32 remote_port;	/* Network byte order */ +	__be16 remote_port;	/* Network byte order */ +	__u16 :16;		/* Zero padding */  	__u32 local_ip4;	/* Network byte order */  	__u32 local_ip6[4];	/* Network byte order */  	__u32 local_port;	/* Host byte order */ +	__u32 ingress_ifindex;		/* The arriving interface. Determined by inet_iif. */ +}; + +/* + * struct btf_ptr is used for typed pointer representation; the + * type id is used to render the pointer data as the appropriate type + * via the bpf_snprintf_btf() helper described above.  A flags field - + * potentially to specify additional details about the BTF pointer + * (rather than its mode of display) - is included for future use. + * Display flags - BTF_F_* - are passed to bpf_snprintf_btf separately. + */ +struct btf_ptr { +	void *ptr; +	__u32 type_id; +	__u32 flags;		/* BTF ptr flags; unused at present. */ +}; + +/* + * Flags to control bpf_snprintf_btf() behaviour. + *     - BTF_F_COMPACT: no formatting around type information + *     - BTF_F_NONAME: no struct/union member names/types + *     - BTF_F_PTR_RAW: show raw (unobfuscated) pointer values; + *       equivalent to %px. + *     - BTF_F_ZERO: show zero-valued struct/union members; they + *       are not displayed by default + */ +enum { +	BTF_F_COMPACT	=	(1ULL << 0), +	BTF_F_NONAME	=	(1ULL << 1), +	BTF_F_PTR_RAW	=	(1ULL << 2), +	BTF_F_ZERO	=	(1ULL << 3), +}; + +/* bpf_core_relo_kind encodes which aspect of captured field/type/enum value + * has to be adjusted by relocations. It is emitted by llvm and passed to + * libbpf and later to the kernel. + */ +enum bpf_core_relo_kind { +	BPF_CORE_FIELD_BYTE_OFFSET = 0,      /* field byte offset */ +	BPF_CORE_FIELD_BYTE_SIZE = 1,        /* field size in bytes */ +	BPF_CORE_FIELD_EXISTS = 2,           /* field existence in target kernel */ +	BPF_CORE_FIELD_SIGNED = 3,           /* field signedness (0 - unsigned, 1 - signed) */ +	BPF_CORE_FIELD_LSHIFT_U64 = 4,       /* bitfield-specific left bitshift */ +	BPF_CORE_FIELD_RSHIFT_U64 = 5,       /* bitfield-specific right bitshift */ +	BPF_CORE_TYPE_ID_LOCAL = 6,          /* type ID in local BPF object */ +	BPF_CORE_TYPE_ID_TARGET = 7,         /* type ID in target kernel */ +	BPF_CORE_TYPE_EXISTS = 8,            /* type existence in target kernel */ +	BPF_CORE_TYPE_SIZE = 9,              /* type size in bytes */ +	BPF_CORE_ENUMVAL_EXISTS = 10,        /* enum value existence in target kernel */ +	BPF_CORE_ENUMVAL_VALUE = 11,         /* enum value integer value */ +	BPF_CORE_TYPE_MATCHES = 12,          /* type match in target kernel */ +}; + +/* + * "struct bpf_core_relo" is used to pass relocation data form LLVM to libbpf + * and from libbpf to the kernel. + * + * CO-RE relocation captures the following data: + * - insn_off - instruction offset (in bytes) within a BPF program that needs + *   its insn->imm field to be relocated with actual field info; + * - type_id - BTF type ID of the "root" (containing) entity of a relocatable + *   type or field; + * - access_str_off - offset into corresponding .BTF string section. String + *   interpretation depends on specific relocation kind: + *     - for field-based relocations, string encodes an accessed field using + *       a sequence of field and array indices, separated by colon (:). It's + *       conceptually very close to LLVM's getelementptr ([0]) instruction's + *       arguments for identifying offset to a field. + *     - for type-based relocations, strings is expected to be just "0"; + *     - for enum value-based relocations, string contains an index of enum + *       value within its enum type; + * - kind - one of enum bpf_core_relo_kind; + * + * Example: + *   struct sample { + *       int a; + *       struct { + *           int b[10]; + *       }; + *   }; + * + *   struct sample *s = ...; + *   int *x = &s->a;     // encoded as "0:0" (a is field #0) + *   int *y = &s->b[5];  // encoded as "0:1:0:5" (anon struct is field #1, + *                       // b is field #0 inside anon struct, accessing elem #5) + *   int *z = &s[10]->b; // encoded as "10:1" (ptr is used as an array) + * + * type_id for all relocs in this example will capture BTF type id of + * `struct sample`. + * + * Such relocation is emitted when using __builtin_preserve_access_index() + * Clang built-in, passing expression that captures field address, e.g.: + * + * bpf_probe_read(&dst, sizeof(dst), + *		  __builtin_preserve_access_index(&src->a.b.c)); + * + * In this case Clang will emit field relocation recording necessary data to + * be able to find offset of embedded `a.b.c` field within `src` struct. + * + * [0] https://llvm.org/docs/LangRef.html#getelementptr-instruction + */ +struct bpf_core_relo { +	__u32 insn_off; +	__u32 type_id; +	__u32 access_str_off; +	enum bpf_core_relo_kind kind; +}; + +/* + * Flags to control bpf_timer_start() behaviour. + *     - BPF_F_TIMER_ABS: Timeout passed is absolute time, by default it is + *       relative to current time. + *     - BPF_F_TIMER_CPU_PIN: Timer will be pinned to the CPU of the caller. + */ +enum { +	BPF_F_TIMER_ABS = (1ULL << 0), +	BPF_F_TIMER_CPU_PIN = (1ULL << 1), +}; + +/* BPF numbers iterator state */ +struct bpf_iter_num { +	/* opaque iterator state; having __u64 here allows to preserve correct +	 * alignment requirements in vmlinux.h, generated from BTF +	 */ +	__u64 __opaque[1]; +} __attribute__((aligned(8))); + +/* + * Flags to control BPF kfunc behaviour. + *     - BPF_F_PAD_ZEROS: Pad destination buffer with zeros. (See the respective + *       helper documentation for details.) + */ +enum bpf_kfunc_flags { +	BPF_F_PAD_ZEROS = (1ULL << 0),  };  #endif /* _UAPI__LINUX_BPF_H__ */ diff --git a/include/uapi/linux/bpfilter.h b/include/uapi/linux/bpfilter.h deleted file mode 100644 index cbc1f5813f50..000000000000 --- a/include/uapi/linux/bpfilter.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _UAPI_LINUX_BPFILTER_H -#define _UAPI_LINUX_BPFILTER_H - -#include <linux/if.h> - -enum { -	BPFILTER_IPT_SO_SET_REPLACE = 64, -	BPFILTER_IPT_SO_SET_ADD_COUNTERS = 65, -	BPFILTER_IPT_SET_MAX, -}; - -enum { -	BPFILTER_IPT_SO_GET_INFO = 64, -	BPFILTER_IPT_SO_GET_ENTRIES = 65, -	BPFILTER_IPT_SO_GET_REVISION_MATCH = 66, -	BPFILTER_IPT_SO_GET_REVISION_TARGET = 67, -	BPFILTER_IPT_GET_MAX, -}; - -#endif /* _UAPI_LINUX_BPFILTER_H */ diff --git a/include/uapi/linux/btf.h b/include/uapi/linux/btf.h index 5a667107ad2c..266d4ffa6c07 100644 --- a/include/uapi/linux/btf.h +++ b/include/uapi/linux/btf.h @@ -33,17 +33,18 @@ struct btf_type {  	/* "info" bits arrangement  	 * bits  0-15: vlen (e.g. # of struct's members)  	 * bits 16-23: unused -	 * bits 24-27: kind (e.g. int, ptr, array...etc) -	 * bits 28-30: unused +	 * bits 24-28: kind (e.g. int, ptr, array...etc) +	 * bits 29-30: unused  	 * bit     31: kind_flag, currently used by -	 *             struct, union and fwd +	 *             struct, union, enum, fwd, enum64, +	 *             decl_tag and type_tag  	 */  	__u32 info; -	/* "size" is used by INT, ENUM, STRUCT, UNION and DATASEC. +	/* "size" is used by INT, ENUM, STRUCT, UNION, DATASEC and ENUM64.  	 * "size" tells the size of the type it is describing.  	 *  	 * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT, -	 * FUNC, FUNC_PROTO and VAR. +	 * FUNC, FUNC_PROTO, VAR, DECL_TAG and TYPE_TAG.  	 * "type" is a type_id referring to another type.  	 */  	union { @@ -52,28 +53,35 @@ struct btf_type {  	};  }; -#define BTF_INFO_KIND(info)	(((info) >> 24) & 0x0f) +#define BTF_INFO_KIND(info)	(((info) >> 24) & 0x1f)  #define BTF_INFO_VLEN(info)	((info) & 0xffff)  #define BTF_INFO_KFLAG(info)	((info) >> 31) -#define BTF_KIND_UNKN		0	/* Unknown	*/ -#define BTF_KIND_INT		1	/* Integer	*/ -#define BTF_KIND_PTR		2	/* Pointer	*/ -#define BTF_KIND_ARRAY		3	/* Array	*/ -#define BTF_KIND_STRUCT		4	/* Struct	*/ -#define BTF_KIND_UNION		5	/* Union	*/ -#define BTF_KIND_ENUM		6	/* Enumeration	*/ -#define BTF_KIND_FWD		7	/* Forward	*/ -#define BTF_KIND_TYPEDEF	8	/* Typedef	*/ -#define BTF_KIND_VOLATILE	9	/* Volatile	*/ -#define BTF_KIND_CONST		10	/* Const	*/ -#define BTF_KIND_RESTRICT	11	/* Restrict	*/ -#define BTF_KIND_FUNC		12	/* Function	*/ -#define BTF_KIND_FUNC_PROTO	13	/* Function Proto	*/ -#define BTF_KIND_VAR		14	/* Variable	*/ -#define BTF_KIND_DATASEC	15	/* Section	*/ -#define BTF_KIND_MAX		BTF_KIND_DATASEC -#define NR_BTF_KINDS		(BTF_KIND_MAX + 1) +enum { +	BTF_KIND_UNKN		= 0,	/* Unknown	*/ +	BTF_KIND_INT		= 1,	/* Integer	*/ +	BTF_KIND_PTR		= 2,	/* Pointer	*/ +	BTF_KIND_ARRAY		= 3,	/* Array	*/ +	BTF_KIND_STRUCT		= 4,	/* Struct	*/ +	BTF_KIND_UNION		= 5,	/* Union	*/ +	BTF_KIND_ENUM		= 6,	/* Enumeration up to 32-bit values */ +	BTF_KIND_FWD		= 7,	/* Forward	*/ +	BTF_KIND_TYPEDEF	= 8,	/* Typedef	*/ +	BTF_KIND_VOLATILE	= 9,	/* Volatile	*/ +	BTF_KIND_CONST		= 10,	/* Const	*/ +	BTF_KIND_RESTRICT	= 11,	/* Restrict	*/ +	BTF_KIND_FUNC		= 12,	/* Function	*/ +	BTF_KIND_FUNC_PROTO	= 13,	/* Function Proto	*/ +	BTF_KIND_VAR		= 14,	/* Variable	*/ +	BTF_KIND_DATASEC	= 15,	/* Section	*/ +	BTF_KIND_FLOAT		= 16,	/* Floating point	*/ +	BTF_KIND_DECL_TAG	= 17,	/* Decl Tag */ +	BTF_KIND_TYPE_TAG	= 18,	/* Type Tag */ +	BTF_KIND_ENUM64		= 19,	/* Enumeration up to 64-bit values */ + +	NR_BTF_KINDS, +	BTF_KIND_MAX		= NR_BTF_KINDS - 1, +};  /* For some specific BTF_KIND, "struct btf_type" is immediately   * followed by extra data. @@ -169,4 +177,25 @@ struct btf_var_secinfo {  	__u32	size;  }; +/* BTF_KIND_DECL_TAG is followed by a single "struct btf_decl_tag" to describe + * additional information related to the tag applied location. + * If component_idx == -1, the tag is applied to a struct, union, + * variable or function. Otherwise, it is applied to a struct/union + * member or a func argument, and component_idx indicates which member + * or argument (0 ... vlen-1). + */ +struct btf_decl_tag { +       __s32   component_idx; +}; + +/* BTF_KIND_ENUM64 is followed by multiple "struct btf_enum64". + * The exact number of btf_enum64 is stored in the vlen (of the + * info in "struct btf_type"). + */ +struct btf_enum64 { +	__u32	name_off; +	__u32	val_lo32; +	__u32	val_hi32; +}; +  #endif /* _UAPI__LINUX_BTF_H__ */ diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h index 2c39d15a2beb..8e710bbb688e 100644 --- a/include/uapi/linux/btrfs.h +++ b/include/uapi/linux/btrfs.h @@ -19,8 +19,14 @@  #ifndef _UAPI_LINUX_BTRFS_H  #define _UAPI_LINUX_BTRFS_H + +#ifdef __cplusplus +extern "C" { +#endif +  #include <linux/types.h>  #include <linux/ioctl.h> +#include <linux/fs.h>  #define BTRFS_IOCTL_MAGIC 0x94  #define BTRFS_VOL_NAME_MAX 255 @@ -86,6 +92,7 @@ struct btrfs_qgroup_limit {   * struct btrfs_qgroup_inherit.flags   */  #define BTRFS_QGROUP_INHERIT_SET_LIMITS	(1ULL << 0) +#define BTRFS_QGROUP_INHERIT_FLAGS_SUPP (BTRFS_QGROUP_INHERIT_SET_LIMITS)  struct btrfs_qgroup_inherit {  	__u64	flags; @@ -93,7 +100,7 @@ struct btrfs_qgroup_inherit {  	__u64	num_ref_copies;  	__u64	num_excl_copies;  	struct btrfs_qgroup_limit lim; -	__u64	qgroups[0]; +	__u64	qgroups[];  };  struct btrfs_ioctl_qgroup_limit_args { @@ -154,7 +161,7 @@ struct btrfs_scrub_progress {  	__u64 tree_bytes_scrubbed;	/* # of tree bytes scrubbed */  	__u64 read_errors;		/* # of read errors encountered (EIO) */  	__u64 csum_errors;		/* # of failed csum checks */ -	__u64 verify_errors;		/* # of occurences, where the metadata +	__u64 verify_errors;		/* # of occurrences, where the metadata  					 * of a tree block did not match the  					 * expected values, like generation or  					 * logical */ @@ -174,13 +181,14 @@ struct btrfs_scrub_progress {  	__u64 last_physical;		/* last physical address scrubbed. In  					 * case a scrub was aborted, this can  					 * be used to restart the scrub */ -	__u64 unverified_errors;	/* # of occurences where a read for a +	__u64 unverified_errors;	/* # of occurrences where a read for a  					 * full (64k) bio failed, but the re-  					 * check succeeded for each 4k piece.  					 * Intermittent error. */  };  #define BTRFS_SCRUB_READONLY	1 +#define BTRFS_SCRUB_SUPPORTED_FLAGS	(BTRFS_SCRUB_READONLY)  struct btrfs_ioctl_scrub_args {  	__u64 devid;				/* in */  	__u64 start;				/* in */ @@ -239,7 +247,17 @@ struct btrfs_ioctl_dev_info_args {  	__u8 uuid[BTRFS_UUID_SIZE];		/* in/out */  	__u64 bytes_used;			/* out */  	__u64 total_bytes;			/* out */ -	__u64 unused[379];			/* pad to 4k */ +	/* +	 * Optional, out. +	 * +	 * Showing the fsid of the device, allowing user space to check if this +	 * device is a seeding one. +	 * +	 * Introduced in v6.3, thus user space still needs to check if kernel +	 * changed this value.  Older kernel will not touch the values here. +	 */ +	__u8 fsid[BTRFS_UUID_SIZE]; +	__u64 unused[377];			/* pad to 4k */  	__u8 path[BTRFS_DEVICE_PATH_NAME_MAX];	/* out */  }; @@ -288,6 +306,13 @@ struct btrfs_ioctl_fs_info_args {   * first mount when booting older kernel versions.   */  #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID	(1ULL << 1) +#define BTRFS_FEATURE_COMPAT_RO_VERITY			(1ULL << 2) + +/* + * Put all block group items into a dedicated block group tree, greatly + * reducing mount time for large filesystem due to better locality. + */ +#define BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE	(1ULL << 3)  #define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF	(1ULL << 0)  #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL	(1ULL << 1) @@ -307,6 +332,10 @@ struct btrfs_ioctl_fs_info_args {  #define BTRFS_FEATURE_INCOMPAT_NO_HOLES		(1ULL << 9)  #define BTRFS_FEATURE_INCOMPAT_METADATA_UUID	(1ULL << 10)  #define BTRFS_FEATURE_INCOMPAT_RAID1C34		(1ULL << 11) +#define BTRFS_FEATURE_INCOMPAT_ZONED		(1ULL << 12) +#define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2	(1ULL << 13) +#define BTRFS_FEATURE_INCOMPAT_RAID_STRIPE_TREE	(1ULL << 14) +#define BTRFS_FEATURE_INCOMPAT_SIMPLE_QUOTA	(1ULL << 16)  struct btrfs_ioctl_feature_flags {  	__u64 compat_flags; @@ -324,6 +353,12 @@ struct btrfs_ioctl_feature_flags {   */  struct btrfs_balance_args {  	__u64 profiles; + +	/* +	 * usage filter +	 * BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N' +	 * BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max +	 */  	union {  		__u64 usage;  		struct { @@ -540,7 +575,7 @@ struct btrfs_ioctl_search_header {  	__u64 offset;  	__u32 type;  	__u32 len; -}; +} __attribute__ ((__may_alias__));  #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))  /* @@ -553,18 +588,23 @@ struct btrfs_ioctl_search_args {  	char buf[BTRFS_SEARCH_ARGS_BUFSIZE];  }; +/* + * Extended version of TREE_SEARCH ioctl that can return more than 4k of bytes. + * The allocated size of the buffer is set in buf_size. + */  struct btrfs_ioctl_search_args_v2 {  	struct btrfs_ioctl_search_key key; /* in/out - search parameters */  	__u64 buf_size;		   /* in - size of buffer  					    * out - on EOVERFLOW: needed size  					    *       to store item */ -	__u64 buf[0];                       /* out - found items */ +	__u64 buf[];                       /* out - found items */  }; +/* With a @src_length of zero, the range from @src_offset->EOF is cloned! */  struct btrfs_ioctl_clone_range_args { -  __s64 src_fd; -  __u64 src_offset, src_length; -  __u64 dest_offset; +	__s64 src_fd; +	__u64 src_offset, src_length; +	__u64 dest_offset;  };  /* @@ -575,6 +615,14 @@ struct btrfs_ioctl_clone_range_args {   */  #define BTRFS_DEFRAG_RANGE_COMPRESS 1  #define BTRFS_DEFRAG_RANGE_START_IO 2 +#define BTRFS_DEFRAG_RANGE_COMPRESS_LEVEL 4 +/* Request no compression on the range (uncompress if necessary). */ +#define BTRFS_DEFRAG_RANGE_NOCOMPRESS	8 +#define BTRFS_DEFRAG_RANGE_FLAGS_SUPP	(BTRFS_DEFRAG_RANGE_COMPRESS |		\ +					 BTRFS_DEFRAG_RANGE_COMPRESS_LEVEL |	\ +					 BTRFS_DEFRAG_RANGE_NOCOMPRESS |	\ +					 BTRFS_DEFRAG_RANGE_START_IO) +  struct btrfs_ioctl_defrag_range_args {  	/* start of the defrag operation */  	__u64 start; @@ -597,10 +645,18 @@ struct btrfs_ioctl_defrag_range_args {  	/*  	 * which compression method to use if turning on compression -	 * for this defrag operation.  If unspecified, zlib will -	 * be used +	 * for this defrag operation. If unspecified, zlib will be +	 * used. If compression level is also being specified, set the +	 * BTRFS_DEFRAG_RANGE_COMPRESS_LEVEL flag and fill the compress +	 * member structure instead of the compress_type field.  	 */ -	__u32 compress_type; +	union { +		__u32 compress_type; +		struct { +			__u8 type; +			__s8 level; +		} compress; +	};  	/* spare for later */  	__u32 unused[4]; @@ -629,7 +685,7 @@ struct btrfs_ioctl_same_args {  	__u16 dest_count;	/* in - total elements in info array */  	__u16 reserved1;  	__u32 reserved2; -	struct btrfs_ioctl_same_extent_info info[0]; +	struct btrfs_ioctl_same_extent_info info[];  };  struct btrfs_ioctl_space_info { @@ -641,7 +697,7 @@ struct btrfs_ioctl_space_info {  struct btrfs_ioctl_space_args {  	__u64 space_slots;  	__u64 total_spaces; -	struct btrfs_ioctl_space_info spaces[0]; +	struct btrfs_ioctl_space_info spaces[];  };  struct btrfs_data_container { @@ -649,7 +705,7 @@ struct btrfs_data_container {  	__u32	bytes_missing;	/* out -- additional bytes needed for result */  	__u32	elem_cnt;	/* out */  	__u32	elem_missed;	/* out */ -	__u64	val[0];		/* out */ +	__u64	val[];		/* out */  };  struct btrfs_ioctl_ino_path_args { @@ -668,8 +724,11 @@ struct btrfs_ioctl_logical_ino_args {  	/* struct btrfs_data_container	*inodes;	out   */  	__u64				inodes;  }; -/* Return every ref to the extent, not just those containing logical block. - * Requires logical == extent bytenr. */ + +/* + * Return every ref to the extent, not just those containing logical block. + * Requires logical == extent bytenr. + */  #define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET	(1ULL << 0)  enum btrfs_dev_stat_values { @@ -713,6 +772,7 @@ struct btrfs_ioctl_get_dev_stats {  #define BTRFS_QUOTA_CTL_ENABLE	1  #define BTRFS_QUOTA_CTL_DISABLE	2  #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED	3 +#define BTRFS_QUOTA_CTL_ENABLE_SIMPLE_QUOTA 4  struct btrfs_ioctl_quota_ctl_args {  	__u64 cmd;  	__u64 status; @@ -769,10 +829,24 @@ struct btrfs_ioctl_received_subvol_args {   */  #define BTRFS_SEND_FLAG_OMIT_END_CMD		0x4 +/* + * Read the protocol version in the structure + */ +#define BTRFS_SEND_FLAG_VERSION			0x8 + +/* + * Send compressed data using the ENCODED_WRITE command instead of decompressing + * the data and sending it with the WRITE command. This requires protocol + * version >= 2. + */ +#define BTRFS_SEND_FLAG_COMPRESSED		0x10 +  #define BTRFS_SEND_FLAG_MASK \  	(BTRFS_SEND_FLAG_NO_FILE_DATA | \  	 BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \ -	 BTRFS_SEND_FLAG_OMIT_END_CMD) +	 BTRFS_SEND_FLAG_OMIT_END_CMD | \ +	 BTRFS_SEND_FLAG_VERSION | \ +	 BTRFS_SEND_FLAG_COMPRESSED)  struct btrfs_ioctl_send_args {  	__s64 send_fd;			/* in */ @@ -780,7 +854,8 @@ struct btrfs_ioctl_send_args {  	__u64 __user *clone_sources;	/* in */  	__u64 parent_root;		/* in */  	__u64 flags;			/* in */ -	__u64 reserved[4];		/* in */ +	__u32 version;			/* in */ +	__u8  reserved[28];		/* in */  };  /* @@ -859,6 +934,157 @@ struct btrfs_ioctl_get_subvol_rootref_args {  		__u8 align[7];  }; +/* + * Data and metadata for an encoded read or write. + * + * Encoded I/O bypasses any encoding automatically done by the filesystem (e.g., + * compression). This can be used to read the compressed contents of a file or + * write pre-compressed data directly to a file. + * + * BTRFS_IOC_ENCODED_READ and BTRFS_IOC_ENCODED_WRITE are essentially + * preadv/pwritev with additional metadata about how the data is encoded and the + * size of the unencoded data. + * + * BTRFS_IOC_ENCODED_READ fills the given iovecs with the encoded data, fills + * the metadata fields, and returns the size of the encoded data. It reads one + * extent per call. It can also read data which is not encoded. + * + * BTRFS_IOC_ENCODED_WRITE uses the metadata fields, writes the encoded data + * from the iovecs, and returns the size of the encoded data. Note that the + * encoded data is not validated when it is written; if it is not valid (e.g., + * it cannot be decompressed), then a subsequent read may return an error. + * + * Since the filesystem page cache contains decoded data, encoded I/O bypasses + * the page cache. Encoded I/O requires CAP_SYS_ADMIN. + */ +struct btrfs_ioctl_encoded_io_args { +	/* Input parameters for both reads and writes. */ + +	/* +	 * iovecs containing encoded data. +	 * +	 * For reads, if the size of the encoded data is larger than the sum of +	 * iov[n].iov_len for 0 <= n < iovcnt, then the ioctl fails with +	 * ENOBUFS. +	 * +	 * For writes, the size of the encoded data is the sum of iov[n].iov_len +	 * for 0 <= n < iovcnt. This must be less than 128 KiB (this limit may +	 * increase in the future). This must also be less than or equal to +	 * unencoded_len. +	 */ +	const struct iovec __user *iov; +	/* Number of iovecs. */ +	unsigned long iovcnt; +	/* +	 * Offset in file. +	 * +	 * For writes, must be aligned to the sector size of the filesystem. +	 */ +	__s64 offset; +	/* Currently must be zero. */ +	__u64 flags; + +	/* +	 * For reads, the following members are output parameters that will +	 * contain the returned metadata for the encoded data. +	 * For writes, the following members must be set to the metadata for the +	 * encoded data. +	 */ + +	/* +	 * Length of the data in the file. +	 * +	 * Must be less than or equal to unencoded_len - unencoded_offset. For +	 * writes, must be aligned to the sector size of the filesystem unless +	 * the data ends at or beyond the current end of the file. +	 */ +	__u64 len; +	/* +	 * Length of the unencoded (i.e., decrypted and decompressed) data. +	 * +	 * For writes, must be no more than 128 KiB (this limit may increase in +	 * the future). If the unencoded data is actually longer than +	 * unencoded_len, then it is truncated; if it is shorter, then it is +	 * extended with zeroes. +	 */ +	__u64 unencoded_len; +	/* +	 * Offset from the first byte of the unencoded data to the first byte of +	 * logical data in the file. +	 * +	 * Must be less than unencoded_len. +	 */ +	__u64 unencoded_offset; +	/* +	 * BTRFS_ENCODED_IO_COMPRESSION_* type. +	 * +	 * For writes, must not be BTRFS_ENCODED_IO_COMPRESSION_NONE. +	 */ +	__u32 compression; +	/* Currently always BTRFS_ENCODED_IO_ENCRYPTION_NONE. */ +	__u32 encryption; +	/* +	 * Reserved for future expansion. +	 * +	 * For reads, always returned as zero. Users should check for non-zero +	 * bytes. If there are any, then the kernel has a newer version of this +	 * structure with additional information that the user definition is +	 * missing. +	 * +	 * For writes, must be zeroed. +	 */ +	__u8 reserved[64]; +}; + +/* Data is not compressed. */ +#define BTRFS_ENCODED_IO_COMPRESSION_NONE 0 +/* Data is compressed as a single zlib stream. */ +#define BTRFS_ENCODED_IO_COMPRESSION_ZLIB 1 +/* + * Data is compressed as a single zstd frame with the windowLog compression + * parameter set to no more than 17. + */ +#define BTRFS_ENCODED_IO_COMPRESSION_ZSTD 2 +/* + * Data is compressed sector by sector (using the sector size indicated by the + * name of the constant) with LZO1X and wrapped in the format documented in + * fs/btrfs/lzo.c. For writes, the compression sector size must match the + * filesystem sector size. + */ +#define BTRFS_ENCODED_IO_COMPRESSION_LZO_4K 3 +#define BTRFS_ENCODED_IO_COMPRESSION_LZO_8K 4 +#define BTRFS_ENCODED_IO_COMPRESSION_LZO_16K 5 +#define BTRFS_ENCODED_IO_COMPRESSION_LZO_32K 6 +#define BTRFS_ENCODED_IO_COMPRESSION_LZO_64K 7 +#define BTRFS_ENCODED_IO_COMPRESSION_TYPES 8 + +/* Data is not encrypted. */ +#define BTRFS_ENCODED_IO_ENCRYPTION_NONE 0 +#define BTRFS_ENCODED_IO_ENCRYPTION_TYPES 1 + +/* + * Wait for subvolume cleaning process. This queries the kernel queue and it + * can change between the calls. + * + * - FOR_ONE	- specify the subvolid + * - FOR_QUEUED - wait for all currently queued + * - COUNT	- count number of queued + * - PEEK_FIRST - read which is the first in the queue (to be cleaned or being + * 		  cleaned already), or 0 if the queue is empty + * - PEEK_LAST  - read the last subvolid in the queue, or 0 if the queue is empty + */ +struct btrfs_ioctl_subvol_wait { +	__u64 subvolid; +	__u32 mode; +	__u32 count; +}; + +#define BTRFS_SUBVOL_SYNC_WAIT_FOR_ONE		(0) +#define BTRFS_SUBVOL_SYNC_WAIT_FOR_QUEUED	(1) +#define BTRFS_SUBVOL_SYNC_COUNT			(2) +#define BTRFS_SUBVOL_SYNC_PEEK_FIRST		(3) +#define BTRFS_SUBVOL_SYNC_PEEK_LAST		(4) +  /* Error codes as returned by the kernel */  enum btrfs_err_code {  	BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1, @@ -987,5 +1213,15 @@ enum btrfs_err_code {  				struct btrfs_ioctl_ino_lookup_user_args)  #define BTRFS_IOC_SNAP_DESTROY_V2 _IOW(BTRFS_IOCTL_MAGIC, 63, \  				struct btrfs_ioctl_vol_args_v2) +#define BTRFS_IOC_ENCODED_READ _IOR(BTRFS_IOCTL_MAGIC, 64, \ +				    struct btrfs_ioctl_encoded_io_args) +#define BTRFS_IOC_ENCODED_WRITE _IOW(BTRFS_IOCTL_MAGIC, 64, \ +				     struct btrfs_ioctl_encoded_io_args) +#define BTRFS_IOC_SUBVOL_SYNC_WAIT _IOW(BTRFS_IOCTL_MAGIC, 65, \ +					struct btrfs_ioctl_subvol_wait) + +#ifdef __cplusplus +} +#endif  #endif /* _UAPI_LINUX_BTRFS_H */ diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h index 9ba64ca6b4ac..fc29d273845d 100644 --- a/include/uapi/linux/btrfs_tree.h +++ b/include/uapi/linux/btrfs_tree.h @@ -4,6 +4,28 @@  #include <linux/btrfs.h>  #include <linux/types.h> +#ifdef __KERNEL__ +#include <linux/stddef.h> +#else +#include <stddef.h> +#endif + +/* ASCII for _BHRfS_M, no terminating nul */ +#define BTRFS_MAGIC 0x4D5F53665248425FULL + +#define BTRFS_MAX_LEVEL 8 + +/* + * We can actually store much bigger names, but lets not confuse the rest of + * linux. + */ +#define BTRFS_NAME_LEN 255 + +/* + * Theoretical limit is larger, but we keep this down to a sane value. That + * should limit greatly the possibility of collisions on inode ref items. + */ +#define BTRFS_LINK_MAX 65535U  /*   * This header contains the structure definitions and constants used @@ -48,13 +70,19 @@  /* tracks free space in block groups. */  #define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL +/* Holds the block group items for extent tree v2. */ +#define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL + +/* Tracks RAID stripes in block groups. */ +#define BTRFS_RAID_STRIPE_TREE_OBJECTID 12ULL +  /* device stats in the device tree */  #define BTRFS_DEV_STATS_OBJECTID 0ULL  /* for storing balance parameters in the root tree */  #define BTRFS_BALANCE_OBJECTID -4ULL -/* orhpan objectid for tracking unlinked/truncated files */ +/* orphan objectid for tracking unlinked/truncated files */  #define BTRFS_ORPHAN_OBJECTID -5ULL  /* does write ahead logging to speed up fsyncs */ @@ -113,12 +141,37 @@  #define BTRFS_INODE_REF_KEY		12  #define BTRFS_INODE_EXTREF_KEY		13  #define BTRFS_XATTR_ITEM_KEY		24 + +/* + * fs verity items are stored under two different key types on disk. + * The descriptor items: + * [ inode objectid, BTRFS_VERITY_DESC_ITEM_KEY, offset ] + * + * At offset 0, we store a btrfs_verity_descriptor_item which tracks the size + * of the descriptor item and some extra data for encryption. + * Starting at offset 1, these hold the generic fs verity descriptor.  The + * latter are opaque to btrfs, we just read and write them as a blob for the + * higher level verity code.  The most common descriptor size is 256 bytes. + * + * The merkle tree items: + * [ inode objectid, BTRFS_VERITY_MERKLE_ITEM_KEY, offset ] + * + * These also start at offset 0, and correspond to the merkle tree bytes.  When + * fsverity asks for page 0 of the merkle tree, we pull up one page starting at + * offset 0 for this key type.  These are also opaque to btrfs, we're blindly + * storing whatever fsverity sends down. + */ +#define BTRFS_VERITY_DESC_ITEM_KEY	36 +#define BTRFS_VERITY_MERKLE_ITEM_KEY	37 +  #define BTRFS_ORPHAN_ITEM_KEY		48  /* reserve 2-15 close to the inode for later flexibility */  /*   * dir items are the name -> inode pointers in a directory.  There is one - * for every name in a directory. + * for every name in a directory.  BTRFS_DIR_LOG_ITEM_KEY is no longer used + * but it's still defined here for documentation purposes and to help avoid + * having its numerical value reused in the future.   */  #define BTRFS_DIR_LOG_ITEM_KEY  60  #define BTRFS_DIR_LOG_INDEX_KEY 72 @@ -166,11 +219,31 @@   */  #define BTRFS_METADATA_ITEM_KEY	169 +/* + * Special inline ref key which stores the id of the subvolume which originally + * created the extent. This subvolume owns the extent permanently from the + * perspective of simple quotas. Needed to know which subvolume to free quota + * usage from when the extent is deleted. + * + * Stored as an inline ref rather to avoid wasting space on a separate item on + * top of the existing extent item. However, unlike the other inline refs, + * there is one one owner ref per extent rather than one per extent. + * + * Because of this, it goes at the front of the list of inline refs, and thus + * must have a lower type value than any other inline ref type (to satisfy the + * disk format rule that inline refs have non-decreasing type). + */ +#define BTRFS_EXTENT_OWNER_REF_KEY	172 +  #define BTRFS_TREE_BLOCK_REF_KEY	176  #define BTRFS_EXTENT_DATA_REF_KEY	178 -#define BTRFS_EXTENT_REF_V0_KEY		180 +/* + * Obsolete key. Defintion removed in 6.6, value may be reused in the future. + * + * #define BTRFS_EXTENT_REF_V0_KEY	180 + */  #define BTRFS_SHARED_BLOCK_REF_KEY	182 @@ -207,6 +280,8 @@  #define BTRFS_DEV_ITEM_KEY	216  #define BTRFS_CHUNK_ITEM_KEY	228 +#define BTRFS_RAID_STRIPE_KEY	230 +  /*   * Records the overall state of the qgroups.   * There's only one instance of this key present, @@ -270,7 +345,7 @@  #define BTRFS_PERSISTENT_ITEM_KEY	249  /* - * Persistantly stores the device replace state in the device tree. + * Persistently stores the device replace state in the device tree.   * The key is built like this: (0, BTRFS_DEV_REPLACE_KEY, 0).   */  #define BTRFS_DEV_REPLACE_KEY	250 @@ -294,7 +369,8 @@   */  #define BTRFS_STRING_ITEM_KEY	253 - +/* Maximum metadata block size (nodesize) */ +#define BTRFS_MAX_METADATA_BLOCKSIZE			65536  /* 32 bytes in various csum fields */  #define BTRFS_CSUM_SIZE 32 @@ -325,6 +401,50 @@ enum btrfs_csum_type {  #define BTRFS_FT_SYMLINK	7  #define BTRFS_FT_XATTR		8  #define BTRFS_FT_MAX		9 +/* Directory contains encrypted data */ +#define BTRFS_FT_ENCRYPTED	0x80 + +static inline __u8 btrfs_dir_flags_to_ftype(__u8 flags) +{ +	return flags & ~BTRFS_FT_ENCRYPTED; +} + +/* + * Inode flags + */ +#define BTRFS_INODE_NODATASUM		(1U << 0) +#define BTRFS_INODE_NODATACOW		(1U << 1) +#define BTRFS_INODE_READONLY		(1U << 2) +#define BTRFS_INODE_NOCOMPRESS		(1U << 3) +#define BTRFS_INODE_PREALLOC		(1U << 4) +#define BTRFS_INODE_SYNC		(1U << 5) +#define BTRFS_INODE_IMMUTABLE		(1U << 6) +#define BTRFS_INODE_APPEND		(1U << 7) +#define BTRFS_INODE_NODUMP		(1U << 8) +#define BTRFS_INODE_NOATIME		(1U << 9) +#define BTRFS_INODE_DIRSYNC		(1U << 10) +#define BTRFS_INODE_COMPRESS		(1U << 11) + +#define BTRFS_INODE_ROOT_ITEM_INIT	(1U << 31) + +#define BTRFS_INODE_FLAG_MASK						\ +	(BTRFS_INODE_NODATASUM |					\ +	 BTRFS_INODE_NODATACOW |					\ +	 BTRFS_INODE_READONLY |						\ +	 BTRFS_INODE_NOCOMPRESS |					\ +	 BTRFS_INODE_PREALLOC |						\ +	 BTRFS_INODE_SYNC |						\ +	 BTRFS_INODE_IMMUTABLE |					\ +	 BTRFS_INODE_APPEND |						\ +	 BTRFS_INODE_NODUMP |						\ +	 BTRFS_INODE_NOATIME |						\ +	 BTRFS_INODE_DIRSYNC |						\ +	 BTRFS_INODE_COMPRESS |						\ +	 BTRFS_INODE_ROOT_ITEM_INIT) + +#define BTRFS_INODE_RO_VERITY		(1U << 0) + +#define BTRFS_INODE_RO_FLAG_MASK	(BTRFS_INODE_RO_VERITY)  /*   * The key defines the order in the tree, and so it also defines (optimal) @@ -355,6 +475,109 @@ struct btrfs_key {  	__u64 offset;  } __attribute__ ((__packed__)); +/* + * Every tree block (leaf or node) starts with this header. + */ +struct btrfs_header { +	/* These first four must match the super block */ +	__u8 csum[BTRFS_CSUM_SIZE]; +	/* FS specific uuid */ +	__u8 fsid[BTRFS_FSID_SIZE]; +	/* Which block this node is supposed to live in */ +	__le64 bytenr; +	__le64 flags; + +	/* Allowed to be different from the super from here on down */ +	__u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; +	__le64 generation; +	__le64 owner; +	__le32 nritems; +	__u8 level; +} __attribute__ ((__packed__)); + +/* + * This is a very generous portion of the super block, giving us room to + * translate 14 chunks with 3 stripes each. + */ +#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048 + +/* + * Just in case we somehow lose the roots and are not able to mount, we store + * an array of the roots from previous transactions in the super. + */ +#define BTRFS_NUM_BACKUP_ROOTS 4 +struct btrfs_root_backup { +	__le64 tree_root; +	__le64 tree_root_gen; + +	__le64 chunk_root; +	__le64 chunk_root_gen; + +	__le64 extent_root; +	__le64 extent_root_gen; + +	__le64 fs_root; +	__le64 fs_root_gen; + +	__le64 dev_root; +	__le64 dev_root_gen; + +	__le64 csum_root; +	__le64 csum_root_gen; + +	__le64 total_bytes; +	__le64 bytes_used; +	__le64 num_devices; +	/* future */ +	__le64 unused_64[4]; + +	__u8 tree_root_level; +	__u8 chunk_root_level; +	__u8 extent_root_level; +	__u8 fs_root_level; +	__u8 dev_root_level; +	__u8 csum_root_level; +	/* future and to align */ +	__u8 unused_8[10]; +} __attribute__ ((__packed__)); + +/* + * A leaf is full of items. offset and size tell us where to find the item in + * the leaf (relative to the start of the data area) + */ +struct btrfs_item { +	struct btrfs_disk_key key; +	__le32 offset; +	__le32 size; +} __attribute__ ((__packed__)); + +/* + * Leaves have an item area and a data area: + * [item0, item1....itemN] [free space] [dataN...data1, data0] + * + * The data is separate from the items to get the keys closer together during + * searches. + */ +struct btrfs_leaf { +	struct btrfs_header header; +	struct btrfs_item items[]; +} __attribute__ ((__packed__)); + +/* + * All non-leaf blocks are nodes, they hold only keys and pointers to other + * blocks. + */ +struct btrfs_key_ptr { +	struct btrfs_disk_key key; +	__le64 blockptr; +	__le64 generation; +} __attribute__ ((__packed__)); + +struct btrfs_node { +	struct btrfs_header header; +	struct btrfs_key_ptr ptrs[]; +} __attribute__ ((__packed__)); +  struct btrfs_dev_item {  	/* the internal btrfs device id */  	__le64 devid; @@ -438,6 +661,69 @@ struct btrfs_chunk {  	/* additional stripes go here */  } __attribute__ ((__packed__)); +/* + * The super block basically lists the main trees of the FS. + */ +struct btrfs_super_block { +	/* The first 4 fields must match struct btrfs_header */ +	__u8 csum[BTRFS_CSUM_SIZE]; +	/* FS specific UUID, visible to user */ +	__u8 fsid[BTRFS_FSID_SIZE]; +	/* This block number */ +	__le64 bytenr; +	__le64 flags; + +	/* Allowed to be different from the btrfs_header from here own down */ +	__le64 magic; +	__le64 generation; +	__le64 root; +	__le64 chunk_root; +	__le64 log_root; + +	/* +	 * This member has never been utilized since the very beginning, thus +	 * it's always 0 regardless of kernel version.  We always use +	 * generation + 1 to read log tree root.  So here we mark it deprecated. +	 */ +	__le64 __unused_log_root_transid; +	__le64 total_bytes; +	__le64 bytes_used; +	__le64 root_dir_objectid; +	__le64 num_devices; +	__le32 sectorsize; +	__le32 nodesize; +	__le32 __unused_leafsize; +	__le32 stripesize; +	__le32 sys_chunk_array_size; +	__le64 chunk_root_generation; +	__le64 compat_flags; +	__le64 compat_ro_flags; +	__le64 incompat_flags; +	__le16 csum_type; +	__u8 root_level; +	__u8 chunk_root_level; +	__u8 log_root_level; +	struct btrfs_dev_item dev_item; + +	char label[BTRFS_LABEL_SIZE]; + +	__le64 cache_generation; +	__le64 uuid_tree_generation; + +	/* The UUID written into btree blocks */ +	__u8 metadata_uuid[BTRFS_FSID_SIZE]; + +	__u64 nr_global_roots; + +	/* Future expansion */ +	__le64 reserved[27]; +	__u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE]; +	struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS]; + +	/* Padded to 4096 bytes */ +	__u8 padding[565]; +} __attribute__ ((__packed__)); +  #define BTRFS_FREE_SPACE_EXTENT	1  #define BTRFS_FREE_SPACE_BITMAP	2 @@ -454,6 +740,18 @@ struct btrfs_free_space_header {  	__le64 num_bitmaps;  } __attribute__ ((__packed__)); +struct btrfs_raid_stride { +	/* The id of device this raid extent lives on. */ +	__le64 devid; +	/* The physical location on disk. */ +	__le64 physical; +} __attribute__ ((__packed__)); + +struct btrfs_stripe_extent { +	/* An array of raid strides this stripe is composed of. */ +	__DECLARE_FLEX_ARRAY(struct btrfs_raid_stride, strides); +} __attribute__ ((__packed__)); +  #define BTRFS_HEADER_FLAG_WRITTEN	(1ULL << 0)  #define BTRFS_HEADER_FLAG_RELOC		(1ULL << 1) @@ -467,6 +765,14 @@ struct btrfs_free_space_header {  #define BTRFS_SUPER_FLAG_CHANGING_FSID	(1ULL << 35)  #define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36) +/* + * Those are temporaray flags utilized by btrfs-progs to do offline conversion. + * They are rejected by kernel. + * But still keep them all here to avoid conflicts. + */ +#define BTRFS_SUPER_FLAG_CHANGING_BG_TREE	(1ULL << 38) +#define BTRFS_SUPER_FLAG_CHANGING_DATA_CSUM	(1ULL << 39) +#define BTRFS_SUPER_FLAG_CHANGING_META_CSUM	(1ULL << 40)  /*   * items in the extent btree are used to record the objectid of the @@ -492,6 +798,14 @@ struct btrfs_extent_item_v0 {  /* use full backrefs for extent pointers in the block */  #define BTRFS_BLOCK_FLAG_FULL_BACKREF	(1ULL << 8) +#define BTRFS_BACKREF_REV_MAX		256 +#define BTRFS_BACKREF_REV_SHIFT		56 +#define BTRFS_BACKREF_REV_MASK		(((u64)BTRFS_BACKREF_REV_MAX - 1) << \ +					 BTRFS_BACKREF_REV_SHIFT) + +#define BTRFS_OLD_BACKREF_REV		0 +#define BTRFS_MIXED_BACKREF_REV		1 +  /*   * this flag is only used internally by scrub and may be changed at any time   * it is only declared here to avoid collisions @@ -514,6 +828,10 @@ struct btrfs_shared_data_ref {  	__le32 count;  } __attribute__ ((__packed__)); +struct btrfs_extent_owner_ref { +	__le64 root_id; +} __attribute__ ((__packed__)); +  struct btrfs_extent_inline_ref {  	__u8 type;  	__le64 offset; @@ -541,7 +859,7 @@ struct btrfs_inode_extref {  	__le64 parent_objectid;  	__le64 index;  	__le16 name_len; -	__u8   name[0]; +	__u8   name[];  	/* name goes here */  } __attribute__ ((__packed__)); @@ -645,6 +963,15 @@ struct btrfs_root_item {  } __attribute__ ((__packed__));  /* + * Btrfs root item used to be smaller than current size.  The old format ends + * at where member generation_v2 is. + */ +static inline __u32 btrfs_legacy_root_item_size(void) +{ +	return offsetof(struct btrfs_root_item, generation_v2); +} + +/*   * this is used for both forward and backward root refs   */  struct btrfs_root_ref { @@ -837,19 +1164,6 @@ struct btrfs_dev_replace_item {  #define BTRFS_BLOCK_GROUP_RESERVED	(BTRFS_AVAIL_ALLOC_BIT_SINGLE | \  					 BTRFS_SPACE_INFO_GLOBAL_RSV) -enum btrfs_raid_types { -	BTRFS_RAID_RAID10, -	BTRFS_RAID_RAID1, -	BTRFS_RAID_DUP, -	BTRFS_RAID_RAID0, -	BTRFS_RAID_SINGLE, -	BTRFS_RAID_RAID5, -	BTRFS_RAID_RAID6, -	BTRFS_RAID_RAID1C3, -	BTRFS_RAID_RAID1C4, -	BTRFS_NR_RAID_TYPES -}; -  #define BTRFS_BLOCK_GROUP_TYPE_MASK	(BTRFS_BLOCK_GROUP_DATA |    \  					 BTRFS_BLOCK_GROUP_SYSTEM |  \  					 BTRFS_BLOCK_GROUP_METADATA) @@ -935,6 +1249,18 @@ static inline __u16 btrfs_qgroup_level(__u64 qgroupid)   */  #define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT	(1ULL << 2) +/* + * Whether or not this filesystem is using simple quotas.  Not exactly the + * incompat bit, because we support using simple quotas, disabling it, then + * going back to full qgroup quotas. + */ +#define BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE	(1ULL << 3) + +#define BTRFS_QGROUP_STATUS_FLAGS_MASK	(BTRFS_QGROUP_STATUS_FLAG_ON |		\ +					 BTRFS_QGROUP_STATUS_FLAG_RESCAN |	\ +					 BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | \ +					 BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE) +  #define BTRFS_QGROUP_STATUS_VERSION        1  struct btrfs_qgroup_status_item { @@ -955,6 +1281,15 @@ struct btrfs_qgroup_status_item {  	 * of the scan. It contains a logical address  	 */  	__le64 rescan; + +	/* +	 * The generation when quotas were last enabled. Used by simple quotas to +	 * avoid decrementing when freeing an extent that was written before +	 * enable. +	 * +	 * Set only if flags contain BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE. +	 */ +	__le64 enable_gen;  } __attribute__ ((__packed__));  struct btrfs_qgroup_info_item { @@ -976,4 +1311,16 @@ struct btrfs_qgroup_limit_item {  	__le64 rsv_excl;  } __attribute__ ((__packed__)); +struct btrfs_verity_descriptor_item { +	/* Size of the verity descriptor in bytes */ +	__le64 size; +	/* +	 * When we implement support for fscrypt, we will need to encrypt the +	 * Merkle tree for encrypted verity files. These 128 bits are for the +	 * eventual storage of an fscrypt initialization vector. +	 */ +	__le64 reserved[2]; +	__u8 encryption; +} __attribute__ ((__packed__)); +  #endif /* _BTRFS_CTREE_H_ */ diff --git a/include/uapi/linux/byteorder/big_endian.h b/include/uapi/linux/byteorder/big_endian.h index 2199adc6a6c2..80aa5c41a763 100644 --- a/include/uapi/linux/byteorder/big_endian.h +++ b/include/uapi/linux/byteorder/big_endian.h @@ -9,6 +9,7 @@  #define __BIG_ENDIAN_BITFIELD  #endif +#include <linux/stddef.h>  #include <linux/types.h>  #include <linux/swab.h> diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h index 601c904fd5cd..cd98982e7523 100644 --- a/include/uapi/linux/byteorder/little_endian.h +++ b/include/uapi/linux/byteorder/little_endian.h @@ -9,6 +9,7 @@  #define __LITTLE_ENDIAN_BITFIELD  #endif +#include <linux/stddef.h>  #include <linux/types.h>  #include <linux/swab.h> diff --git a/include/uapi/linux/cachefiles.h b/include/uapi/linux/cachefiles.h new file mode 100644 index 000000000000..78caa73e5343 --- /dev/null +++ b/include/uapi/linux/cachefiles.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _LINUX_CACHEFILES_H +#define _LINUX_CACHEFILES_H + +#include <linux/types.h> +#include <linux/ioctl.h> + +/* + * Fscache ensures that the maximum length of cookie key is 255. The volume key + * is controlled by netfs, and generally no bigger than 255. + */ +#define CACHEFILES_MSG_MAX_SIZE	1024 + +enum cachefiles_opcode { +	CACHEFILES_OP_OPEN, +	CACHEFILES_OP_CLOSE, +	CACHEFILES_OP_READ, +}; + +/* + * Message Header + * + * @msg_id	a unique ID identifying this message + * @opcode	message type, CACHEFILE_OP_* + * @len		message length, including message header and following data + * @object_id	a unique ID identifying a cache file + * @data	message type specific payload + */ +struct cachefiles_msg { +	__u32 msg_id; +	__u32 opcode; +	__u32 len; +	__u32 object_id; +	__u8  data[]; +}; + +/* + * @data contains the volume_key followed directly by the cookie_key. volume_key + * is a NUL-terminated string; @volume_key_size indicates the size of the volume + * key in bytes. cookie_key is binary data, which is netfs specific; + * @cookie_key_size indicates the size of the cookie key in bytes. + * + * @fd identifies an anon_fd referring to the cache file. + */ +struct cachefiles_open { +	__u32 volume_key_size; +	__u32 cookie_key_size; +	__u32 fd; +	__u32 flags; +	__u8  data[]; +}; + +/* + * @off		indicates the starting offset of the requested file range + * @len		indicates the length of the requested file range + */ +struct cachefiles_read { +	__u64 off; +	__u64 len; +}; + +/* + * Reply for READ request + * @arg for this ioctl is the @id field of READ request. + */ +#define CACHEFILES_IOC_READ_COMPLETE	_IOW(0x98, 1, int) + +#endif diff --git a/include/uapi/linux/can.h b/include/uapi/linux/can.h index 6a6d2c7655ff..42abf0679fb4 100644 --- a/include/uapi/linux/can.h +++ b/include/uapi/linux/can.h @@ -48,6 +48,7 @@  #include <linux/types.h>  #include <linux/socket.h> +#include <linux/stddef.h> /* for offsetof */  /* controller area network (CAN) kernel definitions */ @@ -60,6 +61,7 @@  #define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */  #define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */  #define CAN_ERR_MASK 0x1FFFFFFFU /* omit EFF, RTR, ERR flags */ +#define CANXL_PRIO_MASK CAN_SFF_MASK /* 11 bit priority mask */  /*   * Controller Area Network Identifier structure @@ -73,6 +75,7 @@ typedef __u32 canid_t;  #define CAN_SFF_ID_BITS		11  #define CAN_EFF_ID_BITS		29 +#define CANXL_PRIO_BITS		CAN_SFF_ID_BITS  /*   * Controller Area Network Error Message Frame Mask structure @@ -84,37 +87,57 @@ typedef __u32 can_err_mask_t;  /* CAN payload length and DLC definitions according to ISO 11898-1 */  #define CAN_MAX_DLC 8 +#define CAN_MAX_RAW_DLC 15  #define CAN_MAX_DLEN 8  /* CAN FD payload length and DLC definitions according to ISO 11898-7 */  #define CANFD_MAX_DLC 15  #define CANFD_MAX_DLEN 64 +/* + * CAN XL payload length and DLC definitions according to ISO 11898-1 + * CAN XL DLC ranges from 0 .. 2047 => data length from 1 .. 2048 byte + */ +#define CANXL_MIN_DLC 0 +#define CANXL_MAX_DLC 2047 +#define CANXL_MAX_DLC_MASK 0x07FF +#define CANXL_MIN_DLEN 1 +#define CANXL_MAX_DLEN 2048 +  /** - * struct can_frame - basic CAN frame structure - * @can_id:  CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition - * @can_dlc: frame payload length in byte (0 .. 8) aka data length code - *           N.B. the DLC field from ISO 11898-1 Chapter 8.4.2.3 has a 1:1 - *           mapping of the 'data length code' to the real payload length - * @__pad:   padding - * @__res0:  reserved / padding - * @__res1:  reserved / padding - * @data:    CAN frame payload (up to 8 byte) + * struct can_frame - Classical CAN frame structure (aka CAN 2.0B) + * @can_id:   CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition + * @len:      CAN frame payload length in byte (0 .. 8) + * @can_dlc:  deprecated name for CAN frame payload length in byte (0 .. 8) + * @__pad:    padding + * @__res0:   reserved / padding + * @len8_dlc: optional DLC value (9 .. 15) at 8 byte payload length + *            len8_dlc contains values from 9 .. 15 when the payload length is + *            8 bytes but the DLC value (see ISO 11898-1) is greater then 8. + *            CAN_CTRLMODE_CC_LEN8_DLC flag has to be enabled in CAN driver. + * @data:     CAN frame payload (up to 8 byte)   */  struct can_frame {  	canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */ -	__u8    can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */ -	__u8    __pad;   /* padding */ -	__u8    __res0;  /* reserved / padding */ -	__u8    __res1;  /* reserved / padding */ -	__u8    data[CAN_MAX_DLEN] __attribute__((aligned(8))); +	union { +		/* CAN frame payload length in byte (0 .. CAN_MAX_DLEN) +		 * was previously named can_dlc so we need to carry that +		 * name for legacy support +		 */ +		__u8 len; +		__u8 can_dlc; /* deprecated */ +	} __attribute__((packed)); /* disable padding added in some ABIs */ +	__u8 __pad; /* padding */ +	__u8 __res0; /* reserved / padding */ +	__u8 len8_dlc; /* optional DLC for 8 byte payload length (9 .. 15) */ +	__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));  };  /*   * defined bits for canfd_frame.flags   * - * The use of struct canfd_frame implies the Extended Data Length (EDL) bit to - * be set in the CAN frame bitstream on the wire. The EDL bit switch turns + * The use of struct canfd_frame implies the FD Frame (FDF) bit to + * be set in the CAN frame bitstream on the wire. The FDF bit switch turns   * the CAN controllers bitstream processor into the CAN FD mode which creates   * two new options within the CAN FD frame specification:   * @@ -125,9 +148,18 @@ struct can_frame {   * controller only the CANFD_BRS bit is relevant for real CAN controllers when   * building a CAN FD frame for transmission. Setting the CANFD_ESI bit can make   * sense for virtual CAN interfaces to test applications with echoed frames. + * + * The struct can_frame and struct canfd_frame intentionally share the same + * layout to be able to write CAN frame content into a CAN FD frame structure. + * When this is done the former differentiation via CAN_MTU / CANFD_MTU gets + * lost. CANFD_FDF allows programmers to mark CAN FD frames in the case of + * using struct canfd_frame for mixed CAN / CAN FD content (dual use). + * Since the introduction of CAN XL the CANFD_FDF flag is set in all CAN FD + * frame structures provided by the CAN subsystem of the Linux kernel.   */  #define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */  #define CANFD_ESI 0x02 /* error state indicator of the transmitting node */ +#define CANFD_FDF 0x04 /* mark CAN FD for dual use of struct canfd_frame */  /**   * struct canfd_frame - CAN flexible data rate frame structure @@ -147,8 +179,52 @@ struct canfd_frame {  	__u8    data[CANFD_MAX_DLEN] __attribute__((aligned(8)));  }; +/* + * defined bits for canxl_frame.flags + * + * The canxl_frame.flags element contains three bits CANXL_[XLF|SEC|RRS] + * and shares the relative position of the struct can[fd]_frame.len element. + * The CANXL_XLF bit ALWAYS needs to be set to indicate a valid CAN XL frame. + * As a side effect setting this bit intentionally breaks the length checks + * for Classical CAN and CAN FD frames. + * + * Undefined bits in canxl_frame.flags are reserved and shall be set to zero. + */ +#define CANXL_XLF 0x80 /* mandatory CAN XL frame flag (must always be set!) */ +#define CANXL_SEC 0x01 /* Simple Extended Content (security/segmentation) */ +#define CANXL_RRS 0x02 /* Remote Request Substitution */ + +/* the 8-bit VCID is optionally placed in the canxl_frame.prio element */ +#define CANXL_VCID_OFFSET 16 /* bit offset of VCID in prio element */ +#define CANXL_VCID_VAL_MASK 0xFFUL /* VCID is an 8-bit value */ +#define CANXL_VCID_MASK (CANXL_VCID_VAL_MASK << CANXL_VCID_OFFSET) + +/** + * struct canxl_frame - CAN with e'X'tended frame 'L'ength frame structure + * @prio:  11 bit arbitration priority with zero'ed CAN_*_FLAG flags / VCID + * @flags: additional flags for CAN XL + * @sdt:   SDU (service data unit) type + * @len:   frame payload length in byte (CANXL_MIN_DLEN .. CANXL_MAX_DLEN) + * @af:    acceptance field + * @data:  CAN XL frame payload (CANXL_MIN_DLEN .. CANXL_MAX_DLEN byte) + * + * @prio shares the same position as @can_id from struct can[fd]_frame. + */ +struct canxl_frame { +	canid_t prio;  /* 11 bit priority for arbitration / 8 bit VCID */ +	__u8    flags; /* additional flags for CAN XL */ +	__u8    sdt;   /* SDU (service data unit) type */ +	__u16   len;   /* frame payload length in byte */ +	__u32   af;    /* acceptance field */ +	__u8    data[CANXL_MAX_DLEN]; +}; +  #define CAN_MTU		(sizeof(struct can_frame))  #define CANFD_MTU	(sizeof(struct canfd_frame)) +#define CANXL_MTU	(sizeof(struct canxl_frame)) +#define CANXL_HDR_SIZE	(offsetof(struct canxl_frame, data)) +#define CANXL_MIN_MTU	(CANXL_HDR_SIZE + 64) +#define CANXL_MAX_MTU	CANXL_MTU  /* particular protocols of the protocol family PF_CAN */  #define CAN_RAW		1 /* RAW sockets */ @@ -215,6 +291,5 @@ struct can_filter {  };  #define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */ -#define CAN_RAW_FILTER_MAX 512 /* maximum number of can_filter set via setsockopt() */  #endif /* !_UAPI_CAN_H */ diff --git a/include/uapi/linux/can/bcm.h b/include/uapi/linux/can/bcm.h index dd2b925b09ac..f1e45f533a72 100644 --- a/include/uapi/linux/can/bcm.h +++ b/include/uapi/linux/can/bcm.h @@ -71,7 +71,7 @@ struct bcm_msg_head {  	struct bcm_timeval ival1, ival2;  	canid_t can_id;  	__u32 nframes; -	struct can_frame frames[0]; +	struct can_frame frames[];  };  enum { diff --git a/include/uapi/linux/can/error.h b/include/uapi/linux/can/error.h index 34633283de64..acc1ac393d2a 100644 --- a/include/uapi/linux/can/error.h +++ b/include/uapi/linux/can/error.h @@ -57,6 +57,8 @@  #define CAN_ERR_BUSOFF       0x00000040U /* bus off */  #define CAN_ERR_BUSERROR     0x00000080U /* bus error (may flood!) */  #define CAN_ERR_RESTARTED    0x00000100U /* controller restarted */ +#define CAN_ERR_CNT          0x00000200U /* TX error counter / data[6] */ +					 /* RX error counter / data[7] */  /* arbitration lost in bit ... / data[0] */  #define CAN_ERR_LOSTARB_UNSPEC   0x00 /* unspecified */ @@ -120,6 +122,22 @@  #define CAN_ERR_TRX_CANL_SHORT_TO_GND  0x70 /* 0111 0000 */  #define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */ -/* controller specific additional information / data[5..7] */ +/* data[5] is reserved (do not use) */ + +/* TX error counter / data[6] */ +/* RX error counter / data[7] */ + +/* CAN state thresholds + * + * Error counter	Error state + * ----------------------------------- + * 0 -  95		Error-active + * 96 - 127		Error-warning + * 128 - 255		Error-passive + * 256 and greater	Bus-off + */ +#define CAN_ERROR_WARNING_THRESHOLD 96 +#define CAN_ERROR_PASSIVE_THRESHOLD 128 +#define CAN_BUS_OFF_THRESHOLD 256  #endif /* _UAPI_CAN_ERROR_H */ diff --git a/include/uapi/linux/can/gw.h b/include/uapi/linux/can/gw.h index c2190bbe21d8..e4f0957554f3 100644 --- a/include/uapi/linux/can/gw.h +++ b/include/uapi/linux/can/gw.h @@ -98,8 +98,8 @@ enum {  /* CAN frame elements that are affected by curr. 3 CAN frame modifications */  #define CGW_MOD_ID	0x01 -#define CGW_MOD_DLC	0x02		/* contains the data length in bytes */ -#define CGW_MOD_LEN	CGW_MOD_DLC	/* CAN FD length representation */ +#define CGW_MOD_DLC	0x02		/* Classical CAN data length code */ +#define CGW_MOD_LEN	CGW_MOD_DLC	/* CAN FD (plain) data length */  #define CGW_MOD_DATA	0x04  #define CGW_MOD_FLAGS	0x08		/* CAN FD flags */ diff --git a/include/uapi/linux/can/isotp.h b/include/uapi/linux/can/isotp.h new file mode 100644 index 000000000000..bd990917f7c4 --- /dev/null +++ b/include/uapi/linux/can/isotp.h @@ -0,0 +1,183 @@ +/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* + * linux/can/isotp.h + * + * Definitions for ISO 15765-2 CAN transport protocol sockets + * + * Copyright (c) 2020 Volkswagen Group Electronic Research + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *    notice, this list of conditions and the following disclaimer in the + *    documentation and/or other materials provided with the distribution. + * 3. Neither the name of Volkswagen nor the names of its contributors + *    may be used to endorse or promote products derived from this software + *    without specific prior written permission. + * + * Alternatively, provided that this notice is retained in full, this + * software may be distributed under the terms of the GNU General + * Public License ("GPL") version 2, in which case the provisions of the + * GPL apply INSTEAD OF those given above. + * + * The provided data structures and external interfaces from this code + * are not restricted to be used by modules with a GPL compatible license. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + */ + +#ifndef _UAPI_CAN_ISOTP_H +#define _UAPI_CAN_ISOTP_H + +#include <linux/types.h> +#include <linux/can.h> + +#define SOL_CAN_ISOTP (SOL_CAN_BASE + CAN_ISOTP) + +/* for socket options affecting the socket (not the global system) */ + +#define CAN_ISOTP_OPTS		1	/* pass struct can_isotp_options */ + +#define CAN_ISOTP_RECV_FC	2	/* pass struct can_isotp_fc_options */ + +/* sockopts to force stmin timer values for protocol regression tests */ + +#define CAN_ISOTP_TX_STMIN	3	/* pass __u32 value in nano secs    */ +					/* use this time instead of value   */ +					/* provided in FC from the receiver */ + +#define CAN_ISOTP_RX_STMIN	4	/* pass __u32 value in nano secs   */ +					/* ignore received CF frames which */ +					/* timestamps differ less than val */ + +#define CAN_ISOTP_LL_OPTS	5	/* pass struct can_isotp_ll_options */ + +struct can_isotp_options { + +	__u32 flags;		/* set flags for isotp behaviour.	*/ +				/* __u32 value : flags see below	*/ + +	__u32 frame_txtime;	/* frame transmission time (N_As/N_Ar)	*/ +				/* __u32 value : time in nano secs	*/ + +	__u8  ext_address;	/* set address for extended addressing	*/ +				/* __u8 value : extended address	*/ + +	__u8  txpad_content;	/* set content of padding byte (tx)	*/ +				/* __u8 value : content	on tx path	*/ + +	__u8  rxpad_content;	/* set content of padding byte (rx)	*/ +				/* __u8 value : content	on rx path	*/ + +	__u8  rx_ext_address;	/* set address for extended addressing	*/ +				/* __u8 value : extended address (rx)	*/ +}; + +struct can_isotp_fc_options { + +	__u8  bs;		/* blocksize provided in FC frame	*/ +				/* __u8 value : blocksize. 0 = off	*/ + +	__u8  stmin;		/* separation time provided in FC frame	*/ +				/* __u8 value :				*/ +				/* 0x00 - 0x7F : 0 - 127 ms		*/ +				/* 0x80 - 0xF0 : reserved		*/ +				/* 0xF1 - 0xF9 : 100 us - 900 us	*/ +				/* 0xFA - 0xFF : reserved		*/ + +	__u8  wftmax;		/* max. number of wait frame transmiss.	*/ +				/* __u8 value : 0 = omit FC N_PDU WT	*/ +}; + +struct can_isotp_ll_options { + +	__u8  mtu;		/* generated & accepted CAN frame type	*/ +				/* __u8 value :				*/ +				/* CAN_MTU   (16) -> standard CAN 2.0	*/ +				/* CANFD_MTU (72) -> CAN FD frame	*/ + +	__u8  tx_dl;		/* tx link layer data length in bytes	*/ +				/* (configured maximum payload length)	*/ +				/* __u8 value : 8,12,16,20,24,32,48,64	*/ +				/* => rx path supports all LL_DL values */ + +	__u8  tx_flags;		/* set into struct canfd_frame.flags	*/ +				/* at frame creation: e.g. CANFD_BRS	*/ +				/* Obsolete when the BRS flag is fixed	*/ +				/* by the CAN netdriver configuration	*/ +}; + +/* flags for isotp behaviour */ + +#define CAN_ISOTP_LISTEN_MODE	0x0001	/* listen only (do not send FC) */ +#define CAN_ISOTP_EXTEND_ADDR	0x0002	/* enable extended addressing */ +#define CAN_ISOTP_TX_PADDING	0x0004	/* enable CAN frame padding tx path */ +#define CAN_ISOTP_RX_PADDING	0x0008	/* enable CAN frame padding rx path */ +#define CAN_ISOTP_CHK_PAD_LEN	0x0010	/* check received CAN frame padding */ +#define CAN_ISOTP_CHK_PAD_DATA	0x0020	/* check received CAN frame padding */ +#define CAN_ISOTP_HALF_DUPLEX	0x0040	/* half duplex error state handling */ +#define CAN_ISOTP_FORCE_TXSTMIN	0x0080	/* ignore stmin from received FC */ +#define CAN_ISOTP_FORCE_RXSTMIN	0x0100	/* ignore CFs depending on rx stmin */ +#define CAN_ISOTP_RX_EXT_ADDR	0x0200	/* different rx extended addressing */ +#define CAN_ISOTP_WAIT_TX_DONE	0x0400	/* wait for tx completion */ +#define CAN_ISOTP_SF_BROADCAST	0x0800	/* 1-to-N functional addressing */ +#define CAN_ISOTP_CF_BROADCAST	0x1000	/* 1-to-N transmission w/o FC */ +#define CAN_ISOTP_DYN_FC_PARMS	0x2000	/* dynamic FC parameters BS/STmin */ + +/* protocol machine default values */ + +#define CAN_ISOTP_DEFAULT_FLAGS		0 +#define CAN_ISOTP_DEFAULT_EXT_ADDRESS	0x00 +#define CAN_ISOTP_DEFAULT_PAD_CONTENT	0xCC /* prevent bit-stuffing */ +#define CAN_ISOTP_DEFAULT_FRAME_TXTIME	50000 /* 50 micro seconds */ +#define CAN_ISOTP_DEFAULT_RECV_BS	0 +#define CAN_ISOTP_DEFAULT_RECV_STMIN	0x00 +#define CAN_ISOTP_DEFAULT_RECV_WFTMAX	0 + +/* + * Remark on CAN_ISOTP_DEFAULT_RECV_* values: + * + * We can strongly assume, that the Linux Kernel implementation of + * CAN_ISOTP is capable to run with BS=0, STmin=0 and WFTmax=0. + * But as we like to be able to behave as a commonly available ECU, + * these default settings can be changed via sockopts. + * For that reason the STmin value is intentionally _not_ checked for + * consistency and copied directly into the flow control (FC) frame. + */ + +/* link layer default values => make use of Classical CAN frames */ + +#define CAN_ISOTP_DEFAULT_LL_MTU	CAN_MTU +#define CAN_ISOTP_DEFAULT_LL_TX_DL	CAN_MAX_DLEN +#define CAN_ISOTP_DEFAULT_LL_TX_FLAGS	0 + +/* + * The CAN_ISOTP_DEFAULT_FRAME_TXTIME has become a non-zero value as + * it only makes sense for isotp implementation tests to run without + * a N_As value. As user space applications usually do not set the + * frame_txtime element of struct can_isotp_options the new in-kernel + * default is very likely overwritten with zero when the sockopt() + * CAN_ISOTP_OPTS is invoked. + * To make sure that a N_As value of zero is only set intentional the + * value '0' is now interpreted as 'do not change the current value'. + * When a frame_txtime of zero is required for testing purposes this + * CAN_ISOTP_FRAME_TXTIME_ZERO u32 value has to be set in frame_txtime. + */ +#define CAN_ISOTP_FRAME_TXTIME_ZERO	0xFFFFFFFF + +#endif /* !_UAPI_CAN_ISOTP_H */ diff --git a/include/uapi/linux/can/j1939.h b/include/uapi/linux/can/j1939.h index df6e821075c1..38936460f668 100644 --- a/include/uapi/linux/can/j1939.h +++ b/include/uapi/linux/can/j1939.h @@ -78,11 +78,20 @@ enum {  enum {  	J1939_NLA_PAD,  	J1939_NLA_BYTES_ACKED, +	J1939_NLA_TOTAL_SIZE, +	J1939_NLA_PGN, +	J1939_NLA_SRC_NAME, +	J1939_NLA_DEST_NAME, +	J1939_NLA_SRC_ADDR, +	J1939_NLA_DEST_ADDR,  };  enum {  	J1939_EE_INFO_NONE,  	J1939_EE_INFO_TX_ABORT, +	J1939_EE_INFO_RX_RTS, +	J1939_EE_INFO_RX_DPO, +	J1939_EE_INFO_RX_ABORT,  };  struct j1939_filter { diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h index 6f598b73839e..02ec32d69474 100644 --- a/include/uapi/linux/can/netlink.h +++ b/include/uapi/linux/can/netlink.h @@ -100,6 +100,9 @@ struct can_ctrlmode {  #define CAN_CTRLMODE_FD			0x20	/* CAN FD mode */  #define CAN_CTRLMODE_PRESUME_ACK	0x40	/* Ignore missing CAN ACKs */  #define CAN_CTRLMODE_FD_NON_ISO		0x80	/* CAN FD in non-ISO mode */ +#define CAN_CTRLMODE_CC_LEN8_DLC	0x100	/* Classic CAN DLC option */ +#define CAN_CTRLMODE_TDC_AUTO		0x200	/* CAN transiver automatically calculates TDCV */ +#define CAN_CTRLMODE_TDC_MANUAL		0x400	/* TDCV is manually set up by user */  /*   * CAN device statistics @@ -133,10 +136,48 @@ enum {  	IFLA_CAN_BITRATE_CONST,  	IFLA_CAN_DATA_BITRATE_CONST,  	IFLA_CAN_BITRATE_MAX, -	__IFLA_CAN_MAX +	IFLA_CAN_TDC, +	IFLA_CAN_CTRLMODE_EXT, + +	/* add new constants above here */ +	__IFLA_CAN_MAX, +	IFLA_CAN_MAX = __IFLA_CAN_MAX - 1  }; -#define IFLA_CAN_MAX	(__IFLA_CAN_MAX - 1) +/* + * CAN FD Transmitter Delay Compensation (TDC) + * + * Please refer to struct can_tdc_const and can_tdc in + * include/linux/can/bittiming.h for further details. + */ +enum { +	IFLA_CAN_TDC_UNSPEC, +	IFLA_CAN_TDC_TDCV_MIN,	/* u32 */ +	IFLA_CAN_TDC_TDCV_MAX,	/* u32 */ +	IFLA_CAN_TDC_TDCO_MIN,	/* u32 */ +	IFLA_CAN_TDC_TDCO_MAX,	/* u32 */ +	IFLA_CAN_TDC_TDCF_MIN,	/* u32 */ +	IFLA_CAN_TDC_TDCF_MAX,	/* u32 */ +	IFLA_CAN_TDC_TDCV,	/* u32 */ +	IFLA_CAN_TDC_TDCO,	/* u32 */ +	IFLA_CAN_TDC_TDCF,	/* u32 */ + +	/* add new constants above here */ +	__IFLA_CAN_TDC, +	IFLA_CAN_TDC_MAX = __IFLA_CAN_TDC - 1 +}; + +/* + * IFLA_CAN_CTRLMODE_EXT nest: controller mode extended parameters + */ +enum { +	IFLA_CAN_CTRLMODE_UNSPEC, +	IFLA_CAN_CTRLMODE_SUPPORTED,	/* u32 */ + +	/* add new constants above here */ +	__IFLA_CAN_CTRLMODE, +	IFLA_CAN_CTRLMODE_MAX = __IFLA_CAN_CTRLMODE - 1 +};  /* u16 termination range: 1..65535 Ohms */  #define CAN_TERMINATION_DISABLED 0 diff --git a/include/uapi/linux/can/raw.h b/include/uapi/linux/can/raw.h index 6a11d308eb5c..e024d896e278 100644 --- a/include/uapi/linux/can/raw.h +++ b/include/uapi/linux/can/raw.h @@ -49,6 +49,11 @@  #include <linux/can.h>  #define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW) +#define CAN_RAW_FILTER_MAX 512 /* maximum number of can_filter set via setsockopt() */ + +enum { +	SCM_CAN_RAW_ERRQUEUE = 1, +};  /* for socket options affecting the socket (not the global system) */ @@ -59,6 +64,23 @@ enum {  	CAN_RAW_RECV_OWN_MSGS,	/* receive my own msgs (default:off) */  	CAN_RAW_FD_FRAMES,	/* allow CAN FD frames (default:off) */  	CAN_RAW_JOIN_FILTERS,	/* all filters must match to trigger */ +	CAN_RAW_XL_FRAMES,	/* allow CAN XL frames (default:off) */ +	CAN_RAW_XL_VCID_OPTS,	/* CAN XL VCID configuration options */ +}; + +/* configuration for CAN XL virtual CAN identifier (VCID) handling */ +struct can_raw_vcid_options { + +	__u8 flags;		/* flags for vcid (filter) behaviour */ +	__u8 tx_vcid;		/* VCID value set into canxl_frame.prio */ +	__u8 rx_vcid;		/* VCID value for VCID filter */ +	__u8 rx_vcid_mask;	/* VCID mask for VCID filter */ +  }; +/* can_raw_vcid_options.flags for CAN XL virtual CAN identifier handling */ +#define CAN_RAW_XL_VCID_TX_SET		0x01 +#define CAN_RAW_XL_VCID_TX_PASS		0x02 +#define CAN_RAW_XL_VCID_RX_FILTER	0x04 +  #endif /* !_UAPI_CAN_RAW_H */ diff --git a/include/uapi/linux/capability.h b/include/uapi/linux/capability.h index 395dd0df8d08..ea5a0899ecf0 100644 --- a/include/uapi/linux/capability.h +++ b/include/uapi/linux/capability.h @@ -6,9 +6,10 @@   * Alexander Kjeldaas <astor@guardian.no>   * with help from Aleph1, Roland Buresund and Andrew Main.   * - * See here for the libcap library ("POSIX draft" compliance): + * See here for the libcap2 library (compliant with Section 25 of + * the withdrawn POSIX 1003.1e Draft 17):   * - * ftp://www.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.6/ + * https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/   */  #ifndef _UAPI_LINUX_CAPABILITY_H @@ -41,11 +42,12 @@ typedef struct __user_cap_header_struct {  	int pid;  } __user *cap_user_header_t; -typedef struct __user_cap_data_struct { +struct __user_cap_data_struct {          __u32 effective;          __u32 permitted;          __u32 inheritable; -} __user *cap_user_data_t; +}; +typedef struct __user_cap_data_struct __user *cap_user_data_t;  #define VFS_CAP_REVISION_MASK	0xFF000000 @@ -243,7 +245,6 @@ struct vfs_ns_cap_data {  /* Allow examination and configuration of disk quotas */  /* Allow setting the domainname */  /* Allow setting the hostname */ -/* Allow calling bdflush() */  /* Allow mount() and umount(), setting up new smb connection */  /* Allow some autofs root ioctls */  /* Allow nfsservctl */ @@ -275,6 +276,7 @@ struct vfs_ns_cap_data {  /* Allow setting encryption key on loopback filesystem */  /* Allow setting zone reclaim policy */  /* Allow everything under CAP_BPF and CAP_PERFMON for backward compatibility */ +/* Allow setting hardware protection emergency action */  #define CAP_SYS_ADMIN        21 @@ -288,6 +290,8 @@ struct vfs_ns_cap_data {     processes and setting the scheduling algorithm used by another     process. */  /* Allow setting cpu affinity on other processes */ +/* Allow setting realtime ioprio class */ +/* Allow setting ioprio class on other processes */  #define CAP_SYS_NICE         23 @@ -333,7 +337,8 @@ struct vfs_ns_cap_data {  #define CAP_AUDIT_CONTROL    30 -/* Set or remove capabilities on files */ +/* Set or remove capabilities on files. +   Map uid=0 into a child user namespace. */  #define CAP_SETFCAP	     31 @@ -424,7 +429,7 @@ struct vfs_ns_cap_data {   */  #define CAP_TO_INDEX(x)     ((x) >> 5)        /* 1 << 5 == bits in __u32 */ -#define CAP_TO_MASK(x)      (1 << ((x) & 31)) /* mask for indexed __u32 */ +#define CAP_TO_MASK(x)      (1U << ((x) & 31)) /* mask for indexed __u32 */  #endif /* _UAPI_LINUX_CAPABILITY_H */ diff --git a/include/uapi/linux/ccs.h b/include/uapi/linux/ccs.h new file mode 100644 index 000000000000..2896d3bfdb5e --- /dev/null +++ b/include/uapi/linux/ccs.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* Copyright (C) 2020 Intel Corporation */ + +#ifndef __UAPI_CCS_H__ +#define __UAPI_CCS_H__ + +#include <linux/v4l2-controls.h> + +#define V4L2_CID_CCS_ANALOGUE_GAIN_M0		(V4L2_CID_USER_CCS_BASE + 1) +#define V4L2_CID_CCS_ANALOGUE_GAIN_C0		(V4L2_CID_USER_CCS_BASE + 2) +#define V4L2_CID_CCS_ANALOGUE_GAIN_M1		(V4L2_CID_USER_CCS_BASE + 3) +#define V4L2_CID_CCS_ANALOGUE_GAIN_C1		(V4L2_CID_USER_CCS_BASE + 4) +#define V4L2_CID_CCS_ANALOGUE_LINEAR_GAIN	(V4L2_CID_USER_CCS_BASE + 5) +#define V4L2_CID_CCS_ANALOGUE_EXPONENTIAL_GAIN	(V4L2_CID_USER_CCS_BASE + 6) +#define V4L2_CID_CCS_SHADING_CORRECTION		(V4L2_CID_USER_CCS_BASE + 8) +#define V4L2_CID_CCS_LUMINANCE_CORRECTION_LEVEL	(V4L2_CID_USER_CCS_BASE + 9) + +#endif diff --git a/include/uapi/linux/cdrom.h b/include/uapi/linux/cdrom.h index 2817230148fd..011e594e4a0d 100644 --- a/include/uapi/linux/cdrom.h +++ b/include/uapi/linux/cdrom.h @@ -103,7 +103,7 @@  #define CDROMREADALL		0x5318	/* read all 2646 bytes */  /*  - * These ioctls are (now) only in ide-cd.c for controlling  + * These ioctls were only in (now removed) ide-cd.c for controlling   * drive spindown time.  They should be implemented in the   * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,   * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE... @@ -147,6 +147,8 @@  #define CDROM_NEXT_WRITABLE	0x5394	/* get next writable block */  #define CDROM_LAST_WRITTEN	0x5395	/* get last block written on disc */ +#define CDROM_TIMED_MEDIA_CHANGE   0x5396  /* get the timestamp of the last media change */ +  /*******************************************************   * CDROM IOCTL structures   *******************************************************/ @@ -289,8 +291,28 @@ struct cdrom_generic_command  	unsigned char		data_direction;  	int			quiet;  	int			timeout; -	void			__user *reserved[1];	/* unused, actually */ -}; +	union { +		void		__user *reserved[1];	/* unused, actually */ +		void            __user *unused; +	}; +}; + +/* This struct is used by CDROM_TIMED_MEDIA_CHANGE */ +struct cdrom_timed_media_change_info { +	__s64	last_media_change;	/* Timestamp of the last detected media +					 * change in ms. May be set by caller, +					 * updated upon successful return of +					 * ioctl. +					 */ +	__u64	media_flags;		/* Flags returned by ioctl to indicate +					 * media status. +					 */ +}; +#define MEDIA_CHANGED_FLAG	0x1	/* Last detected media change was more +					 * recent than last_media_change set by +					 * caller. +					 */ +/* other bits of media_flags available for future use */  /*   * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336,  diff --git a/include/uapi/linux/cec-funcs.h b/include/uapi/linux/cec-funcs.h index 37590027b604..189ecf0e13cd 100644 --- a/include/uapi/linux/cec-funcs.h +++ b/include/uapi/linux/cec-funcs.h @@ -14,7 +14,7 @@  static inline void cec_msg_active_source(struct cec_msg *msg, __u16 phys_addr)  {  	msg->len = 4; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_ACTIVE_SOURCE;  	msg->msg[2] = phys_addr >> 8;  	msg->msg[3] = phys_addr & 0xff; @@ -59,7 +59,7 @@ static inline void cec_msg_request_active_source(struct cec_msg *msg,  						 int reply)  {  	msg->len = 2; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_REQUEST_ACTIVE_SOURCE;  	msg->reply = reply ? CEC_MSG_ACTIVE_SOURCE : 0;  } @@ -68,7 +68,7 @@ static inline void cec_msg_routing_information(struct cec_msg *msg,  					       __u16 phys_addr)  {  	msg->len = 4; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_ROUTING_INFORMATION;  	msg->msg[2] = phys_addr >> 8;  	msg->msg[3] = phys_addr & 0xff; @@ -86,7 +86,7 @@ static inline void cec_msg_routing_change(struct cec_msg *msg,  					  __u16 new_phys_addr)  {  	msg->len = 6; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_ROUTING_CHANGE;  	msg->msg[2] = orig_phys_addr >> 8;  	msg->msg[3] = orig_phys_addr & 0xff; @@ -106,7 +106,7 @@ static inline void cec_ops_routing_change(const struct cec_msg *msg,  static inline void cec_msg_set_stream_path(struct cec_msg *msg, __u16 phys_addr)  {  	msg->len = 4; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_SET_STREAM_PATH;  	msg->msg[2] = phys_addr >> 8;  	msg->msg[3] = phys_addr & 0xff; @@ -791,7 +791,7 @@ static inline void cec_msg_report_physical_addr(struct cec_msg *msg,  					__u16 phys_addr, __u8 prim_devtype)  {  	msg->len = 5; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_REPORT_PHYSICAL_ADDR;  	msg->msg[2] = phys_addr >> 8;  	msg->msg[3] = phys_addr & 0xff; @@ -817,7 +817,7 @@ static inline void cec_msg_set_menu_language(struct cec_msg *msg,  					     const char *language)  {  	msg->len = 5; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_SET_MENU_LANGUAGE;  	memcpy(msg->msg + 2, language, 3);  } @@ -850,7 +850,7 @@ static inline void cec_msg_report_features(struct cec_msg *msg,  				__u8 rc_profile, __u8 dev_features)  {  	msg->len = 6; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_REPORT_FEATURES;  	msg->msg[2] = cec_version;  	msg->msg[3] = all_device_types; @@ -1092,7 +1092,7 @@ static inline void cec_msg_tuner_step_increment(struct cec_msg *msg)  static inline void cec_msg_device_vendor_id(struct cec_msg *msg, __u32 vendor_id)  {  	msg->len = 5; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_DEVICE_VENDOR_ID;  	msg->msg[2] = vendor_id >> 16;  	msg->msg[3] = (vendor_id >> 8) & 0xff; @@ -1568,6 +1568,20 @@ static inline void cec_ops_request_short_audio_descriptor(const struct cec_msg *  	}  } +static inline void cec_msg_set_audio_volume_level(struct cec_msg *msg, +						  __u8 audio_volume_level) +{ +	msg->len = 3; +	msg->msg[1] = CEC_MSG_SET_AUDIO_VOLUME_LEVEL; +	msg->msg[2] = audio_volume_level; +} + +static inline void cec_ops_set_audio_volume_level(const struct cec_msg *msg, +						  __u8 *audio_volume_level) +{ +	*audio_volume_level = msg->msg[2]; +} +  /* Audio Rate Control Feature */  static inline void cec_msg_set_audio_rate(struct cec_msg *msg, @@ -1641,7 +1655,7 @@ static inline void cec_msg_report_current_latency(struct cec_msg *msg,  						  __u8 audio_out_delay)  {  	msg->len = 6; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_REPORT_CURRENT_LATENCY;  	msg->msg[2] = phys_addr >> 8;  	msg->msg[3] = phys_addr & 0xff; @@ -1665,7 +1679,7 @@ static inline void cec_ops_report_current_latency(const struct cec_msg *msg,  	if (*audio_out_compensated == 3 && msg->len >= 7)  		*audio_out_delay = msg->msg[6];  	else -		*audio_out_delay = 0; +		*audio_out_delay = 1;  }  static inline void cec_msg_request_current_latency(struct cec_msg *msg, @@ -1673,7 +1687,7 @@ static inline void cec_msg_request_current_latency(struct cec_msg *msg,  						   __u16 phys_addr)  {  	msg->len = 4; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_REQUEST_CURRENT_LATENCY;  	msg->msg[2] = phys_addr >> 8;  	msg->msg[3] = phys_addr & 0xff; @@ -1693,7 +1707,7 @@ static inline void cec_msg_cdc_hec_inquire_state(struct cec_msg *msg,  						 __u16 phys_addr2)  {  	msg->len = 9; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_CDC_MESSAGE;  	/* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */  	msg->msg[4] = CEC_MSG_CDC_HEC_INQUIRE_STATE; @@ -1723,7 +1737,7 @@ static inline void cec_msg_cdc_hec_report_state(struct cec_msg *msg,  						__u16 hec_field)  {  	msg->len = has_field ? 10 : 8; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_CDC_MESSAGE;  	/* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */  	msg->msg[4] = CEC_MSG_CDC_HEC_REPORT_STATE; @@ -1768,7 +1782,7 @@ static inline void cec_msg_cdc_hec_set_state(struct cec_msg *msg,  					     __u16 phys_addr5)  {  	msg->len = 10; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_CDC_MESSAGE;  	/* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */  	msg->msg[4] = CEC_MSG_CDC_HEC_INQUIRE_STATE; @@ -1818,7 +1832,7 @@ static inline void cec_msg_cdc_hec_set_state_adjacent(struct cec_msg *msg,  						      __u8 hec_set_state)  {  	msg->len = 8; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_CDC_MESSAGE;  	/* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */  	msg->msg[4] = CEC_MSG_CDC_HEC_SET_STATE_ADJACENT; @@ -1843,7 +1857,7 @@ static inline void cec_msg_cdc_hec_request_deactivation(struct cec_msg *msg,  							__u16 phys_addr3)  {  	msg->len = 11; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_CDC_MESSAGE;  	/* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */  	msg->msg[4] = CEC_MSG_CDC_HEC_REQUEST_DEACTIVATION; @@ -1870,7 +1884,7 @@ static inline void cec_ops_cdc_hec_request_deactivation(const struct cec_msg *ms  static inline void cec_msg_cdc_hec_notify_alive(struct cec_msg *msg)  {  	msg->len = 5; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_CDC_MESSAGE;  	/* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */  	msg->msg[4] = CEC_MSG_CDC_HEC_NOTIFY_ALIVE; @@ -1885,7 +1899,7 @@ static inline void cec_ops_cdc_hec_notify_alive(const struct cec_msg *msg,  static inline void cec_msg_cdc_hec_discover(struct cec_msg *msg)  {  	msg->len = 5; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_CDC_MESSAGE;  	/* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */  	msg->msg[4] = CEC_MSG_CDC_HEC_DISCOVER; @@ -1902,7 +1916,7 @@ static inline void cec_msg_cdc_hpd_set_state(struct cec_msg *msg,  					     __u8 hpd_state)  {  	msg->len = 6; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_CDC_MESSAGE;  	/* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */  	msg->msg[4] = CEC_MSG_CDC_HPD_SET_STATE; @@ -1924,7 +1938,7 @@ static inline void cec_msg_cdc_hpd_report_state(struct cec_msg *msg,  						__u8 hpd_error)  {  	msg->len = 6; -	msg->msg[0] |= 0xf; /* broadcast */ +	msg->msg[0] |= CEC_LOG_ADDR_BROADCAST;  	msg->msg[1] = CEC_MSG_CDC_MESSAGE;  	/* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */  	msg->msg[4] = CEC_MSG_CDC_HPD_REPORT_STATE; diff --git a/include/uapi/linux/cec.h b/include/uapi/linux/cec.h index 7d1a06c52469..b2af1dddd4d7 100644 --- a/include/uapi/linux/cec.h +++ b/include/uapi/linux/cec.h @@ -132,6 +132,8 @@ static inline void cec_msg_init(struct cec_msg *msg,   * Set the msg destination to the orig initiator and the msg initiator to the   * orig destination. Note that msg and orig may be the same pointer, in which   * case the change is done in place. + * + * It also zeroes the reply, timeout and flags fields.   */  static inline void cec_msg_set_reply_to(struct cec_msg *msg,  					struct cec_msg *orig) @@ -139,12 +141,35 @@ static inline void cec_msg_set_reply_to(struct cec_msg *msg,  	/* The destination becomes the initiator and vice versa */  	msg->msg[0] = (cec_msg_destination(orig) << 4) |  		      cec_msg_initiator(orig); -	msg->reply = msg->timeout = 0; +	msg->reply = 0; +	msg->timeout = 0; +	msg->flags = 0; +} + +/** + * cec_msg_recv_is_tx_result - return true if this message contains the + *			       result of an earlier non-blocking transmit + * @msg:	the message structure from CEC_RECEIVE + */ +static inline int cec_msg_recv_is_tx_result(const struct cec_msg *msg) +{ +	return msg->sequence && msg->tx_status && !msg->rx_status; +} + +/** + * cec_msg_recv_is_rx_result - return true if this message contains the + *			       reply of an earlier non-blocking transmit + * @msg:	the message structure from CEC_RECEIVE + */ +static inline int cec_msg_recv_is_rx_result(const struct cec_msg *msg) +{ +	return msg->sequence && !msg->tx_status && msg->rx_status;  }  /* cec_msg flags field */  #define CEC_MSG_FL_REPLY_TO_FOLLOWERS	(1 << 0)  #define CEC_MSG_FL_RAW			(1 << 1) +#define CEC_MSG_FL_REPLY_VENDOR_ID	(1 << 2)  /* cec_msg tx/rx_status field */  #define CEC_TX_STATUS_OK		(1 << 0) @@ -319,6 +344,8 @@ static inline int cec_is_unconfigured(__u16 log_addr_mask)  #define CEC_CAP_MONITOR_PIN	(1 << 7)  /* CEC_ADAP_G_CONNECTOR_INFO is available */  #define CEC_CAP_CONNECTOR_INFO	(1 << 8) +/* CEC_MSG_FL_REPLY_VENDOR_ID is available */ +#define CEC_CAP_REPLY_VENDOR_ID	(1 << 9)  /**   * struct cec_caps - CEC capabilities structure. @@ -396,6 +423,7 @@ struct cec_drm_connector_info {   * associated with the CEC adapter.   * @type: connector type (if any)   * @drm: drm connector info + * @raw: array to pad the union   */  struct cec_connector_info {  	__u32 type; @@ -453,7 +481,7 @@ struct cec_event_lost_msgs {   * struct cec_event - CEC event structure   * @ts: the timestamp of when the event was sent.   * @event: the event. - * array. + * @flags: event flags.   * @state_change: the event payload for CEC_EVENT_STATE_CHANGE.   * @lost_msgs: the event payload for CEC_EVENT_LOST_MSGS.   * @raw: array to pad the union. @@ -641,7 +669,7 @@ struct cec_event {  #define CEC_OP_REC_SEQ_WEDNESDAY			0x08  #define CEC_OP_REC_SEQ_THURSDAY				0x10  #define CEC_OP_REC_SEQ_FRIDAY				0x20 -#define CEC_OP_REC_SEQ_SATERDAY				0x40 +#define CEC_OP_REC_SEQ_SATURDAY				0x40  #define CEC_OP_REC_SEQ_ONCE_ONLY			0x00  #define CEC_MSG_CLEAR_DIGITAL_TIMER			0x99 @@ -747,6 +775,7 @@ struct cec_event {  #define CEC_OP_FEAT_DEV_HAS_SET_AUDIO_RATE		0x08  #define CEC_OP_FEAT_DEV_SINK_HAS_ARC_TX			0x04  #define CEC_OP_FEAT_DEV_SOURCE_HAS_ARC_RX		0x02 +#define CEC_OP_FEAT_DEV_HAS_SET_AUDIO_VOLUME_LEVEL	0x01  #define CEC_MSG_GIVE_FEATURES				0xa5	/* HDMI 2.0 */ @@ -1038,6 +1067,7 @@ struct cec_event {  #define CEC_OP_AUD_FMT_ID_CEA861			0  #define CEC_OP_AUD_FMT_ID_CEA861_CXT			1 +#define CEC_MSG_SET_AUDIO_VOLUME_LEVEL			0x73  /* Audio Rate Control Feature */  #define CEC_MSG_SET_AUDIO_RATE				0x9a diff --git a/include/uapi/linux/cfm_bridge.h b/include/uapi/linux/cfm_bridge.h new file mode 100644 index 000000000000..3c1cbd1db2f5 --- /dev/null +++ b/include/uapi/linux/cfm_bridge.h @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ + +#ifndef _UAPI_LINUX_CFM_BRIDGE_H_ +#define _UAPI_LINUX_CFM_BRIDGE_H_ + +#include <linux/types.h> +#include <linux/if_ether.h> + +#define ETHER_HEADER_LENGTH		(6+6+4+2) +#define CFM_MAID_LENGTH			48 +#define CFM_CCM_PDU_LENGTH		75 +#define CFM_PORT_STATUS_TLV_LENGTH	4 +#define CFM_IF_STATUS_TLV_LENGTH	4 +#define CFM_IF_STATUS_TLV_TYPE		4 +#define CFM_PORT_STATUS_TLV_TYPE	2 +#define CFM_ENDE_TLV_TYPE		0 +#define CFM_CCM_MAX_FRAME_LENGTH	(ETHER_HEADER_LENGTH+\ +					 CFM_CCM_PDU_LENGTH+\ +					 CFM_PORT_STATUS_TLV_LENGTH+\ +					 CFM_IF_STATUS_TLV_LENGTH) +#define CFM_FRAME_PRIO			7 +#define CFM_CCM_TLV_OFFSET		70 +#define CFM_CCM_PDU_MAID_OFFSET		10 +#define CFM_CCM_PDU_MEPID_OFFSET	8 +#define CFM_CCM_PDU_SEQNR_OFFSET	4 +#define CFM_CCM_PDU_TLV_OFFSET		74 +#define CFM_CCM_ITU_RESERVED_SIZE	16 + +struct br_cfm_common_hdr { +	__u8 mdlevel_version; +	__u8 opcode; +	__u8 flags; +	__u8 tlv_offset; +}; + +enum br_cfm_opcodes { +	BR_CFM_OPCODE_CCM = 0x1, +}; + +/* MEP domain */ +enum br_cfm_domain { +	BR_CFM_PORT, +	BR_CFM_VLAN, +}; + +/* MEP direction */ +enum br_cfm_mep_direction { +	BR_CFM_MEP_DIRECTION_DOWN, +	BR_CFM_MEP_DIRECTION_UP, +}; + +/* CCM interval supported. */ +enum br_cfm_ccm_interval { +	BR_CFM_CCM_INTERVAL_NONE, +	BR_CFM_CCM_INTERVAL_3_3_MS, +	BR_CFM_CCM_INTERVAL_10_MS, +	BR_CFM_CCM_INTERVAL_100_MS, +	BR_CFM_CCM_INTERVAL_1_SEC, +	BR_CFM_CCM_INTERVAL_10_SEC, +	BR_CFM_CCM_INTERVAL_1_MIN, +	BR_CFM_CCM_INTERVAL_10_MIN, +}; + +#endif diff --git a/include/uapi/linux/cgroupstats.h b/include/uapi/linux/cgroupstats.h index aa306e4cd6c1..80b2c8594480 100644 --- a/include/uapi/linux/cgroupstats.h +++ b/include/uapi/linux/cgroupstats.h @@ -24,8 +24,6 @@   * basis. This data is shared using taskstats.   *   * Most of these states are derived by looking at the task->state value - * For the nr_io_wait state, a flag in the delay accounting structure - * indicates that the task is waiting on IO   *   * Each member is aligned to a 8 byte boundary.   */ diff --git a/include/uapi/linux/cifs/cifs_mount.h b/include/uapi/linux/cifs/cifs_mount.h index 69829205fdb5..8e87d27b0951 100644 --- a/include/uapi/linux/cifs/cifs_mount.h +++ b/include/uapi/linux/cifs/cifs_mount.h @@ -1,6 +1,5 @@  /* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */  /* - *   include/uapi/linux/cifs/cifs_mount.h   *   *   Author(s): Scott Lovenberg (scott.lovenberg@gmail.com)   * diff --git a/include/uapi/linux/cifs/cifs_netlink.h b/include/uapi/linux/cifs/cifs_netlink.h new file mode 100644 index 000000000000..da3107582f49 --- /dev/null +++ b/include/uapi/linux/cifs/cifs_netlink.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */ +/* + * Netlink routines for CIFS + * + * Copyright (c) 2020 Samuel Cabrero <scabrero@suse.de> + */ + + +#ifndef _UAPILINUX_CIFS_NETLINK_H +#define _UAPILINUX_CIFS_NETLINK_H + +#define CIFS_GENL_NAME			"cifs" +#define CIFS_GENL_VERSION		0x1 + +#define CIFS_GENL_MCGRP_SWN_NAME	"cifs_mcgrp_swn" + +enum cifs_genl_multicast_groups { +	CIFS_GENL_MCGRP_SWN, +}; + +enum cifs_genl_attributes { +	CIFS_GENL_ATTR_UNSPEC, +	CIFS_GENL_ATTR_SWN_REGISTRATION_ID, +	CIFS_GENL_ATTR_SWN_NET_NAME, +	CIFS_GENL_ATTR_SWN_SHARE_NAME, +	CIFS_GENL_ATTR_SWN_IP, +	CIFS_GENL_ATTR_SWN_NET_NAME_NOTIFY, +	CIFS_GENL_ATTR_SWN_SHARE_NAME_NOTIFY, +	CIFS_GENL_ATTR_SWN_IP_NOTIFY, +	CIFS_GENL_ATTR_SWN_KRB_AUTH, +	CIFS_GENL_ATTR_SWN_USER_NAME, +	CIFS_GENL_ATTR_SWN_PASSWORD, +	CIFS_GENL_ATTR_SWN_DOMAIN_NAME, +	CIFS_GENL_ATTR_SWN_NOTIFICATION_TYPE, +	CIFS_GENL_ATTR_SWN_RESOURCE_STATE, +	CIFS_GENL_ATTR_SWN_RESOURCE_NAME, +	__CIFS_GENL_ATTR_MAX, +}; +#define CIFS_GENL_ATTR_MAX (__CIFS_GENL_ATTR_MAX - 1) + +enum cifs_genl_commands { +	CIFS_GENL_CMD_UNSPEC, +	CIFS_GENL_CMD_SWN_REGISTER, +	CIFS_GENL_CMD_SWN_UNREGISTER, +	CIFS_GENL_CMD_SWN_NOTIFY, +	__CIFS_GENL_CMD_MAX +}; +#define CIFS_GENL_CMD_MAX (__CIFS_GENL_CMD_MAX - 1) + +enum cifs_swn_notification_type { +	CIFS_SWN_NOTIFICATION_RESOURCE_CHANGE = 0x01, +	CIFS_SWN_NOTIFICATION_CLIENT_MOVE	 = 0x02, +	CIFS_SWN_NOTIFICATION_SHARE_MOVE	 = 0x03, +	CIFS_SWN_NOTIFICATION_IP_CHANGE	 = 0x04, +}; + +enum cifs_swn_resource_state { +	CIFS_SWN_RESOURCE_STATE_UNKNOWN     = 0x00, +	CIFS_SWN_RESOURCE_STATE_AVAILABLE   = 0x01, +	CIFS_SWN_RESOURCE_STATE_UNAVAILABLE = 0xFF +}; + +#endif /* _UAPILINUX_CIFS_NETLINK_H */ diff --git a/include/uapi/linux/close_range.h b/include/uapi/linux/close_range.h index 6928a9fdee3c..2d804281554c 100644 --- a/include/uapi/linux/close_range.h +++ b/include/uapi/linux/close_range.h @@ -5,5 +5,8 @@  /* Unshare the file descriptor table before closing file descriptors. */  #define CLOSE_RANGE_UNSHARE	(1U << 1) +/* Set the FD_CLOEXEC bit instead of closing the file descriptor. */ +#define CLOSE_RANGE_CLOEXEC	(1U << 2) +  #endif /* _UAPI_LINUX_CLOSE_RANGE_H */ diff --git a/include/uapi/linux/cm4000_cs.h b/include/uapi/linux/cm4000_cs.h deleted file mode 100644 index c70a62ec8a49..000000000000 --- a/include/uapi/linux/cm4000_cs.h +++ /dev/null @@ -1,64 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _UAPI_CM4000_H_ -#define _UAPI_CM4000_H_ - -#include <linux/types.h> -#include <linux/ioctl.h> - -#define	MAX_ATR			33 - -#define	CM4000_MAX_DEV		4 - -/* those two structures are passed via ioctl() from/to userspace.  They are - * used by existing userspace programs, so I kepth the awkward "bIFSD" naming - * not to break compilation of userspace apps. -HW */ - -typedef struct atreq { -	__s32 atr_len; -	unsigned char atr[64]; -	__s32 power_act; -	unsigned char bIFSD; -	unsigned char bIFSC; -} atreq_t; - - -/* what is particularly stupid in the original driver is the arch-dependent - * member sizes. This leads to CONFIG_COMPAT breakage, since 32bit userspace - * will lay out the structure members differently than the 64bit kernel. - * - * I've changed "ptsreq.protocol" from "unsigned long" to "__u32". - * On 32bit this will make no difference.  With 64bit kernels, it will make - * 32bit apps work, too. - */ - -typedef struct ptsreq { -	__u32 protocol; /*T=0: 2^0, T=1:  2^1*/ - 	unsigned char flags; - 	unsigned char pts1; - 	unsigned char pts2; -	unsigned char pts3; -} ptsreq_t; - -#define	CM_IOC_MAGIC		'c' -#define	CM_IOC_MAXNR	        255 - -#define	CM_IOCGSTATUS		_IOR (CM_IOC_MAGIC, 0, unsigned char *) -#define	CM_IOCGATR		_IOWR(CM_IOC_MAGIC, 1, atreq_t *) -#define	CM_IOCSPTS		_IOW (CM_IOC_MAGIC, 2, ptsreq_t *) -#define	CM_IOCSRDR		_IO  (CM_IOC_MAGIC, 3) -#define CM_IOCARDOFF            _IO  (CM_IOC_MAGIC, 4) - -#define CM_IOSDBGLVL            _IOW(CM_IOC_MAGIC, 250, int*) - -/* card and device states */ -#define	CM_CARD_INSERTED		0x01 -#define	CM_CARD_POWERED			0x02 -#define	CM_ATR_PRESENT			0x04 -#define	CM_ATR_VALID	 		0x08 -#define	CM_STATE_VALID			0x0f -/* extra info only from CM4000 */ -#define	CM_NO_READER			0x10 -#define	CM_BAD_CARD			0x20 - - -#endif /* _UAPI_CM4000_H_ */ diff --git a/include/uapi/linux/cn_proc.h b/include/uapi/linux/cn_proc.h index db210625cee8..18e3745b86cd 100644 --- a/include/uapi/linux/cn_proc.h +++ b/include/uapi/linux/cn_proc.h @@ -30,6 +30,48 @@ enum proc_cn_mcast_op {  	PROC_CN_MCAST_IGNORE = 2  }; +#define PROC_EVENT_ALL (PROC_EVENT_FORK | PROC_EVENT_EXEC | PROC_EVENT_UID |  \ +			PROC_EVENT_GID | PROC_EVENT_SID | PROC_EVENT_PTRACE | \ +			PROC_EVENT_COMM | PROC_EVENT_NONZERO_EXIT |           \ +			PROC_EVENT_COREDUMP | PROC_EVENT_EXIT) + +/* + * If you add an entry in proc_cn_event, make sure you add it in + * PROC_EVENT_ALL above as well. + */ +enum proc_cn_event { +	/* Use successive bits so the enums can be used to record +	 * sets of events as well +	 */ +	PROC_EVENT_NONE = 0x00000000, +	PROC_EVENT_FORK = 0x00000001, +	PROC_EVENT_EXEC = 0x00000002, +	PROC_EVENT_UID  = 0x00000004, +	PROC_EVENT_GID  = 0x00000040, +	PROC_EVENT_SID  = 0x00000080, +	PROC_EVENT_PTRACE = 0x00000100, +	PROC_EVENT_COMM = 0x00000200, +	/* "next" should be 0x00000400 */ +	/* "last" is the last process event: exit, +	 * while "next to last" is coredumping event +	 * before that is report only if process dies +	 * with non-zero exit status +	 */ +	PROC_EVENT_NONZERO_EXIT = 0x20000000, +	PROC_EVENT_COREDUMP = 0x40000000, +	PROC_EVENT_EXIT = 0x80000000 +}; + +struct proc_input { +	enum proc_cn_mcast_op mcast_op; +	enum proc_cn_event event_type; +}; + +static inline enum proc_cn_event valid_event(enum proc_cn_event ev_type) +{ +	return (enum proc_cn_event)(ev_type & PROC_EVENT_ALL); +} +  /*   * From the user's point of view, the process   * ID is the thread group ID and thread ID is the internal @@ -44,24 +86,7 @@ enum proc_cn_mcast_op {   */  struct proc_event { -	enum what { -		/* Use successive bits so the enums can be used to record -		 * sets of events as well -		 */ -		PROC_EVENT_NONE = 0x00000000, -		PROC_EVENT_FORK = 0x00000001, -		PROC_EVENT_EXEC = 0x00000002, -		PROC_EVENT_UID  = 0x00000004, -		PROC_EVENT_GID  = 0x00000040, -		PROC_EVENT_SID  = 0x00000080, -		PROC_EVENT_PTRACE = 0x00000100, -		PROC_EVENT_COMM = 0x00000200, -		/* "next" should be 0x00000400 */ -		/* "last" is the last process event: exit, -		 * while "next to last" is coredumping event */ -		PROC_EVENT_COREDUMP = 0x40000000, -		PROC_EVENT_EXIT = 0x80000000 -	} what; +	enum proc_cn_event what;  	__u32 cpu;  	__u64 __attribute__((aligned(8))) timestamp_ns;  		/* Number of nano seconds since system boot */ diff --git a/include/uapi/linux/comedi.h b/include/uapi/linux/comedi.h new file mode 100644 index 000000000000..7314e5ee0a1e --- /dev/null +++ b/include/uapi/linux/comedi.h @@ -0,0 +1,1528 @@ +/* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */ +/* + * comedi.h + * header file for COMEDI user API + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1998-2001 David A. Schleef <ds@schleef.org> + */ + +#ifndef _COMEDI_H +#define _COMEDI_H + +#define COMEDI_MAJORVERSION	0 +#define COMEDI_MINORVERSION	7 +#define COMEDI_MICROVERSION	76 +#define VERSION	"0.7.76" + +/* comedi's major device number */ +#define COMEDI_MAJOR 98 + +/* + * maximum number of minor devices.  This can be increased, although + * kernel structures are currently statically allocated, thus you + * don't want this to be much more than you actually use. + */ +#define COMEDI_NDEVICES 16 + +/* number of config options in the config structure */ +#define COMEDI_NDEVCONFOPTS 32 + +/* + * NOTE: 'comedi_config --init-data' is deprecated + * + * The following indexes in the config options were used by + * comedi_config to pass firmware blobs from user space to the + * comedi drivers. The request_firmware() hotplug interface is + * now used by all comedi drivers instead. + */ + +/* length of nth chunk of firmware data -*/ +#define COMEDI_DEVCONF_AUX_DATA3_LENGTH		25 +#define COMEDI_DEVCONF_AUX_DATA2_LENGTH		26 +#define COMEDI_DEVCONF_AUX_DATA1_LENGTH		27 +#define COMEDI_DEVCONF_AUX_DATA0_LENGTH		28 +/* most significant 32 bits of pointer address (if needed) */ +#define COMEDI_DEVCONF_AUX_DATA_HI		29 +/* least significant 32 bits of pointer address */ +#define COMEDI_DEVCONF_AUX_DATA_LO		30 +#define COMEDI_DEVCONF_AUX_DATA_LENGTH		31	/* total data length */ + +/* max length of device and driver names */ +#define COMEDI_NAMELEN 20 + +/* packs and unpacks a channel/range number */ + +#define CR_PACK(chan, rng, aref)					\ +	((((aref) & 0x3) << 24) | (((rng) & 0xff) << 16) | (chan)) +#define CR_PACK_FLAGS(chan, range, aref, flags)				\ +	(CR_PACK(chan, range, aref) | ((flags) & CR_FLAGS_MASK)) + +#define CR_CHAN(a)	((a) & 0xffff) +#define CR_RANGE(a)	(((a) >> 16) & 0xff) +#define CR_AREF(a)	(((a) >> 24) & 0x03) + +#define CR_FLAGS_MASK	0xfc000000 +#define CR_ALT_FILTER	0x04000000 +#define CR_DITHER	CR_ALT_FILTER +#define CR_DEGLITCH	CR_ALT_FILTER +#define CR_ALT_SOURCE	0x08000000 +#define CR_EDGE		0x40000000 +#define CR_INVERT	0x80000000 + +#define AREF_GROUND	0x00	/* analog ref = analog ground */ +#define AREF_COMMON	0x01	/* analog ref = analog common */ +#define AREF_DIFF	0x02	/* analog ref = differential */ +#define AREF_OTHER	0x03	/* analog ref = other (undefined) */ + +/* counters -- these are arbitrary values */ +#define GPCT_RESET		0x0001 +#define GPCT_SET_SOURCE		0x0002 +#define GPCT_SET_GATE		0x0004 +#define GPCT_SET_DIRECTION	0x0008 +#define GPCT_SET_OPERATION	0x0010 +#define GPCT_ARM		0x0020 +#define GPCT_DISARM		0x0040 +#define GPCT_GET_INT_CLK_FRQ	0x0080 + +#define GPCT_INT_CLOCK		0x0001 +#define GPCT_EXT_PIN		0x0002 +#define GPCT_NO_GATE		0x0004 +#define GPCT_UP			0x0008 +#define GPCT_DOWN		0x0010 +#define GPCT_HWUD		0x0020 +#define GPCT_SIMPLE_EVENT	0x0040 +#define GPCT_SINGLE_PERIOD	0x0080 +#define GPCT_SINGLE_PW		0x0100 +#define GPCT_CONT_PULSE_OUT	0x0200 +#define GPCT_SINGLE_PULSE_OUT	0x0400 + +/* instructions */ + +#define INSN_MASK_WRITE		0x8000000 +#define INSN_MASK_READ		0x4000000 +#define INSN_MASK_SPECIAL	0x2000000 + +#define INSN_READ		(0 | INSN_MASK_READ) +#define INSN_WRITE		(1 | INSN_MASK_WRITE) +#define INSN_BITS		(2 | INSN_MASK_READ | INSN_MASK_WRITE) +#define INSN_CONFIG		(3 | INSN_MASK_READ | INSN_MASK_WRITE) +#define INSN_DEVICE_CONFIG	(INSN_CONFIG | INSN_MASK_SPECIAL) +#define INSN_GTOD		(4 | INSN_MASK_READ | INSN_MASK_SPECIAL) +#define INSN_WAIT		(5 | INSN_MASK_WRITE | INSN_MASK_SPECIAL) +#define INSN_INTTRIG		(6 | INSN_MASK_WRITE | INSN_MASK_SPECIAL) + +/* command flags */ +/* These flags are used in comedi_cmd structures */ + +#define CMDF_BOGUS		0x00000001	/* do the motions */ + +/* try to use a real-time interrupt while performing command */ +#define CMDF_PRIORITY		0x00000008 + +/* wake up on end-of-scan events */ +#define CMDF_WAKE_EOS		0x00000020 + +#define CMDF_WRITE		0x00000040 + +#define CMDF_RAWDATA		0x00000080 + +/* timer rounding definitions */ +#define CMDF_ROUND_MASK		0x00030000 +#define CMDF_ROUND_NEAREST	0x00000000 +#define CMDF_ROUND_DOWN		0x00010000 +#define CMDF_ROUND_UP		0x00020000 +#define CMDF_ROUND_UP_NEXT	0x00030000 + +#define COMEDI_EV_START		0x00040000 +#define COMEDI_EV_SCAN_BEGIN	0x00080000 +#define COMEDI_EV_CONVERT	0x00100000 +#define COMEDI_EV_SCAN_END	0x00200000 +#define COMEDI_EV_STOP		0x00400000 + +/* compatibility definitions */ +#define TRIG_BOGUS		CMDF_BOGUS +#define TRIG_RT			CMDF_PRIORITY +#define TRIG_WAKE_EOS		CMDF_WAKE_EOS +#define TRIG_WRITE		CMDF_WRITE +#define TRIG_ROUND_MASK		CMDF_ROUND_MASK +#define TRIG_ROUND_NEAREST	CMDF_ROUND_NEAREST +#define TRIG_ROUND_DOWN		CMDF_ROUND_DOWN +#define TRIG_ROUND_UP		CMDF_ROUND_UP +#define TRIG_ROUND_UP_NEXT	CMDF_ROUND_UP_NEXT + +/* trigger sources */ + +#define TRIG_ANY	0xffffffff +#define TRIG_INVALID	0x00000000 + +#define TRIG_NONE	0x00000001 /* never trigger */ +#define TRIG_NOW	0x00000002 /* trigger now + N ns */ +#define TRIG_FOLLOW	0x00000004 /* trigger on next lower level trig */ +#define TRIG_TIME	0x00000008 /* trigger at time N ns */ +#define TRIG_TIMER	0x00000010 /* trigger at rate N ns */ +#define TRIG_COUNT	0x00000020 /* trigger when count reaches N */ +#define TRIG_EXT	0x00000040 /* trigger on external signal N */ +#define TRIG_INT	0x00000080 /* trigger on comedi-internal signal N */ +#define TRIG_OTHER	0x00000100 /* driver defined */ + +/* subdevice flags */ + +#define SDF_BUSY	0x0001	/* device is busy */ +#define SDF_BUSY_OWNER	0x0002	/* device is busy with your job */ +#define SDF_LOCKED	0x0004	/* subdevice is locked */ +#define SDF_LOCK_OWNER	0x0008	/* you own lock */ +#define SDF_MAXDATA	0x0010	/* maxdata depends on channel */ +#define SDF_FLAGS	0x0020	/* flags depend on channel */ +#define SDF_RANGETYPE	0x0040	/* range type depends on channel */ +#define SDF_PWM_COUNTER 0x0080	/* PWM can automatically switch off */ +#define SDF_PWM_HBRIDGE 0x0100	/* PWM is signed (H-bridge) */ +#define SDF_CMD		0x1000	/* can do commands (deprecated) */ +#define SDF_SOFT_CALIBRATED	0x2000 /* subdevice uses software calibration */ +#define SDF_CMD_WRITE		0x4000 /* can do output commands */ +#define SDF_CMD_READ		0x8000 /* can do input commands */ + +/* subdevice can be read (e.g. analog input) */ +#define SDF_READABLE	0x00010000 +/* subdevice can be written (e.g. analog output) */ +#define SDF_WRITABLE	0x00020000 +#define SDF_WRITEABLE	SDF_WRITABLE	/* spelling error in API */ +/* subdevice does not have externally visible lines */ +#define SDF_INTERNAL	0x00040000 +#define SDF_GROUND	0x00100000	/* can do aref=ground */ +#define SDF_COMMON	0x00200000	/* can do aref=common */ +#define SDF_DIFF	0x00400000	/* can do aref=diff */ +#define SDF_OTHER	0x00800000	/* can do aref=other */ +#define SDF_DITHER	0x01000000	/* can do dithering */ +#define SDF_DEGLITCH	0x02000000	/* can do deglitching */ +#define SDF_MMAP	0x04000000	/* can do mmap() */ +#define SDF_RUNNING	0x08000000	/* subdevice is acquiring data */ +#define SDF_LSAMPL	0x10000000	/* subdevice uses 32-bit samples */ +#define SDF_PACKED	0x20000000	/* subdevice can do packed DIO */ + +/* subdevice types */ + +/** + * enum comedi_subdevice_type - COMEDI subdevice types + * @COMEDI_SUBD_UNUSED:		Unused subdevice. + * @COMEDI_SUBD_AI:		Analog input. + * @COMEDI_SUBD_AO:		Analog output. + * @COMEDI_SUBD_DI:		Digital input. + * @COMEDI_SUBD_DO:		Digital output. + * @COMEDI_SUBD_DIO:		Digital input/output. + * @COMEDI_SUBD_COUNTER:	Counter. + * @COMEDI_SUBD_TIMER:		Timer. + * @COMEDI_SUBD_MEMORY:		Memory, EEPROM, DPRAM. + * @COMEDI_SUBD_CALIB:		Calibration DACs. + * @COMEDI_SUBD_PROC:		Processor, DSP. + * @COMEDI_SUBD_SERIAL:		Serial I/O. + * @COMEDI_SUBD_PWM:		Pulse-Width Modulation output. + */ +enum comedi_subdevice_type { +	COMEDI_SUBD_UNUSED, +	COMEDI_SUBD_AI, +	COMEDI_SUBD_AO, +	COMEDI_SUBD_DI, +	COMEDI_SUBD_DO, +	COMEDI_SUBD_DIO, +	COMEDI_SUBD_COUNTER, +	COMEDI_SUBD_TIMER, +	COMEDI_SUBD_MEMORY, +	COMEDI_SUBD_CALIB, +	COMEDI_SUBD_PROC, +	COMEDI_SUBD_SERIAL, +	COMEDI_SUBD_PWM +}; + +/* configuration instructions */ + +/** + * enum comedi_io_direction - COMEDI I/O directions + * @COMEDI_INPUT:	Input. + * @COMEDI_OUTPUT:	Output. + * @COMEDI_OPENDRAIN:	Open-drain (or open-collector) output. + * + * These are used by the %INSN_CONFIG_DIO_QUERY configuration instruction to + * report a direction.  They may also be used in other places where a direction + * needs to be specified. + */ +enum comedi_io_direction { +	COMEDI_INPUT = 0, +	COMEDI_OUTPUT = 1, +	COMEDI_OPENDRAIN = 2 +}; + +/** + * enum configuration_ids - COMEDI configuration instruction codes + * @INSN_CONFIG_DIO_INPUT:	Configure digital I/O as input. + * @INSN_CONFIG_DIO_OUTPUT:	Configure digital I/O as output. + * @INSN_CONFIG_DIO_OPENDRAIN:	Configure digital I/O as open-drain (or open + *				collector) output. + * @INSN_CONFIG_ANALOG_TRIG:	Configure analog trigger. + * @INSN_CONFIG_ALT_SOURCE:	Configure alternate input source. + * @INSN_CONFIG_DIGITAL_TRIG:	Configure digital trigger. + * @INSN_CONFIG_BLOCK_SIZE:	Configure block size for DMA transfers. + * @INSN_CONFIG_TIMER_1:	Configure divisor for external clock. + * @INSN_CONFIG_FILTER:		Configure a filter. + * @INSN_CONFIG_CHANGE_NOTIFY:	Configure change notification for digital + *				inputs.  (New drivers should use + *				%INSN_CONFIG_DIGITAL_TRIG instead.) + * @INSN_CONFIG_SERIAL_CLOCK:	Configure clock for serial I/O. + * @INSN_CONFIG_BIDIRECTIONAL_DATA: Send and receive byte over serial I/O. + * @INSN_CONFIG_DIO_QUERY:	Query direction of digital I/O channel. + * @INSN_CONFIG_PWM_OUTPUT:	Configure pulse-width modulator output. + * @INSN_CONFIG_GET_PWM_OUTPUT:	Get pulse-width modulator output configuration. + * @INSN_CONFIG_ARM:		Arm a subdevice or channel. + * @INSN_CONFIG_DISARM:		Disarm a subdevice or channel. + * @INSN_CONFIG_GET_COUNTER_STATUS: Get counter status. + * @INSN_CONFIG_RESET:		Reset a subdevice or channel. + * @INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR: Configure counter/timer as + *				single pulse generator. + * @INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR: Configure counter/timer as + *				pulse train generator. + * @INSN_CONFIG_GPCT_QUADRATURE_ENCODER: Configure counter as a quadrature + *				encoder. + * @INSN_CONFIG_SET_GATE_SRC:	Set counter/timer gate source. + * @INSN_CONFIG_GET_GATE_SRC:	Get counter/timer gate source. + * @INSN_CONFIG_SET_CLOCK_SRC:	Set counter/timer master clock source. + * @INSN_CONFIG_GET_CLOCK_SRC:	Get counter/timer master clock source. + * @INSN_CONFIG_SET_OTHER_SRC:	Set counter/timer "other" source. + * @INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE: Get size (in bytes) of subdevice's + *				on-board FIFOs used during streaming + *				input/output. + * @INSN_CONFIG_SET_COUNTER_MODE: Set counter/timer mode. + * @INSN_CONFIG_8254_SET_MODE:	(Deprecated) Same as + *				%INSN_CONFIG_SET_COUNTER_MODE. + * @INSN_CONFIG_8254_READ_STATUS: Read status of 8254 counter channel. + * @INSN_CONFIG_SET_ROUTING:	Set routing for a channel. + * @INSN_CONFIG_GET_ROUTING:	Get routing for a channel. + * @INSN_CONFIG_PWM_SET_PERIOD: Set PWM period in nanoseconds. + * @INSN_CONFIG_PWM_GET_PERIOD: Get PWM period in nanoseconds. + * @INSN_CONFIG_GET_PWM_STATUS: Get PWM status. + * @INSN_CONFIG_PWM_SET_H_BRIDGE: Set PWM H bridge duty cycle and polarity for + *				a relay simultaneously. + * @INSN_CONFIG_PWM_GET_H_BRIDGE: Get PWM H bridge duty cycle and polarity. + * @INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS: Get the hardware timing restraints, + *				regardless of trigger sources. + */ +enum configuration_ids { +	INSN_CONFIG_DIO_INPUT = COMEDI_INPUT, +	INSN_CONFIG_DIO_OUTPUT = COMEDI_OUTPUT, +	INSN_CONFIG_DIO_OPENDRAIN = COMEDI_OPENDRAIN, +	INSN_CONFIG_ANALOG_TRIG = 16, +/*	INSN_CONFIG_WAVEFORM = 17, */ +/*	INSN_CONFIG_TRIG = 18, */ +/*	INSN_CONFIG_COUNTER = 19, */ +	INSN_CONFIG_ALT_SOURCE = 20, +	INSN_CONFIG_DIGITAL_TRIG = 21, +	INSN_CONFIG_BLOCK_SIZE = 22, +	INSN_CONFIG_TIMER_1 = 23, +	INSN_CONFIG_FILTER = 24, +	INSN_CONFIG_CHANGE_NOTIFY = 25, + +	INSN_CONFIG_SERIAL_CLOCK = 26,	/*ALPHA*/ +	INSN_CONFIG_BIDIRECTIONAL_DATA = 27, +	INSN_CONFIG_DIO_QUERY = 28, +	INSN_CONFIG_PWM_OUTPUT = 29, +	INSN_CONFIG_GET_PWM_OUTPUT = 30, +	INSN_CONFIG_ARM = 31, +	INSN_CONFIG_DISARM = 32, +	INSN_CONFIG_GET_COUNTER_STATUS = 33, +	INSN_CONFIG_RESET = 34, +	INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001, +	INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002, +	INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003, +	INSN_CONFIG_SET_GATE_SRC = 2001, +	INSN_CONFIG_GET_GATE_SRC = 2002, +	INSN_CONFIG_SET_CLOCK_SRC = 2003, +	INSN_CONFIG_GET_CLOCK_SRC = 2004, +	INSN_CONFIG_SET_OTHER_SRC = 2005, +	INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006, +	INSN_CONFIG_SET_COUNTER_MODE = 4097, +	INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE, +	INSN_CONFIG_8254_READ_STATUS = 4098, +	INSN_CONFIG_SET_ROUTING = 4099, +	INSN_CONFIG_GET_ROUTING = 4109, +	INSN_CONFIG_PWM_SET_PERIOD = 5000, +	INSN_CONFIG_PWM_GET_PERIOD = 5001, +	INSN_CONFIG_GET_PWM_STATUS = 5002, +	INSN_CONFIG_PWM_SET_H_BRIDGE = 5003, +	INSN_CONFIG_PWM_GET_H_BRIDGE = 5004, +	INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS = 5005, +}; + +/** + * enum device_configuration_ids - COMEDI configuration instruction codes global + * to an entire device. + * @INSN_DEVICE_CONFIG_TEST_ROUTE:	Validate the possibility of a + *					globally-named route + * @INSN_DEVICE_CONFIG_CONNECT_ROUTE:	Connect a globally-named route + * @INSN_DEVICE_CONFIG_DISCONNECT_ROUTE:Disconnect a globally-named route + * @INSN_DEVICE_CONFIG_GET_ROUTES:	Get a list of all globally-named routes + *					that are valid for a particular device. + */ +enum device_config_route_ids { +	INSN_DEVICE_CONFIG_TEST_ROUTE = 0, +	INSN_DEVICE_CONFIG_CONNECT_ROUTE = 1, +	INSN_DEVICE_CONFIG_DISCONNECT_ROUTE = 2, +	INSN_DEVICE_CONFIG_GET_ROUTES = 3, +}; + +/** + * enum comedi_digital_trig_op - operations for configuring a digital trigger + * @COMEDI_DIGITAL_TRIG_DISABLE:	Return digital trigger to its default, + *					inactive, unconfigured state. + * @COMEDI_DIGITAL_TRIG_ENABLE_EDGES:	Set rising and/or falling edge inputs + *					that each can fire the trigger. + * @COMEDI_DIGITAL_TRIG_ENABLE_LEVELS:	Set a combination of high and/or low + *					level inputs that can fire the trigger. + * + * These are used with the %INSN_CONFIG_DIGITAL_TRIG configuration instruction. + * The data for the configuration instruction is as follows... + * + *   data[%0] = %INSN_CONFIG_DIGITAL_TRIG + * + *   data[%1] = trigger ID + * + *   data[%2] = configuration operation + * + *   data[%3] = configuration parameter 1 + * + *   data[%4] = configuration parameter 2 + * + *   data[%5] = configuration parameter 3 + * + * The trigger ID (data[%1]) is used to differentiate multiple digital triggers + * belonging to the same subdevice.  The configuration operation (data[%2]) is + * one of the enum comedi_digital_trig_op values.  The configuration + * parameters (data[%3], data[%4], and data[%5]) depend on the operation; they + * are not used with %COMEDI_DIGITAL_TRIG_DISABLE. + * + * For %COMEDI_DIGITAL_TRIG_ENABLE_EDGES and %COMEDI_DIGITAL_TRIG_ENABLE_LEVELS, + * configuration parameter 1 (data[%3]) contains a "left-shift" value that + * specifies the input corresponding to bit 0 of configuration parameters 2 + * and 3.  This is useful if the trigger has more than 32 inputs. + * + * For %COMEDI_DIGITAL_TRIG_ENABLE_EDGES, configuration parameter 2 (data[%4]) + * specifies which of up to 32 inputs have rising-edge sensitivity, and + * configuration parameter 3 (data[%5]) specifies which of up to 32 inputs + * have falling-edge sensitivity that can fire the trigger. + * + * For %COMEDI_DIGITAL_TRIG_ENABLE_LEVELS, configuration parameter 2 (data[%4]) + * specifies which of up to 32 inputs must be at a high level, and + * configuration parameter 3 (data[%5]) specifies which of up to 32 inputs + * must be at a low level for the trigger to fire. + * + * Some sequences of %INSN_CONFIG_DIGITAL_TRIG instructions may have a (partly) + * accumulative effect, depending on the low-level driver.  This is useful + * when setting up a trigger that has more than 32 inputs, or has a combination + * of edge- and level-triggered inputs. + */ +enum comedi_digital_trig_op { +	COMEDI_DIGITAL_TRIG_DISABLE = 0, +	COMEDI_DIGITAL_TRIG_ENABLE_EDGES = 1, +	COMEDI_DIGITAL_TRIG_ENABLE_LEVELS = 2 +}; + +/** + * enum comedi_support_level - support level for a COMEDI feature + * @COMEDI_UNKNOWN_SUPPORT:	Unspecified support for feature. + * @COMEDI_SUPPORTED:		Feature is supported. + * @COMEDI_UNSUPPORTED:		Feature is unsupported. + */ +enum comedi_support_level { +	COMEDI_UNKNOWN_SUPPORT = 0, +	COMEDI_SUPPORTED, +	COMEDI_UNSUPPORTED +}; + +/** + * enum comedi_counter_status_flags - counter status bits + * @COMEDI_COUNTER_ARMED:		Counter is armed. + * @COMEDI_COUNTER_COUNTING:		Counter is counting. + * @COMEDI_COUNTER_TERMINAL_COUNT:	Counter reached terminal count. + * + * These bitwise values are used by the %INSN_CONFIG_GET_COUNTER_STATUS + * configuration instruction to report the status of a counter. + */ +enum comedi_counter_status_flags { +	COMEDI_COUNTER_ARMED = 0x1, +	COMEDI_COUNTER_COUNTING = 0x2, +	COMEDI_COUNTER_TERMINAL_COUNT = 0x4, +}; + +/* ioctls */ + +#define CIO 'd' +#define COMEDI_DEVCONFIG _IOW(CIO, 0, struct comedi_devconfig) +#define COMEDI_DEVINFO _IOR(CIO, 1, struct comedi_devinfo) +#define COMEDI_SUBDINFO _IOR(CIO, 2, struct comedi_subdinfo) +#define COMEDI_CHANINFO _IOR(CIO, 3, struct comedi_chaninfo) +/* _IOWR(CIO, 4, ...) is reserved */ +#define COMEDI_LOCK _IO(CIO, 5) +#define COMEDI_UNLOCK _IO(CIO, 6) +#define COMEDI_CANCEL _IO(CIO, 7) +#define COMEDI_RANGEINFO _IOR(CIO, 8, struct comedi_rangeinfo) +#define COMEDI_CMD _IOR(CIO, 9, struct comedi_cmd) +#define COMEDI_CMDTEST _IOR(CIO, 10, struct comedi_cmd) +#define COMEDI_INSNLIST _IOR(CIO, 11, struct comedi_insnlist) +#define COMEDI_INSN _IOR(CIO, 12, struct comedi_insn) +#define COMEDI_BUFCONFIG _IOR(CIO, 13, struct comedi_bufconfig) +#define COMEDI_BUFINFO _IOWR(CIO, 14, struct comedi_bufinfo) +#define COMEDI_POLL _IO(CIO, 15) +#define COMEDI_SETRSUBD _IO(CIO, 16) +#define COMEDI_SETWSUBD _IO(CIO, 17) + +/* structures */ + +/** + * struct comedi_insn - COMEDI instruction + * @insn:	COMEDI instruction type (%INSN_xxx). + * @n:		Length of @data[]. + * @data:	Pointer to data array operated on by the instruction. + * @subdev:	Subdevice index. + * @chanspec:	A packed "chanspec" value consisting of channel number, + *		analog range index, analog reference type, and flags. + * @unused:	Reserved for future use. + * + * This is used with the %COMEDI_INSN ioctl, and indirectly with the + * %COMEDI_INSNLIST ioctl. + */ +struct comedi_insn { +	unsigned int insn; +	unsigned int n; +	unsigned int __user *data; +	unsigned int subdev; +	unsigned int chanspec; +	unsigned int unused[3]; +}; + +/** + * struct comedi_insnlist - list of COMEDI instructions + * @n_insns:	Number of COMEDI instructions. + * @insns:	Pointer to array COMEDI instructions. + * + * This is used with the %COMEDI_INSNLIST ioctl. + */ +struct comedi_insnlist { +	unsigned int n_insns; +	struct comedi_insn __user *insns; +}; + +/** + * struct comedi_cmd - COMEDI asynchronous acquisition command details + * @subdev:		Subdevice index. + * @flags:		Command flags (%CMDF_xxx). + * @start_src:		"Start acquisition" trigger source (%TRIG_xxx). + * @start_arg:		"Start acquisition" trigger argument. + * @scan_begin_src:	"Scan begin" trigger source. + * @scan_begin_arg:	"Scan begin" trigger argument. + * @convert_src:	"Convert" trigger source. + * @convert_arg:	"Convert" trigger argument. + * @scan_end_src:	"Scan end" trigger source. + * @scan_end_arg:	"Scan end" trigger argument. + * @stop_src:		"Stop acquisition" trigger source. + * @stop_arg:		"Stop acquisition" trigger argument. + * @chanlist:		Pointer to array of "chanspec" values, containing a + *			sequence of channel numbers packed with analog range + *			index, etc. + * @chanlist_len:	Number of channels in sequence. + * @data:		Pointer to miscellaneous set-up data (not used). + * @data_len:		Length of miscellaneous set-up data. + * + * This is used with the %COMEDI_CMD or %COMEDI_CMDTEST ioctl to set-up + * or validate an asynchronous acquisition command.  The ioctl may modify + * the &struct comedi_cmd and copy it back to the caller. + * + * Optional command @flags values that can be ORed together... + * + * %CMDF_BOGUS - makes %COMEDI_CMD ioctl return error %EAGAIN instead of + * starting the command. + * + * %CMDF_PRIORITY - requests "hard real-time" processing (which is not + * supported in this version of COMEDI). + * + * %CMDF_WAKE_EOS - requests the command makes data available for reading + * after every "scan" period. + * + * %CMDF_WRITE - marks the command as being in the "write" (to device) + * direction.  This does not need to be specified by the caller unless the + * subdevice supports commands in either direction. + * + * %CMDF_RAWDATA - prevents the command from "munging" the data between the + * COMEDI sample format and the raw hardware sample format. + * + * %CMDF_ROUND_NEAREST - requests timing periods to be rounded to nearest + * supported values. + * + * %CMDF_ROUND_DOWN - requests timing periods to be rounded down to supported + * values (frequencies rounded up). + * + * %CMDF_ROUND_UP - requests timing periods to be rounded up to supported + * values (frequencies rounded down). + * + * Trigger source values for @start_src, @scan_begin_src, @convert_src, + * @scan_end_src, and @stop_src... + * + * %TRIG_ANY - "all ones" value used to test which trigger sources are + * supported. + * + * %TRIG_INVALID - "all zeroes" value used to indicate that all requested + * trigger sources are invalid. + * + * %TRIG_NONE - never trigger (often used as a @stop_src value). + * + * %TRIG_NOW - trigger after '_arg' nanoseconds. + * + * %TRIG_FOLLOW - trigger follows another event. + * + * %TRIG_TIMER - trigger every '_arg' nanoseconds. + * + * %TRIG_COUNT - trigger when count '_arg' is reached. + * + * %TRIG_EXT - trigger on external signal specified by '_arg'. + * + * %TRIG_INT - trigger on internal, software trigger specified by '_arg'. + * + * %TRIG_OTHER - trigger on other, driver-defined signal specified by '_arg'. + */ +struct comedi_cmd { +	unsigned int subdev; +	unsigned int flags; + +	unsigned int start_src; +	unsigned int start_arg; + +	unsigned int scan_begin_src; +	unsigned int scan_begin_arg; + +	unsigned int convert_src; +	unsigned int convert_arg; + +	unsigned int scan_end_src; +	unsigned int scan_end_arg; + +	unsigned int stop_src; +	unsigned int stop_arg; + +	unsigned int *chanlist; +	unsigned int chanlist_len; + +	short __user *data; +	unsigned int data_len; +}; + +/** + * struct comedi_chaninfo - used to retrieve per-channel information + * @subdev:		Subdevice index. + * @maxdata_list:	Optional pointer to per-channel maximum data values. + * @flaglist:		Optional pointer to per-channel flags. + * @rangelist:		Optional pointer to per-channel range types. + * @unused:		Reserved for future use. + * + * This is used with the %COMEDI_CHANINFO ioctl to get per-channel information + * for the subdevice.  Use of this requires knowledge of the number of channels + * and subdevice flags obtained using the %COMEDI_SUBDINFO ioctl. + * + * The @maxdata_list member must be %NULL unless the %SDF_MAXDATA subdevice + * flag is set.  The @flaglist member must be %NULL unless the %SDF_FLAGS + * subdevice flag is set.  The @rangelist member must be %NULL unless the + * %SDF_RANGETYPE subdevice flag is set.  Otherwise, the arrays they point to + * must be at least as long as the number of channels. + */ +struct comedi_chaninfo { +	unsigned int subdev; +	unsigned int __user *maxdata_list; +	unsigned int __user *flaglist; +	unsigned int __user *rangelist; +	unsigned int unused[4]; +}; + +/** + * struct comedi_rangeinfo - used to retrieve the range table for a channel + * @range_type:		Encodes subdevice index (bits 27:24), channel index + *			(bits 23:16) and range table length (bits 15:0). + * @range_ptr:		Pointer to array of @struct comedi_krange to be filled + *			in with the range table for the channel or subdevice. + * + * This is used with the %COMEDI_RANGEINFO ioctl to retrieve the range table + * for a specific channel (if the subdevice has the %SDF_RANGETYPE flag set to + * indicate that the range table depends on the channel), or for the subdevice + * as a whole (if the %SDF_RANGETYPE flag is clear, indicating the range table + * is shared by all channels). + * + * The @range_type value is an input to the ioctl and comes from a previous + * use of the %COMEDI_SUBDINFO ioctl (if the %SDF_RANGETYPE flag is clear), + * or the %COMEDI_CHANINFO ioctl (if the %SDF_RANGETYPE flag is set). + */ +struct comedi_rangeinfo { +	unsigned int range_type; +	void __user *range_ptr; +}; + +/** + * struct comedi_krange - describes a range in a range table + * @min:	Minimum value in millionths (1e-6) of a unit. + * @max:	Maximum value in millionths (1e-6) of a unit. + * @flags:	Indicates the units (in bits 7:0) OR'ed with optional flags. + * + * A range table is associated with a single channel, or with all channels in a + * subdevice, and a list of one or more ranges.  A %struct comedi_krange + * describes the physical range of units for one of those ranges.  Sample + * values in COMEDI are unsigned from %0 up to some 'maxdata' value.  The + * mapping from sample values to physical units is assumed to be nomimally + * linear (for the purpose of describing the range), with sample value %0 + * mapping to @min, and the 'maxdata' sample value mapping to @max. + * + * The currently defined units are %UNIT_volt (%0), %UNIT_mA (%1), and + * %UNIT_none (%2).  The @min and @max values are the physical range multiplied + * by 1e6, so a @max value of %1000000 (with %UNIT_volt) represents a maximal + * value of 1 volt. + * + * The only defined flag value is %RF_EXTERNAL (%0x100), indicating that the + * range needs to be multiplied by an external reference. + */ +struct comedi_krange { +	int min; +	int max; +	unsigned int flags; +}; + +/** + * struct comedi_subdinfo - used to retrieve information about a subdevice + * @type:		Type of subdevice from &enum comedi_subdevice_type. + * @n_chan:		Number of channels the subdevice supports. + * @subd_flags:		A mixture of static and dynamic flags describing + *			aspects of the subdevice and its current state. + * @timer_type:		Timer type.  Always set to %5 ("nanosecond timer"). + * @len_chanlist:	Maximum length of a channel list if the subdevice + *			supports asynchronous acquisition commands. + * @maxdata:		Maximum sample value for all channels if the + *			%SDF_MAXDATA subdevice flag is clear. + * @flags:		Channel flags for all channels if the %SDF_FLAGS + *			subdevice flag is clear. + * @range_type:		The range type for all channels if the %SDF_RANGETYPE + *			subdevice flag is clear.  Encodes the subdevice index + *			(bits 27:24), a dummy channel index %0 (bits 23:16), + *			and the range table length (bits 15:0). + * @settling_time_0:	Not used. + * @insn_bits_support:	Set to %COMEDI_SUPPORTED if the subdevice supports the + *			%INSN_BITS instruction, or to %COMEDI_UNSUPPORTED if it + *			does not. + * @unused:		Reserved for future use. + * + * This is used with the %COMEDI_SUBDINFO ioctl which copies an array of + * &struct comedi_subdinfo back to user space, with one element per subdevice. + * Use of this requires knowledge of the number of subdevices obtained from + * the %COMEDI_DEVINFO ioctl. + * + * These are the @subd_flags values that may be ORed together... + * + * %SDF_BUSY - the subdevice is busy processing an asynchronous command or a + * synchronous instruction. + * + * %SDF_BUSY_OWNER - the subdevice is busy processing an asynchronous + * acquisition command started on the current file object (the file object + * issuing the %COMEDI_SUBDINFO ioctl). + * + * %SDF_LOCKED - the subdevice is locked by a %COMEDI_LOCK ioctl. + * + * %SDF_LOCK_OWNER - the subdevice is locked by a %COMEDI_LOCK ioctl from the + * current file object. + * + * %SDF_MAXDATA - maximum sample values are channel-specific. + * + * %SDF_FLAGS - channel flags are channel-specific. + * + * %SDF_RANGETYPE - range types are channel-specific. + * + * %SDF_PWM_COUNTER - PWM can switch off automatically. + * + * %SDF_PWM_HBRIDGE - or PWM is signed (H-bridge). + * + * %SDF_CMD - the subdevice supports asynchronous commands. + * + * %SDF_SOFT_CALIBRATED - the subdevice uses software calibration. + * + * %SDF_CMD_WRITE - the subdevice supports asynchronous commands in the output + * ("write") direction. + * + * %SDF_CMD_READ - the subdevice supports asynchronous commands in the input + * ("read") direction. + * + * %SDF_READABLE - the subdevice is readable (e.g. analog input). + * + * %SDF_WRITABLE (aliased as %SDF_WRITEABLE) - the subdevice is writable (e.g. + * analog output). + * + * %SDF_INTERNAL - the subdevice has no externally visible lines. + * + * %SDF_GROUND - the subdevice can use ground as an analog reference. + * + * %SDF_COMMON - the subdevice can use a common analog reference. + * + * %SDF_DIFF - the subdevice can use differential inputs (or outputs). + * + * %SDF_OTHER - the subdevice can use some other analog reference. + * + * %SDF_DITHER - the subdevice can do dithering. + * + * %SDF_DEGLITCH - the subdevice can do deglitching. + * + * %SDF_MMAP - this is never set. + * + * %SDF_RUNNING - an asynchronous command is still running. + * + * %SDF_LSAMPL - the subdevice uses "long" (32-bit) samples (for asynchronous + * command data). + * + * %SDF_PACKED - the subdevice packs several DIO samples into a single sample + * (for asynchronous command data). + * + * No "channel flags" (@flags) values are currently defined. + */ +struct comedi_subdinfo { +	unsigned int type; +	unsigned int n_chan; +	unsigned int subd_flags; +	unsigned int timer_type; +	unsigned int len_chanlist; +	unsigned int maxdata; +	unsigned int flags; +	unsigned int range_type; +	unsigned int settling_time_0; +	unsigned int insn_bits_support; +	unsigned int unused[8]; +}; + +/** + * struct comedi_devinfo - used to retrieve information about a COMEDI device + * @version_code:	COMEDI version code. + * @n_subdevs:		Number of subdevices the device has. + * @driver_name:	Null-terminated COMEDI driver name. + * @board_name:		Null-terminated COMEDI board name. + * @read_subdevice:	Index of the current "read" subdevice (%-1 if none). + * @write_subdevice:	Index of the current "write" subdevice (%-1 if none). + * @unused:		Reserved for future use. + * + * This is used with the %COMEDI_DEVINFO ioctl to get basic information about + * the device. + */ +struct comedi_devinfo { +	unsigned int version_code; +	unsigned int n_subdevs; +	char driver_name[COMEDI_NAMELEN]; +	char board_name[COMEDI_NAMELEN]; +	int read_subdevice; +	int write_subdevice; +	int unused[30]; +}; + +/** + * struct comedi_devconfig - used to configure a legacy COMEDI device + * @board_name:		Null-terminated string specifying the type of board + *			to configure. + * @options:		An array of integer configuration options. + * + * This is used with the %COMEDI_DEVCONFIG ioctl to configure a "legacy" COMEDI + * device, such as an ISA card.  Not all COMEDI drivers support this.  Those + * that do either expect the specified board name to match one of a list of + * names registered with the COMEDI core, or expect the specified board name + * to match the COMEDI driver name itself.  The configuration options are + * handled in a driver-specific manner. + */ +struct comedi_devconfig { +	char board_name[COMEDI_NAMELEN]; +	int options[COMEDI_NDEVCONFOPTS]; +}; + +/** + * struct comedi_bufconfig - used to set or get buffer size for a subdevice + * @subdevice:		Subdevice index. + * @flags:		Not used. + * @maximum_size:	Maximum allowed buffer size. + * @size:		Buffer size. + * @unused:		Reserved for future use. + * + * This is used with the %COMEDI_BUFCONFIG ioctl to get or configure the + * maximum buffer size and current buffer size for a COMEDI subdevice that + * supports asynchronous commands.  If the subdevice does not support + * asynchronous commands, @maximum_size and @size are ignored and set to 0. + * + * On ioctl input, non-zero values of @maximum_size and @size specify a + * new maximum size and new current size (in bytes), respectively.  These + * will by rounded up to a multiple of %PAGE_SIZE.  Specifying a new maximum + * size requires admin capabilities. + * + * On ioctl output, @maximum_size and @size and set to the current maximum + * buffer size and current buffer size, respectively. + */ +struct comedi_bufconfig { +	unsigned int subdevice; +	unsigned int flags; + +	unsigned int maximum_size; +	unsigned int size; + +	unsigned int unused[4]; +}; + +/** + * struct comedi_bufinfo - used to manipulate buffer position for a subdevice + * @subdevice:		Subdevice index. + * @bytes_read:		Specify amount to advance read position for an + *			asynchronous command in the input ("read") direction. + * @buf_write_ptr:	Current write position (index) within the buffer. + * @buf_read_ptr:	Current read position (index) within the buffer. + * @buf_write_count:	Total amount written, modulo 2^32. + * @buf_read_count:	Total amount read, modulo 2^32. + * @bytes_written:	Specify amount to advance write position for an + *			asynchronous command in the output ("write") direction. + * @unused:		Reserved for future use. + * + * This is used with the %COMEDI_BUFINFO ioctl to optionally advance the + * current read or write position in an asynchronous acquisition data buffer, + * and to get the current read and write positions in the buffer. + */ +struct comedi_bufinfo { +	unsigned int subdevice; +	unsigned int bytes_read; + +	unsigned int buf_write_ptr; +	unsigned int buf_read_ptr; +	unsigned int buf_write_count; +	unsigned int buf_read_count; + +	unsigned int bytes_written; + +	unsigned int unused[4]; +}; + +/* range stuff */ + +#define __RANGE(a, b)	((((a) & 0xffff) << 16) | ((b) & 0xffff)) + +#define RANGE_OFFSET(a)		(((a) >> 16) & 0xffff) +#define RANGE_LENGTH(b)		((b) & 0xffff) + +#define RF_UNIT(flags)		((flags) & 0xff) +#define RF_EXTERNAL		0x100 + +#define UNIT_volt		0 +#define UNIT_mA			1 +#define UNIT_none		2 + +#define COMEDI_MIN_SPEED	0xffffffffu + +/**********************************************************/ +/* everything after this line is ALPHA */ +/**********************************************************/ + +/* + * 8254 specific configuration. + * + * It supports two config commands: + * + * 0 ID: INSN_CONFIG_SET_COUNTER_MODE + * 1 8254 Mode + * I8254_MODE0, I8254_MODE1, ..., I8254_MODE5 + * OR'ed with: + * I8254_BCD, I8254_BINARY + * + * 0 ID: INSN_CONFIG_8254_READ_STATUS + * 1 <-- Status byte returned here. + * B7 = Output + * B6 = NULL Count + * B5 - B0 Current mode. + */ + +enum i8254_mode { +	I8254_MODE0 = (0 << 1),	/* Interrupt on terminal count */ +	I8254_MODE1 = (1 << 1),	/* Hardware retriggerable one-shot */ +	I8254_MODE2 = (2 << 1),	/* Rate generator */ +	I8254_MODE3 = (3 << 1),	/* Square wave mode */ +	I8254_MODE4 = (4 << 1),	/* Software triggered strobe */ +	/* Hardware triggered strobe (retriggerable) */ +	I8254_MODE5 = (5 << 1), +	/* Use binary-coded decimal instead of binary (pretty useless) */ +	I8254_BCD = 1, +	I8254_BINARY = 0 +}; + +/* *** BEGIN GLOBALLY-NAMED NI TERMINALS/SIGNALS *** */ + +/* + * Common National Instruments Terminal/Signal names. + * Some of these have no NI_ prefix as they are useful for non-NI hardware, such + * as those that utilize the PXI/RTSI trigger lines. + * + * NOTE ABOUT THE CHOICE OF NAMES HERE AND THE CAMELSCRIPT: + *   The choice to use CamelScript and the exact names below is for + *   maintainability, clarity, similarity to manufacturer's documentation, + *   _and_ a mitigation for confusion that has plagued the use of these drivers + *   for years! + * + *   More detail: + *   There have been significant confusions over the past many years for users + *   when trying to understand how to connect to/from signals and terminals on + *   NI hardware using comedi.  The major reason for this is that the actual + *   register values were exposed and required to be used by users.  Several + *   major reasons exist why this caused major confusion for users: + *   1) The register values are _NOT_ in user documentation, but rather in + *     arcane locations, such as a few register programming manuals that are + *     increasingly hard to find and the NI MHDDK (comments in example code). + *     There is no one place to find the various valid values of the registers. + *   2) The register values are _NOT_ completely consistent.  There is no way to + *     gain any sense of intuition of which values, or even enums one should use + *     for various registers.  There was some attempt in prior use of comedi to + *     name enums such that a user might know which enums should be used for + *     varying purposes, but the end-user had to gain a knowledge of register + *     values to correctly wield this approach. + *   3) The names for signals and registers found in the various register level + *     programming manuals and vendor-provided documentation are _not_ even + *     close to the same names that are in the end-user documentation. + * + *   Similar, albeit less, confusion plagued NI's previous version of their own + *   drivers.  Earlier than 2003, NI greatly simplified the situation for users + *   by releasing a new API that abstracted the names of signals/terminals to a + *   common and intuitive set of names. + * + *   The names below mirror the names chosen and well documented by NI.  These + *   names are exposed to the user via the comedilib user library.  By keeping + *   the names below, in spite of the use of CamelScript, maintenance will be + *   greatly eased and confusion for users _and_ comedi developers will be + *   greatly reduced. + */ + +/* + * Base of abstracted NI names. + * The first 16 bits of *_arg are reserved for channel selection. + * Since we only actually need the first 4 or 5 bits for all register values on + * NI select registers anyways, we'll identify all values >= (1<<15) as being an + * abstracted NI signal/terminal name. + * These values are also used/returned by INSN_DEVICE_CONFIG_TEST_ROUTE, + * INSN_DEVICE_CONFIG_CONNECT_ROUTE, INSN_DEVICE_CONFIG_DISCONNECT_ROUTE, + * and INSN_DEVICE_CONFIG_GET_ROUTES. + */ +#define NI_NAMES_BASE	0x8000u + +#define _TERM_N(base, n, x)	((base) + ((x) & ((n) - 1))) + +/* + * not necessarily all allowed 64 PFIs are valid--certainly not for all devices + */ +#define NI_PFI(x)		_TERM_N(NI_NAMES_BASE, 64, x) +/* 8 trigger lines by standard, Some devices cannot talk to all eight. */ +#define TRIGGER_LINE(x)		_TERM_N(NI_PFI(-1) + 1, 8, x) +/* 4 RTSI shared MUXes to route signals to/from TRIGGER_LINES on NI hardware */ +#define NI_RTSI_BRD(x)		_TERM_N(TRIGGER_LINE(-1) + 1, 4, x) + +/* *** Counter/timer names : 8 counters max *** */ +#define NI_MAX_COUNTERS		8 +#define NI_COUNTER_NAMES_BASE	(NI_RTSI_BRD(-1)  + 1) +#define NI_CtrSource(x)	      _TERM_N(NI_COUNTER_NAMES_BASE, NI_MAX_COUNTERS, x) +/* Gate, Aux, A,B,Z are all treated, at times as gates */ +#define NI_GATES_NAMES_BASE	(NI_CtrSource(-1) + 1) +#define NI_CtrGate(x)		_TERM_N(NI_GATES_NAMES_BASE, NI_MAX_COUNTERS, x) +#define NI_CtrAux(x)		_TERM_N(NI_CtrGate(-1)  + 1, NI_MAX_COUNTERS, x) +#define NI_CtrA(x)		_TERM_N(NI_CtrAux(-1)   + 1, NI_MAX_COUNTERS, x) +#define NI_CtrB(x)		_TERM_N(NI_CtrA(-1)     + 1, NI_MAX_COUNTERS, x) +#define NI_CtrZ(x)		_TERM_N(NI_CtrB(-1)     + 1, NI_MAX_COUNTERS, x) +#define NI_GATES_NAMES_MAX	NI_CtrZ(-1) +#define NI_CtrArmStartTrigger(x) _TERM_N(NI_CtrZ(-1)    + 1, NI_MAX_COUNTERS, x) +#define NI_CtrInternalOutput(x) \ +		      _TERM_N(NI_CtrArmStartTrigger(-1) + 1, NI_MAX_COUNTERS, x) +/** external pin(s) labeled conveniently as Ctr<i>Out. */ +#define NI_CtrOut(x)   _TERM_N(NI_CtrInternalOutput(-1) + 1, NI_MAX_COUNTERS, x) +/** For Buffered sampling of ctr -- x series capability. */ +#define NI_CtrSampleClock(x)	_TERM_N(NI_CtrOut(-1)   + 1, NI_MAX_COUNTERS, x) +#define NI_COUNTER_NAMES_MAX	NI_CtrSampleClock(-1) + +enum ni_common_signal_names { +	/* PXI_Star: this is a non-NI-specific signal */ +	PXI_Star = NI_COUNTER_NAMES_MAX + 1, +	PXI_Clk10, +	PXIe_Clk100, +	NI_AI_SampleClock, +	NI_AI_SampleClockTimebase, +	NI_AI_StartTrigger, +	NI_AI_ReferenceTrigger, +	NI_AI_ConvertClock, +	NI_AI_ConvertClockTimebase, +	NI_AI_PauseTrigger, +	NI_AI_HoldCompleteEvent, +	NI_AI_HoldComplete, +	NI_AI_ExternalMUXClock, +	NI_AI_STOP, /* pulse signal that occurs when a update is finished(?) */ +	NI_AO_SampleClock, +	NI_AO_SampleClockTimebase, +	NI_AO_StartTrigger, +	NI_AO_PauseTrigger, +	NI_DI_SampleClock, +	NI_DI_SampleClockTimebase, +	NI_DI_StartTrigger, +	NI_DI_ReferenceTrigger, +	NI_DI_PauseTrigger, +	NI_DI_InputBufferFull, +	NI_DI_ReadyForStartEvent, +	NI_DI_ReadyForTransferEventBurst, +	NI_DI_ReadyForTransferEventPipelined, +	NI_DO_SampleClock, +	NI_DO_SampleClockTimebase, +	NI_DO_StartTrigger, +	NI_DO_PauseTrigger, +	NI_DO_OutputBufferFull, +	NI_DO_DataActiveEvent, +	NI_DO_ReadyForStartEvent, +	NI_DO_ReadyForTransferEvent, +	NI_MasterTimebase, +	NI_20MHzTimebase, +	NI_80MHzTimebase, +	NI_100MHzTimebase, +	NI_200MHzTimebase, +	NI_100kHzTimebase, +	NI_10MHzRefClock, +	NI_FrequencyOutput, +	NI_ChangeDetectionEvent, +	NI_AnalogComparisonEvent, +	NI_WatchdogExpiredEvent, +	NI_WatchdogExpirationTrigger, +	NI_SCXI_Trig1, +	NI_LogicLow, +	NI_LogicHigh, +	NI_ExternalStrobe, +	NI_PFI_DO, +	NI_CaseGround, +	/* special internal signal used as variable source for RTSI bus: */ +	NI_RGOUT0, + +	/* just a name to make the next more convenient, regardless of above */ +	_NI_NAMES_MAX_PLUS_1, +	NI_NUM_NAMES = _NI_NAMES_MAX_PLUS_1 - NI_NAMES_BASE, +}; + +/* *** END GLOBALLY-NAMED NI TERMINALS/SIGNALS *** */ + +#define NI_USUAL_PFI_SELECT(x)	(((x) < 10) ? (0x1 + (x)) : (0xb + (x))) +#define NI_USUAL_RTSI_SELECT(x)	(((x) < 7) ? (0xb + (x)) : 0x1b) + +/* + * mode bits for NI general-purpose counters, set with + * INSN_CONFIG_SET_COUNTER_MODE + */ +#define NI_GPCT_COUNTING_MODE_SHIFT 16 +#define NI_GPCT_INDEX_PHASE_BITSHIFT 20 +#define NI_GPCT_COUNTING_DIRECTION_SHIFT 24 +enum ni_gpct_mode_bits { +	NI_GPCT_GATE_ON_BOTH_EDGES_BIT = 0x4, +	NI_GPCT_EDGE_GATE_MODE_MASK = 0x18, +	NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS = 0x0, +	NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS = 0x8, +	NI_GPCT_EDGE_GATE_STARTS_BITS = 0x10, +	NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS = 0x18, +	NI_GPCT_STOP_MODE_MASK = 0x60, +	NI_GPCT_STOP_ON_GATE_BITS = 0x00, +	NI_GPCT_STOP_ON_GATE_OR_TC_BITS = 0x20, +	NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS = 0x40, +	NI_GPCT_LOAD_B_SELECT_BIT = 0x80, +	NI_GPCT_OUTPUT_MODE_MASK = 0x300, +	NI_GPCT_OUTPUT_TC_PULSE_BITS = 0x100, +	NI_GPCT_OUTPUT_TC_TOGGLE_BITS = 0x200, +	NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS = 0x300, +	NI_GPCT_HARDWARE_DISARM_MASK = 0xc00, +	NI_GPCT_NO_HARDWARE_DISARM_BITS = 0x000, +	NI_GPCT_DISARM_AT_TC_BITS = 0x400, +	NI_GPCT_DISARM_AT_GATE_BITS = 0x800, +	NI_GPCT_DISARM_AT_TC_OR_GATE_BITS = 0xc00, +	NI_GPCT_LOADING_ON_TC_BIT = 0x1000, +	NI_GPCT_LOADING_ON_GATE_BIT = 0x4000, +	NI_GPCT_COUNTING_MODE_MASK = 0x7 << NI_GPCT_COUNTING_MODE_SHIFT, +	NI_GPCT_COUNTING_MODE_NORMAL_BITS = +		0x0 << NI_GPCT_COUNTING_MODE_SHIFT, +	NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS = +		0x1 << NI_GPCT_COUNTING_MODE_SHIFT, +	NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS = +		0x2 << NI_GPCT_COUNTING_MODE_SHIFT, +	NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS = +		0x3 << NI_GPCT_COUNTING_MODE_SHIFT, +	NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS = +		0x4 << NI_GPCT_COUNTING_MODE_SHIFT, +	NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS = +		0x6 << NI_GPCT_COUNTING_MODE_SHIFT, +	NI_GPCT_INDEX_PHASE_MASK = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT, +	NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS = +		0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT, +	NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS = +		0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT, +	NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS = +		0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT, +	NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS = +		0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT, +	NI_GPCT_INDEX_ENABLE_BIT = 0x400000, +	NI_GPCT_COUNTING_DIRECTION_MASK = +		0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT, +	NI_GPCT_COUNTING_DIRECTION_DOWN_BITS = +		0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT, +	NI_GPCT_COUNTING_DIRECTION_UP_BITS = +		0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT, +	NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS = +		0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT, +	NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS = +		0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT, +	NI_GPCT_RELOAD_SOURCE_MASK = 0xc000000, +	NI_GPCT_RELOAD_SOURCE_FIXED_BITS = 0x0, +	NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS = 0x4000000, +	NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS = 0x8000000, +	NI_GPCT_OR_GATE_BIT = 0x10000000, +	NI_GPCT_INVERT_OUTPUT_BIT = 0x20000000 +}; + +/* + * Bits for setting a clock source with + * INSN_CONFIG_SET_CLOCK_SRC when using NI general-purpose counters. + */ +enum ni_gpct_clock_source_bits { +	NI_GPCT_CLOCK_SRC_SELECT_MASK = 0x3f, +	NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS = 0x0, +	NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS = 0x1, +	NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS = 0x2, +	NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS = 0x3, +	NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS = 0x4, +	NI_GPCT_NEXT_TC_CLOCK_SRC_BITS = 0x5, +	/* NI 660x-specific */ +	NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS = 0x6, +	NI_GPCT_PXI10_CLOCK_SRC_BITS = 0x7, +	NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS = 0x8, +	NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS = 0x9, +	NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK = 0x30000000, +	NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS = 0x0, +	/* divide source by 2 */ +	NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS = 0x10000000, +	/* divide source by 8 */ +	NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000, +	NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000 +}; + +/* NI 660x-specific */ +#define NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(x)	(0x10 + (x)) + +#define NI_GPCT_RTSI_CLOCK_SRC_BITS(x)		(0x18 + (x)) + +/* no pfi on NI 660x */ +#define NI_GPCT_PFI_CLOCK_SRC_BITS(x)		(0x20 + (x)) + +/* + * Possibilities for setting a gate source with + * INSN_CONFIG_SET_GATE_SRC when using NI general-purpose counters. + * May be bitwise-or'd with CR_EDGE or CR_INVERT. + */ +enum ni_gpct_gate_select { +	/* m-series gates */ +	NI_GPCT_TIMESTAMP_MUX_GATE_SELECT = 0x0, +	NI_GPCT_AI_START2_GATE_SELECT = 0x12, +	NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT = 0x13, +	NI_GPCT_NEXT_OUT_GATE_SELECT = 0x14, +	NI_GPCT_AI_START1_GATE_SELECT = 0x1c, +	NI_GPCT_NEXT_SOURCE_GATE_SELECT = 0x1d, +	NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT = 0x1e, +	NI_GPCT_LOGIC_LOW_GATE_SELECT = 0x1f, +	/* more gates for 660x */ +	NI_GPCT_SOURCE_PIN_i_GATE_SELECT = 0x100, +	NI_GPCT_GATE_PIN_i_GATE_SELECT = 0x101, +	/* more gates for 660x "second gate" */ +	NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT = 0x201, +	NI_GPCT_SELECTED_GATE_GATE_SELECT = 0x21e, +	/* +	 * m-series "second gate" sources are unknown, +	 * we should add them here with an offset of 0x300 when +	 * known. +	 */ +	NI_GPCT_DISABLED_GATE_SELECT = 0x8000, +}; + +#define NI_GPCT_GATE_PIN_GATE_SELECT(x)		(0x102 + (x)) +#define NI_GPCT_RTSI_GATE_SELECT(x)		NI_USUAL_RTSI_SELECT(x) +#define NI_GPCT_PFI_GATE_SELECT(x)		NI_USUAL_PFI_SELECT(x) +#define NI_GPCT_UP_DOWN_PIN_GATE_SELECT(x)	(0x202 + (x)) + +/* + * Possibilities for setting a source with + * INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters. + */ +enum ni_gpct_other_index { +	NI_GPCT_SOURCE_ENCODER_A, +	NI_GPCT_SOURCE_ENCODER_B, +	NI_GPCT_SOURCE_ENCODER_Z +}; + +enum ni_gpct_other_select { +	/* m-series gates */ +	/* Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT */ +	NI_GPCT_DISABLED_OTHER_SELECT = 0x8000, +}; + +#define NI_GPCT_PFI_OTHER_SELECT(x)	NI_USUAL_PFI_SELECT(x) + +/* + * start sources for ni general-purpose counters for use with + * INSN_CONFIG_ARM + */ +enum ni_gpct_arm_source { +	NI_GPCT_ARM_IMMEDIATE = 0x0, +	/* +	 * Start both the counter and the adjacent paired counter simultaneously +	 */ +	NI_GPCT_ARM_PAIRED_IMMEDIATE = 0x1, +	/* +	 * If the NI_GPCT_HW_ARM bit is set, we will pass the least significant +	 * bits (3 bits for 660x or 5 bits for m-series) through to the +	 * hardware. To select a hardware trigger, pass the appropriate select +	 * bit, e.g., +	 * NI_GPCT_HW_ARM | NI_GPCT_AI_START1_GATE_SELECT or +	 * NI_GPCT_HW_ARM | NI_GPCT_PFI_GATE_SELECT(pfi_number) +	 */ +	NI_GPCT_HW_ARM = 0x1000, +	NI_GPCT_ARM_UNKNOWN = NI_GPCT_HW_ARM,	/* for backward compatibility */ +}; + +/* digital filtering options for ni 660x for use with INSN_CONFIG_FILTER. */ +enum ni_gpct_filter_select { +	NI_GPCT_FILTER_OFF = 0x0, +	NI_GPCT_FILTER_TIMEBASE_3_SYNC = 0x1, +	NI_GPCT_FILTER_100x_TIMEBASE_1 = 0x2, +	NI_GPCT_FILTER_20x_TIMEBASE_1 = 0x3, +	NI_GPCT_FILTER_10x_TIMEBASE_1 = 0x4, +	NI_GPCT_FILTER_2x_TIMEBASE_1 = 0x5, +	NI_GPCT_FILTER_2x_TIMEBASE_3 = 0x6 +}; + +/* + * PFI digital filtering options for ni m-series for use with + * INSN_CONFIG_FILTER. + */ +enum ni_pfi_filter_select { +	NI_PFI_FILTER_OFF = 0x0, +	NI_PFI_FILTER_125ns = 0x1, +	NI_PFI_FILTER_6425ns = 0x2, +	NI_PFI_FILTER_2550us = 0x3 +}; + +/* master clock sources for ni mio boards and INSN_CONFIG_SET_CLOCK_SRC */ +enum ni_mio_clock_source { +	NI_MIO_INTERNAL_CLOCK = 0, +	/* +	 * Doesn't work for m-series, use NI_MIO_PLL_RTSI_CLOCK() +	 * the NI_MIO_PLL_* sources are m-series only +	 */ +	NI_MIO_RTSI_CLOCK = 1, +	NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK = 2, +	NI_MIO_PLL_PXI10_CLOCK = 3, +	NI_MIO_PLL_RTSI0_CLOCK = 4 +}; + +#define NI_MIO_PLL_RTSI_CLOCK(x)	(NI_MIO_PLL_RTSI0_CLOCK + (x)) + +/* + * Signals which can be routed to an NI RTSI pin with INSN_CONFIG_SET_ROUTING. + * The numbers assigned are not arbitrary, they correspond to the bits required + * to program the board. + */ +enum ni_rtsi_routing { +	NI_RTSI_OUTPUT_ADR_START1 = 0, +	NI_RTSI_OUTPUT_ADR_START2 = 1, +	NI_RTSI_OUTPUT_SCLKG = 2, +	NI_RTSI_OUTPUT_DACUPDN = 3, +	NI_RTSI_OUTPUT_DA_START1 = 4, +	NI_RTSI_OUTPUT_G_SRC0 = 5, +	NI_RTSI_OUTPUT_G_GATE0 = 6, +	NI_RTSI_OUTPUT_RGOUT0 = 7, +	NI_RTSI_OUTPUT_RTSI_BRD_0 = 8, +	/* Pre-m-series always have RTSI clock on line 7 */ +	NI_RTSI_OUTPUT_RTSI_OSC = 12 +}; + +#define NI_RTSI_OUTPUT_RTSI_BRD(x)	(NI_RTSI_OUTPUT_RTSI_BRD_0 + (x)) + +/* + * Signals which can be routed to an NI PFI pin on an m-series board with + * INSN_CONFIG_SET_ROUTING.  These numbers are also returned by + * INSN_CONFIG_GET_ROUTING on pre-m-series boards, even though their routing + * cannot be changed.  The numbers assigned are not arbitrary, they correspond + * to the bits required to program the board. + */ +enum ni_pfi_routing { +	NI_PFI_OUTPUT_PFI_DEFAULT = 0, +	NI_PFI_OUTPUT_AI_START1 = 1, +	NI_PFI_OUTPUT_AI_START2 = 2, +	NI_PFI_OUTPUT_AI_CONVERT = 3, +	NI_PFI_OUTPUT_G_SRC1 = 4, +	NI_PFI_OUTPUT_G_GATE1 = 5, +	NI_PFI_OUTPUT_AO_UPDATE_N = 6, +	NI_PFI_OUTPUT_AO_START1 = 7, +	NI_PFI_OUTPUT_AI_START_PULSE = 8, +	NI_PFI_OUTPUT_G_SRC0 = 9, +	NI_PFI_OUTPUT_G_GATE0 = 10, +	NI_PFI_OUTPUT_EXT_STROBE = 11, +	NI_PFI_OUTPUT_AI_EXT_MUX_CLK = 12, +	NI_PFI_OUTPUT_GOUT0 = 13, +	NI_PFI_OUTPUT_GOUT1 = 14, +	NI_PFI_OUTPUT_FREQ_OUT = 15, +	NI_PFI_OUTPUT_PFI_DO = 16, +	NI_PFI_OUTPUT_I_ATRIG = 17, +	NI_PFI_OUTPUT_RTSI0 = 18, +	NI_PFI_OUTPUT_PXI_STAR_TRIGGER_IN = 26, +	NI_PFI_OUTPUT_SCXI_TRIG1 = 27, +	NI_PFI_OUTPUT_DIO_CHANGE_DETECT_RTSI = 28, +	NI_PFI_OUTPUT_CDI_SAMPLE = 29, +	NI_PFI_OUTPUT_CDO_UPDATE = 30 +}; + +#define NI_PFI_OUTPUT_RTSI(x)		(NI_PFI_OUTPUT_RTSI0 + (x)) + +/* + * Signals which can be routed to output on a NI PFI pin on a 660x board + * with INSN_CONFIG_SET_ROUTING.  The numbers assigned are + * not arbitrary, they correspond to the bits required + * to program the board.  Lines 0 to 7 can only be set to + * NI_660X_PFI_OUTPUT_DIO.  Lines 32 to 39 can only be set to + * NI_660X_PFI_OUTPUT_COUNTER. + */ +enum ni_660x_pfi_routing { +	NI_660X_PFI_OUTPUT_COUNTER = 1,	/* counter */ +	NI_660X_PFI_OUTPUT_DIO = 2,	/* static digital output */ +}; + +/* + * NI External Trigger lines.  These values are not arbitrary, but are related + * to the bits required to program the board (offset by 1 for historical + * reasons). + */ +#define NI_EXT_PFI(x)			(NI_USUAL_PFI_SELECT(x) - 1) +#define NI_EXT_RTSI(x)			(NI_USUAL_RTSI_SELECT(x) - 1) + +/* + * Clock sources for CDIO subdevice on NI m-series boards.  Used as the + * scan_begin_arg for a comedi_command. These sources may also be bitwise-or'd + * with CR_INVERT to change polarity. + */ +enum ni_m_series_cdio_scan_begin_src { +	NI_CDIO_SCAN_BEGIN_SRC_GROUND = 0, +	NI_CDIO_SCAN_BEGIN_SRC_AI_START = 18, +	NI_CDIO_SCAN_BEGIN_SRC_AI_CONVERT = 19, +	NI_CDIO_SCAN_BEGIN_SRC_PXI_STAR_TRIGGER = 20, +	NI_CDIO_SCAN_BEGIN_SRC_G0_OUT = 28, +	NI_CDIO_SCAN_BEGIN_SRC_G1_OUT = 29, +	NI_CDIO_SCAN_BEGIN_SRC_ANALOG_TRIGGER = 30, +	NI_CDIO_SCAN_BEGIN_SRC_AO_UPDATE = 31, +	NI_CDIO_SCAN_BEGIN_SRC_FREQ_OUT = 32, +	NI_CDIO_SCAN_BEGIN_SRC_DIO_CHANGE_DETECT_IRQ = 33 +}; + +#define NI_CDIO_SCAN_BEGIN_SRC_PFI(x)	NI_USUAL_PFI_SELECT(x) +#define NI_CDIO_SCAN_BEGIN_SRC_RTSI(x)	NI_USUAL_RTSI_SELECT(x) + +/* + * scan_begin_src for scan_begin_arg==TRIG_EXT with analog output command on NI + * boards.  These scan begin sources can also be bitwise-or'd with CR_INVERT to + * change polarity. + */ +#define NI_AO_SCAN_BEGIN_SRC_PFI(x)	NI_USUAL_PFI_SELECT(x) +#define NI_AO_SCAN_BEGIN_SRC_RTSI(x)	NI_USUAL_RTSI_SELECT(x) + +/* + * Bits for setting a clock source with + * INSN_CONFIG_SET_CLOCK_SRC when using NI frequency output subdevice. + */ +enum ni_freq_out_clock_source_bits { +	NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC,	/* 10 MHz */ +	NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC	/* 100 KHz */ +}; + +/* + * Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for + * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver). + */ +enum amplc_dio_clock_source { +	/* +	 * Per channel external clock +	 * input/output pin (pin is only an +	 * input when clock source set to this value, +	 * otherwise it is an output) +	 */ +	AMPLC_DIO_CLK_CLKN, +	AMPLC_DIO_CLK_10MHZ,	/* 10 MHz internal clock */ +	AMPLC_DIO_CLK_1MHZ,	/* 1 MHz internal clock */ +	AMPLC_DIO_CLK_100KHZ,	/* 100 kHz internal clock */ +	AMPLC_DIO_CLK_10KHZ,	/* 10 kHz internal clock */ +	AMPLC_DIO_CLK_1KHZ,	/* 1 kHz internal clock */ +	/* +	 * Output of preceding counter channel +	 * (for channel 0, preceding counter +	 * channel is channel 2 on preceding +	 * counter subdevice, for first counter +	 * subdevice, preceding counter +	 * subdevice is the last counter +	 * subdevice) +	 */ +	AMPLC_DIO_CLK_OUTNM1, +	AMPLC_DIO_CLK_EXT,	/* per chip external input pin */ +	/* the following are "enhanced" clock sources for PCIe models */ +	AMPLC_DIO_CLK_VCC,	/* clock input HIGH */ +	AMPLC_DIO_CLK_GND,	/* clock input LOW */ +	AMPLC_DIO_CLK_PAT_PRESENT, /* "pattern present" signal */ +	AMPLC_DIO_CLK_20MHZ	/* 20 MHz internal clock */ +}; + +/* + * Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for + * timer subdevice on some Amplicon DIO PCIe boards (amplc_dio200 driver). + */ +enum amplc_dio_ts_clock_src { +	AMPLC_DIO_TS_CLK_1GHZ,	/* 1 ns period with 20 ns granularity */ +	AMPLC_DIO_TS_CLK_1MHZ,	/* 1 us period */ +	AMPLC_DIO_TS_CLK_1KHZ	/* 1 ms period */ +}; + +/* + * Values for setting a gate source with INSN_CONFIG_SET_GATE_SRC for + * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver). + */ +enum amplc_dio_gate_source { +	AMPLC_DIO_GAT_VCC,	/* internal high logic level */ +	AMPLC_DIO_GAT_GND,	/* internal low logic level */ +	AMPLC_DIO_GAT_GATN,	/* per channel external gate input */ +	/* +	 * negated output of counter channel minus 2 +	 * (for channels 0 or 1, channel minus 2 is channel 1 or 2 on +	 * the preceding counter subdevice, for the first counter subdevice +	 * the preceding counter subdevice is the last counter subdevice) +	 */ +	AMPLC_DIO_GAT_NOUTNM2, +	AMPLC_DIO_GAT_RESERVED4, +	AMPLC_DIO_GAT_RESERVED5, +	AMPLC_DIO_GAT_RESERVED6, +	AMPLC_DIO_GAT_RESERVED7, +	/* the following are "enhanced" gate sources for PCIe models */ +	AMPLC_DIO_GAT_NGATN = 6, /* negated per channel gate input */ +	/* non-negated output of counter channel minus 2 */ +	AMPLC_DIO_GAT_OUTNM2, +	AMPLC_DIO_GAT_PAT_PRESENT, /* "pattern present" signal */ +	AMPLC_DIO_GAT_PAT_OCCURRED, /* "pattern occurred" latched */ +	AMPLC_DIO_GAT_PAT_GONE,	/* "pattern gone away" latched */ +	AMPLC_DIO_GAT_NPAT_PRESENT, /* negated "pattern present" */ +	AMPLC_DIO_GAT_NPAT_OCCURRED, /* negated "pattern occurred" */ +	AMPLC_DIO_GAT_NPAT_GONE	/* negated "pattern gone away" */ +}; + +/* + * Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for + * the counter subdevice on the Kolter Electronic PCI-Counter board + * (ke_counter driver). + */ +enum ke_counter_clock_source { +	KE_CLK_20MHZ,	/* internal 20MHz (default) */ +	KE_CLK_4MHZ,	/* internal 4MHz (option) */ +	KE_CLK_EXT	/* external clock on pin 21 of D-Sub */ +}; + +#endif /* _COMEDI_H */ diff --git a/include/uapi/linux/connector.h b/include/uapi/linux/connector.h index 3738936149a2..5ae131c3f145 100644 --- a/include/uapi/linux/connector.h +++ b/include/uapi/linux/connector.h @@ -75,7 +75,7 @@ struct cn_msg {  	__u16 len;		/* Length of the following data */  	__u16 flags; -	__u8 data[0]; +	__u8 data[];  };  #endif /* _UAPI__CONNECTOR_H */ diff --git a/include/uapi/linux/const.h b/include/uapi/linux/const.h index 5ed721ad5b19..b8f629ef135f 100644 --- a/include/uapi/linux/const.h +++ b/include/uapi/linux/const.h @@ -28,4 +28,26 @@  #define _BITUL(x)	(_UL(1) << (x))  #define _BITULL(x)	(_ULL(1) << (x)) +#if !defined(__ASSEMBLY__) +/* + * Missing asm support + * + * __BIT128() would not work in the asm code, as it shifts an + * 'unsigned __int128' data type as direct representation of + * 128 bit constants is not supported in the gcc compiler, as + * they get silently truncated. + * + * TODO: Please revisit this implementation when gcc compiler + * starts representing 128 bit constants directly like long + * and unsigned long etc. Subsequently drop the comment for + * GENMASK_U128() which would then start supporting asm code. + */ +#define _BIT128(x)	((unsigned __int128)(1) << (x)) +#endif + +#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1) +#define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask)) + +#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) +  #endif /* _UAPI_LINUX_CONST_H */ diff --git a/include/uapi/linux/coredump.h b/include/uapi/linux/coredump.h new file mode 100644 index 000000000000..dc3789b78af0 --- /dev/null +++ b/include/uapi/linux/coredump.h @@ -0,0 +1,104 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ + +#ifndef _UAPI_LINUX_COREDUMP_H +#define _UAPI_LINUX_COREDUMP_H + +#include <linux/types.h> + +/** + * coredump_{req,ack} flags + * @COREDUMP_KERNEL: kernel writes coredump + * @COREDUMP_USERSPACE: userspace writes coredump + * @COREDUMP_REJECT: don't generate coredump + * @COREDUMP_WAIT: wait for coredump server + */ +enum { +	COREDUMP_KERNEL		= (1ULL << 0), +	COREDUMP_USERSPACE	= (1ULL << 1), +	COREDUMP_REJECT		= (1ULL << 2), +	COREDUMP_WAIT		= (1ULL << 3), +}; + +/** + * struct coredump_req - message kernel sends to userspace + * @size: size of struct coredump_req + * @size_ack: known size of struct coredump_ack on this kernel + * @mask: supported features + * + * When a coredump happens the kernel will connect to the coredump + * socket and send a coredump request to the coredump server. The @size + * member is set to the size of struct coredump_req and provides a hint + * to userspace how much data can be read. Userspace may use MSG_PEEK to + * peek the size of struct coredump_req and then choose to consume it in + * one go. Userspace may also simply read a COREDUMP_ACK_SIZE_VER0 + * request. If the size the kernel sends is larger userspace simply + * discards any remaining data. + * + * The coredump_req->mask member is set to the currently know features. + * Userspace may only set coredump_ack->mask to the bits raised by the + * kernel in coredump_req->mask. + * + * The coredump_req->size_ack member is set by the kernel to the size of + * struct coredump_ack the kernel knows. Userspace may only send up to + * coredump_req->size_ack bytes to the kernel and must set + * coredump_ack->size accordingly. + */ +struct coredump_req { +	__u32 size; +	__u32 size_ack; +	__u64 mask; +}; + +enum { +	COREDUMP_REQ_SIZE_VER0 = 16U, /* size of first published struct */ +}; + +/** + * struct coredump_ack - message userspace sends to kernel + * @size: size of the struct + * @spare: unused + * @mask: features kernel is supposed to use + * + * The @size member must be set to the size of struct coredump_ack. It + * may never exceed what the kernel returned in coredump_req->size_ack + * but it may of course be smaller (>= COREDUMP_ACK_SIZE_VER0 and <= + * coredump_req->size_ack). + * + * The @mask member must be set to the features the coredump server + * wants the kernel to use. Only bits the kernel returned in + * coredump_req->mask may be set. + */ +struct coredump_ack { +	__u32 size; +	__u32 spare; +	__u64 mask; +}; + +enum { +	COREDUMP_ACK_SIZE_VER0 = 16U, /* size of first published struct */ +}; + +/** + * enum coredump_mark - Markers for the coredump socket + * + * The kernel will place a single byte on the coredump socket. The + * markers notify userspace whether the coredump ack succeeded or + * failed. + * + * @COREDUMP_MARK_MINSIZE: the provided coredump_ack size was too small + * @COREDUMP_MARK_MAXSIZE: the provided coredump_ack size was too big + * @COREDUMP_MARK_UNSUPPORTED: the provided coredump_ack mask was invalid + * @COREDUMP_MARK_CONFLICTING: the provided coredump_ack mask has conflicting options + * @COREDUMP_MARK_REQACK: the coredump request and ack was successful + * @__COREDUMP_MARK_MAX: the maximum coredump mark value + */ +enum coredump_mark { +	COREDUMP_MARK_REQACK		= 0U, +	COREDUMP_MARK_MINSIZE		= 1U, +	COREDUMP_MARK_MAXSIZE		= 2U, +	COREDUMP_MARK_UNSUPPORTED	= 3U, +	COREDUMP_MARK_CONFLICTING	= 4U, +	__COREDUMP_MARK_MAX		= (1U << 31), +}; + +#endif /* _UAPI_LINUX_COREDUMP_H */ diff --git a/include/uapi/linux/coresight-stm.h b/include/uapi/linux/coresight-stm.h index 8847dbf24151..7ff3709c01b8 100644 --- a/include/uapi/linux/coresight-stm.h +++ b/include/uapi/linux/coresight-stm.h @@ -5,6 +5,7 @@  #include <linux/const.h>  #define STM_FLAG_TIMESTAMPED   _BITUL(3) +#define STM_FLAG_MARKED        _BITUL(4)  #define STM_FLAG_GUARANTEED    _BITUL(7)  /* diff --git a/include/uapi/linux/counter.h b/include/uapi/linux/counter.h new file mode 100644 index 000000000000..350b45d616bb --- /dev/null +++ b/include/uapi/linux/counter.h @@ -0,0 +1,172 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Userspace ABI for Counter character devices + * Copyright (C) 2020 William Breathitt Gray + */ +#ifndef _UAPI_COUNTER_H_ +#define _UAPI_COUNTER_H_ + +#include <linux/ioctl.h> +#include <linux/types.h> + +/* Component type definitions */ +enum counter_component_type { +	COUNTER_COMPONENT_NONE, +	COUNTER_COMPONENT_SIGNAL, +	COUNTER_COMPONENT_COUNT, +	COUNTER_COMPONENT_FUNCTION, +	COUNTER_COMPONENT_SYNAPSE_ACTION, +	COUNTER_COMPONENT_EXTENSION, +}; + +/* Component scope definitions */ +enum counter_scope { +	COUNTER_SCOPE_DEVICE, +	COUNTER_SCOPE_SIGNAL, +	COUNTER_SCOPE_COUNT, +}; + +/** + * struct counter_component - Counter component identification + * @type: component type (one of enum counter_component_type) + * @scope: component scope (one of enum counter_scope) + * @parent: parent ID (matching the ID suffix of the respective parent sysfs + *          path as described by the ABI documentation file + *          Documentation/ABI/testing/sysfs-bus-counter) + * @id: component ID (matching the ID provided by the respective *_component_id + *      sysfs attribute of the desired component) + * + * For example, if the Count 2 ceiling extension of Counter device 4 is desired, + * set type equal to COUNTER_COMPONENT_EXTENSION, scope equal to + * COUNTER_SCOPE_COUNT, parent equal to 2, and id equal to the value provided by + * the respective /sys/bus/counter/devices/counter4/count2/ceiling_component_id + * sysfs attribute. + */ +struct counter_component { +	__u8 type; +	__u8 scope; +	__u8 parent; +	__u8 id; +}; + +/* Event type definitions */ +enum counter_event_type { +	/* Count value increased past ceiling */ +	COUNTER_EVENT_OVERFLOW, +	/* Count value decreased past floor */ +	COUNTER_EVENT_UNDERFLOW, +	/* Count value increased past ceiling, or decreased past floor */ +	COUNTER_EVENT_OVERFLOW_UNDERFLOW, +	/* Count value reached threshold */ +	COUNTER_EVENT_THRESHOLD, +	/* Index signal detected */ +	COUNTER_EVENT_INDEX, +	/* State of counter is changed */ +	COUNTER_EVENT_CHANGE_OF_STATE, +	/* Count value captured */ +	COUNTER_EVENT_CAPTURE, +	/* Direction change detected */ +	COUNTER_EVENT_DIRECTION_CHANGE, +}; + +/** + * struct counter_watch - Counter component watch configuration + * @component: component to watch when event triggers + * @event: event that triggers (one of enum counter_event_type) + * @channel: event channel (typically 0 unless the device supports concurrent + *	     events of the same type) + */ +struct counter_watch { +	struct counter_component component; +	__u8 event; +	__u8 channel; +}; + +/* + * Queues a Counter watch for the specified event. + * + * The queued watches will not be applied until COUNTER_ENABLE_EVENTS_IOCTL is + * called. + */ +#define COUNTER_ADD_WATCH_IOCTL _IOW(0x3E, 0x00, struct counter_watch) +/* + * Enables monitoring the events specified by the Counter watches that were + * queued by COUNTER_ADD_WATCH_IOCTL. + * + * If events are already enabled, the new set of watches replaces the old one. + * Calling this ioctl also has the effect of clearing the queue of watches added + * by COUNTER_ADD_WATCH_IOCTL. + */ +#define COUNTER_ENABLE_EVENTS_IOCTL _IO(0x3E, 0x01) +/* + * Stops monitoring the previously enabled events. + */ +#define COUNTER_DISABLE_EVENTS_IOCTL _IO(0x3E, 0x02) + +/** + * struct counter_event - Counter event data + * @timestamp: best estimate of time of event occurrence, in nanoseconds + * @value: component value + * @watch: component watch configuration + * @status: return status (system error number) + */ +struct counter_event { +	__aligned_u64 timestamp; +	__aligned_u64 value; +	struct counter_watch watch; +	__u8 status; +}; + +/* Count direction values */ +enum counter_count_direction { +	COUNTER_COUNT_DIRECTION_FORWARD, +	COUNTER_COUNT_DIRECTION_BACKWARD, +}; + +/* Count mode values */ +enum counter_count_mode { +	COUNTER_COUNT_MODE_NORMAL, +	COUNTER_COUNT_MODE_RANGE_LIMIT, +	COUNTER_COUNT_MODE_NON_RECYCLE, +	COUNTER_COUNT_MODE_MODULO_N, +	COUNTER_COUNT_MODE_INTERRUPT_ON_TERMINAL_COUNT, +	COUNTER_COUNT_MODE_HARDWARE_RETRIGGERABLE_ONESHOT, +	COUNTER_COUNT_MODE_RATE_GENERATOR, +	COUNTER_COUNT_MODE_SQUARE_WAVE_MODE, +	COUNTER_COUNT_MODE_SOFTWARE_TRIGGERED_STROBE, +	COUNTER_COUNT_MODE_HARDWARE_TRIGGERED_STROBE, +}; + +/* Count function values */ +enum counter_function { +	COUNTER_FUNCTION_INCREASE, +	COUNTER_FUNCTION_DECREASE, +	COUNTER_FUNCTION_PULSE_DIRECTION, +	COUNTER_FUNCTION_QUADRATURE_X1_A, +	COUNTER_FUNCTION_QUADRATURE_X1_B, +	COUNTER_FUNCTION_QUADRATURE_X2_A, +	COUNTER_FUNCTION_QUADRATURE_X2_B, +	COUNTER_FUNCTION_QUADRATURE_X4, +}; + +/* Signal values */ +enum counter_signal_level { +	COUNTER_SIGNAL_LEVEL_LOW, +	COUNTER_SIGNAL_LEVEL_HIGH, +}; + +/* Action mode values */ +enum counter_synapse_action { +	COUNTER_SYNAPSE_ACTION_NONE, +	COUNTER_SYNAPSE_ACTION_RISING_EDGE, +	COUNTER_SYNAPSE_ACTION_FALLING_EDGE, +	COUNTER_SYNAPSE_ACTION_BOTH_EDGES, +}; + +/* Signal polarity values */ +enum counter_signal_polarity { +	COUNTER_SIGNAL_POLARITY_POSITIVE, +	COUNTER_SIGNAL_POLARITY_NEGATIVE, +}; + +#endif /* _UAPI_COUNTER_H_ */ diff --git a/include/uapi/linux/counter/microchip-tcb-capture.h b/include/uapi/linux/counter/microchip-tcb-capture.h new file mode 100644 index 000000000000..136e2faa7730 --- /dev/null +++ b/include/uapi/linux/counter/microchip-tcb-capture.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Channel numbers used by the microchip-tcb-capture driver + * Copyright (C) 2025 Bence Csókás + */ +#ifndef _UAPI_COUNTER_MCHP_TCB_H_ +#define _UAPI_COUNTER_MCHP_TCB_H_ + +/* + * The driver defines the following components: + * + * Count 0 + * \__  Synapse 0 -- Signal 0 (Channel A, i.e. TIOA) + * \__  Synapse 1 -- Signal 1 (Channel B, i.e. TIOB) + * \__  Extension capture0    (RA register) + * \__  Extension capture1    (RB register) + * + * It also supports the following events: + * + * Channel 0: + * - CV register changed + * - CV overflowed + * - RA captured + * Channel 1: + * - RB captured + * Channel 2: + * - RC compare triggered + */ + +/* Capture extensions */ +#define COUNTER_MCHP_EXCAP_RA 0 +#define COUNTER_MCHP_EXCAP_RB 1 + +/* Event channels */ +#define COUNTER_MCHP_EVCHN_CV 0 +#define COUNTER_MCHP_EVCHN_RA 0 +#define COUNTER_MCHP_EVCHN_RB 1 +#define COUNTER_MCHP_EVCHN_RC 2 + +#endif /* _UAPI_COUNTER_MCHP_TCB_H_ */ diff --git a/include/uapi/linux/cryptouser.h b/include/uapi/linux/cryptouser.h index 5730c67f0617..db05e0419972 100644 --- a/include/uapi/linux/cryptouser.h +++ b/include/uapi/linux/cryptouser.h @@ -32,7 +32,7 @@ enum {  	CRYPTO_MSG_UPDATEALG,  	CRYPTO_MSG_GETALG,  	CRYPTO_MSG_DELRNG, -	CRYPTO_MSG_GETSTAT, +	CRYPTO_MSG_GETSTAT, /* No longer supported, do not use. */  	__CRYPTO_MSG_MAX  };  #define CRYPTO_MSG_MAX (__CRYPTO_MSG_MAX - 1) @@ -54,16 +54,17 @@ enum crypto_attr_type_t {  	CRYPTOCFGA_REPORT_AKCIPHER,	/* struct crypto_report_akcipher */  	CRYPTOCFGA_REPORT_KPP,		/* struct crypto_report_kpp */  	CRYPTOCFGA_REPORT_ACOMP,	/* struct crypto_report_acomp */ -	CRYPTOCFGA_STAT_LARVAL,		/* struct crypto_stat */ -	CRYPTOCFGA_STAT_HASH,		/* struct crypto_stat */ -	CRYPTOCFGA_STAT_BLKCIPHER,	/* struct crypto_stat */ -	CRYPTOCFGA_STAT_AEAD,		/* struct crypto_stat */ -	CRYPTOCFGA_STAT_COMPRESS,	/* struct crypto_stat */ -	CRYPTOCFGA_STAT_RNG,		/* struct crypto_stat */ -	CRYPTOCFGA_STAT_CIPHER,		/* struct crypto_stat */ -	CRYPTOCFGA_STAT_AKCIPHER,	/* struct crypto_stat */ -	CRYPTOCFGA_STAT_KPP,		/* struct crypto_stat */ -	CRYPTOCFGA_STAT_ACOMP,		/* struct crypto_stat */ +	CRYPTOCFGA_STAT_LARVAL,		/* No longer supported, do not use. */ +	CRYPTOCFGA_STAT_HASH,		/* No longer supported, do not use. */ +	CRYPTOCFGA_STAT_BLKCIPHER,	/* No longer supported, do not use. */ +	CRYPTOCFGA_STAT_AEAD,		/* No longer supported, do not use. */ +	CRYPTOCFGA_STAT_COMPRESS,	/* No longer supported, do not use. */ +	CRYPTOCFGA_STAT_RNG,		/* No longer supported, do not use. */ +	CRYPTOCFGA_STAT_CIPHER,		/* No longer supported, do not use. */ +	CRYPTOCFGA_STAT_AKCIPHER,	/* No longer supported, do not use. */ +	CRYPTOCFGA_STAT_KPP,		/* No longer supported, do not use. */ +	CRYPTOCFGA_STAT_ACOMP,		/* No longer supported, do not use. */ +	CRYPTOCFGA_REPORT_SIG,		/* struct crypto_report_sig */  	__CRYPTOCFGA_MAX  #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) @@ -79,6 +80,7 @@ struct crypto_user_alg {  	__u32 cru_flags;  }; +/* No longer supported, do not use. */  struct crypto_stat_aead {  	char type[CRYPTO_MAX_NAME];  	__u64 stat_encrypt_cnt; @@ -88,6 +90,7 @@ struct crypto_stat_aead {  	__u64 stat_err_cnt;  }; +/* No longer supported, do not use. */  struct crypto_stat_akcipher {  	char type[CRYPTO_MAX_NAME];  	__u64 stat_encrypt_cnt; @@ -99,6 +102,7 @@ struct crypto_stat_akcipher {  	__u64 stat_err_cnt;  }; +/* No longer supported, do not use. */  struct crypto_stat_cipher {  	char type[CRYPTO_MAX_NAME];  	__u64 stat_encrypt_cnt; @@ -108,6 +112,7 @@ struct crypto_stat_cipher {  	__u64 stat_err_cnt;  }; +/* No longer supported, do not use. */  struct crypto_stat_compress {  	char type[CRYPTO_MAX_NAME];  	__u64 stat_compress_cnt; @@ -117,6 +122,7 @@ struct crypto_stat_compress {  	__u64 stat_err_cnt;  }; +/* No longer supported, do not use. */  struct crypto_stat_hash {  	char type[CRYPTO_MAX_NAME];  	__u64 stat_hash_cnt; @@ -124,6 +130,7 @@ struct crypto_stat_hash {  	__u64 stat_err_cnt;  }; +/* No longer supported, do not use. */  struct crypto_stat_kpp {  	char type[CRYPTO_MAX_NAME];  	__u64 stat_setsecret_cnt; @@ -132,6 +139,7 @@ struct crypto_stat_kpp {  	__u64 stat_err_cnt;  }; +/* No longer supported, do not use. */  struct crypto_stat_rng {  	char type[CRYPTO_MAX_NAME];  	__u64 stat_generate_cnt; @@ -140,6 +148,7 @@ struct crypto_stat_rng {  	__u64 stat_err_cnt;  }; +/* No longer supported, do not use. */  struct crypto_stat_larval {  	char type[CRYPTO_MAX_NAME];  }; @@ -199,6 +208,10 @@ struct crypto_report_acomp {  	char type[CRYPTO_MAX_NAME];  }; +struct crypto_report_sig { +	char type[CRYPTO_MAX_NAME]; +}; +  #define CRYPTO_REPORT_MAXSIZE (sizeof(struct crypto_user_alg) + \  			       sizeof(struct crypto_report_blkcipher)) diff --git a/include/uapi/linux/cxl_mem.h b/include/uapi/linux/cxl_mem.h new file mode 100644 index 000000000000..c6c0fe27495d --- /dev/null +++ b/include/uapi/linux/cxl_mem.h @@ -0,0 +1,233 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * CXL IOCTLs for Memory Devices + */ + +#ifndef _UAPI_CXL_MEM_H_ +#define _UAPI_CXL_MEM_H_ + +#include <linux/types.h> + +/** + * DOC: UAPI + * + * Not all of the commands that the driver supports are available for use by + * userspace at all times.  Userspace can check the result of the QUERY command + * to determine the live set of commands.  Alternatively, it can issue the + * command and check for failure. + */ + +#define CXL_MEM_QUERY_COMMANDS _IOR(0xCE, 1, struct cxl_mem_query_commands) +#define CXL_MEM_SEND_COMMAND _IOWR(0xCE, 2, struct cxl_send_command) + +/* + * NOTE: New defines must be added to the end of the list to preserve + * compatibility because this enum is exported to user space. + */ +#define CXL_CMDS                                                          \ +	___C(INVALID, "Invalid Command"),                                 \ +	___C(IDENTIFY, "Identify Command"),                               \ +	___C(RAW, "Raw device command"),                                  \ +	___C(GET_SUPPORTED_LOGS, "Get Supported Logs"),                   \ +	___C(GET_FW_INFO, "Get FW Info"),                                 \ +	___C(GET_PARTITION_INFO, "Get Partition Information"),            \ +	___C(GET_LSA, "Get Label Storage Area"),                          \ +	___C(GET_HEALTH_INFO, "Get Health Info"),                         \ +	___C(GET_LOG, "Get Log"),                                         \ +	___C(SET_PARTITION_INFO, "Set Partition Information"),            \ +	___C(SET_LSA, "Set Label Storage Area"),                          \ +	___C(GET_ALERT_CONFIG, "Get Alert Configuration"),                \ +	___C(SET_ALERT_CONFIG, "Set Alert Configuration"),                \ +	___C(GET_SHUTDOWN_STATE, "Get Shutdown State"),                   \ +	___C(SET_SHUTDOWN_STATE, "Set Shutdown State"),                   \ +	___DEPRECATED(GET_POISON, "Get Poison List"),                     \ +	___DEPRECATED(INJECT_POISON, "Inject Poison"),                    \ +	___DEPRECATED(CLEAR_POISON, "Clear Poison"),                      \ +	___C(GET_SCAN_MEDIA_CAPS, "Get Scan Media Capabilities"),         \ +	___DEPRECATED(SCAN_MEDIA, "Scan Media"),                          \ +	___DEPRECATED(GET_SCAN_MEDIA, "Get Scan Media Results"),          \ +	___C(GET_TIMESTAMP, "Get Timestamp"),                             \ +	___C(GET_LOG_CAPS, "Get Log Capabilities"),			  \ +	___C(CLEAR_LOG, "Clear Log"),					  \ +	___C(GET_SUP_LOG_SUBLIST, "Get Supported Logs Sub-List"),	  \ +	___C(MAX, "invalid / last command") + +#define ___C(a, b) CXL_MEM_COMMAND_ID_##a +#define ___DEPRECATED(a, b) CXL_MEM_DEPRECATED_ID_##a +enum { CXL_CMDS }; + +#undef ___C +#undef ___DEPRECATED +#define ___C(a, b) { b } +#define ___DEPRECATED(a, b) { "Deprecated " b } +static const struct { +	const char *name; +} cxl_command_names[] __attribute__((__unused__)) = { CXL_CMDS }; + +/* + * Here's how this actually breaks out: + * cxl_command_names[] = { + *	[CXL_MEM_COMMAND_ID_INVALID] = { "Invalid Command" }, + *	[CXL_MEM_COMMAND_ID_IDENTIFY] = { "Identify Command" }, + *	... + *	[CXL_MEM_COMMAND_ID_MAX] = { "invalid / last command" }, + * }; + */ + +#undef ___C +#undef ___DEPRECATED +#define ___C(a, b) (0) +#define ___DEPRECATED(a, b) (1) + +static const __u8 cxl_deprecated_commands[] +	__attribute__((__unused__)) = { CXL_CMDS }; + +/* + * Here's how this actually breaks out: + * cxl_deprecated_commands[] = { + *	[CXL_MEM_COMMAND_ID_INVALID] = 0, + *	[CXL_MEM_COMMAND_ID_IDENTIFY] = 0, + *	... + *	[CXL_MEM_DEPRECATED_ID_GET_POISON] = 1, + *	[CXL_MEM_DEPRECATED_ID_INJECT_POISON] = 1, + *	[CXL_MEM_DEPRECATED_ID_CLEAR_POISON] = 1, + *	... + * }; + */ + +#undef ___C +#undef ___DEPRECATED + +/** + * struct cxl_command_info - Command information returned from a query. + * @id: ID number for the command. + * @flags: Flags that specify command behavior. + * + *         CXL_MEM_COMMAND_FLAG_USER_ENABLED + * + *         The given command id is supported by the driver and is supported by + *         a related opcode on the device. + * + *         CXL_MEM_COMMAND_FLAG_EXCLUSIVE + * + *         Requests with the given command id will terminate with EBUSY as the + *         kernel actively owns management of the given resource. For example, + *         the label-storage-area can not be written while the kernel is + *         actively managing that space. + * + * @size_in: Expected input size, or ~0 if variable length. + * @size_out: Expected output size, or ~0 if variable length. + * + * Represents a single command that is supported by both the driver and the + * hardware. This is returned as part of an array from the query ioctl. The + * following would be a command that takes a variable length input and returns 0 + * bytes of output. + * + *  - @id = 10 + *  - @flags = CXL_MEM_COMMAND_FLAG_ENABLED + *  - @size_in = ~0 + *  - @size_out = 0 + * + * See struct cxl_mem_query_commands. + */ +struct cxl_command_info { +	__u32 id; + +	__u32 flags; +#define CXL_MEM_COMMAND_FLAG_MASK		GENMASK(1, 0) +#define CXL_MEM_COMMAND_FLAG_ENABLED		BIT(0) +#define CXL_MEM_COMMAND_FLAG_EXCLUSIVE		BIT(1) + +	__u32 size_in; +	__u32 size_out; +}; + +/** + * struct cxl_mem_query_commands - Query supported commands. + * @n_commands: In/out parameter. When @n_commands is > 0, the driver will + *		return min(num_support_commands, n_commands). When @n_commands + *		is 0, driver will return the number of total supported commands. + * @rsvd: Reserved for future use. + * @commands: Output array of supported commands. This array must be allocated + *            by userspace to be at least min(num_support_commands, @n_commands) + * + * Allow userspace to query the available commands supported by both the driver, + * and the hardware. Commands that aren't supported by either the driver, or the + * hardware are not returned in the query. + * + * Examples: + * + *  - { .n_commands = 0 } // Get number of supported commands + *  - { .n_commands = 15, .commands = buf } // Return first 15 (or less) + *    supported commands + * + *  See struct cxl_command_info. + */ +struct cxl_mem_query_commands { +	/* +	 * Input: Number of commands to return (space allocated by user) +	 * Output: Number of commands supported by the driver/hardware +	 * +	 * If n_commands is 0, kernel will only return number of commands and +	 * not try to populate commands[], thus allowing userspace to know how +	 * much space to allocate +	 */ +	__u32 n_commands; +	__u32 rsvd; + +	struct cxl_command_info __user commands[]; /* out: supported commands */ +}; + +/** + * struct cxl_send_command - Send a command to a memory device. + * @id: The command to send to the memory device. This must be one of the + *	commands returned by the query command. + * @flags: Flags for the command (input). + * @raw: Special fields for raw commands + * @raw.opcode: Opcode passed to hardware when using the RAW command. + * @raw.rsvd: Must be zero. + * @rsvd: Must be zero. + * @retval: Return value from the memory device (output). + * @in: Parameters associated with input payload. + * @in.size: Size of the payload to provide to the device (input). + * @in.rsvd: Must be zero. + * @in.payload: Pointer to memory for payload input, payload is little endian. + * @out: Parameters associated with output payload. + * @out.size: Size of the payload received from the device (input/output). This + *	      field is filled in by userspace to let the driver know how much + *	      space was allocated for output. It is populated by the driver to + *	      let userspace know how large the output payload actually was. + * @out.rsvd: Must be zero. + * @out.payload: Pointer to memory for payload output, payload is little endian. + * + * Mechanism for userspace to send a command to the hardware for processing. The + * driver will do basic validation on the command sizes. In some cases even the + * payload may be introspected. Userspace is required to allocate large enough + * buffers for size_out which can be variable length in certain situations. + */ +struct cxl_send_command { +	__u32 id; +	__u32 flags; +	union { +		struct { +			__u16 opcode; +			__u16 rsvd; +		} raw; +		__u32 rsvd; +	}; +	__u32 retval; + +	struct { +		__u32 size; +		__u32 rsvd; +		__u64 payload; +	} in; + +	struct { +		__u32 size; +		__u32 rsvd; +		__u64 payload; +	} out; +}; + +#endif diff --git a/include/uapi/linux/cyclades.h b/include/uapi/linux/cyclades.h index fc0add2194a9..6225c5aebe06 100644 --- a/include/uapi/linux/cyclades.h +++ b/include/uapi/linux/cyclades.h @@ -1,109 +1,27 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* $Revision: 3.0 $$Date: 1998/11/02 14:20:59 $ - * linux/include/linux/cyclades.h - * - * This file was initially written by - * Randolph Bentson <bentson@grieg.seaslug.org> and is maintained by - * Ivan Passos <ivan@cyclades.com>. - * - * This file contains the general definitions for the cyclades.c driver - *$Log: cyclades.h,v $ - *Revision 3.1  2002/01/29 11:36:16  henrique - *added throttle field on struct cyclades_port to indicate whether the - *port is throttled or not - * - *Revision 3.1  2000/04/19 18:52:52  ivan - *converted address fields to unsigned long and added fields for physical - *addresses on cyclades_card structure; - * - *Revision 3.0  1998/11/02 14:20:59  ivan - *added nports field on cyclades_card structure; - * - *Revision 2.5  1998/08/03 16:57:01  ivan - *added cyclades_idle_stats structure; - *  - *Revision 2.4  1998/06/01 12:09:53  ivan - *removed closing_wait2 from cyclades_port structure; - * - *Revision 2.3  1998/03/16 18:01:12  ivan - *changes in the cyclades_port structure to get it closer to the  - *standard serial port structure; - *added constants for new ioctls; - * - *Revision 2.2  1998/02/17 16:50:00  ivan - *changes in the cyclades_port structure (addition of shutdown_wait and  - *chip_rev variables); - *added constants for new ioctls and for CD1400 rev. numbers. - * - *Revision 2.1	1997/10/24 16:03:00  ivan - *added rflow (which allows enabling the CD1400 special flow control  - *feature) and rtsdtr_inv (which allows DTR/RTS pin inversion) to  - *cyclades_port structure; - *added Alpha support - * - *Revision 2.0  1997/06/30 10:30:00  ivan - *added some new doorbell command constants related to IOCTLW and - *UART error signaling - * - *Revision 1.8  1997/06/03 15:30:00  ivan - *added constant ZFIRM_HLT - *added constant CyPCI_Ze_win ( = 2 * Cy_PCI_Zwin) - * - *Revision 1.7  1997/03/26 10:30:00  daniel - *new entries at the end of cyclades_port struct to reallocate - *variables illegally allocated within card memory. - * - *Revision 1.6  1996/09/09 18:35:30  bentson - *fold in changes for Cyclom-Z -- including structures for - *communicating with board as well modest changes to original - *structures to support new features. - * - *Revision 1.5  1995/11/13 21:13:31  bentson - *changes suggested by Michael Chastain <mec@duracef.shout.net> - *to support use of this file in non-kernel applications - * - * - */  #ifndef _UAPI_LINUX_CYCLADES_H  #define _UAPI_LINUX_CYCLADES_H -#include <linux/types.h> +#warning "Support for features provided by this header has been removed" +#warning "Please consider updating your code"  struct cyclades_monitor { -        unsigned long           int_count; -        unsigned long           char_count; -        unsigned long           char_max; -        unsigned long           char_last; -}; - -/* - * These stats all reflect activity since the device was last initialized. - * (i.e., since the port was opened with no other processes already having it - * open) - */ -struct cyclades_idle_stats { -    __kernel_old_time_t in_use;	/* Time device has been in use (secs) */ -    __kernel_old_time_t recv_idle; /* Time since last char received (secs) */ -    __kernel_old_time_t xmit_idle; /* Time since last char transmitted (secs) */ -    unsigned long  recv_bytes;	/* Bytes received */ -    unsigned long  xmit_bytes;	/* Bytes transmitted */ -    unsigned long  overruns;	/* Input overruns */ -    unsigned long  frame_errs;	/* Input framing errors */ -    unsigned long  parity_errs;	/* Input parity errors */ -}; - -#define CYCLADES_MAGIC  0x4359 - -#define CYGETMON                0x435901 -#define CYGETTHRESH             0x435902 -#define CYSETTHRESH             0x435903 -#define CYGETDEFTHRESH          0x435904 -#define CYSETDEFTHRESH          0x435905 -#define CYGETTIMEOUT            0x435906 -#define CYSETTIMEOUT            0x435907 -#define CYGETDEFTIMEOUT         0x435908 -#define CYSETDEFTIMEOUT         0x435909 +	unsigned long int_count; +	unsigned long char_count; +	unsigned long char_max; +	unsigned long char_last; +}; + +#define CYGETMON		0x435901 +#define CYGETTHRESH		0x435902 +#define CYSETTHRESH		0x435903 +#define CYGETDEFTHRESH		0x435904 +#define CYSETDEFTHRESH		0x435905 +#define CYGETTIMEOUT		0x435906 +#define CYSETTIMEOUT		0x435907 +#define CYGETDEFTIMEOUT		0x435908 +#define CYSETDEFTIMEOUT		0x435909  #define CYSETRFLOW		0x43590a  #define CYGETRFLOW		0x43590b  #define CYSETRTSDTR_INV		0x43590c @@ -111,384 +29,7 @@ struct cyclades_idle_stats {  #define CYZSETPOLLCYCLE		0x43590e  #define CYZGETPOLLCYCLE		0x43590f  #define CYGETCD1400VER		0x435910 -#define	CYSETWAIT		0x435912 -#define	CYGETWAIT		0x435913 - -/*************** CYCLOM-Z ADDITIONS ***************/ - -#define CZIOC           ('M' << 8) -#define CZ_NBOARDS      (CZIOC|0xfa) -#define CZ_BOOT_START   (CZIOC|0xfb) -#define CZ_BOOT_DATA    (CZIOC|0xfc) -#define CZ_BOOT_END     (CZIOC|0xfd) -#define CZ_TEST         (CZIOC|0xfe) - -#define CZ_DEF_POLL	(HZ/25) - -#define MAX_BOARD       4       /* Max number of boards */ -#define MAX_DEV         256     /* Max number of ports total */ -#define	CYZ_MAX_SPEED	921600 - -#define	CYZ_FIFO_SIZE	16 - -#define CYZ_BOOT_NWORDS 0x100 -struct CYZ_BOOT_CTRL { -        unsigned short  nboard; -        int             status[MAX_BOARD]; -        int             nchannel[MAX_BOARD]; -        int             fw_rev[MAX_BOARD]; -        unsigned long   offset; -        unsigned long   data[CYZ_BOOT_NWORDS]; -}; - - -#ifndef DP_WINDOW_SIZE -/* - *	Memory Window Sizes - */ - -#define	DP_WINDOW_SIZE		(0x00080000)	/* window size 512 Kb */ -#define	ZE_DP_WINDOW_SIZE	(0x00100000)	/* window size 1 Mb (Ze and -						  8Zo V.2 */ -#define	CTRL_WINDOW_SIZE	(0x00000080)	/* runtime regs 128 bytes */ - -/* - *	CUSTOM_REG - Cyclom-Z/PCI Custom Registers Set. The driver - *	normally will access only interested on the fpga_id, fpga_version, - *	start_cpu and stop_cpu. - */ - -struct	CUSTOM_REG { -	__u32	fpga_id;		/* FPGA Identification Register */ -	__u32	fpga_version;		/* FPGA Version Number Register */ -	__u32	cpu_start;		/* CPU start Register (write) */ -	__u32	cpu_stop;		/* CPU stop Register (write) */ -	__u32	misc_reg;		/* Miscellaneous Register */ -	__u32	idt_mode;		/* IDT mode Register */ -	__u32	uart_irq_status;	/* UART IRQ status Register */ -	__u32	clear_timer0_irq;	/* Clear timer interrupt Register */ -	__u32	clear_timer1_irq;	/* Clear timer interrupt Register */ -	__u32	clear_timer2_irq;	/* Clear timer interrupt Register */ -	__u32	test_register;		/* Test Register */ -	__u32	test_count;		/* Test Count Register */ -	__u32	timer_select;		/* Timer select register */ -	__u32	pr_uart_irq_status;	/* Prioritized UART IRQ stat Reg */ -	__u32	ram_wait_state;		/* RAM wait-state Register */ -	__u32	uart_wait_state;	/* UART wait-state Register */ -	__u32	timer_wait_state;	/* timer wait-state Register */ -	__u32	ack_wait_state;		/* ACK wait State Register */ -}; - -/* - *	RUNTIME_9060 - PLX PCI9060ES local configuration and shared runtime - *	registers. This structure can be used to access the 9060 registers - *	(memory mapped). - */ - -struct RUNTIME_9060 { -	__u32	loc_addr_range;	/* 00h - Local Address Range */ -	__u32	loc_addr_base;	/* 04h - Local Address Base */ -	__u32	loc_arbitr;	/* 08h - Local Arbitration */ -	__u32	endian_descr;	/* 0Ch - Big/Little Endian Descriptor */ -	__u32	loc_rom_range;	/* 10h - Local ROM Range */ -	__u32	loc_rom_base;	/* 14h - Local ROM Base */ -	__u32	loc_bus_descr;	/* 18h - Local Bus descriptor */ -	__u32	loc_range_mst;	/* 1Ch - Local Range for Master to PCI */ -	__u32	loc_base_mst;	/* 20h - Local Base for Master PCI */ -	__u32	loc_range_io;	/* 24h - Local Range for Master IO */ -	__u32	pci_base_mst;	/* 28h - PCI Base for Master PCI */ -	__u32	pci_conf_io;	/* 2Ch - PCI configuration for Master IO */ -	__u32	filler1;	/* 30h */ -	__u32	filler2;	/* 34h */ -	__u32	filler3;	/* 38h */ -	__u32	filler4;	/* 3Ch */ -	__u32	mail_box_0;	/* 40h - Mail Box 0 */ -	__u32	mail_box_1;	/* 44h - Mail Box 1 */ -	__u32	mail_box_2;	/* 48h - Mail Box 2 */ -	__u32	mail_box_3;	/* 4Ch - Mail Box 3 */ -	__u32	filler5;	/* 50h */ -	__u32	filler6;	/* 54h */ -	__u32	filler7;	/* 58h */ -	__u32	filler8;	/* 5Ch */ -	__u32	pci_doorbell;	/* 60h - PCI to Local Doorbell */ -	__u32	loc_doorbell;	/* 64h - Local to PCI Doorbell */ -	__u32	intr_ctrl_stat;	/* 68h - Interrupt Control/Status */ -	__u32	init_ctrl;	/* 6Ch - EEPROM control, Init Control, etc */ -}; - -/* Values for the Local Base Address re-map register */ - -#define	WIN_RAM		0x00000001L	/* set the sliding window to RAM */ -#define	WIN_CREG	0x14000001L	/* set the window to custom Registers */ - -/* Values timer select registers */ - -#define	TIMER_BY_1M	0x00		/* clock divided by 1M */ -#define	TIMER_BY_256K	0x01		/* clock divided by 256k */ -#define	TIMER_BY_128K	0x02		/* clock divided by 128k */ -#define	TIMER_BY_32K	0x03		/* clock divided by 32k */ - -/****************** ****************** *******************/ -#endif - -#ifndef ZFIRM_ID -/* #include "zfwint.h" */ -/****************** ****************** *******************/ -/* - *	This file contains the definitions for interfacing with the - *	Cyclom-Z ZFIRM Firmware. - */ - -/* General Constant definitions */ - -#define	MAX_CHAN	64		/* max number of channels per board */ - -/* firmware id structure (set after boot) */ - -#define ID_ADDRESS	0x00000180L	/* signature/pointer address */ -#define	ZFIRM_ID	0x5557465AL	/* ZFIRM/U signature */ -#define	ZFIRM_HLT	0x59505B5CL	/* ZFIRM needs external power supply */ -#define	ZFIRM_RST	0x56040674L	/* RST signal (due to FW reset) */ - -#define	ZF_TINACT_DEF	1000		/* default inactivity timeout  -					   (1000 ms) */ -#define	ZF_TINACT	ZF_TINACT_DEF - -struct	FIRM_ID { -	__u32	signature;		/* ZFIRM/U signature */ -	__u32	zfwctrl_addr;		/* pointer to ZFW_CTRL structure */ -}; - -/* Op. System id */ - -#define	C_OS_LINUX	0x00000030	/* generic Linux system */ - -/* channel op_mode */ - -#define	C_CH_DISABLE	0x00000000	/* channel is disabled */ -#define	C_CH_TXENABLE	0x00000001	/* channel Tx enabled */ -#define	C_CH_RXENABLE	0x00000002	/* channel Rx enabled */ -#define	C_CH_ENABLE	0x00000003	/* channel Tx/Rx enabled */ -#define	C_CH_LOOPBACK	0x00000004	/* Loopback mode */ - -/* comm_parity - parity */ - -#define	C_PR_NONE	0x00000000	/* None */ -#define	C_PR_ODD	0x00000001	/* Odd */ -#define C_PR_EVEN	0x00000002	/* Even */ -#define C_PR_MARK	0x00000004	/* Mark */ -#define C_PR_SPACE	0x00000008	/* Space */ -#define C_PR_PARITY	0x000000ff - -#define	C_PR_DISCARD	0x00000100	/* discard char with frame/par error */ -#define C_PR_IGNORE	0x00000200	/* ignore frame/par error */ - -/* comm_data_l - data length and stop bits */ - -#define C_DL_CS5	0x00000001 -#define C_DL_CS6	0x00000002 -#define C_DL_CS7	0x00000004 -#define C_DL_CS8	0x00000008 -#define	C_DL_CS		0x0000000f -#define C_DL_1STOP	0x00000010 -#define C_DL_15STOP	0x00000020 -#define C_DL_2STOP	0x00000040 -#define	C_DL_STOP	0x000000f0 - -/* interrupt enabling/status */ - -#define	C_IN_DISABLE	0x00000000	/* zero, disable interrupts */ -#define	C_IN_TXBEMPTY	0x00000001	/* tx buffer empty */ -#define	C_IN_TXLOWWM	0x00000002	/* tx buffer below LWM */ -#define	C_IN_RXHIWM	0x00000010	/* rx buffer above HWM */ -#define	C_IN_RXNNDT	0x00000020	/* rx no new data timeout */ -#define	C_IN_MDCD	0x00000100	/* modem DCD change */ -#define	C_IN_MDSR	0x00000200	/* modem DSR change */ -#define	C_IN_MRI	0x00000400	/* modem RI change */ -#define	C_IN_MCTS	0x00000800	/* modem CTS change */ -#define	C_IN_RXBRK	0x00001000	/* Break received */ -#define	C_IN_PR_ERROR	0x00002000	/* parity error */ -#define	C_IN_FR_ERROR	0x00004000	/* frame error */ -#define C_IN_OVR_ERROR  0x00008000      /* overrun error */ -#define C_IN_RXOFL	0x00010000      /* RX buffer overflow */ -#define C_IN_IOCTLW	0x00020000      /* I/O control w/ wait */ -#define C_IN_MRTS	0x00040000	/* modem RTS drop */ -#define C_IN_ICHAR	0x00080000 -  -/* flow control */ - -#define	C_FL_OXX	0x00000001	/* output Xon/Xoff flow control */ -#define	C_FL_IXX	0x00000002	/* output Xon/Xoff flow control */ -#define C_FL_OIXANY	0x00000004	/* output Xon/Xoff (any xon) */ -#define	C_FL_SWFLOW	0x0000000f - -/* flow status */ - -#define	C_FS_TXIDLE	0x00000000	/* no Tx data in the buffer or UART */ -#define	C_FS_SENDING	0x00000001	/* UART is sending data */ -#define	C_FS_SWFLOW	0x00000002	/* Tx is stopped by received Xoff */ - -/* rs_control/rs_status RS-232 signals */ - -#define C_RS_PARAM	0x80000000	/* Indicates presence of parameter in  -					   IOCTLM command */ -#define	C_RS_RTS	0x00000001	/* RTS */ -#define	C_RS_DTR	0x00000004	/* DTR */ -#define	C_RS_DCD	0x00000100	/* CD */ -#define	C_RS_DSR	0x00000200	/* DSR */ -#define	C_RS_RI		0x00000400	/* RI */ -#define	C_RS_CTS	0x00000800	/* CTS */ - -/* commands Host <-> Board */ - -#define	C_CM_RESET	0x01		/* reset/flush buffers */ -#define	C_CM_IOCTL	0x02		/* re-read CH_CTRL */ -#define	C_CM_IOCTLW	0x03		/* re-read CH_CTRL, intr when done */ -#define	C_CM_IOCTLM	0x04		/* RS-232 outputs change */ -#define	C_CM_SENDXOFF	0x10		/* send Xoff */ -#define	C_CM_SENDXON	0x11		/* send Xon */ -#define C_CM_CLFLOW	0x12		/* Clear flow control (resume) */ -#define	C_CM_SENDBRK	0x41		/* send break */ -#define	C_CM_INTBACK	0x42		/* Interrupt back */ -#define	C_CM_SET_BREAK	0x43		/* Tx break on */ -#define	C_CM_CLR_BREAK	0x44		/* Tx break off */ -#define	C_CM_CMD_DONE	0x45		/* Previous command done */ -#define C_CM_INTBACK2	0x46		/* Alternate Interrupt back */ -#define	C_CM_TINACT	0x51		/* set inactivity detection */ -#define	C_CM_IRQ_ENBL	0x52		/* enable generation of interrupts */ -#define	C_CM_IRQ_DSBL	0x53		/* disable generation of interrupts */ -#define	C_CM_ACK_ENBL	0x54		/* enable acknowledged interrupt mode */ -#define	C_CM_ACK_DSBL	0x55		/* disable acknowledged intr mode */ -#define	C_CM_FLUSH_RX	0x56		/* flushes Rx buffer */ -#define	C_CM_FLUSH_TX	0x57		/* flushes Tx buffer */ -#define C_CM_Q_ENABLE	0x58		/* enables queue access from the  -					   driver */ -#define C_CM_Q_DISABLE  0x59            /* disables queue access from the  -					   driver */ - -#define	C_CM_TXBEMPTY	0x60		/* Tx buffer is empty */ -#define	C_CM_TXLOWWM	0x61		/* Tx buffer low water mark */ -#define	C_CM_RXHIWM	0x62		/* Rx buffer high water mark */ -#define	C_CM_RXNNDT	0x63		/* rx no new data timeout */ -#define	C_CM_TXFEMPTY	0x64 -#define	C_CM_ICHAR	0x65 -#define	C_CM_MDCD	0x70		/* modem DCD change */ -#define	C_CM_MDSR	0x71		/* modem DSR change */ -#define	C_CM_MRI	0x72		/* modem RI change */ -#define	C_CM_MCTS	0x73		/* modem CTS change */ -#define C_CM_MRTS	0x74		/* modem RTS drop */ -#define	C_CM_RXBRK	0x84		/* Break received */ -#define	C_CM_PR_ERROR	0x85		/* Parity error */ -#define	C_CM_FR_ERROR	0x86		/* Frame error */ -#define C_CM_OVR_ERROR  0x87            /* Overrun error */ -#define C_CM_RXOFL	0x88            /* RX buffer overflow */ -#define	C_CM_CMDERROR	0x90		/* command error */ -#define	C_CM_FATAL	0x91		/* fatal error */ -#define	C_CM_HW_RESET	0x92		/* reset board */ - -/* - *	CH_CTRL - This per port structure contains all parameters - *	that control an specific port. It can be seen as the - *	configuration registers of a "super-serial-controller". - */ - -struct CH_CTRL { -	__u32	op_mode;	/* operation mode */ -	__u32	intr_enable;	/* interrupt masking */ -	__u32	sw_flow;	/* SW flow control */ -	__u32	flow_status;	/* output flow status */ -	__u32	comm_baud;	/* baud rate  - numerically specified */ -	__u32	comm_parity;	/* parity */ -	__u32	comm_data_l;	/* data length/stop */ -	__u32	comm_flags;	/* other flags */ -	__u32	hw_flow;	/* HW flow control */ -	__u32	rs_control;	/* RS-232 outputs */ -	__u32	rs_status;	/* RS-232 inputs */ -	__u32	flow_xon;	/* xon char */ -	__u32	flow_xoff;	/* xoff char */ -	__u32	hw_overflow;	/* hw overflow counter */ -	__u32	sw_overflow;	/* sw overflow counter */ -	__u32	comm_error;	/* frame/parity error counter */ -	__u32 ichar; -	__u32 filler[7]; -}; - - -/* - *	BUF_CTRL - This per channel structure contains - *	all Tx and Rx buffer control for a given channel. - */ - -struct	BUF_CTRL	{ -	__u32	flag_dma;	/* buffers are in Host memory */ -	__u32	tx_bufaddr;	/* address of the tx buffer */ -	__u32	tx_bufsize;	/* tx buffer size */ -	__u32	tx_threshold;	/* tx low water mark */ -	__u32	tx_get;		/* tail index tx buf */ -	__u32	tx_put;		/* head index tx buf */ -	__u32	rx_bufaddr;	/* address of the rx buffer */ -	__u32	rx_bufsize;	/* rx buffer size */ -	__u32	rx_threshold;	/* rx high water mark */ -	__u32	rx_get;		/* tail index rx buf */ -	__u32	rx_put;		/* head index rx buf */ -	__u32	filler[5];	/* filler to align structures */ -}; - -/* - *	BOARD_CTRL - This per board structure contains all global  - *	control fields related to the board. - */ - -struct BOARD_CTRL { - -	/* static info provided by the on-board CPU */ -	__u32	n_channel;	/* number of channels */ -	__u32	fw_version;	/* firmware version */ - -	/* static info provided by the driver */ -	__u32	op_system;	/* op_system id */ -	__u32	dr_version;	/* driver version */ - -	/* board control area */ -	__u32	inactivity;	/* inactivity control */ - -	/* host to FW commands */ -	__u32	hcmd_channel;	/* channel number */ -	__u32	hcmd_param;	/* pointer to parameters */ - -	/* FW to Host commands */ -	__u32	fwcmd_channel;	/* channel number */ -	__u32	fwcmd_param;	/* pointer to parameters */ -	__u32	zf_int_queue_addr; /* offset for INT_QUEUE structure */ - -	/* filler so the structures are aligned */ -	__u32	filler[6]; -}; - -/* Host Interrupt Queue */ - -#define QUEUE_SIZE	(10*MAX_CHAN) - -struct	INT_QUEUE { -	unsigned char	intr_code[QUEUE_SIZE]; -	unsigned long	channel[QUEUE_SIZE]; -	unsigned long	param[QUEUE_SIZE]; -	unsigned long	put; -	unsigned long	get; -}; - -/* - *	ZFW_CTRL - This is the data structure that includes all other - *	data structures used by the Firmware. - */ -  -struct ZFW_CTRL { -	struct BOARD_CTRL	board_ctrl; -	struct CH_CTRL		ch_ctrl[MAX_CHAN]; -	struct BUF_CTRL		buf_ctrl[MAX_CHAN]; -}; - -/****************** ****************** *******************/ -#endif +#define CYSETWAIT		0x435912 +#define CYGETWAIT		0x435913  #endif /* _UAPI_LINUX_CYCLADES_H */ diff --git a/include/uapi/linux/cycx_cfm.h b/include/uapi/linux/cycx_cfm.h index 51f541942ff9..91778c8024b1 100644 --- a/include/uapi/linux/cycx_cfm.h +++ b/include/uapi/linux/cycx_cfm.h @@ -91,7 +91,7 @@ struct cycx_firmware {  	unsigned short	    reserved[6];  	char		    descr[CFM_DESCR_LEN];  	struct cycx_fw_info info; -	unsigned char	    image[0]; +	unsigned char	    image[];  };  struct cycx_fw_header { diff --git a/include/uapi/linux/dcbnl.h b/include/uapi/linux/dcbnl.h index a791a94013a6..7e15214aa5dd 100644 --- a/include/uapi/linux/dcbnl.h +++ b/include/uapi/linux/dcbnl.h @@ -218,6 +218,9 @@ struct cee_pfc {  #define IEEE_8021QAZ_APP_SEL_ANY	4  #define IEEE_8021QAZ_APP_SEL_DSCP       5 +/* Non-std selector values */ +#define DCB_APP_SEL_PCP 255 +  /* This structure contains the IEEE 802.1Qaz APP managed object. This   * object is also used for the CEE std as well.   * @@ -247,6 +250,8 @@ struct dcb_app {  	__u16	protocol;  }; +#define IEEE_8021QAZ_APP_SEL_MAX 255 +  /**   * struct dcb_peer_app_info - APP feature information sent by the peer   * @@ -405,6 +410,8 @@ enum dcbnl_attrs {   * @DCB_ATTR_IEEE_PEER_ETS: peer ETS configuration - get only   * @DCB_ATTR_IEEE_PEER_PFC: peer PFC configuration - get only   * @DCB_ATTR_IEEE_PEER_APP: peer APP tlv - get only + * @DCB_ATTR_DCB_APP_TRUST_TABLE: selector trust table + * @DCB_ATTR_DCB_REWR_TABLE: rewrite configuration   */  enum ieee_attrs {  	DCB_ATTR_IEEE_UNSPEC, @@ -418,6 +425,8 @@ enum ieee_attrs {  	DCB_ATTR_IEEE_QCN,  	DCB_ATTR_IEEE_QCN_STATS,  	DCB_ATTR_DCB_BUFFER, +	DCB_ATTR_DCB_APP_TRUST_TABLE, +	DCB_ATTR_DCB_REWR_TABLE,  	__DCB_ATTR_IEEE_MAX  };  #define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1) @@ -425,6 +434,7 @@ enum ieee_attrs {  enum ieee_attrs_app {  	DCB_ATTR_IEEE_APP_UNSPEC,  	DCB_ATTR_IEEE_APP, +	DCB_ATTR_DCB_APP,  	__DCB_ATTR_IEEE_APP_MAX  };  #define DCB_ATTR_IEEE_APP_MAX (__DCB_ATTR_IEEE_APP_MAX - 1) diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index cfef4245ea5a..9fcb25a0f447 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -13,6 +13,8 @@  #ifndef _UAPI_LINUX_DEVLINK_H_  #define _UAPI_LINUX_DEVLINK_H_ +#include <linux/const.h> +  #define DEVLINK_GENL_NAME "devlink"  #define DEVLINK_GENL_VERSION 0x1  #define DEVLINK_GENL_MCGRP_CONFIG_NAME "config" @@ -122,6 +124,23 @@ enum devlink_command {  	DEVLINK_CMD_TRAP_POLICER_NEW,  	DEVLINK_CMD_TRAP_POLICER_DEL, +	DEVLINK_CMD_HEALTH_REPORTER_TEST, + +	DEVLINK_CMD_RATE_GET,		/* can dump */ +	DEVLINK_CMD_RATE_SET, +	DEVLINK_CMD_RATE_NEW, +	DEVLINK_CMD_RATE_DEL, + +	DEVLINK_CMD_LINECARD_GET,		/* can dump */ +	DEVLINK_CMD_LINECARD_SET, +	DEVLINK_CMD_LINECARD_NEW, +	DEVLINK_CMD_LINECARD_DEL, + +	DEVLINK_CMD_SELFTESTS_GET,	/* can dump */ +	DEVLINK_CMD_SELFTESTS_RUN, + +	DEVLINK_CMD_NOTIFY_FILTER_SET, +  	/* add new commands above here */  	__DEVLINK_CMD_MAX,  	DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 @@ -193,6 +212,23 @@ enum devlink_port_flavour {  				      * port that faces the PCI VF.  				      */  	DEVLINK_PORT_FLAVOUR_VIRTUAL, /* Any virtual port facing the user. */ +	DEVLINK_PORT_FLAVOUR_UNUSED, /* Port which exists in the switch, but +				      * is not used in any way. +				      */ +	DEVLINK_PORT_FLAVOUR_PCI_SF, /* Represents eswitch port +				      * for the PCI SF. It is an internal +				      * port that faces the PCI SF. +				      */ +}; + +/* IEEE 802.1Qaz standard supported values. */ + +#define DEVLINK_RATE_TCS_MAX 8 +#define DEVLINK_RATE_TC_INDEX_MAX (DEVLINK_RATE_TCS_MAX - 1) + +enum devlink_rate_type { +	DEVLINK_RATE_TYPE_LEAF, +	DEVLINK_RATE_TYPE_NODE,  };  enum devlink_param_cmode { @@ -228,6 +264,52 @@ enum {  	DEVLINK_ATTR_STATS_MAX = __DEVLINK_ATTR_STATS_MAX - 1  }; +/* Specify what sections of a flash component can be overwritten when + * performing an update. Overwriting of firmware binary sections is always + * implicitly assumed to be allowed. + * + * Each section must be documented in + * Documentation/networking/devlink/devlink-flash.rst + * + */ +enum devlink_flash_overwrite { +	DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT, +	DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT, + +	__DEVLINK_FLASH_OVERWRITE_MAX_BIT, +	DEVLINK_FLASH_OVERWRITE_MAX_BIT = __DEVLINK_FLASH_OVERWRITE_MAX_BIT - 1 +}; + +#define DEVLINK_FLASH_OVERWRITE_SETTINGS _BITUL(DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT) +#define DEVLINK_FLASH_OVERWRITE_IDENTIFIERS _BITUL(DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT) + +#define DEVLINK_SUPPORTED_FLASH_OVERWRITE_SECTIONS \ +	(_BITUL(__DEVLINK_FLASH_OVERWRITE_MAX_BIT) - 1) + +enum devlink_attr_selftest_id { +	DEVLINK_ATTR_SELFTEST_ID_UNSPEC, +	DEVLINK_ATTR_SELFTEST_ID_FLASH,	/* flag */ + +	__DEVLINK_ATTR_SELFTEST_ID_MAX, +	DEVLINK_ATTR_SELFTEST_ID_MAX = __DEVLINK_ATTR_SELFTEST_ID_MAX - 1 +}; + +enum devlink_selftest_status { +	DEVLINK_SELFTEST_STATUS_SKIP, +	DEVLINK_SELFTEST_STATUS_PASS, +	DEVLINK_SELFTEST_STATUS_FAIL +}; + +enum devlink_attr_selftest_result { +	DEVLINK_ATTR_SELFTEST_RESULT_UNSPEC, +	DEVLINK_ATTR_SELFTEST_RESULT,		/* nested */ +	DEVLINK_ATTR_SELFTEST_RESULT_ID,	/* u32, enum devlink_attr_selftest_id */ +	DEVLINK_ATTR_SELFTEST_RESULT_STATUS,	/* u8, enum devlink_selftest_status */ + +	__DEVLINK_ATTR_SELFTEST_RESULT_MAX, +	DEVLINK_ATTR_SELFTEST_RESULT_MAX = __DEVLINK_ATTR_SELFTEST_RESULT_MAX - 1 +}; +  /**   * enum devlink_trap_action - Packet trap action.   * @DEVLINK_TRAP_ACTION_DROP: Packet is dropped by the device and a copy is not @@ -272,6 +354,57 @@ enum {  	DEVLINK_ATTR_TRAP_METADATA_TYPE_FA_COOKIE,  }; +enum devlink_reload_action { +	DEVLINK_RELOAD_ACTION_UNSPEC, +	DEVLINK_RELOAD_ACTION_DRIVER_REINIT,	/* Driver entities re-instantiation */ +	DEVLINK_RELOAD_ACTION_FW_ACTIVATE,	/* FW activate */ + +	/* Add new reload actions above */ +	__DEVLINK_RELOAD_ACTION_MAX, +	DEVLINK_RELOAD_ACTION_MAX = __DEVLINK_RELOAD_ACTION_MAX - 1 +}; + +enum devlink_reload_limit { +	DEVLINK_RELOAD_LIMIT_UNSPEC,	/* unspecified, no constraints */ +	DEVLINK_RELOAD_LIMIT_NO_RESET,	/* No reset allowed, no down time allowed, +					 * no link flap and no configuration is lost. +					 */ + +	/* Add new reload limit above */ +	__DEVLINK_RELOAD_LIMIT_MAX, +	DEVLINK_RELOAD_LIMIT_MAX = __DEVLINK_RELOAD_LIMIT_MAX - 1 +}; + +#define DEVLINK_RELOAD_LIMITS_VALID_MASK (_BITUL(__DEVLINK_RELOAD_LIMIT_MAX) - 1) + +enum devlink_linecard_state { +	DEVLINK_LINECARD_STATE_UNSPEC, +	DEVLINK_LINECARD_STATE_UNPROVISIONED, +	DEVLINK_LINECARD_STATE_UNPROVISIONING, +	DEVLINK_LINECARD_STATE_PROVISIONING, +	DEVLINK_LINECARD_STATE_PROVISIONING_FAILED, +	DEVLINK_LINECARD_STATE_PROVISIONED, +	DEVLINK_LINECARD_STATE_ACTIVE, + +	__DEVLINK_LINECARD_STATE_MAX, +	DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX - 1 +}; + +/* Variable attribute type. */ +enum devlink_var_attr_type { +	/* Following values relate to the internal NLA_* values */ +	DEVLINK_VAR_ATTR_TYPE_U8 = 1, +	DEVLINK_VAR_ATTR_TYPE_U16, +	DEVLINK_VAR_ATTR_TYPE_U32, +	DEVLINK_VAR_ATTR_TYPE_U64, +	DEVLINK_VAR_ATTR_TYPE_STRING, +	DEVLINK_VAR_ATTR_TYPE_FLAG, +	DEVLINK_VAR_ATTR_TYPE_NUL_STRING = 10, +	DEVLINK_VAR_ATTR_TYPE_BINARY, +	__DEVLINK_VAR_ATTR_TYPE_CUSTOM_BASE = 0x80, +	/* Any possible custom types, unrelated to NLA_* values go below */ +}; +  enum devlink_attr {  	/* don't change the order or add anything between, this is ABI! */  	DEVLINK_ATTR_UNSPEC, @@ -458,12 +591,69 @@ enum devlink_attr {  	DEVLINK_ATTR_PORT_LANES,			/* u32 */  	DEVLINK_ATTR_PORT_SPLITTABLE,			/* u8 */ -	/* add new attributes above here, update the policy in devlink.c */ +	DEVLINK_ATTR_PORT_EXTERNAL,		/* u8 */ +	DEVLINK_ATTR_PORT_CONTROLLER_NUMBER,	/* u32 */ + +	DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT,	/* u64 */ +	DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK,	/* bitfield32 */ + +	DEVLINK_ATTR_RELOAD_ACTION,		/* u8 */ +	DEVLINK_ATTR_RELOAD_ACTIONS_PERFORMED,	/* bitfield32 */ +	DEVLINK_ATTR_RELOAD_LIMITS,		/* bitfield32 */ + +	DEVLINK_ATTR_DEV_STATS,			/* nested */ +	DEVLINK_ATTR_RELOAD_STATS,		/* nested */ +	DEVLINK_ATTR_RELOAD_STATS_ENTRY,	/* nested */ +	DEVLINK_ATTR_RELOAD_STATS_LIMIT,	/* u8 */ +	DEVLINK_ATTR_RELOAD_STATS_VALUE,	/* u32 */ +	DEVLINK_ATTR_REMOTE_RELOAD_STATS,	/* nested */ +	DEVLINK_ATTR_RELOAD_ACTION_INFO,        /* nested */ +	DEVLINK_ATTR_RELOAD_ACTION_STATS,       /* nested */ + +	DEVLINK_ATTR_PORT_PCI_SF_NUMBER,	/* u32 */ + +	DEVLINK_ATTR_RATE_TYPE,			/* u16 */ +	DEVLINK_ATTR_RATE_TX_SHARE,		/* u64 */ +	DEVLINK_ATTR_RATE_TX_MAX,		/* u64 */ +	DEVLINK_ATTR_RATE_NODE_NAME,		/* string */ +	DEVLINK_ATTR_RATE_PARENT_NODE_NAME,	/* string */ + +	DEVLINK_ATTR_REGION_MAX_SNAPSHOTS,	/* u32 */ + +	DEVLINK_ATTR_LINECARD_INDEX,		/* u32 */ +	DEVLINK_ATTR_LINECARD_STATE,		/* u8 */ +	DEVLINK_ATTR_LINECARD_TYPE,		/* string */ +	DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES,	/* nested */ + +	DEVLINK_ATTR_NESTED_DEVLINK,		/* nested */ + +	DEVLINK_ATTR_SELFTESTS,			/* nested */ + +	DEVLINK_ATTR_RATE_TX_PRIORITY,		/* u32 */ +	DEVLINK_ATTR_RATE_TX_WEIGHT,		/* u32 */ + +	DEVLINK_ATTR_REGION_DIRECT,		/* flag */ + +	DEVLINK_ATTR_RATE_TC_BWS,		/* nested */ + +	/* Add new attributes above here, update the spec in +	 * Documentation/netlink/specs/devlink.yaml and re-generate +	 * net/devlink/netlink_gen.c. +	 */  	__DEVLINK_ATTR_MAX,  	DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1  }; +enum devlink_rate_tc_attr { +	DEVLINK_RATE_TC_ATTR_UNSPEC, +	DEVLINK_RATE_TC_ATTR_INDEX,		/* u8 */ +	DEVLINK_RATE_TC_ATTR_BW,		/* u32 */ + +	__DEVLINK_RATE_TC_ATTR_MAX, +	DEVLINK_RATE_TC_ATTR_MAX = __DEVLINK_RATE_TC_ATTR_MAX - 1 +}; +  /* Mapping between internal resource described by the field and system   * structure   */ @@ -504,12 +694,51 @@ enum devlink_resource_unit {  	DEVLINK_RESOURCE_UNIT_ENTRY,  }; +enum devlink_port_fn_attr_cap { +	DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT, +	DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT, +	DEVLINK_PORT_FN_ATTR_CAP_IPSEC_CRYPTO_BIT, +	DEVLINK_PORT_FN_ATTR_CAP_IPSEC_PACKET_BIT, + +	/* Add new caps above */ +	__DEVLINK_PORT_FN_ATTR_CAPS_MAX, +}; + +#define DEVLINK_PORT_FN_CAP_ROCE _BITUL(DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT) +#define DEVLINK_PORT_FN_CAP_MIGRATABLE \ +	_BITUL(DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT) +#define DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO _BITUL(DEVLINK_PORT_FN_ATTR_CAP_IPSEC_CRYPTO_BIT) +#define DEVLINK_PORT_FN_CAP_IPSEC_PACKET _BITUL(DEVLINK_PORT_FN_ATTR_CAP_IPSEC_PACKET_BIT) +  enum devlink_port_function_attr {  	DEVLINK_PORT_FUNCTION_ATTR_UNSPEC,  	DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR,	/* binary */ +	DEVLINK_PORT_FN_ATTR_STATE,	/* u8 */ +	DEVLINK_PORT_FN_ATTR_OPSTATE,	/* u8 */ +	DEVLINK_PORT_FN_ATTR_CAPS,	/* bitfield32 */ +	DEVLINK_PORT_FN_ATTR_DEVLINK,	/* nested */ +	DEVLINK_PORT_FN_ATTR_MAX_IO_EQS,	/* u32 */  	__DEVLINK_PORT_FUNCTION_ATTR_MAX,  	DEVLINK_PORT_FUNCTION_ATTR_MAX = __DEVLINK_PORT_FUNCTION_ATTR_MAX - 1  }; +enum devlink_port_fn_state { +	DEVLINK_PORT_FN_STATE_INACTIVE, +	DEVLINK_PORT_FN_STATE_ACTIVE, +}; + +/** + * enum devlink_port_fn_opstate - indicates operational state of the function + * @DEVLINK_PORT_FN_OPSTATE_ATTACHED: Driver is attached to the function. + * For graceful tear down of the function, after inactivation of the + * function, user should wait for operational state to turn DETACHED. + * @DEVLINK_PORT_FN_OPSTATE_DETACHED: Driver is detached from the function. + * It is safe to delete the port. + */ +enum devlink_port_fn_opstate { +	DEVLINK_PORT_FN_OPSTATE_DETACHED, +	DEVLINK_PORT_FN_OPSTATE_ATTACHED, +}; +  #endif /* _UAPI_LINUX_DEVLINK_H_ */ diff --git a/include/uapi/linux/dlm.h b/include/uapi/linux/dlm.h index 0d2eca287567..4eaf835780b0 100644 --- a/include/uapi/linux/dlm.h +++ b/include/uapi/linux/dlm.h @@ -68,9 +68,11 @@ struct dlm_lksb {  /* dlm_new_lockspace() flags */ +/* DLM_LSFL_TIMEWARN is deprecated and reserved. DO NOT USE! */  #define DLM_LSFL_TIMEWARN	0x00000002 -#define DLM_LSFL_FS     	0x00000004  #define DLM_LSFL_NEWEXCL     	0x00000008 +/* currently reserved due in-kernel use */ +#define __DLM_LSFL_RESERVED0	0x00000010  #endif /* _UAPI__DLM_DOT_H__ */ diff --git a/include/uapi/linux/dlm_device.h b/include/uapi/linux/dlm_device.h index f880d2831160..e83954c69fff 100644 --- a/include/uapi/linux/dlm_device.h +++ b/include/uapi/linux/dlm_device.h @@ -45,13 +45,13 @@ struct dlm_lock_params {  	void __user *bastaddr;  	struct dlm_lksb __user *lksb;  	char lvb[DLM_USER_LVB_LEN]; -	char name[0]; +	char name[];  };  struct dlm_lspace_params {  	__u32 flags;  	__u32 minor; -	char name[0]; +	char name[];  };  struct dlm_purge_params { diff --git a/include/uapi/linux/dlm_netlink.h b/include/uapi/linux/dlm_netlink.h deleted file mode 100644 index 5dc3a67d353d..000000000000 --- a/include/uapi/linux/dlm_netlink.h +++ /dev/null @@ -1,60 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * Copyright (C) 2007 Red Hat, Inc.  All rights reserved. - * - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. - */ - -#ifndef _DLM_NETLINK_H -#define _DLM_NETLINK_H - -#include <linux/types.h> -#include <linux/dlmconstants.h> - -enum { -	DLM_STATUS_WAITING = 1, -	DLM_STATUS_GRANTED = 2, -	DLM_STATUS_CONVERT = 3, -}; - -#define DLM_LOCK_DATA_VERSION 1 - -struct dlm_lock_data { -	__u16 version; -	__u32 lockspace_id; -	int nodeid; -	int ownpid; -	__u32 id; -	__u32 remid; -	__u64 xid; -	__s8 status; -	__s8 grmode; -	__s8 rqmode; -	unsigned long timestamp; -	int resource_namelen; -	char resource_name[DLM_RESNAME_MAXLEN]; -}; - -enum { -	DLM_CMD_UNSPEC = 0, -	DLM_CMD_HELLO,		/* user->kernel */ -	DLM_CMD_TIMEOUT,	/* kernel->user */ -	__DLM_CMD_MAX, -}; - -#define DLM_CMD_MAX (__DLM_CMD_MAX - 1) - -enum { -	DLM_TYPE_UNSPEC = 0, -	DLM_TYPE_LOCK, -	__DLM_TYPE_MAX, -}; - -#define DLM_TYPE_MAX (__DLM_TYPE_MAX - 1) - -#define DLM_GENL_VERSION 0x1 -#define DLM_GENL_NAME "DLM" - -#endif /* _DLM_NETLINK_H */ diff --git a/include/uapi/linux/dlm_plock.h b/include/uapi/linux/dlm_plock.h index 63b6c1fd9169..eb66afcac40e 100644 --- a/include/uapi/linux/dlm_plock.h +++ b/include/uapi/linux/dlm_plock.h @@ -22,6 +22,7 @@ enum {  	DLM_PLOCK_OP_LOCK = 1,  	DLM_PLOCK_OP_UNLOCK,  	DLM_PLOCK_OP_GET, +	DLM_PLOCK_OP_CANCEL,  };  #define DLM_PLOCK_FL_CLOSE 1 diff --git a/include/uapi/linux/dlmconstants.h b/include/uapi/linux/dlmconstants.h index a8ae47c32a37..6ca77a6388bc 100644 --- a/include/uapi/linux/dlmconstants.h +++ b/include/uapi/linux/dlmconstants.h @@ -87,7 +87,6 @@   * DLM_LKF_NODLCKWT   *   * Do not cancel the lock if it gets into conversion deadlock. - * Exclude this lock from being monitored due to DLM_LSFL_TIMEWARN.   *   * DLM_LKF_NODLCKBLK   * @@ -132,6 +131,10 @@   * Unlock the lock even if it is converting or waiting or has sublocks.   * Only really for use by the userland device.c code.   * + * DLM_LKF_TIMEOUT + * + * This value is deprecated and reserved. DO NOT USE! + *   */  #define DLM_LKF_NOQUEUE		0x00000001 diff --git a/include/uapi/linux/dm-ioctl.h b/include/uapi/linux/dm-ioctl.h index 6622912c2342..3225e025e30e 100644 --- a/include/uapi/linux/dm-ioctl.h +++ b/include/uapi/linux/dm-ioctl.h @@ -182,7 +182,7 @@ struct dm_target_spec {  struct dm_target_deps {  	__u32 count;	/* Array size */  	__u32 padding;	/* unused */ -	__u64 dev[0];	/* out */ +	__u64 dev[];	/* out */  };  /* @@ -192,9 +192,23 @@ struct dm_name_list {  	__u64 dev;  	__u32 next;		/* offset to the next record from  				   the _start_ of this */ -	char name[0]; +	char name[]; + +	/* +	 * The following members can be accessed by taking a pointer that +	 * points immediately after the terminating zero character in "name" +	 * and aligning this pointer to next 8-byte boundary. +	 * Uuid is present if the flag DM_NAME_LIST_FLAG_HAS_UUID is set. +	 * +	 * __u32 event_nr; +	 * __u32 flags; +	 * char uuid[0]; +	 */  }; +#define DM_NAME_LIST_FLAG_HAS_UUID		1 +#define DM_NAME_LIST_FLAG_DOESNT_HAVE_UUID	2 +  /*   * Used to retrieve the target versions   */ @@ -202,7 +216,7 @@ struct dm_target_versions {          __u32 next;          __u32 version[3]; -        char name[0]; +        char name[];  };  /* @@ -211,7 +225,7 @@ struct dm_target_versions {  struct dm_target_msg {  	__u64 sector;	/* Device sector */ -	char message[0]; +	char message[];  };  /* @@ -244,10 +258,12 @@ enum {  	DM_DEV_SET_GEOMETRY_CMD,  	DM_DEV_ARM_POLL_CMD,  	DM_GET_TARGET_VERSION_CMD, +	DM_MPATH_PROBE_PATHS_CMD,  };  #define DM_IOCTL 0xfd +/* Control device ioctls */  #define DM_VERSION       _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)  #define DM_REMOVE_ALL    _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)  #define DM_LIST_DEVICES  _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl) @@ -271,10 +287,13 @@ enum {  #define DM_TARGET_MSG	 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)  #define DM_DEV_SET_GEOMETRY	_IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) +/* Block device ioctls */ +#define DM_MPATH_PROBE_PATHS _IO(DM_IOCTL, DM_MPATH_PROBE_PATHS_CMD) +  #define DM_VERSION_MAJOR	4 -#define DM_VERSION_MINOR	42 +#define DM_VERSION_MINOR	50  #define DM_VERSION_PATCHLEVEL	0 -#define DM_VERSION_EXTRA	"-ioctl (2020-02-27)" +#define DM_VERSION_EXTRA	"-ioctl (2025-04-28)"  /* Status bits */  #define DM_READONLY_FLAG	(1 << 0) /* In/Out */ @@ -362,4 +381,10 @@ enum {   */  #define DM_INTERNAL_SUSPEND_FLAG	(1 << 18) /* Out */ +/* + * If set, returns in the in buffer passed by UM, the raw table information + * that would be measured by IMA subsystem on device state change. + */ +#define DM_IMA_MEASUREMENT_FLAG	(1 << 19) /* In */ +  #endif				/* _LINUX_DM_IOCTL_H */ diff --git a/include/uapi/linux/dm-log-userspace.h b/include/uapi/linux/dm-log-userspace.h index 5c47a8603376..23dad9565e46 100644 --- a/include/uapi/linux/dm-log-userspace.h +++ b/include/uapi/linux/dm-log-userspace.h @@ -426,7 +426,7 @@ struct dm_ulog_request {  	__u32 request_type;  /* DM_ULOG_* defined above */  	__u32 data_size;     /* How much data (not including this struct) */ -	char data[0]; +	char data[];  };  #endif /* __DM_LOG_USERSPACE_H__ */ diff --git a/include/uapi/linux/dma-buf.h b/include/uapi/linux/dma-buf.h index 7f30393b92c3..5a6fda66d9ad 100644 --- a/include/uapi/linux/dma-buf.h +++ b/include/uapi/linux/dma-buf.h @@ -22,8 +22,56 @@  #include <linux/types.h> -/* begin/end dma-buf functions used for userspace mmap. */ +/** + * struct dma_buf_sync - Synchronize with CPU access. + * + * When a DMA buffer is accessed from the CPU via mmap, it is not always + * possible to guarantee coherency between the CPU-visible map and underlying + * memory.  To manage coherency, DMA_BUF_IOCTL_SYNC must be used to bracket + * any CPU access to give the kernel the chance to shuffle memory around if + * needed. + * + * Prior to accessing the map, the client must call DMA_BUF_IOCTL_SYNC + * with DMA_BUF_SYNC_START and the appropriate read/write flags.  Once the + * access is complete, the client should call DMA_BUF_IOCTL_SYNC with + * DMA_BUF_SYNC_END and the same read/write flags. + * + * The synchronization provided via DMA_BUF_IOCTL_SYNC only provides cache + * coherency.  It does not prevent other processes or devices from + * accessing the memory at the same time.  If synchronization with a GPU or + * other device driver is required, it is the client's responsibility to + * wait for buffer to be ready for reading or writing before calling this + * ioctl with DMA_BUF_SYNC_START.  Likewise, the client must ensure that + * follow-up work is not submitted to GPU or other device driver until + * after this ioctl has been called with DMA_BUF_SYNC_END? + * + * If the driver or API with which the client is interacting uses implicit + * synchronization, waiting for prior work to complete can be done via + * poll() on the DMA buffer file descriptor.  If the driver or API requires + * explicit synchronization, the client may have to wait on a sync_file or + * other synchronization primitive outside the scope of the DMA buffer API. + */  struct dma_buf_sync { +	/** +	 * @flags: Set of access flags +	 * +	 * DMA_BUF_SYNC_START: +	 *     Indicates the start of a map access session. +	 * +	 * DMA_BUF_SYNC_END: +	 *     Indicates the end of a map access session. +	 * +	 * DMA_BUF_SYNC_READ: +	 *     Indicates that the mapped DMA buffer will be read by the +	 *     client via the CPU map. +	 * +	 * DMA_BUF_SYNC_WRITE: +	 *     Indicates that the mapped DMA buffer will be written by the +	 *     client via the CPU map. +	 * +	 * DMA_BUF_SYNC_RW: +	 *     An alias for DMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE. +	 */  	__u64 flags;  }; @@ -37,6 +85,88 @@ struct dma_buf_sync {  #define DMA_BUF_NAME_LEN	32 +/** + * struct dma_buf_export_sync_file - Get a sync_file from a dma-buf + * + * Userspace can perform a DMA_BUF_IOCTL_EXPORT_SYNC_FILE to retrieve the + * current set of fences on a dma-buf file descriptor as a sync_file.  CPU + * waits via poll() or other driver-specific mechanisms typically wait on + * whatever fences are on the dma-buf at the time the wait begins.  This + * is similar except that it takes a snapshot of the current fences on the + * dma-buf for waiting later instead of waiting immediately.  This is + * useful for modern graphics APIs such as Vulkan which assume an explicit + * synchronization model but still need to inter-operate with dma-buf. + * + * The intended usage pattern is the following: + * + *  1. Export a sync_file with flags corresponding to the expected GPU usage + *     via DMA_BUF_IOCTL_EXPORT_SYNC_FILE. + * + *  2. Submit rendering work which uses the dma-buf.  The work should wait on + *     the exported sync file before rendering and produce another sync_file + *     when complete. + * + *  3. Import the rendering-complete sync_file into the dma-buf with flags + *     corresponding to the GPU usage via DMA_BUF_IOCTL_IMPORT_SYNC_FILE. + * + * Unlike doing implicit synchronization via a GPU kernel driver's exec ioctl, + * the above is not a single atomic operation.  If userspace wants to ensure + * ordering via these fences, it is the respnosibility of userspace to use + * locks or other mechanisms to ensure that no other context adds fences or + * submits work between steps 1 and 3 above. + */ +struct dma_buf_export_sync_file { +	/** +	 * @flags: Read/write flags +	 * +	 * Must be DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or both. +	 * +	 * If DMA_BUF_SYNC_READ is set and DMA_BUF_SYNC_WRITE is not set, +	 * the returned sync file waits on any writers of the dma-buf to +	 * complete.  Waiting on the returned sync file is equivalent to +	 * poll() with POLLIN. +	 * +	 * If DMA_BUF_SYNC_WRITE is set, the returned sync file waits on +	 * any users of the dma-buf (read or write) to complete.  Waiting +	 * on the returned sync file is equivalent to poll() with POLLOUT. +	 * If both DMA_BUF_SYNC_WRITE and DMA_BUF_SYNC_READ are set, this +	 * is equivalent to just DMA_BUF_SYNC_WRITE. +	 */ +	__u32 flags; +	/** @fd: Returned sync file descriptor */ +	__s32 fd; +}; + +/** + * struct dma_buf_import_sync_file - Insert a sync_file into a dma-buf + * + * Userspace can perform a DMA_BUF_IOCTL_IMPORT_SYNC_FILE to insert a + * sync_file into a dma-buf for the purposes of implicit synchronization + * with other dma-buf consumers.  This allows clients using explicitly + * synchronized APIs such as Vulkan to inter-op with dma-buf consumers + * which expect implicit synchronization such as OpenGL or most media + * drivers/video. + */ +struct dma_buf_import_sync_file { +	/** +	 * @flags: Read/write flags +	 * +	 * Must be DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or both. +	 * +	 * If DMA_BUF_SYNC_READ is set and DMA_BUF_SYNC_WRITE is not set, +	 * this inserts the sync_file as a read-only fence.  Any subsequent +	 * implicitly synchronized writes to this dma-buf will wait on this +	 * fence but reads will not. +	 * +	 * If DMA_BUF_SYNC_WRITE is set, this inserts the sync_file as a +	 * write fence.  All subsequent implicitly synchronized access to +	 * this dma-buf will wait on this fence. +	 */ +	__u32 flags; +	/** @fd: Sync file descriptor */ +	__s32 fd; +}; +  #define DMA_BUF_BASE		'b'  #define DMA_BUF_IOCTL_SYNC	_IOW(DMA_BUF_BASE, 0, struct dma_buf_sync) @@ -44,7 +174,9 @@ struct dma_buf_sync {   * between them in actual uapi, they're just different numbers.   */  #define DMA_BUF_SET_NAME	_IOW(DMA_BUF_BASE, 1, const char *) -#define DMA_BUF_SET_NAME_A	_IOW(DMA_BUF_BASE, 1, u32) -#define DMA_BUF_SET_NAME_B	_IOW(DMA_BUF_BASE, 1, u64) +#define DMA_BUF_SET_NAME_A	_IOW(DMA_BUF_BASE, 1, __u32) +#define DMA_BUF_SET_NAME_B	_IOW(DMA_BUF_BASE, 1, __u64) +#define DMA_BUF_IOCTL_EXPORT_SYNC_FILE	_IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file) +#define DMA_BUF_IOCTL_IMPORT_SYNC_FILE	_IOW(DMA_BUF_BASE, 3, struct dma_buf_import_sync_file)  #endif diff --git a/include/uapi/linux/dma-heap.h b/include/uapi/linux/dma-heap.h index 6f84fa08e074..a4cf716a49fa 100644 --- a/include/uapi/linux/dma-heap.h +++ b/include/uapi/linux/dma-heap.h @@ -19,7 +19,7 @@  #define DMA_HEAP_VALID_FD_FLAGS (O_CLOEXEC | O_ACCMODE)  /* Currently no heap flags */ -#define DMA_HEAP_VALID_HEAP_FLAGS (0) +#define DMA_HEAP_VALID_HEAP_FLAGS (0ULL)  /**   * struct dma_heap_allocation_data - metadata passed from userspace for diff --git a/include/uapi/linux/dn.h b/include/uapi/linux/dn.h deleted file mode 100644 index 36ca71bd8bbe..000000000000 --- a/include/uapi/linux/dn.h +++ /dev/null @@ -1,149 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _LINUX_DN_H -#define _LINUX_DN_H - -#include <linux/ioctl.h> -#include <linux/types.h> -#include <linux/if_ether.h> - -/* - -	DECnet Data Structures and Constants - -*/ - -/*  - * DNPROTO_NSP can't be the same as SOL_SOCKET,  - * so increment each by one (compared to ULTRIX) - */ -#define DNPROTO_NSP     2                       /* NSP protocol number       */ -#define DNPROTO_ROU     3                       /* Routing protocol number   */ -#define DNPROTO_NML     4                       /* Net mgt protocol number   */ -#define DNPROTO_EVL     5                       /* Evl protocol number (usr) */ -#define DNPROTO_EVR     6                       /* Evl protocol number (evl) */ -#define DNPROTO_NSPT    7                       /* NSP trace protocol number */ - - -#define DN_ADDL		2 -#define DN_MAXADDL	2 /* ULTRIX headers have 20 here, but pathworks has 2 */ -#define DN_MAXOPTL	16 -#define DN_MAXOBJL	16 -#define DN_MAXACCL	40 -#define DN_MAXALIASL	128 -#define DN_MAXNODEL	256 -#define DNBUFSIZE	65023 - -/*  - * SET/GET Socket options  - must match the DSO_ numbers below - */ -#define SO_CONDATA      1 -#define SO_CONACCESS    2 -#define SO_PROXYUSR     3 -#define SO_LINKINFO     7 - -#define DSO_CONDATA     1        /* Set/Get connect data                */ -#define DSO_DISDATA     10       /* Set/Get disconnect data             */ -#define DSO_CONACCESS   2        /* Set/Get connect access data         */ -#define DSO_ACCEPTMODE  4        /* Set/Get accept mode                 */ -#define DSO_CONACCEPT   5        /* Accept deferred connection          */ -#define DSO_CONREJECT   6        /* Reject deferred connection          */ -#define DSO_LINKINFO    7        /* Set/Get link information            */ -#define DSO_STREAM      8        /* Set socket type to stream           */ -#define DSO_SEQPACKET   9        /* Set socket type to sequenced packet */ -#define DSO_MAXWINDOW   11       /* Maximum window size allowed         */ -#define DSO_NODELAY	12       /* Turn off nagle                      */ -#define DSO_CORK        13       /* Wait for more data!                 */ -#define DSO_SERVICES	14       /* NSP Services field                  */ -#define DSO_INFO	15       /* NSP Info field                      */ -#define DSO_MAX         15       /* Maximum option number               */ - - -/* LINK States */ -#define LL_INACTIVE	0 -#define LL_CONNECTING	1 -#define LL_RUNNING	2 -#define LL_DISCONNECTING 3 - -#define ACC_IMMED 0 -#define ACC_DEFER 1 - -#define SDF_WILD        1                  /* Wild card object          */ -#define SDF_PROXY       2                  /* Addr eligible for proxy   */ -#define SDF_UICPROXY    4                  /* Use uic-based proxy       */ - -/* Structures */ - - -struct dn_naddr { -	__le16		a_len; -	__u8 a_addr[DN_MAXADDL]; /* Two bytes little endian */ -}; - -struct sockaddr_dn { -	__u16		sdn_family; -	__u8		sdn_flags; -	__u8		sdn_objnum; -	__le16		sdn_objnamel; -	__u8		sdn_objname[DN_MAXOBJL]; -	struct   dn_naddr	sdn_add; -}; -#define sdn_nodeaddrl   sdn_add.a_len   /* Node address length  */ -#define sdn_nodeaddr    sdn_add.a_addr  /* Node address         */ - - - -/* - * DECnet set/get DSO_CONDATA, DSO_DISDATA (optional data) structure - */ -struct optdata_dn { -        __le16  opt_status;     /* Extended status return */ -#define opt_sts opt_status -        __le16  opt_optl;       /* Length of user data    */ -        __u8   opt_data[16];   /* User data              */ -}; - -struct accessdata_dn { -	__u8		acc_accl; -	__u8		acc_acc[DN_MAXACCL]; -	__u8 		acc_passl; -	__u8		acc_pass[DN_MAXACCL]; -	__u8 		acc_userl; -	__u8		acc_user[DN_MAXACCL]; -}; - -/* - * DECnet logical link information structure - */ -struct linkinfo_dn { -        __u16  idn_segsize;    /* Segment size for link */ -        __u8   idn_linkstate;  /* Logical link state    */ -}; - -/* - * Ethernet address format (for DECnet) - */ -union etheraddress { -        __u8 dne_addr[ETH_ALEN];      /* Full ethernet address */ -  struct { -                __u8 dne_hiord[4];    /* DECnet HIORD prefix   */ -                __u8 dne_nodeaddr[2]; /* DECnet node address   */ -  } dne_remote; -}; - - -/* - * DECnet physical socket address format - */ -struct dn_addr { -        __le16 dna_family;      /* AF_DECnet               */ -        union etheraddress dna_netaddr; /* DECnet ethernet address */ -}; - -#define DECNET_IOCTL_BASE 0x89 /* PROTOPRIVATE range */ - -#define SIOCSNETADDR  _IOW(DECNET_IOCTL_BASE, 0xe0, struct dn_naddr) -#define SIOCGNETADDR  _IOR(DECNET_IOCTL_BASE, 0xe1, struct dn_naddr) -#define OSIOCSNETADDR _IOW(DECNET_IOCTL_BASE, 0xe0, int) -#define OSIOCGNETADDR _IOR(DECNET_IOCTL_BASE, 0xe1, int) - -#endif /* _LINUX_DN_H */ diff --git a/include/uapi/linux/dpll.h b/include/uapi/linux/dpll.h new file mode 100644 index 000000000000..37b438ce8efc --- /dev/null +++ b/include/uapi/linux/dpll.h @@ -0,0 +1,278 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/dpll.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_DPLL_H +#define _UAPI_LINUX_DPLL_H + +#define DPLL_FAMILY_NAME	"dpll" +#define DPLL_FAMILY_VERSION	1 + +/** + * enum dpll_mode - working modes a dpll can support, differentiates if and how + *   dpll selects one of its inputs to syntonize with it, valid values for + *   DPLL_A_MODE attribute + * @DPLL_MODE_MANUAL: input can be only selected by sending a request to dpll + * @DPLL_MODE_AUTOMATIC: highest prio input pin auto selected by dpll + */ +enum dpll_mode { +	DPLL_MODE_MANUAL = 1, +	DPLL_MODE_AUTOMATIC, + +	/* private: */ +	__DPLL_MODE_MAX, +	DPLL_MODE_MAX = (__DPLL_MODE_MAX - 1) +}; + +/** + * enum dpll_lock_status - provides information of dpll device lock status, + *   valid values for DPLL_A_LOCK_STATUS attribute + * @DPLL_LOCK_STATUS_UNLOCKED: dpll was not yet locked to any valid input (or + *   forced by setting DPLL_A_MODE to DPLL_MODE_DETACHED) + * @DPLL_LOCK_STATUS_LOCKED: dpll is locked to a valid signal, but no holdover + *   available + * @DPLL_LOCK_STATUS_LOCKED_HO_ACQ: dpll is locked and holdover acquired + * @DPLL_LOCK_STATUS_HOLDOVER: dpll is in holdover state - lost a valid lock or + *   was forced by disconnecting all the pins (latter possible only when dpll + *   lock-state was already DPLL_LOCK_STATUS_LOCKED_HO_ACQ, if dpll lock-state + *   was not DPLL_LOCK_STATUS_LOCKED_HO_ACQ, the dpll's lock-state shall remain + *   DPLL_LOCK_STATUS_UNLOCKED) + */ +enum dpll_lock_status { +	DPLL_LOCK_STATUS_UNLOCKED = 1, +	DPLL_LOCK_STATUS_LOCKED, +	DPLL_LOCK_STATUS_LOCKED_HO_ACQ, +	DPLL_LOCK_STATUS_HOLDOVER, + +	/* private: */ +	__DPLL_LOCK_STATUS_MAX, +	DPLL_LOCK_STATUS_MAX = (__DPLL_LOCK_STATUS_MAX - 1) +}; + +/** + * enum dpll_lock_status_error - if previous status change was done due to a + *   failure, this provides information of dpll device lock status error. Valid + *   values for DPLL_A_LOCK_STATUS_ERROR attribute + * @DPLL_LOCK_STATUS_ERROR_NONE: dpll device lock status was changed without + *   any error + * @DPLL_LOCK_STATUS_ERROR_UNDEFINED: dpll device lock status was changed due + *   to undefined error. Driver fills this value up in case it is not able to + *   obtain suitable exact error type. + * @DPLL_LOCK_STATUS_ERROR_MEDIA_DOWN: dpll device lock status was changed + *   because of associated media got down. This may happen for example if dpll + *   device was previously locked on an input pin of type + *   PIN_TYPE_SYNCE_ETH_PORT. + * @DPLL_LOCK_STATUS_ERROR_FRACTIONAL_FREQUENCY_OFFSET_TOO_HIGH: the FFO + *   (Fractional Frequency Offset) between the RX and TX symbol rate on the + *   media got too high. This may happen for example if dpll device was + *   previously locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT. + */ +enum dpll_lock_status_error { +	DPLL_LOCK_STATUS_ERROR_NONE = 1, +	DPLL_LOCK_STATUS_ERROR_UNDEFINED, +	DPLL_LOCK_STATUS_ERROR_MEDIA_DOWN, +	DPLL_LOCK_STATUS_ERROR_FRACTIONAL_FREQUENCY_OFFSET_TOO_HIGH, + +	/* private: */ +	__DPLL_LOCK_STATUS_ERROR_MAX, +	DPLL_LOCK_STATUS_ERROR_MAX = (__DPLL_LOCK_STATUS_ERROR_MAX - 1) +}; + +/* + * level of quality of a clock device. This mainly applies when the dpll + * lock-status is DPLL_LOCK_STATUS_HOLDOVER. The current list is defined + * according to the table 11-7 contained in ITU-T G.8264/Y.1364 document. One + * may extend this list freely by other ITU-T defined clock qualities, or + * different ones defined by another standardization body (for those, please + * use different prefix). + */ +enum dpll_clock_quality_level { +	DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_PRC = 1, +	DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_SSU_A, +	DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_SSU_B, +	DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EEC1, +	DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_PRTC, +	DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRTC, +	DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EEEC, +	DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRC, + +	/* private: */ +	__DPLL_CLOCK_QUALITY_LEVEL_MAX, +	DPLL_CLOCK_QUALITY_LEVEL_MAX = (__DPLL_CLOCK_QUALITY_LEVEL_MAX - 1) +}; + +#define DPLL_TEMP_DIVIDER	1000 + +/** + * enum dpll_type - type of dpll, valid values for DPLL_A_TYPE attribute + * @DPLL_TYPE_PPS: dpll produces Pulse-Per-Second signal + * @DPLL_TYPE_EEC: dpll drives the Ethernet Equipment Clock + */ +enum dpll_type { +	DPLL_TYPE_PPS = 1, +	DPLL_TYPE_EEC, + +	/* private: */ +	__DPLL_TYPE_MAX, +	DPLL_TYPE_MAX = (__DPLL_TYPE_MAX - 1) +}; + +/** + * enum dpll_pin_type - defines possible types of a pin, valid values for + *   DPLL_A_PIN_TYPE attribute + * @DPLL_PIN_TYPE_MUX: aggregates another layer of selectable pins + * @DPLL_PIN_TYPE_EXT: external input + * @DPLL_PIN_TYPE_SYNCE_ETH_PORT: ethernet port PHY's recovered clock + * @DPLL_PIN_TYPE_INT_OSCILLATOR: device internal oscillator + * @DPLL_PIN_TYPE_GNSS: GNSS recovered clock + */ +enum dpll_pin_type { +	DPLL_PIN_TYPE_MUX = 1, +	DPLL_PIN_TYPE_EXT, +	DPLL_PIN_TYPE_SYNCE_ETH_PORT, +	DPLL_PIN_TYPE_INT_OSCILLATOR, +	DPLL_PIN_TYPE_GNSS, + +	/* private: */ +	__DPLL_PIN_TYPE_MAX, +	DPLL_PIN_TYPE_MAX = (__DPLL_PIN_TYPE_MAX - 1) +}; + +/** + * enum dpll_pin_direction - defines possible direction of a pin, valid values + *   for DPLL_A_PIN_DIRECTION attribute + * @DPLL_PIN_DIRECTION_INPUT: pin used as a input of a signal + * @DPLL_PIN_DIRECTION_OUTPUT: pin used to output the signal + */ +enum dpll_pin_direction { +	DPLL_PIN_DIRECTION_INPUT = 1, +	DPLL_PIN_DIRECTION_OUTPUT, + +	/* private: */ +	__DPLL_PIN_DIRECTION_MAX, +	DPLL_PIN_DIRECTION_MAX = (__DPLL_PIN_DIRECTION_MAX - 1) +}; + +#define DPLL_PIN_FREQUENCY_1_HZ		1 +#define DPLL_PIN_FREQUENCY_10_KHZ	10000 +#define DPLL_PIN_FREQUENCY_77_5_KHZ	77500 +#define DPLL_PIN_FREQUENCY_10_MHZ	10000000 + +/** + * enum dpll_pin_state - defines possible states of a pin, valid values for + *   DPLL_A_PIN_STATE attribute + * @DPLL_PIN_STATE_CONNECTED: pin connected, active input of phase locked loop + * @DPLL_PIN_STATE_DISCONNECTED: pin disconnected, not considered as a valid + *   input + * @DPLL_PIN_STATE_SELECTABLE: pin enabled for automatic input selection + */ +enum dpll_pin_state { +	DPLL_PIN_STATE_CONNECTED = 1, +	DPLL_PIN_STATE_DISCONNECTED, +	DPLL_PIN_STATE_SELECTABLE, + +	/* private: */ +	__DPLL_PIN_STATE_MAX, +	DPLL_PIN_STATE_MAX = (__DPLL_PIN_STATE_MAX - 1) +}; + +/** + * enum dpll_pin_capabilities - defines possible capabilities of a pin, valid + *   flags on DPLL_A_PIN_CAPABILITIES attribute + * @DPLL_PIN_CAPABILITIES_DIRECTION_CAN_CHANGE: pin direction can be changed + * @DPLL_PIN_CAPABILITIES_PRIORITY_CAN_CHANGE: pin priority can be changed + * @DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE: pin state can be changed + */ +enum dpll_pin_capabilities { +	DPLL_PIN_CAPABILITIES_DIRECTION_CAN_CHANGE = 1, +	DPLL_PIN_CAPABILITIES_PRIORITY_CAN_CHANGE = 2, +	DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE = 4, +}; + +#define DPLL_PHASE_OFFSET_DIVIDER	1000 + +/** + * enum dpll_feature_state - Allow control (enable/disable) and status checking + *   over features. + * @DPLL_FEATURE_STATE_DISABLE: feature shall be disabled + * @DPLL_FEATURE_STATE_ENABLE: feature shall be enabled + */ +enum dpll_feature_state { +	DPLL_FEATURE_STATE_DISABLE, +	DPLL_FEATURE_STATE_ENABLE, +}; + +enum dpll_a { +	DPLL_A_ID = 1, +	DPLL_A_MODULE_NAME, +	DPLL_A_PAD, +	DPLL_A_CLOCK_ID, +	DPLL_A_MODE, +	DPLL_A_MODE_SUPPORTED, +	DPLL_A_LOCK_STATUS, +	DPLL_A_TEMP, +	DPLL_A_TYPE, +	DPLL_A_LOCK_STATUS_ERROR, +	DPLL_A_CLOCK_QUALITY_LEVEL, +	DPLL_A_PHASE_OFFSET_MONITOR, + +	__DPLL_A_MAX, +	DPLL_A_MAX = (__DPLL_A_MAX - 1) +}; + +enum dpll_a_pin { +	DPLL_A_PIN_ID = 1, +	DPLL_A_PIN_PARENT_ID, +	DPLL_A_PIN_MODULE_NAME, +	DPLL_A_PIN_PAD, +	DPLL_A_PIN_CLOCK_ID, +	DPLL_A_PIN_BOARD_LABEL, +	DPLL_A_PIN_PANEL_LABEL, +	DPLL_A_PIN_PACKAGE_LABEL, +	DPLL_A_PIN_TYPE, +	DPLL_A_PIN_DIRECTION, +	DPLL_A_PIN_FREQUENCY, +	DPLL_A_PIN_FREQUENCY_SUPPORTED, +	DPLL_A_PIN_FREQUENCY_MIN, +	DPLL_A_PIN_FREQUENCY_MAX, +	DPLL_A_PIN_PRIO, +	DPLL_A_PIN_STATE, +	DPLL_A_PIN_CAPABILITIES, +	DPLL_A_PIN_PARENT_DEVICE, +	DPLL_A_PIN_PARENT_PIN, +	DPLL_A_PIN_PHASE_ADJUST_MIN, +	DPLL_A_PIN_PHASE_ADJUST_MAX, +	DPLL_A_PIN_PHASE_ADJUST, +	DPLL_A_PIN_PHASE_OFFSET, +	DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET, +	DPLL_A_PIN_ESYNC_FREQUENCY, +	DPLL_A_PIN_ESYNC_FREQUENCY_SUPPORTED, +	DPLL_A_PIN_ESYNC_PULSE, +	DPLL_A_PIN_REFERENCE_SYNC, + +	__DPLL_A_PIN_MAX, +	DPLL_A_PIN_MAX = (__DPLL_A_PIN_MAX - 1) +}; + +enum dpll_cmd { +	DPLL_CMD_DEVICE_ID_GET = 1, +	DPLL_CMD_DEVICE_GET, +	DPLL_CMD_DEVICE_SET, +	DPLL_CMD_DEVICE_CREATE_NTF, +	DPLL_CMD_DEVICE_DELETE_NTF, +	DPLL_CMD_DEVICE_CHANGE_NTF, +	DPLL_CMD_PIN_ID_GET, +	DPLL_CMD_PIN_GET, +	DPLL_CMD_PIN_SET, +	DPLL_CMD_PIN_CREATE_NTF, +	DPLL_CMD_PIN_DELETE_NTF, +	DPLL_CMD_PIN_CHANGE_NTF, + +	__DPLL_CMD_MAX, +	DPLL_CMD_MAX = (__DPLL_CMD_MAX - 1) +}; + +#define DPLL_MCGRP_MONITOR	"monitor" + +#endif /* _UAPI_LINUX_DPLL_H */ diff --git a/include/uapi/linux/dqblk_xfs.h b/include/uapi/linux/dqblk_xfs.h index 03d890b80ebc..8cda3e62e0e7 100644 --- a/include/uapi/linux/dqblk_xfs.h +++ b/include/uapi/linux/dqblk_xfs.h @@ -61,12 +61,16 @@ typedef struct fs_disk_quota {  	__u64		d_ino_softlimit;/* preferred inode limit */  	__u64		d_bcount;	/* # disk blocks owned by the user */  	__u64		d_icount;	/* # inodes owned by the user */ -	__s32		d_itimer;	/* zero if within inode limits */ -					/* if not, we refuse service */ +	__s32		d_itimer;	/* Zero if within inode limits. If +					 * not, we refuse service at this time +					 * (in seconds since Unix epoch) */  	__s32		d_btimer;	/* similar to above; for disk blocks */  	__u16	  	d_iwarns;       /* # warnings issued wrt num inodes */  	__u16	  	d_bwarns;       /* # warnings issued wrt disk blocks */ -	__s32		d_padding2;	/* padding2 - for future use */ +	__s8		d_itimer_hi;	/* upper 8 bits of timer values */ +	__s8		d_btimer_hi; +	__s8		d_rtbtimer_hi; +	__s8		d_padding2;	/* padding2 - for future use */  	__u64		d_rtb_hardlimit;/* absolute limit on realtime blks */  	__u64		d_rtb_softlimit;/* preferred limit on RT disk blks */  	__u64		d_rtbcount;	/* # realtime blocks owned */ @@ -122,6 +126,12 @@ typedef struct fs_disk_quota {  #define FS_DQ_ACCT_MASK		(FS_DQ_BCOUNT | FS_DQ_ICOUNT | FS_DQ_RTBCOUNT)  /* + * Quota expiration timestamps are 40-bit signed integers, with the upper 8 + * bits encoded in the _hi fields. + */ +#define FS_DQ_BIGTIME		(1<<15) + +/*   * Various flags related to quotactl(2).   */  #define FS_QUOTA_UDQ_ACCT	(1<<0)  /* user quota accounting */ @@ -209,7 +219,10 @@ struct fs_quota_statv {  	__s32			qs_rtbtimelimit;/* limit for rt blks timer */  	__u16			qs_bwarnlimit;	/* limit for num warnings */  	__u16			qs_iwarnlimit;	/* limit for num warnings */ -	__u64			qs_pad2[8];	/* for future proofing */ +	__u16			qs_rtbwarnlimit;/* limit for rt blks warnings */ +	__u16			qs_pad3; +	__u32			qs_pad4; +	__u64			qs_pad2[7];	/* for future proofing */  };  #endif	/* _LINUX_DQBLK_XFS_H */ diff --git a/include/uapi/linux/dvb/audio.h b/include/uapi/linux/dvb/audio.h index 2f869da69171..77fb866890b4 100644 --- a/include/uapi/linux/dvb/audio.h +++ b/include/uapi/linux/dvb/audio.h @@ -7,21 +7,6 @@   * Copyright (C) 2000 Ralph  Metzler <ralph@convergence.de>   *                  & Marcus Metzler <marcus@convergence.de>   *                    for convergence integrated media GmbH - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Lesser Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. - *   */  #ifndef _DVBAUDIO_H_ diff --git a/include/uapi/linux/dvb/ca.h b/include/uapi/linux/dvb/ca.h index dffa59e95ebb..4244b187cc4d 100644 --- a/include/uapi/linux/dvb/ca.h +++ b/include/uapi/linux/dvb/ca.h @@ -5,21 +5,6 @@   * Copyright (C) 2000 Ralph  Metzler <ralph@convergence.de>   *                  & Marcus Metzler <marcus@convergence.de>   *                    for convergence integrated media GmbH - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Lesser Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. - *   */  #ifndef _DVBCA_H_ diff --git a/include/uapi/linux/dvb/dmx.h b/include/uapi/linux/dvb/dmx.h index b4112f0b6dd3..7b16375f94e2 100644 --- a/include/uapi/linux/dvb/dmx.h +++ b/include/uapi/linux/dvb/dmx.h @@ -5,21 +5,6 @@   * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>   *                  & Ralph  Metzler <ralph@convergence.de>   *                    for convergence integrated media GmbH - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. - *   */  #ifndef _UAPI_DVBDMX_H_ diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h index 4f9b4551c534..8d38c6befda8 100644 --- a/include/uapi/linux/dvb/frontend.h +++ b/include/uapi/linux/dvb/frontend.h @@ -7,21 +7,6 @@   *		    Holger Waechtler <holger@convergence.de>   *		    Andre Draszik <ad@convergence.de>   *		    for convergence integrated media GmbH - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. - *   */  #ifndef _DVBFRONTEND_H_ @@ -282,7 +267,6 @@ enum fe_spectral_inversion {  /**   * enum fe_code_rate - Type of Forward Error Correction (FEC)   * - *   * @FEC_NONE: No Forward Error Correction Code   * @FEC_1_2:  Forward Error Correction Code 1/2   * @FEC_2_3:  Forward Error Correction Code 2/3 @@ -296,6 +280,26 @@ enum fe_spectral_inversion {   * @FEC_3_5:  Forward Error Correction Code 3/5   * @FEC_9_10: Forward Error Correction Code 9/10   * @FEC_2_5:  Forward Error Correction Code 2/5 + * @FEC_1_3:  Forward Error Correction Code 1/3 + * @FEC_1_4:  Forward Error Correction Code 1/4 + * @FEC_5_9:  Forward Error Correction Code 5/9 + * @FEC_7_9:  Forward Error Correction Code 7/9 + * @FEC_8_15:  Forward Error Correction Code 8/15 + * @FEC_11_15: Forward Error Correction Code 11/15 + * @FEC_13_18: Forward Error Correction Code 13/18 + * @FEC_9_20:  Forward Error Correction Code 9/20 + * @FEC_11_20: Forward Error Correction Code 11/20 + * @FEC_23_36: Forward Error Correction Code 23/36 + * @FEC_25_36: Forward Error Correction Code 25/36 + * @FEC_13_45: Forward Error Correction Code 13/45 + * @FEC_26_45: Forward Error Correction Code 26/45 + * @FEC_28_45: Forward Error Correction Code 28/45 + * @FEC_32_45: Forward Error Correction Code 32/45 + * @FEC_77_90: Forward Error Correction Code 77/90 + * @FEC_11_45: Forward Error Correction Code 11/45 + * @FEC_4_15: Forward Error Correction Code 4/15 + * @FEC_14_45: Forward Error Correction Code 14/45 + * @FEC_7_15: Forward Error Correction Code 7/15   *   * Please note that not all FEC types are supported by a given standard.   */ @@ -313,6 +317,26 @@ enum fe_code_rate {  	FEC_3_5,  	FEC_9_10,  	FEC_2_5, +	FEC_1_3, +	FEC_1_4, +	FEC_5_9, +	FEC_7_9, +	FEC_8_15, +	FEC_11_15, +	FEC_13_18, +	FEC_9_20, +	FEC_11_20, +	FEC_23_36, +	FEC_25_36, +	FEC_13_45, +	FEC_26_45, +	FEC_28_45, +	FEC_32_45, +	FEC_77_90, +	FEC_11_45, +	FEC_4_15, +	FEC_14_45, +	FEC_7_15,  };  /** @@ -331,6 +355,13 @@ enum fe_code_rate {   * @APSK_32:	32-APSK modulation   * @DQPSK:	DQPSK modulation   * @QAM_4_NR:	4-QAM-NR modulation + * @QAM_1024:	1024-QAM modulation + * @QAM_4096:	4096-QAM modulation + * @APSK_8_L:	8APSK-L modulation + * @APSK_16_L:	16APSK-L modulation + * @APSK_32_L:	32APSK-L modulation + * @APSK_64:	64APSK modulation + * @APSK_64_L:	64APSK-L modulation   *   * Please note that not all modulations are supported by a given standard.   * @@ -350,6 +381,13 @@ enum fe_modulation {  	APSK_32,  	DQPSK,  	QAM_4_NR, +	QAM_1024, +	QAM_4096, +	APSK_8_L, +	APSK_16_L, +	APSK_32_L, +	APSK_64, +	APSK_64_L,  };  /** @@ -404,6 +442,7 @@ enum fe_transmit_mode {   * @GUARD_INTERVAL_PN420:	PN length 420 (1/4)   * @GUARD_INTERVAL_PN595:	PN length 595 (1/6)   * @GUARD_INTERVAL_PN945:	PN length 945 (1/9) + * @GUARD_INTERVAL_1_64:	Guard interval 1/64   *   * Please note that not all guard intervals are supported by a given standard.   */ @@ -419,6 +458,7 @@ enum fe_guard_interval {  	GUARD_INTERVAL_PN420,  	GUARD_INTERVAL_PN595,  	GUARD_INTERVAL_PN945, +	GUARD_INTERVAL_1_64,  };  /** @@ -571,6 +611,9 @@ enum fe_pilot {   * @ROLLOFF_20:		Roloff factor: α=20%   * @ROLLOFF_25:		Roloff factor: α=25%   * @ROLLOFF_AUTO:	Auto-detect the roloff factor. + * @ROLLOFF_15:		Rolloff factor: α=15% + * @ROLLOFF_10:		Rolloff factor: α=10% + * @ROLLOFF_5:		Rolloff factor: α=5%   *   * .. note:   * @@ -581,6 +624,9 @@ enum fe_rolloff {  	ROLLOFF_20,  	ROLLOFF_25,  	ROLLOFF_AUTO, +	ROLLOFF_15, +	ROLLOFF_10, +	ROLLOFF_5,  };  /** @@ -594,6 +640,8 @@ enum fe_rolloff {   *	Cable TV: DVB-C following ITU-T J.83 Annex B spec (ClearQAM)   * @SYS_DVBC_ANNEX_C:   *	Cable TV: DVB-C following ITU-T J.83 Annex C spec + * @SYS_DVBC2: + *      Cable TV: DVB-C2   * @SYS_ISDBC:   *	Cable TV: ISDB-C (no drivers yet)   * @SYS_DVBT: @@ -611,7 +659,7 @@ enum fe_rolloff {   * @SYS_DVBS:   *	Satellite TV: DVB-S   * @SYS_DVBS2: - *	Satellite TV: DVB-S2 + *	Satellite TV: DVB-S2 and DVB-S2X   * @SYS_TURBO:   *	Satellite TV: DVB-S Turbo   * @SYS_ISDBS: @@ -645,6 +693,7 @@ enum fe_delivery_system {  	SYS_DVBT2,  	SYS_TURBO,  	SYS_DVBC_ANNEX_C, +	SYS_DVBC2,  };  /* backward compatibility definitions for delivery systems */ @@ -720,7 +769,7 @@ enum atscmh_rs_frame_mode {  };  /** - * enum atscmh_rs_code_mode + * enum atscmh_rs_code_mode - ATSC-M/H Reed Solomon modes   * @ATSCMH_RSCODE_211_187:	Reed Solomon code (211,187).   * @ATSCMH_RSCODE_223_187:	Reed Solomon code (223,187).   * @ATSCMH_RSCODE_235_187:	Reed Solomon code (235,187). @@ -805,7 +854,7 @@ struct dtv_stats {  	union {  		__u64 uvalue;	/* for counters and relative scales */  		__s64 svalue;	/* for 0.001 dB measures */ -	}; +	}  __attribute__ ((packed));  } __attribute__ ((packed)); diff --git a/include/uapi/linux/dvb/net.h b/include/uapi/linux/dvb/net.h index 0c550ef93f2c..7cbb47ac38ef 100644 --- a/include/uapi/linux/dvb/net.h +++ b/include/uapi/linux/dvb/net.h @@ -5,21 +5,6 @@   * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>   *                  & Ralph  Metzler <ralph@convergence.de>   *                    for convergence integrated media GmbH - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. - *   */  #ifndef _DVBNET_H_ diff --git a/include/uapi/linux/dvb/osd.h b/include/uapi/linux/dvb/osd.h index 858997c74043..6003b108ba45 100644 --- a/include/uapi/linux/dvb/osd.h +++ b/include/uapi/linux/dvb/osd.h @@ -7,21 +7,6 @@   * Copyright (C) 2001 Ralph  Metzler <ralph@convergence.de>   *                  & Marcus Metzler <marcus@convergence.de>   *                    for convergence integrated media GmbH - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Lesser Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. - *   */  #ifndef _DVBOSD_H_ diff --git a/include/uapi/linux/dvb/version.h b/include/uapi/linux/dvb/version.h index 2c5cffe6d2a0..20bc874de321 100644 --- a/include/uapi/linux/dvb/version.h +++ b/include/uapi/linux/dvb/version.h @@ -4,27 +4,12 @@   *   * Copyright (C) 2000 Holger Waechtler <holger@convergence.de>   *                    for convergence integrated media GmbH - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. - *   */  #ifndef _DVBVERSION_H_  #define _DVBVERSION_H_  #define DVB_API_VERSION 5 -#define DVB_API_VERSION_MINOR 11 +#define DVB_API_VERSION_MINOR 12  #endif /*_DVBVERSION_H_*/ diff --git a/include/uapi/linux/dvb/video.h b/include/uapi/linux/dvb/video.h index 179f1ec60af6..9910b73737e0 100644 --- a/include/uapi/linux/dvb/video.h +++ b/include/uapi/linux/dvb/video.h @@ -7,21 +7,6 @@   * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>   *                  & Ralph  Metzler <ralph@convergence.de>   *                    for convergence integrated media GmbH - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. - *   */  #ifndef _UAPI_DVBVIDEO_H_ diff --git a/include/uapi/linux/dw100.h b/include/uapi/linux/dw100.h new file mode 100644 index 000000000000..3356496edd6b --- /dev/null +++ b/include/uapi/linux/dw100.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* Copyright 2022 NXP */ + +#ifndef __UAPI_DW100_H__ +#define __UAPI_DW100_H__ + +#include <linux/v4l2-controls.h> + +/* + * Check Documentation/userspace-api/media/drivers/dw100.rst for control details. + */ +#define V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP (V4L2_CID_USER_DW100_BASE + 1) + +#endif diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h index f47e853546fa..ef38c2bc5ab7 100644 --- a/include/uapi/linux/elf-em.h +++ b/include/uapi/linux/elf-em.h @@ -51,6 +51,7 @@  #define EM_RISCV	243	/* RISC-V */  #define EM_BPF		247	/* Linux BPF - in-kernel virtual machine */  #define EM_CSKY		252	/* C-SKY */ +#define EM_LOONGARCH	258	/* LoongArch */  #define EM_FRV		0x5441	/* Fujitsu FR-V */  /* diff --git a/include/uapi/linux/elf-fdpic.h b/include/uapi/linux/elf-fdpic.h index 4fcc6cfebe18..ec23f0871129 100644 --- a/include/uapi/linux/elf-fdpic.h +++ b/include/uapi/linux/elf-fdpic.h @@ -32,4 +32,19 @@ struct elf32_fdpic_loadmap {  #define ELF32_FDPIC_LOADMAP_VERSION	0x0000 +/* segment mappings for ELF FDPIC libraries/executables/interpreters */ +struct elf64_fdpic_loadseg { +	Elf64_Addr	addr;		/* core address to which mapped */ +	Elf64_Addr	p_vaddr;	/* VMA recorded in file */ +	Elf64_Word	p_memsz;	/* allocation size recorded in file */ +}; + +struct elf64_fdpic_loadmap { +	Elf64_Half	version;	/* version of these structures, just in case... */ +	Elf64_Half	nsegs;		/* number of segments */ +	struct elf64_fdpic_loadseg segs[]; +}; + +#define ELF64_FDPIC_LOADMAP_VERSION	0x0000 +  #endif /* _UAPI_LINUX_ELF_FDPIC_H */ diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index 22220945a5fd..819ded2d39de 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -11,6 +11,7 @@ typedef __u16	Elf32_Half;  typedef __u32	Elf32_Off;  typedef __s32	Elf32_Sword;  typedef __u32	Elf32_Word; +typedef __u16	Elf32_Versym;  /* 64-bit ELF base types. */  typedef __u64	Elf64_Addr; @@ -21,6 +22,7 @@ typedef __s32	Elf64_Sword;  typedef __u32	Elf64_Word;  typedef __u64	Elf64_Xword;  typedef __s64	Elf64_Sxword; +typedef __u16	Elf64_Versym;  /* These constants are for the segment types stored in the image headers */  #define PT_NULL    0 @@ -35,10 +37,14 @@ typedef __s64	Elf64_Sxword;  #define PT_HIOS    0x6fffffff      /* OS-specific */  #define PT_LOPROC  0x70000000  #define PT_HIPROC  0x7fffffff -#define PT_GNU_EH_FRAME		0x6474e550 -#define PT_GNU_PROPERTY		0x6474e553 - +#define PT_GNU_EH_FRAME	(PT_LOOS + 0x474e550)  #define PT_GNU_STACK	(PT_LOOS + 0x474e551) +#define PT_GNU_RELRO	(PT_LOOS + 0x474e552) +#define PT_GNU_PROPERTY	(PT_LOOS + 0x474e553) + + +/* ARM MTE memory tag segment type */ +#define PT_AARCH64_MEMTAG_MTE	(PT_LOPROC + 0x2)  /*   * Extended Numbering @@ -87,7 +93,7 @@ typedef __s64	Elf64_Sxword;  #define DT_INIT		12  #define DT_FINI		13  #define DT_SONAME	14 -#define DT_RPATH 	15 +#define DT_RPATH	15  #define DT_SYMBOLIC	16  #define DT_REL	        17  #define DT_RELSZ	18 @@ -103,6 +109,7 @@ typedef __s64	Elf64_Sxword;  #define DT_VALRNGLO	0x6ffffd00  #define DT_VALRNGHI	0x6ffffdff  #define DT_ADDRRNGLO	0x6ffffe00 +#define DT_GNU_HASH	0x6ffffef5  #define DT_ADDRRNGHI	0x6ffffeff  #define DT_VERSYM	0x6ffffff0  #define DT_RELACOUNT	0x6ffffff9 @@ -121,6 +128,8 @@ typedef __s64	Elf64_Sxword;  #define STB_GLOBAL 1  #define STB_WEAK   2 +#define STN_UNDEF 0 +  #define STT_NOTYPE  0  #define STT_OBJECT  1  #define STT_FUNC    2 @@ -129,16 +138,19 @@ typedef __s64	Elf64_Sxword;  #define STT_COMMON  5  #define STT_TLS     6 +#define VER_FLG_BASE 0x1 +#define VER_FLG_WEAK 0x2 +  #define ELF_ST_BIND(x)		((x) >> 4) -#define ELF_ST_TYPE(x)		(((unsigned int) x) & 0xf) +#define ELF_ST_TYPE(x)		((x) & 0xf)  #define ELF32_ST_BIND(x)	ELF_ST_BIND(x)  #define ELF32_ST_TYPE(x)	ELF_ST_TYPE(x)  #define ELF64_ST_BIND(x)	ELF_ST_BIND(x)  #define ELF64_ST_TYPE(x)	ELF_ST_TYPE(x) -typedef struct dynamic{ +typedef struct {    Elf32_Sword d_tag; -  union{ +  union {      Elf32_Sword	d_val;      Elf32_Addr	d_ptr;    } d_un; @@ -169,7 +181,7 @@ typedef struct elf64_rel {    Elf64_Xword r_info;	/* index and type of relocation */  } Elf64_Rel; -typedef struct elf32_rela{ +typedef struct elf32_rela {    Elf32_Addr	r_offset;    Elf32_Word	r_info;    Elf32_Sword	r_addend; @@ -181,7 +193,7 @@ typedef struct elf64_rela {    Elf64_Sxword r_addend;	/* Constant addend used to compute value */  } Elf64_Rela; -typedef struct elf32_sym{ +typedef struct elf32_sym {    Elf32_Word	st_name;    Elf32_Addr	st_value;    Elf32_Word	st_size; @@ -202,7 +214,7 @@ typedef struct elf64_sym {  #define EI_NIDENT	16 -typedef struct elf32_hdr{ +typedef struct elf32_hdr {    unsigned char	e_ident[EI_NIDENT];    Elf32_Half	e_type;    Elf32_Half	e_machine; @@ -242,7 +254,7 @@ typedef struct elf64_hdr {  #define PF_W		0x2  #define PF_X		0x1 -typedef struct elf32_phdr{ +typedef struct elf32_phdr {    Elf32_Word	p_type;    Elf32_Off	p_offset;    Elf32_Addr	p_vaddr; @@ -287,8 +299,18 @@ typedef struct elf64_phdr {  #define SHF_WRITE		0x1  #define SHF_ALLOC		0x2  #define SHF_EXECINSTR		0x4 +#define SHF_MERGE		0x10 +#define SHF_STRINGS		0x20 +#define SHF_INFO_LINK		0x40 +#define SHF_LINK_ORDER		0x80 +#define SHF_OS_NONCONFORMING	0x100 +#define SHF_GROUP		0x200 +#define SHF_TLS			0x400  #define SHF_RELA_LIVEPATCH	0x00100000  #define SHF_RO_AFTER_INIT	0x00200000 +#define SHF_ORDERED		0x04000000 +#define SHF_EXCLUDE		0x08000000 +#define SHF_MASKOS		0x0ff00000  #define SHF_MASKPROC		0xf0000000  /* special section indexes */ @@ -364,75 +386,179 @@ typedef struct elf64_shdr {  #define ELF_OSABI ELFOSABI_NONE  #endif +/* Note definitions: NN_ defines names. NT_ defines types. */ + +#define NN_GNU_PROPERTY_TYPE_0	"GNU" +#define NT_GNU_PROPERTY_TYPE_0	5 +  /*   * Notes used in ET_CORE. Architectures export some of the arch register sets   * using the corresponding note types via the PTRACE_GETREGSET and   * PTRACE_SETREGSET requests. - * The note name for all these is "LINUX".   */ +#define NN_PRSTATUS	"CORE"  #define NT_PRSTATUS	1 +#define NN_PRFPREG	"CORE"  #define NT_PRFPREG	2 +#define NN_PRPSINFO	"CORE"  #define NT_PRPSINFO	3 +#define NN_TASKSTRUCT	"CORE"  #define NT_TASKSTRUCT	4 +#define NN_AUXV		"CORE"  #define NT_AUXV		6  /*   * Note to userspace developers: size of NT_SIGINFO note may increase   * in the future to accomodate more fields, don't assume it is fixed!   */ +#define NN_SIGINFO      "CORE"  #define NT_SIGINFO      0x53494749 +#define NN_FILE         "CORE"  #define NT_FILE         0x46494c45 +#define NN_PRXFPREG     "LINUX"  #define NT_PRXFPREG     0x46e62b7f      /* copied from gdb5.1/include/elf/common.h */ +#define NN_PPC_VMX	"LINUX"  #define NT_PPC_VMX	0x100		/* PowerPC Altivec/VMX registers */ +#define NN_PPC_SPE	"LINUX"  #define NT_PPC_SPE	0x101		/* PowerPC SPE/EVR registers */ +#define NN_PPC_VSX	"LINUX"  #define NT_PPC_VSX	0x102		/* PowerPC VSX registers */ +#define NN_PPC_TAR	"LINUX"  #define NT_PPC_TAR	0x103		/* Target Address Register */ +#define NN_PPC_PPR	"LINUX"  #define NT_PPC_PPR	0x104		/* Program Priority Register */ +#define NN_PPC_DSCR	"LINUX"  #define NT_PPC_DSCR	0x105		/* Data Stream Control Register */ +#define NN_PPC_EBB	"LINUX"  #define NT_PPC_EBB	0x106		/* Event Based Branch Registers */ +#define NN_PPC_PMU	"LINUX"  #define NT_PPC_PMU	0x107		/* Performance Monitor Registers */ +#define NN_PPC_TM_CGPR	"LINUX"  #define NT_PPC_TM_CGPR	0x108		/* TM checkpointed GPR Registers */ +#define NN_PPC_TM_CFPR	"LINUX"  #define NT_PPC_TM_CFPR	0x109		/* TM checkpointed FPR Registers */ +#define NN_PPC_TM_CVMX	"LINUX"  #define NT_PPC_TM_CVMX	0x10a		/* TM checkpointed VMX Registers */ +#define NN_PPC_TM_CVSX	"LINUX"  #define NT_PPC_TM_CVSX	0x10b		/* TM checkpointed VSX Registers */ +#define NN_PPC_TM_SPR	"LINUX"  #define NT_PPC_TM_SPR	0x10c		/* TM Special Purpose Registers */ +#define NN_PPC_TM_CTAR	"LINUX"  #define NT_PPC_TM_CTAR	0x10d		/* TM checkpointed Target Address Register */ +#define NN_PPC_TM_CPPR	"LINUX"  #define NT_PPC_TM_CPPR	0x10e		/* TM checkpointed Program Priority Register */ +#define NN_PPC_TM_CDSCR	"LINUX"  #define NT_PPC_TM_CDSCR	0x10f		/* TM checkpointed Data Stream Control Register */ +#define NN_PPC_PKEY	"LINUX"  #define NT_PPC_PKEY	0x110		/* Memory Protection Keys registers */ +#define NN_PPC_DEXCR	"LINUX" +#define NT_PPC_DEXCR	0x111		/* PowerPC DEXCR registers */ +#define NN_PPC_HASHKEYR	"LINUX" +#define NT_PPC_HASHKEYR	0x112		/* PowerPC HASHKEYR register */ +#define NN_386_TLS	"LINUX"  #define NT_386_TLS	0x200		/* i386 TLS slots (struct user_desc) */ +#define NN_386_IOPERM	"LINUX"  #define NT_386_IOPERM	0x201		/* x86 io permission bitmap (1=deny) */ +#define NN_X86_XSTATE	"LINUX"  #define NT_X86_XSTATE	0x202		/* x86 extended state using xsave */ +/* Old binutils treats 0x203 as a CET state */ +#define NN_X86_SHSTK	"LINUX" +#define NT_X86_SHSTK	0x204		/* x86 SHSTK state */ +#define NN_X86_XSAVE_LAYOUT	"LINUX" +#define NT_X86_XSAVE_LAYOUT	0x205	/* XSAVE layout description */ +#define NN_S390_HIGH_GPRS	"LINUX"  #define NT_S390_HIGH_GPRS	0x300	/* s390 upper register halves */ +#define NN_S390_TIMER	"LINUX"  #define NT_S390_TIMER	0x301		/* s390 timer register */ +#define NN_S390_TODCMP	"LINUX"  #define NT_S390_TODCMP	0x302		/* s390 TOD clock comparator register */ +#define NN_S390_TODPREG	"LINUX"  #define NT_S390_TODPREG	0x303		/* s390 TOD programmable register */ +#define NN_S390_CTRS	"LINUX"  #define NT_S390_CTRS	0x304		/* s390 control registers */ +#define NN_S390_PREFIX	"LINUX"  #define NT_S390_PREFIX	0x305		/* s390 prefix register */ +#define NN_S390_LAST_BREAK	"LINUX"  #define NT_S390_LAST_BREAK	0x306	/* s390 breaking event address */ +#define NN_S390_SYSTEM_CALL	"LINUX"  #define NT_S390_SYSTEM_CALL	0x307	/* s390 system call restart data */ +#define NN_S390_TDB	"LINUX"  #define NT_S390_TDB	0x308		/* s390 transaction diagnostic block */ +#define NN_S390_VXRS_LOW	"LINUX"  #define NT_S390_VXRS_LOW	0x309	/* s390 vector registers 0-15 upper half */ +#define NN_S390_VXRS_HIGH	"LINUX"  #define NT_S390_VXRS_HIGH	0x30a	/* s390 vector registers 16-31 */ +#define NN_S390_GS_CB	"LINUX"  #define NT_S390_GS_CB	0x30b		/* s390 guarded storage registers */ +#define NN_S390_GS_BC	"LINUX"  #define NT_S390_GS_BC	0x30c		/* s390 guarded storage broadcast control block */ +#define NN_S390_RI_CB	"LINUX"  #define NT_S390_RI_CB	0x30d		/* s390 runtime instrumentation */ +#define NN_S390_PV_CPU_DATA	"LINUX" +#define NT_S390_PV_CPU_DATA	0x30e	/* s390 protvirt cpu dump data */ +#define NN_ARM_VFP	"LINUX"  #define NT_ARM_VFP	0x400		/* ARM VFP/NEON registers */ +#define NN_ARM_TLS	"LINUX"  #define NT_ARM_TLS	0x401		/* ARM TLS register */ +#define NN_ARM_HW_BREAK	"LINUX"  #define NT_ARM_HW_BREAK	0x402		/* ARM hardware breakpoint registers */ +#define NN_ARM_HW_WATCH	"LINUX"  #define NT_ARM_HW_WATCH	0x403		/* ARM hardware watchpoint registers */ +#define NN_ARM_SYSTEM_CALL	"LINUX"  #define NT_ARM_SYSTEM_CALL	0x404	/* ARM system call number */ +#define NN_ARM_SVE	"LINUX"  #define NT_ARM_SVE	0x405		/* ARM Scalable Vector Extension registers */ +#define NN_ARM_PAC_MASK		"LINUX"  #define NT_ARM_PAC_MASK		0x406	/* ARM pointer authentication code masks */ +#define NN_ARM_PACA_KEYS	"LINUX"  #define NT_ARM_PACA_KEYS	0x407	/* ARM pointer authentication address keys */ +#define NN_ARM_PACG_KEYS	"LINUX"  #define NT_ARM_PACG_KEYS	0x408	/* ARM pointer authentication generic key */ +#define NN_ARM_TAGGED_ADDR_CTRL	"LINUX" +#define NT_ARM_TAGGED_ADDR_CTRL	0x409	/* arm64 tagged address control (prctl()) */ +#define NN_ARM_PAC_ENABLED_KEYS	"LINUX" +#define NT_ARM_PAC_ENABLED_KEYS	0x40a	/* arm64 ptr auth enabled keys (prctl()) */ +#define NN_ARM_SSVE	"LINUX" +#define NT_ARM_SSVE	0x40b		/* ARM Streaming SVE registers */ +#define NN_ARM_ZA	"LINUX" +#define NT_ARM_ZA	0x40c		/* ARM SME ZA registers */ +#define NN_ARM_ZT	"LINUX" +#define NT_ARM_ZT	0x40d		/* ARM SME ZT registers */ +#define NN_ARM_FPMR	"LINUX" +#define NT_ARM_FPMR	0x40e		/* ARM floating point mode register */ +#define NN_ARM_POE	"LINUX" +#define NT_ARM_POE	0x40f		/* ARM POE registers */ +#define NN_ARM_GCS	"LINUX" +#define NT_ARM_GCS	0x410		/* ARM GCS state */ +#define NN_ARC_V2	"LINUX"  #define NT_ARC_V2	0x600		/* ARCv2 accumulator/extra registers */ +#define NN_VMCOREDD	"LINUX"  #define NT_VMCOREDD	0x700		/* Vmcore Device Dump Note */ +#define NN_MIPS_DSP	"LINUX"  #define NT_MIPS_DSP	0x800		/* MIPS DSP ASE registers */ +#define NN_MIPS_FP_MODE	"LINUX"  #define NT_MIPS_FP_MODE	0x801		/* MIPS floating-point mode */ +#define NN_MIPS_MSA	"LINUX"  #define NT_MIPS_MSA	0x802		/* MIPS SIMD registers */ - -/* Note types with note name "GNU" */ -#define NT_GNU_PROPERTY_TYPE_0	5 +#define NN_RISCV_CSR	"LINUX" +#define NT_RISCV_CSR	0x900		/* RISC-V Control and Status Registers */ +#define NN_RISCV_VECTOR	"LINUX" +#define NT_RISCV_VECTOR	0x901		/* RISC-V vector registers */ +#define NN_RISCV_TAGGED_ADDR_CTRL "LINUX" +#define NT_RISCV_TAGGED_ADDR_CTRL 0x902	/* RISC-V tagged address control (prctl()) */ +#define NN_LOONGARCH_CPUCFG	"LINUX" +#define NT_LOONGARCH_CPUCFG	0xa00	/* LoongArch CPU config registers */ +#define NN_LOONGARCH_CSR	"LINUX" +#define NT_LOONGARCH_CSR	0xa01	/* LoongArch control and status registers */ +#define NN_LOONGARCH_LSX	"LINUX" +#define NT_LOONGARCH_LSX	0xa02	/* LoongArch Loongson SIMD Extension registers */ +#define NN_LOONGARCH_LASX	"LINUX" +#define NT_LOONGARCH_LASX	0xa03	/* LoongArch Loongson Advanced SIMD Extension registers */ +#define NN_LOONGARCH_LBT	"LINUX" +#define NT_LOONGARCH_LBT	0xa04	/* LoongArch Loongson Binary Translation registers */ +#define NN_LOONGARCH_HW_BREAK	"LINUX" +#define NT_LOONGARCH_HW_BREAK	0xa05   /* LoongArch hardware breakpoint registers */ +#define NN_LOONGARCH_HW_WATCH	"LINUX" +#define NT_LOONGARCH_HW_WATCH	0xa06   /* LoongArch hardware watchpoint registers */  /* Note header in a PT_NOTE section */  typedef struct elf32_note { @@ -454,4 +580,34 @@ typedef struct elf64_note {  /* Bits for GNU_PROPERTY_AARCH64_FEATURE_1_BTI */  #define GNU_PROPERTY_AARCH64_FEATURE_1_BTI	(1U << 0) +typedef struct { +  Elf32_Half	vd_version; +  Elf32_Half	vd_flags; +  Elf32_Half	vd_ndx; +  Elf32_Half	vd_cnt; +  Elf32_Word	vd_hash; +  Elf32_Word	vd_aux; +  Elf32_Word	vd_next; +} Elf32_Verdef; + +typedef struct { +  Elf64_Half	vd_version; +  Elf64_Half	vd_flags; +  Elf64_Half	vd_ndx; +  Elf64_Half	vd_cnt; +  Elf64_Word	vd_hash; +  Elf64_Word	vd_aux; +  Elf64_Word	vd_next; +} Elf64_Verdef; + +typedef struct { +  Elf32_Word    vda_name; +  Elf32_Word    vda_next; +} Elf32_Verdaux; + +typedef struct { +  Elf64_Word    vda_name; +  Elf64_Word    vda_next; +} Elf64_Verdaux; +  #endif /* _UAPI_LINUX_ELF_H */ diff --git a/include/uapi/linux/errqueue.h b/include/uapi/linux/errqueue.h index 3c70e8ac14b8..1ea47309d772 100644 --- a/include/uapi/linux/errqueue.h +++ b/include/uapi/linux/errqueue.h @@ -73,6 +73,7 @@ enum {  	SCM_TSTAMP_SND,		/* driver passed skb to NIC, or HW */  	SCM_TSTAMP_SCHED,	/* data entered the packet scheduler */  	SCM_TSTAMP_ACK,		/* data acknowledged by peer */ +	SCM_TSTAMP_COMPLETION,	/* packet tx completion */  };  #endif /* _UAPI_LINUX_ERRQUEUE_H */ diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index b4f2d134e713..9e9afdd1238a 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -14,7 +14,7 @@  #ifndef _UAPI_LINUX_ETHTOOL_H  #define _UAPI_LINUX_ETHTOOL_H -#include <linux/kernel.h> +#include <linux/const.h>  #include <linux/types.h>  #include <linux/if_ether.h> @@ -26,6 +26,14 @@   * have the same layout for 32-bit and 64-bit userland.   */ +/* Note on reserved space. + * Reserved fields must not be accessed directly by user space because + * they may be replaced by a different field in the future. They must + * be initialized to zero before making the request, e.g. via memset + * of the entire structure or implicitly by not being set in a structure + * initializer. + */ +  /**   * struct ethtool_cmd - DEPRECATED, link control and status   * This structure is DEPRECATED, please use struct ethtool_link_settings. @@ -67,6 +75,7 @@   *	and other link features that the link partner advertised   *	through autonegotiation; 0 if unknown or not applicable.   *	Read-only. + * @reserved: Reserved for future use; see the note on reserved space.   *   * The link speed in Mbps is split between @speed and @speed_hi.  Use   * the ethtool_cmd_speed() and ethtool_cmd_speed_set() functions to @@ -150,11 +159,14 @@ static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)   *	in its bus driver structure (e.g. pci_driver::name).  Must   *	not be an empty string.   * @version: Driver version string; may be an empty string - * @fw_version: Firmware version string; may be an empty string - * @erom_version: Expansion ROM version string; may be an empty string + * @fw_version: Firmware version string; driver defined; may be an + *	empty string + * @erom_version: Expansion ROM version string; driver defined; may be + *	an empty string   * @bus_info: Device bus address.  This should match the dev_name()   *	string for the underlying bus device, if there is one.  May be   *	an empty string. + * @reserved2: Reserved for future use; see the note on reserved space.   * @n_priv_flags: Number of flags valid for %ETHTOOL_GPFLAGS and   *	%ETHTOOL_SPFLAGS commands; also the number of strings in the   *	%ETH_SS_PRIV_FLAGS set @@ -169,10 +181,6 @@ static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)   *   * Users can use the %ETHTOOL_GSSET_INFO command to get the number of   * strings in any string set (from Linux 2.6.34). - * - * Drivers should set at most @driver, @version, @fw_version and - * @bus_info in their get_drvinfo() implementation.  The ethtool - * core fills in the other fields using other driver operations.   */  struct ethtool_drvinfo {  	__u32	cmd; @@ -221,9 +229,10 @@ enum tunable_id {  	ETHTOOL_RX_COPYBREAK,  	ETHTOOL_TX_COPYBREAK,  	ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */ +	ETHTOOL_TX_COPYBREAK_BUF_SIZE,  	/*  	 * Add your fresh new tunable attribute above and remember to update -	 * tunable_strings[] in net/core/ethtool.c +	 * tunable_strings[] in net/ethtool/common.c  	 */  	__ETHTOOL_TUNABLE_COUNT,  }; @@ -246,7 +255,7 @@ struct ethtool_tunable {  	__u32	id;  	__u32	type_id;  	__u32	len; -	void	*data[0]; +	void	*data[];  };  #define DOWNSHIFT_DEV_DEFAULT_COUNT	0xff @@ -287,7 +296,7 @@ enum phy_tunable_id {  	ETHTOOL_PHY_EDPD,  	/*  	 * Add your fresh new phy tunable attribute above and remember to update -	 * phy_tunable_strings[] in net/core/ethtool.c +	 * phy_tunable_strings[] in net/ethtool/common.c  	 */  	__ETHTOOL_PHY_TUNABLE_COUNT,  }; @@ -311,7 +320,7 @@ struct ethtool_regs {  	__u32	cmd;  	__u32	version;  	__u32	len; -	__u8	data[0]; +	__u8	data[];  };  /** @@ -337,7 +346,7 @@ struct ethtool_eeprom {  	__u32	magic;  	__u32	offset;  	__u32	len; -	__u8	data[0]; +	__u8	data[];  };  /** @@ -356,6 +365,7 @@ struct ethtool_eeprom {   * @tx_lpi_timer: Time in microseconds the interface delays prior to asserting   *	its tx lpi (after reaching 'idle' state). Effective only when eee   *	was negotiated and tx_lpi_enabled was set. + * @reserved: Reserved for future use; see the note on reserved space.   */  struct ethtool_eee {  	__u32	cmd; @@ -374,6 +384,7 @@ struct ethtool_eee {   * @cmd: %ETHTOOL_GMODULEINFO   * @type: Standard the module information conforms to %ETH_MODULE_SFF_xxxx   * @eeprom_len: Length of the eeprom + * @reserved: Reserved for future use; see the note on reserved space.   *   * This structure is used to return the information to   * properly size memory for a subsequent call to %ETHTOOL_GMODULEEEPROM. @@ -579,9 +590,7 @@ struct ethtool_pauseparam {  	__u32	tx_pause;  }; -/** - * enum ethtool_link_ext_state - link extended state - */ +/* Link extended state */  enum ethtool_link_ext_state {  	ETHTOOL_LINK_EXT_STATE_AUTONEG,  	ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE, @@ -593,12 +602,10 @@ enum ethtool_link_ext_state {  	ETHTOOL_LINK_EXT_STATE_CALIBRATION_FAILURE,  	ETHTOOL_LINK_EXT_STATE_POWER_BUDGET_EXCEEDED,  	ETHTOOL_LINK_EXT_STATE_OVERHEAT, +	ETHTOOL_LINK_EXT_STATE_MODULE,  }; -/** - * enum ethtool_link_ext_substate_autoneg - more information in addition to - * ETHTOOL_LINK_EXT_STATE_AUTONEG. - */ +/* More information in addition to ETHTOOL_LINK_EXT_STATE_AUTONEG. */  enum ethtool_link_ext_substate_autoneg {  	ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED = 1,  	ETHTOOL_LINK_EXT_SUBSTATE_AN_ACK_NOT_RECEIVED, @@ -608,9 +615,7 @@ enum ethtool_link_ext_substate_autoneg {  	ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_HCD,  }; -/** - * enum ethtool_link_ext_substate_link_training - more information in addition to - * ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE. +/* More information in addition to ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE.   */  enum ethtool_link_ext_substate_link_training {  	ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_FRAME_LOCK_NOT_ACQUIRED = 1, @@ -619,9 +624,7 @@ enum ethtool_link_ext_substate_link_training {  	ETHTOOL_LINK_EXT_SUBSTATE_LT_REMOTE_FAULT,  }; -/** - * enum ethtool_link_ext_substate_logical_mismatch - more information in addition - * to ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH. +/* More information in addition to ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH.   */  enum ethtool_link_ext_substate_link_logical_mismatch {  	ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_BLOCK_LOCK = 1, @@ -631,24 +634,26 @@ enum ethtool_link_ext_substate_link_logical_mismatch {  	ETHTOOL_LINK_EXT_SUBSTATE_LLM_RS_FEC_IS_NOT_LOCKED,  }; -/** - * enum ethtool_link_ext_substate_bad_signal_integrity - more information in - * addition to ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY. +/* More information in addition to ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY.   */  enum ethtool_link_ext_substate_bad_signal_integrity {  	ETHTOOL_LINK_EXT_SUBSTATE_BSI_LARGE_NUMBER_OF_PHYSICAL_ERRORS = 1,  	ETHTOOL_LINK_EXT_SUBSTATE_BSI_UNSUPPORTED_RATE, +	ETHTOOL_LINK_EXT_SUBSTATE_BSI_SERDES_REFERENCE_CLOCK_LOST, +	ETHTOOL_LINK_EXT_SUBSTATE_BSI_SERDES_ALOS,  }; -/** - * enum ethtool_link_ext_substate_cable_issue - more information in - * addition to ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE. - */ +/* More information in addition to ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE. */  enum ethtool_link_ext_substate_cable_issue {  	ETHTOOL_LINK_EXT_SUBSTATE_CI_UNSUPPORTED_CABLE = 1,  	ETHTOOL_LINK_EXT_SUBSTATE_CI_CABLE_TEST_FAILURE,  }; +/* More information in addition to ETHTOOL_LINK_EXT_STATE_MODULE. */ +enum ethtool_link_ext_substate_module { +	ETHTOOL_LINK_EXT_SUBSTATE_MODULE_CMIS_NOT_READY = 1, +}; +  #define ETH_GSTRING_LEN		32  /** @@ -661,6 +666,7 @@ enum ethtool_link_ext_substate_cable_issue {   *	now deprecated   * @ETH_SS_FEATURES: Device feature names   * @ETH_SS_RSS_HASH_FUNCS: RSS hush function names + * @ETH_SS_TUNABLES: tunable names   * @ETH_SS_PHY_STATS: Statistic names, for use with %ETHTOOL_GPHYSTATS   * @ETH_SS_PHY_TUNABLES: PHY tunable names   * @ETH_SS_LINK_MODES: link mode names @@ -670,6 +676,15 @@ enum ethtool_link_ext_substate_cable_issue {   * @ETH_SS_TS_TX_TYPES: timestamping Tx types   * @ETH_SS_TS_RX_FILTERS: timestamping Rx filters   * @ETH_SS_UDP_TUNNEL_TYPES: UDP tunnel types + * @ETH_SS_STATS_STD: standardized stats + * @ETH_SS_STATS_ETH_PHY: names of IEEE 802.3 PHY statistics + * @ETH_SS_STATS_ETH_MAC: names of IEEE 802.3 MAC statistics + * @ETH_SS_STATS_ETH_CTRL: names of IEEE 802.3 MAC Control statistics + * @ETH_SS_STATS_RMON: names of RMON statistics + * @ETH_SS_STATS_PHY: names of PHY(dev) statistics + * @ETH_SS_TS_FLAGS: hardware timestamping flags + * + * @ETH_SS_COUNT: number of defined string sets   */  enum ethtool_stringset {  	ETH_SS_TEST		= 0, @@ -688,12 +703,394 @@ enum ethtool_stringset {  	ETH_SS_TS_TX_TYPES,  	ETH_SS_TS_RX_FILTERS,  	ETH_SS_UDP_TUNNEL_TYPES, +	ETH_SS_STATS_STD, +	ETH_SS_STATS_ETH_PHY, +	ETH_SS_STATS_ETH_MAC, +	ETH_SS_STATS_ETH_CTRL, +	ETH_SS_STATS_RMON, +	ETH_SS_STATS_PHY, +	ETH_SS_TS_FLAGS,  	/* add new constants above here */  	ETH_SS_COUNT  };  /** + * enum ethtool_mac_stats_src - source of ethtool MAC statistics + * @ETHTOOL_MAC_STATS_SRC_AGGREGATE: + *	if device supports a MAC merge layer, this retrieves the aggregate + *	statistics of the eMAC and pMAC. Otherwise, it retrieves just the + *	statistics of the single (express) MAC. + * @ETHTOOL_MAC_STATS_SRC_EMAC: + *	if device supports a MM layer, this retrieves the eMAC statistics. + *	Otherwise, it retrieves the statistics of the single (express) MAC. + * @ETHTOOL_MAC_STATS_SRC_PMAC: + *	if device supports a MM layer, this retrieves the pMAC statistics. + */ +enum ethtool_mac_stats_src { +	ETHTOOL_MAC_STATS_SRC_AGGREGATE, +	ETHTOOL_MAC_STATS_SRC_EMAC, +	ETHTOOL_MAC_STATS_SRC_PMAC, +}; + +/** + * enum ethtool_module_power_mode_policy - plug-in module power mode policy + * @ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH: Module is always in high power mode. + * @ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO: Module is transitioned by the host + *	to high power mode when the first port using it is put administratively + *	up and to low power mode when the last port using it is put + *	administratively down. + */ +enum ethtool_module_power_mode_policy { +	ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH = 1, +	ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO, +}; + +/** + * enum ethtool_module_power_mode - plug-in module power mode + * @ETHTOOL_MODULE_POWER_MODE_LOW: Module is in low power mode. + * @ETHTOOL_MODULE_POWER_MODE_HIGH: Module is in high power mode. + */ +enum ethtool_module_power_mode { +	ETHTOOL_MODULE_POWER_MODE_LOW = 1, +	ETHTOOL_MODULE_POWER_MODE_HIGH, +}; + +/** + * enum ethtool_c33_pse_ext_state - groups of PSE extended states + *      functions. IEEE 802.3-2022 33.2.4.4 Variables + * + * @ETHTOOL_C33_PSE_EXT_STATE_ERROR_CONDITION: Group of error_condition states + * @ETHTOOL_C33_PSE_EXT_STATE_MR_MPS_VALID: Group of mr_mps_valid states + * @ETHTOOL_C33_PSE_EXT_STATE_MR_PSE_ENABLE: Group of mr_pse_enable states + * @ETHTOOL_C33_PSE_EXT_STATE_OPTION_DETECT_TED: Group of option_detect_ted + *	states + * @ETHTOOL_C33_PSE_EXT_STATE_OPTION_VPORT_LIM: Group of option_vport_lim states + * @ETHTOOL_C33_PSE_EXT_STATE_OVLD_DETECTED: Group of ovld_detected states + * @ETHTOOL_C33_PSE_EXT_STATE_PD_DLL_POWER_TYPE: Group of pd_dll_power_type + *	states + * @ETHTOOL_C33_PSE_EXT_STATE_POWER_NOT_AVAILABLE: Group of power_not_available + *	states + * @ETHTOOL_C33_PSE_EXT_STATE_SHORT_DETECTED: Group of short_detected states + */ +enum ethtool_c33_pse_ext_state { +	ETHTOOL_C33_PSE_EXT_STATE_ERROR_CONDITION = 1, +	ETHTOOL_C33_PSE_EXT_STATE_MR_MPS_VALID, +	ETHTOOL_C33_PSE_EXT_STATE_MR_PSE_ENABLE, +	ETHTOOL_C33_PSE_EXT_STATE_OPTION_DETECT_TED, +	ETHTOOL_C33_PSE_EXT_STATE_OPTION_VPORT_LIM, +	ETHTOOL_C33_PSE_EXT_STATE_OVLD_DETECTED, +	ETHTOOL_C33_PSE_EXT_STATE_PD_DLL_POWER_TYPE, +	ETHTOOL_C33_PSE_EXT_STATE_POWER_NOT_AVAILABLE, +	ETHTOOL_C33_PSE_EXT_STATE_SHORT_DETECTED, +}; + +/** + * enum ethtool_c33_pse_ext_substate_mr_mps_valid - mr_mps_valid states + *      functions. IEEE 802.3-2022 33.2.4.4 Variables + * + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_MPS_VALID_DETECTED_UNDERLOAD: Underload + *	state + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_MPS_VALID_CONNECTION_OPEN: Port is not + *	connected + * + * The PSE monitors either the DC or AC Maintain Power Signature + * (MPS, see 33.2.9.1). This variable indicates the presence or absence of + * a valid MPS. + */ +enum ethtool_c33_pse_ext_substate_mr_mps_valid { +	ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_MPS_VALID_DETECTED_UNDERLOAD = 1, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_MPS_VALID_CONNECTION_OPEN, +}; + +/** + * enum ethtool_c33_pse_ext_substate_error_condition - error_condition states + *      functions. IEEE 802.3-2022 33.2.4.4 Variables + * + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_NON_EXISTING_PORT: Non-existing + *	port number + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_UNDEFINED_PORT: Undefined port + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_INTERNAL_HW_FAULT: Internal + *	hardware fault + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_COMM_ERROR_AFTER_FORCE_ON: + *	Communication error after force on + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_UNKNOWN_PORT_STATUS: Unknown + *	port status + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_HOST_CRASH_TURN_OFF: Host + *	crash turn off + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_HOST_CRASH_FORCE_SHUTDOWN: + *	Host crash force shutdown + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_CONFIG_CHANGE: Configuration + *	change + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_DETECTED_OVER_TEMP: Over + *	temperature detected + * + * error_condition is a variable indicating the status of + * implementation-specific fault conditions or optionally other system faults + * that prevent the PSE from meeting the specifications in Table 33–11 and that + * require the PSE not to source power. These error conditions are different + * from those monitored by the state diagrams in Figure 33–10. + */ +enum ethtool_c33_pse_ext_substate_error_condition { +	ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_NON_EXISTING_PORT = 1, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_UNDEFINED_PORT, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_INTERNAL_HW_FAULT, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_COMM_ERROR_AFTER_FORCE_ON, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_UNKNOWN_PORT_STATUS, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_HOST_CRASH_TURN_OFF, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_HOST_CRASH_FORCE_SHUTDOWN, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_CONFIG_CHANGE, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_ERROR_CONDITION_DETECTED_OVER_TEMP, +}; + +/** + * enum ethtool_c33_pse_ext_substate_mr_pse_enable - mr_pse_enable states + *      functions. IEEE 802.3-2022 33.2.4.4 Variables + * + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_PSE_ENABLE_DISABLE_PIN_ACTIVE: Disable + *	pin active + * + * mr_pse_enable is control variable that selects PSE operation and test + * functions. + */ +enum ethtool_c33_pse_ext_substate_mr_pse_enable { +	ETHTOOL_C33_PSE_EXT_SUBSTATE_MR_PSE_ENABLE_DISABLE_PIN_ACTIVE = 1, +}; + +/** + * enum ethtool_c33_pse_ext_substate_option_detect_ted - option_detect_ted + *	states functions. IEEE 802.3-2022 33.2.4.4 Variables + * + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_DETECT_TED_DET_IN_PROCESS: Detection + *	in process + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_DETECT_TED_CONNECTION_CHECK_ERROR: + *	Connection check error + * + * option_detect_ted is a variable indicating if detection can be performed + * by the PSE during the ted_timer interval. + */ +enum ethtool_c33_pse_ext_substate_option_detect_ted { +	ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_DETECT_TED_DET_IN_PROCESS = 1, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_DETECT_TED_CONNECTION_CHECK_ERROR, +}; + +/** + * enum ethtool_c33_pse_ext_substate_option_vport_lim - option_vport_lim states + *      functions. IEEE 802.3-2022 33.2.4.4 Variables + * + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_HIGH_VOLTAGE: Main supply + *	voltage is high + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_LOW_VOLTAGE: Main supply + *	voltage is low + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_VOLTAGE_INJECTION: Voltage + *	injection into the port + * + * option_vport_lim is an optional variable indicates if VPSE is out of the + * operating range during normal operating state. + */ +enum ethtool_c33_pse_ext_substate_option_vport_lim { +	ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_HIGH_VOLTAGE = 1, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_LOW_VOLTAGE, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_OPTION_VPORT_LIM_VOLTAGE_INJECTION, +}; + +/** + * enum ethtool_c33_pse_ext_substate_ovld_detected - ovld_detected states + *      functions. IEEE 802.3-2022 33.2.4.4 Variables + * + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_OVLD_DETECTED_OVERLOAD: Overload state + * + * ovld_detected is a variable indicating if the PSE output current has been + * in an overload condition (see 33.2.7.6) for at least TCUT of a one-second + * sliding time. + */ +enum ethtool_c33_pse_ext_substate_ovld_detected { +	ETHTOOL_C33_PSE_EXT_SUBSTATE_OVLD_DETECTED_OVERLOAD = 1, +}; + +/** + * enum ethtool_c33_pse_ext_substate_power_not_available - power_not_available + *	states functions. IEEE 802.3-2022 33.2.4.4 Variables + * + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_BUDGET_EXCEEDED: Power + *	budget exceeded for the controller + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_PORT_PW_LIMIT_EXCEEDS_CONTROLLER_BUDGET: + *	Configured port power limit exceeded controller power budget + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_PD_REQUEST_EXCEEDS_PORT_LIMIT: + *	Power request from PD exceeds port limit + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_HW_PW_LIMIT: Power + *	denied due to Hardware power limit + * + * power_not_available is a variable that is asserted in an + * implementation-dependent manner when the PSE is no longer capable of + * sourcing sufficient power to support the attached PD. Sufficient power + * is defined by classification; see 33.2.6. + */ +enum ethtool_c33_pse_ext_substate_power_not_available { +	ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_BUDGET_EXCEEDED =  1, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_PORT_PW_LIMIT_EXCEEDS_CONTROLLER_BUDGET, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_PD_REQUEST_EXCEEDS_PORT_LIMIT, +	ETHTOOL_C33_PSE_EXT_SUBSTATE_POWER_NOT_AVAILABLE_HW_PW_LIMIT, +}; + +/** + * enum ethtool_c33_pse_ext_substate_short_detected - short_detected states + *      functions. IEEE 802.3-2022 33.2.4.4 Variables + * + * @ETHTOOL_C33_PSE_EXT_SUBSTATE_SHORT_DETECTED_SHORT_CONDITION: Short + *	condition was detected + * + * short_detected is a variable indicating if the PSE output current has been + * in a short circuit condition for TLIM within a sliding window (see 33.2.7.7). + */ +enum ethtool_c33_pse_ext_substate_short_detected { +	ETHTOOL_C33_PSE_EXT_SUBSTATE_SHORT_DETECTED_SHORT_CONDITION = 1, +}; + +/** + * enum ethtool_pse_types - Types of PSE controller. + * @ETHTOOL_PSE_UNKNOWN: Type of PSE controller is unknown + * @ETHTOOL_PSE_PODL: PSE controller which support PoDL + * @ETHTOOL_PSE_C33: PSE controller which support Clause 33 (PoE) + */ +enum ethtool_pse_types { +	ETHTOOL_PSE_UNKNOWN =	1 << 0, +	ETHTOOL_PSE_PODL =	1 << 1, +	ETHTOOL_PSE_C33 =	1 << 2, +}; + +/** + * enum ethtool_c33_pse_admin_state - operational state of the PoDL PSE + *	functions. IEEE 802.3-2022 30.9.1.1.2 aPSEAdminState + * @ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN: state of PSE functions is unknown + * @ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED: PSE functions are disabled + * @ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED: PSE functions are enabled + */ +enum ethtool_c33_pse_admin_state { +	ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN = 1, +	ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED, +	ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED, +}; + +/** + * enum ethtool_c33_pse_pw_d_status - power detection status of the PSE. + *	IEEE 802.3-2022 30.9.1.1.3 aPoDLPSEPowerDetectionStatus: + * @ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN: PSE status is unknown + * @ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED: The enumeration "disabled" + *	indicates that the PSE State diagram is in the state DISABLED. + * @ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING: The enumeration "searching" + *	indicates the PSE State diagram is in a state other than those + *	listed. + * @ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING: The enumeration + *	"deliveringPower" indicates that the PSE State diagram is in the + *	state POWER_ON. + * @ETHTOOL_C33_PSE_PW_D_STATUS_TEST: The enumeration "test" indicates that + *	the PSE State diagram is in the state TEST_MODE. + * @ETHTOOL_C33_PSE_PW_D_STATUS_FAULT: The enumeration "fault" indicates that + *	the PSE State diagram is in the state TEST_ERROR. + * @ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT: The enumeration "otherFault" + *	indicates that the PSE State diagram is in the state IDLE due to + *	the variable error_condition = true. + */ +enum ethtool_c33_pse_pw_d_status { +	ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN = 1, +	ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED, +	ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING, +	ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING, +	ETHTOOL_C33_PSE_PW_D_STATUS_TEST, +	ETHTOOL_C33_PSE_PW_D_STATUS_FAULT, +	ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT, +}; + +/** + * enum ethtool_podl_pse_admin_state - operational state of the PoDL PSE + *	functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState + * @ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN: state of PoDL PSE functions are + * 	unknown + * @ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED: PoDL PSE functions are disabled + * @ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED: PoDL PSE functions are enabled + */ +enum ethtool_podl_pse_admin_state { +	ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN = 1, +	ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED, +	ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED, +}; + +/** + * enum ethtool_podl_pse_pw_d_status - power detection status of the PoDL PSE. + *	IEEE 802.3-2018 30.15.1.1.3 aPoDLPSEPowerDetectionStatus: + * @ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN: PoDL PSE + * @ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED: "The enumeration “disabled” is + *	asserted true when the PoDL PSE state diagram variable mr_pse_enable is + *	false" + * @ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING: "The enumeration “searching” is + *	asserted true when either of the PSE state diagram variables + *	pi_detecting or pi_classifying is true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING: "The enumeration “deliveringPower” + *	is asserted true when the PoDL PSE state diagram variable pi_powered is + *	true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP: "The enumeration “sleep” is asserted + *	true when the PoDL PSE state diagram variable pi_sleeping is true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE: "The enumeration “idle” is asserted true + *	when the logical combination of the PoDL PSE state diagram variables + *	pi_prebiased*!pi_sleeping is true." + * @ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR: "The enumeration “error” is asserted + *	true when the PoDL PSE state diagram variable overload_held is true." + */ +enum ethtool_podl_pse_pw_d_status { +	ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN = 1, +	ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED, +	ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING, +	ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING, +	ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP, +	ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE, +	ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR, +}; + +/** + * enum ethtool_mm_verify_status - status of MAC Merge Verify function + * @ETHTOOL_MM_VERIFY_STATUS_UNKNOWN: + *	verification status is unknown + * @ETHTOOL_MM_VERIFY_STATUS_INITIAL: + *	the 802.3 Verify State diagram is in the state INIT_VERIFICATION + * @ETHTOOL_MM_VERIFY_STATUS_VERIFYING: + *	the Verify State diagram is in the state VERIFICATION_IDLE, + *	SEND_VERIFY or WAIT_FOR_RESPONSE + * @ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED: + *	indicates that the Verify State diagram is in the state VERIFIED + * @ETHTOOL_MM_VERIFY_STATUS_FAILED: + *	the Verify State diagram is in the state VERIFY_FAIL + * @ETHTOOL_MM_VERIFY_STATUS_DISABLED: + *	verification of preemption operation is disabled + */ +enum ethtool_mm_verify_status { +	ETHTOOL_MM_VERIFY_STATUS_UNKNOWN, +	ETHTOOL_MM_VERIFY_STATUS_INITIAL, +	ETHTOOL_MM_VERIFY_STATUS_VERIFYING, +	ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED, +	ETHTOOL_MM_VERIFY_STATUS_FAILED, +	ETHTOOL_MM_VERIFY_STATUS_DISABLED, +}; + +/** + * enum ethtool_module_fw_flash_status - plug-in module firmware flashing status + * @ETHTOOL_MODULE_FW_FLASH_STATUS_STARTED: The firmware flashing process has + *	started. + * @ETHTOOL_MODULE_FW_FLASH_STATUS_IN_PROGRESS: The firmware flashing process + *	is in progress. + * @ETHTOOL_MODULE_FW_FLASH_STATUS_COMPLETED: The firmware flashing process was + *	completed successfully. + * @ETHTOOL_MODULE_FW_FLASH_STATUS_ERROR: The firmware flashing process was + *	stopped due to an error. + */ +enum ethtool_module_fw_flash_status { +	ETHTOOL_MODULE_FW_FLASH_STATUS_STARTED = 1, +	ETHTOOL_MODULE_FW_FLASH_STATUS_IN_PROGRESS, +	ETHTOOL_MODULE_FW_FLASH_STATUS_COMPLETED, +	ETHTOOL_MODULE_FW_FLASH_STATUS_ERROR, +}; + +/**   * struct ethtool_gstrings - string set for data tagging   * @cmd: Command number = %ETHTOOL_GSTRINGS   * @string_set: String set ID; one of &enum ethtool_stringset @@ -709,12 +1106,13 @@ struct ethtool_gstrings {  	__u32	cmd;  	__u32	string_set;  	__u32	len; -	__u8	data[0]; +	__u8	data[];  };  /**   * struct ethtool_sset_info - string set information   * @cmd: Command number = %ETHTOOL_GSSET_INFO + * @reserved: Reserved for future use; see the note on reserved space.   * @sset_mask: On entry, a bitmask of string sets to query, with bits   *	numbered according to &enum ethtool_stringset.  On return, a   *	bitmask of those string sets queried that are supported. @@ -733,7 +1131,7 @@ struct ethtool_sset_info {  	__u32	cmd;  	__u32	reserved;  	__u64	sset_mask; -	__u32	data[0]; +	__u32	data[];  };  /** @@ -759,6 +1157,7 @@ enum ethtool_test_flags {   * @flags: A bitmask of flags from &enum ethtool_test_flags.  Some   *	flags may be set by the user on entry; others may be set by   *	the driver on return. + * @reserved: Reserved for future use; see the note on reserved space.   * @len: On return, the number of test results   * @data: Array of test results   * @@ -772,7 +1171,7 @@ struct ethtool_test {  	__u32	flags;  	__u32	reserved;  	__u32	len; -	__u64	data[0]; +	__u64	data[];  };  /** @@ -789,7 +1188,7 @@ struct ethtool_test {  struct ethtool_stats {  	__u32	cmd;  	__u32	n_stats; -	__u64	data[0]; +	__u64	data[];  };  /** @@ -806,7 +1205,7 @@ struct ethtool_stats {  struct ethtool_perm_addr {  	__u32	cmd;  	__u32	size; -	__u8	data[0]; +	__u8	data[];  };  /* boolean flags controlling per-interface behavior characteristics. @@ -959,6 +1358,7 @@ union ethtool_flow_union {   * @vlan_etype: VLAN EtherType   * @vlan_tci: VLAN tag control information   * @data: user defined data + * @padding: Reserved for future use; see the note on reserved space.   *   * Note, @vlan_etype, @vlan_tci, and @data are only valid if %FLOW_EXT   * is set in &struct ethtool_rx_flow_spec @flow_type. @@ -1094,7 +1494,7 @@ struct ethtool_rxnfc {  		__u32			rule_cnt;  		__u32			rss_context;  	}; -	__u32				rule_locs[0]; +	__u32				rule_locs[];  }; @@ -1114,7 +1514,7 @@ struct ethtool_rxnfc {  struct ethtool_rxfh_indir {  	__u32	cmd;  	__u32	size; -	__u32	ring_index[0]; +	__u32	ring_index[];  };  /** @@ -1134,7 +1534,10 @@ struct ethtool_rxfh_indir {   *	hardware hash key.   * @hfunc: Defines the current RSS hash function used by HW (or to be set to).   *	Valid values are one of the %ETH_RSS_HASH_*. - * @rsvd:	Reserved for future extensions. + * @input_xfrm: Defines how the input data is transformed. Valid values are one + *	of %RXH_XFRM_*. + * @rsvd8: Reserved for future use; see the note on reserved space. + * @rsvd32: Reserved for future use; see the note on reserved space.   * @rss_config: RX ring/queue index for each hash value i.e., indirection table   *	of @indir_size __u32 elements, followed by hash key of @key_size   *	bytes. @@ -1152,9 +1555,10 @@ struct ethtool_rxfh {  	__u32   indir_size;  	__u32   key_size;  	__u8	hfunc; -	__u8	rsvd8[3]; +	__u8	input_xfrm; +	__u8	rsvd8[2];  	__u32	rsvd32; -	__u32   rss_config[0]; +	__u32   rss_config[];  };  #define ETH_RXFH_CONTEXT_ALLOC		0xffffffff  #define ETH_RXFH_INDIR_NO_CHANGE	0xffffffff @@ -1239,7 +1643,7 @@ struct ethtool_dump {  	__u32	version;  	__u32	flag;  	__u32	len; -	__u8	data[0]; +	__u8	data[];  };  #define ETH_FW_DUMP_DISABLE 0 @@ -1271,7 +1675,7 @@ struct ethtool_get_features_block {  struct ethtool_gfeatures {  	__u32	cmd;  	__u32	size; -	struct ethtool_get_features_block features[0]; +	struct ethtool_get_features_block features[];  };  /** @@ -1293,7 +1697,7 @@ struct ethtool_set_features_block {  struct ethtool_sfeatures {  	__u32	cmd;  	__u32	size; -	struct ethtool_set_features_block features[0]; +	struct ethtool_set_features_block features[];  };  /** @@ -1302,7 +1706,9 @@ struct ethtool_sfeatures {   * @so_timestamping: bit mask of the sum of the supported SO_TIMESTAMPING flags   * @phc_index: device index of the associated PHC, or -1 if there is none   * @tx_types: bit mask of the supported hwtstamp_tx_types enumeration values + * @tx_reserved: Reserved for future use; see the note on reserved space.   * @rx_filters: bit mask of the supported hwtstamp_rx_filters enumeration values + * @rx_reserved: Reserved for future use; see the note on reserved space.   *   * The bits in the 'tx_types' and 'rx_filters' fields correspond to   * the 'hwtstamp_tx_types' and 'hwtstamp_rx_filters' enumeration values, @@ -1376,15 +1782,33 @@ struct ethtool_per_queue_op {  };  /** - * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters + * struct ethtool_fecparam - Ethernet Forward Error Correction parameters   * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM - * @active_fec: FEC mode which is active on porte - * @fec: Bitmask of supported/configured FEC modes - * @rsvd: Reserved for future extensions. i.e FEC bypass feature. + * @active_fec: FEC mode which is active on the port, single bit set, GET only. + * @fec: Bitmask of configured FEC modes. + * @reserved: Reserved for future extensions, ignore on GET, write 0 for SET.   * - * Drivers should reject a non-zero setting of @autoneg when - * autoneogotiation is disabled (or not supported) for the link. + * Note that @reserved was never validated on input and ethtool user space + * left it uninitialized when calling SET. Hence going forward it can only be + * used to return a value to userspace with GET. + * + * FEC modes supported by the device can be read via %ETHTOOL_GLINKSETTINGS. + * FEC settings are configured by link autonegotiation whenever it's enabled. + * With autoneg on %ETHTOOL_GFECPARAM can be used to read the current mode. + * + * When autoneg is disabled %ETHTOOL_SFECPARAM controls the FEC settings. + * It is recommended that drivers only accept a single bit set in @fec. + * When multiple bits are set in @fec drivers may pick mode in an implementation + * dependent way. Drivers should reject mixing %ETHTOOL_FEC_AUTO_BIT with other + * FEC modes, because it's unclear whether in this case other modes constrain + * AUTO or are independent choices. + * Drivers must reject SET requests if they support none of the requested modes. + * + * If device does not support FEC drivers may use %ETHTOOL_FEC_NONE instead + * of returning %EOPNOTSUPP from %ETHTOOL_GFECPARAM.   * + * See enum ethtool_fec_config_bits for definition of valid bits for both + * @fec and @active_fec.   */  struct ethtool_fecparam {  	__u32   cmd; @@ -1396,11 +1820,16 @@ struct ethtool_fecparam {  /**   * enum ethtool_fec_config_bits - flags definition of ethtool_fec_configuration - * @ETHTOOL_FEC_NONE: FEC mode configuration is not supported - * @ETHTOOL_FEC_AUTO: Default/Best FEC mode provided by driver - * @ETHTOOL_FEC_OFF: No FEC Mode - * @ETHTOOL_FEC_RS: Reed-Solomon Forward Error Detection mode - * @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon Forward Error Detection mode + * @ETHTOOL_FEC_NONE_BIT: FEC mode configuration is not supported. Should not + *			be used together with other bits. GET only. + * @ETHTOOL_FEC_AUTO_BIT: Select default/best FEC mode automatically, usually + *			based link mode and SFP parameters read from module's + *			EEPROM. This bit does _not_ mean autonegotiation. + * @ETHTOOL_FEC_OFF_BIT: No FEC Mode + * @ETHTOOL_FEC_RS_BIT: Reed-Solomon FEC Mode + * @ETHTOOL_FEC_BASER_BIT: Base-R/Reed-Solomon FEC Mode + * @ETHTOOL_FEC_LLRS_BIT: Low Latency Reed Solomon FEC Mode (25G/50G Ethernet + *			Consortium)   */  enum ethtool_fec_config_bits {  	ETHTOOL_FEC_NONE_BIT, @@ -1617,6 +2046,38 @@ enum ethtool_link_mode_bit_indices {  	ETHTOOL_LINK_MODE_400000baseLR4_ER4_FR4_Full_BIT = 87,  	ETHTOOL_LINK_MODE_400000baseDR4_Full_BIT	 = 88,  	ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT	 = 89, +	ETHTOOL_LINK_MODE_100baseFX_Half_BIT		 = 90, +	ETHTOOL_LINK_MODE_100baseFX_Full_BIT		 = 91, +	ETHTOOL_LINK_MODE_10baseT1L_Full_BIT		 = 92, +	ETHTOOL_LINK_MODE_800000baseCR8_Full_BIT	 = 93, +	ETHTOOL_LINK_MODE_800000baseKR8_Full_BIT	 = 94, +	ETHTOOL_LINK_MODE_800000baseDR8_Full_BIT	 = 95, +	ETHTOOL_LINK_MODE_800000baseDR8_2_Full_BIT	 = 96, +	ETHTOOL_LINK_MODE_800000baseSR8_Full_BIT	 = 97, +	ETHTOOL_LINK_MODE_800000baseVR8_Full_BIT	 = 98, +	ETHTOOL_LINK_MODE_10baseT1S_Full_BIT		 = 99, +	ETHTOOL_LINK_MODE_10baseT1S_Half_BIT		 = 100, +	ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT	 = 101, +	ETHTOOL_LINK_MODE_10baseT1BRR_Full_BIT		 = 102, +	ETHTOOL_LINK_MODE_200000baseCR_Full_BIT		 = 103, +	ETHTOOL_LINK_MODE_200000baseKR_Full_BIT		 = 104, +	ETHTOOL_LINK_MODE_200000baseDR_Full_BIT		 = 105, +	ETHTOOL_LINK_MODE_200000baseDR_2_Full_BIT	 = 106, +	ETHTOOL_LINK_MODE_200000baseSR_Full_BIT		 = 107, +	ETHTOOL_LINK_MODE_200000baseVR_Full_BIT		 = 108, +	ETHTOOL_LINK_MODE_400000baseCR2_Full_BIT	 = 109, +	ETHTOOL_LINK_MODE_400000baseKR2_Full_BIT	 = 110, +	ETHTOOL_LINK_MODE_400000baseDR2_Full_BIT	 = 111, +	ETHTOOL_LINK_MODE_400000baseDR2_2_Full_BIT	 = 112, +	ETHTOOL_LINK_MODE_400000baseSR2_Full_BIT	 = 113, +	ETHTOOL_LINK_MODE_400000baseVR2_Full_BIT	 = 114, +	ETHTOOL_LINK_MODE_800000baseCR4_Full_BIT	 = 115, +	ETHTOOL_LINK_MODE_800000baseKR4_Full_BIT	 = 116, +	ETHTOOL_LINK_MODE_800000baseDR4_Full_BIT	 = 117, +	ETHTOOL_LINK_MODE_800000baseDR4_2_Full_BIT	 = 118, +	ETHTOOL_LINK_MODE_800000baseSR4_Full_BIT	 = 119, +	ETHTOOL_LINK_MODE_800000baseVR4_Full_BIT	 = 120, +  	/* must be last entry */  	__ETHTOOL_LINK_MODE_MASK_NBITS  }; @@ -1728,6 +2189,7 @@ enum ethtool_link_mode_bit_indices {  #define SPEED_100000		100000  #define SPEED_200000		200000  #define SPEED_400000		400000 +#define SPEED_800000		800000  #define SPEED_UNKNOWN		-1 @@ -1765,6 +2227,20 @@ static inline int ethtool_validate_duplex(__u8 duplex)  #define MASTER_SLAVE_STATE_SLAVE		3  #define MASTER_SLAVE_STATE_ERR			4 +/* These are used to throttle the rate of data on the phy interface when the + * native speed of the interface is higher than the link speed. These should + * not be used for phy interfaces which natively support multiple speeds (e.g. + * MII or SGMII). + */ +/* No rate matching performed. */ +#define RATE_MATCH_NONE		0 +/* The phy sends pause frames to throttle the MAC. */ +#define RATE_MATCH_PAUSE	1 +/* The phy asserts CRS to prevent the MAC from transmitting. */ +#define RATE_MATCH_CRS		2 +/* The MAC is programmed with a sufficiently-large IPG. */ +#define RATE_MATCH_OPEN_LOOP	3 +  /* Which connector port. */  #define PORT_TP			0x00  #define PORT_AUI		0x01 @@ -1806,32 +2282,96 @@ static inline int ethtool_validate_duplex(__u8 duplex)  #define WOL_MODE_COUNT		8 -/* L2-L4 network traffic flow types */ -#define	TCP_V4_FLOW	0x01	/* hash or spec (tcp_ip4_spec) */ -#define	UDP_V4_FLOW	0x02	/* hash or spec (udp_ip4_spec) */ -#define	SCTP_V4_FLOW	0x03	/* hash or spec (sctp_ip4_spec) */ -#define	AH_ESP_V4_FLOW	0x04	/* hash only */ -#define	TCP_V6_FLOW	0x05	/* hash or spec (tcp_ip6_spec; nfc only) */ -#define	UDP_V6_FLOW	0x06	/* hash or spec (udp_ip6_spec; nfc only) */ -#define	SCTP_V6_FLOW	0x07	/* hash or spec (sctp_ip6_spec; nfc only) */ -#define	AH_ESP_V6_FLOW	0x08	/* hash only */ -#define	AH_V4_FLOW	0x09	/* hash or spec (ah_ip4_spec) */ -#define	ESP_V4_FLOW	0x0a	/* hash or spec (esp_ip4_spec) */ -#define	AH_V6_FLOW	0x0b	/* hash or spec (ah_ip6_spec; nfc only) */ -#define	ESP_V6_FLOW	0x0c	/* hash or spec (esp_ip6_spec; nfc only) */ -#define	IPV4_USER_FLOW	0x0d	/* spec only (usr_ip4_spec) */ -#define	IP_USER_FLOW	IPV4_USER_FLOW -#define	IPV6_USER_FLOW	0x0e	/* spec only (usr_ip6_spec; nfc only) */ -#define	IPV4_FLOW	0x10	/* hash only */ -#define	IPV6_FLOW	0x11	/* hash only */ -#define	ETHER_FLOW	0x12	/* spec only (ether_spec) */ +/* RSS hash function data + * XOR the corresponding source and destination fields of each specified + * protocol. Both copies of the XOR'ed fields are fed into the RSS and RXHASH + * calculation. Note that this XORing reduces the input set entropy and could + * be exploited to reduce the RSS queue spread. + */ +#define	RXH_XFRM_SYM_XOR	(1 << 0) +/* Similar to SYM_XOR, except that one copy of the XOR'ed fields is replaced by + * an OR of the same fields + */ +#define	RXH_XFRM_SYM_OR_XOR	(1 << 1) +#define	RXH_XFRM_NO_CHANGE	0xff + +enum { +	/* L2-L4 network traffic flow types */ +	TCP_V4_FLOW	= 0x01,	/* hash or spec (tcp_ip4_spec) */ +	UDP_V4_FLOW	= 0x02,	/* hash or spec (udp_ip4_spec) */ +	SCTP_V4_FLOW	= 0x03,	/* hash or spec (sctp_ip4_spec) */ +	AH_ESP_V4_FLOW	= 0x04,	/* hash only */ +	TCP_V6_FLOW	= 0x05,	/* hash or spec (tcp_ip6_spec; nfc only) */ +	UDP_V6_FLOW	= 0x06,	/* hash or spec (udp_ip6_spec; nfc only) */ +	SCTP_V6_FLOW	= 0x07,	/* hash or spec (sctp_ip6_spec; nfc only) */ +	AH_ESP_V6_FLOW	= 0x08,	/* hash only */ +	AH_V4_FLOW	= 0x09,	/* hash or spec (ah_ip4_spec) */ +	ESP_V4_FLOW	= 0x0a,	/* hash or spec (esp_ip4_spec) */ +	AH_V6_FLOW	= 0x0b,	/* hash or spec (ah_ip6_spec; nfc only) */ +	ESP_V6_FLOW	= 0x0c,	/* hash or spec (esp_ip6_spec; nfc only) */ +	IPV4_USER_FLOW	= 0x0d,	/* spec only (usr_ip4_spec) */ +	IP_USER_FLOW	= IPV4_USER_FLOW, +	IPV6_USER_FLOW	= 0x0e, /* spec only (usr_ip6_spec; nfc only) */ +	IPV4_FLOW	= 0x10, /* hash only */ +	IPV6_FLOW	= 0x11, /* hash only */ +	ETHER_FLOW	= 0x12, /* hash or spec (ether_spec) */ + +	/* Used for GTP-U IPv4 and IPv6. +	 * The format of GTP packets only includes +	 * elements such as TEID and GTP version. +	 * It is primarily intended for data communication of the UE. +	 */ +	GTPU_V4_FLOW	= 0x13,	/* hash only */ +	GTPU_V6_FLOW	= 0x14,	/* hash only */ + +	/* Use for GTP-C IPv4 and v6. +	 * The format of these GTP packets does not include TEID. +	 * Primarily expected to be used for communication +	 * to create sessions for UE data communication, +	 * commonly referred to as CSR (Create Session Request). +	 */ +	GTPC_V4_FLOW	= 0x15,	/* hash only */ +	GTPC_V6_FLOW	= 0x16,	/* hash only */ + +	/* Use for GTP-C IPv4 and v6. +	 * Unlike GTPC_V4_FLOW, the format of these GTP packets includes TEID. +	 * After session creation, it becomes this packet. +	 * This is mainly used for requests to realize UE handover. +	 */ +	GTPC_TEID_V4_FLOW	= 0x17,	/* hash only */ +	GTPC_TEID_V6_FLOW	= 0x18,	/* hash only */ + +	/* Use for GTP-U and extended headers for the PSC (PDU Session Container). +	 * The format of these GTP packets includes TEID and QFI. +	 * In 5G communication using UPF (User Plane Function), +	 * data communication with this extended header is performed. +	 */ +	GTPU_EH_V4_FLOW	= 0x19,	/* hash only */ +	GTPU_EH_V6_FLOW	= 0x1a,	/* hash only */ + +	/* Use for GTP-U IPv4 and v6 PSC (PDU Session Container) extended headers. +	 * This differs from GTPU_EH_V(4|6)_FLOW in that it is distinguished by +	 * UL/DL included in the PSC. +	 * There are differences in the data included based on Downlink/Uplink, +	 * and can be used to distinguish packets. +	 * The functions described so far are useful when you want to +	 * handle communication from the mobile network in UPF, PGW, etc. +	 */ +	GTPU_UL_V4_FLOW	= 0x1b,	/* hash only */ +	GTPU_UL_V6_FLOW	= 0x1c,	/* hash only */ +	GTPU_DL_V4_FLOW	= 0x1d,	/* hash only */ +	GTPU_DL_V6_FLOW	= 0x1e,	/* hash only */ + +	__FLOW_TYPE_COUNT, +}; +  /* Flag to enable additional fields in struct ethtool_rx_flow_spec */  #define	FLOW_EXT	0x80000000  #define	FLOW_MAC_EXT	0x40000000  /* Flag to enable RSS spreading of traffic matching rule (nfc only) */  #define	FLOW_RSS	0x20000000 -/* L3-L4 network traffic flow hash options */ +/* L2-L4 network traffic flow hash options */  #define	RXH_L2DA	(1 << 1)  #define	RXH_VLAN	(1 << 2)  #define	RXH_L3_PROTO	(1 << 3) @@ -1839,6 +2379,7 @@ static inline int ethtool_validate_duplex(__u8 duplex)  #define	RXH_IP_DST	(1 << 5)  #define	RXH_L4_B_0_1	(1 << 6) /* src port in case of TCP/UDP/SCTP */  #define	RXH_L4_B_2_3	(1 << 7) /* dst port in case of TCP/UDP/SCTP */ +#define	RXH_GTP_TEID	(1 << 8) /* teid in case of GTP */  #define	RXH_DISCARD	(1 << 31)  #define	RX_CLS_FLOW_DISC	0xffffffffffffffffULL @@ -1942,20 +2483,13 @@ enum ethtool_reset_flags {   *	refused. For drivers: ignore this field (use kernel's   *	__ETHTOOL_LINK_MODE_MASK_NBITS instead), any change to it will   *	be overwritten by kernel. - * @supported: Bitmap with each bit meaning given by - *	%ethtool_link_mode_bit_indices for the link modes, physical - *	connectors and other link features for which the interface - *	supports autonegotiation or auto-detection.  Read-only. - * @advertising: Bitmap with each bit meaning given by - *	%ethtool_link_mode_bit_indices for the link modes, physical - *	connectors and other link features that are advertised through - *	autonegotiation or enabled for auto-detection. - * @lp_advertising: Bitmap with each bit meaning given by - *	%ethtool_link_mode_bit_indices for the link modes, and other - *	link features that the link partner advertised through - *	autonegotiation; 0 if unknown or not applicable.  Read-only.   * @transceiver: Used to distinguish different possible PHY types,   *	reported consistently by PHYLIB.  Read-only. + * @master_slave_cfg: Master/slave port mode. + * @master_slave_state: Master/slave port state. + * @rate_matching: Rate adaptation performed by the PHY + * @reserved: Reserved for future use; see the note on reserved space. + * @link_mode_masks: Variable length bitmaps.   *   * If autonegotiation is disabled, the speed and @duplex represent the   * fixed link mode and are writable if the driver supports multiple @@ -1990,6 +2524,21 @@ enum ethtool_reset_flags {   * %set_link_ksettings() should validate all fields other than @cmd   * and @link_mode_masks_nwords that are not described as read-only or   * deprecated, and must ignore all fields described as read-only. + * + * @link_mode_masks is divided into three bitfields, each of length + * @link_mode_masks_nwords: + * - supported: Bitmap with each bit meaning given by + *	%ethtool_link_mode_bit_indices for the link modes, physical + *	connectors and other link features for which the interface + *	supports autonegotiation or auto-detection.  Read-only. + * - advertising: Bitmap with each bit meaning given by + *	%ethtool_link_mode_bit_indices for the link modes, physical + *	connectors and other link features that are advertised through + *	autonegotiation or enabled for auto-detection. + * - lp_advertising: Bitmap with each bit meaning given by + *	%ethtool_link_mode_bit_indices for the link modes, and other + *	link features that the link partner advertised through + *	autonegotiation; 0 if unknown or not applicable.  Read-only.   */  struct ethtool_link_settings {  	__u32	cmd; @@ -2005,13 +2554,36 @@ struct ethtool_link_settings {  	__u8	transceiver;  	__u8	master_slave_cfg;  	__u8	master_slave_state; -	__u8	reserved1[1]; +	__u8	rate_matching;  	__u32	reserved[7]; -	__u32	link_mode_masks[0]; +#ifndef __KERNEL__ +	/* Linux builds with -Wflex-array-member-not-at-end but does +	 * not use the "link_mode_masks" member. Leave it defined for +	 * userspace for now, and when userspace wants to start using +	 * -Wfamnae, we'll need a new solution. +	 */ +	__u32	link_mode_masks[];  	/* layout of link_mode_masks fields:  	 * __u32 map_supported[link_mode_masks_nwords];  	 * __u32 map_advertising[link_mode_masks_nwords];  	 * __u32 map_lp_advertising[link_mode_masks_nwords];  	 */ +#endif  }; + +/** + * enum phy_upstream - Represents the upstream component a given PHY device + * is connected to, as in what is on the other end of the MII bus. Most PHYs + * will be attached to an Ethernet MAC controller, but in some cases, there's + * an intermediate PHY used as a media-converter, which will driver another + * MII interface as its output. + * @PHY_UPSTREAM_MAC: Upstream component is a MAC (a switch port, + *		      or ethernet controller) + * @PHY_UPSTREAM_PHY: Upstream component is a PHY (likely a media converter) + */ +enum phy_upstream { +	PHY_UPSTREAM_MAC, +	PHY_UPSTREAM_PHY, +}; +  #endif /* _UAPI_LINUX_ETHTOOL_H */ diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 5dcd24cb33ea..fa5d645140a4 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -10,420 +10,11 @@  #define _UAPI_LINUX_ETHTOOL_NETLINK_H_  #include <linux/ethtool.h> - -/* message types - userspace to kernel */ -enum { -	ETHTOOL_MSG_USER_NONE, -	ETHTOOL_MSG_STRSET_GET, -	ETHTOOL_MSG_LINKINFO_GET, -	ETHTOOL_MSG_LINKINFO_SET, -	ETHTOOL_MSG_LINKMODES_GET, -	ETHTOOL_MSG_LINKMODES_SET, -	ETHTOOL_MSG_LINKSTATE_GET, -	ETHTOOL_MSG_DEBUG_GET, -	ETHTOOL_MSG_DEBUG_SET, -	ETHTOOL_MSG_WOL_GET, -	ETHTOOL_MSG_WOL_SET, -	ETHTOOL_MSG_FEATURES_GET, -	ETHTOOL_MSG_FEATURES_SET, -	ETHTOOL_MSG_PRIVFLAGS_GET, -	ETHTOOL_MSG_PRIVFLAGS_SET, -	ETHTOOL_MSG_RINGS_GET, -	ETHTOOL_MSG_RINGS_SET, -	ETHTOOL_MSG_CHANNELS_GET, -	ETHTOOL_MSG_CHANNELS_SET, -	ETHTOOL_MSG_COALESCE_GET, -	ETHTOOL_MSG_COALESCE_SET, -	ETHTOOL_MSG_PAUSE_GET, -	ETHTOOL_MSG_PAUSE_SET, -	ETHTOOL_MSG_EEE_GET, -	ETHTOOL_MSG_EEE_SET, -	ETHTOOL_MSG_TSINFO_GET, -	ETHTOOL_MSG_CABLE_TEST_ACT, -	ETHTOOL_MSG_CABLE_TEST_TDR_ACT, -	ETHTOOL_MSG_TUNNEL_INFO_GET, - -	/* add new constants above here */ -	__ETHTOOL_MSG_USER_CNT, -	ETHTOOL_MSG_USER_MAX = __ETHTOOL_MSG_USER_CNT - 1 -}; - -/* message types - kernel to userspace */ -enum { -	ETHTOOL_MSG_KERNEL_NONE, -	ETHTOOL_MSG_STRSET_GET_REPLY, -	ETHTOOL_MSG_LINKINFO_GET_REPLY, -	ETHTOOL_MSG_LINKINFO_NTF, -	ETHTOOL_MSG_LINKMODES_GET_REPLY, -	ETHTOOL_MSG_LINKMODES_NTF, -	ETHTOOL_MSG_LINKSTATE_GET_REPLY, -	ETHTOOL_MSG_DEBUG_GET_REPLY, -	ETHTOOL_MSG_DEBUG_NTF, -	ETHTOOL_MSG_WOL_GET_REPLY, -	ETHTOOL_MSG_WOL_NTF, -	ETHTOOL_MSG_FEATURES_GET_REPLY, -	ETHTOOL_MSG_FEATURES_SET_REPLY, -	ETHTOOL_MSG_FEATURES_NTF, -	ETHTOOL_MSG_PRIVFLAGS_GET_REPLY, -	ETHTOOL_MSG_PRIVFLAGS_NTF, -	ETHTOOL_MSG_RINGS_GET_REPLY, -	ETHTOOL_MSG_RINGS_NTF, -	ETHTOOL_MSG_CHANNELS_GET_REPLY, -	ETHTOOL_MSG_CHANNELS_NTF, -	ETHTOOL_MSG_COALESCE_GET_REPLY, -	ETHTOOL_MSG_COALESCE_NTF, -	ETHTOOL_MSG_PAUSE_GET_REPLY, -	ETHTOOL_MSG_PAUSE_NTF, -	ETHTOOL_MSG_EEE_GET_REPLY, -	ETHTOOL_MSG_EEE_NTF, -	ETHTOOL_MSG_TSINFO_GET_REPLY, -	ETHTOOL_MSG_CABLE_TEST_NTF, -	ETHTOOL_MSG_CABLE_TEST_TDR_NTF, - -	/* add new constants above here */ -	__ETHTOOL_MSG_KERNEL_CNT, -	ETHTOOL_MSG_KERNEL_MAX = __ETHTOOL_MSG_KERNEL_CNT - 1 -}; - -/* request header */ - -/* use compact bitsets in reply */ -#define ETHTOOL_FLAG_COMPACT_BITSETS	(1 << 0) -/* provide optional reply for SET or ACT requests */ -#define ETHTOOL_FLAG_OMIT_REPLY	(1 << 1) +#include <linux/ethtool_netlink_generated.h>  #define ETHTOOL_FLAG_ALL (ETHTOOL_FLAG_COMPACT_BITSETS | \ -			  ETHTOOL_FLAG_OMIT_REPLY) - -enum { -	ETHTOOL_A_HEADER_UNSPEC, -	ETHTOOL_A_HEADER_DEV_INDEX,		/* u32 */ -	ETHTOOL_A_HEADER_DEV_NAME,		/* string */ -	ETHTOOL_A_HEADER_FLAGS,			/* u32 - ETHTOOL_FLAG_* */ - -	/* add new constants above here */ -	__ETHTOOL_A_HEADER_CNT, -	ETHTOOL_A_HEADER_MAX = __ETHTOOL_A_HEADER_CNT - 1 -}; - -/* bit sets */ - -enum { -	ETHTOOL_A_BITSET_BIT_UNSPEC, -	ETHTOOL_A_BITSET_BIT_INDEX,		/* u32 */ -	ETHTOOL_A_BITSET_BIT_NAME,		/* string */ -	ETHTOOL_A_BITSET_BIT_VALUE,		/* flag */ - -	/* add new constants above here */ -	__ETHTOOL_A_BITSET_BIT_CNT, -	ETHTOOL_A_BITSET_BIT_MAX = __ETHTOOL_A_BITSET_BIT_CNT - 1 -}; - -enum { -	ETHTOOL_A_BITSET_BITS_UNSPEC, -	ETHTOOL_A_BITSET_BITS_BIT,		/* nest - _A_BITSET_BIT_* */ - -	/* add new constants above here */ -	__ETHTOOL_A_BITSET_BITS_CNT, -	ETHTOOL_A_BITSET_BITS_MAX = __ETHTOOL_A_BITSET_BITS_CNT - 1 -}; - -enum { -	ETHTOOL_A_BITSET_UNSPEC, -	ETHTOOL_A_BITSET_NOMASK,		/* flag */ -	ETHTOOL_A_BITSET_SIZE,			/* u32 */ -	ETHTOOL_A_BITSET_BITS,			/* nest - _A_BITSET_BITS_* */ -	ETHTOOL_A_BITSET_VALUE,			/* binary */ -	ETHTOOL_A_BITSET_MASK,			/* binary */ - -	/* add new constants above here */ -	__ETHTOOL_A_BITSET_CNT, -	ETHTOOL_A_BITSET_MAX = __ETHTOOL_A_BITSET_CNT - 1 -}; - -/* string sets */ - -enum { -	ETHTOOL_A_STRING_UNSPEC, -	ETHTOOL_A_STRING_INDEX,			/* u32 */ -	ETHTOOL_A_STRING_VALUE,			/* string */ - -	/* add new constants above here */ -	__ETHTOOL_A_STRING_CNT, -	ETHTOOL_A_STRING_MAX = __ETHTOOL_A_STRING_CNT - 1 -}; - -enum { -	ETHTOOL_A_STRINGS_UNSPEC, -	ETHTOOL_A_STRINGS_STRING,		/* nest - _A_STRINGS_* */ - -	/* add new constants above here */ -	__ETHTOOL_A_STRINGS_CNT, -	ETHTOOL_A_STRINGS_MAX = __ETHTOOL_A_STRINGS_CNT - 1 -}; - -enum { -	ETHTOOL_A_STRINGSET_UNSPEC, -	ETHTOOL_A_STRINGSET_ID,			/* u32 */ -	ETHTOOL_A_STRINGSET_COUNT,		/* u32 */ -	ETHTOOL_A_STRINGSET_STRINGS,		/* nest - _A_STRINGS_* */ - -	/* add new constants above here */ -	__ETHTOOL_A_STRINGSET_CNT, -	ETHTOOL_A_STRINGSET_MAX = __ETHTOOL_A_STRINGSET_CNT - 1 -}; - -enum { -	ETHTOOL_A_STRINGSETS_UNSPEC, -	ETHTOOL_A_STRINGSETS_STRINGSET,		/* nest - _A_STRINGSET_* */ - -	/* add new constants above here */ -	__ETHTOOL_A_STRINGSETS_CNT, -	ETHTOOL_A_STRINGSETS_MAX = __ETHTOOL_A_STRINGSETS_CNT - 1 -}; - -/* STRSET */ - -enum { -	ETHTOOL_A_STRSET_UNSPEC, -	ETHTOOL_A_STRSET_HEADER,		/* nest - _A_HEADER_* */ -	ETHTOOL_A_STRSET_STRINGSETS,		/* nest - _A_STRINGSETS_* */ -	ETHTOOL_A_STRSET_COUNTS_ONLY,		/* flag */ - -	/* add new constants above here */ -	__ETHTOOL_A_STRSET_CNT, -	ETHTOOL_A_STRSET_MAX = __ETHTOOL_A_STRSET_CNT - 1 -}; - -/* LINKINFO */ - -enum { -	ETHTOOL_A_LINKINFO_UNSPEC, -	ETHTOOL_A_LINKINFO_HEADER,		/* nest - _A_HEADER_* */ -	ETHTOOL_A_LINKINFO_PORT,		/* u8 */ -	ETHTOOL_A_LINKINFO_PHYADDR,		/* u8 */ -	ETHTOOL_A_LINKINFO_TP_MDIX,		/* u8 */ -	ETHTOOL_A_LINKINFO_TP_MDIX_CTRL,	/* u8 */ -	ETHTOOL_A_LINKINFO_TRANSCEIVER,		/* u8 */ - -	/* add new constants above here */ -	__ETHTOOL_A_LINKINFO_CNT, -	ETHTOOL_A_LINKINFO_MAX = __ETHTOOL_A_LINKINFO_CNT - 1 -}; - -/* LINKMODES */ - -enum { -	ETHTOOL_A_LINKMODES_UNSPEC, -	ETHTOOL_A_LINKMODES_HEADER,		/* nest - _A_HEADER_* */ -	ETHTOOL_A_LINKMODES_AUTONEG,		/* u8 */ -	ETHTOOL_A_LINKMODES_OURS,		/* bitset */ -	ETHTOOL_A_LINKMODES_PEER,		/* bitset */ -	ETHTOOL_A_LINKMODES_SPEED,		/* u32 */ -	ETHTOOL_A_LINKMODES_DUPLEX,		/* u8 */ -	ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG,	/* u8 */ -	ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE,	/* u8 */ - -	/* add new constants above here */ -	__ETHTOOL_A_LINKMODES_CNT, -	ETHTOOL_A_LINKMODES_MAX = __ETHTOOL_A_LINKMODES_CNT - 1 -}; - -/* LINKSTATE */ - -enum { -	ETHTOOL_A_LINKSTATE_UNSPEC, -	ETHTOOL_A_LINKSTATE_HEADER,		/* nest - _A_HEADER_* */ -	ETHTOOL_A_LINKSTATE_LINK,		/* u8 */ -	ETHTOOL_A_LINKSTATE_SQI,		/* u32 */ -	ETHTOOL_A_LINKSTATE_SQI_MAX,		/* u32 */ -	ETHTOOL_A_LINKSTATE_EXT_STATE,		/* u8 */ -	ETHTOOL_A_LINKSTATE_EXT_SUBSTATE,	/* u8 */ - -	/* add new constants above here */ -	__ETHTOOL_A_LINKSTATE_CNT, -	ETHTOOL_A_LINKSTATE_MAX = __ETHTOOL_A_LINKSTATE_CNT - 1 -}; - -/* DEBUG */ - -enum { -	ETHTOOL_A_DEBUG_UNSPEC, -	ETHTOOL_A_DEBUG_HEADER,			/* nest - _A_HEADER_* */ -	ETHTOOL_A_DEBUG_MSGMASK,		/* bitset */ - -	/* add new constants above here */ -	__ETHTOOL_A_DEBUG_CNT, -	ETHTOOL_A_DEBUG_MAX = __ETHTOOL_A_DEBUG_CNT - 1 -}; - -/* WOL */ - -enum { -	ETHTOOL_A_WOL_UNSPEC, -	ETHTOOL_A_WOL_HEADER,			/* nest - _A_HEADER_* */ -	ETHTOOL_A_WOL_MODES,			/* bitset */ -	ETHTOOL_A_WOL_SOPASS,			/* binary */ - -	/* add new constants above here */ -	__ETHTOOL_A_WOL_CNT, -	ETHTOOL_A_WOL_MAX = __ETHTOOL_A_WOL_CNT - 1 -}; - -/* FEATURES */ - -enum { -	ETHTOOL_A_FEATURES_UNSPEC, -	ETHTOOL_A_FEATURES_HEADER,			/* nest - _A_HEADER_* */ -	ETHTOOL_A_FEATURES_HW,				/* bitset */ -	ETHTOOL_A_FEATURES_WANTED,			/* bitset */ -	ETHTOOL_A_FEATURES_ACTIVE,			/* bitset */ -	ETHTOOL_A_FEATURES_NOCHANGE,			/* bitset */ - -	/* add new constants above here */ -	__ETHTOOL_A_FEATURES_CNT, -	ETHTOOL_A_FEATURES_MAX = __ETHTOOL_A_FEATURES_CNT - 1 -}; - -/* PRIVFLAGS */ - -enum { -	ETHTOOL_A_PRIVFLAGS_UNSPEC, -	ETHTOOL_A_PRIVFLAGS_HEADER,			/* nest - _A_HEADER_* */ -	ETHTOOL_A_PRIVFLAGS_FLAGS,			/* bitset */ - -	/* add new constants above here */ -	__ETHTOOL_A_PRIVFLAGS_CNT, -	ETHTOOL_A_PRIVFLAGS_MAX = __ETHTOOL_A_PRIVFLAGS_CNT - 1 -}; - -/* RINGS */ - -enum { -	ETHTOOL_A_RINGS_UNSPEC, -	ETHTOOL_A_RINGS_HEADER,				/* nest - _A_HEADER_* */ -	ETHTOOL_A_RINGS_RX_MAX,				/* u32 */ -	ETHTOOL_A_RINGS_RX_MINI_MAX,			/* u32 */ -	ETHTOOL_A_RINGS_RX_JUMBO_MAX,			/* u32 */ -	ETHTOOL_A_RINGS_TX_MAX,				/* u32 */ -	ETHTOOL_A_RINGS_RX,				/* u32 */ -	ETHTOOL_A_RINGS_RX_MINI,			/* u32 */ -	ETHTOOL_A_RINGS_RX_JUMBO,			/* u32 */ -	ETHTOOL_A_RINGS_TX,				/* u32 */ - -	/* add new constants above here */ -	__ETHTOOL_A_RINGS_CNT, -	ETHTOOL_A_RINGS_MAX = (__ETHTOOL_A_RINGS_CNT - 1) -}; - -/* CHANNELS */ - -enum { -	ETHTOOL_A_CHANNELS_UNSPEC, -	ETHTOOL_A_CHANNELS_HEADER,			/* nest - _A_HEADER_* */ -	ETHTOOL_A_CHANNELS_RX_MAX,			/* u32 */ -	ETHTOOL_A_CHANNELS_TX_MAX,			/* u32 */ -	ETHTOOL_A_CHANNELS_OTHER_MAX,			/* u32 */ -	ETHTOOL_A_CHANNELS_COMBINED_MAX,		/* u32 */ -	ETHTOOL_A_CHANNELS_RX_COUNT,			/* u32 */ -	ETHTOOL_A_CHANNELS_TX_COUNT,			/* u32 */ -	ETHTOOL_A_CHANNELS_OTHER_COUNT,			/* u32 */ -	ETHTOOL_A_CHANNELS_COMBINED_COUNT,		/* u32 */ - -	/* add new constants above here */ -	__ETHTOOL_A_CHANNELS_CNT, -	ETHTOOL_A_CHANNELS_MAX = (__ETHTOOL_A_CHANNELS_CNT - 1) -}; - -/* COALESCE */ - -enum { -	ETHTOOL_A_COALESCE_UNSPEC, -	ETHTOOL_A_COALESCE_HEADER,			/* nest - _A_HEADER_* */ -	ETHTOOL_A_COALESCE_RX_USECS,			/* u32 */ -	ETHTOOL_A_COALESCE_RX_MAX_FRAMES,		/* u32 */ -	ETHTOOL_A_COALESCE_RX_USECS_IRQ,		/* u32 */ -	ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ,		/* u32 */ -	ETHTOOL_A_COALESCE_TX_USECS,			/* u32 */ -	ETHTOOL_A_COALESCE_TX_MAX_FRAMES,		/* u32 */ -	ETHTOOL_A_COALESCE_TX_USECS_IRQ,		/* u32 */ -	ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ,		/* u32 */ -	ETHTOOL_A_COALESCE_STATS_BLOCK_USECS,		/* u32 */ -	ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX,		/* u8 */ -	ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX,		/* u8 */ -	ETHTOOL_A_COALESCE_PKT_RATE_LOW,		/* u32 */ -	ETHTOOL_A_COALESCE_RX_USECS_LOW,		/* u32 */ -	ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW,		/* u32 */ -	ETHTOOL_A_COALESCE_TX_USECS_LOW,		/* u32 */ -	ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW,		/* u32 */ -	ETHTOOL_A_COALESCE_PKT_RATE_HIGH,		/* u32 */ -	ETHTOOL_A_COALESCE_RX_USECS_HIGH,		/* u32 */ -	ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH,		/* u32 */ -	ETHTOOL_A_COALESCE_TX_USECS_HIGH,		/* u32 */ -	ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH,		/* u32 */ -	ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL,	/* u32 */ - -	/* add new constants above here */ -	__ETHTOOL_A_COALESCE_CNT, -	ETHTOOL_A_COALESCE_MAX = (__ETHTOOL_A_COALESCE_CNT - 1) -}; - -/* PAUSE */ - -enum { -	ETHTOOL_A_PAUSE_UNSPEC, -	ETHTOOL_A_PAUSE_HEADER,				/* nest - _A_HEADER_* */ -	ETHTOOL_A_PAUSE_AUTONEG,			/* u8 */ -	ETHTOOL_A_PAUSE_RX,				/* u8 */ -	ETHTOOL_A_PAUSE_TX,				/* u8 */ - -	/* add new constants above here */ -	__ETHTOOL_A_PAUSE_CNT, -	ETHTOOL_A_PAUSE_MAX = (__ETHTOOL_A_PAUSE_CNT - 1) -}; - -/* EEE */ - -enum { -	ETHTOOL_A_EEE_UNSPEC, -	ETHTOOL_A_EEE_HEADER,				/* nest - _A_HEADER_* */ -	ETHTOOL_A_EEE_MODES_OURS,			/* bitset */ -	ETHTOOL_A_EEE_MODES_PEER,			/* bitset */ -	ETHTOOL_A_EEE_ACTIVE,				/* u8 */ -	ETHTOOL_A_EEE_ENABLED,				/* u8 */ -	ETHTOOL_A_EEE_TX_LPI_ENABLED,			/* u8 */ -	ETHTOOL_A_EEE_TX_LPI_TIMER,			/* u32 */ - -	/* add new constants above here */ -	__ETHTOOL_A_EEE_CNT, -	ETHTOOL_A_EEE_MAX = (__ETHTOOL_A_EEE_CNT - 1) -}; - -/* TSINFO */ - -enum { -	ETHTOOL_A_TSINFO_UNSPEC, -	ETHTOOL_A_TSINFO_HEADER,			/* nest - _A_HEADER_* */ -	ETHTOOL_A_TSINFO_TIMESTAMPING,			/* bitset */ -	ETHTOOL_A_TSINFO_TX_TYPES,			/* bitset */ -	ETHTOOL_A_TSINFO_RX_FILTERS,			/* bitset */ -	ETHTOOL_A_TSINFO_PHC_INDEX,			/* u32 */ - -	/* add new constants above here */ -	__ETHTOOL_A_TSINFO_CNT, -	ETHTOOL_A_TSINFO_MAX = (__ETHTOOL_A_TSINFO_CNT - 1) -}; - -/* CABLE TEST */ - -enum { -	ETHTOOL_A_CABLE_TEST_UNSPEC, -	ETHTOOL_A_CABLE_TEST_HEADER,		/* nest - _A_HEADER_* */ - -	/* add new constants above here */ -	__ETHTOOL_A_CABLE_TEST_CNT, -	ETHTOOL_A_CABLE_TEST_MAX = __ETHTOOL_A_CABLE_TEST_CNT - 1 -}; +			  ETHTOOL_FLAG_OMIT_REPLY | \ +			  ETHTOOL_FLAG_STATS)  /* CABLE TEST NOTIFY */  enum { @@ -432,6 +23,14 @@ enum {  	ETHTOOL_A_CABLE_RESULT_CODE_OPEN,  	ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT,  	ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT, +	/* detected reflection caused by the impedance discontinuity between +	 * a regular 100 Ohm cable and a part with the abnormal impedance value +	 */ +	ETHTOOL_A_CABLE_RESULT_CODE_IMPEDANCE_MISMATCH, +	/* TDR not possible due to high noise level */ +	ETHTOOL_A_CABLE_RESULT_CODE_NOISE, +	/* TDR resolution not possible / out of distance */ +	ETHTOOL_A_CABLE_RESULT_CODE_RESOLUTION_NOT_POSSIBLE,  };  enum { @@ -441,22 +40,13 @@ enum {  	ETHTOOL_A_CABLE_PAIR_D,  }; +/* Information source for specific results. */  enum { -	ETHTOOL_A_CABLE_RESULT_UNSPEC, -	ETHTOOL_A_CABLE_RESULT_PAIR,		/* u8 ETHTOOL_A_CABLE_PAIR_ */ -	ETHTOOL_A_CABLE_RESULT_CODE,		/* u8 ETHTOOL_A_CABLE_RESULT_CODE_ */ - -	__ETHTOOL_A_CABLE_RESULT_CNT, -	ETHTOOL_A_CABLE_RESULT_MAX = (__ETHTOOL_A_CABLE_RESULT_CNT - 1) -}; - -enum { -	ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC, -	ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR,	/* u8 ETHTOOL_A_CABLE_PAIR_ */ -	ETHTOOL_A_CABLE_FAULT_LENGTH_CM,	/* u32 */ - -	__ETHTOOL_A_CABLE_FAULT_LENGTH_CNT, -	ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = (__ETHTOOL_A_CABLE_FAULT_LENGTH_CNT - 1) +	ETHTOOL_A_CABLE_INF_SRC_UNSPEC, +	/* Results provided by the Time Domain Reflectometry (TDR) */ +	ETHTOOL_A_CABLE_INF_SRC_TDR, +	/* Results provided by the Active Link Cable Diagnostic (ALCD) */ +	ETHTOOL_A_CABLE_INF_SRC_ALCD,  };  enum { @@ -465,48 +55,6 @@ enum {  	ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED  }; -enum { -	ETHTOOL_A_CABLE_NEST_UNSPEC, -	ETHTOOL_A_CABLE_NEST_RESULT,		/* nest - ETHTOOL_A_CABLE_RESULT_ */ -	ETHTOOL_A_CABLE_NEST_FAULT_LENGTH,	/* nest - ETHTOOL_A_CABLE_FAULT_LENGTH_ */ -	__ETHTOOL_A_CABLE_NEST_CNT, -	ETHTOOL_A_CABLE_NEST_MAX = (__ETHTOOL_A_CABLE_NEST_CNT - 1) -}; - -enum { -	ETHTOOL_A_CABLE_TEST_NTF_UNSPEC, -	ETHTOOL_A_CABLE_TEST_NTF_HEADER,	/* nest - ETHTOOL_A_HEADER_* */ -	ETHTOOL_A_CABLE_TEST_NTF_STATUS,	/* u8 - _STARTED/_COMPLETE */ -	ETHTOOL_A_CABLE_TEST_NTF_NEST,		/* nest - of results: */ - -	__ETHTOOL_A_CABLE_TEST_NTF_CNT, -	ETHTOOL_A_CABLE_TEST_NTF_MAX = (__ETHTOOL_A_CABLE_TEST_NTF_CNT - 1) -}; - -/* CABLE TEST TDR */ - -enum { -	ETHTOOL_A_CABLE_TEST_TDR_CFG_UNSPEC, -	ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST,		/* u32 */ -	ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST,		/* u32 */ -	ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP,		/* u32 */ -	ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR,		/* u8 */ - -	/* add new constants above here */ -	__ETHTOOL_A_CABLE_TEST_TDR_CFG_CNT, -	ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX = __ETHTOOL_A_CABLE_TEST_TDR_CFG_CNT - 1 -}; - -enum { -	ETHTOOL_A_CABLE_TEST_TDR_UNSPEC, -	ETHTOOL_A_CABLE_TEST_TDR_HEADER,	/* nest - _A_HEADER_* */ -	ETHTOOL_A_CABLE_TEST_TDR_CFG,		/* nest - *_TDR_CFG_* */ - -	/* add new constants above here */ -	__ETHTOOL_A_CABLE_TEST_TDR_CNT, -	ETHTOOL_A_CABLE_TEST_TDR_MAX = __ETHTOOL_A_CABLE_TEST_TDR_CNT - 1 -}; -  /* CABLE TEST TDR NOTIFY */  enum { @@ -547,74 +95,117 @@ enum {  };  enum { -	ETHTOOL_A_CABLE_TEST_TDR_NTF_UNSPEC, -	ETHTOOL_A_CABLE_TEST_TDR_NTF_HEADER,	/* nest - ETHTOOL_A_HEADER_* */ -	ETHTOOL_A_CABLE_TEST_TDR_NTF_STATUS,	/* u8 - _STARTED/_COMPLETE */ -	ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST,	/* nest - of results: */ +	ETHTOOL_STATS_ETH_PHY, +	ETHTOOL_STATS_ETH_MAC, +	ETHTOOL_STATS_ETH_CTRL, +	ETHTOOL_STATS_RMON, +	ETHTOOL_STATS_PHY,  	/* add new constants above here */ -	__ETHTOOL_A_CABLE_TEST_TDR_NTF_CNT, -	ETHTOOL_A_CABLE_TEST_TDR_NTF_MAX = __ETHTOOL_A_CABLE_TEST_TDR_NTF_CNT - 1 +	__ETHTOOL_STATS_CNT  }; -/* TUNNEL INFO */ -  enum { -	ETHTOOL_UDP_TUNNEL_TYPE_VXLAN, -	ETHTOOL_UDP_TUNNEL_TYPE_GENEVE, -	ETHTOOL_UDP_TUNNEL_TYPE_VXLAN_GPE, +	/* 30.3.2.1.5 aSymbolErrorDuringCarrier */ +	ETHTOOL_A_STATS_ETH_PHY_5_SYM_ERR, -	__ETHTOOL_UDP_TUNNEL_TYPE_CNT +	/* add new constants above here */ +	__ETHTOOL_A_STATS_ETH_PHY_CNT, +	ETHTOOL_A_STATS_ETH_PHY_MAX = (__ETHTOOL_A_STATS_ETH_PHY_CNT - 1)  };  enum { -	ETHTOOL_A_TUNNEL_UDP_ENTRY_UNSPEC, +	/* 30.3.1.1.2 aFramesTransmittedOK */ +	ETHTOOL_A_STATS_ETH_MAC_2_TX_PKT, +	/* 30.3.1.1.3 aSingleCollisionFrames */ +	ETHTOOL_A_STATS_ETH_MAC_3_SINGLE_COL, +	/* 30.3.1.1.4 aMultipleCollisionFrames */ +	ETHTOOL_A_STATS_ETH_MAC_4_MULTI_COL, +	/* 30.3.1.1.5 aFramesReceivedOK */ +	ETHTOOL_A_STATS_ETH_MAC_5_RX_PKT, +	/* 30.3.1.1.6 aFrameCheckSequenceErrors */ +	ETHTOOL_A_STATS_ETH_MAC_6_FCS_ERR, +	/* 30.3.1.1.7 aAlignmentErrors */ +	ETHTOOL_A_STATS_ETH_MAC_7_ALIGN_ERR, +	/* 30.3.1.1.8 aOctetsTransmittedOK */ +	ETHTOOL_A_STATS_ETH_MAC_8_TX_BYTES, +	/* 30.3.1.1.9 aFramesWithDeferredXmissions */ +	ETHTOOL_A_STATS_ETH_MAC_9_TX_DEFER, +	/* 30.3.1.1.10 aLateCollisions */ +	ETHTOOL_A_STATS_ETH_MAC_10_LATE_COL, +	/* 30.3.1.1.11 aFramesAbortedDueToXSColls */ +	ETHTOOL_A_STATS_ETH_MAC_11_XS_COL, +	/* 30.3.1.1.12 aFramesLostDueToIntMACXmitError */ +	ETHTOOL_A_STATS_ETH_MAC_12_TX_INT_ERR, +	/* 30.3.1.1.13 aCarrierSenseErrors */ +	ETHTOOL_A_STATS_ETH_MAC_13_CS_ERR, +	/* 30.3.1.1.14 aOctetsReceivedOK */ +	ETHTOOL_A_STATS_ETH_MAC_14_RX_BYTES, +	/* 30.3.1.1.15 aFramesLostDueToIntMACRcvError */ +	ETHTOOL_A_STATS_ETH_MAC_15_RX_INT_ERR, -	ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,		/* be16 */ -	ETHTOOL_A_TUNNEL_UDP_ENTRY_TYPE,		/* u32 */ +	/* 30.3.1.1.18 aMulticastFramesXmittedOK */ +	ETHTOOL_A_STATS_ETH_MAC_18_TX_MCAST, +	/* 30.3.1.1.19 aBroadcastFramesXmittedOK */ +	ETHTOOL_A_STATS_ETH_MAC_19_TX_BCAST, +	/* 30.3.1.1.20 aFramesWithExcessiveDeferral */ +	ETHTOOL_A_STATS_ETH_MAC_20_XS_DEFER, +	/* 30.3.1.1.21 aMulticastFramesReceivedOK */ +	ETHTOOL_A_STATS_ETH_MAC_21_RX_MCAST, +	/* 30.3.1.1.22 aBroadcastFramesReceivedOK */ +	ETHTOOL_A_STATS_ETH_MAC_22_RX_BCAST, +	/* 30.3.1.1.23 aInRangeLengthErrors */ +	ETHTOOL_A_STATS_ETH_MAC_23_IR_LEN_ERR, +	/* 30.3.1.1.24 aOutOfRangeLengthField */ +	ETHTOOL_A_STATS_ETH_MAC_24_OOR_LEN, +	/* 30.3.1.1.25 aFrameTooLongErrors */ +	ETHTOOL_A_STATS_ETH_MAC_25_TOO_LONG_ERR,  	/* add new constants above here */ -	__ETHTOOL_A_TUNNEL_UDP_ENTRY_CNT, -	ETHTOOL_A_TUNNEL_UDP_ENTRY_MAX = (__ETHTOOL_A_TUNNEL_UDP_ENTRY_CNT - 1) +	__ETHTOOL_A_STATS_ETH_MAC_CNT, +	ETHTOOL_A_STATS_ETH_MAC_MAX = (__ETHTOOL_A_STATS_ETH_MAC_CNT - 1)  };  enum { -	ETHTOOL_A_TUNNEL_UDP_TABLE_UNSPEC, - -	ETHTOOL_A_TUNNEL_UDP_TABLE_SIZE,		/* u32 */ -	ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES,		/* bitset */ -	ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY,		/* nest - _UDP_ENTRY_* */ +	/* 30.3.3.3 aMACControlFramesTransmitted */ +	ETHTOOL_A_STATS_ETH_CTRL_3_TX, +	/* 30.3.3.4 aMACControlFramesReceived */ +	ETHTOOL_A_STATS_ETH_CTRL_4_RX, +	/* 30.3.3.5 aUnsupportedOpcodesReceived */ +	ETHTOOL_A_STATS_ETH_CTRL_5_RX_UNSUP,  	/* add new constants above here */ -	__ETHTOOL_A_TUNNEL_UDP_TABLE_CNT, -	ETHTOOL_A_TUNNEL_UDP_TABLE_MAX = (__ETHTOOL_A_TUNNEL_UDP_TABLE_CNT - 1) +	__ETHTOOL_A_STATS_ETH_CTRL_CNT, +	ETHTOOL_A_STATS_ETH_CTRL_MAX = (__ETHTOOL_A_STATS_ETH_CTRL_CNT - 1)  };  enum { -	ETHTOOL_A_TUNNEL_UDP_UNSPEC, - -	ETHTOOL_A_TUNNEL_UDP_TABLE,			/* nest - _UDP_TABLE_* */ +	/* etherStatsUndersizePkts */ +	ETHTOOL_A_STATS_RMON_UNDERSIZE, +	/* etherStatsOversizePkts */ +	ETHTOOL_A_STATS_RMON_OVERSIZE, +	/* etherStatsFragments */ +	ETHTOOL_A_STATS_RMON_FRAG, +	/* etherStatsJabbers */ +	ETHTOOL_A_STATS_RMON_JABBER,  	/* add new constants above here */ -	__ETHTOOL_A_TUNNEL_UDP_CNT, -	ETHTOOL_A_TUNNEL_UDP_MAX = (__ETHTOOL_A_TUNNEL_UDP_CNT - 1) +	__ETHTOOL_A_STATS_RMON_CNT, +	ETHTOOL_A_STATS_RMON_MAX = (__ETHTOOL_A_STATS_RMON_CNT - 1)  };  enum { -	ETHTOOL_A_TUNNEL_INFO_UNSPEC, -	ETHTOOL_A_TUNNEL_INFO_HEADER,			/* nest - _A_HEADER_* */ - -	ETHTOOL_A_TUNNEL_INFO_UDP_PORTS,		/* nest - _UDP_TABLE */ +	/* Basic packet counters if PHY has separate counters from the MAC */ +	ETHTOOL_A_STATS_PHY_RX_PKTS, +	ETHTOOL_A_STATS_PHY_RX_BYTES, +	ETHTOOL_A_STATS_PHY_RX_ERRORS, +	ETHTOOL_A_STATS_PHY_TX_PKTS, +	ETHTOOL_A_STATS_PHY_TX_BYTES, +	ETHTOOL_A_STATS_PHY_TX_ERRORS,  	/* add new constants above here */ -	__ETHTOOL_A_TUNNEL_INFO_CNT, -	ETHTOOL_A_TUNNEL_INFO_MAX = (__ETHTOOL_A_TUNNEL_INFO_CNT - 1) +	__ETHTOOL_A_STATS_PHY_CNT, +	ETHTOOL_A_STATS_PHY_MAX = (__ETHTOOL_A_STATS_PHY_CNT - 1)  }; -/* generic netlink info */ -#define ETHTOOL_GENL_NAME "ethtool" -#define ETHTOOL_GENL_VERSION 1 - -#define ETHTOOL_MCGRP_MONITOR_NAME "monitor" -  #endif /* _UAPI_LINUX_ETHTOOL_NETLINK_H_ */ diff --git a/include/uapi/linux/ethtool_netlink_generated.h b/include/uapi/linux/ethtool_netlink_generated.h new file mode 100644 index 000000000000..e3b8813465d7 --- /dev/null +++ b/include/uapi/linux/ethtool_netlink_generated.h @@ -0,0 +1,913 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/ethtool.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_ETHTOOL_NETLINK_GENERATED_H +#define _UAPI_LINUX_ETHTOOL_NETLINK_GENERATED_H + +#define ETHTOOL_GENL_NAME	"ethtool" +#define ETHTOOL_GENL_VERSION	1 + +enum { +	ETHTOOL_UDP_TUNNEL_TYPE_VXLAN, +	ETHTOOL_UDP_TUNNEL_TYPE_GENEVE, +	ETHTOOL_UDP_TUNNEL_TYPE_VXLAN_GPE, + +	/* private: */ +	__ETHTOOL_UDP_TUNNEL_TYPE_CNT, +	ETHTOOL_UDP_TUNNEL_TYPE_MAX = (__ETHTOOL_UDP_TUNNEL_TYPE_CNT - 1) +}; + +/** + * enum ethtool_header_flags - common ethtool header flags + * @ETHTOOL_FLAG_COMPACT_BITSETS: use compact bitsets in reply + * @ETHTOOL_FLAG_OMIT_REPLY: provide optional reply for SET or ACT requests + * @ETHTOOL_FLAG_STATS: request statistics, if supported by the driver + */ +enum ethtool_header_flags { +	ETHTOOL_FLAG_COMPACT_BITSETS = 1, +	ETHTOOL_FLAG_OMIT_REPLY = 2, +	ETHTOOL_FLAG_STATS = 4, +}; + +enum ethtool_tcp_data_split { +	ETHTOOL_TCP_DATA_SPLIT_UNKNOWN, +	ETHTOOL_TCP_DATA_SPLIT_DISABLED, +	ETHTOOL_TCP_DATA_SPLIT_ENABLED, +}; + +/** + * enum hwtstamp_source - Source of the hardware timestamp + * @HWTSTAMP_SOURCE_NETDEV: Hardware timestamp comes from a MAC or a device + *   which has MAC and PHY integrated + * @HWTSTAMP_SOURCE_PHYLIB: Hardware timestamp comes from one PHY device of the + *   network topology + */ +enum hwtstamp_source { +	HWTSTAMP_SOURCE_NETDEV = 1, +	HWTSTAMP_SOURCE_PHYLIB, +}; + +/** + * enum ethtool_pse_event - PSE event list for the PSE controller + * @ETHTOOL_PSE_EVENT_OVER_CURRENT: PSE output current is too high + * @ETHTOOL_PSE_EVENT_OVER_TEMP: PSE in over temperature state + * @ETHTOOL_C33_PSE_EVENT_DETECTION: detection process occur on the PSE. IEEE + *   802.3-2022 33.2.5 and 145.2.6 PSE detection of PDs. IEEE 802.3-202 + *   30.9.1.1.5 aPSEPowerDetectionStatus + * @ETHTOOL_C33_PSE_EVENT_CLASSIFICATION: classification process occur on the + *   PSE. IEEE 802.3-2022 33.2.6 and 145.2.8 classification of PDs mutual + *   identification. IEEE 802.3-2022 30.9.1.1.8 aPSEPowerClassification. + * @ETHTOOL_C33_PSE_EVENT_DISCONNECTION: PD has been disconnected on the PSE. + *   IEEE 802.3-2022 33.3.8 and 145.3.9 PD Maintain Power Signature. IEEE + *   802.3-2022 33.5.1.2.9 MPS Absent. IEEE 802.3-2022 30.9.1.1.20 + *   aPSEMPSAbsentCounter. + * @ETHTOOL_PSE_EVENT_OVER_BUDGET: PSE turned off due to over budget situation + * @ETHTOOL_PSE_EVENT_SW_PW_CONTROL_ERROR: PSE faced an error managing the + *   power control from software + */ +enum ethtool_pse_event { +	ETHTOOL_PSE_EVENT_OVER_CURRENT = 1, +	ETHTOOL_PSE_EVENT_OVER_TEMP = 2, +	ETHTOOL_C33_PSE_EVENT_DETECTION = 4, +	ETHTOOL_C33_PSE_EVENT_CLASSIFICATION = 8, +	ETHTOOL_C33_PSE_EVENT_DISCONNECTION = 16, +	ETHTOOL_PSE_EVENT_OVER_BUDGET = 32, +	ETHTOOL_PSE_EVENT_SW_PW_CONTROL_ERROR = 64, +}; + +enum { +	ETHTOOL_A_HEADER_UNSPEC, +	ETHTOOL_A_HEADER_DEV_INDEX, +	ETHTOOL_A_HEADER_DEV_NAME, +	ETHTOOL_A_HEADER_FLAGS, +	ETHTOOL_A_HEADER_PHY_INDEX, + +	__ETHTOOL_A_HEADER_CNT, +	ETHTOOL_A_HEADER_MAX = (__ETHTOOL_A_HEADER_CNT - 1) +}; + +enum { +	ETHTOOL_A_BITSET_BIT_UNSPEC, +	ETHTOOL_A_BITSET_BIT_INDEX, +	ETHTOOL_A_BITSET_BIT_NAME, +	ETHTOOL_A_BITSET_BIT_VALUE, + +	__ETHTOOL_A_BITSET_BIT_CNT, +	ETHTOOL_A_BITSET_BIT_MAX = (__ETHTOOL_A_BITSET_BIT_CNT - 1) +}; + +enum { +	ETHTOOL_A_BITSET_BITS_UNSPEC, +	ETHTOOL_A_BITSET_BITS_BIT, + +	__ETHTOOL_A_BITSET_BITS_CNT, +	ETHTOOL_A_BITSET_BITS_MAX = (__ETHTOOL_A_BITSET_BITS_CNT - 1) +}; + +enum { +	ETHTOOL_A_BITSET_UNSPEC, +	ETHTOOL_A_BITSET_NOMASK, +	ETHTOOL_A_BITSET_SIZE, +	ETHTOOL_A_BITSET_BITS, +	ETHTOOL_A_BITSET_VALUE, +	ETHTOOL_A_BITSET_MASK, + +	__ETHTOOL_A_BITSET_CNT, +	ETHTOOL_A_BITSET_MAX = (__ETHTOOL_A_BITSET_CNT - 1) +}; + +enum { +	ETHTOOL_A_STRING_UNSPEC, +	ETHTOOL_A_STRING_INDEX, +	ETHTOOL_A_STRING_VALUE, + +	__ETHTOOL_A_STRING_CNT, +	ETHTOOL_A_STRING_MAX = (__ETHTOOL_A_STRING_CNT - 1) +}; + +enum { +	ETHTOOL_A_STRINGS_UNSPEC, +	ETHTOOL_A_STRINGS_STRING, + +	__ETHTOOL_A_STRINGS_CNT, +	ETHTOOL_A_STRINGS_MAX = (__ETHTOOL_A_STRINGS_CNT - 1) +}; + +enum { +	ETHTOOL_A_STRINGSET_UNSPEC, +	ETHTOOL_A_STRINGSET_ID, +	ETHTOOL_A_STRINGSET_COUNT, +	ETHTOOL_A_STRINGSET_STRINGS, + +	__ETHTOOL_A_STRINGSET_CNT, +	ETHTOOL_A_STRINGSET_MAX = (__ETHTOOL_A_STRINGSET_CNT - 1) +}; + +enum { +	ETHTOOL_A_STRINGSETS_UNSPEC, +	ETHTOOL_A_STRINGSETS_STRINGSET, + +	__ETHTOOL_A_STRINGSETS_CNT, +	ETHTOOL_A_STRINGSETS_MAX = (__ETHTOOL_A_STRINGSETS_CNT - 1) +}; + +enum { +	ETHTOOL_A_STRSET_UNSPEC, +	ETHTOOL_A_STRSET_HEADER, +	ETHTOOL_A_STRSET_STRINGSETS, +	ETHTOOL_A_STRSET_COUNTS_ONLY, + +	__ETHTOOL_A_STRSET_CNT, +	ETHTOOL_A_STRSET_MAX = (__ETHTOOL_A_STRSET_CNT - 1) +}; + +enum { +	ETHTOOL_A_PRIVFLAGS_UNSPEC, +	ETHTOOL_A_PRIVFLAGS_HEADER, +	ETHTOOL_A_PRIVFLAGS_FLAGS, + +	__ETHTOOL_A_PRIVFLAGS_CNT, +	ETHTOOL_A_PRIVFLAGS_MAX = (__ETHTOOL_A_PRIVFLAGS_CNT - 1) +}; + +enum { +	ETHTOOL_A_RINGS_UNSPEC, +	ETHTOOL_A_RINGS_HEADER, +	ETHTOOL_A_RINGS_RX_MAX, +	ETHTOOL_A_RINGS_RX_MINI_MAX, +	ETHTOOL_A_RINGS_RX_JUMBO_MAX, +	ETHTOOL_A_RINGS_TX_MAX, +	ETHTOOL_A_RINGS_RX, +	ETHTOOL_A_RINGS_RX_MINI, +	ETHTOOL_A_RINGS_RX_JUMBO, +	ETHTOOL_A_RINGS_TX, +	ETHTOOL_A_RINGS_RX_BUF_LEN, +	ETHTOOL_A_RINGS_TCP_DATA_SPLIT, +	ETHTOOL_A_RINGS_CQE_SIZE, +	ETHTOOL_A_RINGS_TX_PUSH, +	ETHTOOL_A_RINGS_RX_PUSH, +	ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN, +	ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX, +	ETHTOOL_A_RINGS_HDS_THRESH, +	ETHTOOL_A_RINGS_HDS_THRESH_MAX, + +	__ETHTOOL_A_RINGS_CNT, +	ETHTOOL_A_RINGS_MAX = (__ETHTOOL_A_RINGS_CNT - 1) +}; + +enum { +	ETHTOOL_A_MM_STAT_UNSPEC, +	ETHTOOL_A_MM_STAT_PAD, +	ETHTOOL_A_MM_STAT_REASSEMBLY_ERRORS, +	ETHTOOL_A_MM_STAT_SMD_ERRORS, +	ETHTOOL_A_MM_STAT_REASSEMBLY_OK, +	ETHTOOL_A_MM_STAT_RX_FRAG_COUNT, +	ETHTOOL_A_MM_STAT_TX_FRAG_COUNT, +	ETHTOOL_A_MM_STAT_HOLD_COUNT, + +	__ETHTOOL_A_MM_STAT_CNT, +	ETHTOOL_A_MM_STAT_MAX = (__ETHTOOL_A_MM_STAT_CNT - 1) +}; + +enum { +	ETHTOOL_A_MM_UNSPEC, +	ETHTOOL_A_MM_HEADER, +	ETHTOOL_A_MM_PMAC_ENABLED, +	ETHTOOL_A_MM_TX_ENABLED, +	ETHTOOL_A_MM_TX_ACTIVE, +	ETHTOOL_A_MM_TX_MIN_FRAG_SIZE, +	ETHTOOL_A_MM_RX_MIN_FRAG_SIZE, +	ETHTOOL_A_MM_VERIFY_ENABLED, +	ETHTOOL_A_MM_VERIFY_STATUS, +	ETHTOOL_A_MM_VERIFY_TIME, +	ETHTOOL_A_MM_MAX_VERIFY_TIME, +	ETHTOOL_A_MM_STATS, + +	__ETHTOOL_A_MM_CNT, +	ETHTOOL_A_MM_MAX = (__ETHTOOL_A_MM_CNT - 1) +}; + +enum { +	ETHTOOL_A_LINKINFO_UNSPEC, +	ETHTOOL_A_LINKINFO_HEADER, +	ETHTOOL_A_LINKINFO_PORT, +	ETHTOOL_A_LINKINFO_PHYADDR, +	ETHTOOL_A_LINKINFO_TP_MDIX, +	ETHTOOL_A_LINKINFO_TP_MDIX_CTRL, +	ETHTOOL_A_LINKINFO_TRANSCEIVER, + +	__ETHTOOL_A_LINKINFO_CNT, +	ETHTOOL_A_LINKINFO_MAX = (__ETHTOOL_A_LINKINFO_CNT - 1) +}; + +enum { +	ETHTOOL_A_LINKMODES_UNSPEC, +	ETHTOOL_A_LINKMODES_HEADER, +	ETHTOOL_A_LINKMODES_AUTONEG, +	ETHTOOL_A_LINKMODES_OURS, +	ETHTOOL_A_LINKMODES_PEER, +	ETHTOOL_A_LINKMODES_SPEED, +	ETHTOOL_A_LINKMODES_DUPLEX, +	ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG, +	ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE, +	ETHTOOL_A_LINKMODES_LANES, +	ETHTOOL_A_LINKMODES_RATE_MATCHING, + +	__ETHTOOL_A_LINKMODES_CNT, +	ETHTOOL_A_LINKMODES_MAX = (__ETHTOOL_A_LINKMODES_CNT - 1) +}; + +enum { +	ETHTOOL_A_LINKSTATE_UNSPEC, +	ETHTOOL_A_LINKSTATE_HEADER, +	ETHTOOL_A_LINKSTATE_LINK, +	ETHTOOL_A_LINKSTATE_SQI, +	ETHTOOL_A_LINKSTATE_SQI_MAX, +	ETHTOOL_A_LINKSTATE_EXT_STATE, +	ETHTOOL_A_LINKSTATE_EXT_SUBSTATE, +	ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT, + +	__ETHTOOL_A_LINKSTATE_CNT, +	ETHTOOL_A_LINKSTATE_MAX = (__ETHTOOL_A_LINKSTATE_CNT - 1) +}; + +enum { +	ETHTOOL_A_DEBUG_UNSPEC, +	ETHTOOL_A_DEBUG_HEADER, +	ETHTOOL_A_DEBUG_MSGMASK, + +	__ETHTOOL_A_DEBUG_CNT, +	ETHTOOL_A_DEBUG_MAX = (__ETHTOOL_A_DEBUG_CNT - 1) +}; + +enum { +	ETHTOOL_A_WOL_UNSPEC, +	ETHTOOL_A_WOL_HEADER, +	ETHTOOL_A_WOL_MODES, +	ETHTOOL_A_WOL_SOPASS, + +	__ETHTOOL_A_WOL_CNT, +	ETHTOOL_A_WOL_MAX = (__ETHTOOL_A_WOL_CNT - 1) +}; + +enum { +	ETHTOOL_A_FEATURES_UNSPEC, +	ETHTOOL_A_FEATURES_HEADER, +	ETHTOOL_A_FEATURES_HW, +	ETHTOOL_A_FEATURES_WANTED, +	ETHTOOL_A_FEATURES_ACTIVE, +	ETHTOOL_A_FEATURES_NOCHANGE, + +	__ETHTOOL_A_FEATURES_CNT, +	ETHTOOL_A_FEATURES_MAX = (__ETHTOOL_A_FEATURES_CNT - 1) +}; + +enum { +	ETHTOOL_A_CHANNELS_UNSPEC, +	ETHTOOL_A_CHANNELS_HEADER, +	ETHTOOL_A_CHANNELS_RX_MAX, +	ETHTOOL_A_CHANNELS_TX_MAX, +	ETHTOOL_A_CHANNELS_OTHER_MAX, +	ETHTOOL_A_CHANNELS_COMBINED_MAX, +	ETHTOOL_A_CHANNELS_RX_COUNT, +	ETHTOOL_A_CHANNELS_TX_COUNT, +	ETHTOOL_A_CHANNELS_OTHER_COUNT, +	ETHTOOL_A_CHANNELS_COMBINED_COUNT, + +	__ETHTOOL_A_CHANNELS_CNT, +	ETHTOOL_A_CHANNELS_MAX = (__ETHTOOL_A_CHANNELS_CNT - 1) +}; + +enum { +	ETHTOOL_A_IRQ_MODERATION_UNSPEC, +	ETHTOOL_A_IRQ_MODERATION_USEC, +	ETHTOOL_A_IRQ_MODERATION_PKTS, +	ETHTOOL_A_IRQ_MODERATION_COMPS, + +	__ETHTOOL_A_IRQ_MODERATION_CNT, +	ETHTOOL_A_IRQ_MODERATION_MAX = (__ETHTOOL_A_IRQ_MODERATION_CNT - 1) +}; + +enum { +	ETHTOOL_A_PROFILE_UNSPEC, +	ETHTOOL_A_PROFILE_IRQ_MODERATION, + +	__ETHTOOL_A_PROFILE_CNT, +	ETHTOOL_A_PROFILE_MAX = (__ETHTOOL_A_PROFILE_CNT - 1) +}; + +enum { +	ETHTOOL_A_COALESCE_UNSPEC, +	ETHTOOL_A_COALESCE_HEADER, +	ETHTOOL_A_COALESCE_RX_USECS, +	ETHTOOL_A_COALESCE_RX_MAX_FRAMES, +	ETHTOOL_A_COALESCE_RX_USECS_IRQ, +	ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ, +	ETHTOOL_A_COALESCE_TX_USECS, +	ETHTOOL_A_COALESCE_TX_MAX_FRAMES, +	ETHTOOL_A_COALESCE_TX_USECS_IRQ, +	ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ, +	ETHTOOL_A_COALESCE_STATS_BLOCK_USECS, +	ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX, +	ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX, +	ETHTOOL_A_COALESCE_PKT_RATE_LOW, +	ETHTOOL_A_COALESCE_RX_USECS_LOW, +	ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW, +	ETHTOOL_A_COALESCE_TX_USECS_LOW, +	ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW, +	ETHTOOL_A_COALESCE_PKT_RATE_HIGH, +	ETHTOOL_A_COALESCE_RX_USECS_HIGH, +	ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH, +	ETHTOOL_A_COALESCE_TX_USECS_HIGH, +	ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH, +	ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL, +	ETHTOOL_A_COALESCE_USE_CQE_MODE_TX, +	ETHTOOL_A_COALESCE_USE_CQE_MODE_RX, +	ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES, +	ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES, +	ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS, +	ETHTOOL_A_COALESCE_RX_PROFILE, +	ETHTOOL_A_COALESCE_TX_PROFILE, + +	__ETHTOOL_A_COALESCE_CNT, +	ETHTOOL_A_COALESCE_MAX = (__ETHTOOL_A_COALESCE_CNT - 1) +}; + +enum { +	ETHTOOL_A_PAUSE_STAT_UNSPEC, +	ETHTOOL_A_PAUSE_STAT_PAD, +	ETHTOOL_A_PAUSE_STAT_TX_FRAMES, +	ETHTOOL_A_PAUSE_STAT_RX_FRAMES, + +	__ETHTOOL_A_PAUSE_STAT_CNT, +	ETHTOOL_A_PAUSE_STAT_MAX = (__ETHTOOL_A_PAUSE_STAT_CNT - 1) +}; + +enum { +	ETHTOOL_A_PAUSE_UNSPEC, +	ETHTOOL_A_PAUSE_HEADER, +	ETHTOOL_A_PAUSE_AUTONEG, +	ETHTOOL_A_PAUSE_RX, +	ETHTOOL_A_PAUSE_TX, +	ETHTOOL_A_PAUSE_STATS, +	ETHTOOL_A_PAUSE_STATS_SRC, + +	__ETHTOOL_A_PAUSE_CNT, +	ETHTOOL_A_PAUSE_MAX = (__ETHTOOL_A_PAUSE_CNT - 1) +}; + +enum { +	ETHTOOL_A_EEE_UNSPEC, +	ETHTOOL_A_EEE_HEADER, +	ETHTOOL_A_EEE_MODES_OURS, +	ETHTOOL_A_EEE_MODES_PEER, +	ETHTOOL_A_EEE_ACTIVE, +	ETHTOOL_A_EEE_ENABLED, +	ETHTOOL_A_EEE_TX_LPI_ENABLED, +	ETHTOOL_A_EEE_TX_LPI_TIMER, + +	__ETHTOOL_A_EEE_CNT, +	ETHTOOL_A_EEE_MAX = (__ETHTOOL_A_EEE_CNT - 1) +}; + +enum { +	ETHTOOL_A_TS_STAT_UNSPEC, +	ETHTOOL_A_TS_STAT_TX_PKTS, +	ETHTOOL_A_TS_STAT_TX_LOST, +	ETHTOOL_A_TS_STAT_TX_ERR, +	ETHTOOL_A_TS_STAT_TX_ONESTEP_PKTS_UNCONFIRMED, + +	__ETHTOOL_A_TS_STAT_CNT, +	ETHTOOL_A_TS_STAT_MAX = (__ETHTOOL_A_TS_STAT_CNT - 1) +}; + +enum { +	ETHTOOL_A_TS_HWTSTAMP_PROVIDER_UNSPEC, +	ETHTOOL_A_TS_HWTSTAMP_PROVIDER_INDEX, +	ETHTOOL_A_TS_HWTSTAMP_PROVIDER_QUALIFIER, + +	__ETHTOOL_A_TS_HWTSTAMP_PROVIDER_CNT, +	ETHTOOL_A_TS_HWTSTAMP_PROVIDER_MAX = (__ETHTOOL_A_TS_HWTSTAMP_PROVIDER_CNT - 1) +}; + +enum { +	ETHTOOL_A_TSINFO_UNSPEC, +	ETHTOOL_A_TSINFO_HEADER, +	ETHTOOL_A_TSINFO_TIMESTAMPING, +	ETHTOOL_A_TSINFO_TX_TYPES, +	ETHTOOL_A_TSINFO_RX_FILTERS, +	ETHTOOL_A_TSINFO_PHC_INDEX, +	ETHTOOL_A_TSINFO_STATS, +	ETHTOOL_A_TSINFO_HWTSTAMP_PROVIDER, +	ETHTOOL_A_TSINFO_HWTSTAMP_SOURCE, +	ETHTOOL_A_TSINFO_HWTSTAMP_PHYINDEX, + +	__ETHTOOL_A_TSINFO_CNT, +	ETHTOOL_A_TSINFO_MAX = (__ETHTOOL_A_TSINFO_CNT - 1) +}; + +enum { +	ETHTOOL_A_CABLE_RESULT_UNSPEC, +	ETHTOOL_A_CABLE_RESULT_PAIR, +	ETHTOOL_A_CABLE_RESULT_CODE, +	ETHTOOL_A_CABLE_RESULT_SRC, + +	__ETHTOOL_A_CABLE_RESULT_CNT, +	ETHTOOL_A_CABLE_RESULT_MAX = (__ETHTOOL_A_CABLE_RESULT_CNT - 1) +}; + +enum { +	ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC, +	ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR, +	ETHTOOL_A_CABLE_FAULT_LENGTH_CM, +	ETHTOOL_A_CABLE_FAULT_LENGTH_SRC, + +	__ETHTOOL_A_CABLE_FAULT_LENGTH_CNT, +	ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = (__ETHTOOL_A_CABLE_FAULT_LENGTH_CNT - 1) +}; + +enum { +	ETHTOOL_A_CABLE_NEST_UNSPEC, +	ETHTOOL_A_CABLE_NEST_RESULT, +	ETHTOOL_A_CABLE_NEST_FAULT_LENGTH, + +	__ETHTOOL_A_CABLE_NEST_CNT, +	ETHTOOL_A_CABLE_NEST_MAX = (__ETHTOOL_A_CABLE_NEST_CNT - 1) +}; + +enum { +	ETHTOOL_A_CABLE_TEST_UNSPEC, +	ETHTOOL_A_CABLE_TEST_HEADER, + +	__ETHTOOL_A_CABLE_TEST_CNT, +	ETHTOOL_A_CABLE_TEST_MAX = (__ETHTOOL_A_CABLE_TEST_CNT - 1) +}; + +enum { +	ETHTOOL_A_CABLE_TEST_NTF_UNSPEC, +	ETHTOOL_A_CABLE_TEST_NTF_HEADER, +	ETHTOOL_A_CABLE_TEST_NTF_STATUS, +	ETHTOOL_A_CABLE_TEST_NTF_NEST, + +	__ETHTOOL_A_CABLE_TEST_NTF_CNT, +	ETHTOOL_A_CABLE_TEST_NTF_MAX = (__ETHTOOL_A_CABLE_TEST_NTF_CNT - 1) +}; + +enum { +	ETHTOOL_A_CABLE_TEST_TDR_CFG_UNSPEC, +	ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST, +	ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST, +	ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP, +	ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR, + +	__ETHTOOL_A_CABLE_TEST_TDR_CFG_CNT, +	ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX = (__ETHTOOL_A_CABLE_TEST_TDR_CFG_CNT - 1) +}; + +enum { +	ETHTOOL_A_CABLE_TEST_TDR_NTF_UNSPEC, +	ETHTOOL_A_CABLE_TEST_TDR_NTF_HEADER, +	ETHTOOL_A_CABLE_TEST_TDR_NTF_STATUS, +	ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST, + +	__ETHTOOL_A_CABLE_TEST_TDR_NTF_CNT, +	ETHTOOL_A_CABLE_TEST_TDR_NTF_MAX = (__ETHTOOL_A_CABLE_TEST_TDR_NTF_CNT - 1) +}; + +enum { +	ETHTOOL_A_CABLE_TEST_TDR_UNSPEC, +	ETHTOOL_A_CABLE_TEST_TDR_HEADER, +	ETHTOOL_A_CABLE_TEST_TDR_CFG, + +	__ETHTOOL_A_CABLE_TEST_TDR_CNT, +	ETHTOOL_A_CABLE_TEST_TDR_MAX = (__ETHTOOL_A_CABLE_TEST_TDR_CNT - 1) +}; + +enum { +	ETHTOOL_A_TUNNEL_UDP_ENTRY_UNSPEC, +	ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT, +	ETHTOOL_A_TUNNEL_UDP_ENTRY_TYPE, + +	__ETHTOOL_A_TUNNEL_UDP_ENTRY_CNT, +	ETHTOOL_A_TUNNEL_UDP_ENTRY_MAX = (__ETHTOOL_A_TUNNEL_UDP_ENTRY_CNT - 1) +}; + +enum { +	ETHTOOL_A_TUNNEL_UDP_TABLE_UNSPEC, +	ETHTOOL_A_TUNNEL_UDP_TABLE_SIZE, +	ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES, +	ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY, + +	__ETHTOOL_A_TUNNEL_UDP_TABLE_CNT, +	ETHTOOL_A_TUNNEL_UDP_TABLE_MAX = (__ETHTOOL_A_TUNNEL_UDP_TABLE_CNT - 1) +}; + +enum { +	ETHTOOL_A_TUNNEL_UDP_UNSPEC, +	ETHTOOL_A_TUNNEL_UDP_TABLE, + +	__ETHTOOL_A_TUNNEL_UDP_CNT, +	ETHTOOL_A_TUNNEL_UDP_MAX = (__ETHTOOL_A_TUNNEL_UDP_CNT - 1) +}; + +enum { +	ETHTOOL_A_TUNNEL_INFO_UNSPEC, +	ETHTOOL_A_TUNNEL_INFO_HEADER, +	ETHTOOL_A_TUNNEL_INFO_UDP_PORTS, + +	__ETHTOOL_A_TUNNEL_INFO_CNT, +	ETHTOOL_A_TUNNEL_INFO_MAX = (__ETHTOOL_A_TUNNEL_INFO_CNT - 1) +}; + +enum { +	ETHTOOL_A_FEC_STAT_UNSPEC, +	ETHTOOL_A_FEC_STAT_PAD, +	ETHTOOL_A_FEC_STAT_CORRECTED, +	ETHTOOL_A_FEC_STAT_UNCORR, +	ETHTOOL_A_FEC_STAT_CORR_BITS, + +	__ETHTOOL_A_FEC_STAT_CNT, +	ETHTOOL_A_FEC_STAT_MAX = (__ETHTOOL_A_FEC_STAT_CNT - 1) +}; + +enum { +	ETHTOOL_A_FEC_UNSPEC, +	ETHTOOL_A_FEC_HEADER, +	ETHTOOL_A_FEC_MODES, +	ETHTOOL_A_FEC_AUTO, +	ETHTOOL_A_FEC_ACTIVE, +	ETHTOOL_A_FEC_STATS, + +	__ETHTOOL_A_FEC_CNT, +	ETHTOOL_A_FEC_MAX = (__ETHTOOL_A_FEC_CNT - 1) +}; + +enum { +	ETHTOOL_A_MODULE_EEPROM_UNSPEC, +	ETHTOOL_A_MODULE_EEPROM_HEADER, +	ETHTOOL_A_MODULE_EEPROM_OFFSET, +	ETHTOOL_A_MODULE_EEPROM_LENGTH, +	ETHTOOL_A_MODULE_EEPROM_PAGE, +	ETHTOOL_A_MODULE_EEPROM_BANK, +	ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS, +	ETHTOOL_A_MODULE_EEPROM_DATA, + +	__ETHTOOL_A_MODULE_EEPROM_CNT, +	ETHTOOL_A_MODULE_EEPROM_MAX = (__ETHTOOL_A_MODULE_EEPROM_CNT - 1) +}; + +enum { +	ETHTOOL_A_STATS_GRP_UNSPEC, +	ETHTOOL_A_STATS_GRP_PAD, +	ETHTOOL_A_STATS_GRP_ID, +	ETHTOOL_A_STATS_GRP_SS_ID, +	ETHTOOL_A_STATS_GRP_STAT, +	ETHTOOL_A_STATS_GRP_HIST_RX, +	ETHTOOL_A_STATS_GRP_HIST_TX, +	ETHTOOL_A_STATS_GRP_HIST_BKT_LOW, +	ETHTOOL_A_STATS_GRP_HIST_BKT_HI, +	ETHTOOL_A_STATS_GRP_HIST_VAL, + +	__ETHTOOL_A_STATS_GRP_CNT, +	ETHTOOL_A_STATS_GRP_MAX = (__ETHTOOL_A_STATS_GRP_CNT - 1) +}; + +enum { +	ETHTOOL_A_STATS_UNSPEC, +	ETHTOOL_A_STATS_PAD, +	ETHTOOL_A_STATS_HEADER, +	ETHTOOL_A_STATS_GROUPS, +	ETHTOOL_A_STATS_GRP, +	ETHTOOL_A_STATS_SRC, + +	__ETHTOOL_A_STATS_CNT, +	ETHTOOL_A_STATS_MAX = (__ETHTOOL_A_STATS_CNT - 1) +}; + +enum { +	ETHTOOL_A_PHC_VCLOCKS_UNSPEC, +	ETHTOOL_A_PHC_VCLOCKS_HEADER, +	ETHTOOL_A_PHC_VCLOCKS_NUM, +	ETHTOOL_A_PHC_VCLOCKS_INDEX, + +	__ETHTOOL_A_PHC_VCLOCKS_CNT, +	ETHTOOL_A_PHC_VCLOCKS_MAX = (__ETHTOOL_A_PHC_VCLOCKS_CNT - 1) +}; + +enum { +	ETHTOOL_A_MODULE_UNSPEC, +	ETHTOOL_A_MODULE_HEADER, +	ETHTOOL_A_MODULE_POWER_MODE_POLICY, +	ETHTOOL_A_MODULE_POWER_MODE, + +	__ETHTOOL_A_MODULE_CNT, +	ETHTOOL_A_MODULE_MAX = (__ETHTOOL_A_MODULE_CNT - 1) +}; + +enum { +	ETHTOOL_A_C33_PSE_PW_LIMIT_UNSPEC, +	ETHTOOL_A_C33_PSE_PW_LIMIT_MIN, +	ETHTOOL_A_C33_PSE_PW_LIMIT_MAX, + +	__ETHTOOL_A_C33_PSE_PW_LIMIT_CNT, +	__ETHTOOL_A_C33_PSE_PW_LIMIT_MAX = (__ETHTOOL_A_C33_PSE_PW_LIMIT_CNT - 1) +}; + +enum { +	ETHTOOL_A_PSE_UNSPEC, +	ETHTOOL_A_PSE_HEADER, +	ETHTOOL_A_PODL_PSE_ADMIN_STATE, +	ETHTOOL_A_PODL_PSE_ADMIN_CONTROL, +	ETHTOOL_A_PODL_PSE_PW_D_STATUS, +	ETHTOOL_A_C33_PSE_ADMIN_STATE, +	ETHTOOL_A_C33_PSE_ADMIN_CONTROL, +	ETHTOOL_A_C33_PSE_PW_D_STATUS, +	ETHTOOL_A_C33_PSE_PW_CLASS, +	ETHTOOL_A_C33_PSE_ACTUAL_PW, +	ETHTOOL_A_C33_PSE_EXT_STATE, +	ETHTOOL_A_C33_PSE_EXT_SUBSTATE, +	ETHTOOL_A_C33_PSE_AVAIL_PW_LIMIT, +	ETHTOOL_A_C33_PSE_PW_LIMIT_RANGES, +	ETHTOOL_A_PSE_PW_D_ID, +	ETHTOOL_A_PSE_PRIO_MAX, +	ETHTOOL_A_PSE_PRIO, + +	__ETHTOOL_A_PSE_CNT, +	ETHTOOL_A_PSE_MAX = (__ETHTOOL_A_PSE_CNT - 1) +}; + +enum { +	ETHTOOL_A_FLOW_ETHER = 1, +	ETHTOOL_A_FLOW_IP4, +	ETHTOOL_A_FLOW_IP6, +	ETHTOOL_A_FLOW_TCP4, +	ETHTOOL_A_FLOW_TCP6, +	ETHTOOL_A_FLOW_UDP4, +	ETHTOOL_A_FLOW_UDP6, +	ETHTOOL_A_FLOW_SCTP4, +	ETHTOOL_A_FLOW_SCTP6, +	ETHTOOL_A_FLOW_AH4, +	ETHTOOL_A_FLOW_AH6, +	ETHTOOL_A_FLOW_ESP4, +	ETHTOOL_A_FLOW_ESP6, +	ETHTOOL_A_FLOW_AH_ESP4, +	ETHTOOL_A_FLOW_AH_ESP6, +	ETHTOOL_A_FLOW_GTPU4, +	ETHTOOL_A_FLOW_GTPU6, +	ETHTOOL_A_FLOW_GTPC4, +	ETHTOOL_A_FLOW_GTPC6, +	ETHTOOL_A_FLOW_GTPC_TEID4, +	ETHTOOL_A_FLOW_GTPC_TEID6, +	ETHTOOL_A_FLOW_GTPU_EH4, +	ETHTOOL_A_FLOW_GTPU_EH6, +	ETHTOOL_A_FLOW_GTPU_UL4, +	ETHTOOL_A_FLOW_GTPU_UL6, +	ETHTOOL_A_FLOW_GTPU_DL4, +	ETHTOOL_A_FLOW_GTPU_DL6, + +	__ETHTOOL_A_FLOW_CNT, +	ETHTOOL_A_FLOW_MAX = (__ETHTOOL_A_FLOW_CNT - 1) +}; + +enum { +	ETHTOOL_A_RSS_UNSPEC, +	ETHTOOL_A_RSS_HEADER, +	ETHTOOL_A_RSS_CONTEXT, +	ETHTOOL_A_RSS_HFUNC, +	ETHTOOL_A_RSS_INDIR, +	ETHTOOL_A_RSS_HKEY, +	ETHTOOL_A_RSS_INPUT_XFRM, +	ETHTOOL_A_RSS_START_CONTEXT, +	ETHTOOL_A_RSS_FLOW_HASH, + +	__ETHTOOL_A_RSS_CNT, +	ETHTOOL_A_RSS_MAX = (__ETHTOOL_A_RSS_CNT - 1) +}; + +enum { +	ETHTOOL_A_PLCA_UNSPEC, +	ETHTOOL_A_PLCA_HEADER, +	ETHTOOL_A_PLCA_VERSION, +	ETHTOOL_A_PLCA_ENABLED, +	ETHTOOL_A_PLCA_STATUS, +	ETHTOOL_A_PLCA_NODE_CNT, +	ETHTOOL_A_PLCA_NODE_ID, +	ETHTOOL_A_PLCA_TO_TMR, +	ETHTOOL_A_PLCA_BURST_CNT, +	ETHTOOL_A_PLCA_BURST_TMR, + +	__ETHTOOL_A_PLCA_CNT, +	ETHTOOL_A_PLCA_MAX = (__ETHTOOL_A_PLCA_CNT - 1) +}; + +enum { +	ETHTOOL_A_MODULE_FW_FLASH_UNSPEC, +	ETHTOOL_A_MODULE_FW_FLASH_HEADER, +	ETHTOOL_A_MODULE_FW_FLASH_FILE_NAME, +	ETHTOOL_A_MODULE_FW_FLASH_PASSWORD, +	ETHTOOL_A_MODULE_FW_FLASH_STATUS, +	ETHTOOL_A_MODULE_FW_FLASH_STATUS_MSG, +	ETHTOOL_A_MODULE_FW_FLASH_DONE, +	ETHTOOL_A_MODULE_FW_FLASH_TOTAL, + +	__ETHTOOL_A_MODULE_FW_FLASH_CNT, +	ETHTOOL_A_MODULE_FW_FLASH_MAX = (__ETHTOOL_A_MODULE_FW_FLASH_CNT - 1) +}; + +enum { +	ETHTOOL_A_PHY_UNSPEC, +	ETHTOOL_A_PHY_HEADER, +	ETHTOOL_A_PHY_INDEX, +	ETHTOOL_A_PHY_DRVNAME, +	ETHTOOL_A_PHY_NAME, +	ETHTOOL_A_PHY_UPSTREAM_TYPE, +	ETHTOOL_A_PHY_UPSTREAM_INDEX, +	ETHTOOL_A_PHY_UPSTREAM_SFP_NAME, +	ETHTOOL_A_PHY_DOWNSTREAM_SFP_NAME, + +	__ETHTOOL_A_PHY_CNT, +	ETHTOOL_A_PHY_MAX = (__ETHTOOL_A_PHY_CNT - 1) +}; + +enum { +	ETHTOOL_A_TSCONFIG_UNSPEC, +	ETHTOOL_A_TSCONFIG_HEADER, +	ETHTOOL_A_TSCONFIG_HWTSTAMP_PROVIDER, +	ETHTOOL_A_TSCONFIG_TX_TYPES, +	ETHTOOL_A_TSCONFIG_RX_FILTERS, +	ETHTOOL_A_TSCONFIG_HWTSTAMP_FLAGS, + +	__ETHTOOL_A_TSCONFIG_CNT, +	ETHTOOL_A_TSCONFIG_MAX = (__ETHTOOL_A_TSCONFIG_CNT - 1) +}; + +enum { +	ETHTOOL_A_PSE_NTF_HEADER = 1, +	ETHTOOL_A_PSE_NTF_EVENTS, + +	__ETHTOOL_A_PSE_NTF_CNT, +	ETHTOOL_A_PSE_NTF_MAX = (__ETHTOOL_A_PSE_NTF_CNT - 1) +}; + +enum { +	ETHTOOL_MSG_USER_NONE = 0, +	ETHTOOL_MSG_STRSET_GET = 1, +	ETHTOOL_MSG_LINKINFO_GET, +	ETHTOOL_MSG_LINKINFO_SET, +	ETHTOOL_MSG_LINKMODES_GET, +	ETHTOOL_MSG_LINKMODES_SET, +	ETHTOOL_MSG_LINKSTATE_GET, +	ETHTOOL_MSG_DEBUG_GET, +	ETHTOOL_MSG_DEBUG_SET, +	ETHTOOL_MSG_WOL_GET, +	ETHTOOL_MSG_WOL_SET, +	ETHTOOL_MSG_FEATURES_GET, +	ETHTOOL_MSG_FEATURES_SET, +	ETHTOOL_MSG_PRIVFLAGS_GET, +	ETHTOOL_MSG_PRIVFLAGS_SET, +	ETHTOOL_MSG_RINGS_GET, +	ETHTOOL_MSG_RINGS_SET, +	ETHTOOL_MSG_CHANNELS_GET, +	ETHTOOL_MSG_CHANNELS_SET, +	ETHTOOL_MSG_COALESCE_GET, +	ETHTOOL_MSG_COALESCE_SET, +	ETHTOOL_MSG_PAUSE_GET, +	ETHTOOL_MSG_PAUSE_SET, +	ETHTOOL_MSG_EEE_GET, +	ETHTOOL_MSG_EEE_SET, +	ETHTOOL_MSG_TSINFO_GET, +	ETHTOOL_MSG_CABLE_TEST_ACT, +	ETHTOOL_MSG_CABLE_TEST_TDR_ACT, +	ETHTOOL_MSG_TUNNEL_INFO_GET, +	ETHTOOL_MSG_FEC_GET, +	ETHTOOL_MSG_FEC_SET, +	ETHTOOL_MSG_MODULE_EEPROM_GET, +	ETHTOOL_MSG_STATS_GET, +	ETHTOOL_MSG_PHC_VCLOCKS_GET, +	ETHTOOL_MSG_MODULE_GET, +	ETHTOOL_MSG_MODULE_SET, +	ETHTOOL_MSG_PSE_GET, +	ETHTOOL_MSG_PSE_SET, +	ETHTOOL_MSG_RSS_GET, +	ETHTOOL_MSG_PLCA_GET_CFG, +	ETHTOOL_MSG_PLCA_SET_CFG, +	ETHTOOL_MSG_PLCA_GET_STATUS, +	ETHTOOL_MSG_MM_GET, +	ETHTOOL_MSG_MM_SET, +	ETHTOOL_MSG_MODULE_FW_FLASH_ACT, +	ETHTOOL_MSG_PHY_GET, +	ETHTOOL_MSG_TSCONFIG_GET, +	ETHTOOL_MSG_TSCONFIG_SET, +	ETHTOOL_MSG_RSS_SET, +	ETHTOOL_MSG_RSS_CREATE_ACT, +	ETHTOOL_MSG_RSS_DELETE_ACT, + +	__ETHTOOL_MSG_USER_CNT, +	ETHTOOL_MSG_USER_MAX = (__ETHTOOL_MSG_USER_CNT - 1) +}; + +enum { +	ETHTOOL_MSG_KERNEL_NONE = 0, +	ETHTOOL_MSG_STRSET_GET_REPLY = 1, +	ETHTOOL_MSG_LINKINFO_GET_REPLY, +	ETHTOOL_MSG_LINKINFO_NTF, +	ETHTOOL_MSG_LINKMODES_GET_REPLY, +	ETHTOOL_MSG_LINKMODES_NTF, +	ETHTOOL_MSG_LINKSTATE_GET_REPLY, +	ETHTOOL_MSG_DEBUG_GET_REPLY, +	ETHTOOL_MSG_DEBUG_NTF, +	ETHTOOL_MSG_WOL_GET_REPLY, +	ETHTOOL_MSG_WOL_NTF, +	ETHTOOL_MSG_FEATURES_GET_REPLY, +	ETHTOOL_MSG_FEATURES_SET_REPLY, +	ETHTOOL_MSG_FEATURES_NTF, +	ETHTOOL_MSG_PRIVFLAGS_GET_REPLY, +	ETHTOOL_MSG_PRIVFLAGS_NTF, +	ETHTOOL_MSG_RINGS_GET_REPLY, +	ETHTOOL_MSG_RINGS_NTF, +	ETHTOOL_MSG_CHANNELS_GET_REPLY, +	ETHTOOL_MSG_CHANNELS_NTF, +	ETHTOOL_MSG_COALESCE_GET_REPLY, +	ETHTOOL_MSG_COALESCE_NTF, +	ETHTOOL_MSG_PAUSE_GET_REPLY, +	ETHTOOL_MSG_PAUSE_NTF, +	ETHTOOL_MSG_EEE_GET_REPLY, +	ETHTOOL_MSG_EEE_NTF, +	ETHTOOL_MSG_TSINFO_GET_REPLY, +	ETHTOOL_MSG_CABLE_TEST_NTF, +	ETHTOOL_MSG_CABLE_TEST_TDR_NTF, +	ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY, +	ETHTOOL_MSG_FEC_GET_REPLY, +	ETHTOOL_MSG_FEC_NTF, +	ETHTOOL_MSG_MODULE_EEPROM_GET_REPLY, +	ETHTOOL_MSG_STATS_GET_REPLY, +	ETHTOOL_MSG_PHC_VCLOCKS_GET_REPLY, +	ETHTOOL_MSG_MODULE_GET_REPLY, +	ETHTOOL_MSG_MODULE_NTF, +	ETHTOOL_MSG_PSE_GET_REPLY, +	ETHTOOL_MSG_RSS_GET_REPLY, +	ETHTOOL_MSG_PLCA_GET_CFG_REPLY, +	ETHTOOL_MSG_PLCA_GET_STATUS_REPLY, +	ETHTOOL_MSG_PLCA_NTF, +	ETHTOOL_MSG_MM_GET_REPLY, +	ETHTOOL_MSG_MM_NTF, +	ETHTOOL_MSG_MODULE_FW_FLASH_NTF, +	ETHTOOL_MSG_PHY_GET_REPLY, +	ETHTOOL_MSG_PHY_NTF, +	ETHTOOL_MSG_TSCONFIG_GET_REPLY, +	ETHTOOL_MSG_TSCONFIG_SET_REPLY, +	ETHTOOL_MSG_PSE_NTF, +	ETHTOOL_MSG_RSS_NTF, +	ETHTOOL_MSG_RSS_CREATE_ACT_REPLY, +	ETHTOOL_MSG_RSS_CREATE_NTF, +	ETHTOOL_MSG_RSS_DELETE_NTF, + +	__ETHTOOL_MSG_KERNEL_CNT, +	ETHTOOL_MSG_KERNEL_MAX = (__ETHTOOL_MSG_KERNEL_CNT - 1) +}; + +#define ETHTOOL_MCGRP_MONITOR_NAME	"monitor" + +#endif /* _UAPI_LINUX_ETHTOOL_NETLINK_GENERATED_H */ diff --git a/include/uapi/linux/eventfd.h b/include/uapi/linux/eventfd.h new file mode 100644 index 000000000000..2eb9ab6c32f3 --- /dev/null +++ b/include/uapi/linux/eventfd.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_EVENTFD_H +#define _UAPI_LINUX_EVENTFD_H + +#include <linux/fcntl.h> + +#define EFD_SEMAPHORE (1 << 0) +#define EFD_CLOEXEC O_CLOEXEC +#define EFD_NONBLOCK O_NONBLOCK + +#endif /* _UAPI_LINUX_EVENTFD_H */ diff --git a/include/uapi/linux/eventpoll.h b/include/uapi/linux/eventpoll.h index 8a3432d0f0dc..4f4b948ef381 100644 --- a/include/uapi/linux/eventpoll.h +++ b/include/uapi/linux/eventpoll.h @@ -41,6 +41,12 @@  #define EPOLLMSG	(__force __poll_t)0x00000400  #define EPOLLRDHUP	(__force __poll_t)0x00002000 +/* + * Internal flag - wakeup generated by io_uring, used to detect recursion back + * into the io_uring poll handler. + */ +#define EPOLL_URING_WAKE	((__force __poll_t)(1U << 27)) +  /* Set exclusive wakeup mode for the target file descriptor */  #define EPOLLEXCLUSIVE	((__force __poll_t)(1U << 28)) @@ -79,16 +85,17 @@ struct epoll_event {  	__u64 data;  } EPOLL_PACKED; -#ifdef CONFIG_PM_SLEEP -static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev) -{ -	if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND)) -		epev->events &= ~EPOLLWAKEUP; -} -#else -static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev) -{ -	epev->events &= ~EPOLLWAKEUP; -} -#endif +struct epoll_params { +	__u32 busy_poll_usecs; +	__u16 busy_poll_budget; +	__u8 prefer_busy_poll; + +	/* pad the struct to a multiple of 64bits */ +	__u8 __pad; +}; + +#define EPOLL_IOC_TYPE 0x8A +#define EPIOCSPARAMS _IOW(EPOLL_IOC_TYPE, 0x01, struct epoll_params) +#define EPIOCGPARAMS _IOR(EPOLL_IOC_TYPE, 0x02, struct epoll_params) +  #endif /* _UAPI_LINUX_EVENTPOLL_H */ diff --git a/include/uapi/linux/exfat.h b/include/uapi/linux/exfat.h new file mode 100644 index 000000000000..46d95b16fc4b --- /dev/null +++ b/include/uapi/linux/exfat.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Copyright (C) 2024 Unisoc Technologies Co., Ltd. + */ + +#ifndef _UAPI_LINUX_EXFAT_H +#define _UAPI_LINUX_EXFAT_H +#include <linux/types.h> +#include <linux/ioctl.h> + +/* + * exfat-specific ioctl commands + */ + +#define EXFAT_IOC_SHUTDOWN _IOR('X', 125, __u32) + +/* + * Flags used by EXFAT_IOC_SHUTDOWN + */ + +#define EXFAT_GOING_DOWN_DEFAULT	0x0	/* default with full sync */ +#define EXFAT_GOING_DOWN_FULLSYNC	0x1     /* going down with full sync*/ +#define EXFAT_GOING_DOWN_NOSYNC         0x2     /* going down */ + +#endif /* _UAPI_LINUX_EXFAT_H */ diff --git a/include/uapi/linux/ext4.h b/include/uapi/linux/ext4.h new file mode 100644 index 000000000000..1c4c2dd29112 --- /dev/null +++ b/include/uapi/linux/ext4.h @@ -0,0 +1,117 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ + +#ifndef _UAPI_LINUX_EXT4_H +#define _UAPI_LINUX_EXT4_H +#include <linux/fiemap.h> +#include <linux/fs.h> +#include <linux/ioctl.h> +#include <linux/types.h> + +/* + * ext4-specific ioctl commands + */ +#define	EXT4_IOC_GETVERSION		_IOR('f', 3, long) +#define	EXT4_IOC_SETVERSION		_IOW('f', 4, long) +#define	EXT4_IOC_GETVERSION_OLD		FS_IOC_GETVERSION +#define	EXT4_IOC_SETVERSION_OLD		FS_IOC_SETVERSION +#define EXT4_IOC_GETRSVSZ		_IOR('f', 5, long) +#define EXT4_IOC_SETRSVSZ		_IOW('f', 6, long) +#define EXT4_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long) +#define EXT4_IOC_GROUP_ADD		_IOW('f', 8, struct ext4_new_group_input) +#define EXT4_IOC_MIGRATE		_IO('f', 9) + /* note ioctl 10 reserved for an early version of the FIEMAP ioctl */ + /* note ioctl 11 reserved for filesystem-independent FIEMAP ioctl */ +#define EXT4_IOC_ALLOC_DA_BLKS		_IO('f', 12) +#define EXT4_IOC_MOVE_EXT		_IOWR('f', 15, struct move_extent) +#define EXT4_IOC_RESIZE_FS		_IOW('f', 16, __u64) +#define EXT4_IOC_SWAP_BOOT		_IO('f', 17) +#define EXT4_IOC_PRECACHE_EXTENTS	_IO('f', 18) +/* ioctl codes 19--39 are reserved for fscrypt */ +#define EXT4_IOC_CLEAR_ES_CACHE		_IO('f', 40) +#define EXT4_IOC_GETSTATE		_IOW('f', 41, __u32) +#define EXT4_IOC_GET_ES_CACHE		_IOWR('f', 42, struct fiemap) +#define EXT4_IOC_CHECKPOINT		_IOW('f', 43, __u32) +#define EXT4_IOC_GETFSUUID		_IOR('f', 44, struct fsuuid) +#define EXT4_IOC_SETFSUUID		_IOW('f', 44, struct fsuuid) + +#define EXT4_IOC_SHUTDOWN _IOR('X', 125, __u32) + +/* + * ioctl commands in 32 bit emulation + */ +#define EXT4_IOC32_GETVERSION		_IOR('f', 3, int) +#define EXT4_IOC32_SETVERSION		_IOW('f', 4, int) +#define EXT4_IOC32_GETRSVSZ		_IOR('f', 5, int) +#define EXT4_IOC32_SETRSVSZ		_IOW('f', 6, int) +#define EXT4_IOC32_GROUP_EXTEND		_IOW('f', 7, unsigned int) +#define EXT4_IOC32_GROUP_ADD		_IOW('f', 8, struct compat_ext4_new_group_input) +#define EXT4_IOC32_GETVERSION_OLD	FS_IOC32_GETVERSION +#define EXT4_IOC32_SETVERSION_OLD	FS_IOC32_SETVERSION + +/* + * Flags returned by EXT4_IOC_GETSTATE + * + * We only expose to userspace a subset of the state flags in + * i_state_flags + */ +#define EXT4_STATE_FLAG_EXT_PRECACHED	0x00000001 +#define EXT4_STATE_FLAG_NEW		0x00000002 +#define EXT4_STATE_FLAG_NEWENTRY	0x00000004 +#define EXT4_STATE_FLAG_DA_ALLOC_CLOSE	0x00000008 + +/* + * Flags for ioctl EXT4_IOC_CHECKPOINT + */ +#define EXT4_IOC_CHECKPOINT_FLAG_DISCARD	0x1 +#define EXT4_IOC_CHECKPOINT_FLAG_ZEROOUT	0x2 +#define EXT4_IOC_CHECKPOINT_FLAG_DRY_RUN	0x4 +#define EXT4_IOC_CHECKPOINT_FLAG_VALID		(EXT4_IOC_CHECKPOINT_FLAG_DISCARD | \ +						EXT4_IOC_CHECKPOINT_FLAG_ZEROOUT | \ +						EXT4_IOC_CHECKPOINT_FLAG_DRY_RUN) + +/* + * Structure for EXT4_IOC_GETFSUUID/EXT4_IOC_SETFSUUID + */ +struct fsuuid { +	__u32       fsu_len; +	__u32       fsu_flags; +	__u8        fsu_uuid[]; +}; + +/* + * Structure for EXT4_IOC_MOVE_EXT + */ +struct move_extent { +	__u32 reserved;		/* should be zero */ +	__u32 donor_fd;		/* donor file descriptor */ +	__u64 orig_start;	/* logical start offset in block for orig */ +	__u64 donor_start;	/* logical start offset in block for donor */ +	__u64 len;		/* block length to be moved */ +	__u64 moved_len;	/* moved block length */ +}; + +/* + * Flags used by EXT4_IOC_SHUTDOWN + */ +#define EXT4_GOING_FLAGS_DEFAULT		0x0	/* going down */ +#define EXT4_GOING_FLAGS_LOGFLUSH		0x1	/* flush log but not data */ +#define EXT4_GOING_FLAGS_NOLOGFLUSH		0x2	/* don't flush log nor data */ + +/* Used to pass group descriptor data when online resize is done */ +struct ext4_new_group_input { +	__u32 group;		/* Group number for this data */ +	__u64 block_bitmap;	/* Absolute block number of block bitmap */ +	__u64 inode_bitmap;	/* Absolute block number of inode bitmap */ +	__u64 inode_table;	/* Absolute block number of inode table start */ +	__u32 blocks_count;	/* Total number of blocks in this group */ +	__u16 reserved_blocks;	/* Number of reserved blocks in this group */ +	__u16 unused; +}; + +/* + * Returned by EXT4_IOC_GET_ES_CACHE as an additional possible flag. + * It indicates that the entry in extent status cache is for a hole. + */ +#define EXT4_FIEMAP_EXTENT_HOLE		0x08000000 + +#endif /* _UAPI_LINUX_EXT4_H */ diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h new file mode 100644 index 000000000000..795e26258355 --- /dev/null +++ b/include/uapi/linux/f2fs.h @@ -0,0 +1,107 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ + +#ifndef _UAPI_LINUX_F2FS_H +#define _UAPI_LINUX_F2FS_H +#include <linux/types.h> +#include <linux/ioctl.h> + +/* + * f2fs-specific ioctl commands + */ +#define F2FS_IOCTL_MAGIC		0xf5 +#define F2FS_IOC_START_ATOMIC_WRITE	_IO(F2FS_IOCTL_MAGIC, 1) +#define F2FS_IOC_COMMIT_ATOMIC_WRITE	_IO(F2FS_IOCTL_MAGIC, 2) +#define F2FS_IOC_START_VOLATILE_WRITE	_IO(F2FS_IOCTL_MAGIC, 3) +#define F2FS_IOC_RELEASE_VOLATILE_WRITE	_IO(F2FS_IOCTL_MAGIC, 4) +#define F2FS_IOC_ABORT_ATOMIC_WRITE	_IO(F2FS_IOCTL_MAGIC, 5) +#define F2FS_IOC_GARBAGE_COLLECT	_IOW(F2FS_IOCTL_MAGIC, 6, __u32) +#define F2FS_IOC_WRITE_CHECKPOINT	_IO(F2FS_IOCTL_MAGIC, 7) +#define F2FS_IOC_DEFRAGMENT		_IOWR(F2FS_IOCTL_MAGIC, 8,	\ +						struct f2fs_defragment) +#define F2FS_IOC_MOVE_RANGE		_IOWR(F2FS_IOCTL_MAGIC, 9,	\ +						struct f2fs_move_range) +#define F2FS_IOC_FLUSH_DEVICE		_IOW(F2FS_IOCTL_MAGIC, 10,	\ +						struct f2fs_flush_device) +#define F2FS_IOC_GARBAGE_COLLECT_RANGE	_IOW(F2FS_IOCTL_MAGIC, 11,	\ +						struct f2fs_gc_range) +#define F2FS_IOC_GET_FEATURES		_IOR(F2FS_IOCTL_MAGIC, 12, __u32) +#define F2FS_IOC_SET_PIN_FILE		_IOW(F2FS_IOCTL_MAGIC, 13, __u32) +#define F2FS_IOC_GET_PIN_FILE		_IOR(F2FS_IOCTL_MAGIC, 14, __u32) +#define F2FS_IOC_PRECACHE_EXTENTS	_IO(F2FS_IOCTL_MAGIC, 15) +#define F2FS_IOC_RESIZE_FS		_IOW(F2FS_IOCTL_MAGIC, 16, __u64) +#define F2FS_IOC_GET_COMPRESS_BLOCKS	_IOR(F2FS_IOCTL_MAGIC, 17, __u64) +#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS				\ +					_IOR(F2FS_IOCTL_MAGIC, 18, __u64) +#define F2FS_IOC_RESERVE_COMPRESS_BLOCKS				\ +					_IOR(F2FS_IOCTL_MAGIC, 19, __u64) +#define F2FS_IOC_SEC_TRIM_FILE		_IOW(F2FS_IOCTL_MAGIC, 20,	\ +						struct f2fs_sectrim_range) +#define F2FS_IOC_GET_COMPRESS_OPTION	_IOR(F2FS_IOCTL_MAGIC, 21,	\ +						struct f2fs_comp_option) +#define F2FS_IOC_SET_COMPRESS_OPTION	_IOW(F2FS_IOCTL_MAGIC, 22,	\ +						struct f2fs_comp_option) +#define F2FS_IOC_DECOMPRESS_FILE	_IO(F2FS_IOCTL_MAGIC, 23) +#define F2FS_IOC_COMPRESS_FILE		_IO(F2FS_IOCTL_MAGIC, 24) +#define F2FS_IOC_START_ATOMIC_REPLACE	_IO(F2FS_IOCTL_MAGIC, 25) +#define F2FS_IOC_GET_DEV_ALIAS_FILE	_IOR(F2FS_IOCTL_MAGIC, 26, __u32) +#define F2FS_IOC_IO_PRIO		_IOW(F2FS_IOCTL_MAGIC, 27, __u32) + +/* + * should be same as XFS_IOC_GOINGDOWN. + * Flags for going down operation used by FS_IOC_GOINGDOWN + */ +#define F2FS_IOC_SHUTDOWN	_IOR('X', 125, __u32)	/* Shutdown */ +#define F2FS_GOING_DOWN_FULLSYNC	0x0	/* going down with full sync */ +#define F2FS_GOING_DOWN_METASYNC	0x1	/* going down with metadata */ +#define F2FS_GOING_DOWN_NOSYNC		0x2	/* going down */ +#define F2FS_GOING_DOWN_METAFLUSH	0x3	/* going down with meta flush */ +#define F2FS_GOING_DOWN_NEED_FSCK	0x4	/* going down to trigger fsck */ + +/* + * Flags used by F2FS_IOC_SEC_TRIM_FILE + */ +#define F2FS_TRIM_FILE_DISCARD		0x1	/* send discard command */ +#define F2FS_TRIM_FILE_ZEROOUT		0x2	/* zero out */ +#define F2FS_TRIM_FILE_MASK		0x3 + +/* for F2FS_IOC_IO_PRIO */ +enum { +	F2FS_IOPRIO_WRITE = 1,	/* high write priority */ +	F2FS_IOPRIO_MAX, +}; + +struct f2fs_gc_range { +	__u32 sync; +	__u64 start; +	__u64 len; +}; + +struct f2fs_defragment { +	__u64 start; +	__u64 len; +}; + +struct f2fs_move_range { +	__u32 dst_fd;		/* destination fd */ +	__u64 pos_in;		/* start position in src_fd */ +	__u64 pos_out;		/* start position in dst_fd */ +	__u64 len;		/* size to move */ +}; + +struct f2fs_flush_device { +	__u32 dev_num;		/* device number to flush */ +	__u32 segments;		/* # of segments to flush */ +}; + +struct f2fs_sectrim_range { +	__u64 start; +	__u64 len; +	__u64 flags; +}; + +struct f2fs_comp_option { +	__u8 algorithm; +	__u8 log_cluster_size; +}; + +#endif /* _UAPI_LINUX_F2FS_H */ diff --git a/include/uapi/linux/falloc.h b/include/uapi/linux/falloc.h index 51398fa57f6c..1f9ca757d02d 100644 --- a/include/uapi/linux/falloc.h +++ b/include/uapi/linux/falloc.h @@ -2,6 +2,7 @@  #ifndef _UAPI_FALLOC_H_  #define _UAPI_FALLOC_H_ +#define FALLOC_FL_ALLOCATE_RANGE 0x00 /* allocate range */  #define FALLOC_FL_KEEP_SIZE	0x01 /* default is extend size */  #define FALLOC_FL_PUNCH_HOLE	0x02 /* de-allocates range */  #define FALLOC_FL_NO_HIDE_STALE	0x04 /* reserved codepoint */ @@ -77,4 +78,21 @@   */  #define FALLOC_FL_UNSHARE_RANGE		0x40 +/* + * FALLOC_FL_WRITE_ZEROES zeroes a specified file range in such a way that + * subsequent writes to that range do not require further changes to the file + * mapping metadata. This flag is beneficial for subsequent pure overwriting + * within this range, as it can save on block allocation and, consequently, + * significant metadata changes. Therefore, filesystems that always require + * out-of-place writes should not support this flag. + * + * Different filesystems may implement different limitations on the + * granularity of the zeroing operation. Most will preferably be accelerated + * by submitting write zeroes command if the backing storage supports, which + * may not physically write zeros to the media. + * + * This flag cannot be specified in conjunction with the FALLOC_FL_KEEP_SIZE. + */ +#define FALLOC_FL_WRITE_ZEROES		0x80 +  #endif /* _UAPI_FALLOC_H_ */ diff --git a/include/uapi/linux/fanotify.h b/include/uapi/linux/fanotify.h index fbf9c5c7dd59..e710967c7c26 100644 --- a/include/uapi/linux/fanotify.h +++ b/include/uapi/linux/fanotify.h @@ -8,8 +8,8 @@  #define FAN_ACCESS		0x00000001	/* File was accessed */  #define FAN_MODIFY		0x00000002	/* File was modified */  #define FAN_ATTRIB		0x00000004	/* Metadata changed */ -#define FAN_CLOSE_WRITE		0x00000008	/* Writtable file closed */ -#define FAN_CLOSE_NOWRITE	0x00000010	/* Unwrittable file closed */ +#define FAN_CLOSE_WRITE		0x00000008	/* Writable file closed */ +#define FAN_CLOSE_NOWRITE	0x00000010	/* Unwritable file closed */  #define FAN_OPEN		0x00000020	/* File was opened */  #define FAN_MOVED_FROM		0x00000040	/* File was moved from X */  #define FAN_MOVED_TO		0x00000080	/* File was moved to Y */ @@ -20,13 +20,21 @@  #define FAN_OPEN_EXEC		0x00001000	/* File was opened for exec */  #define FAN_Q_OVERFLOW		0x00004000	/* Event queued overflowed */ +#define FAN_FS_ERROR		0x00008000	/* Filesystem error */  #define FAN_OPEN_PERM		0x00010000	/* File open in perm check */  #define FAN_ACCESS_PERM		0x00020000	/* File accessed in perm check */  #define FAN_OPEN_EXEC_PERM	0x00040000	/* File open/exec in perm check */ +/* #define FAN_DIR_MODIFY	0x00080000 */	/* Deprecated (reserved) */ + +#define FAN_PRE_ACCESS		0x00100000	/* Pre-content access hook */ +#define FAN_MNT_ATTACH		0x01000000	/* Mount was attached */ +#define FAN_MNT_DETACH		0x02000000	/* Mount was detached */  #define FAN_EVENT_ON_CHILD	0x08000000	/* Interested in child events */ +#define FAN_RENAME		0x10000000	/* File was renamed */ +  #define FAN_ONDIR		0x40000000	/* Event occurred against dir */  /* helper events */ @@ -51,13 +59,20 @@  #define FAN_ENABLE_AUDIT	0x00000040  /* Flags to determine fanotify event format */ +#define FAN_REPORT_PIDFD	0x00000080	/* Report pidfd for event->pid */  #define FAN_REPORT_TID		0x00000100	/* event->pid is thread id */  #define FAN_REPORT_FID		0x00000200	/* Report unique file id */  #define FAN_REPORT_DIR_FID	0x00000400	/* Report unique directory id */  #define FAN_REPORT_NAME		0x00000800	/* Report events with name */ +#define FAN_REPORT_TARGET_FID	0x00001000	/* Report dirent target id  */ +#define FAN_REPORT_FD_ERROR	0x00002000	/* event->fd can report error */ +#define FAN_REPORT_MNT		0x00004000	/* Report mount events */  /* Convenience macro - FAN_REPORT_NAME requires FAN_REPORT_DIR_FID */  #define FAN_REPORT_DFID_NAME	(FAN_REPORT_DIR_FID | FAN_REPORT_NAME) +/* Convenience macro - FAN_REPORT_TARGET_FID requires all other FID flags */ +#define FAN_REPORT_DFID_NAME_TARGET (FAN_REPORT_DFID_NAME | \ +				     FAN_REPORT_FID | FAN_REPORT_TARGET_FID)  /* Deprecated - do not use this in programs and do not add new flags here! */  #define FAN_ALL_INIT_FLAGS	(FAN_CLOEXEC | FAN_NONBLOCK | \ @@ -74,11 +89,21 @@  #define FAN_MARK_IGNORED_SURV_MODIFY	0x00000040  #define FAN_MARK_FLUSH		0x00000080  /* FAN_MARK_FILESYSTEM is	0x00000100 */ +#define FAN_MARK_EVICTABLE	0x00000200 +/* This bit is mutually exclusive with FAN_MARK_IGNORED_MASK bit */ +#define FAN_MARK_IGNORE		0x00000400  /* These are NOT bitwise flags.  Both bits can be used togther.  */  #define FAN_MARK_INODE		0x00000000  #define FAN_MARK_MOUNT		0x00000010  #define FAN_MARK_FILESYSTEM	0x00000100 +#define FAN_MARK_MNTNS		0x00000110 + +/* + * Convenience macro - FAN_MARK_IGNORE requires FAN_MARK_IGNORED_SURV_MODIFY + * for non-inode mark types. + */ +#define FAN_MARK_IGNORE_SURV	(FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY)  /* Deprecated - do not use this in programs and do not add new flags here! */  #define FAN_ALL_MARK_FLAGS	(FAN_MARK_ADD |\ @@ -123,6 +148,16 @@ struct fanotify_event_metadata {  #define FAN_EVENT_INFO_TYPE_FID		1  #define FAN_EVENT_INFO_TYPE_DFID_NAME	2  #define FAN_EVENT_INFO_TYPE_DFID	3 +#define FAN_EVENT_INFO_TYPE_PIDFD	4 +#define FAN_EVENT_INFO_TYPE_ERROR	5 +#define FAN_EVENT_INFO_TYPE_RANGE	6 +#define FAN_EVENT_INFO_TYPE_MNT		7 + +/* Special info types for FAN_RENAME */ +#define FAN_EVENT_INFO_TYPE_OLD_DFID_NAME	10 +/* Reserved for FAN_EVENT_INFO_TYPE_OLD_DFID	11 */ +#define FAN_EVENT_INFO_TYPE_NEW_DFID_NAME	12 +/* Reserved for FAN_EVENT_INFO_TYPE_NEW_DFID	13 */  /* Variable length info record following event metadata */  struct fanotify_event_info_header { @@ -145,21 +180,85 @@ struct fanotify_event_info_fid {  	 * Following is an opaque struct file_handle that can be passed as  	 * an argument to open_by_handle_at(2).  	 */ -	unsigned char handle[0]; +	unsigned char handle[]; +}; + +/* + * This structure is used for info records of type FAN_EVENT_INFO_TYPE_PIDFD. + * It holds a pidfd for the pid that was responsible for generating an event. + */ +struct fanotify_event_info_pidfd { +	struct fanotify_event_info_header hdr; +	__s32 pidfd; +}; + +struct fanotify_event_info_error { +	struct fanotify_event_info_header hdr; +	__s32 error; +	__u32 error_count;  }; +struct fanotify_event_info_range { +	struct fanotify_event_info_header hdr; +	__u32 pad; +	__u64 offset; +	__u64 count; +}; + +struct fanotify_event_info_mnt { +	struct fanotify_event_info_header hdr; +	__u64 mnt_id; +}; + +/* + * User space may need to record additional information about its decision. + * The extra information type records what kind of information is included. + * The default is none. We also define an extra information buffer whose + * size is determined by the extra information type. + * + * If the information type is Audit Rule, then the information following + * is the rule number that triggered the user space decision that + * requires auditing. + */ + +#define FAN_RESPONSE_INFO_NONE		0 +#define FAN_RESPONSE_INFO_AUDIT_RULE	1 +  struct fanotify_response {  	__s32 fd;  	__u32 response;  }; +struct fanotify_response_info_header { +	__u8 type; +	__u8 pad; +	__u16 len; +}; + +struct fanotify_response_info_audit_rule { +	struct fanotify_response_info_header hdr; +	__u32 rule_number; +	__u32 subj_trust; +	__u32 obj_trust; +}; +  /* Legit userspace responses to a _PERM event */  #define FAN_ALLOW	0x01  #define FAN_DENY	0x02 -#define FAN_AUDIT	0x10	/* Bit mask to create audit record for result */ +/* errno other than EPERM can specified in upper byte of deny response */ +#define FAN_ERRNO_BITS	8 +#define FAN_ERRNO_SHIFT (32 - FAN_ERRNO_BITS) +#define FAN_ERRNO_MASK	((1 << FAN_ERRNO_BITS) - 1) +#define FAN_DENY_ERRNO(err) \ +	(FAN_DENY | ((((__u32)(err)) & FAN_ERRNO_MASK) << FAN_ERRNO_SHIFT)) + +#define FAN_AUDIT	0x10	/* Bitmask to create audit record for result */ +#define FAN_INFO	0x20	/* Bitmask to indicate additional information */  /* No fd set in event */  #define FAN_NOFD	-1 +#define FAN_NOPIDFD	FAN_NOFD +#define FAN_EPIDFD	-2  /* Helper functions to deal with fanotify_event_metadata buffers */  #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata)) diff --git a/include/uapi/linux/fb.h b/include/uapi/linux/fb.h index 4c14e8be7267..cde8f173f566 100644 --- a/include/uapi/linux/fb.h +++ b/include/uapi/linux/fb.h @@ -4,6 +4,7 @@  #include <linux/types.h>  #include <linux/i2c.h> +#include <linux/vesa.h>  /* Definitions of frame buffers						*/ @@ -182,7 +183,7 @@ struct fb_fix_screeninfo {   *   * For pseudocolor: offset and length should be the same for all color   * components. Offset specifies the position of the least significant bit - * of the pallette index in a pixel value. Length indicates the number + * of the palette index in a pixel value. Length indicates the number   * of available palette entries (i.e. # of entries = 1 << length).   */  struct fb_bitfield { @@ -293,13 +294,6 @@ struct fb_con2fbmap {  	__u32 framebuffer;  }; -/* VESA Blanking Levels */ -#define VESA_NO_BLANKING        0 -#define VESA_VSYNC_SUSPEND      1 -#define VESA_HSYNC_SUSPEND      2 -#define VESA_POWERDOWN          3 - -  enum {  	/* screen: unblanked, hsync: on,  vsync: on */  	FB_BLANK_UNBLANK       = VESA_NO_BLANKING, diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index 2f86b2ad6d7e..f291ab4f94eb 100644 --- a/include/uapi/linux/fcntl.h +++ b/include/uapi/linux/fcntl.h @@ -9,6 +9,17 @@  #define F_GETLEASE	(F_LINUX_SPECIFIC_BASE + 1)  /* + * Request nofications on a directory. + * See below for events that may be notified. + */ +#define F_NOTIFY	(F_LINUX_SPECIFIC_BASE + 2) + +#define F_DUPFD_QUERY	(F_LINUX_SPECIFIC_BASE + 3) + +/* Was the file just created? */ +#define F_CREATED_QUERY	(F_LINUX_SPECIFIC_BASE + 4) + +/*   * Cancel a blocking posix lock; internal use only until we expose an   * asynchronous lock api to userspace:   */ @@ -18,12 +29,6 @@  #define F_DUPFD_CLOEXEC	(F_LINUX_SPECIFIC_BASE + 6)  /* - * Request nofications on a directory. - * See below for events that may be notified. - */ -#define F_NOTIFY	(F_LINUX_SPECIFIC_BASE+2) - -/*   * Set and get of pipe page size array   */  #define F_SETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 7) @@ -43,6 +48,7 @@  #define F_SEAL_GROW	0x0004	/* prevent file from growing */  #define F_SEAL_WRITE	0x0008	/* prevent writes */  #define F_SEAL_FUTURE_WRITE	0x0010  /* prevent future writes while mapped */ +#define F_SEAL_EXEC	0x0020  /* prevent chmod modifying exec bits */  /* (1U << 31) is reserved for signed error codes */  /* @@ -84,31 +90,91 @@  #define DN_ATTRIB	0x00000020	/* File changed attibutes */  #define DN_MULTISHOT	0x80000000	/* Don't remove notifier */ +/* Reserved kernel ranges [-100], [-10000, -40000]. */ +#define AT_FDCWD		-100    /* Special value for dirfd used to +					   indicate openat should use the +					   current working directory. */ + +/* + * The concept of process and threads in userland and the kernel is a confusing + * one - within the kernel every thread is a 'task' with its own individual PID, + * however from userland's point of view threads are grouped by a single PID, + * which is that of the 'thread group leader', typically the first thread + * spawned. + * + * To cut the Gideon knot, for internal kernel usage, we refer to + * PIDFD_SELF_THREAD to refer to the current thread (or task from a kernel + * perspective), and PIDFD_SELF_THREAD_GROUP to refer to the current thread + * group leader... + */ +#define PIDFD_SELF_THREAD		-10000 /* Current thread. */ +#define PIDFD_SELF_THREAD_GROUP		-10001 /* Current thread group leader. */ + +#define FD_PIDFS_ROOT			-10002 /* Root of the pidfs filesystem */ +#define FD_INVALID			-10009 /* Invalid file descriptor: -10000 - EBADF = -10009 */ + +/* Generic flags for the *at(2) family of syscalls. */ + +/* Reserved for per-syscall flags	0xff. */ +#define AT_SYMLINK_NOFOLLOW		0x100   /* Do not follow symbolic +						   links. */ +/* Reserved for per-syscall flags	0x200 */ +#define AT_SYMLINK_FOLLOW		0x400   /* Follow symbolic links. */ +#define AT_NO_AUTOMOUNT			0x800	/* Suppress terminal automount +						   traversal. */ +#define AT_EMPTY_PATH			0x1000	/* Allow empty relative +						   pathname to operate on dirfd +						   directly. */  /* - * The constants AT_REMOVEDIR and AT_EACCESS have the same value.  AT_EACCESS is - * meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to - * unlinkat.  The two functions do completely different things and therefore, - * the flags can be allowed to overlap.  For example, passing AT_REMOVEDIR to - * faccessat would be undefined behavior and thus treating it equivalent to - * AT_EACCESS is valid undefined behavior. + * These flags are currently statx(2)-specific, but they could be made generic + * in the future and so they should not be used for other per-syscall flags.   */ -#define AT_FDCWD		-100    /* Special value used to indicate -                                           openat should use the current -                                           working directory. */ -#define AT_SYMLINK_NOFOLLOW	0x100   /* Do not follow symbolic links.  */ +#define AT_STATX_SYNC_TYPE		0x6000	/* Type of synchronisation required from statx() */ +#define AT_STATX_SYNC_AS_STAT		0x0000	/* - Do whatever stat() does */ +#define AT_STATX_FORCE_SYNC		0x2000	/* - Force the attributes to be sync'd with the server */ +#define AT_STATX_DONT_SYNC		0x4000	/* - Don't sync attributes with the server */ + +#define AT_RECURSIVE			0x8000	/* Apply to the entire subtree */ + +/* + * Per-syscall flags for the *at(2) family of syscalls. + * + * These are flags that are so syscall-specific that a user passing these flags + * to the wrong syscall is so "clearly wrong" that we can safely call such + * usage "undefined behaviour". + * + * For example, the constants AT_REMOVEDIR and AT_EACCESS have the same value. + * AT_EACCESS is meaningful only to faccessat, while AT_REMOVEDIR is meaningful + * only to unlinkat. The two functions do completely different things and + * therefore, the flags can be allowed to overlap. For example, passing + * AT_REMOVEDIR to faccessat would be undefined behavior and thus treating it + * equivalent to AT_EACCESS is valid undefined behavior. + * + * Note for implementers: When picking a new per-syscall AT_* flag, try to + * reuse already existing flags first. This leaves us with as many unused bits + * as possible, so we can use them for generic bits in the future if necessary. + */ + +/* Flags for renameat2(2) (must match legacy RENAME_* flags). */ +#define AT_RENAME_NOREPLACE	0x0001 +#define AT_RENAME_EXCHANGE	0x0002 +#define AT_RENAME_WHITEOUT	0x0004 + +/* Flag for faccessat(2). */  #define AT_EACCESS		0x200	/* Test access permitted for                                             effective IDs, not real IDs.  */ +/* Flag for unlinkat(2). */  #define AT_REMOVEDIR		0x200   /* Remove directory instead of                                             unlinking file.  */ -#define AT_SYMLINK_FOLLOW	0x400   /* Follow symbolic links.  */ -#define AT_NO_AUTOMOUNT		0x800	/* Suppress terminal automount traversal */ -#define AT_EMPTY_PATH		0x1000	/* Allow empty relative pathname */ - -#define AT_STATX_SYNC_TYPE	0x6000	/* Type of synchronisation required from statx() */ -#define AT_STATX_SYNC_AS_STAT	0x0000	/* - Do whatever stat() does */ -#define AT_STATX_FORCE_SYNC	0x2000	/* - Force the attributes to be sync'd with the server */ -#define AT_STATX_DONT_SYNC	0x4000	/* - Don't sync attributes with the server */ - -#define AT_RECURSIVE		0x8000	/* Apply to the entire subtree */ +/* Flags for name_to_handle_at(2). */ +#define AT_HANDLE_FID		0x200	/* File handle is needed to compare +					   object identity and may not be +					   usable with open_by_handle_at(2). */ +#define AT_HANDLE_MNT_ID_UNIQUE	0x001	/* Return the u64 unique mount ID. */ +#define AT_HANDLE_CONNECTABLE	0x002	/* Request a connectable file handle */ + +/* Flags for execveat2(2). */ +#define AT_EXECVE_CHECK		0x10000	/* Only perform a check if execution +					   would be allowed. */  #endif /* _UAPI_LINUX_FCNTL_H */ diff --git a/include/uapi/linux/fd.h b/include/uapi/linux/fd.h index 8b80c63b971c..7022e3413dbc 100644 --- a/include/uapi/linux/fd.h +++ b/include/uapi/linux/fd.h @@ -49,11 +49,11 @@ struct floppy_struct {  #define FDCLRPRM _IO(2, 0x41)  /* clear user-defined parameters */ -#define FDSETPRM _IOW(2, 0x42, struct floppy_struct)  +#define FDSETPRM _IOW(2, 0x42, struct floppy_struct)  #define FDSETMEDIAPRM FDSETPRM  /* set user-defined parameters for current media */ -#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct)  +#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct)  #define FDGETPRM _IOR(2, 0x04, struct floppy_struct)  #define FDDEFMEDIAPRM FDDEFPRM  #define FDGETMEDIAPRM FDGETPRM @@ -65,7 +65,7 @@ struct floppy_struct {  /* issue/don't issue kernel messages on media type change */ -/*  +/*   * Formatting (obsolete)   */  #define FD_FILL_BYTE 0xF6 /* format fill byte. */ @@ -126,13 +126,13 @@ typedef char floppy_drive_name[16];   */  struct floppy_drive_params {  	signed char cmos;		/* CMOS type */ -	 -	/* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms  + +	/* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms  	 * etc) and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA).  	 */  	unsigned long max_dtr;		/* Step rate, usec */  	unsigned long hlt;     		/* Head load/settle time, msec */ -	unsigned long hut;     		/* Head unload time (remnant of  +	unsigned long hut;     		/* Head unload time (remnant of  					 * 8" drives) */  	unsigned long srt;     		/* Step rate, usec */ @@ -145,12 +145,12 @@ struct floppy_drive_params {  	unsigned char rps;		/* rotations per second */  	unsigned char tracks;		/* maximum number of tracks */  	unsigned long timeout;		/* timeout for interrupt requests */ -	 -	unsigned char interleave_sect;	/* if there are more sectors, use  + +	unsigned char interleave_sect;	/* if there are more sectors, use  					 * interleave */ -	 +  	struct floppy_max_errors max_errors; -	 +  	char flags;			/* various flags, including ftd_msg */  /*   * Announce successful media type detection and media information loss after @@ -162,7 +162,7 @@ struct floppy_drive_params {  #define FD_BROKEN_DCL 0x20  #define FD_DEBUG 0x02  #define FD_SILENT_DCL_CLEAR 0x4 -#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware  +#define FD_INVERTED_DCL 0x80 /* must be 0x80, because of hardware  				considerations */  	char read_track;		/* use readtrack during probing? */ @@ -176,8 +176,8 @@ struct floppy_drive_params {  #define FD_AUTODETECT_SIZE 8  	short autodetect[FD_AUTODETECT_SIZE]; /* autodetected formats */ -	 -	int checkfreq; /* how often should the drive be checked for disk  + +	int checkfreq; /* how often should the drive be checked for disk  			* changes */  	int native_format; /* native format of this drive */  }; @@ -225,13 +225,13 @@ struct floppy_drive_struct {   * decremented after each probe.   */  	int keep_data; -	 +  	/* Prevent "aliased" accesses. */  	int fd_ref;  	int fd_device; -	unsigned long last_checked; /* when was the drive last checked for a disk  +	unsigned long last_checked; /* when was the drive last checked for a disk  			   * change? */ -	 +  	char *dmabuf;  	int bufblocks;  }; @@ -255,7 +255,7 @@ enum reset_mode {  /*   * FDC state   */ -struct floppy_fdc_state {	 +struct floppy_fdc_state {  	int spec1;		/* spec1 value last used */  	int spec2;		/* spec2 value last used */  	int dtr; @@ -302,16 +302,16 @@ struct floppy_write_errors {  	 * to the user process are not counted.  	 */ -	unsigned int write_errors;  /* number of physical write errors  +	unsigned int write_errors;  /* number of physical write errors  				     * encountered */ -	 +  	/* position of first and last write errors */  	unsigned long first_error_sector;  	int           first_error_generation;  	unsigned long last_error_sector;  	int           last_error_generation; -	 -	unsigned int badness; /* highest retry count for a read or write  + +	unsigned int badness; /* highest retry count for a read or write  			       * operation */  }; @@ -335,7 +335,7 @@ struct floppy_raw_cmd {  #define FD_RAW_DISK_CHANGE 4 /* out: disk change flag was set */  #define FD_RAW_INTR 8    /* wait for an interrupt */  #define FD_RAW_SPIN 0x10 /* spin up the disk for this command */ -#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command  +#define FD_RAW_NO_MOTOR_AFTER 0x20 /* switch the motor off after command  				    * completion */  #define FD_RAW_NEED_DISK 0x40  /* this command needs a disk to be present */  #define FD_RAW_NEED_SEEK 0x80  /* this command uses an implied seek (soft) */ @@ -353,7 +353,7 @@ struct floppy_raw_cmd {  	void __user *data;  	char *kernel_data; /* location of data buffer in the kernel */ -	struct floppy_raw_cmd *next; /* used for chaining of raw cmd's  +	struct floppy_raw_cmd *next; /* used for chaining of raw cmd's  				      * within the kernel */  	long length; /* in: length of dma transfer. out: remaining bytes */  	long phys_length; /* physical length, if different from dma length */ diff --git a/include/uapi/linux/fib_rules.h b/include/uapi/linux/fib_rules.h index 232df14e1287..418c4be697ad 100644 --- a/include/uapi/linux/fib_rules.h +++ b/include/uapi/linux/fib_rules.h @@ -1,6 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_FIB_RULES_H -#define __LINUX_FIB_RULES_H +#ifndef _UAPI__LINUX_FIB_RULES_H +#define _UAPI__LINUX_FIB_RULES_H  #include <linux/types.h>  #include <linux/rtnetlink.h> @@ -67,6 +67,12 @@ enum {  	FRA_IP_PROTO,	/* ip proto */  	FRA_SPORT_RANGE, /* sport */  	FRA_DPORT_RANGE, /* dport */ +	FRA_DSCP,	/* dscp */ +	FRA_FLOWLABEL,	/* flowlabel */ +	FRA_FLOWLABEL_MASK,	/* flowlabel mask */ +	FRA_SPORT_MASK,	/* sport mask */ +	FRA_DPORT_MASK,	/* dport mask */ +	FRA_DSCP_MASK,	/* dscp mask */  	__FRA_MAX  }; diff --git a/include/uapi/linux/fiemap.h b/include/uapi/linux/fiemap.h index 07c1cdcb715e..9d9e8ae32b41 100644 --- a/include/uapi/linux/fiemap.h +++ b/include/uapi/linux/fiemap.h @@ -14,37 +14,56 @@  #include <linux/types.h> +/** + * struct fiemap_extent - description of one fiemap extent + * @fe_logical: byte offset of the extent in the file + * @fe_physical: byte offset of extent on disk + * @fe_length: length in bytes for this extent + * @fe_flags: FIEMAP_EXTENT_* flags for this extent + */  struct fiemap_extent { -	__u64 fe_logical;  /* logical offset in bytes for the start of -			    * the extent from the beginning of the file */ -	__u64 fe_physical; /* physical offset in bytes for the start -			    * of the extent from the beginning of the disk */ -	__u64 fe_length;   /* length in bytes for this extent */ +	__u64 fe_logical; +	__u64 fe_physical; +	__u64 fe_length; +	/* private: */  	__u64 fe_reserved64[2]; -	__u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */ +	/* public: */ +	__u32 fe_flags; +	/* private: */  	__u32 fe_reserved[3];  }; +/** + * struct fiemap - file extent mappings + * @fm_start: byte offset (inclusive) at which to start mapping (in) + * @fm_length: logical length of mapping which userspace wants (in) + * @fm_flags: FIEMAP_FLAG_* flags for request (in/out) + * @fm_mapped_extents: number of extents that were mapped (out) + * @fm_extent_count: size of fm_extents array (in) + * @fm_extents: array of mapped extents (out) + */  struct fiemap { -	__u64 fm_start;		/* logical offset (inclusive) at -				 * which to start mapping (in) */ -	__u64 fm_length;	/* logical length of mapping which -				 * userspace wants (in) */ -	__u32 fm_flags;		/* FIEMAP_FLAG_* flags for request (in/out) */ -	__u32 fm_mapped_extents;/* number of extents that were mapped (out) */ -	__u32 fm_extent_count;  /* size of fm_extents array (in) */ +	__u64 fm_start; +	__u64 fm_length; +	__u32 fm_flags; +	__u32 fm_mapped_extents; +	__u32 fm_extent_count; +	/* private: */  	__u32 fm_reserved; -	struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */ +	/* public: */ +	struct fiemap_extent fm_extents[];  };  #define FIEMAP_MAX_OFFSET	(~0ULL) +/* flags used in fm_flags: */  #define FIEMAP_FLAG_SYNC	0x00000001 /* sync file data before map */  #define FIEMAP_FLAG_XATTR	0x00000002 /* map extended attribute tree */  #define FIEMAP_FLAG_CACHE	0x00000004 /* request caching of the extents */  #define FIEMAP_FLAGS_COMPAT	(FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR) +/* flags used in fe_flags: */  #define FIEMAP_EXTENT_LAST		0x00000001 /* Last extent in file. */  #define FIEMAP_EXTENT_UNKNOWN		0x00000002 /* Data location unknown. */  #define FIEMAP_EXTENT_DELALLOC		0x00000004 /* Location still pending. diff --git a/include/uapi/linux/firewire-cdev.h b/include/uapi/linux/firewire-cdev.h index 7e5b5c10a49c..05e3aa8fa8bc 100644 --- a/include/uapi/linux/firewire-cdev.h +++ b/include/uapi/linux/firewire-cdev.h @@ -46,6 +46,12 @@  #define FW_CDEV_EVENT_PHY_PACKET_RECEIVED		0x08  #define FW_CDEV_EVENT_ISO_INTERRUPT_MULTICHANNEL	0x09 +/* available since kernel version 6.5 */ +#define FW_CDEV_EVENT_REQUEST3				0x0a +#define FW_CDEV_EVENT_RESPONSE2				0x0b +#define FW_CDEV_EVENT_PHY_PACKET_SENT2			0x0c +#define FW_CDEV_EVENT_PHY_PACKET_RECEIVED2		0x0d +  /**   * struct fw_cdev_event_common - Common part of all fw_cdev_event_* types   * @closure:	For arbitrary use by userspace @@ -103,6 +109,32 @@ struct fw_cdev_event_bus_reset {   * @length:	Data length, i.e. the response's payload size in bytes   * @data:	Payload data, if any   * + * This event is sent instead of &fw_cdev_event_response if the kernel or the client implements + * ABI version <= 5. It has the lack of time stamp field comparing to &fw_cdev_event_response2. + */ +struct fw_cdev_event_response { +	__u64 closure; +	__u32 type; +	__u32 rcode; +	__u32 length; +	__u32 data[]; +}; + +/** + * struct fw_cdev_event_response2 - Sent when a response packet was received + * @closure:	See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_REQUEST + *		or %FW_CDEV_IOC_SEND_BROADCAST_REQUEST + *		or %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl + * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE + * @rcode:	Response code returned by the remote node + * @length:	Data length, i.e. the response's payload size in bytes + * @request_tstamp:	The time stamp of isochronous cycle at which the request was sent. + * @response_tstamp:	The time stamp of isochronous cycle at which the response was sent. + * @padding:	Padding to keep the size of structure as multiples of 8 in various architectures + *		since 4 byte alignment is used for 8 byte of object type in System V ABI for i386 + *		architecture. + * @data:	Payload data, if any + *   * This event is sent when the stack receives a response to an outgoing request   * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl.  The payload data for responses   * carrying data (read and lock responses) follows immediately and can be @@ -112,13 +144,22 @@ struct fw_cdev_event_bus_reset {   * involve response packets.  This includes unified write transactions,   * broadcast write transactions, and transmission of asynchronous stream   * packets.  @rcode indicates success or failure of such transmissions. + * + * The value of @request_tstamp expresses the isochronous cycle at which the request was sent to + * initiate the transaction. The value of @response_tstamp expresses the isochronous cycle at which + * the response arrived to complete the transaction. Each value is unsigned 16 bit integer + * containing three low order bits of second field and all 13 bits of cycle field in format of + * CYCLE_TIMER register.   */ -struct fw_cdev_event_response { +struct fw_cdev_event_response2 {  	__u64 closure;  	__u32 type;  	__u32 rcode;  	__u32 length; -	__u32 data[0]; +	__u32 request_tstamp; +	__u32 response_tstamp; +	__u32 padding; +	__u32 data[];  };  /** @@ -142,7 +183,7 @@ struct fw_cdev_event_request {  	__u64 offset;  	__u32 handle;  	__u32 length; -	__u32 data[0]; +	__u32 data[];  };  /** @@ -159,6 +200,41 @@ struct fw_cdev_event_request {   * @length:	Data length, i.e. the request's payload size in bytes   * @data:	Incoming data, if any   * + * This event is sent instead of &fw_cdev_event_request3 if the kernel or the client implements + * ABI version <= 5. It has the lack of time stamp field comparing to &fw_cdev_event_request3. + */ +struct fw_cdev_event_request2 { +	__u64 closure; +	__u32 type; +	__u32 tcode; +	__u64 offset; +	__u32 source_node_id; +	__u32 destination_node_id; +	__u32 card; +	__u32 generation; +	__u32 handle; +	__u32 length; +	__u32 data[]; +}; + +/** + * struct fw_cdev_event_request3 - Sent on incoming request to an address region + * @closure:	See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl + * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST2 + * @tcode:	Transaction code of the incoming request + * @offset:	The offset into the 48-bit per-node address space + * @source_node_id: Sender node ID + * @destination_node_id: Destination node ID + * @card:	The index of the card from which the request came + * @generation:	Bus generation in which the request is valid + * @handle:	Reference to the kernel-side pending request + * @length:	Data length, i.e. the request's payload size in bytes + * @tstamp:	The time stamp of isochronous cycle at which the request arrived. + * @padding:	Padding to keep the size of structure as multiples of 8 in various architectures + *		since 4 byte alignment is used for 8 byte of object type in System V ABI for i386 + *		architecture. + * @data:	Incoming data, if any + *   * This event is sent when the stack receives an incoming request to an address   * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl.  The request is   * guaranteed to be completely contained in the specified region.  Userspace is @@ -191,10 +267,14 @@ struct fw_cdev_event_request {   * sent.   *   * If the client subsequently needs to initiate requests to the sender node of - * an &fw_cdev_event_request2, it needs to use a device file with matching + * an &fw_cdev_event_request3, it needs to use a device file with matching   * card index, node ID, and generation for outbound requests. + * + * @tstamp is isochronous cycle at which the request arrived. It is 16 bit integer value and the + * higher 3 bits expresses three low order bits of second field in the format of CYCLE_TIME + * register and the rest 13 bits expresses cycle field.   */ -struct fw_cdev_event_request2 { +struct fw_cdev_event_request3 {  	__u64 closure;  	__u32 type;  	__u32 tcode; @@ -205,7 +285,9 @@ struct fw_cdev_event_request2 {  	__u32 generation;  	__u32 handle;  	__u32 length; -	__u32 data[0]; +	__u32 tstamp; +	__u32 padding; +	__u32 data[];  };  /** @@ -265,7 +347,7 @@ struct fw_cdev_event_iso_interrupt {  	__u32 type;  	__u32 cycle;  	__u32 header_length; -	__u32 header[0]; +	__u32 header[];  };  /** @@ -341,21 +423,61 @@ struct fw_cdev_event_iso_resource {   * @type:	%FW_CDEV_EVENT_PHY_PACKET_SENT or %..._RECEIVED   * @rcode:	%RCODE_..., indicates success or failure of transmission   * @length:	Data length in bytes + * @data:	Incoming data for %FW_CDEV_IOC_RECEIVE_PHY_PACKETS. For %FW_CDEV_IOC_SEND_PHY_PACKET + *		the field has the same data in the request, thus the length of 8 bytes. + * + * This event is sent instead of &fw_cdev_event_phy_packet2 if the kernel or + * the client implements ABI version <= 5. It has the lack of time stamp field comparing to + * &fw_cdev_event_phy_packet2. + */ +struct fw_cdev_event_phy_packet { +	__u64 closure; +	__u32 type; +	__u32 rcode; +	__u32 length; +	__u32 data[]; +}; + +/** + * struct fw_cdev_event_phy_packet2 - A PHY packet was transmitted or received with time stamp. + * @closure:	See &fw_cdev_event_common; set by %FW_CDEV_IOC_SEND_PHY_PACKET + *		or %FW_CDEV_IOC_RECEIVE_PHY_PACKETS ioctl + * @type:	%FW_CDEV_EVENT_PHY_PACKET_SENT2 or %FW_CDEV_EVENT_PHY_PACKET_RECEIVED2 + * @rcode:	%RCODE_..., indicates success or failure of transmission + * @length:	Data length in bytes + * @tstamp:	For %FW_CDEV_EVENT_PHY_PACKET_RECEIVED2, the time stamp of isochronous cycle at + *		which the packet arrived. For %FW_CDEV_EVENT_PHY_PACKET_SENT2 and non-ping packet, + *		the time stamp of isochronous cycle at which the packet was sent. For ping packet, + *		the tick count for round-trip time measured by 1394 OHCI controller. + * + *		The time stamp of isochronous cycle at which either the response was sent for + *		%FW_CDEV_EVENT_PHY_PACKET_SENT2 or the request arrived for + *		%FW_CDEV_EVENT_PHY_PACKET_RECEIVED2.   * @data:	Incoming data   * - * If @type is %FW_CDEV_EVENT_PHY_PACKET_SENT, @length is 0 and @data empty, - * except in case of a ping packet:  Then, @length is 4, and @data[0] is the - * ping time in 49.152MHz clocks if @rcode is %RCODE_COMPLETE. + * If @type is %FW_CDEV_EVENT_PHY_PACKET_SENT2, @length is 8 and @data consists of the two PHY + * packet quadlets to be sent, in host byte order,   * - * If @type is %FW_CDEV_EVENT_PHY_PACKET_RECEIVED, @length is 8 and @data - * consists of the two PHY packet quadlets, in host byte order. + * If @type is %FW_CDEV_EVENT_PHY_PACKET_RECEIVED2, @length is 8 and @data consists of the two PHY + * packet quadlets, in host byte order. + * + * For %FW_CDEV_EVENT_PHY_PACKET_RECEIVED2, the @tstamp is the isochronous cycle at which the + * packet arrived. It is 16 bit integer value and the higher 3 bits expresses three low order bits + * of second field and the rest 13 bits expresses cycle field in the format of CYCLE_TIME register. + * + * For %FW_CDEV_EVENT_PHY_PACKET_SENT2, the @tstamp has different meanings whether to sent the + * packet for ping or not. If it's not for ping, the @tstamp is the isochronous cycle at which the + * packet was sent, and use the same format as the case of %FW_CDEV_EVENT_PHY_PACKET_SENT2. If it's + * for ping, the @tstamp is for round-trip time measured by 1394 OHCI controller with 42.195 MHz + * resolution.   */ -struct fw_cdev_event_phy_packet { +struct fw_cdev_event_phy_packet2 {  	__u64 closure;  	__u32 type;  	__u32 rcode;  	__u32 length; -	__u32 data[0]; +	__u32 tstamp; +	__u32 data[];  };  /** @@ -375,6 +497,11 @@ struct fw_cdev_event_phy_packet {   *				%FW_CDEV_EVENT_PHY_PACKET_SENT or   *				%FW_CDEV_EVENT_PHY_PACKET_RECEIVED   * + * @request3:		Valid if @common.type == %FW_CDEV_EVENT_REQUEST3 + * @response2:		Valid if @common.type == %FW_CDEV_EVENT_RESPONSE2 + * @phy_packet2:	Valid if @common.type == %FW_CDEV_EVENT_PHY_PACKET_SENT2 or + *				%FW_CDEV_EVENT_PHY_PACKET_RECEIVED2 + *   * Convenience union for userspace use.  Events could be read(2) into an   * appropriately aligned char buffer and then cast to this union for further   * processing.  Note that for a request, response or iso_interrupt event, @@ -393,6 +520,9 @@ union fw_cdev_event {  	struct fw_cdev_event_iso_interrupt_mc	iso_interrupt_mc;	/* added in 2.6.36 */  	struct fw_cdev_event_iso_resource	iso_resource;		/* added in 2.6.30 */  	struct fw_cdev_event_phy_packet		phy_packet;		/* added in 2.6.36 */ +	struct fw_cdev_event_request3		request3;		/* added in 6.5 */ +	struct fw_cdev_event_response2		response2;		/* added in 6.5 */ +	struct fw_cdev_event_phy_packet2	phy_packet2;		/* added in 6.5 */  };  /* available since kernel version 2.6.22 */ @@ -457,6 +587,11 @@ union fw_cdev_event {   *  5  (3.4)     - send %FW_CDEV_EVENT_ISO_INTERRUPT events when needed to   *                 avoid dropping data   *               - added %FW_CDEV_IOC_FLUSH_ISO + *  6  (6.5)     - added some event for subactions of asynchronous transaction with time stamp + *                   - %FW_CDEV_EVENT_REQUEST3 + *                   - %FW_CDEV_EVENT_RESPONSE2 + *                   - %FW_CDEV_EVENT_PHY_PACKET_SENT2 + *                   - %FW_CDEV_EVENT_PHY_PACKET_RECEIVED2   */  /** @@ -502,11 +637,11 @@ struct fw_cdev_get_info {   * @data:	Userspace pointer to payload   * @generation:	The bus generation where packet is valid   * - * Send a request to the device.  This ioctl implements all outgoing requests. - * Both quadlet and block request specify the payload as a pointer to the data - * in the @data field.  Once the transaction completes, the kernel writes an - * &fw_cdev_event_response event back.  The @closure field is passed back to - * user space in the response event. + * Send a request to the device.  This ioctl implements all outgoing requests. Both quadlet and + * block request specify the payload as a pointer to the data in the @data field. Once the + * transaction completes, the kernel writes either &fw_cdev_event_response event or + * &fw_cdev_event_response event back. The @closure field is passed back to user space in the + * response event.   */  struct fw_cdev_send_request {  	__u32 tcode; @@ -803,7 +938,7 @@ struct fw_cdev_set_iso_channels {   */  struct fw_cdev_iso_packet {  	__u32 control; -	__u32 header[0]; +	__u32 header[];  };  /** @@ -844,7 +979,7 @@ struct fw_cdev_queue_iso {   * struct fw_cdev_start_iso - Start an isochronous transmission or reception   * @cycle:	Cycle in which to start I/O.  If @cycle is greater than or   *		equal to 0, the I/O will start on that cycle. - * @sync:	Determines the value to wait for for receive packets that have + * @sync:	Determines the value to wait for receive packets that have   *		the %FW_CDEV_ISO_SYNC bit set   * @tags:	Tag filter bit mask.  Only valid for isochronous reception.   *		Determines the tag values for which packets will be accepted. @@ -989,10 +1124,9 @@ struct fw_cdev_allocate_iso_resource {   * @generation:	The bus generation where packet is valid   * @speed:	Speed to transmit at   * - * The %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl sends an asynchronous stream packet - * to every device which is listening to the specified channel.  The kernel - * writes an &fw_cdev_event_response event which indicates success or failure of - * the transmission. + * The %FW_CDEV_IOC_SEND_STREAM_PACKET ioctl sends an asynchronous stream packet to every device + * which is listening to the specified channel. The kernel writes either &fw_cdev_event_response + * event or &fw_cdev_event_response2 event which indicates success or failure of the transmission.   */  struct fw_cdev_send_stream_packet {  	__u32 length; @@ -1011,8 +1145,8 @@ struct fw_cdev_send_stream_packet {   * @data:	First and second quadlet of the PHY packet   * @generation:	The bus generation where packet is valid   * - * The %FW_CDEV_IOC_SEND_PHY_PACKET ioctl sends a PHY packet to all nodes - * on the same card as this device.  After transmission, an + * The %FW_CDEV_IOC_SEND_PHY_PACKET ioctl sends a PHY packet to all nodes on the same card as this + * device.  After transmission, either %FW_CDEV_EVENT_PHY_PACKET_SENT event or   * %FW_CDEV_EVENT_PHY_PACKET_SENT event is generated.   *   * The payload @data\[\] shall be specified in host byte order.  Usually, @@ -1031,8 +1165,9 @@ struct fw_cdev_send_phy_packet {   * struct fw_cdev_receive_phy_packets - start reception of PHY packets   * @closure: Passed back to userspace in phy packet events   * - * This ioctl activates issuing of %FW_CDEV_EVENT_PHY_PACKET_RECEIVED due to - * incoming PHY packets from any node on the same bus as the device. + * This ioctl activates issuing of either %FW_CDEV_EVENT_PHY_PACKET_RECEIVED or + * %FW_CDEV_EVENT_PHY_PACKET_RECEIVED2 due to incoming PHY packets from any node on the same bus + * as the device.   *   * The ioctl is only permitted on device files which represent a local node.   */ diff --git a/include/uapi/linux/fou.h b/include/uapi/linux/fou.h index 87c2c9f08803..b5cd3e7b3775 100644 --- a/include/uapi/linux/fou.h +++ b/include/uapi/linux/fou.h @@ -1,32 +1,37 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* fou.h - FOU Interface */ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/fou.yaml */ +/* YNL-GEN uapi header */  #ifndef _UAPI_LINUX_FOU_H  #define _UAPI_LINUX_FOU_H -/* NETLINK_GENERIC related info - */  #define FOU_GENL_NAME		"fou" -#define FOU_GENL_VERSION	0x1 +#define FOU_GENL_VERSION	1  enum { -	FOU_ATTR_UNSPEC, -	FOU_ATTR_PORT,				/* u16 */ -	FOU_ATTR_AF,				/* u8 */ -	FOU_ATTR_IPPROTO,			/* u8 */ -	FOU_ATTR_TYPE,				/* u8 */ -	FOU_ATTR_REMCSUM_NOPARTIAL,		/* flag */ -	FOU_ATTR_LOCAL_V4,			/* u32 */ -	FOU_ATTR_LOCAL_V6,			/* in6_addr */ -	FOU_ATTR_PEER_V4,			/* u32 */ -	FOU_ATTR_PEER_V6,			/* in6_addr */ -	FOU_ATTR_PEER_PORT,			/* u16 */ -	FOU_ATTR_IFINDEX,			/* s32 */ - -	__FOU_ATTR_MAX, +	FOU_ENCAP_UNSPEC, +	FOU_ENCAP_DIRECT, +	FOU_ENCAP_GUE,  }; -#define FOU_ATTR_MAX		(__FOU_ATTR_MAX - 1) +enum { +	FOU_ATTR_UNSPEC, +	FOU_ATTR_PORT, +	FOU_ATTR_AF, +	FOU_ATTR_IPPROTO, +	FOU_ATTR_TYPE, +	FOU_ATTR_REMCSUM_NOPARTIAL, +	FOU_ATTR_LOCAL_V4, +	FOU_ATTR_LOCAL_V6, +	FOU_ATTR_PEER_V4, +	FOU_ATTR_PEER_V6, +	FOU_ATTR_PEER_PORT, +	FOU_ATTR_IFINDEX, + +	__FOU_ATTR_MAX +}; +#define FOU_ATTR_MAX (__FOU_ATTR_MAX - 1)  enum {  	FOU_CMD_UNSPEC, @@ -34,15 +39,8 @@ enum {  	FOU_CMD_DEL,  	FOU_CMD_GET, -	__FOU_CMD_MAX, +	__FOU_CMD_MAX  }; - -enum { -	FOU_ENCAP_UNSPEC, -	FOU_ENCAP_DIRECT, -	FOU_ENCAP_GUE, -}; - -#define FOU_CMD_MAX	(__FOU_CMD_MAX - 1) +#define FOU_CMD_MAX (__FOU_CMD_MAX - 1)  #endif /* _UAPI_LINUX_FOU_H */ diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index f44eb0a04afd..0bd678a4a10e 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -40,6 +40,15 @@  #define BLOCK_SIZE_BITS 10  #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS) +/* flags for integrity meta */ +#define IO_INTEGRITY_CHK_GUARD		(1U << 0) /* enforce guard check */ +#define IO_INTEGRITY_CHK_REFTAG		(1U << 1) /* enforce ref check */ +#define IO_INTEGRITY_CHK_APPTAG		(1U << 2) /* enforce app check */ + +#define IO_INTEGRITY_VALID_FLAGS (IO_INTEGRITY_CHK_GUARD | \ +				  IO_INTEGRITY_CHK_REFTAG | \ +				  IO_INTEGRITY_CHK_APPTAG) +  #define SEEK_SET	0	/* seek relative to beginning of file */  #define SEEK_CUR	1	/* seek relative to current file position */  #define SEEK_END	2	/* seek relative to end of file */ @@ -51,6 +60,17 @@  #define RENAME_EXCHANGE		(1 << 1)	/* Exchange source and dest */  #define RENAME_WHITEOUT		(1 << 2)	/* Whiteout source */ +/* + * The root inode of procfs is guaranteed to always have the same inode number. + * For programs that make heavy use of procfs, verifying that the root is a + * real procfs root and using openat2(RESOLVE_{NO_{XDEV,MAGICLINKS},BENEATH}) + * will allow you to make sure you are never tricked into operating on the + * wrong procfs file. + */ +enum procfs_ino { +	PROCFS_ROOT_INO = 1, +}; +  struct file_clone_range {  	__s64 src_fd;  	__u64 src_offset; @@ -64,6 +84,81 @@ struct fstrim_range {  	__u64 minlen;  }; +/* + * We include a length field because some filesystems (vfat) have an identifier + * that we do want to expose as a UUID, but doesn't have the standard length. + * + * We use a fixed size buffer beacuse this interface will, by fiat, never + * support "UUIDs" longer than 16 bytes; we don't want to force all downstream + * users to have to deal with that. + */ +struct fsuuid2 { +	__u8	len; +	__u8	uuid[16]; +}; + +struct fs_sysfs_path { +	__u8			len; +	__u8			name[128]; +}; + +/* Protection info capability flags */ +#define	LBMD_PI_CAP_INTEGRITY		(1 << 0) +#define	LBMD_PI_CAP_REFTAG		(1 << 1) + +/* Checksum types for Protection Information */ +#define LBMD_PI_CSUM_NONE		0 +#define LBMD_PI_CSUM_IP			1 +#define LBMD_PI_CSUM_CRC16_T10DIF	2 +#define LBMD_PI_CSUM_CRC64_NVME		4 + +/* sizeof first published struct */ +#define LBMD_SIZE_VER0			16 + +/* + * Logical block metadata capability descriptor + * If the device does not support metadata, all the fields will be zero. + * Applications must check lbmd_flags to determine whether metadata is + * supported or not. + */ +struct logical_block_metadata_cap { +	/* Bitmask of logical block metadata capability flags */ +	__u32	lbmd_flags; +	/* +	 * The amount of data described by each unit of logical block +	 * metadata +	 */ +	__u16	lbmd_interval; +	/* +	 * Size in bytes of the logical block metadata associated with each +	 * interval +	 */ +	__u8	lbmd_size; +	/* +	 * Size in bytes of the opaque block tag associated with each +	 * interval +	 */ +	__u8	lbmd_opaque_size; +	/* +	 * Offset in bytes of the opaque block tag within the logical block +	 * metadata +	 */ +	__u8	lbmd_opaque_offset; +	/* Size in bytes of the T10 PI tuple associated with each interval */ +	__u8	lbmd_pi_size; +	/* Offset in bytes of T10 PI tuple within the logical block metadata */ +	__u8	lbmd_pi_offset; +	/* T10 PI guard tag type */ +	__u8	lbmd_guard_tag_type; +	/* Size in bytes of the T10 PI application tag */ +	__u8	lbmd_app_tag_size; +	/* Size in bytes of the T10 PI reference tag */ +	__u8	lbmd_ref_tag_size; +	/* Size in bytes of the T10 PI storage tag */ +	__u8	lbmd_storage_tag_size; +	__u8	pad; +}; +  /* extent-same (dedupe) ioctls; these MUST match the btrfs ioctl definitions */  #define FILE_DEDUPE_RANGE_SAME		0  #define FILE_DEDUPE_RANGE_DIFFERS	1 @@ -90,7 +185,7 @@ struct file_dedupe_range {  	__u16 dest_count;	/* in - total elements in info array */  	__u16 reserved1;	/* must be zero */  	__u32 reserved2;	/* must be zero */ -	struct file_dedupe_range_info info[0]; +	struct file_dedupe_range_info info[];  };  /* And dynamically-tunable limits and defaults: */ @@ -122,6 +217,24 @@ struct fsxattr {  };  /* + * Variable size structure for file_[sg]et_attr(). + * + * Note. This is alternative to the structure 'struct file_kattr'/'struct fsxattr'. + * As this structure is passed to/from userspace with its size, this can + * be versioned based on the size. + */ +struct file_attr { +	__u64 fa_xflags;	/* xflags field value (get/set) */ +	__u32 fa_extsize;	/* extsize field value (get/set)*/ +	__u32 fa_nextents;	/* nextents field value (get)   */ +	__u32 fa_projid;	/* project identifier (get/set) */ +	__u32 fa_cowextsize;	/* CoW extsize field value (get/set) */ +}; + +#define FILE_ATTR_SIZE_VER0 24 +#define FILE_ATTR_SIZE_LATEST FILE_ATTR_SIZE_VER0 + +/*   * Flags for the fsx_xflags field   */  #define FS_XFLAG_REALTIME	0x00000001	/* data in realtime volume */ @@ -184,10 +297,9 @@ struct fsxattr {  #define BLKSECDISCARD _IO(0x12,125)  #define BLKROTATIONAL _IO(0x12,126)  #define BLKZEROOUT _IO(0x12,127) -/* - * A jump here: 130-131 are reserved for zoned block devices - * (see uapi/linux/blkzoned.h) - */ +#define BLKGETDISKSEQ _IOR(0x12,128,__u64) +/* 130-136 are used by zoned block device ioctls (uapi/linux/blkzoned.h) */ +/* 137-141 are used by blk-crypto ioctls (uapi/linux/blk-crypto.h) */  #define BMAP_IOCTL 1		/* obsolete - kept for compatibility */  #define FIBMAP	   _IO(0x00,1)	/* bmap access */ @@ -214,6 +326,15 @@ struct fsxattr {  #define FS_IOC_FSSETXATTR		_IOW('X', 32, struct fsxattr)  #define FS_IOC_GETFSLABEL		_IOR(0x94, 49, char[FSLABEL_MAX])  #define FS_IOC_SETFSLABEL		_IOW(0x94, 50, char[FSLABEL_MAX]) +/* Returns the external filesystem UUID, the same one blkid returns */ +#define FS_IOC_GETFSUUID		_IOR(0x15, 0, struct fsuuid2) +/* + * Returns the path component under /sys/fs/ that refers to this filesystem; + * also /sys/kernel/debug/ for filesystems with debugfs exports + */ +#define FS_IOC_GETFSSYSFSPATH		_IOR(0x15, 1, struct fs_sysfs_path) +/* Get logical block metadata capability details */ +#define FS_IOC_GETLBMD_CAP		_IOWR(0x15, 2, struct logical_block_metadata_cap)  /*   * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS) @@ -300,8 +421,235 @@ typedef int __bitwise __kernel_rwf_t;  /* per-IO O_APPEND */  #define RWF_APPEND	((__force __kernel_rwf_t)0x00000010) +/* per-IO negation of O_APPEND */ +#define RWF_NOAPPEND	((__force __kernel_rwf_t)0x00000020) + +/* Atomic Write */ +#define RWF_ATOMIC	((__force __kernel_rwf_t)0x00000040) + +/* buffered IO that drops the cache after reading or writing data */ +#define RWF_DONTCACHE	((__force __kernel_rwf_t)0x00000080) +  /* mask of flags supported by the kernel */  #define RWF_SUPPORTED	(RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\ -			 RWF_APPEND) +			 RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC |\ +			 RWF_DONTCACHE) + +#define PROCFS_IOCTL_MAGIC 'f' + +/* Pagemap ioctl */ +#define PAGEMAP_SCAN	_IOWR(PROCFS_IOCTL_MAGIC, 16, struct pm_scan_arg) + +/* Bitmasks provided in pm_scan_args masks and reported in page_region.categories. */ +#define PAGE_IS_WPALLOWED	(1 << 0) +#define PAGE_IS_WRITTEN		(1 << 1) +#define PAGE_IS_FILE		(1 << 2) +#define PAGE_IS_PRESENT		(1 << 3) +#define PAGE_IS_SWAPPED		(1 << 4) +#define PAGE_IS_PFNZERO		(1 << 5) +#define PAGE_IS_HUGE		(1 << 6) +#define PAGE_IS_SOFT_DIRTY	(1 << 7) +#define PAGE_IS_GUARD		(1 << 8) + +/* + * struct page_region - Page region with flags + * @start:	Start of the region + * @end:	End of the region (exclusive) + * @categories:	PAGE_IS_* category bitmask for the region + */ +struct page_region { +	__u64 start; +	__u64 end; +	__u64 categories; +}; + +/* Flags for PAGEMAP_SCAN ioctl */ +#define PM_SCAN_WP_MATCHING	(1 << 0)	/* Write protect the pages matched. */ +#define PM_SCAN_CHECK_WPASYNC	(1 << 1)	/* Abort the scan when a non-WP-enabled page is found. */ + +/* + * struct pm_scan_arg - Pagemap ioctl argument + * @size:		Size of the structure + * @flags:		Flags for the IOCTL + * @start:		Starting address of the region + * @end:		Ending address of the region + * @walk_end		Address where the scan stopped (written by kernel). + *			walk_end == end (address tags cleared) informs that the scan completed on entire range. + * @vec:		Address of page_region struct array for output + * @vec_len:		Length of the page_region struct array + * @max_pages:		Optional limit for number of returned pages (0 = disabled) + * @category_inverted:	PAGE_IS_* categories which values match if 0 instead of 1 + * @category_mask:	Skip pages for which any category doesn't match + * @category_anyof_mask: Skip pages for which no category matches + * @return_mask:	PAGE_IS_* categories that are to be reported in `page_region`s returned + */ +struct pm_scan_arg { +	__u64 size; +	__u64 flags; +	__u64 start; +	__u64 end; +	__u64 walk_end; +	__u64 vec; +	__u64 vec_len; +	__u64 max_pages; +	__u64 category_inverted; +	__u64 category_mask; +	__u64 category_anyof_mask; +	__u64 return_mask; +}; + +/* /proc/<pid>/maps ioctl */ +#define PROCMAP_QUERY	_IOWR(PROCFS_IOCTL_MAGIC, 17, struct procmap_query) + +enum procmap_query_flags { +	/* +	 * VMA permission flags. +	 * +	 * Can be used as part of procmap_query.query_flags field to look up +	 * only VMAs satisfying specified subset of permissions. E.g., specifying +	 * PROCMAP_QUERY_VMA_READABLE only will return both readable and read/write VMAs, +	 * while having PROCMAP_QUERY_VMA_READABLE | PROCMAP_QUERY_VMA_WRITABLE will only +	 * return read/write VMAs, though both executable/non-executable and +	 * private/shared will be ignored. +	 * +	 * PROCMAP_QUERY_VMA_* flags are also returned in procmap_query.vma_flags +	 * field to specify actual VMA permissions. +	 */ +	PROCMAP_QUERY_VMA_READABLE		= 0x01, +	PROCMAP_QUERY_VMA_WRITABLE		= 0x02, +	PROCMAP_QUERY_VMA_EXECUTABLE		= 0x04, +	PROCMAP_QUERY_VMA_SHARED		= 0x08, +	/* +	 * Query modifier flags. +	 * +	 * By default VMA that covers provided address is returned, or -ENOENT +	 * is returned. With PROCMAP_QUERY_COVERING_OR_NEXT_VMA flag set, closest +	 * VMA with vma_start > addr will be returned if no covering VMA is +	 * found. +	 * +	 * PROCMAP_QUERY_FILE_BACKED_VMA instructs query to consider only VMAs that +	 * have file backing. Can be combined with PROCMAP_QUERY_COVERING_OR_NEXT_VMA +	 * to iterate all VMAs with file backing. +	 */ +	PROCMAP_QUERY_COVERING_OR_NEXT_VMA	= 0x10, +	PROCMAP_QUERY_FILE_BACKED_VMA		= 0x20, +}; + +/* + * Input/output argument structured passed into ioctl() call. It can be used + * to query a set of VMAs (Virtual Memory Areas) of a process. + * + * Each field can be one of three kinds, marked in a short comment to the + * right of the field: + *   - "in", input argument, user has to provide this value, kernel doesn't modify it; + *   - "out", output argument, kernel sets this field with VMA data; + *   - "in/out", input and output argument; user provides initial value (used + *     to specify maximum allowable buffer size), and kernel sets it to actual + *     amount of data written (or zero, if there is no data). + * + * If matching VMA is found (according to criterias specified by + * query_addr/query_flags, all the out fields are filled out, and ioctl() + * returns 0. If there is no matching VMA, -ENOENT will be returned. + * In case of any other error, negative error code other than -ENOENT is + * returned. + * + * Most of the data is similar to the one returned as text in /proc/<pid>/maps + * file, but procmap_query provides more querying flexibility. There are no + * consistency guarantees between subsequent ioctl() calls, but data returned + * for matched VMA is self-consistent. + */ +struct procmap_query { +	/* Query struct size, for backwards/forward compatibility */ +	__u64 size; +	/* +	 * Query flags, a combination of enum procmap_query_flags values. +	 * Defines query filtering and behavior, see enum procmap_query_flags. +	 * +	 * Input argument, provided by user. Kernel doesn't modify it. +	 */ +	__u64 query_flags;		/* in */ +	/* +	 * Query address. By default, VMA that covers this address will +	 * be looked up. PROCMAP_QUERY_* flags above modify this default +	 * behavior further. +	 * +	 * Input argument, provided by user. Kernel doesn't modify it. +	 */ +	__u64 query_addr;		/* in */ +	/* VMA starting (inclusive) and ending (exclusive) address, if VMA is found. */ +	__u64 vma_start;		/* out */ +	__u64 vma_end;			/* out */ +	/* VMA permissions flags. A combination of PROCMAP_QUERY_VMA_* flags. */ +	__u64 vma_flags;		/* out */ +	/* VMA backing page size granularity. */ +	__u64 vma_page_size;		/* out */ +	/* +	 * VMA file offset. If VMA has file backing, this specifies offset +	 * within the file that VMA's start address corresponds to. +	 * Is set to zero if VMA has no backing file. +	 */ +	__u64 vma_offset;		/* out */ +	/* Backing file's inode number, or zero, if VMA has no backing file. */ +	__u64 inode;			/* out */ +	/* Backing file's device major/minor number, or zero, if VMA has no backing file. */ +	__u32 dev_major;		/* out */ +	__u32 dev_minor;		/* out */ +	/* +	 * If set to non-zero value, signals the request to return VMA name +	 * (i.e., VMA's backing file's absolute path, with " (deleted)" suffix +	 * appended, if file was unlinked from FS) for matched VMA. VMA name +	 * can also be some special name (e.g., "[heap]", "[stack]") or could +	 * be even user-supplied with prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME). +	 * +	 * Kernel will set this field to zero, if VMA has no associated name. +	 * Otherwise kernel will return actual amount of bytes filled in +	 * user-supplied buffer (see vma_name_addr field below), including the +	 * terminating zero. +	 * +	 * If VMA name is longer that user-supplied maximum buffer size, +	 * -E2BIG error is returned. +	 * +	 * If this field is set to non-zero value, vma_name_addr should point +	 * to valid user space memory buffer of at least vma_name_size bytes. +	 * If set to zero, vma_name_addr should be set to zero as well +	 */ +	__u32 vma_name_size;		/* in/out */ +	/* +	 * If set to non-zero value, signals the request to extract and return +	 * VMA's backing file's build ID, if the backing file is an ELF file +	 * and it contains embedded build ID. +	 * +	 * Kernel will set this field to zero, if VMA has no backing file, +	 * backing file is not an ELF file, or ELF file has no build ID +	 * embedded. +	 * +	 * Build ID is a binary value (not a string). Kernel will set +	 * build_id_size field to exact number of bytes used for build ID. +	 * If build ID is requested and present, but needs more bytes than +	 * user-supplied maximum buffer size (see build_id_addr field below), +	 * -E2BIG error will be returned. +	 * +	 * If this field is set to non-zero value, build_id_addr should point +	 * to valid user space memory buffer of at least build_id_size bytes. +	 * If set to zero, build_id_addr should be set to zero as well +	 */ +	__u32 build_id_size;		/* in/out */ +	/* +	 * User-supplied address of a buffer of at least vma_name_size bytes +	 * for kernel to fill with matched VMA's name (see vma_name_size field +	 * description above for details). +	 * +	 * Should be set to zero if VMA name should not be returned. +	 */ +	__u64 vma_name_addr;		/* in */ +	/* +	 * User-supplied address of a buffer of at least build_id_size bytes +	 * for kernel to fill with matched VMA's ELF build ID, if available +	 * (see build_id_size field description above for details). +	 * +	 * Should be set to zero if build ID should not be returned. +	 */ +	__u64 build_id_addr;		/* in */ +};  #endif /* _UAPI_LINUX_FS_H */ diff --git a/include/uapi/linux/fscrypt.h b/include/uapi/linux/fscrypt.h index 7875709ccfeb..3aff99f2696a 100644 --- a/include/uapi/linux/fscrypt.h +++ b/include/uapi/linux/fscrypt.h @@ -20,15 +20,17 @@  #define FSCRYPT_POLICY_FLAG_DIRECT_KEY		0x04  #define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64	0x08  #define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32	0x10 -#define FSCRYPT_POLICY_FLAGS_VALID		0x1F  /* Encryption algorithms */  #define FSCRYPT_MODE_AES_256_XTS		1  #define FSCRYPT_MODE_AES_256_CTS		4  #define FSCRYPT_MODE_AES_128_CBC		5  #define FSCRYPT_MODE_AES_128_CTS		6 +#define FSCRYPT_MODE_SM4_XTS			7 +#define FSCRYPT_MODE_SM4_CTS			8  #define FSCRYPT_MODE_ADIANTUM			9 -#define __FSCRYPT_MODE_MAX			9 +#define FSCRYPT_MODE_AES_256_HCTR2		10 +/* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */  /*   * Legacy policy version; ad-hoc KDF and no key verification. @@ -45,7 +47,6 @@ struct fscrypt_policy_v1 {  	__u8 flags;  	__u8 master_key_descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE];  }; -#define fscrypt_policy	fscrypt_policy_v1  /*   * Process-subscribed "logon" key description prefix and payload format. @@ -70,7 +71,8 @@ struct fscrypt_policy_v2 {  	__u8 contents_encryption_mode;  	__u8 filenames_encryption_mode;  	__u8 flags; -	__u8 __reserved[4]; +	__u8 log2_data_unit_size; +	__u8 __reserved[3];  	__u8 master_key_identifier[FSCRYPT_KEY_IDENTIFIER_SIZE];  }; @@ -117,7 +119,7 @@ struct fscrypt_key_specifier {   */  struct fscrypt_provisioning_key_payload {  	__u32 type; -	__u32 __reserved; +	__u32 flags;  	__u8 raw[];  }; @@ -126,7 +128,9 @@ struct fscrypt_add_key_arg {  	struct fscrypt_key_specifier key_spec;  	__u32 raw_size;  	__u32 key_id; -	__u32 __reserved[8]; +#define FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED	0x00000001 +	__u32 flags; +	__u32 __reserved[7];  	__u8 raw[];  }; @@ -156,9 +160,9 @@ struct fscrypt_get_key_status_arg {  	__u32 __out_reserved[13];  }; -#define FS_IOC_SET_ENCRYPTION_POLICY		_IOR('f', 19, struct fscrypt_policy) +#define FS_IOC_SET_ENCRYPTION_POLICY		_IOR('f', 19, struct fscrypt_policy_v1)  #define FS_IOC_GET_ENCRYPTION_PWSALT		_IOW('f', 20, __u8[16]) -#define FS_IOC_GET_ENCRYPTION_POLICY		_IOW('f', 21, struct fscrypt_policy) +#define FS_IOC_GET_ENCRYPTION_POLICY		_IOW('f', 21, struct fscrypt_policy_v1)  #define FS_IOC_GET_ENCRYPTION_POLICY_EX		_IOWR('f', 22, __u8[9]) /* size + version */  #define FS_IOC_ADD_ENCRYPTION_KEY		_IOWR('f', 23, struct fscrypt_add_key_arg)  #define FS_IOC_REMOVE_ENCRYPTION_KEY		_IOWR('f', 24, struct fscrypt_remove_key_arg) @@ -170,6 +174,7 @@ struct fscrypt_get_key_status_arg {  /* old names; don't add anything new here! */  #ifndef __KERNEL__ +#define fscrypt_policy			fscrypt_policy_v1  #define FS_KEY_DESCRIPTOR_SIZE		FSCRYPT_KEY_DESCRIPTOR_SIZE  #define FS_POLICY_FLAGS_PAD_4		FSCRYPT_POLICY_FLAGS_PAD_4  #define FS_POLICY_FLAGS_PAD_8		FSCRYPT_POLICY_FLAGS_PAD_8 @@ -177,7 +182,7 @@ struct fscrypt_get_key_status_arg {  #define FS_POLICY_FLAGS_PAD_32		FSCRYPT_POLICY_FLAGS_PAD_32  #define FS_POLICY_FLAGS_PAD_MASK	FSCRYPT_POLICY_FLAGS_PAD_MASK  #define FS_POLICY_FLAG_DIRECT_KEY	FSCRYPT_POLICY_FLAG_DIRECT_KEY -#define FS_POLICY_FLAGS_VALID		FSCRYPT_POLICY_FLAGS_VALID +#define FS_POLICY_FLAGS_VALID		0x07	/* contains old flags only */  #define FS_ENCRYPTION_MODE_INVALID	0	/* never used */  #define FS_ENCRYPTION_MODE_AES_256_XTS	FSCRYPT_MODE_AES_256_XTS  #define FS_ENCRYPTION_MODE_AES_256_GCM	2	/* never used */ @@ -185,8 +190,6 @@ struct fscrypt_get_key_status_arg {  #define FS_ENCRYPTION_MODE_AES_256_CTS	FSCRYPT_MODE_AES_256_CTS  #define FS_ENCRYPTION_MODE_AES_128_CBC	FSCRYPT_MODE_AES_128_CBC  #define FS_ENCRYPTION_MODE_AES_128_CTS	FSCRYPT_MODE_AES_128_CTS -#define FS_ENCRYPTION_MODE_SPECK128_256_XTS	7	/* removed */ -#define FS_ENCRYPTION_MODE_SPECK128_256_CTS	8	/* removed */  #define FS_ENCRYPTION_MODE_ADIANTUM	FSCRYPT_MODE_ADIANTUM  #define FS_KEY_DESC_PREFIX		FSCRYPT_KEY_DESC_PREFIX  #define FS_KEY_DESC_PREFIX_SIZE		FSCRYPT_KEY_DESC_PREFIX_SIZE diff --git a/include/uapi/linux/fsi.h b/include/uapi/linux/fsi.h index da577ecd90e7..a2e730fc6309 100644 --- a/include/uapi/linux/fsi.h +++ b/include/uapi/linux/fsi.h @@ -55,4 +55,28 @@ struct scom_access {  #define FSI_SCOM_WRITE	_IOWR('s', 0x02, struct scom_access)  #define FSI_SCOM_RESET	_IOW('s', 0x03, __u32) +/* + * /dev/sbefifo* ioctl interface + */ + +/** + * FSI_SBEFIFO_CMD_TIMEOUT sets the timeout for writing data to the SBEFIFO. + * + * The command timeout is specified in seconds.  The minimum value of command + * timeout is 1 seconds (default) and the maximum value of command timeout is + * 120 seconds.  A command timeout of 0 will reset the value to the default of + * 1 seconds. + */ +#define FSI_SBEFIFO_CMD_TIMEOUT_SECONDS		_IOW('s', 0x01, __u32) + +/** + * FSI_SBEFIFO_READ_TIMEOUT sets the read timeout for response from SBE. + * + * The read timeout is specified in seconds.  The minimum value of read + * timeout is 10 seconds (default) and the maximum value of read timeout is + * 120 seconds.  A read timeout of 0 will reset the value to the default of + * (10 seconds). + */ +#define FSI_SBEFIFO_READ_TIMEOUT_SECONDS	_IOW('s', 0x00, __u32) +  #endif /* _UAPI_LINUX_FSI_H */ diff --git a/include/uapi/linux/fsl_mc.h b/include/uapi/linux/fsl_mc.h new file mode 100644 index 000000000000..e57451570033 --- /dev/null +++ b/include/uapi/linux/fsl_mc.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Management Complex (MC) userspace public interface + * + * Copyright 2021 NXP + * + */ +#ifndef _UAPI_FSL_MC_H_ +#define _UAPI_FSL_MC_H_ + +#include <linux/types.h> + +#define MC_CMD_NUM_OF_PARAMS	7 + +/** + * struct fsl_mc_command - Management Complex (MC) command structure + * @header: MC command header + * @params: MC command parameters + * + * Used by FSL_MC_SEND_MC_COMMAND + */ +struct fsl_mc_command { +	__le64 header; +	__le64 params[MC_CMD_NUM_OF_PARAMS]; +}; + +#define FSL_MC_SEND_CMD_IOCTL_TYPE	'R' +#define FSL_MC_SEND_CMD_IOCTL_SEQ	0xE0 + +#define FSL_MC_SEND_MC_COMMAND \ +	_IOWR(FSL_MC_SEND_CMD_IOCTL_TYPE, FSL_MC_SEND_CMD_IOCTL_SEQ, \ +	struct fsl_mc_command) + +#endif /* _UAPI_FSL_MC_H_ */ diff --git a/include/uapi/linux/fsmap.h b/include/uapi/linux/fsmap.h index 91fd519a3f7d..c690d17f1d07 100644 --- a/include/uapi/linux/fsmap.h +++ b/include/uapi/linux/fsmap.h @@ -69,7 +69,7 @@ struct fsmap_head {  };  /* Size of an fsmap_head with room for nr records. */ -static inline size_t +static inline __kernel_size_t  fsmap_sizeof(  	unsigned int	nr)  { diff --git a/include/uapi/linux/fsverity.h b/include/uapi/linux/fsverity.h index da0daf6c193b..15384e22e331 100644 --- a/include/uapi/linux/fsverity.h +++ b/include/uapi/linux/fsverity.h @@ -34,7 +34,70 @@ struct fsverity_digest {  	__u8 digest[];  }; +/* + * Struct containing a file's Merkle tree properties.  The fs-verity file digest + * is the hash of this struct.  A userspace program needs this struct only if it + * needs to compute fs-verity file digests itself, e.g. in order to sign files. + * It isn't needed just to enable fs-verity on a file. + * + * Note: when computing the file digest, 'sig_size' and 'signature' must be left + * zero and empty, respectively.  These fields are present only because some + * filesystems reuse this struct as part of their on-disk format. + */ +struct fsverity_descriptor { +	__u8 version;		/* must be 1 */ +	__u8 hash_algorithm;	/* Merkle tree hash algorithm */ +	__u8 log_blocksize;	/* log2 of size of data and tree blocks */ +	__u8 salt_size;		/* size of salt in bytes; 0 if none */ +#ifdef __KERNEL__ +	__le32 sig_size; +#else +	__le32 __reserved_0x04;	/* must be 0 */ +#endif +	__le64 data_size;	/* size of file the Merkle tree is built over */ +	__u8 root_hash[64];	/* Merkle tree root hash */ +	__u8 salt[32];		/* salt prepended to each hashed block */ +	__u8 __reserved[144];	/* must be 0's */ +#ifdef __KERNEL__ +	__u8 signature[]; +#endif +}; + +/* + * Format in which fs-verity file digests are signed in built-in signatures. + * This is the same as 'struct fsverity_digest', except here some magic bytes + * are prepended to provide some context about what is being signed in case the + * same key is used for non-fsverity purposes, and here the fields have fixed + * endianness. + * + * This struct is specific to the built-in signature verification support, which + * is optional.  fs-verity users may also verify signatures in userspace, in + * which case userspace is responsible for deciding on what bytes are signed. + * This struct may still be used, but it doesn't have to be.  For example, + * userspace could instead use a string like "sha256:$digest_as_hex_string". + */ +struct fsverity_formatted_digest { +	char magic[8];			/* must be "FSVerity" */ +	__le16 digest_algorithm; +	__le16 digest_size; +	__u8 digest[]; +}; + +#define FS_VERITY_METADATA_TYPE_MERKLE_TREE	1 +#define FS_VERITY_METADATA_TYPE_DESCRIPTOR	2 +#define FS_VERITY_METADATA_TYPE_SIGNATURE	3 + +struct fsverity_read_metadata_arg { +	__u64 metadata_type; +	__u64 offset; +	__u64 length; +	__u64 buf_ptr; +	__u64 __reserved; +}; +  #define FS_IOC_ENABLE_VERITY	_IOW('f', 133, struct fsverity_enable_arg)  #define FS_IOC_MEASURE_VERITY	_IOWR('f', 134, struct fsverity_digest) +#define FS_IOC_READ_VERITY_METADATA \ +	_IOWR('f', 135, struct fsverity_read_metadata_arg)  #endif /* _UAPI_LINUX_FSVERITY_H */ diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 373cada89815..122d6586e8d4 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -172,6 +172,69 @@   *  - add FUSE_WRITE_KILL_PRIV flag   *  - add FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING   *  - add map_alignment to fuse_init_out, add FUSE_MAP_ALIGNMENT flag + * + *  7.32 + *  - add flags to fuse_attr, add FUSE_ATTR_SUBMOUNT, add FUSE_SUBMOUNTS + * + *  7.33 + *  - add FUSE_HANDLE_KILLPRIV_V2, FUSE_WRITE_KILL_SUIDGID, FATTR_KILL_SUIDGID + *  - add FUSE_OPEN_KILL_SUIDGID + *  - extend fuse_setxattr_in, add FUSE_SETXATTR_EXT + *  - add FUSE_SETXATTR_ACL_KILL_SGID + * + *  7.34 + *  - add FUSE_SYNCFS + * + *  7.35 + *  - add FOPEN_NOFLUSH + * + *  7.36 + *  - extend fuse_init_in with reserved fields, add FUSE_INIT_EXT init flag + *  - add flags2 to fuse_init_in and fuse_init_out + *  - add FUSE_SECURITY_CTX init flag + *  - add security context to create, mkdir, symlink, and mknod requests + *  - add FUSE_HAS_INODE_DAX, FUSE_ATTR_DAX + * + *  7.37 + *  - add FUSE_TMPFILE + * + *  7.38 + *  - add FUSE_EXPIRE_ONLY flag to fuse_notify_inval_entry + *  - add FOPEN_PARALLEL_DIRECT_WRITES + *  - add total_extlen to fuse_in_header + *  - add FUSE_MAX_NR_SECCTX + *  - add extension header + *  - add FUSE_EXT_GROUPS + *  - add FUSE_CREATE_SUPP_GROUP + *  - add FUSE_HAS_EXPIRE_ONLY + * + *  7.39 + *  - add FUSE_DIRECT_IO_ALLOW_MMAP + *  - add FUSE_STATX and related structures + * + *  7.40 + *  - add max_stack_depth to fuse_init_out, add FUSE_PASSTHROUGH init flag + *  - add backing_id to fuse_open_out, add FOPEN_PASSTHROUGH open flag + *  - add FUSE_NO_EXPORT_SUPPORT init flag + *  - add FUSE_NOTIFY_RESEND, add FUSE_HAS_RESEND init flag + * + *  7.41 + *  - add FUSE_ALLOW_IDMAP + *  7.42 + *  - Add FUSE_OVER_IO_URING and all other io-uring related flags and data + *    structures: + *    - struct fuse_uring_ent_in_out + *    - struct fuse_uring_req_header + *    - struct fuse_uring_cmd_req + *    - FUSE_URING_IN_OUT_HEADER_SZ + *    - FUSE_URING_OP_IN_OUT_SZ + *    - enum fuse_uring_cmd + * + *  7.43 + *  - add FUSE_REQUEST_TIMEOUT + * + *  7.44 + *  - add FUSE_NOTIFY_INC_EPOCH   */  #ifndef _LINUX_FUSE_H @@ -207,7 +270,7 @@  #define FUSE_KERNEL_VERSION 7  /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 31 +#define FUSE_KERNEL_MINOR_VERSION 44  /** The node ID of the root inode */  #define FUSE_ROOT_ID 1 @@ -231,7 +294,41 @@ struct fuse_attr {  	uint32_t	gid;  	uint32_t	rdev;  	uint32_t	blksize; -	uint32_t	padding; +	uint32_t	flags; +}; + +/* + * The following structures are bit-for-bit compatible with the statx(2) ABI in + * Linux. + */ +struct fuse_sx_time { +	int64_t		tv_sec; +	uint32_t	tv_nsec; +	int32_t		__reserved; +}; + +struct fuse_statx { +	uint32_t	mask; +	uint32_t	blksize; +	uint64_t	attributes; +	uint32_t	nlink; +	uint32_t	uid; +	uint32_t	gid; +	uint16_t	mode; +	uint16_t	__spare0[1]; +	uint64_t	ino; +	uint64_t	size; +	uint64_t	blocks; +	uint64_t	attributes_mask; +	struct fuse_sx_time	atime; +	struct fuse_sx_time	btime; +	struct fuse_sx_time	ctime; +	struct fuse_sx_time	mtime; +	uint32_t	rdev_major; +	uint32_t	rdev_minor; +	uint32_t	dev_major; +	uint32_t	dev_minor; +	uint64_t	__spare2[14];  };  struct fuse_kstatfs { @@ -268,6 +365,7 @@ struct fuse_file_lock {  #define FATTR_MTIME_NOW	(1 << 8)  #define FATTR_LOCKOWNER	(1 << 9)  #define FATTR_CTIME	(1 << 10) +#define FATTR_KILL_SUIDGID	(1 << 11)  /**   * Flags returned by the OPEN request @@ -277,12 +375,18 @@ struct fuse_file_lock {   * FOPEN_NONSEEKABLE: the file is not seekable   * FOPEN_CACHE_DIR: allow caching this directory   * FOPEN_STREAM: the file is stream-like (no file position at all) + * FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE) + * FOPEN_PARALLEL_DIRECT_WRITES: Allow concurrent direct writes on the same inode + * FOPEN_PASSTHROUGH: passthrough read/write io for this open file   */  #define FOPEN_DIRECT_IO		(1 << 0)  #define FOPEN_KEEP_CACHE	(1 << 1)  #define FOPEN_NONSEEKABLE	(1 << 2)  #define FOPEN_CACHE_DIR		(1 << 3)  #define FOPEN_STREAM		(1 << 4) +#define FOPEN_NOFLUSH		(1 << 5) +#define FOPEN_PARALLEL_DIRECT_WRITES	(1 << 6) +#define FOPEN_PASSTHROUGH	(1 << 7)  /**   * INIT request/reply flags @@ -313,7 +417,32 @@ struct fuse_file_lock {   * FUSE_CACHE_SYMLINKS: cache READLINK responses   * FUSE_NO_OPENDIR_SUPPORT: kernel supports zero-message opendir   * FUSE_EXPLICIT_INVAL_DATA: only invalidate cached pages on explicit request - * FUSE_MAP_ALIGNMENT: map_alignment field is valid + * FUSE_MAP_ALIGNMENT: init_out.map_alignment contains log2(byte alignment) for + *		       foffset and moffset fields in struct + *		       fuse_setupmapping_out and fuse_removemapping_one. + * FUSE_SUBMOUNTS: kernel supports auto-mounting directory submounts + * FUSE_HANDLE_KILLPRIV_V2: fs kills suid/sgid/cap on write/chown/trunc. + *			Upon write/truncate suid/sgid is only killed if caller + *			does not have CAP_FSETID. Additionally upon + *			write/truncate sgid is killed only if file has group + *			execute permission. (Same as Linux VFS behavior). + * FUSE_SETXATTR_EXT:	Server supports extended struct fuse_setxattr_in + * FUSE_INIT_EXT: extended fuse_init_in request + * FUSE_INIT_RESERVED: reserved, do not use + * FUSE_SECURITY_CTX:	add security context to create, mkdir, symlink, and + *			mknod + * FUSE_HAS_INODE_DAX:  use per inode DAX + * FUSE_CREATE_SUPP_GROUP: add supplementary group info to create, mkdir, + *			symlink and mknod (single group that matches parent) + * FUSE_HAS_EXPIRE_ONLY: kernel supports expiry-only entry invalidation + * FUSE_DIRECT_IO_ALLOW_MMAP: allow shared mmap in FOPEN_DIRECT_IO mode. + * FUSE_NO_EXPORT_SUPPORT: explicitly disable export support + * FUSE_HAS_RESEND: kernel supports resending pending requests, and the high bit + *		    of the request ID indicates resend requests + * FUSE_ALLOW_IDMAP: allow creation of idmapped mounts + * FUSE_OVER_IO_URING: Indicate that client supports io-uring + * FUSE_REQUEST_TIMEOUT: kernel supports timing out requests. + *			 init_out.request_timeout contains the timeout (in secs)   */  #define FUSE_ASYNC_READ		(1 << 0)  #define FUSE_POSIX_LOCKS	(1 << 1) @@ -342,6 +471,25 @@ struct fuse_file_lock {  #define FUSE_NO_OPENDIR_SUPPORT (1 << 24)  #define FUSE_EXPLICIT_INVAL_DATA (1 << 25)  #define FUSE_MAP_ALIGNMENT	(1 << 26) +#define FUSE_SUBMOUNTS		(1 << 27) +#define FUSE_HANDLE_KILLPRIV_V2	(1 << 28) +#define FUSE_SETXATTR_EXT	(1 << 29) +#define FUSE_INIT_EXT		(1 << 30) +#define FUSE_INIT_RESERVED	(1 << 31) +/* bits 32..63 get shifted down 32 bits into the flags2 field */ +#define FUSE_SECURITY_CTX	(1ULL << 32) +#define FUSE_HAS_INODE_DAX	(1ULL << 33) +#define FUSE_CREATE_SUPP_GROUP	(1ULL << 34) +#define FUSE_HAS_EXPIRE_ONLY	(1ULL << 35) +#define FUSE_DIRECT_IO_ALLOW_MMAP (1ULL << 36) +#define FUSE_PASSTHROUGH	(1ULL << 37) +#define FUSE_NO_EXPORT_SUPPORT	(1ULL << 38) +#define FUSE_HAS_RESEND		(1ULL << 39) +/* Obsolete alias for FUSE_DIRECT_IO_ALLOW_MMAP */ +#define FUSE_DIRECT_IO_RELAX	FUSE_DIRECT_IO_ALLOW_MMAP +#define FUSE_ALLOW_IDMAP	(1ULL << 40) +#define FUSE_OVER_IO_URING	(1ULL << 41) +#define FUSE_REQUEST_TIMEOUT	(1ULL << 42)  /**   * CUSE INIT request/reply flags @@ -371,11 +519,14 @@ struct fuse_file_lock {   *   * FUSE_WRITE_CACHE: delayed write from page cache, file handle is guessed   * FUSE_WRITE_LOCKOWNER: lock_owner field is valid - * FUSE_WRITE_KILL_PRIV: kill suid and sgid bits + * FUSE_WRITE_KILL_SUIDGID: kill suid and sgid bits   */  #define FUSE_WRITE_CACHE	(1 << 0)  #define FUSE_WRITE_LOCKOWNER	(1 << 1) -#define FUSE_WRITE_KILL_PRIV	(1 << 2) +#define FUSE_WRITE_KILL_SUIDGID (1 << 2) + +/* Obsolete alias; this flag implies killing suid/sgid only. */ +#define FUSE_WRITE_KILL_PRIV	FUSE_WRITE_KILL_SUIDGID  /**   * Read flags @@ -417,6 +568,44 @@ struct fuse_file_lock {   */  #define FUSE_FSYNC_FDATASYNC	(1 << 0) +/** + * fuse_attr flags + * + * FUSE_ATTR_SUBMOUNT: Object is a submount root + * FUSE_ATTR_DAX: Enable DAX for this file in per inode DAX mode + */ +#define FUSE_ATTR_SUBMOUNT      (1 << 0) +#define FUSE_ATTR_DAX		(1 << 1) + +/** + * Open flags + * FUSE_OPEN_KILL_SUIDGID: Kill suid and sgid if executable + */ +#define FUSE_OPEN_KILL_SUIDGID	(1 << 0) + +/** + * setxattr flags + * FUSE_SETXATTR_ACL_KILL_SGID: Clear SGID when system.posix_acl_access is set + */ +#define FUSE_SETXATTR_ACL_KILL_SGID	(1 << 0) + +/** + * notify_inval_entry flags + * FUSE_EXPIRE_ONLY + */ +#define FUSE_EXPIRE_ONLY		(1 << 0) + +/** + * extension type + * FUSE_MAX_NR_SECCTX: maximum value of &fuse_secctx_header.nr_secctx + * FUSE_EXT_GROUPS: &fuse_supp_groups extension + */ +enum fuse_ext_type { +	/* Types 0..31 are reserved for fuse_secctx_header */ +	FUSE_MAX_NR_SECCTX	= 31, +	FUSE_EXT_GROUPS		= 32, +}; +  enum fuse_opcode {  	FUSE_LOOKUP		= 1,  	FUSE_FORGET		= 2,  /* no reply */ @@ -465,6 +654,9 @@ enum fuse_opcode {  	FUSE_COPY_FILE_RANGE	= 47,  	FUSE_SETUPMAPPING	= 48,  	FUSE_REMOVEMAPPING	= 49, +	FUSE_SYNCFS		= 50, +	FUSE_TMPFILE		= 51, +	FUSE_STATX		= 52,  	/* CUSE specific operations */  	CUSE_INIT		= 4096, @@ -481,6 +673,8 @@ enum fuse_notify_code {  	FUSE_NOTIFY_STORE = 4,  	FUSE_NOTIFY_RETRIEVE = 5,  	FUSE_NOTIFY_DELETE = 6, +	FUSE_NOTIFY_RESEND = 7, +	FUSE_NOTIFY_INC_EPOCH = 8,  	FUSE_NOTIFY_CODE_MAX,  }; @@ -529,6 +723,22 @@ struct fuse_attr_out {  	struct fuse_attr attr;  }; +struct fuse_statx_in { +	uint32_t	getattr_flags; +	uint32_t	reserved; +	uint64_t	fh; +	uint32_t	sx_flags; +	uint32_t	sx_mask; +}; + +struct fuse_statx_out { +	uint64_t	attr_valid;	/* Cache timeout for the attributes */ +	uint32_t	attr_valid_nsec; +	uint32_t	flags; +	uint64_t	spare[2]; +	struct fuse_statx stat; +}; +  #define FUSE_COMPAT_MKNOD_IN_SIZE 8  struct fuse_mknod_in { @@ -578,20 +788,20 @@ struct fuse_setattr_in {  struct fuse_open_in {  	uint32_t	flags; -	uint32_t	unused; +	uint32_t	open_flags;	/* FUSE_OPEN_... */  };  struct fuse_create_in {  	uint32_t	flags;  	uint32_t	mode;  	uint32_t	umask; -	uint32_t	padding; +	uint32_t	open_flags;	/* FUSE_OPEN_... */  };  struct fuse_open_out {  	uint64_t	fh;  	uint32_t	open_flags; -	uint32_t	padding; +	int32_t		backing_id;  };  struct fuse_release_in { @@ -647,9 +857,13 @@ struct fuse_fsync_in {  	uint32_t	padding;  }; +#define FUSE_COMPAT_SETXATTR_IN_SIZE 8 +  struct fuse_setxattr_in {  	uint32_t	size;  	uint32_t	flags; +	uint32_t	setxattr_flags; +	uint32_t	padding;  };  struct fuse_getxattr_in { @@ -684,6 +898,8 @@ struct fuse_init_in {  	uint32_t	minor;  	uint32_t	max_readahead;  	uint32_t	flags; +	uint32_t	flags2; +	uint32_t	unused[11];  };  #define FUSE_COMPAT_INIT_OUT_SIZE 8 @@ -700,7 +916,10 @@ struct fuse_init_out {  	uint32_t	time_gran;  	uint16_t	max_pages;  	uint16_t	map_alignment; -	uint32_t	unused[8]; +	uint32_t	flags2; +	uint32_t	max_stack_depth; +	uint16_t	request_timeout; +	uint16_t	unused[11];  };  #define CUSE_INIT_INFO_MAX 4096 @@ -783,6 +1002,29 @@ struct fuse_fallocate_in {  	uint32_t	padding;  }; +/** + * FUSE request unique ID flag + * + * Indicates whether this is a resend request. The receiver should handle this + * request accordingly. + */ +#define FUSE_UNIQUE_RESEND (1ULL << 63) + +/** + * This value will be set by the kernel to + * (struct fuse_in_header).{uid,gid} fields in + * case when: + * - fuse daemon enabled FUSE_ALLOW_IDMAP + * - idmapping information is not available and uid/gid + *   can not be mapped in accordance with an idmapping. + * + * Note: an idmapping information always available + * for inode creation operations like: + * FUSE_MKNOD, FUSE_SYMLINK, FUSE_MKDIR, FUSE_TMPFILE, + * FUSE_CREATE and FUSE_RENAME2 (with RENAME_WHITEOUT). + */ +#define FUSE_INVALID_UIDGID ((uint32_t)(-1)) +  struct fuse_in_header {  	uint32_t	len;  	uint32_t	opcode; @@ -791,7 +1033,8 @@ struct fuse_in_header {  	uint32_t	uid;  	uint32_t	gid;  	uint32_t	pid; -	uint32_t	padding; +	uint16_t	total_extlen; /* length of extensions in 8byte units */ +	uint16_t	padding;  };  struct fuse_out_header { @@ -808,9 +1051,12 @@ struct fuse_dirent {  	char name[];  }; -#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) -#define FUSE_DIRENT_ALIGN(x) \ +/* Align variable length records to 64bit boundary */ +#define FUSE_REC_ALIGN(x) \  	(((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1)) + +#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) +#define FUSE_DIRENT_ALIGN(x) FUSE_REC_ALIGN(x)  #define FUSE_DIRENT_SIZE(d) \  	FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) @@ -833,7 +1079,7 @@ struct fuse_notify_inval_inode_out {  struct fuse_notify_inval_entry_out {  	uint64_t	parent;  	uint32_t	namelen; -	uint32_t	padding; +	uint32_t	flags;  };  struct fuse_notify_delete_out { @@ -868,8 +1114,18 @@ struct fuse_notify_retrieve_in {  	uint64_t	dummy4;  }; +struct fuse_backing_map { +	int32_t		fd; +	uint32_t	flags; +	uint64_t	padding; +}; +  /* Device ioctls: */ -#define FUSE_DEV_IOC_CLONE	_IOR(229, 0, uint32_t) +#define FUSE_DEV_IOC_MAGIC		229 +#define FUSE_DEV_IOC_CLONE		_IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t) +#define FUSE_DEV_IOC_BACKING_OPEN	_IOW(FUSE_DEV_IOC_MAGIC, 1, \ +					     struct fuse_backing_map) +#define FUSE_DEV_IOC_BACKING_CLOSE	_IOW(FUSE_DEV_IOC_MAGIC, 2, uint32_t)  struct fuse_lseek_in {  	uint64_t	fh; @@ -892,4 +1148,146 @@ struct fuse_copy_file_range_in {  	uint64_t	flags;  }; +#define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0) +#define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1) +struct fuse_setupmapping_in { +	/* An already open handle */ +	uint64_t	fh; +	/* Offset into the file to start the mapping */ +	uint64_t	foffset; +	/* Length of mapping required */ +	uint64_t	len; +	/* Flags, FUSE_SETUPMAPPING_FLAG_* */ +	uint64_t	flags; +	/* Offset in Memory Window */ +	uint64_t	moffset; +}; + +struct fuse_removemapping_in { +	/* number of fuse_removemapping_one follows */ +	uint32_t        count; +}; + +struct fuse_removemapping_one { +	/* Offset into the dax window start the unmapping */ +	uint64_t        moffset; +	/* Length of mapping required */ +	uint64_t	len; +}; + +#define FUSE_REMOVEMAPPING_MAX_ENTRY   \ +		(PAGE_SIZE / sizeof(struct fuse_removemapping_one)) + +struct fuse_syncfs_in { +	uint64_t	padding; +}; + +/* + * For each security context, send fuse_secctx with size of security context + * fuse_secctx will be followed by security context name and this in turn + * will be followed by actual context label. + * fuse_secctx, name, context + */ +struct fuse_secctx { +	uint32_t	size; +	uint32_t	padding; +}; + +/* + * Contains the information about how many fuse_secctx structures are being + * sent and what's the total size of all security contexts (including + * size of fuse_secctx_header). + * + */ +struct fuse_secctx_header { +	uint32_t	size; +	uint32_t	nr_secctx; +}; + +/** + * struct fuse_ext_header - extension header + * @size: total size of this extension including this header + * @type: type of extension + * + * This is made compatible with fuse_secctx_header by using type values > + * FUSE_MAX_NR_SECCTX + */ +struct fuse_ext_header { +	uint32_t	size; +	uint32_t	type; +}; + +/** + * struct fuse_supp_groups - Supplementary group extension + * @nr_groups: number of supplementary groups + * @groups: flexible array of group IDs + */ +struct fuse_supp_groups { +	uint32_t	nr_groups; +	uint32_t	groups[]; +}; + +/** + * Size of the ring buffer header + */ +#define FUSE_URING_IN_OUT_HEADER_SZ 128 +#define FUSE_URING_OP_IN_OUT_SZ 128 + +/* Used as part of the fuse_uring_req_header */ +struct fuse_uring_ent_in_out { +	uint64_t flags; + +	/* +	 * commit ID to be used in a reply to a ring request (see also +	 * struct fuse_uring_cmd_req) +	 */ +	uint64_t commit_id; + +	/* size of user payload buffer */ +	uint32_t payload_sz; +	uint32_t padding; + +	uint64_t reserved; +}; + +/** + * Header for all fuse-io-uring requests + */ +struct fuse_uring_req_header { +	/* struct fuse_in_header / struct fuse_out_header */ +	char in_out[FUSE_URING_IN_OUT_HEADER_SZ]; + +	/* per op code header */ +	char op_in[FUSE_URING_OP_IN_OUT_SZ]; + +	struct fuse_uring_ent_in_out ring_ent_in_out; +}; + +/** + * sqe commands to the kernel + */ +enum fuse_uring_cmd { +	FUSE_IO_URING_CMD_INVALID = 0, + +	/* register the request buffer and fetch a fuse request */ +	FUSE_IO_URING_CMD_REGISTER = 1, + +	/* commit fuse request result and fetch next request */ +	FUSE_IO_URING_CMD_COMMIT_AND_FETCH = 2, +}; + +/** + * In the 80B command area of the SQE. + */ +struct fuse_uring_cmd_req { +	uint64_t flags; + +	/* entry identifier for commits */ +	uint64_t commit_id; + +	/* queue the command is for (queue index) */ +	uint16_t qid; +	uint8_t padding[6]; +}; +  #endif /* _LINUX_FUSE_H */ diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h index a89eb0accd5e..7e2744ec8933 100644 --- a/include/uapi/linux/futex.h +++ b/include/uapi/linux/futex.h @@ -21,6 +21,7 @@  #define FUTEX_WAKE_BITSET	10  #define FUTEX_WAIT_REQUEUE_PI	11  #define FUTEX_CMP_REQUEUE_PI	12 +#define FUTEX_LOCK_PI2		13  #define FUTEX_PRIVATE_FLAG	128  #define FUTEX_CLOCK_REALTIME	256 @@ -32,6 +33,7 @@  #define FUTEX_CMP_REQUEUE_PRIVATE (FUTEX_CMP_REQUEUE | FUTEX_PRIVATE_FLAG)  #define FUTEX_WAKE_OP_PRIVATE	(FUTEX_WAKE_OP | FUTEX_PRIVATE_FLAG)  #define FUTEX_LOCK_PI_PRIVATE	(FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG) +#define FUTEX_LOCK_PI2_PRIVATE	(FUTEX_LOCK_PI2 | FUTEX_PRIVATE_FLAG)  #define FUTEX_UNLOCK_PI_PRIVATE	(FUTEX_UNLOCK_PI | FUTEX_PRIVATE_FLAG)  #define FUTEX_TRYLOCK_PI_PRIVATE (FUTEX_TRYLOCK_PI | FUTEX_PRIVATE_FLAG)  #define FUTEX_WAIT_BITSET_PRIVATE	(FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG) @@ -42,6 +44,63 @@  					 FUTEX_PRIVATE_FLAG)  /* + * Flags for futex2 syscalls. + * + * NOTE: these are not pure flags, they can also be seen as: + * + *   union { + *     u32  flags; + *     struct { + *       u32 size    : 2, + *           numa    : 1, + *                   : 4, + *           private : 1; + *     }; + *   }; + */ +#define FUTEX2_SIZE_U8		0x00 +#define FUTEX2_SIZE_U16		0x01 +#define FUTEX2_SIZE_U32		0x02 +#define FUTEX2_SIZE_U64		0x03 +#define FUTEX2_NUMA		0x04 +#define FUTEX2_MPOL		0x08 +			/*	0x10 */ +			/*	0x20 */ +			/*	0x40 */ +#define FUTEX2_PRIVATE		FUTEX_PRIVATE_FLAG + +#define FUTEX2_SIZE_MASK	0x03 + +/* do not use */ +#define FUTEX_32		FUTEX2_SIZE_U32 /* historical accident :-( */ + +/* + * When FUTEX2_NUMA doubles the futex word, the second word is a node value. + * The special value -1 indicates no-node. This is the same value as + * NUMA_NO_NODE, except that value is not ABI, this is. + */ +#define FUTEX_NO_NODE		(-1) + +/* + * Max numbers of elements in a futex_waitv array + */ +#define FUTEX_WAITV_MAX		128 + +/** + * struct futex_waitv - A waiter for vectorized wait + * @val:	Expected value at uaddr + * @uaddr:	User address to wait on + * @flags:	Flags for this waiter + * @__reserved:	Reserved member to preserve data alignment. Should be 0. + */ +struct futex_waitv { +	__u64 val; +	__u64 uaddr; +	__u32 flags; +	__u32 __reserved; +}; + +/*   * Support for robust futexes: the kernel cleans up held futexes at   * thread exit time.   */ diff --git a/include/uapi/linux/genetlink.h b/include/uapi/linux/genetlink.h index 9c0636ec2286..ddba3ca01e39 100644 --- a/include/uapi/linux/genetlink.h +++ b/include/uapi/linux/genetlink.h @@ -64,6 +64,8 @@ enum {  	CTRL_ATTR_OPS,  	CTRL_ATTR_MCAST_GROUPS,  	CTRL_ATTR_POLICY, +	CTRL_ATTR_OP_POLICY, +	CTRL_ATTR_OP,  	__CTRL_ATTR_MAX,  }; @@ -87,5 +89,15 @@ enum {  #define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1) +enum { +	CTRL_ATTR_POLICY_UNSPEC, +	CTRL_ATTR_POLICY_DO, +	CTRL_ATTR_POLICY_DUMP, + +	__CTRL_ATTR_POLICY_DUMP_MAX, +	CTRL_ATTR_POLICY_DUMP_MAX = __CTRL_ATTR_POLICY_DUMP_MAX - 1 +}; + +#define CTRL_ATTR_POLICY_MAX (__CTRL_ATTR_POLICY_DUMP_MAX - 1)  #endif /* _UAPI__LINUX_GENERIC_NETLINK_H */ diff --git a/include/uapi/linux/gfs2_ondisk.h b/include/uapi/linux/gfs2_ondisk.h index 07e508e6691b..6ec4291bcc7a 100644 --- a/include/uapi/linux/gfs2_ondisk.h +++ b/include/uapi/linux/gfs2_ondisk.h @@ -47,7 +47,7 @@  #define GFS2_FORMAT_DE		1200  #define GFS2_FORMAT_QU		1500  /* These are part of the superblock */ -#define GFS2_FORMAT_FS		1801 +#define GFS2_FORMAT_FS		1802  #define GFS2_FORMAT_MULTI	1900  /* @@ -389,8 +389,9 @@ struct gfs2_leaf {  #define GFS2_EATYPE_USR		1  #define GFS2_EATYPE_SYS		2  #define GFS2_EATYPE_SECURITY	3 +#define GFS2_EATYPE_TRUSTED	4 -#define GFS2_EATYPE_LAST	3 +#define GFS2_EATYPE_LAST	4  #define GFS2_EATYPE_VALID(x)	((x) <= GFS2_EATYPE_LAST)  #define GFS2_EAFLAG_LAST	0x01	/* last ea in block */ diff --git a/include/uapi/linux/gpio.h b/include/uapi/linux/gpio.h index 9c27cecf406f..f7cb8ae87df7 100644 --- a/include/uapi/linux/gpio.h +++ b/include/uapi/linux/gpio.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */  /*   * <linux/gpio.h> - userspace ABI for the GPIO character devices   * @@ -11,22 +11,305 @@  #ifndef _UAPI_GPIO_H_  #define _UAPI_GPIO_H_ +#include <linux/const.h>  #include <linux/ioctl.h>  #include <linux/types.h> +/* + * The maximum size of name and label arrays. + * + * Must be a multiple of 8 to ensure 32/64-bit alignment of structs. + */ +#define GPIO_MAX_NAME_SIZE 32 +  /**   * struct gpiochip_info - Information about a certain GPIO chip   * @name: the Linux kernel name of this GPIO chip   * @label: a functional name for this GPIO chip, such as a product - * number, may be empty + * number, may be empty (i.e. label[0] == '\0')   * @lines: number of GPIO lines on this chip   */  struct gpiochip_info { -	char name[32]; -	char label[32]; +	char name[GPIO_MAX_NAME_SIZE]; +	char label[GPIO_MAX_NAME_SIZE];  	__u32 lines;  }; +/* + * Maximum number of requested lines. + * + * Must be no greater than 64, as bitmaps are restricted here to 64-bits + * for simplicity, and a multiple of 2 to ensure 32/64-bit alignment of + * structs. + */ +#define GPIO_V2_LINES_MAX 64 + +/* + * The maximum number of configuration attributes associated with a line + * request. + */ +#define GPIO_V2_LINE_NUM_ATTRS_MAX 10 + +/** + * enum gpio_v2_line_flag - &struct gpio_v2_line_attribute.flags values + * @GPIO_V2_LINE_FLAG_USED: line is not available for request + * @GPIO_V2_LINE_FLAG_ACTIVE_LOW: line active state is physical low + * @GPIO_V2_LINE_FLAG_INPUT: line is an input + * @GPIO_V2_LINE_FLAG_OUTPUT: line is an output + * @GPIO_V2_LINE_FLAG_EDGE_RISING: line detects rising (inactive to active) + * edges + * @GPIO_V2_LINE_FLAG_EDGE_FALLING: line detects falling (active to + * inactive) edges + * @GPIO_V2_LINE_FLAG_OPEN_DRAIN: line is an open drain output + * @GPIO_V2_LINE_FLAG_OPEN_SOURCE: line is an open source output + * @GPIO_V2_LINE_FLAG_BIAS_PULL_UP: line has pull-up bias enabled + * @GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN: line has pull-down bias enabled + * @GPIO_V2_LINE_FLAG_BIAS_DISABLED: line has bias disabled + * @GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME: line events contain REALTIME timestamps + * @GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE: line events contain timestamps from + * the hardware timestamping engine (HTE) subsystem + */ +enum gpio_v2_line_flag { +	GPIO_V2_LINE_FLAG_USED			= _BITULL(0), +	GPIO_V2_LINE_FLAG_ACTIVE_LOW		= _BITULL(1), +	GPIO_V2_LINE_FLAG_INPUT			= _BITULL(2), +	GPIO_V2_LINE_FLAG_OUTPUT		= _BITULL(3), +	GPIO_V2_LINE_FLAG_EDGE_RISING		= _BITULL(4), +	GPIO_V2_LINE_FLAG_EDGE_FALLING		= _BITULL(5), +	GPIO_V2_LINE_FLAG_OPEN_DRAIN		= _BITULL(6), +	GPIO_V2_LINE_FLAG_OPEN_SOURCE		= _BITULL(7), +	GPIO_V2_LINE_FLAG_BIAS_PULL_UP		= _BITULL(8), +	GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN	= _BITULL(9), +	GPIO_V2_LINE_FLAG_BIAS_DISABLED		= _BITULL(10), +	GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME	= _BITULL(11), +	GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE	= _BITULL(12), +}; + +/** + * struct gpio_v2_line_values - Values of GPIO lines + * @bits: a bitmap containing the value of the lines, set to 1 for active + * and 0 for inactive + * @mask: a bitmap identifying the lines to get or set, with each bit + * number corresponding to the index into &struct + * gpio_v2_line_request.offsets + */ +struct gpio_v2_line_values { +	__aligned_u64 bits; +	__aligned_u64 mask; +}; + +/** + * enum gpio_v2_line_attr_id - &struct gpio_v2_line_attribute.id values + * identifying which field of the attribute union is in use. + * @GPIO_V2_LINE_ATTR_ID_FLAGS: flags field is in use + * @GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES: values field is in use + * @GPIO_V2_LINE_ATTR_ID_DEBOUNCE: debounce_period_us field is in use + */ +enum gpio_v2_line_attr_id { +	GPIO_V2_LINE_ATTR_ID_FLAGS		= 1, +	GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES	= 2, +	GPIO_V2_LINE_ATTR_ID_DEBOUNCE		= 3, +}; + +/** + * struct gpio_v2_line_attribute - a configurable attribute of a line + * @id: attribute identifier with value from &enum gpio_v2_line_attr_id + * @padding: reserved for future use and must be zero filled + * @flags: if id is %GPIO_V2_LINE_ATTR_ID_FLAGS, the flags for the GPIO + * line, with values from &enum gpio_v2_line_flag, such as + * %GPIO_V2_LINE_FLAG_ACTIVE_LOW, %GPIO_V2_LINE_FLAG_OUTPUT etc, added + * together.  This overrides the default flags contained in the &struct + * gpio_v2_line_config for the associated line. + * @values: if id is %GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES, a bitmap + * containing the values to which the lines will be set, with each bit + * number corresponding to the index into &struct + * gpio_v2_line_request.offsets + * @debounce_period_us: if id is %GPIO_V2_LINE_ATTR_ID_DEBOUNCE, the + * desired debounce period, in microseconds + */ +struct gpio_v2_line_attribute { +	__u32 id; +	__u32 padding; +	union { +		__aligned_u64 flags; +		__aligned_u64 values; +		__u32 debounce_period_us; +	}; +}; + +/** + * struct gpio_v2_line_config_attribute - a configuration attribute + * associated with one or more of the requested lines. + * @attr: the configurable attribute + * @mask: a bitmap identifying the lines to which the attribute applies, + * with each bit number corresponding to the index into &struct + * gpio_v2_line_request.offsets + */ +struct gpio_v2_line_config_attribute { +	struct gpio_v2_line_attribute attr; +	__aligned_u64 mask; +}; + +/** + * struct gpio_v2_line_config - Configuration for GPIO lines + * @flags: flags for the GPIO lines, with values from &enum + * gpio_v2_line_flag, such as %GPIO_V2_LINE_FLAG_ACTIVE_LOW, + * %GPIO_V2_LINE_FLAG_OUTPUT etc, added together.  This is the default for + * all requested lines but may be overridden for particular lines using + * @attrs. + * @num_attrs: the number of attributes in @attrs + * @padding: reserved for future use and must be zero filled + * @attrs: the configuration attributes associated with the requested + * lines.  Any attribute should only be associated with a particular line + * once.  If an attribute is associated with a line multiple times then the + * first occurrence (i.e. lowest index) has precedence. + */ +struct gpio_v2_line_config { +	__aligned_u64 flags; +	__u32 num_attrs; +	/* Pad to fill implicit padding and reserve space for future use. */ +	__u32 padding[5]; +	struct gpio_v2_line_config_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX]; +}; + +/** + * struct gpio_v2_line_request - Information about a request for GPIO lines + * @offsets: an array of desired lines, specified by offset index for the + * associated GPIO chip + * @consumer: a desired consumer label for the selected GPIO lines such as + * "my-bitbanged-relay" + * @config: requested configuration for the lines + * @num_lines: number of lines requested in this request, i.e. the number + * of valid fields in the %GPIO_V2_LINES_MAX sized arrays, set to 1 to + * request a single line + * @event_buffer_size: a suggested minimum number of line events that the + * kernel should buffer.  This is only relevant if edge detection is + * enabled in the configuration. Note that this is only a suggested value + * and the kernel may allocate a larger buffer or cap the size of the + * buffer. If this field is zero then the buffer size defaults to a minimum + * of @num_lines * 16. + * @padding: reserved for future use and must be zero filled + * @fd: after a successful %GPIO_V2_GET_LINE_IOCTL operation, contains + * a valid anonymous file descriptor representing the request + */ +struct gpio_v2_line_request { +	__u32 offsets[GPIO_V2_LINES_MAX]; +	char consumer[GPIO_MAX_NAME_SIZE]; +	struct gpio_v2_line_config config; +	__u32 num_lines; +	__u32 event_buffer_size; +	/* Pad to fill implicit padding and reserve space for future use. */ +	__u32 padding[5]; +	__s32 fd; +}; + +/** + * struct gpio_v2_line_info - Information about a certain GPIO line + * @name: the name of this GPIO line, such as the output pin of the line on + * the chip, a rail or a pin header name on a board, as specified by the + * GPIO chip, may be empty (i.e. name[0] == '\0') + * @consumer: a functional name for the consumer of this GPIO line as set + * by whatever is using it, will be empty if there is no current user but + * may also be empty if the consumer doesn't set this up + * @offset: the local offset on this GPIO chip, fill this in when + * requesting the line information from the kernel + * @num_attrs: the number of attributes in @attrs + * @flags: flags for this GPIO line, with values from &enum + * gpio_v2_line_flag, such as %GPIO_V2_LINE_FLAG_ACTIVE_LOW, + * %GPIO_V2_LINE_FLAG_OUTPUT etc, added together + * @attrs: the configuration attributes associated with the line + * @padding: reserved for future use + */ +struct gpio_v2_line_info { +	char name[GPIO_MAX_NAME_SIZE]; +	char consumer[GPIO_MAX_NAME_SIZE]; +	__u32 offset; +	__u32 num_attrs; +	__aligned_u64 flags; +	struct gpio_v2_line_attribute attrs[GPIO_V2_LINE_NUM_ATTRS_MAX]; +	/* Space reserved for future use. */ +	__u32 padding[4]; +}; + +/** + * enum gpio_v2_line_changed_type - &struct gpio_v2_line_changed.event_type + * values + * @GPIO_V2_LINE_CHANGED_REQUESTED: line has been requested + * @GPIO_V2_LINE_CHANGED_RELEASED: line has been released + * @GPIO_V2_LINE_CHANGED_CONFIG: line has been reconfigured + */ +enum gpio_v2_line_changed_type { +	GPIO_V2_LINE_CHANGED_REQUESTED	= 1, +	GPIO_V2_LINE_CHANGED_RELEASED	= 2, +	GPIO_V2_LINE_CHANGED_CONFIG	= 3, +}; + +/** + * struct gpio_v2_line_info_changed - Information about a change in status + * of a GPIO line + * @info: updated line information + * @timestamp_ns: estimate of time of status change occurrence, in nanoseconds + * @event_type: the type of change with a value from &enum + * gpio_v2_line_changed_type + * @padding: reserved for future use + */ +struct gpio_v2_line_info_changed { +	struct gpio_v2_line_info info; +	__aligned_u64 timestamp_ns; +	__u32 event_type; +	/* Pad struct to 64-bit boundary and reserve space for future use. */ +	__u32 padding[5]; +}; + +/** + * enum gpio_v2_line_event_id - &struct gpio_v2_line_event.id values + * @GPIO_V2_LINE_EVENT_RISING_EDGE: event triggered by a rising edge + * @GPIO_V2_LINE_EVENT_FALLING_EDGE: event triggered by a falling edge + */ +enum gpio_v2_line_event_id { +	GPIO_V2_LINE_EVENT_RISING_EDGE	= 1, +	GPIO_V2_LINE_EVENT_FALLING_EDGE	= 2, +}; + +/** + * struct gpio_v2_line_event - The actual event being pushed to userspace + * @timestamp_ns: best estimate of time of event occurrence, in nanoseconds + * @id: event identifier with value from &enum gpio_v2_line_event_id + * @offset: the offset of the line that triggered the event + * @seqno: the sequence number for this event in the sequence of events for + * all the lines in this line request + * @line_seqno: the sequence number for this event in the sequence of + * events on this particular line + * @padding: reserved for future use + * + * By default the @timestamp_ns is read from %CLOCK_MONOTONIC and is + * intended to allow the accurate measurement of the time between events. + * It does not provide the wall-clock time. + * + * If the %GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME flag is set then the + * @timestamp_ns is read from %CLOCK_REALTIME. + * + * If the %GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE flag is set then the + * @timestamp_ns is provided by the hardware timestamping engine (HTE) + * subsystem. + */ +struct gpio_v2_line_event { +	__aligned_u64 timestamp_ns; +	__u32 id; +	__u32 offset; +	__u32 seqno; +	__u32 line_seqno; +	/* Space reserved for future use. */ +	__u32 padding[6]; +}; + +/* + * ABI v1 + * + * This version of the ABI is deprecated. + * Use the latest version of the ABI, defined above, instead. + */ +  /* Informational flags */  #define GPIOLINE_FLAG_KERNEL		(1UL << 0) /* Line used by the kernel */  #define GPIOLINE_FLAG_IS_OUT		(1UL << 1) @@ -44,16 +327,19 @@ struct gpiochip_info {   * @flags: various flags for this line   * @name: the name of this GPIO line, such as the output pin of the line on the   * chip, a rail or a pin header name on a board, as specified by the gpio - * chip, may be empty + * chip, may be empty (i.e. name[0] == '\0')   * @consumer: a functional name for the consumer of this GPIO line as set by   * whatever is using it, will be empty if there is no current user but may   * also be empty if the consumer doesn't set this up + * + * Note: This struct is part of ABI v1 and is deprecated. + * Use ABI v2 and &struct gpio_v2_line_info instead.   */  struct gpioline_info {  	__u32 line_offset;  	__u32 flags; -	char name[32]; -	char consumer[32]; +	char name[GPIO_MAX_NAME_SIZE]; +	char consumer[GPIO_MAX_NAME_SIZE];  };  /* Maximum number of requested handles */ @@ -71,14 +357,18 @@ enum {   * of a GPIO line   * @info: updated line information   * @timestamp: estimate of time of status change occurrence, in nanoseconds - * @event_type: one of GPIOLINE_CHANGED_REQUESTED, GPIOLINE_CHANGED_RELEASED - * and GPIOLINE_CHANGED_CONFIG + * @event_type: one of %GPIOLINE_CHANGED_REQUESTED, + * %GPIOLINE_CHANGED_RELEASED and %GPIOLINE_CHANGED_CONFIG + * @padding: reserved for future use   * - * Note: struct gpioline_info embedded here has 32-bit alignment on its own, + * The &struct gpioline_info embedded here has 32-bit alignment on its own,   * but it works fine with 64-bit alignment too. With its 72 byte size, we can   * guarantee there are no implicit holes between it and subsequent members.   * The 20-byte padding at the end makes sure we don't add any implicit padding   * at the end of the structure on 64-bit architectures. + * + * Note: This struct is part of ABI v1 and is deprecated. + * Use ABI v2 and &struct gpio_v2_line_info_changed instead.   */  struct gpioline_info_changed {  	struct gpioline_info info; @@ -102,28 +392,30 @@ struct gpioline_info_changed {   * @lineoffsets: an array of desired lines, specified by offset index for the   * associated GPIO device   * @flags: desired flags for the desired GPIO lines, such as - * GPIOHANDLE_REQUEST_OUTPUT, GPIOHANDLE_REQUEST_ACTIVE_LOW etc, OR:ed + * %GPIOHANDLE_REQUEST_OUTPUT, %GPIOHANDLE_REQUEST_ACTIVE_LOW etc, added   * together. Note that even if multiple lines are requested, the same flags   * must be applicable to all of them, if you want lines with individual   * flags set, request them one by one. It is possible to select   * a batch of input or output lines, but they must all have the same   * characteristics, i.e. all inputs or all outputs, all active low etc - * @default_values: if the GPIOHANDLE_REQUEST_OUTPUT is set for a requested - * line, this specifies the default output value, should be 0 (low) or - * 1 (high), anything else than 0 or 1 will be interpreted as 1 (high) + * @default_values: if the %GPIOHANDLE_REQUEST_OUTPUT is set for a requested + * line, this specifies the default output value, should be 0 (inactive) or + * 1 (active).  Anything other than 0 or 1 will be interpreted as active.   * @consumer_label: a desired consumer label for the selected GPIO line(s)   * such as "my-bitbanged-relay"   * @lines: number of lines requested in this request, i.e. the number of   * valid fields in the above arrays, set to 1 to request a single line - * @fd: if successful this field will contain a valid anonymous file handle - * after a GPIO_GET_LINEHANDLE_IOCTL operation, zero or negative value - * means error + * @fd: after a successful %GPIO_GET_LINEHANDLE_IOCTL operation, contains + * a valid anonymous file descriptor representing the request + * + * Note: This struct is part of ABI v1 and is deprecated. + * Use ABI v2 and &struct gpio_v2_line_request instead.   */  struct gpiohandle_request {  	__u32 lineoffsets[GPIOHANDLES_MAX];  	__u32 flags;  	__u8 default_values[GPIOHANDLES_MAX]; -	char consumer_label[32]; +	char consumer_label[GPIO_MAX_NAME_SIZE];  	__u32 lines;  	int fd;  }; @@ -131,12 +423,15 @@ struct gpiohandle_request {  /**   * struct gpiohandle_config - Configuration for a GPIO handle request   * @flags: updated flags for the requested GPIO lines, such as - * GPIOHANDLE_REQUEST_OUTPUT, GPIOHANDLE_REQUEST_ACTIVE_LOW etc, OR:ed + * %GPIOHANDLE_REQUEST_OUTPUT, %GPIOHANDLE_REQUEST_ACTIVE_LOW etc, added   * together - * @default_values: if the GPIOHANDLE_REQUEST_OUTPUT is set in flags, - * this specifies the default output value, should be 0 (low) or - * 1 (high), anything else than 0 or 1 will be interpreted as 1 (high) + * @default_values: if the %GPIOHANDLE_REQUEST_OUTPUT is set in flags, + * this specifies the default output value, should be 0 (inactive) or + * 1 (active).  Anything other than 0 or 1 will be interpreted as active.   * @padding: reserved for future use and should be zero filled + * + * Note: This struct is part of ABI v1 and is deprecated. + * Use ABI v2 and &struct gpio_v2_line_config instead.   */  struct gpiohandle_config {  	__u32 flags; @@ -144,21 +439,20 @@ struct gpiohandle_config {  	__u32 padding[4]; /* padding for future use */  }; -#define GPIOHANDLE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0a, struct gpiohandle_config) -  /**   * struct gpiohandle_data - Information of values on a GPIO handle   * @values: when getting the state of lines this contains the current   * state of a line, when setting the state of lines these should contain - * the desired target state + * the desired target state.  States are 0 (inactive) or 1 (active). + * When setting, anything other than 0 or 1 will be interpreted as active. + * + * Note: This struct is part of ABI v1 and is deprecated. + * Use ABI v2 and &struct gpio_v2_line_values instead.   */  struct gpiohandle_data {  	__u8 values[GPIOHANDLES_MAX];  }; -#define GPIOHANDLE_GET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x08, struct gpiohandle_data) -#define GPIOHANDLE_SET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x09, struct gpiohandle_data) -  /* Eventrequest flags */  #define GPIOEVENT_REQUEST_RISING_EDGE	(1UL << 0)  #define GPIOEVENT_REQUEST_FALLING_EDGE	(1UL << 1) @@ -169,24 +463,26 @@ struct gpiohandle_data {   * @lineoffset: the desired line to subscribe to events from, specified by   * offset index for the associated GPIO device   * @handleflags: desired handle flags for the desired GPIO line, such as - * GPIOHANDLE_REQUEST_ACTIVE_LOW or GPIOHANDLE_REQUEST_OPEN_DRAIN + * %GPIOHANDLE_REQUEST_ACTIVE_LOW or %GPIOHANDLE_REQUEST_OPEN_DRAIN   * @eventflags: desired flags for the desired GPIO event line, such as - * GPIOEVENT_REQUEST_RISING_EDGE or GPIOEVENT_REQUEST_FALLING_EDGE + * %GPIOEVENT_REQUEST_RISING_EDGE or %GPIOEVENT_REQUEST_FALLING_EDGE   * @consumer_label: a desired consumer label for the selected GPIO line(s)   * such as "my-listener" - * @fd: if successful this field will contain a valid anonymous file handle - * after a GPIO_GET_LINEEVENT_IOCTL operation, zero or negative value - * means error + * @fd: after a successful %GPIO_GET_LINEEVENT_IOCTL operation, contains a + * valid anonymous file descriptor representing the request + * + * Note: This struct is part of ABI v1 and is deprecated. + * Use ABI v2 and &struct gpio_v2_line_request instead.   */  struct gpioevent_request {  	__u32 lineoffset;  	__u32 handleflags;  	__u32 eventflags; -	char consumer_label[32]; +	char consumer_label[GPIO_MAX_NAME_SIZE];  	int fd;  }; -/** +/*   * GPIO event types   */  #define GPIOEVENT_EVENT_RISING_EDGE 0x01 @@ -195,18 +491,44 @@ struct gpioevent_request {  /**   * struct gpioevent_data - The actual event being pushed to userspace   * @timestamp: best estimate of time of event occurrence, in nanoseconds - * @id: event identifier + * @id: event identifier, one of %GPIOEVENT_EVENT_RISING_EDGE or + *  %GPIOEVENT_EVENT_FALLING_EDGE + * + * Note: This struct is part of ABI v1 and is deprecated. + * Use ABI v2 and &struct gpio_v2_line_event instead.   */  struct gpioevent_data {  	__u64 timestamp;  	__u32 id;  }; +/* + * v1 and v2 ioctl()s + */  #define GPIO_GET_CHIPINFO_IOCTL _IOR(0xB4, 0x01, struct gpiochip_info) +#define GPIO_GET_LINEINFO_UNWATCH_IOCTL _IOWR(0xB4, 0x0C, __u32) + +/* + * v2 ioctl()s + */ +#define GPIO_V2_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x05, struct gpio_v2_line_info) +#define GPIO_V2_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x06, struct gpio_v2_line_info) +#define GPIO_V2_GET_LINE_IOCTL _IOWR(0xB4, 0x07, struct gpio_v2_line_request) +#define GPIO_V2_LINE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0D, struct gpio_v2_line_config) +#define GPIO_V2_LINE_GET_VALUES_IOCTL _IOWR(0xB4, 0x0E, struct gpio_v2_line_values) +#define GPIO_V2_LINE_SET_VALUES_IOCTL _IOWR(0xB4, 0x0F, struct gpio_v2_line_values) + +/* + * v1 ioctl()s + * + * These ioctl()s are deprecated.  Use the v2 equivalent instead. + */  #define GPIO_GET_LINEINFO_IOCTL _IOWR(0xB4, 0x02, struct gpioline_info) -#define GPIO_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x0b, struct gpioline_info) -#define GPIO_GET_LINEINFO_UNWATCH_IOCTL _IOWR(0xB4, 0x0c, __u32)  #define GPIO_GET_LINEHANDLE_IOCTL _IOWR(0xB4, 0x03, struct gpiohandle_request)  #define GPIO_GET_LINEEVENT_IOCTL _IOWR(0xB4, 0x04, struct gpioevent_request) +#define GPIOHANDLE_GET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x08, struct gpiohandle_data) +#define GPIOHANDLE_SET_LINE_VALUES_IOCTL _IOWR(0xB4, 0x09, struct gpiohandle_data) +#define GPIOHANDLE_SET_CONFIG_IOCTL _IOWR(0xB4, 0x0A, struct gpiohandle_config) +#define GPIO_GET_LINEINFO_WATCH_IOCTL _IOWR(0xB4, 0x0B, struct gpioline_info)  #endif /* _UAPI_GPIO_H_ */ diff --git a/include/uapi/linux/gsmmux.h b/include/uapi/linux/gsmmux.h index cb8693b39cb7..3a93f17ca943 100644 --- a/include/uapi/linux/gsmmux.h +++ b/include/uapi/linux/gsmmux.h @@ -1,11 +1,47 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* Copyright (c) 2022/23 Siemens Mobility GmbH */  #ifndef _LINUX_GSMMUX_H  #define _LINUX_GSMMUX_H +#include <linux/const.h>  #include <linux/if.h>  #include <linux/ioctl.h>  #include <linux/types.h> +/* + * flags definition for n_gsm + * + * Used by: + * struct gsm_config_ext.flags + * struct gsm_dlci_config.flags + */ +/* Forces a DLCI reset if set. Otherwise, a DLCI reset is only done if + * incompatible settings were provided. Always cleared on retrieval. + */ +#define GSM_FL_RESTART	_BITUL(0) + +/** + * struct gsm_config - n_gsm basic configuration parameters + * + * This structure is used in combination with GSMIOC_GETCONF and GSMIOC_SETCONF + * to retrieve and set the basic parameters of an n_gsm ldisc. + * struct gsm_config_ext can be used to configure extended ldisc parameters. + * + * All timers are in units of 1/100th of a second. + * + * @adaption:      Convergence layer type + * @encapsulation: Framing (0 = basic option, 1 = advanced option) + * @initiator:     Initiator or responder + * @t1:            Acknowledgment timer + * @t2:            Response timer for multiplexer control channel + * @t3:            Response timer for wake-up procedure + * @n2:            Maximum number of retransmissions + * @mru:           Maximum incoming frame payload size + * @mtu:           Maximum outgoing frame payload size + * @k:             Window size + * @i:             Frame type (1 = UIH, 2 = UI) + * @unused:        Can not be used + */  struct gsm_config  {  	unsigned int adaption; @@ -19,19 +55,32 @@ struct gsm_config  	unsigned int mtu;  	unsigned int k;  	unsigned int i; -	unsigned int unused[8];		/* Padding for expansion without -					   breaking stuff */ +	unsigned int unused[8];  };  #define GSMIOC_GETCONF		_IOR('G', 0, struct gsm_config)  #define GSMIOC_SETCONF		_IOW('G', 1, struct gsm_config) +/** + * struct gsm_netconfig - n_gsm network configuration parameters + * + * This structure is used in combination with GSMIOC_ENABLE_NET and + * GSMIOC_DISABLE_NET to enable or disable a network data connection + * over a mux virtual tty channel. This is for modems that support + * data connections with raw IP frames instead of PPP. + * + * @adaption: Adaption to use in network mode. + * @protocol: Protocol to use - only ETH_P_IP supported. + * @unused2:  Can not be used. + * @if_name:  Interface name format string. + * @unused:   Can not be used. + */  struct gsm_netconfig { -	unsigned int adaption;  /* Adaption to use in network mode */ -	unsigned short protocol;/* Protocol to use - only ETH_P_IP supported */ +	unsigned int adaption; +	unsigned short protocol;  	unsigned short unused2; -	char if_name[IFNAMSIZ];	/* interface name format string */ -	__u8 unused[28];        /* For future use */ +	char if_name[IFNAMSIZ]; +	__u8 unused[28];  };  #define GSMIOC_ENABLE_NET      _IOW('G', 2, struct gsm_netconfig) @@ -40,4 +89,60 @@ struct gsm_netconfig {  /* get the base tty number for a configured gsmmux tty */  #define GSMIOC_GETFIRST		_IOR('G', 4, __u32) +/** + * struct gsm_config_ext - n_gsm extended configuration parameters + * + * This structure is used in combination with GSMIOC_GETCONF_EXT and + * GSMIOC_SETCONF_EXT to retrieve and set the extended parameters of an + * n_gsm ldisc. + * + * All timers are in units of 1/100th of a second. + * + * @keep_alive:  Control channel keep-alive in 1/100th of a second (0 to disable). + * @wait_config: Wait for DLCI config before opening virtual link? + * @flags:       Mux specific flags. + * @reserved:    For future use, must be initialized to zero. + */ +struct gsm_config_ext { +	__u32 keep_alive; +	__u32 wait_config; +	__u32 flags; +	__u32 reserved[5]; +}; + +#define GSMIOC_GETCONF_EXT	_IOR('G', 5, struct gsm_config_ext) +#define GSMIOC_SETCONF_EXT	_IOW('G', 6, struct gsm_config_ext) + +/** + * struct gsm_dlci_config - n_gsm channel configuration parameters + * + * This structure is used in combination with GSMIOC_GETCONF_DLCI and + * GSMIOC_SETCONF_DLCI to retrieve and set the channel specific parameters + * of an n_gsm ldisc. + * + * Set the channel accordingly before calling GSMIOC_GETCONF_DLCI. + * + * @channel:  DLCI (0 for the associated DLCI). + * @adaption: Convergence layer type. + * @mtu:      Maximum transfer unit. + * @priority: Priority (0 for default value). + * @i:        Frame type (1 = UIH, 2 = UI). + * @k:        Window size (0 for default value). + * @flags:    DLCI specific flags. + * @reserved: For future use, must be initialized to zero. + */ +struct gsm_dlci_config { +	__u32 channel; +	__u32 adaption; +	__u32 mtu; +	__u32 priority; +	__u32 i; +	__u32 k; +	__u32 flags; +	__u32 reserved[7]; +}; + +#define GSMIOC_GETCONF_DLCI	_IOWR('G', 7, struct gsm_dlci_config) +#define GSMIOC_SETCONF_DLCI	_IOW('G', 8, struct gsm_dlci_config) +  #endif diff --git a/include/uapi/linux/gtp.h b/include/uapi/linux/gtp.h index c7d66755d212..40f5388d6de0 100644 --- a/include/uapi/linux/gtp.h +++ b/include/uapi/linux/gtp.h @@ -2,10 +2,13 @@  #ifndef _UAPI_LINUX_GTP_H_  #define _UAPI_LINUX_GTP_H_ +#define GTP_GENL_MCGRP_NAME	"gtp" +  enum gtp_genl_cmds {  	GTP_CMD_NEWPDP,  	GTP_CMD_DELPDP,  	GTP_CMD_GETPDP, +	GTP_CMD_ECHOREQ,  	GTP_CMD_MAX,  }; @@ -28,8 +31,11 @@ enum gtp_attrs {  	GTPA_I_TEI,	/* for GTPv1 only */  	GTPA_O_TEI,	/* for GTPv1 only */  	GTPA_PAD, +	GTPA_PEER_ADDR6, +	GTPA_MS_ADDR6, +	GTPA_FAMILY,  	__GTPA_MAX,  }; -#define GTPA_MAX (__GTPA_MAX + 1) +#define GTPA_MAX (__GTPA_MAX - 1)  #endif /* _UAPI_LINUX_GTP_H_ */ diff --git a/include/uapi/linux/handshake.h b/include/uapi/linux/handshake.h new file mode 100644 index 000000000000..662e7de46c54 --- /dev/null +++ b/include/uapi/linux/handshake.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/handshake.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_HANDSHAKE_H +#define _UAPI_LINUX_HANDSHAKE_H + +#define HANDSHAKE_FAMILY_NAME		"handshake" +#define HANDSHAKE_FAMILY_VERSION	1 + +enum handshake_handler_class { +	HANDSHAKE_HANDLER_CLASS_NONE, +	HANDSHAKE_HANDLER_CLASS_TLSHD, +	HANDSHAKE_HANDLER_CLASS_MAX, +}; + +enum handshake_msg_type { +	HANDSHAKE_MSG_TYPE_UNSPEC, +	HANDSHAKE_MSG_TYPE_CLIENTHELLO, +	HANDSHAKE_MSG_TYPE_SERVERHELLO, +}; + +enum handshake_auth { +	HANDSHAKE_AUTH_UNSPEC, +	HANDSHAKE_AUTH_UNAUTH, +	HANDSHAKE_AUTH_PSK, +	HANDSHAKE_AUTH_X509, +}; + +enum { +	HANDSHAKE_A_X509_CERT = 1, +	HANDSHAKE_A_X509_PRIVKEY, + +	__HANDSHAKE_A_X509_MAX, +	HANDSHAKE_A_X509_MAX = (__HANDSHAKE_A_X509_MAX - 1) +}; + +enum { +	HANDSHAKE_A_ACCEPT_SOCKFD = 1, +	HANDSHAKE_A_ACCEPT_HANDLER_CLASS, +	HANDSHAKE_A_ACCEPT_MESSAGE_TYPE, +	HANDSHAKE_A_ACCEPT_TIMEOUT, +	HANDSHAKE_A_ACCEPT_AUTH_MODE, +	HANDSHAKE_A_ACCEPT_PEER_IDENTITY, +	HANDSHAKE_A_ACCEPT_CERTIFICATE, +	HANDSHAKE_A_ACCEPT_PEERNAME, +	HANDSHAKE_A_ACCEPT_KEYRING, + +	__HANDSHAKE_A_ACCEPT_MAX, +	HANDSHAKE_A_ACCEPT_MAX = (__HANDSHAKE_A_ACCEPT_MAX - 1) +}; + +enum { +	HANDSHAKE_A_DONE_STATUS = 1, +	HANDSHAKE_A_DONE_SOCKFD, +	HANDSHAKE_A_DONE_REMOTE_AUTH, + +	__HANDSHAKE_A_DONE_MAX, +	HANDSHAKE_A_DONE_MAX = (__HANDSHAKE_A_DONE_MAX - 1) +}; + +enum { +	HANDSHAKE_CMD_READY = 1, +	HANDSHAKE_CMD_ACCEPT, +	HANDSHAKE_CMD_DONE, + +	__HANDSHAKE_CMD_MAX, +	HANDSHAKE_CMD_MAX = (__HANDSHAKE_CMD_MAX - 1) +}; + +#define HANDSHAKE_MCGRP_NONE	"none" +#define HANDSHAKE_MCGRP_TLSHD	"tlshd" + +#endif /* _UAPI_LINUX_HANDSHAKE_H */ diff --git a/include/uapi/linux/hash_info.h b/include/uapi/linux/hash_info.h index 74a8609fcb4d..0af23ec196d8 100644 --- a/include/uapi/linux/hash_info.h +++ b/include/uapi/linux/hash_info.h @@ -35,6 +35,9 @@ enum hash_algo {  	HASH_ALGO_SM3_256,  	HASH_ALGO_STREEBOG_256,  	HASH_ALGO_STREEBOG_512, +	HASH_ALGO_SHA3_256, +	HASH_ALGO_SHA3_384, +	HASH_ALGO_SHA3_512,  	HASH_ALGO__LAST  }; diff --git a/include/uapi/linux/hid.h b/include/uapi/linux/hid.h index b34492a87a8a..a4dcb34386e3 100644 --- a/include/uapi/linux/hid.h +++ b/include/uapi/linux/hid.h @@ -43,15 +43,29 @@  #define USB_INTERFACE_PROTOCOL_MOUSE	2  /* + * HID report types --- Ouch! HID spec says 1 2 3! + */ + +enum hid_report_type { +	HID_INPUT_REPORT		= 0, +	HID_OUTPUT_REPORT		= 1, +	HID_FEATURE_REPORT		= 2, + +	HID_REPORT_TYPES, +}; + +/*   * HID class requests   */ -#define HID_REQ_GET_REPORT		0x01 -#define HID_REQ_GET_IDLE		0x02 -#define HID_REQ_GET_PROTOCOL		0x03 -#define HID_REQ_SET_REPORT		0x09 -#define HID_REQ_SET_IDLE		0x0A -#define HID_REQ_SET_PROTOCOL		0x0B +enum hid_class_request { +	HID_REQ_GET_REPORT		= 0x01, +	HID_REQ_GET_IDLE		= 0x02, +	HID_REQ_GET_PROTOCOL		= 0x03, +	HID_REQ_SET_REPORT		= 0x09, +	HID_REQ_SET_IDLE		= 0x0A, +	HID_REQ_SET_PROTOCOL		= 0x0B, +};  /*   * HID class descriptor types diff --git a/include/uapi/linux/hidraw.h b/include/uapi/linux/hidraw.h index 4913539e5bcc..d5ee269864e0 100644 --- a/include/uapi/linux/hidraw.h +++ b/include/uapi/linux/hidraw.h @@ -40,6 +40,13 @@ struct hidraw_devinfo {  #define HIDIOCSFEATURE(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len)  #define HIDIOCGFEATURE(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)  #define HIDIOCGRAWUNIQ(len)     _IOC(_IOC_READ, 'H', 0x08, len) +/* The first byte of SINPUT and GINPUT is the report number */ +#define HIDIOCSINPUT(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x09, len) +#define HIDIOCGINPUT(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x0A, len) +/* The first byte of SOUTPUT and GOUTPUT is the report number */ +#define HIDIOCSOUTPUT(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x0B, len) +#define HIDIOCGOUTPUT(len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x0C, len) +#define HIDIOCREVOKE	      _IOW('H', 0x0D, int) /* Revoke device access */  #define HIDRAW_FIRST_MINOR 0  #define HIDRAW_MAX_DEVICES 64 diff --git a/include/uapi/linux/hsi/cs-protocol.h b/include/uapi/linux/hsi/cs-protocol.h index c7f6e7672cb5..07c3bfb67463 100644 --- a/include/uapi/linux/hsi/cs-protocol.h +++ b/include/uapi/linux/hsi/cs-protocol.h @@ -6,20 +6,6 @@   *   * Contact: Kai Vehmanen <kai.vehmanen@nokia.com>   * Original author: Peter Ujfalusi <peter.ujfalusi@nokia.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA   */  #ifndef _CS_PROTOCOL_H diff --git a/include/uapi/linux/hsi/hsi_char.h b/include/uapi/linux/hsi/hsi_char.h index 91623b0398b1..5ef72f0daf94 100644 --- a/include/uapi/linux/hsi/hsi_char.h +++ b/include/uapi/linux/hsi/hsi_char.h @@ -5,20 +5,6 @@   * Copyright (C) 2010 Nokia Corporation. All rights reserved.   *   * Contact: Andras Domokos <andras.domokos at nokia.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA   */  #ifndef __HSI_CHAR_H diff --git a/include/uapi/linux/hw_breakpoint.h b/include/uapi/linux/hw_breakpoint.h index 965e4d8606d8..1575d3ca6f0d 100644 --- a/include/uapi/linux/hw_breakpoint.h +++ b/include/uapi/linux/hw_breakpoint.h @@ -22,14 +22,4 @@ enum {  	HW_BREAKPOINT_INVALID   = HW_BREAKPOINT_RW | HW_BREAKPOINT_X,  }; -enum bp_type_idx { -	TYPE_INST 	= 0, -#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS -	TYPE_DATA	= 0, -#else -	TYPE_DATA	= 1, -#endif -	TYPE_MAX -}; -  #endif /* _UAPI_LINUX_HW_BREAKPOINT_H */ diff --git a/include/uapi/linux/hyperv.h b/include/uapi/linux/hyperv.h index 6135d92e0d47..aaa502a7bff4 100644 --- a/include/uapi/linux/hyperv.h +++ b/include/uapi/linux/hyperv.h @@ -26,7 +26,7 @@  #ifndef _UAPI_HYPERV_H  #define _UAPI_HYPERV_H -#include <linux/uuid.h> +#include <linux/types.h>  /*   * Framework version for util services. @@ -90,6 +90,17 @@ struct hv_vss_check_dm_info {  	__u32 flags;  } __attribute__((packed)); +/* + * struct hv_vss_msg encodes the fields that the Linux VSS + * driver accesses. However, FREEZE messages from Hyper-V contain + * additional LUN information that Linux doesn't use and are not + * represented in struct hv_vss_msg. A received FREEZE message may + * be as large as 6,260 bytes, so the driver must allocate at least + * that much space, not sizeof(struct hv_vss_msg). Other messages + * such as AUTO_RECOVER may be as large as 12,500 bytes. However, + * because the Linux VSS driver responds that it doesn't support + * auto-recovery, it should not receive such messages. + */  struct hv_vss_msg {  	union {  		struct hv_vss_hdr vss_hdr; diff --git a/include/uapi/linux/i2c-dev.h b/include/uapi/linux/i2c-dev.h index 85f8047afcf2..1c4cec4ddd84 100644 --- a/include/uapi/linux/i2c-dev.h +++ b/include/uapi/linux/i2c-dev.h @@ -1,25 +1,10 @@  /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */  /* -    i2c-dev.h - i2c-bus driver, char device interface - -    Copyright (C) 1995-97 Simon G. Vogl -    Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl> - -    This program is free software; you can redistribute it and/or modify -    it under the terms of the GNU General Public License as published by -    the Free Software Foundation; either version 2 of the License, or -    (at your option) any later version. - -    This program is distributed in the hope that it will be useful, -    but WITHOUT ANY WARRANTY; without even the implied warranty of -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -    GNU General Public License for more details. - -    You should have received a copy of the GNU General Public License -    along with this program; if not, write to the Free Software -    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -    MA 02110-1301 USA. -*/ + * i2c-dev.h - I2C bus char device interface + * + * Copyright (C) 1995-97 Simon G. Vogl + * Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl> + */  #ifndef _UAPI_LINUX_I2C_DEV_H  #define _UAPI_LINUX_I2C_DEV_H diff --git a/include/uapi/linux/i2c.h b/include/uapi/linux/i2c.h index f71a1751cacf..a2db2a56c8b0 100644 --- a/include/uapi/linux/i2c.h +++ b/include/uapi/linux/i2c.h @@ -1,29 +1,11 @@  /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ -/* ------------------------------------------------------------------------- */ -/*									     */ -/* i2c.h - definitions for the i2c-bus interface			     */ -/*									     */ -/* ------------------------------------------------------------------------- */ -/*   Copyright (C) 1995-2000 Simon G. Vogl - -    This program is free software; you can redistribute it and/or modify -    it under the terms of the GNU General Public License as published by -    the Free Software Foundation; either version 2 of the License, or -    (at your option) any later version. - -    This program is distributed in the hope that it will be useful, -    but WITHOUT ANY WARRANTY; without even the implied warranty of -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -    GNU General Public License for more details. - -    You should have received a copy of the GNU General Public License -    along with this program; if not, write to the Free Software -    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -    MA 02110-1301 USA.							     */ -/* ------------------------------------------------------------------------- */ - -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and -   Frodo Looijaard <frodol@dds.nl> */ +/* + * i2c.h - definitions for the I2C bus interface + * + * Copyright (C) 1995-2000 Simon G. Vogl + * With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and + * Frodo Looijaard <frodol@dds.nl> + */  #ifndef _UAPI_LINUX_I2C_H  #define _UAPI_LINUX_I2C_H @@ -32,18 +14,42 @@  /**   * struct i2c_msg - an I2C transaction segment beginning with START - * @addr: Slave address, either seven or ten bits.  When this is a ten - *	bit address, I2C_M_TEN must be set in @flags and the adapter - *	must support I2C_FUNC_10BIT_ADDR. - * @flags: I2C_M_RD is handled by all adapters.  No other flags may be - *	provided unless the adapter exported the relevant I2C_FUNC_* - *	flags through i2c_check_functionality(). - * @len: Number of data bytes in @buf being read from or written to the - *	I2C slave address.  For read transactions where I2C_M_RECV_LEN - *	is set, the caller guarantees that this buffer can hold up to - *	32 bytes in addition to the initial length byte sent by the - *	slave (plus, if used, the SMBus PEC); and this value will be - *	incremented by the number of block data bytes received. + * + * @addr: Slave address, either 7 or 10 bits. When this is a 10 bit address, + *   %I2C_M_TEN must be set in @flags and the adapter must support + *   %I2C_FUNC_10BIT_ADDR. + * + * @flags: + *   Supported by all adapters: + *   %I2C_M_RD: read data (from slave to master). Guaranteed to be 0x0001! If + *   not set, the transaction is interpreted as write. + * + *   Optional: + *   %I2C_M_DMA_SAFE: the buffer of this message is DMA safe. Makes only sense + *     in kernelspace, because userspace buffers are copied anyway + * + *   Only if I2C_FUNC_10BIT_ADDR is set: + *   %I2C_M_TEN: this is a 10 bit chip address + * + *   Only if I2C_FUNC_SMBUS_READ_BLOCK_DATA is set: + *   %I2C_M_RECV_LEN: message length will be first received byte + * + *   Only if I2C_FUNC_NOSTART is set: + *   %I2C_M_NOSTART: skip repeated start sequence + + *   Only if I2C_FUNC_PROTOCOL_MANGLING is set: + *   %I2C_M_NO_RD_ACK: in a read message, master ACK/NACK bit is skipped + *   %I2C_M_IGNORE_NAK: treat NACK from client as ACK + *   %I2C_M_REV_DIR_ADDR: toggles the Rd/Wr bit + *   %I2C_M_STOP: force a STOP condition after the message + * + * @len: Number of data bytes in @buf being read from or written to the I2C + *   slave address. For read transactions where %I2C_M_RECV_LEN is set, the + *   caller guarantees that this buffer can hold up to %I2C_SMBUS_BLOCK_MAX + *   bytes in addition to the initial length byte sent by the slave (plus, + *   if used, the SMBus PEC); and this value will be incremented by the number + *   of block data bytes received. + *   * @buf: The buffer into which data is read, or from which it's written.   *   * An i2c_msg is the low level representation of one segment of an I2C @@ -60,40 +66,36 @@   * group, it is followed by a STOP.  Otherwise it is followed by the next   * @i2c_msg transaction segment, beginning with a (repeated) START.   * - * Alternatively, when the adapter supports I2C_FUNC_PROTOCOL_MANGLING then + * Alternatively, when the adapter supports %I2C_FUNC_PROTOCOL_MANGLING then   * passing certain @flags may have changed those standard protocol behaviors.   * Those flags are only for use with broken/nonconforming slaves, and with - * adapters which are known to support the specific mangling options they - * need (one or more of IGNORE_NAK, NO_RD_ACK, NOSTART, and REV_DIR_ADDR). + * adapters which are known to support the specific mangling options they need.   */  struct i2c_msg { -	__u16 addr;	/* slave address			*/ +	__u16 addr;  	__u16 flags; -#define I2C_M_RD		0x0001	/* read data, from slave to master */ -					/* I2C_M_RD is guaranteed to be 0x0001! */ -#define I2C_M_TEN		0x0010	/* this is a ten bit chip address */ -#define I2C_M_DMA_SAFE		0x0200	/* the buffer of this message is DMA safe */ -					/* makes only sense in kernelspace */ -					/* userspace buffers are copied anyway */ -#define I2C_M_RECV_LEN		0x0400	/* length will be first received byte */ -#define I2C_M_NO_RD_ACK		0x0800	/* if I2C_FUNC_PROTOCOL_MANGLING */ -#define I2C_M_IGNORE_NAK	0x1000	/* if I2C_FUNC_PROTOCOL_MANGLING */ -#define I2C_M_REV_DIR_ADDR	0x2000	/* if I2C_FUNC_PROTOCOL_MANGLING */ -#define I2C_M_NOSTART		0x4000	/* if I2C_FUNC_NOSTART */ -#define I2C_M_STOP		0x8000	/* if I2C_FUNC_PROTOCOL_MANGLING */ -	__u16 len;		/* msg length				*/ -	__u8 *buf;		/* pointer to msg data			*/ +#define I2C_M_RD		0x0001	/* guaranteed to be 0x0001! */ +#define I2C_M_TEN		0x0010	/* use only if I2C_FUNC_10BIT_ADDR */ +#define I2C_M_DMA_SAFE		0x0200	/* use only in kernel space */ +#define I2C_M_RECV_LEN		0x0400	/* use only if I2C_FUNC_SMBUS_READ_BLOCK_DATA */ +#define I2C_M_NO_RD_ACK		0x0800	/* use only if I2C_FUNC_PROTOCOL_MANGLING */ +#define I2C_M_IGNORE_NAK	0x1000	/* use only if I2C_FUNC_PROTOCOL_MANGLING */ +#define I2C_M_REV_DIR_ADDR	0x2000	/* use only if I2C_FUNC_PROTOCOL_MANGLING */ +#define I2C_M_NOSTART		0x4000	/* use only if I2C_FUNC_NOSTART */ +#define I2C_M_STOP		0x8000	/* use only if I2C_FUNC_PROTOCOL_MANGLING */ +	__u16 len; +	__u8 *buf;  };  /* To determine what functionality is present */  #define I2C_FUNC_I2C			0x00000001 -#define I2C_FUNC_10BIT_ADDR		0x00000002 -#define I2C_FUNC_PROTOCOL_MANGLING	0x00000004 /* I2C_M_IGNORE_NAK etc. */ +#define I2C_FUNC_10BIT_ADDR		0x00000002 /* required for I2C_M_TEN */ +#define I2C_FUNC_PROTOCOL_MANGLING	0x00000004 /* required for I2C_M_IGNORE_NAK etc. */  #define I2C_FUNC_SMBUS_PEC		0x00000008 -#define I2C_FUNC_NOSTART		0x00000010 /* I2C_M_NOSTART */ +#define I2C_FUNC_NOSTART		0x00000010 /* required for I2C_M_NOSTART */  #define I2C_FUNC_SLAVE			0x00000020 -#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL	0x00008000 /* SMBus 2.0 */ +#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL	0x00008000 /* SMBus 2.0 or later */  #define I2C_FUNC_SMBUS_QUICK		0x00010000  #define I2C_FUNC_SMBUS_READ_BYTE	0x00020000  #define I2C_FUNC_SMBUS_WRITE_BYTE	0x00040000 @@ -102,11 +104,11 @@ struct i2c_msg {  #define I2C_FUNC_SMBUS_READ_WORD_DATA	0x00200000  #define I2C_FUNC_SMBUS_WRITE_WORD_DATA	0x00400000  #define I2C_FUNC_SMBUS_PROC_CALL	0x00800000 -#define I2C_FUNC_SMBUS_READ_BLOCK_DATA	0x01000000 +#define I2C_FUNC_SMBUS_READ_BLOCK_DATA	0x01000000 /* required for I2C_M_RECV_LEN */  #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000  #define I2C_FUNC_SMBUS_READ_I2C_BLOCK	0x04000000 /* I2C-like block xfer  */  #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK	0x08000000 /* w/ 1-byte reg. addr. */ -#define I2C_FUNC_SMBUS_HOST_NOTIFY	0x10000000 +#define I2C_FUNC_SMBUS_HOST_NOTIFY	0x10000000 /* SMBus 2.0 or later */  #define I2C_FUNC_SMBUS_BYTE		(I2C_FUNC_SMBUS_READ_BYTE | \  					 I2C_FUNC_SMBUS_WRITE_BYTE) @@ -128,6 +130,11 @@ struct i2c_msg {  					 I2C_FUNC_SMBUS_I2C_BLOCK | \  					 I2C_FUNC_SMBUS_PEC) +/* if I2C_M_RECV_LEN is also supported */ +#define I2C_FUNC_SMBUS_EMUL_ALL		(I2C_FUNC_SMBUS_EMUL | \ +					 I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ +					 I2C_FUNC_SMBUS_BLOCK_PROC_CALL) +  /*   * Data for SMBus Messages   */ diff --git a/include/uapi/linux/icmp.h b/include/uapi/linux/icmp.h index fb169a50895e..163c0998aec9 100644 --- a/include/uapi/linux/icmp.h +++ b/include/uapi/linux/icmp.h @@ -20,6 +20,8 @@  #include <linux/types.h>  #include <asm/byteorder.h> +#include <linux/if.h> +#include <linux/in6.h>  #define ICMP_ECHOREPLY		0	/* Echo Reply			*/  #define ICMP_DEST_UNREACH	3	/* Destination Unreachable	*/ @@ -66,6 +68,23 @@  #define ICMP_EXC_TTL		0	/* TTL count exceeded		*/  #define ICMP_EXC_FRAGTIME	1	/* Fragment Reass time exceeded	*/ +/* Codes for EXT_ECHO (PROBE) */ +#define ICMP_EXT_ECHO			42 +#define ICMP_EXT_ECHOREPLY		43 +#define ICMP_EXT_CODE_MAL_QUERY		1	/* Malformed Query */ +#define ICMP_EXT_CODE_NO_IF		2	/* No such Interface */ +#define ICMP_EXT_CODE_NO_TABLE_ENT	3	/* No such Table Entry */ +#define ICMP_EXT_CODE_MULT_IFS		4	/* Multiple Interfaces Satisfy Query */ + +/* Constants for EXT_ECHO (PROBE) */ +#define ICMP_EXT_ECHOREPLY_ACTIVE	(1 << 2)/* active bit in reply message */ +#define ICMP_EXT_ECHOREPLY_IPV4		(1 << 1)/* ipv4 bit in reply message */ +#define ICMP_EXT_ECHOREPLY_IPV6		1	/* ipv6 bit in reply message */ +#define ICMP_EXT_ECHO_CTYPE_NAME	1 +#define ICMP_EXT_ECHO_CTYPE_INDEX	2 +#define ICMP_EXT_ECHO_CTYPE_ADDR	3 +#define ICMP_AFI_IP			1	/* Address Family Identifier for ipv4 */ +#define ICMP_AFI_IP6			2	/* Address Family Identifier for ipv6 */  struct icmphdr {    __u8		type; @@ -118,4 +137,26 @@ struct icmp_extobj_hdr {  	__u8		class_type;  }; +/* RFC 8335: 2.1 Header for c-type 3 payload */ +struct icmp_ext_echo_ctype3_hdr { +	__be16		afi; +	__u8		addrlen; +	__u8		reserved; +}; + +/* RFC 8335: 2.1 Interface Identification Object */ +struct icmp_ext_echo_iio { +	struct icmp_extobj_hdr extobj_hdr; +	union { +		char name[IFNAMSIZ]; +		__be32 ifindex; +		struct { +			struct icmp_ext_echo_ctype3_hdr ctype3_hdr; +			union { +				__be32		ipv4_addr; +				struct in6_addr	ipv6_addr; +			} ip_addr; +		} addr; +	} ident; +};  #endif /* _UAPI_LINUX_ICMP_H */ diff --git a/include/uapi/linux/icmpv6.h b/include/uapi/linux/icmpv6.h index c1661febc2dc..4eaab89e2856 100644 --- a/include/uapi/linux/icmpv6.h +++ b/include/uapi/linux/icmpv6.h @@ -112,6 +112,7 @@ struct icmp6hdr {  #define ICMPV6_MOBILE_PREFIX_ADV	147  #define ICMPV6_MRDISC_ADV		151 +#define ICMPV6_MRDISC_SOL		152  #define ICMPV6_MSG_MAX          255 @@ -138,7 +139,11 @@ struct icmp6hdr {  #define ICMPV6_HDR_FIELD		0  #define ICMPV6_UNK_NEXTHDR		1  #define ICMPV6_UNK_OPTION		2 +#define ICMPV6_HDR_INCOMP		3 +/* Codes for EXT_ECHO (PROBE) */ +#define ICMPV6_EXT_ECHO_REQUEST		160 +#define ICMPV6_EXT_ECHO_REPLY		161  /*   *	constants for (set|get)sockopt   */ diff --git a/include/uapi/linux/idxd.h b/include/uapi/linux/idxd.h index fdcdfe414223..3d1987e1bb2d 100644 --- a/include/uapi/linux/idxd.h +++ b/include/uapi/linux/idxd.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* SPDX-License-Identifier: LGPL-2.1 WITH Linux-syscall-note */  /* Copyright(c) 2019 Intel Corporation. All rights rsvd. */  #ifndef _USR_IDXD_H_  #define _USR_IDXD_H_ @@ -9,6 +9,34 @@  #include <stdint.h>  #endif +/* Driver command error status */ +enum idxd_scmd_stat { +	IDXD_SCMD_DEV_ENABLED = 0x80000010, +	IDXD_SCMD_DEV_NOT_ENABLED = 0x80000020, +	IDXD_SCMD_WQ_ENABLED = 0x80000021, +	IDXD_SCMD_DEV_DMA_ERR = 0x80020000, +	IDXD_SCMD_WQ_NO_GRP = 0x80030000, +	IDXD_SCMD_WQ_NO_NAME = 0x80040000, +	IDXD_SCMD_WQ_NO_SVM = 0x80050000, +	IDXD_SCMD_WQ_NO_THRESH = 0x80060000, +	IDXD_SCMD_WQ_PORTAL_ERR = 0x80070000, +	IDXD_SCMD_WQ_RES_ALLOC_ERR = 0x80080000, +	IDXD_SCMD_PERCPU_ERR = 0x80090000, +	IDXD_SCMD_DMA_CHAN_ERR = 0x800a0000, +	IDXD_SCMD_CDEV_ERR = 0x800b0000, +	IDXD_SCMD_WQ_NO_SWQ_SUPPORT = 0x800c0000, +	IDXD_SCMD_WQ_NONE_CONFIGURED = 0x800d0000, +	IDXD_SCMD_WQ_NO_SIZE = 0x800e0000, +	IDXD_SCMD_WQ_NO_PRIV = 0x800f0000, +	IDXD_SCMD_WQ_IRQ_ERR = 0x80100000, +	IDXD_SCMD_WQ_USER_NO_IOMMU = 0x80110000, +	IDXD_SCMD_DEV_EVL_ERR = 0x80120000, +	IDXD_SCMD_WQ_NO_DRV_NAME = 0x80200000, +}; + +#define IDXD_SCMD_SOFTERR_MASK	0x80000000 +#define IDXD_SCMD_SOFTERR_SHIFT	16 +  /* Descriptor flags */  #define IDXD_OP_FLAG_FENCE	0x0001  #define IDXD_OP_FLAG_BOF	0x0002 @@ -26,6 +54,14 @@  #define IDXD_OP_FLAG_DRDBK	0x4000  #define IDXD_OP_FLAG_DSTS	0x8000 +/* IAX */ +#define IDXD_OP_FLAG_RD_SRC2_AECS	0x010000 +#define IDXD_OP_FLAG_RD_SRC2_2ND	0x020000 +#define IDXD_OP_FLAG_WR_SRC2_AECS_COMP	0x040000 +#define IDXD_OP_FLAG_WR_SRC2_AECS_OVFL	0x080000 +#define IDXD_OP_FLAG_SRC2_STS		0x100000 +#define IDXD_OP_FLAG_CRC_RFC3720	0x200000 +  /* Opcode */  enum dsa_opcode {  	DSA_OPCODE_NOOP = 0, @@ -38,15 +74,37 @@ enum dsa_opcode {  	DSA_OPCODE_CR_DELTA,  	DSA_OPCODE_AP_DELTA,  	DSA_OPCODE_DUALCAST, +	DSA_OPCODE_TRANSL_FETCH,  	DSA_OPCODE_CRCGEN = 0x10,  	DSA_OPCODE_COPY_CRC,  	DSA_OPCODE_DIF_CHECK,  	DSA_OPCODE_DIF_INS,  	DSA_OPCODE_DIF_STRP,  	DSA_OPCODE_DIF_UPDT, +	DSA_OPCODE_DIX_GEN = 0x17,  	DSA_OPCODE_CFLUSH = 0x20,  }; +enum iax_opcode { +	IAX_OPCODE_NOOP = 0, +	IAX_OPCODE_DRAIN = 2, +	IAX_OPCODE_MEMMOVE, +	IAX_OPCODE_DECOMPRESS = 0x42, +	IAX_OPCODE_COMPRESS, +	IAX_OPCODE_CRC64, +	IAX_OPCODE_ZERO_DECOMP_32 = 0x48, +	IAX_OPCODE_ZERO_DECOMP_16, +	IAX_OPCODE_ZERO_COMP_32 = 0x4c, +	IAX_OPCODE_ZERO_COMP_16, +	IAX_OPCODE_SCAN = 0x50, +	IAX_OPCODE_SET_MEMBER, +	IAX_OPCODE_EXTRACT, +	IAX_OPCODE_SELECT, +	IAX_OPCODE_RLE_BURST, +	IAX_OPCODE_FIND_UNIQUE, +	IAX_OPCODE_EXPAND, +}; +  /* Completion record status */  enum dsa_completion_status {  	DSA_COMP_NONE = 0, @@ -78,10 +136,44 @@ enum dsa_completion_status {  	DSA_COMP_HW_ERR1,  	DSA_COMP_HW_ERR_DRB,  	DSA_COMP_TRANSLATION_FAIL, +	DSA_COMP_DRAIN_EVL = 0x26, +	DSA_COMP_BATCH_EVL_ERR, +}; + +enum iax_completion_status { +	IAX_COMP_NONE = 0, +	IAX_COMP_SUCCESS, +	IAX_COMP_PAGE_FAULT_IR = 0x04, +	IAX_COMP_ANALYTICS_ERROR = 0x0a, +	IAX_COMP_OUTBUF_OVERFLOW, +	IAX_COMP_BAD_OPCODE = 0x10, +	IAX_COMP_INVALID_FLAGS, +	IAX_COMP_NOZERO_RESERVE, +	IAX_COMP_INVALID_SIZE, +	IAX_COMP_OVERLAP_BUFFERS = 0x16, +	IAX_COMP_INT_HANDLE_INVAL = 0x19, +	IAX_COMP_CRA_XLAT, +	IAX_COMP_CRA_ALIGN, +	IAX_COMP_ADDR_ALIGN, +	IAX_COMP_PRIV_BAD, +	IAX_COMP_TRAFFIC_CLASS_CONF, +	IAX_COMP_PFAULT_RDBA, +	IAX_COMP_HW_ERR1, +	IAX_COMP_HW_ERR_DRB, +	IAX_COMP_TRANSLATION_FAIL, +	IAX_COMP_PRS_TIMEOUT, +	IAX_COMP_WATCHDOG, +	IAX_COMP_INVALID_COMP_FLAG = 0x30, +	IAX_COMP_INVALID_FILTER_FLAG, +	IAX_COMP_INVALID_INPUT_SIZE, +	IAX_COMP_INVALID_NUM_ELEMS, +	IAX_COMP_INVALID_SRC1_WIDTH, +	IAX_COMP_INVALID_INVERT_OUT,  };  #define DSA_COMP_STATUS_MASK		0x7f  #define DSA_COMP_STATUS_WRITE		0x80 +#define DSA_COMP_STATUS(status)		((status) & DSA_COMP_STATUS_MASK)  struct dsa_hw_desc {  	uint32_t	pasid:20; @@ -95,6 +187,8 @@ struct dsa_hw_desc {  		uint64_t	rdback_addr;  		uint64_t	pattern;  		uint64_t	desc_list_addr; +		uint64_t	pattern_lower; +		uint64_t	transl_fetch_addr;  	};  	union {  		uint64_t	dst_addr; @@ -105,6 +199,7 @@ struct dsa_hw_desc {  	union {  		uint32_t	xfer_size;  		uint32_t	desc_count; +		uint32_t	region_size;  	};  	uint16_t	int_handle;  	uint16_t	rsvd1; @@ -159,10 +254,52 @@ struct dsa_hw_desc {  			uint16_t	dest_app_tag_seed;  		}; +		/* Fill */ +		uint64_t	pattern_upper; + +		/* Translation fetch */ +		struct { +			uint64_t	transl_fetch_res; +			uint32_t	region_stride; +		}; + +		/* DIX generate */ +		struct { +			uint8_t		dix_gen_res; +			uint8_t		dest_dif_flags; +			uint8_t		dif_flags; +			uint8_t		dix_gen_res2[13]; +			uint32_t	ref_tag_seed; +			uint16_t	app_tag_mask; +			uint16_t	app_tag_seed; +		}; +  		uint8_t		op_specific[24];  	};  } __attribute__((packed)); +struct iax_hw_desc { +	uint32_t        pasid:20; +	uint32_t        rsvd:11; +	uint32_t        priv:1; +	uint32_t        flags:24; +	uint32_t        opcode:8; +	uint64_t        completion_addr; +	uint64_t        src1_addr; +	uint64_t        dst_addr; +	uint32_t        src1_size; +	uint16_t        int_handle; +	union { +		uint16_t        compr_flags; +		uint16_t        decompr_flags; +	}; +	uint64_t        src2_addr; +	uint32_t        max_dst_size; +	uint32_t        src2_size; +	uint32_t	filter_flags; +	uint32_t	num_inputs; +} __attribute__((packed)); +  struct dsa_raw_desc {  	uint64_t	field[8];  } __attribute__((packed)); @@ -177,8 +314,12 @@ struct dsa_completion_record {  		uint8_t		result;  		uint8_t		dif_status;  	}; -	uint16_t		rsvd; -	uint32_t		bytes_completed; +	uint8_t			fault_info; +	uint8_t			rsvd; +	union { +		uint32_t		bytes_completed; +		uint32_t		descs_completed; +	};  	uint64_t		fault_addr;  	union {  		/* common record */ @@ -187,8 +328,8 @@ struct dsa_completion_record {  			uint32_t	rsvd2:8;  		}; -		uint16_t	delta_rec_size; -		uint16_t	crc_val; +		uint32_t	delta_rec_size; +		uint64_t	crc_val;  		/* DIF check & strip */  		struct { @@ -215,6 +356,14 @@ struct dsa_completion_record {  			uint16_t	dif_upd_dest_app_tag;  		}; +		/* DIX generate */ +		struct { +			uint64_t	dix_gen_res; +			uint32_t	dix_ref_tag; +			uint16_t	dix_app_tag_mask; +			uint16_t	dix_app_tag; +		}; +  		uint8_t		op_specific[16];  	};  } __attribute__((packed)); @@ -223,4 +372,28 @@ struct dsa_raw_completion_record {  	uint64_t	field[4];  } __attribute__((packed)); +struct iax_completion_record { +	volatile uint8_t        status; +	uint8_t                 error_code; +	uint8_t			fault_info; +	uint8_t			rsvd; +	uint32_t                bytes_completed; +	uint64_t                fault_addr; +	uint32_t                invalid_flags; +	uint32_t                rsvd2; +	uint32_t                output_size; +	uint8_t                 output_bits; +	uint8_t                 rsvd3; +	uint16_t                xor_csum; +	uint32_t                crc; +	uint32_t                min; +	uint32_t                max; +	uint32_t                sum; +	uint64_t                rsvd4[2]; +} __attribute__((packed)); + +struct iax_raw_completion_record { +	uint64_t	field[8]; +} __attribute__((packed)); +  #endif diff --git a/include/uapi/linux/if_addr.h b/include/uapi/linux/if_addr.h index dfcf3ce0097f..aa7958b4e41d 100644 --- a/include/uapi/linux/if_addr.h +++ b/include/uapi/linux/if_addr.h @@ -1,6 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_IF_ADDR_H -#define __LINUX_IF_ADDR_H +#ifndef _UAPI__LINUX_IF_ADDR_H +#define _UAPI__LINUX_IF_ADDR_H  #include <linux/types.h>  #include <linux/netlink.h> @@ -33,8 +33,9 @@ enum {  	IFA_CACHEINFO,  	IFA_MULTICAST,  	IFA_FLAGS, -	IFA_RT_PRIORITY,  /* u32, priority/metric for prefix route */ +	IFA_RT_PRIORITY,	/* u32, priority/metric for prefix route */  	IFA_TARGET_NETNSID, +	IFA_PROTO,		/* u8, address protocol */  	__IFA_MAX,  }; @@ -69,4 +70,10 @@ struct ifa_cacheinfo {  #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))  #endif +/* ifa_proto */ +#define IFAPROT_UNSPEC		0 +#define IFAPROT_KERNEL_LO	1	/* loopback */ +#define IFAPROT_KERNEL_RA	2	/* set by kernel from router announcement */ +#define IFAPROT_KERNEL_LL	3	/* link-local set by kernel */ +  #endif diff --git a/include/uapi/linux/if_addrlabel.h b/include/uapi/linux/if_addrlabel.h index d1f5974c76e1..e69db764fbba 100644 --- a/include/uapi/linux/if_addrlabel.h +++ b/include/uapi/linux/if_addrlabel.h @@ -8,8 +8,8 @@   *	YOSHIFUJI Hideaki @ USAGI/WIDE <yoshfuji@linux-ipv6.org>   */ -#ifndef __LINUX_IF_ADDRLABEL_H -#define __LINUX_IF_ADDRLABEL_H +#ifndef _UAPI__LINUX_IF_ADDRLABEL_H +#define _UAPI__LINUX_IF_ADDRLABEL_H  #include <linux/types.h> diff --git a/include/uapi/linux/if_alg.h b/include/uapi/linux/if_alg.h index bc2bcdec377b..b35871cbeed7 100644 --- a/include/uapi/linux/if_alg.h +++ b/include/uapi/linux/if_alg.h @@ -11,8 +11,8 @@   *   */ -#ifndef _LINUX_IF_ALG_H -#define _LINUX_IF_ALG_H +#ifndef _UAPI_LINUX_IF_ALG_H +#define _UAPI_LINUX_IF_ALG_H  #include <linux/types.h> @@ -24,9 +24,25 @@ struct sockaddr_alg {  	__u8	salg_name[64];  }; +/* + * Linux v4.12 and later removed the 64-byte limit on salg_name[]; it's now an + * arbitrary-length field.  We had to keep the original struct above for source + * compatibility with existing userspace programs, though.  Use the new struct + * below if support for very long algorithm names is needed.  To do this, + * allocate 'sizeof(struct sockaddr_alg_new) + strlen(algname) + 1' bytes, and + * copy algname (including the null terminator) into salg_name. + */ +struct sockaddr_alg_new { +	__u16	salg_family; +	__u8	salg_type[14]; +	__u32	salg_feat; +	__u32	salg_mask; +	__u8	salg_name[]; +}; +  struct af_alg_iv {  	__u32	ivlen; -	__u8	iv[0]; +	__u8	iv[];  };  /* Socket options */ @@ -35,9 +51,11 @@ struct af_alg_iv {  #define ALG_SET_OP			3  #define ALG_SET_AEAD_ASSOCLEN		4  #define ALG_SET_AEAD_AUTHSIZE		5 +#define ALG_SET_DRBG_ENTROPY		6 +#define ALG_SET_KEY_BY_KEY_SERIAL	7  /* Operations */  #define ALG_OP_DECRYPT			0  #define ALG_OP_ENCRYPT			1 -#endif	/* _LINUX_IF_ALG_H */ +#endif	/* _UAPI_LINUX_IF_ALG_H */ diff --git a/include/uapi/linux/if_arcnet.h b/include/uapi/linux/if_arcnet.h index 683878036d76..473569eaf692 100644 --- a/include/uapi/linux/if_arcnet.h +++ b/include/uapi/linux/if_arcnet.h @@ -14,8 +14,8 @@   *              2 of the License, or (at your option) any later version.   */ -#ifndef _LINUX_IF_ARCNET_H -#define _LINUX_IF_ARCNET_H +#ifndef _UAPI_LINUX_IF_ARCNET_H +#define _UAPI_LINUX_IF_ARCNET_H  #include <linux/types.h>  #include <linux/if_ether.h> @@ -60,7 +60,7 @@ struct arc_rfc1201 {  	__u8  proto;		/* protocol ID field - varies		*/  	__u8  split_flag;	/* for use with split packets		*/  	__be16   sequence;	/* sequence number			*/ -	__u8  payload[0];	/* space remaining in packet (504 bytes)*/ +	__u8  payload[];	/* space remaining in packet (504 bytes)*/  };  #define RFC1201_HDR_SIZE 4 @@ -69,7 +69,7 @@ struct arc_rfc1201 {   */  struct arc_rfc1051 {  	__u8 proto;		/* ARC_P_RFC1051_ARP/RFC1051_IP	*/ -	__u8 payload[0];	/* 507 bytes			*/ +	__u8 payload[];	/* 507 bytes			*/  };  #define RFC1051_HDR_SIZE 1 @@ -80,7 +80,7 @@ struct arc_rfc1051 {  struct arc_eth_encap {  	__u8 proto;		/* Always ARC_P_ETHER			*/  	struct ethhdr eth;	/* standard ethernet header (yuck!)	*/ -	__u8 payload[0];	/* 493 bytes				*/ +	__u8 payload[];	/* 493 bytes				*/  };  #define ETH_ENCAP_HDR_SIZE 14 @@ -127,4 +127,4 @@ struct archdr {  	} soft;  }; -#endif				/* _LINUX_IF_ARCNET_H */ +#endif				/* _UAPI_LINUX_IF_ARCNET_H */ diff --git a/include/uapi/linux/if_arp.h b/include/uapi/linux/if_arp.h index c3cc5a9e5eaf..4783af9fe520 100644 --- a/include/uapi/linux/if_arp.h +++ b/include/uapi/linux/if_arp.h @@ -54,6 +54,7 @@  #define ARPHRD_X25	271		/* CCITT X.25			*/  #define ARPHRD_HWX25	272		/* Boards with X.25 in firmware	*/  #define ARPHRD_CAN	280		/* Controller Area Network      */ +#define ARPHRD_MCTP	290  #define ARPHRD_PPP	512  #define ARPHRD_CISCO	513		/* Cisco HDLC	 		*/  #define ARPHRD_HDLC	ARPHRD_CISCO diff --git a/include/uapi/linux/if_bonding.h b/include/uapi/linux/if_bonding.h index 45f3750aa861..3bcc03f3aa4f 100644 --- a/include/uapi/linux/if_bonding.h +++ b/include/uapi/linux/if_bonding.h @@ -41,8 +41,8 @@   *      - added definitions for various XOR hashing policies   */ -#ifndef _LINUX_IF_BONDING_H -#define _LINUX_IF_BONDING_H +#ifndef _UAPI_LINUX_IF_BONDING_H +#define _UAPI_LINUX_IF_BONDING_H  #include <linux/if.h>  #include <linux/types.h> @@ -94,6 +94,7 @@  #define BOND_XMIT_POLICY_LAYER23	2 /* layer 2+3 (IP ^ MAC) */  #define BOND_XMIT_POLICY_ENCAP23	3 /* encapsulated layer 2+3 */  #define BOND_XMIT_POLICY_ENCAP34	4 /* encapsulated layer 3+4 */ +#define BOND_XMIT_POLICY_VLAN_SRCMAC	5 /* vlan + source MAC */  /* 802.3ad port state definitions (43.4.2.2 in the 802.3ad standard) */  #define LACP_STATE_LACP_ACTIVITY   0x1 @@ -151,15 +152,4 @@ enum {  };  #define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1) -#endif /* _LINUX_IF_BONDING_H */ - -/* - * Local variables: - *  version-control: t - *  kept-new-versions: 5 - *  c-indent-level: 8 - *  c-basic-offset: 8 - *  tab-width: 8 - * End: - */ - +#endif /* _UAPI_LINUX_IF_BONDING_H */ diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h index c1227aecd38f..73876c0e2bba 100644 --- a/include/uapi/linux/if_bridge.h +++ b/include/uapi/linux/if_bridge.h @@ -121,6 +121,8 @@ enum {  	IFLA_BRIDGE_VLAN_INFO,  	IFLA_BRIDGE_VLAN_TUNNEL_INFO,  	IFLA_BRIDGE_MRP, +	IFLA_BRIDGE_CFM, +	IFLA_BRIDGE_MST,  	__IFLA_BRIDGE_MAX,  };  #define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1) @@ -328,6 +330,145 @@ struct br_mrp_start_in_test {  	__u16 in_id;  }; +enum { +	IFLA_BRIDGE_CFM_UNSPEC, +	IFLA_BRIDGE_CFM_MEP_CREATE, +	IFLA_BRIDGE_CFM_MEP_DELETE, +	IFLA_BRIDGE_CFM_MEP_CONFIG, +	IFLA_BRIDGE_CFM_CC_CONFIG, +	IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD, +	IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE, +	IFLA_BRIDGE_CFM_CC_RDI, +	IFLA_BRIDGE_CFM_CC_CCM_TX, +	IFLA_BRIDGE_CFM_MEP_CREATE_INFO, +	IFLA_BRIDGE_CFM_MEP_CONFIG_INFO, +	IFLA_BRIDGE_CFM_CC_CONFIG_INFO, +	IFLA_BRIDGE_CFM_CC_RDI_INFO, +	IFLA_BRIDGE_CFM_CC_CCM_TX_INFO, +	IFLA_BRIDGE_CFM_CC_PEER_MEP_INFO, +	IFLA_BRIDGE_CFM_MEP_STATUS_INFO, +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_INFO, +	__IFLA_BRIDGE_CFM_MAX, +}; + +#define IFLA_BRIDGE_CFM_MAX (__IFLA_BRIDGE_CFM_MAX - 1) + +enum { +	IFLA_BRIDGE_CFM_MEP_CREATE_UNSPEC, +	IFLA_BRIDGE_CFM_MEP_CREATE_INSTANCE, +	IFLA_BRIDGE_CFM_MEP_CREATE_DOMAIN, +	IFLA_BRIDGE_CFM_MEP_CREATE_DIRECTION, +	IFLA_BRIDGE_CFM_MEP_CREATE_IFINDEX, +	__IFLA_BRIDGE_CFM_MEP_CREATE_MAX, +}; + +#define IFLA_BRIDGE_CFM_MEP_CREATE_MAX (__IFLA_BRIDGE_CFM_MEP_CREATE_MAX - 1) + +enum { +	IFLA_BRIDGE_CFM_MEP_DELETE_UNSPEC, +	IFLA_BRIDGE_CFM_MEP_DELETE_INSTANCE, +	__IFLA_BRIDGE_CFM_MEP_DELETE_MAX, +}; + +#define IFLA_BRIDGE_CFM_MEP_DELETE_MAX (__IFLA_BRIDGE_CFM_MEP_DELETE_MAX - 1) + +enum { +	IFLA_BRIDGE_CFM_MEP_CONFIG_UNSPEC, +	IFLA_BRIDGE_CFM_MEP_CONFIG_INSTANCE, +	IFLA_BRIDGE_CFM_MEP_CONFIG_UNICAST_MAC, +	IFLA_BRIDGE_CFM_MEP_CONFIG_MDLEVEL, +	IFLA_BRIDGE_CFM_MEP_CONFIG_MEPID, +	__IFLA_BRIDGE_CFM_MEP_CONFIG_MAX, +}; + +#define IFLA_BRIDGE_CFM_MEP_CONFIG_MAX (__IFLA_BRIDGE_CFM_MEP_CONFIG_MAX - 1) + +enum { +	IFLA_BRIDGE_CFM_CC_CONFIG_UNSPEC, +	IFLA_BRIDGE_CFM_CC_CONFIG_INSTANCE, +	IFLA_BRIDGE_CFM_CC_CONFIG_ENABLE, +	IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL, +	IFLA_BRIDGE_CFM_CC_CONFIG_EXP_MAID, +	__IFLA_BRIDGE_CFM_CC_CONFIG_MAX, +}; + +#define IFLA_BRIDGE_CFM_CC_CONFIG_MAX (__IFLA_BRIDGE_CFM_CC_CONFIG_MAX - 1) + +enum { +	IFLA_BRIDGE_CFM_CC_PEER_MEP_UNSPEC, +	IFLA_BRIDGE_CFM_CC_PEER_MEP_INSTANCE, +	IFLA_BRIDGE_CFM_CC_PEER_MEPID, +	__IFLA_BRIDGE_CFM_CC_PEER_MEP_MAX, +}; + +#define IFLA_BRIDGE_CFM_CC_PEER_MEP_MAX (__IFLA_BRIDGE_CFM_CC_PEER_MEP_MAX - 1) + +enum { +	IFLA_BRIDGE_CFM_CC_RDI_UNSPEC, +	IFLA_BRIDGE_CFM_CC_RDI_INSTANCE, +	IFLA_BRIDGE_CFM_CC_RDI_RDI, +	__IFLA_BRIDGE_CFM_CC_RDI_MAX, +}; + +#define IFLA_BRIDGE_CFM_CC_RDI_MAX (__IFLA_BRIDGE_CFM_CC_RDI_MAX - 1) + +enum { +	IFLA_BRIDGE_CFM_CC_CCM_TX_UNSPEC, +	IFLA_BRIDGE_CFM_CC_CCM_TX_INSTANCE, +	IFLA_BRIDGE_CFM_CC_CCM_TX_DMAC, +	IFLA_BRIDGE_CFM_CC_CCM_TX_SEQ_NO_UPDATE, +	IFLA_BRIDGE_CFM_CC_CCM_TX_PERIOD, +	IFLA_BRIDGE_CFM_CC_CCM_TX_IF_TLV, +	IFLA_BRIDGE_CFM_CC_CCM_TX_IF_TLV_VALUE, +	IFLA_BRIDGE_CFM_CC_CCM_TX_PORT_TLV, +	IFLA_BRIDGE_CFM_CC_CCM_TX_PORT_TLV_VALUE, +	__IFLA_BRIDGE_CFM_CC_CCM_TX_MAX, +}; + +#define IFLA_BRIDGE_CFM_CC_CCM_TX_MAX (__IFLA_BRIDGE_CFM_CC_CCM_TX_MAX - 1) + +enum { +	IFLA_BRIDGE_CFM_MEP_STATUS_UNSPEC, +	IFLA_BRIDGE_CFM_MEP_STATUS_INSTANCE, +	IFLA_BRIDGE_CFM_MEP_STATUS_OPCODE_UNEXP_SEEN, +	IFLA_BRIDGE_CFM_MEP_STATUS_VERSION_UNEXP_SEEN, +	IFLA_BRIDGE_CFM_MEP_STATUS_RX_LEVEL_LOW_SEEN, +	__IFLA_BRIDGE_CFM_MEP_STATUS_MAX, +}; + +#define IFLA_BRIDGE_CFM_MEP_STATUS_MAX (__IFLA_BRIDGE_CFM_MEP_STATUS_MAX - 1) + +enum { +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_UNSPEC, +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_INSTANCE, +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_PEER_MEPID, +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_CCM_DEFECT, +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_RDI, +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_PORT_TLV_VALUE, +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_IF_TLV_VALUE, +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEEN, +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_TLV_SEEN, +	IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEQ_UNEXP_SEEN, +	__IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX, +}; + +#define IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX (__IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX - 1) + +enum { +	IFLA_BRIDGE_MST_UNSPEC, +	IFLA_BRIDGE_MST_ENTRY, +	__IFLA_BRIDGE_MST_MAX, +}; +#define IFLA_BRIDGE_MST_MAX (__IFLA_BRIDGE_MST_MAX - 1) + +enum { +	IFLA_BRIDGE_MST_ENTRY_UNSPEC, +	IFLA_BRIDGE_MST_ENTRY_MSTI, +	IFLA_BRIDGE_MST_ENTRY_STATE, +	__IFLA_BRIDGE_MST_ENTRY_MAX, +}; +#define IFLA_BRIDGE_MST_ENTRY_MAX (__IFLA_BRIDGE_MST_ENTRY_MAX - 1) +  struct bridge_stp_xstats {  	__u64 transition_blk;  	__u64 transition_fwd; @@ -354,16 +495,22 @@ enum {  /* flags used in BRIDGE_VLANDB_DUMP_FLAGS attribute to affect dumps */  #define BRIDGE_VLANDB_DUMPF_STATS	(1 << 0) /* Include stats in the dump */ +#define BRIDGE_VLANDB_DUMPF_GLOBAL	(1 << 1) /* Dump global vlan options only */  /* Bridge vlan RTM attributes   * [BRIDGE_VLANDB_ENTRY] = {   *     [BRIDGE_VLANDB_ENTRY_INFO]   *     ...   * } + * [BRIDGE_VLANDB_GLOBAL_OPTIONS] = { + *     [BRIDGE_VLANDB_GOPTS_ID] + *     ... + * }   */  enum {  	BRIDGE_VLANDB_UNSPEC,  	BRIDGE_VLANDB_ENTRY, +	BRIDGE_VLANDB_GLOBAL_OPTIONS,  	__BRIDGE_VLANDB_MAX,  };  #define BRIDGE_VLANDB_MAX (__BRIDGE_VLANDB_MAX - 1) @@ -375,6 +522,10 @@ enum {  	BRIDGE_VLANDB_ENTRY_STATE,  	BRIDGE_VLANDB_ENTRY_TUNNEL_INFO,  	BRIDGE_VLANDB_ENTRY_STATS, +	BRIDGE_VLANDB_ENTRY_MCAST_ROUTER, +	BRIDGE_VLANDB_ENTRY_MCAST_N_GROUPS, +	BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS, +	BRIDGE_VLANDB_ENTRY_NEIGH_SUPPRESS,  	__BRIDGE_VLANDB_ENTRY_MAX,  };  #define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1) @@ -413,6 +564,30 @@ enum {  };  #define BRIDGE_VLANDB_STATS_MAX (__BRIDGE_VLANDB_STATS_MAX - 1) +enum { +	BRIDGE_VLANDB_GOPTS_UNSPEC, +	BRIDGE_VLANDB_GOPTS_ID, +	BRIDGE_VLANDB_GOPTS_RANGE, +	BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING, +	BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION, +	BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION, +	BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT, +	BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT, +	BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_INTVL, +	BRIDGE_VLANDB_GOPTS_PAD, +	BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL, +	BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_INTVL, +	BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL, +	BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL, +	BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL, +	BRIDGE_VLANDB_GOPTS_MCAST_QUERIER, +	BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS, +	BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE, +	BRIDGE_VLANDB_GOPTS_MSTI, +	__BRIDGE_VLANDB_GOPTS_MAX +}; +#define BRIDGE_VLANDB_GOPTS_MAX (__BRIDGE_VLANDB_GOPTS_MAX - 1) +  /* Bridge multicast database attributes   * [MDBA_MDB] = {   *     [MDBA_MDB_ENTRY] = { @@ -455,10 +630,38 @@ enum {  enum {  	MDBA_MDB_EATTR_UNSPEC,  	MDBA_MDB_EATTR_TIMER, +	MDBA_MDB_EATTR_SRC_LIST, +	MDBA_MDB_EATTR_GROUP_MODE, +	MDBA_MDB_EATTR_SOURCE, +	MDBA_MDB_EATTR_RTPROT, +	MDBA_MDB_EATTR_DST, +	MDBA_MDB_EATTR_DST_PORT, +	MDBA_MDB_EATTR_VNI, +	MDBA_MDB_EATTR_IFINDEX, +	MDBA_MDB_EATTR_SRC_VNI,  	__MDBA_MDB_EATTR_MAX  };  #define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1) +/* per mdb entry source */ +enum { +	MDBA_MDB_SRCLIST_UNSPEC, +	MDBA_MDB_SRCLIST_ENTRY, +	__MDBA_MDB_SRCLIST_MAX +}; +#define MDBA_MDB_SRCLIST_MAX (__MDBA_MDB_SRCLIST_MAX - 1) + +/* per mdb entry per source attributes + * these are embedded in MDBA_MDB_SRCLIST_ENTRY + */ +enum { +	MDBA_MDB_SRCATTR_UNSPEC, +	MDBA_MDB_SRCATTR_ADDRESS, +	MDBA_MDB_SRCATTR_TIMER, +	__MDBA_MDB_SRCATTR_MAX +}; +#define MDBA_MDB_SRCATTR_MAX (__MDBA_MDB_SRCATTR_MAX - 1) +  /* multicast router types */  enum {  	MDB_RTR_TYPE_DISABLED, @@ -479,6 +682,9 @@ enum {  	MDBA_ROUTER_PATTR_UNSPEC,  	MDBA_ROUTER_PATTR_TIMER,  	MDBA_ROUTER_PATTR_TYPE, +	MDBA_ROUTER_PATTR_INET_TIMER, +	MDBA_ROUTER_PATTR_INET6_TIMER, +	MDBA_ROUTER_PATTR_VID,  	__MDBA_ROUTER_PATTR_MAX  };  #define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1) @@ -493,14 +699,18 @@ struct br_mdb_entry {  #define MDB_TEMPORARY 0  #define MDB_PERMANENT 1  	__u8 state; -#define MDB_FLAGS_OFFLOAD	(1 << 0) -#define MDB_FLAGS_FAST_LEAVE	(1 << 1) +#define MDB_FLAGS_OFFLOAD		(1 << 0) +#define MDB_FLAGS_FAST_LEAVE		(1 << 1) +#define MDB_FLAGS_STAR_EXCL		(1 << 2) +#define MDB_FLAGS_BLOCKED		(1 << 3) +#define MDB_FLAGS_OFFLOAD_FAILED	(1 << 4)  	__u8 flags;  	__u16 vid;  	struct {  		union {  			__be32	ip4;  			struct in6_addr ip6; +			unsigned char mac_addr[ETH_ALEN];  		} u;  		__be16		proto;  	} addr; @@ -509,10 +719,68 @@ struct br_mdb_entry {  enum {  	MDBA_SET_ENTRY_UNSPEC,  	MDBA_SET_ENTRY, +	MDBA_SET_ENTRY_ATTRS,  	__MDBA_SET_ENTRY_MAX,  };  #define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1) +/* [MDBA_GET_ENTRY] = { + *    struct br_mdb_entry + *    [MDBA_GET_ENTRY_ATTRS] = { + *       [MDBE_ATTR_SOURCE] + *          struct in_addr / struct in6_addr + *       [MDBE_ATTR_SRC_VNI] + *          u32 + *    } + * } + */ +enum { +	MDBA_GET_ENTRY_UNSPEC, +	MDBA_GET_ENTRY, +	MDBA_GET_ENTRY_ATTRS, +	__MDBA_GET_ENTRY_MAX, +}; +#define MDBA_GET_ENTRY_MAX (__MDBA_GET_ENTRY_MAX - 1) + +/* [MDBA_SET_ENTRY_ATTRS] = { + *    [MDBE_ATTR_xxx] + *    ... + * } + */ +enum { +	MDBE_ATTR_UNSPEC, +	MDBE_ATTR_SOURCE, +	MDBE_ATTR_SRC_LIST, +	MDBE_ATTR_GROUP_MODE, +	MDBE_ATTR_RTPROT, +	MDBE_ATTR_DST, +	MDBE_ATTR_DST_PORT, +	MDBE_ATTR_VNI, +	MDBE_ATTR_IFINDEX, +	MDBE_ATTR_SRC_VNI, +	MDBE_ATTR_STATE_MASK, +	__MDBE_ATTR_MAX, +}; +#define MDBE_ATTR_MAX (__MDBE_ATTR_MAX - 1) + +/* per mdb entry source */ +enum { +	MDBE_SRC_LIST_UNSPEC, +	MDBE_SRC_LIST_ENTRY, +	__MDBE_SRC_LIST_MAX, +}; +#define MDBE_SRC_LIST_MAX (__MDBE_SRC_LIST_MAX - 1) + +/* per mdb entry per source attributes + * these are embedded in MDBE_SRC_LIST_ENTRY + */ +enum { +	MDBE_SRCATTR_UNSPEC, +	MDBE_SRCATTR_ADDRESS, +	__MDBE_SRCATTR_MAX, +}; +#define MDBE_SRCATTR_MAX (__MDBE_SRCATTR_MAX - 1) +  /* Embedded inside LINK_XSTATS_TYPE_BRIDGE */  enum {  	BRIDGE_XSTATS_UNSPEC, @@ -554,12 +822,16 @@ struct br_mcast_stats {  /* bridge boolean options   * BR_BOOLOPT_NO_LL_LEARN - disable learning from link-local packets + * BR_BOOLOPT_MCAST_VLAN_SNOOPING - control vlan multicast snooping   *   * IMPORTANT: if adding a new option do not forget to handle   *            it in br_boolopt_toggle/get and bridge sysfs   */  enum br_boolopt_id {  	BR_BOOLOPT_NO_LL_LEARN, +	BR_BOOLOPT_MCAST_VLAN_SNOOPING, +	BR_BOOLOPT_MST_ENABLE, +	BR_BOOLOPT_MDB_OFFLOAD_FAIL_NOTIFICATION,  	BR_BOOLOPT_MAX  }; @@ -572,4 +844,17 @@ struct br_boolopt_multi {  	__u32 optval;  	__u32 optmask;  }; + +enum { +	BRIDGE_QUERIER_UNSPEC, +	BRIDGE_QUERIER_IP_ADDRESS, +	BRIDGE_QUERIER_IP_PORT, +	BRIDGE_QUERIER_IP_OTHER_TIMER, +	BRIDGE_QUERIER_PAD, +	BRIDGE_QUERIER_IPV6_ADDRESS, +	BRIDGE_QUERIER_IPV6_PORT, +	BRIDGE_QUERIER_IPV6_OTHER_TIMER, +	__BRIDGE_QUERIER_MAX +}; +#define BRIDGE_QUERIER_MAX (__BRIDGE_QUERIER_MAX - 1)  #endif /* _UAPI_LINUX_IF_BRIDGE_H */ diff --git a/include/uapi/linux/if_cablemodem.h b/include/uapi/linux/if_cablemodem.h deleted file mode 100644 index 1f65130bf2a6..000000000000 --- a/include/uapi/linux/if_cablemodem.h +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ -#ifndef _LINUX_CABLEMODEM_H_ -#define _LINUX_CABLEMODEM_H_ -/* - *		Author: Franco Venturi <fventuri@mediaone.net> - *		Copyright 1998 Franco Venturi - * - *		This program is free software; you can redistribute it - *		and/or  modify it under  the terms of  the GNU General - *		Public  License as  published  by  the  Free  Software - *		Foundation;  either  version 2 of the License, or  (at - *		your option) any later version. - */ - -/* some useful defines for sb1000.c e cmconfig.c - fv */ -#define SIOCGCMSTATS		(SIOCDEVPRIVATE+0)	/* get cable modem stats */ -#define SIOCGCMFIRMWARE		(SIOCDEVPRIVATE+1)	/* get cm firmware version */ -#define SIOCGCMFREQUENCY	(SIOCDEVPRIVATE+2)	/* get cable modem frequency */ -#define SIOCSCMFREQUENCY	(SIOCDEVPRIVATE+3)	/* set cable modem frequency */ -#define SIOCGCMPIDS			(SIOCDEVPRIVATE+4)	/* get cable modem PIDs */ -#define SIOCSCMPIDS			(SIOCDEVPRIVATE+5)	/* set cable modem PIDs */ - -#endif diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h index d6de2b167448..69e0457eb200 100644 --- a/include/uapi/linux/if_ether.h +++ b/include/uapi/linux/if_ether.h @@ -86,7 +86,10 @@  					 * over Ethernet  					 */  #define ETH_P_PAE	0x888E		/* Port Access Entity (IEEE 802.1X) */ +#define ETH_P_PROFINET	0x8892		/* PROFINET			*/ +#define ETH_P_REALTEK	0x8899          /* Multiple proprietary protocols */  #define ETH_P_AOE	0x88A2		/* ATA over Ethernet		*/ +#define ETH_P_ETHERCAT	0x88A4		/* EtherCAT			*/  #define ETH_P_8021AD	0x88A8          /* 802.1ad Service VLAN		*/  #define ETH_P_802_EX1	0x88B5		/* 802.1 Local Experimental 1.  */  #define ETH_P_PREAUTH	0x88C7		/* 802.11 Preauthentication */ @@ -99,6 +102,7 @@  #define ETH_P_1588	0x88F7		/* IEEE 1588 Timesync */  #define ETH_P_NCSI	0x88F8		/* NCSI protocol		*/  #define ETH_P_PRP	0x88FB		/* IEC 62439-3 PRP/HSRv0	*/ +#define ETH_P_CFM	0x8902		/* Connectivity Fault Management */  #define ETH_P_FCOE	0x8906		/* Fibre Channel over Ethernet  */  #define ETH_P_IBOE	0x8915		/* Infiniband over Ethernet	*/  #define ETH_P_TDLS	0x890D          /* TDLS */ @@ -112,10 +116,11 @@  #define ETH_P_QINQ3	0x9300		/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */  #define ETH_P_EDSA	0xDADA		/* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */  #define ETH_P_DSA_8021Q	0xDADB		/* Fake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_DSA_A5PSW	0xE001		/* A5PSW Tag Value [ NOT AN OFFICIALLY REGISTERED ID ] */  #define ETH_P_IFE	0xED3E		/* ForCES inter-FE LFB type */  #define ETH_P_AF_IUCV   0xFBFB		/* IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] */ -#define ETH_P_802_3_MIN	0x0600		/* If the value in the ethernet type is less than this value +#define ETH_P_802_3_MIN	0x0600		/* If the value in the ethernet type is more than this value  					 * then the frame is Ethernet II. Else it is 802.3 */  /* @@ -133,6 +138,7 @@  #define ETH_P_LOCALTALK 0x0009		/* Localtalk pseudo type 	*/  #define ETH_P_CAN	0x000C		/* CAN: Controller Area Network */  #define ETH_P_CANFD	0x000D		/* CANFD: CAN flexible data rate*/ +#define ETH_P_CANXL	0x000E		/* CANXL: eXtended frame Length */  #define ETH_P_PPPTALK	0x0010		/* Dummy type for Atalk over PPP*/  #define ETH_P_TR_802_2	0x0011		/* 802.2 frames 		*/  #define ETH_P_MOBITEX	0x0015		/* Mobitex (kaz@cafe.net)	*/ @@ -150,6 +156,9 @@  #define ETH_P_MAP	0x00F9		/* Qualcomm multiplexing and  					 * aggregation protocol  					 */ +#define ETH_P_MCTP	0x00FA		/* Management component transport +					 * protocol packets +					 */  /*   *	This is an Ethernet frame header. diff --git a/include/uapi/linux/if_fc.h b/include/uapi/linux/if_fc.h index 3e3173282cc3..ff5ab92d16c2 100644 --- a/include/uapi/linux/if_fc.h +++ b/include/uapi/linux/if_fc.h @@ -18,8 +18,8 @@   *		as published by the Free Software Foundation; either version   *		2 of the License, or (at your option) any later version.   */ -#ifndef _LINUX_IF_FC_H -#define _LINUX_IF_FC_H +#ifndef _UAPI_LINUX_IF_FC_H +#define _UAPI_LINUX_IF_FC_H  #include <linux/types.h> @@ -49,4 +49,4 @@ struct fcllc {  	__be16 ethertype;		/* ether type field */  }; -#endif	/* _LINUX_IF_FC_H */ +#endif	/* _UAPI_LINUX_IF_FC_H */ diff --git a/include/uapi/linux/if_fddi.h b/include/uapi/linux/if_fddi.h index 7239aa9c0766..8df2d9934bcd 100644 --- a/include/uapi/linux/if_fddi.h +++ b/include/uapi/linux/if_fddi.h @@ -9,7 +9,7 @@   * Version:	@(#)if_fddi.h	1.0.3	Oct  6 2018   *   * Author:	Lawrence V. Stefani, <stefani@yahoo.com> - * Maintainer:	Maciej W. Rozycki, <macro@linux-mips.org> + * Maintainer:	Maciej W. Rozycki, <macro@orcam.me.uk>   *   *		if_fddi.h is based on previous if_ether.h and if_tr.h work by   *			Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> diff --git a/include/uapi/linux/if_frad.h b/include/uapi/linux/if_frad.h deleted file mode 100644 index 3c6ee85f6262..000000000000 --- a/include/uapi/linux/if_frad.h +++ /dev/null @@ -1,123 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ -/* - * DLCI/FRAD	Definitions for Frame Relay Access Devices.  DLCI devices are - *		created for each DLCI associated with a FRAD.  The FRAD driver - *		is not truly a network device, but the lower level device - *		handler.  This allows other FRAD manufacturers to use the DLCI - *		code, including its RFC1490 encapsulation alongside the current - *		implementation for the Sangoma cards. - * - * Version:	@(#)if_ifrad.h	0.15	31 Mar 96 - * - * Author:	Mike McLagan <mike.mclagan@linux.org> - * - * Changes: - *		0.15	Mike McLagan	changed structure defs (packed) - *					re-arranged flags - *					added DLCI_RET vars - * - *		This program is free software; you can redistribute it and/or - *		modify it under the terms of the GNU General Public License - *		as published by the Free Software Foundation; either version - *		2 of the License, or (at your option) any later version. - */ - -#ifndef _UAPI_FRAD_H_ -#define _UAPI_FRAD_H_ - -#include <linux/if.h> - -/* Structures and constants associated with the DLCI device driver */ - -struct dlci_add -{ -   char  devname[IFNAMSIZ]; -   short dlci; -}; - -#define DLCI_GET_CONF	(SIOCDEVPRIVATE + 2) -#define DLCI_SET_CONF	(SIOCDEVPRIVATE + 3) - -/*  - * These are related to the Sangoma SDLA and should remain in order.  - * Code within the SDLA module is based on the specifics of this  - * structure.  Change at your own peril. - */ -struct dlci_conf { -   short flags; -   short CIR_fwd; -   short Bc_fwd; -   short Be_fwd; -   short CIR_bwd; -   short Bc_bwd; -   short Be_bwd;  - -/* these are part of the status read */ -   short Tc_fwd; -   short Tc_bwd; -   short Tf_max; -   short Tb_max; - -/* add any new fields here above is a mirror of sdla_dlci_conf */ -}; - -#define DLCI_GET_SLAVE	(SIOCDEVPRIVATE + 4) - -/* configuration flags for DLCI */ -#define DLCI_IGNORE_CIR_OUT	0x0001 -#define DLCI_ACCOUNT_CIR_IN	0x0002 -#define DLCI_BUFFER_IF		0x0008 - -#define DLCI_VALID_FLAGS	0x000B - -/* defines for the actual Frame Relay hardware */ -#define FRAD_GET_CONF	(SIOCDEVPRIVATE) -#define FRAD_SET_CONF	(SIOCDEVPRIVATE + 1) - -#define FRAD_LAST_IOCTL	FRAD_SET_CONF - -/* - * Based on the setup for the Sangoma SDLA.  If changes are  - * necessary to this structure, a routine will need to be  - * added to that module to copy fields. - */ -struct frad_conf  -{ -   short station; -   short flags; -   short kbaud; -   short clocking; -   short mtu; -   short T391; -   short T392; -   short N391; -   short N392; -   short N393; -   short CIR_fwd; -   short Bc_fwd; -   short Be_fwd; -   short CIR_bwd; -   short Bc_bwd; -   short Be_bwd; - -/* Add new fields here, above is a mirror of the sdla_conf */ - -}; - -#define FRAD_STATION_CPE	0x0000 -#define FRAD_STATION_NODE	0x0001 - -#define FRAD_TX_IGNORE_CIR	0x0001 -#define FRAD_RX_ACCOUNT_CIR	0x0002 -#define FRAD_DROP_ABORTED	0x0004 -#define FRAD_BUFFERIF		0x0008 -#define FRAD_STATS		0x0010 -#define FRAD_MCI		0x0100 -#define FRAD_AUTODLCI		0x8000 -#define FRAD_VALID_FLAGS	0x811F - -#define FRAD_CLOCK_INT		0x0001 -#define FRAD_CLOCK_EXT		0x0000 - - -#endif /* _UAPI_FRAD_H_ */ diff --git a/include/uapi/linux/if_hippi.h b/include/uapi/linux/if_hippi.h index 785a1452a66c..42c4ffd11dae 100644 --- a/include/uapi/linux/if_hippi.h +++ b/include/uapi/linux/if_hippi.h @@ -20,8 +20,8 @@   *		2 of the License, or (at your option) any later version.   */ -#ifndef _LINUX_IF_HIPPI_H -#define _LINUX_IF_HIPPI_H +#ifndef _UAPI_LINUX_IF_HIPPI_H +#define _UAPI_LINUX_IF_HIPPI_H  #include <linux/types.h>  #include <asm/byteorder.h> @@ -151,4 +151,4 @@ struct hippi_hdr {  	struct hippi_snap_hdr	snap;  } __attribute__((packed)); -#endif	/* _LINUX_IF_HIPPI_H */ +#endif	/* _UAPI_LINUX_IF_HIPPI_H */ diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 7fba4de511de..784ace3a519c 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -7,24 +7,23 @@  /* This struct should be in sync with struct rtnl_link_stats64 */  struct rtnl_link_stats { -	__u32	rx_packets;		/* total packets received	*/ -	__u32	tx_packets;		/* total packets transmitted	*/ -	__u32	rx_bytes;		/* total bytes received 	*/ -	__u32	tx_bytes;		/* total bytes transmitted	*/ -	__u32	rx_errors;		/* bad packets received		*/ -	__u32	tx_errors;		/* packet transmit problems	*/ -	__u32	rx_dropped;		/* no space in linux buffers	*/ -	__u32	tx_dropped;		/* no space available in linux	*/ -	__u32	multicast;		/* multicast packets received	*/ +	__u32	rx_packets; +	__u32	tx_packets; +	__u32	rx_bytes; +	__u32	tx_bytes; +	__u32	rx_errors; +	__u32	tx_errors; +	__u32	rx_dropped; +	__u32	tx_dropped; +	__u32	multicast;  	__u32	collisions; -  	/* detailed rx_errors: */  	__u32	rx_length_errors; -	__u32	rx_over_errors;		/* receiver ring buff overflow	*/ -	__u32	rx_crc_errors;		/* recved pkt with crc error	*/ -	__u32	rx_frame_errors;	/* recv'd frame alignment error */ -	__u32	rx_fifo_errors;		/* recv'r fifo overrun		*/ -	__u32	rx_missed_errors;	/* receiver missed packet	*/ +	__u32	rx_over_errors; +	__u32	rx_crc_errors; +	__u32	rx_frame_errors; +	__u32	rx_fifo_errors; +	__u32	rx_missed_errors;  	/* detailed tx_errors */  	__u32	tx_aborted_errors; @@ -37,29 +36,204 @@ struct rtnl_link_stats {  	__u32	rx_compressed;  	__u32	tx_compressed; -	__u32	rx_nohandler;		/* dropped, no handler found	*/ +	__u32	rx_nohandler;  }; -/* The main device statistics structure */ +/** + * struct rtnl_link_stats64 - The main device statistics structure. + * + * @rx_packets: Number of good packets received by the interface. + *   For hardware interfaces counts all good packets received from the device + *   by the host, including packets which host had to drop at various stages + *   of processing (even in the driver). + * + * @tx_packets: Number of packets successfully transmitted. + *   For hardware interfaces counts packets which host was able to successfully + *   hand over to the device, which does not necessarily mean that packets + *   had been successfully transmitted out of the device, only that device + *   acknowledged it copied them out of host memory. + * + * @rx_bytes: Number of good received bytes, corresponding to @rx_packets. + * + *   For IEEE 802.3 devices should count the length of Ethernet Frames + *   excluding the FCS. + * + * @tx_bytes: Number of good transmitted bytes, corresponding to @tx_packets. + * + *   For IEEE 802.3 devices should count the length of Ethernet Frames + *   excluding the FCS. + * + * @rx_errors: Total number of bad packets received on this network device. + *   This counter must include events counted by @rx_length_errors, + *   @rx_crc_errors, @rx_frame_errors and other errors not otherwise + *   counted. + * + * @tx_errors: Total number of transmit problems. + *   This counter must include events counter by @tx_aborted_errors, + *   @tx_carrier_errors, @tx_fifo_errors, @tx_heartbeat_errors, + *   @tx_window_errors and other errors not otherwise counted. + * + * @rx_dropped: Number of packets received but not processed, + *   e.g. due to lack of resources or unsupported protocol. + *   For hardware interfaces this counter may include packets discarded + *   due to L2 address filtering but should not include packets dropped + *   by the device due to buffer exhaustion which are counted separately in + *   @rx_missed_errors (since procfs folds those two counters together). + * + * @tx_dropped: Number of packets dropped on their way to transmission, + *   e.g. due to lack of resources. + * + * @multicast: Multicast packets received. + *   For hardware interfaces this statistic is commonly calculated + *   at the device level (unlike @rx_packets) and therefore may include + *   packets which did not reach the host. + * + *   For IEEE 802.3 devices this counter may be equivalent to: + * + *    - 30.3.1.1.21 aMulticastFramesReceivedOK + * + * @collisions: Number of collisions during packet transmissions. + * + * @rx_length_errors: Number of packets dropped due to invalid length. + *   Part of aggregate "frame" errors in `/proc/net/dev`. + * + *   For IEEE 802.3 devices this counter should be equivalent to a sum + *   of the following attributes: + * + *    - 30.3.1.1.23 aInRangeLengthErrors + *    - 30.3.1.1.24 aOutOfRangeLengthField + *    - 30.3.1.1.25 aFrameTooLongErrors + * + * @rx_over_errors: Receiver FIFO overflow event counter. + * + *   Historically the count of overflow events. Such events may be + *   reported in the receive descriptors or via interrupts, and may + *   not correspond one-to-one with dropped packets. + * + *   The recommended interpretation for high speed interfaces is - + *   number of packets dropped because they did not fit into buffers + *   provided by the host, e.g. packets larger than MTU or next buffer + *   in the ring was not available for a scatter transfer. + * + *   Part of aggregate "frame" errors in `/proc/net/dev`. + * + *   This statistics was historically used interchangeably with + *   @rx_fifo_errors. + * + *   This statistic corresponds to hardware events and is not commonly used + *   on software devices. + * + * @rx_crc_errors: Number of packets received with a CRC error. + *   Part of aggregate "frame" errors in `/proc/net/dev`. + * + *   For IEEE 802.3 devices this counter must be equivalent to: + * + *    - 30.3.1.1.6 aFrameCheckSequenceErrors + * + * @rx_frame_errors: Receiver frame alignment errors. + *   Part of aggregate "frame" errors in `/proc/net/dev`. + * + *   For IEEE 802.3 devices this counter should be equivalent to: + * + *    - 30.3.1.1.7 aAlignmentErrors + * + * @rx_fifo_errors: Receiver FIFO error counter. + * + *   Historically the count of overflow events. Those events may be + *   reported in the receive descriptors or via interrupts, and may + *   not correspond one-to-one with dropped packets. + * + *   This statistics was used interchangeably with @rx_over_errors. + *   Not recommended for use in drivers for high speed interfaces. + * + *   This statistic is used on software devices, e.g. to count software + *   packet queue overflow (can) or sequencing errors (GRE). + * + * @rx_missed_errors: Count of packets missed by the host. + *   Folded into the "drop" counter in `/proc/net/dev`. + * + *   Counts number of packets dropped by the device due to lack + *   of buffer space. This usually indicates that the host interface + *   is slower than the network interface, or host is not keeping up + *   with the receive packet rate. + * + *   This statistic corresponds to hardware events and is not used + *   on software devices. + * + * @tx_aborted_errors: + *   Part of aggregate "carrier" errors in `/proc/net/dev`. + *   For IEEE 802.3 devices capable of half-duplex operation this counter + *   must be equivalent to: + * + *    - 30.3.1.1.11 aFramesAbortedDueToXSColls + * + *   High speed interfaces may use this counter as a general device + *   discard counter. + * + * @tx_carrier_errors: Number of frame transmission errors due to loss + *   of carrier during transmission. + *   Part of aggregate "carrier" errors in `/proc/net/dev`. + * + *   For IEEE 802.3 devices this counter must be equivalent to: + * + *    - 30.3.1.1.13 aCarrierSenseErrors + * + * @tx_fifo_errors: Number of frame transmission errors due to device + *   FIFO underrun / underflow. This condition occurs when the device + *   begins transmission of a frame but is unable to deliver the + *   entire frame to the transmitter in time for transmission. + *   Part of aggregate "carrier" errors in `/proc/net/dev`. + * + * @tx_heartbeat_errors: Number of Heartbeat / SQE Test errors for + *   old half-duplex Ethernet. + *   Part of aggregate "carrier" errors in `/proc/net/dev`. + * + *   For IEEE 802.3 devices possibly equivalent to: + * + *    - 30.3.2.1.4 aSQETestErrors + * + * @tx_window_errors: Number of frame transmission errors due + *   to late collisions (for Ethernet - after the first 64B of transmission). + *   Part of aggregate "carrier" errors in `/proc/net/dev`. + * + *   For IEEE 802.3 devices this counter must be equivalent to: + * + *    - 30.3.1.1.10 aLateCollisions + * + * @rx_compressed: Number of correctly received compressed packets. + *   This counters is only meaningful for interfaces which support + *   packet compression (e.g. CSLIP, PPP). + * + * @tx_compressed: Number of transmitted compressed packets. + *   This counters is only meaningful for interfaces which support + *   packet compression (e.g. CSLIP, PPP). + * + * @rx_nohandler: Number of packets received on the interface + *   but dropped by the networking stack because the device is + *   not designated to receive packets (e.g. backup link in a bond). + * + * @rx_otherhost_dropped: Number of packets dropped due to mismatch + *   in destination MAC address. + */  struct rtnl_link_stats64 { -	__u64	rx_packets;		/* total packets received	*/ -	__u64	tx_packets;		/* total packets transmitted	*/ -	__u64	rx_bytes;		/* total bytes received 	*/ -	__u64	tx_bytes;		/* total bytes transmitted	*/ -	__u64	rx_errors;		/* bad packets received		*/ -	__u64	tx_errors;		/* packet transmit problems	*/ -	__u64	rx_dropped;		/* no space in linux buffers	*/ -	__u64	tx_dropped;		/* no space available in linux	*/ -	__u64	multicast;		/* multicast packets received	*/ +	__u64	rx_packets; +	__u64	tx_packets; +	__u64	rx_bytes; +	__u64	tx_bytes; +	__u64	rx_errors; +	__u64	tx_errors; +	__u64	rx_dropped; +	__u64	tx_dropped; +	__u64	multicast;  	__u64	collisions;  	/* detailed rx_errors: */  	__u64	rx_length_errors; -	__u64	rx_over_errors;		/* receiver ring buff overflow	*/ -	__u64	rx_crc_errors;		/* recved pkt with crc error	*/ -	__u64	rx_frame_errors;	/* recv'd frame alignment error */ -	__u64	rx_fifo_errors;		/* recv'r fifo overrun		*/ -	__u64	rx_missed_errors;	/* receiver missed packet	*/ +	__u64	rx_over_errors; +	__u64	rx_crc_errors; +	__u64	rx_frame_errors; +	__u64	rx_fifo_errors; +	__u64	rx_missed_errors;  	/* detailed tx_errors */  	__u64	tx_aborted_errors; @@ -71,8 +245,24 @@ struct rtnl_link_stats64 {  	/* for cslip etc */  	__u64	rx_compressed;  	__u64	tx_compressed; +	__u64	rx_nohandler; + +	__u64	rx_otherhost_dropped; +}; -	__u64	rx_nohandler;		/* dropped, no handler found	*/ +/* Subset of link stats useful for in-HW collection. Meaning of the fields is as + * for struct rtnl_link_stats64. + */ +struct rtnl_hw_stats64 { +	__u64	rx_packets; +	__u64	tx_packets; +	__u64	rx_bytes; +	__u64	tx_bytes; +	__u64	rx_errors; +	__u64	tx_errors; +	__u64	rx_dropped; +	__u64	tx_dropped; +	__u64	multicast;  };  /* The struct should be in sync with struct ifmap */ @@ -171,6 +361,24 @@ enum {  	IFLA_ALT_IFNAME, /* Alternative ifname */  	IFLA_PERM_ADDRESS,  	IFLA_PROTO_DOWN_REASON, + +	/* device (sysfs) name as parent, used instead +	 * of IFLA_LINK where there's no parent netdev +	 */ +	IFLA_PARENT_DEV_NAME, +	IFLA_PARENT_DEV_BUS_NAME, +	IFLA_GRO_MAX_SIZE, +	IFLA_TSO_MAX_SIZE, +	IFLA_TSO_MAX_SEGS, +	IFLA_ALLMULTI,		/* Allmulti count: > 0 means acts ALLMULTI */ + +	IFLA_DEVLINK_PORT, + +	IFLA_GSO_IPV4_MAX_SIZE, +	IFLA_GRO_IPV4_MAX_SIZE, +	IFLA_DPLL_PIN, +	IFLA_MAX_PACING_OFFLOAD_HORIZON, +	IFLA_NETNS_IMMUTABLE,  	__IFLA_MAX  }; @@ -240,6 +448,7 @@ enum {  	IFLA_INET6_ICMP6STATS,	/* statistics (icmpv6)		*/  	IFLA_INET6_TOKEN,	/* device token			*/  	IFLA_INET6_ADDR_GEN_MODE, /* implicit address generator mode */ +	IFLA_INET6_RA_MTU,	/* mtu carried in the RA message */  	__IFLA_INET6_MAX  }; @@ -254,6 +463,286 @@ enum in6_addr_gen_mode {  /* Bridge section */ +/** + * DOC: Bridge enum definition + * + * Please *note* that the timer values in the following section are expected + * in clock_t format, which is seconds multiplied by USER_HZ (generally + * defined as 100). + * + * @IFLA_BR_FORWARD_DELAY + *   The bridge forwarding delay is the time spent in LISTENING state + *   (before moving to LEARNING) and in LEARNING state (before moving + *   to FORWARDING). Only relevant if STP is enabled. + * + *   The valid values are between (2 * USER_HZ) and (30 * USER_HZ). + *   The default value is (15 * USER_HZ). + * + * @IFLA_BR_HELLO_TIME + *   The time between hello packets sent by the bridge, when it is a root + *   bridge or a designated bridge. Only relevant if STP is enabled. + * + *   The valid values are between (1 * USER_HZ) and (10 * USER_HZ). + *   The default value is (2 * USER_HZ). + * + * @IFLA_BR_MAX_AGE + *   The hello packet timeout is the time until another bridge in the + *   spanning tree is assumed to be dead, after reception of its last hello + *   message. Only relevant if STP is enabled. + * + *   The valid values are between (6 * USER_HZ) and (40 * USER_HZ). + *   The default value is (20 * USER_HZ). + * + * @IFLA_BR_AGEING_TIME + *   Configure the bridge's FDB entries aging time. It is the time a MAC + *   address will be kept in the FDB after a packet has been received from + *   that address. After this time has passed, entries are cleaned up. + *   Allow values outside the 802.1 standard specification for special cases: + * + *     * 0 - entry never ages (all permanent) + *     * 1 - entry disappears (no persistence) + * + *   The default value is (300 * USER_HZ). + * + * @IFLA_BR_STP_STATE + *   Turn spanning tree protocol on (*IFLA_BR_STP_STATE* > 0) or off + *   (*IFLA_BR_STP_STATE* == 0) for this bridge. + * + *   The default value is 0 (disabled). + * + * @IFLA_BR_PRIORITY + *   Set this bridge's spanning tree priority, used during STP root bridge + *   election. + * + *   The valid values are between 0 and 65535. + * + * @IFLA_BR_VLAN_FILTERING + *   Turn VLAN filtering on (*IFLA_BR_VLAN_FILTERING* > 0) or off + *   (*IFLA_BR_VLAN_FILTERING* == 0). When disabled, the bridge will not + *   consider the VLAN tag when handling packets. + * + *   The default value is 0 (disabled). + * + * @IFLA_BR_VLAN_PROTOCOL + *   Set the protocol used for VLAN filtering. + * + *   The valid values are 0x8100(802.1Q) or 0x88A8(802.1AD). The default value + *   is 0x8100(802.1Q). + * + * @IFLA_BR_GROUP_FWD_MASK + *   The group forwarding mask. This is the bitmask that is applied to + *   decide whether to forward incoming frames destined to link-local + *   addresses (of the form 01:80:C2:00:00:0X). + * + *   The default value is 0, which means the bridge does not forward any + *   link-local frames coming on this port. + * + * @IFLA_BR_ROOT_ID + *   The bridge root id, read only. + * + * @IFLA_BR_BRIDGE_ID + *   The bridge id, read only. + * + * @IFLA_BR_ROOT_PORT + *   The bridge root port, read only. + * + * @IFLA_BR_ROOT_PATH_COST + *   The bridge root path cost, read only. + * + * @IFLA_BR_TOPOLOGY_CHANGE + *   The bridge topology change, read only. + * + * @IFLA_BR_TOPOLOGY_CHANGE_DETECTED + *   The bridge topology change detected, read only. + * + * @IFLA_BR_HELLO_TIMER + *   The bridge hello timer, read only. + * + * @IFLA_BR_TCN_TIMER + *   The bridge tcn timer, read only. + * + * @IFLA_BR_TOPOLOGY_CHANGE_TIMER + *   The bridge topology change timer, read only. + * + * @IFLA_BR_GC_TIMER + *   The bridge gc timer, read only. + * + * @IFLA_BR_GROUP_ADDR + *   Set the MAC address of the multicast group this bridge uses for STP. + *   The address must be a link-local address in standard Ethernet MAC address + *   format. It is an address of the form 01:80:C2:00:00:0X, with X in [0, 4..f]. + * + *   The default value is 0. + * + * @IFLA_BR_FDB_FLUSH + *   Flush bridge's fdb dynamic entries. + * + * @IFLA_BR_MCAST_ROUTER + *   Set bridge's multicast router if IGMP snooping is enabled. + *   The valid values are: + * + *     * 0 - disabled. + *     * 1 - automatic (queried). + *     * 2 - permanently enabled. + * + *   The default value is 1. + * + * @IFLA_BR_MCAST_SNOOPING + *   Turn multicast snooping on (*IFLA_BR_MCAST_SNOOPING* > 0) or off + *   (*IFLA_BR_MCAST_SNOOPING* == 0). + * + *   The default value is 1. + * + * @IFLA_BR_MCAST_QUERY_USE_IFADDR + *   If enabled use the bridge's own IP address as source address for IGMP + *   queries (*IFLA_BR_MCAST_QUERY_USE_IFADDR* > 0) or the default of 0.0.0.0 + *   (*IFLA_BR_MCAST_QUERY_USE_IFADDR* == 0). + * + *   The default value is 0 (disabled). + * + * @IFLA_BR_MCAST_QUERIER + *   Enable (*IFLA_BR_MULTICAST_QUERIER* > 0) or disable + *   (*IFLA_BR_MULTICAST_QUERIER* == 0) IGMP querier, ie sending of multicast + *   queries by the bridge. + * + *   The default value is 0 (disabled). + * + * @IFLA_BR_MCAST_HASH_ELASTICITY + *   Set multicast database hash elasticity, It is the maximum chain length in + *   the multicast hash table. This attribute is *deprecated* and the value + *   is always 16. + * + * @IFLA_BR_MCAST_HASH_MAX + *   Set maximum size of the multicast hash table + * + *   The default value is 4096, the value must be a power of 2. + * + * @IFLA_BR_MCAST_LAST_MEMBER_CNT + *   The Last Member Query Count is the number of Group-Specific Queries + *   sent before the router assumes there are no local members. The Last + *   Member Query Count is also the number of Group-and-Source-Specific + *   Queries sent before the router assumes there are no listeners for a + *   particular source. + * + *   The default value is 2. + * + * @IFLA_BR_MCAST_STARTUP_QUERY_CNT + *   The Startup Query Count is the number of Queries sent out on startup, + *   separated by the Startup Query Interval. + * + *   The default value is 2. + * + * @IFLA_BR_MCAST_LAST_MEMBER_INTVL + *   The Last Member Query Interval is the Max Response Time inserted into + *   Group-Specific Queries sent in response to Leave Group messages, and + *   is also the amount of time between Group-Specific Query messages. + * + *   The default value is (1 * USER_HZ). + * + * @IFLA_BR_MCAST_MEMBERSHIP_INTVL + *   The interval after which the bridge will leave a group, if no membership + *   reports for this group are received. + * + *   The default value is (260 * USER_HZ). + * + * @IFLA_BR_MCAST_QUERIER_INTVL + *   The interval between queries sent by other routers. if no queries are + *   seen after this delay has passed, the bridge will start to send its own + *   queries (as if *IFLA_BR_MCAST_QUERIER_INTVL* was enabled). + * + *   The default value is (255 * USER_HZ). + * + * @IFLA_BR_MCAST_QUERY_INTVL + *   The Query Interval is the interval between General Queries sent by + *   the Querier. + * + *   The default value is (125 * USER_HZ). The minimum value is (1 * USER_HZ). + * + * @IFLA_BR_MCAST_QUERY_RESPONSE_INTVL + *   The Max Response Time used to calculate the Max Resp Code inserted + *   into the periodic General Queries. + * + *   The default value is (10 * USER_HZ). + * + * @IFLA_BR_MCAST_STARTUP_QUERY_INTVL + *   The interval between queries in the startup phase. + * + *   The default value is (125 * USER_HZ) / 4. The minimum value is (1 * USER_HZ). + * + * @IFLA_BR_NF_CALL_IPTABLES + *   Enable (*NF_CALL_IPTABLES* > 0) or disable (*NF_CALL_IPTABLES* == 0) + *   iptables hooks on the bridge. + * + *   The default value is 0 (disabled). + * + * @IFLA_BR_NF_CALL_IP6TABLES + *   Enable (*NF_CALL_IP6TABLES* > 0) or disable (*NF_CALL_IP6TABLES* == 0) + *   ip6tables hooks on the bridge. + * + *   The default value is 0 (disabled). + * + * @IFLA_BR_NF_CALL_ARPTABLES + *   Enable (*NF_CALL_ARPTABLES* > 0) or disable (*NF_CALL_ARPTABLES* == 0) + *   arptables hooks on the bridge. + * + *   The default value is 0 (disabled). + * + * @IFLA_BR_VLAN_DEFAULT_PVID + *   VLAN ID applied to untagged and priority-tagged incoming packets. + * + *   The default value is 1. Setting to the special value 0 makes all ports of + *   this bridge not have a PVID by default, which means that they will + *   not accept VLAN-untagged traffic. + * + * @IFLA_BR_PAD + *   Bridge attribute padding type for netlink message. + * + * @IFLA_BR_VLAN_STATS_ENABLED + *   Enable (*IFLA_BR_VLAN_STATS_ENABLED* == 1) or disable + *   (*IFLA_BR_VLAN_STATS_ENABLED* == 0) per-VLAN stats accounting. + * + *   The default value is 0 (disabled). + * + * @IFLA_BR_MCAST_STATS_ENABLED + *   Enable (*IFLA_BR_MCAST_STATS_ENABLED* > 0) or disable + *   (*IFLA_BR_MCAST_STATS_ENABLED* == 0) multicast (IGMP/MLD) stats + *   accounting. + * + *   The default value is 0 (disabled). + * + * @IFLA_BR_MCAST_IGMP_VERSION + *   Set the IGMP version. + * + *   The valid values are 2 and 3. The default value is 2. + * + * @IFLA_BR_MCAST_MLD_VERSION + *   Set the MLD version. + * + *   The valid values are 1 and 2. The default value is 1. + * + * @IFLA_BR_VLAN_STATS_PER_PORT + *   Enable (*IFLA_BR_VLAN_STATS_PER_PORT* == 1) or disable + *   (*IFLA_BR_VLAN_STATS_PER_PORT* == 0) per-VLAN per-port stats accounting. + *   Can be changed only when there are no port VLANs configured. + * + *   The default value is 0 (disabled). + * + * @IFLA_BR_MULTI_BOOLOPT + *   The multi_boolopt is used to control new boolean options to avoid adding + *   new netlink attributes. You can look at ``enum br_boolopt_id`` for those + *   options. + * + * @IFLA_BR_MCAST_QUERIER_STATE + *   Bridge mcast querier states, read only. + * + * @IFLA_BR_FDB_N_LEARNED + *   The number of dynamically learned FDB entries for the current bridge, + *   read only. + * + * @IFLA_BR_FDB_MAX_LEARNED + *   Set the number of max dynamically learned FDB entries for the current + *   bridge. + */  enum {  	IFLA_BR_UNSPEC,  	IFLA_BR_FORWARD_DELAY, @@ -302,6 +791,9 @@ enum {  	IFLA_BR_MCAST_MLD_VERSION,  	IFLA_BR_VLAN_STATS_PER_PORT,  	IFLA_BR_MULTI_BOOLOPT, +	IFLA_BR_MCAST_QUERIER_STATE, +	IFLA_BR_FDB_N_LEARNED, +	IFLA_BR_FDB_MAX_LEARNED,  	__IFLA_BR_MAX,  }; @@ -312,11 +804,252 @@ struct ifla_bridge_id {  	__u8	addr[6]; /* ETH_ALEN */  }; +/** + * DOC: Bridge mode enum definition + * + * @BRIDGE_MODE_HAIRPIN + *   Controls whether traffic may be sent back out of the port on which it + *   was received. This option is also called reflective relay mode, and is + *   used to support basic VEPA (Virtual Ethernet Port Aggregator) + *   capabilities. By default, this flag is turned off and the bridge will + *   not forward traffic back out of the receiving port. + */  enum {  	BRIDGE_MODE_UNSPEC,  	BRIDGE_MODE_HAIRPIN,  }; +/** + * DOC: Bridge port enum definition + * + * @IFLA_BRPORT_STATE + *   The operation state of the port. Here are the valid values. + * + *     * 0 - port is in STP *DISABLED* state. Make this port completely + *       inactive for STP. This is also called BPDU filter and could be used + *       to disable STP on an untrusted port, like a leaf virtual device. + *       The traffic forwarding is also stopped on this port. + *     * 1 - port is in STP *LISTENING* state. Only valid if STP is enabled + *       on the bridge. In this state the port listens for STP BPDUs and + *       drops all other traffic frames. + *     * 2 - port is in STP *LEARNING* state. Only valid if STP is enabled on + *       the bridge. In this state the port will accept traffic only for the + *       purpose of updating MAC address tables. + *     * 3 - port is in STP *FORWARDING* state. Port is fully active. + *     * 4 - port is in STP *BLOCKING* state. Only valid if STP is enabled on + *       the bridge. This state is used during the STP election process. + *       In this state, port will only process STP BPDUs. + * + * @IFLA_BRPORT_PRIORITY + *   The STP port priority. The valid values are between 0 and 255. + * + * @IFLA_BRPORT_COST + *   The STP path cost of the port. The valid values are between 1 and 65535. + * + * @IFLA_BRPORT_MODE + *   Set the bridge port mode. See *BRIDGE_MODE_HAIRPIN* for more details. + * + * @IFLA_BRPORT_GUARD + *   Controls whether STP BPDUs will be processed by the bridge port. By + *   default, the flag is turned off to allow BPDU processing. Turning this + *   flag on will disable the bridge port if a STP BPDU packet is received. + * + *   If the bridge has Spanning Tree enabled, hostile devices on the network + *   may send BPDU on a port and cause network failure. Setting *guard on* + *   will detect and stop this by disabling the port. The port will be + *   restarted if the link is brought down, or removed and reattached. + * + * @IFLA_BRPORT_PROTECT + *   Controls whether a given port is allowed to become a root port or not. + *   Only used when STP is enabled on the bridge. By default the flag is off. + * + *   This feature is also called root port guard. If BPDU is received from a + *   leaf (edge) port, it should not be elected as root port. This could + *   be used if using STP on a bridge and the downstream bridges are not fully + *   trusted; this prevents a hostile guest from rerouting traffic. + * + * @IFLA_BRPORT_FAST_LEAVE + *   This flag allows the bridge to immediately stop multicast traffic + *   forwarding on a port that receives an IGMP Leave message. It is only used + *   when IGMP snooping is enabled on the bridge. By default the flag is off. + * + * @IFLA_BRPORT_LEARNING + *   Controls whether a given port will learn *source* MAC addresses from + *   received traffic or not. Also controls whether dynamic FDB entries + *   (which can also be added by software) will be refreshed by incoming + *   traffic. By default this flag is on. + * + * @IFLA_BRPORT_UNICAST_FLOOD + *   Controls whether unicast traffic for which there is no FDB entry will + *   be flooded towards this port. By default this flag is on. + * + * @IFLA_BRPORT_PROXYARP + *   Enable proxy ARP on this port. + * + * @IFLA_BRPORT_LEARNING_SYNC + *   Controls whether a given port will sync MAC addresses learned on device + *   port to bridge FDB. + * + * @IFLA_BRPORT_PROXYARP_WIFI + *   Enable proxy ARP on this port which meets extended requirements by + *   IEEE 802.11 and Hotspot 2.0 specifications. + * + * @IFLA_BRPORT_ROOT_ID + * + * @IFLA_BRPORT_BRIDGE_ID + * + * @IFLA_BRPORT_DESIGNATED_PORT + * + * @IFLA_BRPORT_DESIGNATED_COST + * + * @IFLA_BRPORT_ID + * + * @IFLA_BRPORT_NO + * + * @IFLA_BRPORT_TOPOLOGY_CHANGE_ACK + * + * @IFLA_BRPORT_CONFIG_PENDING + * + * @IFLA_BRPORT_MESSAGE_AGE_TIMER + * + * @IFLA_BRPORT_FORWARD_DELAY_TIMER + * + * @IFLA_BRPORT_HOLD_TIMER + * + * @IFLA_BRPORT_FLUSH + *   Flush bridge ports' fdb dynamic entries. + * + * @IFLA_BRPORT_MULTICAST_ROUTER + *   Configure the port's multicast router presence. A port with + *   a multicast router will receive all multicast traffic. + *   The valid values are: + * + *     * 0 disable multicast routers on this port + *     * 1 let the system detect the presence of routers (default) + *     * 2 permanently enable multicast traffic forwarding on this port + *     * 3 enable multicast routers temporarily on this port, not depending + *         on incoming queries. + * + * @IFLA_BRPORT_PAD + * + * @IFLA_BRPORT_MCAST_FLOOD + *   Controls whether a given port will flood multicast traffic for which + *   there is no MDB entry. By default this flag is on. + * + * @IFLA_BRPORT_MCAST_TO_UCAST + *   Controls whether a given port will replicate packets using unicast + *   instead of multicast. By default this flag is off. + * + *   This is done by copying the packet per host and changing the multicast + *   destination MAC to a unicast one accordingly. + * + *   *mcast_to_unicast* works on top of the multicast snooping feature of the + *   bridge. Which means unicast copies are only delivered to hosts which + *   are interested in unicast and signaled this via IGMP/MLD reports previously. + * + *   This feature is intended for interface types which have a more reliable + *   and/or efficient way to deliver unicast packets than broadcast ones + *   (e.g. WiFi). + * + *   However, it should only be enabled on interfaces where no IGMPv2/MLDv1 + *   report suppression takes place. IGMP/MLD report suppression issue is + *   usually overcome by the network daemon (supplicant) enabling AP isolation + *   and by that separating all STAs. + * + *   Delivery of STA-to-STA IP multicast is made possible again by enabling + *   and utilizing the bridge hairpin mode, which considers the incoming port + *   as a potential outgoing port, too (see *BRIDGE_MODE_HAIRPIN* option). + *   Hairpin mode is performed after multicast snooping, therefore leading + *   to only deliver reports to STAs running a multicast router. + * + * @IFLA_BRPORT_VLAN_TUNNEL + *   Controls whether vlan to tunnel mapping is enabled on the port. + *   By default this flag is off. + * + * @IFLA_BRPORT_BCAST_FLOOD + *   Controls flooding of broadcast traffic on the given port. By default + *   this flag is on. + * + * @IFLA_BRPORT_GROUP_FWD_MASK + *   Set the group forward mask. This is a bitmask that is applied to + *   decide whether to forward incoming frames destined to link-local + *   addresses. The addresses of the form are 01:80:C2:00:00:0X (defaults + *   to 0, which means the bridge does not forward any link-local frames + *   coming on this port). + * + * @IFLA_BRPORT_NEIGH_SUPPRESS + *   Controls whether neighbor discovery (arp and nd) proxy and suppression + *   is enabled on the port. By default this flag is off. + * + * @IFLA_BRPORT_ISOLATED + *   Controls whether a given port will be isolated, which means it will be + *   able to communicate with non-isolated ports only. By default this + *   flag is off. + * + * @IFLA_BRPORT_BACKUP_PORT + *   Set a backup port. If the port loses carrier all traffic will be + *   redirected to the configured backup port. Set the value to 0 to disable + *   it. + * + * @IFLA_BRPORT_MRP_RING_OPEN + * + * @IFLA_BRPORT_MRP_IN_OPEN + * + * @IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT + *   The number of per-port EHT hosts limit. The default value is 512. + *   Setting to 0 is not allowed. + * + * @IFLA_BRPORT_MCAST_EHT_HOSTS_CNT + *   The current number of tracked hosts, read only. + * + * @IFLA_BRPORT_LOCKED + *   Controls whether a port will be locked, meaning that hosts behind the + *   port will not be able to communicate through the port unless an FDB + *   entry with the unit's MAC address is in the FDB. The common use case is + *   that hosts are allowed access through authentication with the IEEE 802.1X + *   protocol or based on whitelists. By default this flag is off. + * + *   Please note that secure 802.1X deployments should always use the + *   *BR_BOOLOPT_NO_LL_LEARN* flag, to not permit the bridge to populate its + *   FDB based on link-local (EAPOL) traffic received on the port. + * + * @IFLA_BRPORT_MAB + *   Controls whether a port will use MAC Authentication Bypass (MAB), a + *   technique through which select MAC addresses may be allowed on a locked + *   port, without using 802.1X authentication. Packets with an unknown source + *   MAC address generates a "locked" FDB entry on the incoming bridge port. + *   The common use case is for user space to react to these bridge FDB + *   notifications and optionally replace the locked FDB entry with a normal + *   one, allowing traffic to pass for whitelisted MAC addresses. + * + *   Setting this flag also requires *IFLA_BRPORT_LOCKED* and + *   *IFLA_BRPORT_LEARNING*. *IFLA_BRPORT_LOCKED* ensures that unauthorized + *   data packets are dropped, and *IFLA_BRPORT_LEARNING* allows the dynamic + *   FDB entries installed by user space (as replacements for the locked FDB + *   entries) to be refreshed and/or aged out. + * + * @IFLA_BRPORT_MCAST_N_GROUPS + * + * @IFLA_BRPORT_MCAST_MAX_GROUPS + *   Sets the maximum number of MDB entries that can be registered for a + *   given port. Attempts to register more MDB entries at the port than this + *   limit allows will be rejected, whether they are done through netlink + *   (e.g. the bridge tool), or IGMP or MLD membership reports. Setting a + *   limit of 0 disables the limit. The default value is 0. + * + * @IFLA_BRPORT_NEIGH_VLAN_SUPPRESS + *   Controls whether neighbor discovery (arp and nd) proxy and suppression is + *   enabled for a given port. By default this flag is off. + * + *   Note that this option only takes effect when *IFLA_BRPORT_NEIGH_SUPPRESS* + *   is enabled for a given port. + * + * @IFLA_BRPORT_BACKUP_NHID + *   The FDB nexthop object ID to attach to packets being redirected to a + *   backup port that has VLAN tunnel mapping enabled (via the + *   *IFLA_BRPORT_VLAN_TUNNEL* option). Setting a value of 0 (default) has + *   the effect of not attaching any ID. + */  enum {  	IFLA_BRPORT_UNSPEC,  	IFLA_BRPORT_STATE,	/* Spanning tree state     */ @@ -355,6 +1088,14 @@ enum {  	IFLA_BRPORT_BACKUP_PORT,  	IFLA_BRPORT_MRP_RING_OPEN,  	IFLA_BRPORT_MRP_IN_OPEN, +	IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT, +	IFLA_BRPORT_MCAST_EHT_HOSTS_CNT, +	IFLA_BRPORT_LOCKED, +	IFLA_BRPORT_MAB, +	IFLA_BRPORT_MCAST_N_GROUPS, +	IFLA_BRPORT_MCAST_MAX_GROUPS, +	IFLA_BRPORT_NEIGH_VLAN_SUPPRESS, +	IFLA_BRPORT_BACKUP_NHID,  	__IFLA_BRPORT_MAX  };  #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) @@ -419,6 +1160,9 @@ enum {  	IFLA_MACVLAN_MACADDR,  	IFLA_MACVLAN_MACADDR_DATA,  	IFLA_MACVLAN_MACADDR_COUNT, +	IFLA_MACVLAN_BC_QUEUE_LEN, +	IFLA_MACVLAN_BC_QUEUE_LEN_USED, +	IFLA_MACVLAN_BC_CUTOFF,  	__IFLA_MACVLAN_MAX,  }; @@ -440,6 +1184,7 @@ enum macvlan_macaddr_mode {  };  #define MACVLAN_FLAG_NOPROMISC	1 +#define MACVLAN_FLAG_NODST	2 /* skip dst macvlan if matching src macvlan */  /* VRF section */  enum { @@ -486,6 +1231,7 @@ enum {  	IFLA_XFRM_UNSPEC,  	IFLA_XFRM_LINK,  	IFLA_XFRM_IF_ID, +	IFLA_XFRM_COLLECT_METADATA,  	__IFLA_XFRM_MAX  }; @@ -527,7 +1273,96 @@ enum ipvlan_mode {  #define IPVLAN_F_PRIVATE	0x01  #define IPVLAN_F_VEPA		0x02 +/* Tunnel RTM header */ +struct tunnel_msg { +	__u8 family; +	__u8 flags; +	__u16 reserved2; +	__u32 ifindex; +}; + +/* netkit section */ +enum netkit_action { +	NETKIT_NEXT	= -1, +	NETKIT_PASS	= 0, +	NETKIT_DROP	= 2, +	NETKIT_REDIRECT	= 7, +}; + +enum netkit_mode { +	NETKIT_L2, +	NETKIT_L3, +}; + +/* NETKIT_SCRUB_NONE leaves clearing skb->{mark,priority} up to + * the BPF program if attached. This also means the latter can + * consume the two fields if they were populated earlier. + * + * NETKIT_SCRUB_DEFAULT zeroes skb->{mark,priority} fields before + * invoking the attached BPF program when the peer device resides + * in a different network namespace. This is the default behavior. + */ +enum netkit_scrub { +	NETKIT_SCRUB_NONE, +	NETKIT_SCRUB_DEFAULT, +}; + +enum { +	IFLA_NETKIT_UNSPEC, +	IFLA_NETKIT_PEER_INFO, +	IFLA_NETKIT_PRIMARY, +	IFLA_NETKIT_POLICY, +	IFLA_NETKIT_PEER_POLICY, +	IFLA_NETKIT_MODE, +	IFLA_NETKIT_SCRUB, +	IFLA_NETKIT_PEER_SCRUB, +	IFLA_NETKIT_HEADROOM, +	IFLA_NETKIT_TAILROOM, +	__IFLA_NETKIT_MAX, +}; +#define IFLA_NETKIT_MAX	(__IFLA_NETKIT_MAX - 1) +  /* VXLAN section */ + +/* include statistics in the dump */ +#define TUNNEL_MSG_FLAG_STATS	0x01 + +#define TUNNEL_MSG_VALID_USER_FLAGS TUNNEL_MSG_FLAG_STATS + +/* Embedded inside VXLAN_VNIFILTER_ENTRY_STATS */ +enum { +	VNIFILTER_ENTRY_STATS_UNSPEC, +	VNIFILTER_ENTRY_STATS_RX_BYTES, +	VNIFILTER_ENTRY_STATS_RX_PKTS, +	VNIFILTER_ENTRY_STATS_RX_DROPS, +	VNIFILTER_ENTRY_STATS_RX_ERRORS, +	VNIFILTER_ENTRY_STATS_TX_BYTES, +	VNIFILTER_ENTRY_STATS_TX_PKTS, +	VNIFILTER_ENTRY_STATS_TX_DROPS, +	VNIFILTER_ENTRY_STATS_TX_ERRORS, +	VNIFILTER_ENTRY_STATS_PAD, +	__VNIFILTER_ENTRY_STATS_MAX +}; +#define VNIFILTER_ENTRY_STATS_MAX (__VNIFILTER_ENTRY_STATS_MAX - 1) + +enum { +	VXLAN_VNIFILTER_ENTRY_UNSPEC, +	VXLAN_VNIFILTER_ENTRY_START, +	VXLAN_VNIFILTER_ENTRY_END, +	VXLAN_VNIFILTER_ENTRY_GROUP, +	VXLAN_VNIFILTER_ENTRY_GROUP6, +	VXLAN_VNIFILTER_ENTRY_STATS, +	__VXLAN_VNIFILTER_ENTRY_MAX +}; +#define VXLAN_VNIFILTER_ENTRY_MAX	(__VXLAN_VNIFILTER_ENTRY_MAX - 1) + +enum { +	VXLAN_VNIFILTER_UNSPEC, +	VXLAN_VNIFILTER_ENTRY, +	__VXLAN_VNIFILTER_MAX +}; +#define VXLAN_VNIFILTER_MAX	(__VXLAN_VNIFILTER_MAX - 1) +  enum {  	IFLA_VXLAN_UNSPEC,  	IFLA_VXLAN_ID, @@ -559,6 +1394,11 @@ enum {  	IFLA_VXLAN_GPE,  	IFLA_VXLAN_TTL_INHERIT,  	IFLA_VXLAN_DF, +	IFLA_VXLAN_VNIFILTER, /* only applicable with COLLECT_METADATA mode */ +	IFLA_VXLAN_LOCALBYPASS, +	IFLA_VXLAN_LABEL_POLICY, /* IPv6 flow label policy; ifla_vxlan_label_policy */ +	IFLA_VXLAN_RESERVED_BITS, +	IFLA_VXLAN_MC_ROUTE,  	__IFLA_VXLAN_MAX  };  #define IFLA_VXLAN_MAX	(__IFLA_VXLAN_MAX - 1) @@ -576,6 +1416,13 @@ enum ifla_vxlan_df {  	VXLAN_DF_MAX = __VXLAN_DF_END - 1,  }; +enum ifla_vxlan_label_policy { +	VXLAN_LABEL_FIXED = 0, +	VXLAN_LABEL_INHERIT = 1, +	__VXLAN_LABEL_END, +	VXLAN_LABEL_MAX = __VXLAN_LABEL_END - 1, +}; +  /* GENEVE section */  enum {  	IFLA_GENEVE_UNSPEC, @@ -592,6 +1439,8 @@ enum {  	IFLA_GENEVE_LABEL,  	IFLA_GENEVE_TTL_INHERIT,  	IFLA_GENEVE_DF, +	IFLA_GENEVE_INNER_PROTO_INHERIT, +	IFLA_GENEVE_PORT_RANGE,  	__IFLA_GENEVE_MAX  };  #define IFLA_GENEVE_MAX	(__IFLA_GENEVE_MAX - 1) @@ -604,6 +1453,11 @@ enum ifla_geneve_df {  	GENEVE_DF_MAX = __GENEVE_DF_END - 1,  }; +struct ifla_geneve_port_range { +	__be16 low; +	__be16 high; +}; +  /* Bareudp section  */  enum {  	IFLA_BAREUDP_UNSPEC, @@ -637,6 +1491,10 @@ enum {  	IFLA_GTP_FD1,  	IFLA_GTP_PDP_HASHSIZE,  	IFLA_GTP_ROLE, +	IFLA_GTP_CREATE_SOCKETS, +	IFLA_GTP_RESTART_COUNT, +	IFLA_GTP_LOCAL, +	IFLA_GTP_LOCAL6,  	__IFLA_GTP_MAX,  };  #define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1) @@ -673,6 +1531,11 @@ enum {  	IFLA_BOND_AD_ACTOR_SYSTEM,  	IFLA_BOND_TLB_DYNAMIC_LB,  	IFLA_BOND_PEER_NOTIF_DELAY, +	IFLA_BOND_AD_LACP_ACTIVE, +	IFLA_BOND_MISSED_MAX, +	IFLA_BOND_NS_IP6_TARGET, +	IFLA_BOND_COUPLED_CONTROL, +	IFLA_BOND_BROADCAST_NEIGH,  	__IFLA_BOND_MAX,  }; @@ -700,6 +1563,7 @@ enum {  	IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,  	IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,  	IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE, +	IFLA_BOND_SLAVE_PRIO,  	__IFLA_BOND_SLAVE_MAX,  }; @@ -937,6 +1801,7 @@ enum {  	IFLA_HSR_PROTOCOL,		/* Indicate different protocol than  					 * HSR. For example PRP.  					 */ +	IFLA_HSR_INTERLINK,		/* HSR interlink network device */  	__IFLA_HSR_MAX,  }; @@ -969,6 +1834,17 @@ enum {  #define IFLA_STATS_FILTER_BIT(ATTR)	(1 << (ATTR - 1)) +enum { +	IFLA_STATS_GETSET_UNSPEC, +	IFLA_STATS_GET_FILTERS, /* Nest of IFLA_STATS_LINK_xxx, each a u32 with +				 * a filter mask for the corresponding group. +				 */ +	IFLA_STATS_SET_OFFLOAD_XSTATS_L3_STATS, /* 0 or 1 as u8 */ +	__IFLA_STATS_GETSET_MAX, +}; + +#define IFLA_STATS_GETSET_MAX (__IFLA_STATS_GETSET_MAX - 1) +  /* These are embedded into IFLA_STATS_LINK_XSTATS:   * [IFLA_STATS_LINK_XSTATS]   * -> [LINK_XSTATS_TYPE_xxx] @@ -986,10 +1862,21 @@ enum {  enum {  	IFLA_OFFLOAD_XSTATS_UNSPEC,  	IFLA_OFFLOAD_XSTATS_CPU_HIT, /* struct rtnl_link_stats64 */ +	IFLA_OFFLOAD_XSTATS_HW_S_INFO,	/* HW stats info. A nest */ +	IFLA_OFFLOAD_XSTATS_L3_STATS,	/* struct rtnl_hw_stats64 */  	__IFLA_OFFLOAD_XSTATS_MAX  };  #define IFLA_OFFLOAD_XSTATS_MAX (__IFLA_OFFLOAD_XSTATS_MAX - 1) +enum { +	IFLA_OFFLOAD_XSTATS_HW_S_INFO_UNSPEC, +	IFLA_OFFLOAD_XSTATS_HW_S_INFO_REQUEST,		/* u8 */ +	IFLA_OFFLOAD_XSTATS_HW_S_INFO_USED,		/* u8 */ +	__IFLA_OFFLOAD_XSTATS_HW_S_INFO_MAX, +}; +#define IFLA_OFFLOAD_XSTATS_HW_S_INFO_MAX \ +	(__IFLA_OFFLOAD_XSTATS_HW_S_INFO_MAX - 1) +  /* XDP section */  #define XDP_FLAGS_UPDATE_IF_NOEXIST	(1U << 0) @@ -1061,6 +1948,8 @@ enum {  #define RMNET_FLAGS_INGRESS_MAP_COMMANDS          (1U << 1)  #define RMNET_FLAGS_INGRESS_MAP_CKSUMV4           (1U << 2)  #define RMNET_FLAGS_EGRESS_MAP_CKSUMV4            (1U << 3) +#define RMNET_FLAGS_INGRESS_MAP_CKSUMV5           (1U << 4) +#define RMNET_FLAGS_EGRESS_MAP_CKSUMV5            (1U << 5)  enum {  	IFLA_RMNET_UNSPEC, @@ -1076,4 +1965,42 @@ struct ifla_rmnet_flags {  	__u32	mask;  }; +/* MCTP section */ + +enum { +	IFLA_MCTP_UNSPEC, +	IFLA_MCTP_NET, +	IFLA_MCTP_PHYS_BINDING, +	__IFLA_MCTP_MAX, +}; + +#define IFLA_MCTP_MAX (__IFLA_MCTP_MAX - 1) + +/* DSA section */ + +enum { +	IFLA_DSA_UNSPEC, +	IFLA_DSA_CONDUIT, +	/* Deprecated, use IFLA_DSA_CONDUIT instead */ +	IFLA_DSA_MASTER = IFLA_DSA_CONDUIT, +	__IFLA_DSA_MAX, +}; + +#define IFLA_DSA_MAX	(__IFLA_DSA_MAX - 1) + +/* OVPN section */ + +enum ovpn_mode { +	OVPN_MODE_P2P, +	OVPN_MODE_MP, +}; + +enum { +	IFLA_OVPN_UNSPEC, +	IFLA_OVPN_MODE, +	__IFLA_OVPN_MAX, +}; + +#define IFLA_OVPN_MAX	(__IFLA_OVPN_MAX - 1) +  #endif /* _UAPI_LINUX_IF_LINK_H */ diff --git a/include/uapi/linux/if_macsec.h b/include/uapi/linux/if_macsec.h index 3af2aa069a36..d5b6d1f37353 100644 --- a/include/uapi/linux/if_macsec.h +++ b/include/uapi/linux/if_macsec.h @@ -22,6 +22,8 @@  #define MACSEC_KEYID_LEN 16 +#define MACSEC_SALT_LEN 12 +  /* cipher IDs as per IEEE802.1AE-2018 (Table 14-1) */  #define MACSEC_CIPHER_ID_GCM_AES_128 0x0080C20001000001ULL  #define MACSEC_CIPHER_ID_GCM_AES_256 0x0080C20001000002ULL diff --git a/include/uapi/linux/if_packet.h b/include/uapi/linux/if_packet.h index 3d884d68eb30..6cd1d7a41dfb 100644 --- a/include/uapi/linux/if_packet.h +++ b/include/uapi/linux/if_packet.h @@ -1,7 +1,8 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_IF_PACKET_H -#define __LINUX_IF_PACKET_H +#ifndef _UAPI__LINUX_IF_PACKET_H +#define _UAPI__LINUX_IF_PACKET_H +#include <asm/byteorder.h>  #include <linux/types.h>  struct sockaddr_pkt { @@ -58,6 +59,7 @@ struct sockaddr_ll {  #define PACKET_ROLLOVER_STATS		21  #define PACKET_FANOUT_DATA		22  #define PACKET_IGNORE_OUTGOING		23 +#define PACKET_VNET_HDR_SZ		24  #define PACKET_FANOUT_HASH		0  #define PACKET_FANOUT_LB		1 @@ -69,6 +71,7 @@ struct sockaddr_ll {  #define PACKET_FANOUT_EBPF		7  #define PACKET_FANOUT_FLAG_ROLLOVER	0x1000  #define PACKET_FANOUT_FLAG_UNIQUEID	0x2000 +#define PACKET_FANOUT_FLAG_IGNORE_OUTGOING     0x4000  #define PACKET_FANOUT_FLAG_DEFRAG	0x8000  struct tpacket_stats { @@ -113,6 +116,7 @@ struct tpacket_auxdata {  #define TP_STATUS_BLK_TMO		(1 << 5)  #define TP_STATUS_VLAN_TPID_VALID	(1 << 6) /* auxdata has valid tp_vlan_tpid */  #define TP_STATUS_CSUM_VALID		(1 << 7) +#define TP_STATUS_GSO_TCP		(1 << 8)  /* Tx ring - header status */  #define TP_STATUS_AVAILABLE	      0 @@ -226,8 +230,8 @@ struct tpacket_hdr_v1 {  	 * ts_first_pkt:  	 *		Is always the time-stamp when the block was opened.  	 *		Case a)	ZERO packets -	 *			No packets to deal with but atleast you know the -	 *			time-interval of this block. +	 *			No packets to deal with but at least you know +	 *			the time-interval of this block.  	 *		Case b) Non-zero packets  	 *			Use the ts of the first packet in the block.  	 * @@ -261,7 +265,8 @@ enum tpacket_versions {     - struct tpacket_hdr     - pad to TPACKET_ALIGNMENT=16     - struct sockaddr_ll -   - Gap, chosen so that packet data (Start+tp_net) alignes to TPACKET_ALIGNMENT=16 +   - Gap, chosen so that packet data (Start+tp_net) aligns to +     TPACKET_ALIGNMENT=16     - Start+tp_mac: [ Optional MAC header ]     - Start+tp_net: Packet data, aligned to TPACKET_ALIGNMENT=16.     - Pad to align to TPACKET_ALIGNMENT=16 @@ -296,6 +301,17 @@ struct packet_mreq {  	unsigned char	mr_address[8];  }; +struct fanout_args { +#if defined(__LITTLE_ENDIAN_BITFIELD) +	__u16		id; +	__u16		type_flags; +#else +	__u16		type_flags; +	__u16		id; +#endif +	__u32		max_num_members; +}; +  #define PACKET_MR_MULTICAST	0  #define PACKET_MR_PROMISC	1  #define PACKET_MR_ALLMULTI	2 diff --git a/include/uapi/linux/if_plip.h b/include/uapi/linux/if_plip.h index 495a366112f2..054d86a9c6e6 100644 --- a/include/uapi/linux/if_plip.h +++ b/include/uapi/linux/if_plip.h @@ -9,8 +9,8 @@   *   */ -#ifndef _LINUX_IF_PLIP_H -#define _LINUX_IF_PLIP_H +#ifndef _UAPI_LINUX_IF_PLIP_H +#define _UAPI_LINUX_IF_PLIP_H  #include <linux/sockios.h> diff --git a/include/uapi/linux/if_pppol2tp.h b/include/uapi/linux/if_pppol2tp.h index 060b4d1f3129..a91044328bc9 100644 --- a/include/uapi/linux/if_pppol2tp.h +++ b/include/uapi/linux/if_pppol2tp.h @@ -75,7 +75,7 @@ struct pppol2tpv3in6_addr {  };  /* Socket options: - * DEBUG	- bitmask of debug message categories + * DEBUG	- bitmask of debug message categories (not used)   * SENDSEQ	- 0 => don't send packets with sequence numbers   *		  1 => send packets with sequence numbers   * RECVSEQ	- 0 => receive packet sequence numbers are optional diff --git a/include/uapi/linux/if_pppox.h b/include/uapi/linux/if_pppox.h index e7a693c28f16..9abd80dcc46f 100644 --- a/include/uapi/linux/if_pppox.h +++ b/include/uapi/linux/if_pppox.h @@ -122,7 +122,7 @@ struct sockaddr_pppol2tpv3in6 {  struct pppoe_tag {  	__be16 tag_type;  	__be16 tag_len; -	char tag_data[0]; +	char tag_data[];  } __attribute__ ((packed));  /* Tag identifiers */ @@ -150,7 +150,7 @@ struct pppoe_hdr {  	__u8 code;  	__be16 sid;  	__be16 length; -	struct pppoe_tag tag[0]; +	struct pppoe_tag tag[];  } __packed;  /* Length of entire PPPoE + PPP header */ diff --git a/include/uapi/linux/if_slip.h b/include/uapi/linux/if_slip.h index 65937be53103..299bf7adc862 100644 --- a/include/uapi/linux/if_slip.h +++ b/include/uapi/linux/if_slip.h @@ -6,8 +6,8 @@   *	KISS TNC driver.   */ -#ifndef __LINUX_SLIP_H -#define __LINUX_SLIP_H +#ifndef _UAPI__LINUX_SLIP_H +#define _UAPI__LINUX_SLIP_H  #define		SL_MODE_SLIP		0  #define		SL_MODE_CSLIP		1 diff --git a/include/uapi/linux/if_team.h b/include/uapi/linux/if_team.h index 13c61fecb78b..a5c06243a435 100644 --- a/include/uapi/linux/if_team.h +++ b/include/uapi/linux/if_team.h @@ -1,108 +1,78 @@ -/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ -/* - * include/linux/if_team.h - Network team device driver header - * Copyright (c) 2011 Jiri Pirko <jpirko@redhat.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/team.yaml */ +/* YNL-GEN uapi header */ -#ifndef _UAPI_LINUX_IF_TEAM_H_ -#define _UAPI_LINUX_IF_TEAM_H_ +#ifndef _UAPI_LINUX_IF_TEAM_H +#define _UAPI_LINUX_IF_TEAM_H +#define TEAM_GENL_NAME		"team" +#define TEAM_GENL_VERSION	1 -#define TEAM_STRING_MAX_LEN 32 - -/********************************** - * NETLINK_GENERIC netlink family. - **********************************/ - -enum { -	TEAM_CMD_NOOP, -	TEAM_CMD_OPTIONS_SET, -	TEAM_CMD_OPTIONS_GET, -	TEAM_CMD_PORT_LIST_GET, - -	__TEAM_CMD_MAX, -	TEAM_CMD_MAX = (__TEAM_CMD_MAX - 1), -}; +#define TEAM_STRING_MAX_LEN			32 +#define TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME	"change_event"  enum {  	TEAM_ATTR_UNSPEC, -	TEAM_ATTR_TEAM_IFINDEX,		/* u32 */ -	TEAM_ATTR_LIST_OPTION,		/* nest */ -	TEAM_ATTR_LIST_PORT,		/* nest */ +	TEAM_ATTR_TEAM_IFINDEX, +	TEAM_ATTR_LIST_OPTION, +	TEAM_ATTR_LIST_PORT,  	__TEAM_ATTR_MAX, -	TEAM_ATTR_MAX = __TEAM_ATTR_MAX - 1, +	TEAM_ATTR_MAX = (__TEAM_ATTR_MAX - 1)  }; -/* Nested layout of get/set msg: - * - *	[TEAM_ATTR_LIST_OPTION] - *		[TEAM_ATTR_ITEM_OPTION] - *			[TEAM_ATTR_OPTION_*], ... - *		[TEAM_ATTR_ITEM_OPTION] - *			[TEAM_ATTR_OPTION_*], ... - *		... - *	[TEAM_ATTR_LIST_PORT] - *		[TEAM_ATTR_ITEM_PORT] - *			[TEAM_ATTR_PORT_*], ... - *		[TEAM_ATTR_ITEM_PORT] - *			[TEAM_ATTR_PORT_*], ... - *		... - */ -  enum {  	TEAM_ATTR_ITEM_OPTION_UNSPEC, -	TEAM_ATTR_ITEM_OPTION,		/* nest */ +	TEAM_ATTR_ITEM_OPTION,  	__TEAM_ATTR_ITEM_OPTION_MAX, -	TEAM_ATTR_ITEM_OPTION_MAX = __TEAM_ATTR_ITEM_OPTION_MAX - 1, +	TEAM_ATTR_ITEM_OPTION_MAX = (__TEAM_ATTR_ITEM_OPTION_MAX - 1)  };  enum {  	TEAM_ATTR_OPTION_UNSPEC, -	TEAM_ATTR_OPTION_NAME,		/* string */ -	TEAM_ATTR_OPTION_CHANGED,	/* flag */ -	TEAM_ATTR_OPTION_TYPE,		/* u8 */ -	TEAM_ATTR_OPTION_DATA,		/* dynamic */ -	TEAM_ATTR_OPTION_REMOVED,	/* flag */ -	TEAM_ATTR_OPTION_PORT_IFINDEX,	/* u32 */ /* for per-port options */ -	TEAM_ATTR_OPTION_ARRAY_INDEX,	/* u32 */ /* for array options */ +	TEAM_ATTR_OPTION_NAME, +	TEAM_ATTR_OPTION_CHANGED, +	TEAM_ATTR_OPTION_TYPE, +	TEAM_ATTR_OPTION_DATA, +	TEAM_ATTR_OPTION_REMOVED, +	TEAM_ATTR_OPTION_PORT_IFINDEX, +	TEAM_ATTR_OPTION_ARRAY_INDEX,  	__TEAM_ATTR_OPTION_MAX, -	TEAM_ATTR_OPTION_MAX = __TEAM_ATTR_OPTION_MAX - 1, +	TEAM_ATTR_OPTION_MAX = (__TEAM_ATTR_OPTION_MAX - 1)  };  enum {  	TEAM_ATTR_ITEM_PORT_UNSPEC, -	TEAM_ATTR_ITEM_PORT,		/* nest */ +	TEAM_ATTR_ITEM_PORT,  	__TEAM_ATTR_ITEM_PORT_MAX, -	TEAM_ATTR_ITEM_PORT_MAX = __TEAM_ATTR_ITEM_PORT_MAX - 1, +	TEAM_ATTR_ITEM_PORT_MAX = (__TEAM_ATTR_ITEM_PORT_MAX - 1)  };  enum {  	TEAM_ATTR_PORT_UNSPEC, -	TEAM_ATTR_PORT_IFINDEX,		/* u32 */ -	TEAM_ATTR_PORT_CHANGED,		/* flag */ -	TEAM_ATTR_PORT_LINKUP,		/* flag */ -	TEAM_ATTR_PORT_SPEED,		/* u32 */ -	TEAM_ATTR_PORT_DUPLEX,		/* u8 */ -	TEAM_ATTR_PORT_REMOVED,		/* flag */ +	TEAM_ATTR_PORT_IFINDEX, +	TEAM_ATTR_PORT_CHANGED, +	TEAM_ATTR_PORT_LINKUP, +	TEAM_ATTR_PORT_SPEED, +	TEAM_ATTR_PORT_DUPLEX, +	TEAM_ATTR_PORT_REMOVED,  	__TEAM_ATTR_PORT_MAX, -	TEAM_ATTR_PORT_MAX = __TEAM_ATTR_PORT_MAX - 1, +	TEAM_ATTR_PORT_MAX = (__TEAM_ATTR_PORT_MAX - 1)  }; -/* - * NETLINK_GENERIC related info - */ -#define TEAM_GENL_NAME "team" -#define TEAM_GENL_VERSION 0x1 -#define TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME "change_event" +enum { +	TEAM_CMD_NOOP, +	TEAM_CMD_OPTIONS_SET, +	TEAM_CMD_OPTIONS_GET, +	TEAM_CMD_PORT_LIST_GET, + +	__TEAM_CMD_MAX, +	TEAM_CMD_MAX = (__TEAM_CMD_MAX - 1) +}; -#endif /* _UAPI_LINUX_IF_TEAM_H_ */ +#endif /* _UAPI_LINUX_IF_TEAM_H */ diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h index 454ae31b93c7..79d53c7a1ebd 100644 --- a/include/uapi/linux/if_tun.h +++ b/include/uapi/linux/if_tun.h @@ -67,6 +67,8 @@  #define IFF_TAP		0x0002  #define IFF_NAPI	0x0010  #define IFF_NAPI_FRAGS	0x0020 +/* Used in TUNSETIFF to bring up tun/tap without carrier */ +#define IFF_NO_CARRIER	0x0040  #define IFF_NO_PI	0x1000  /* This flag has no real effect */  #define IFF_ONE_QUEUE	0x2000 @@ -88,6 +90,17 @@  #define TUN_F_TSO6	0x04	/* I can handle TSO for IPv6 packets */  #define TUN_F_TSO_ECN	0x08	/* I can handle TSO with ECN bits. */  #define TUN_F_UFO	0x10	/* I can handle UFO packets */ +#define TUN_F_USO4	0x20	/* I can handle USO for IPv4 packets */ +#define TUN_F_USO6	0x40	/* I can handle USO for IPv6 packets */ + +/* I can handle TSO/USO for UDP tunneled packets */ +#define TUN_F_UDP_TUNNEL_GSO		0x080 + +/* + * I can handle TSO/USO for UDP tunneled packets requiring csum offload for + * the outer header + */ +#define TUN_F_UDP_TUNNEL_GSO_CSUM	0x100  /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */  #define TUN_PKT_STRIP	0x0001 @@ -108,7 +121,7 @@ struct tun_pi {  struct tun_filter {  	__u16  flags; /* TUN_FLT_ flags see above */  	__u16  count; /* Number of addresses */ -	__u8   addr[0][ETH_ALEN]; +	__u8   addr[][ETH_ALEN];  };  #endif /* _UAPI__IF_TUN_H */ diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h index 7d9105533c7b..e1a246dd8c62 100644 --- a/include/uapi/linux/if_tunnel.h +++ b/include/uapi/linux/if_tunnel.h @@ -161,6 +161,14 @@ enum {  #define IFLA_VTI_MAX	(__IFLA_VTI_MAX - 1) +#ifndef __KERNEL__ +/* Historically, tunnel flags have been defined as __be16 and now there are + * no free bits left. It is strongly advised to switch the already existing + * userspace code to the new *_BIT definitions from down below, as __be16 + * can't be simply cast to a wider type on LE systems. All new flags and + * code must use *_BIT only. + */ +  #define TUNNEL_CSUM		__cpu_to_be16(0x01)  #define TUNNEL_ROUTING		__cpu_to_be16(0x02)  #define TUNNEL_KEY		__cpu_to_be16(0x04) @@ -176,8 +184,38 @@ enum {  #define TUNNEL_VXLAN_OPT	__cpu_to_be16(0x1000)  #define TUNNEL_NOCACHE		__cpu_to_be16(0x2000)  #define TUNNEL_ERSPAN_OPT	__cpu_to_be16(0x4000) +#define TUNNEL_GTP_OPT		__cpu_to_be16(0x8000)  #define TUNNEL_OPTIONS_PRESENT \ -		(TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT) +		(TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT | \ +		TUNNEL_GTP_OPT) +#endif + +enum { +	IP_TUNNEL_CSUM_BIT		= 0U, +	IP_TUNNEL_ROUTING_BIT, +	IP_TUNNEL_KEY_BIT, +	IP_TUNNEL_SEQ_BIT, +	IP_TUNNEL_STRICT_BIT, +	IP_TUNNEL_REC_BIT, +	IP_TUNNEL_VERSION_BIT, +	IP_TUNNEL_NO_KEY_BIT, +	IP_TUNNEL_DONT_FRAGMENT_BIT, +	IP_TUNNEL_OAM_BIT, +	IP_TUNNEL_CRIT_OPT_BIT, +	IP_TUNNEL_GENEVE_OPT_BIT,	/* OPTIONS_PRESENT */ +	IP_TUNNEL_VXLAN_OPT_BIT,	/* OPTIONS_PRESENT */ +	IP_TUNNEL_NOCACHE_BIT, +	IP_TUNNEL_ERSPAN_OPT_BIT,	/* OPTIONS_PRESENT */ +	IP_TUNNEL_GTP_OPT_BIT,		/* OPTIONS_PRESENT */ + +	IP_TUNNEL_VTI_BIT, +	IP_TUNNEL_SIT_ISATAP_BIT	= IP_TUNNEL_VTI_BIT, + +	/* Flags starting from here are not available via the old UAPI */ +	IP_TUNNEL_PFCP_OPT_BIT,		/* OPTIONS_PRESENT */ + +	__IP_TUNNEL_FLAG_NUM, +};  #endif /* _UAPI_IF_TUNNEL_H_ */ diff --git a/include/uapi/linux/if_x25.h b/include/uapi/linux/if_x25.h index 3a5938e38370..861cfa983db4 100644 --- a/include/uapi/linux/if_x25.h +++ b/include/uapi/linux/if_x25.h @@ -13,8 +13,8 @@   *  GNU General Public License for more details.   */ -#ifndef _IF_X25_H -#define _IF_X25_H +#ifndef _UAPI_IF_X25_H +#define _UAPI_IF_X25_H  #include <linux/types.h> @@ -24,4 +24,4 @@  #define X25_IFACE_DISCONNECT	0x02  #define X25_IFACE_PARAMS	0x03 -#endif /* _IF_X25_H */ +#endif /* _UAPI_IF_X25_H */ diff --git a/include/uapi/linux/if_xdp.h b/include/uapi/linux/if_xdp.h index a78a8096f4ce..23a062781468 100644 --- a/include/uapi/linux/if_xdp.h +++ b/include/uapi/linux/if_xdp.h @@ -7,8 +7,8 @@   *	      Magnus Karlsson <magnus.karlsson@intel.com>   */ -#ifndef _LINUX_IF_XDP_H -#define _LINUX_IF_XDP_H +#ifndef _UAPI_LINUX_IF_XDP_H +#define _UAPI_LINUX_IF_XDP_H  #include <linux/types.h> @@ -25,9 +25,25 @@   * application.   */  #define XDP_USE_NEED_WAKEUP (1 << 3) +/* By setting this option, userspace application indicates that it can + * handle multiple descriptors per packet thus enabling AF_XDP to split + * multi-buffer XDP frames into multiple Rx descriptors. Without this set + * such frames will be dropped. + */ +#define XDP_USE_SG	(1 << 4)  /* Flags for xsk_umem_config flags */ -#define XDP_UMEM_UNALIGNED_CHUNK_FLAG (1 << 0) +#define XDP_UMEM_UNALIGNED_CHUNK_FLAG	(1 << 0) + +/* Force checksum calculation in software. Can be used for testing or + * working around potential HW issues. This option causes performance + * degradation and only works in XDP_COPY mode. + */ +#define XDP_UMEM_TX_SW_CSUM		(1 << 1) + +/* Request to reserve tx_metadata_len bytes of per-chunk metadata. + */ +#define XDP_UMEM_TX_METADATA_LEN	(1 << 2)  struct sockaddr_xdp {  	__u16 sxdp_family; @@ -63,6 +79,7 @@ struct xdp_mmap_offsets {  #define XDP_UMEM_COMPLETION_RING	6  #define XDP_STATISTICS			7  #define XDP_OPTIONS			8 +#define XDP_MAX_TX_SKB_BUDGET		9  struct xdp_umem_reg {  	__u64 addr; /* Start of packet data area */ @@ -70,6 +87,7 @@ struct xdp_umem_reg {  	__u32 chunk_size;  	__u32 headroom;  	__u32 flags; +	__u32 tx_metadata_len;  };  struct xdp_statistics { @@ -99,6 +117,51 @@ struct xdp_options {  #define XSK_UNALIGNED_BUF_ADDR_MASK \  	((1ULL << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1) +/* Request transmit timestamp. Upon completion, put it into tx_timestamp + * field of struct xsk_tx_metadata. + */ +#define XDP_TXMD_FLAGS_TIMESTAMP		(1 << 0) + +/* Request transmit checksum offload. Checksum start position and offset + * are communicated via csum_start and csum_offset fields of struct + * xsk_tx_metadata. + */ +#define XDP_TXMD_FLAGS_CHECKSUM			(1 << 1) + +/* Request launch time hardware offload. The device will schedule the packet for + * transmission at a pre-determined time called launch time. The value of + * launch time is communicated via launch_time field of struct xsk_tx_metadata. + */ +#define XDP_TXMD_FLAGS_LAUNCH_TIME		(1 << 2) + +/* AF_XDP offloads request. 'request' union member is consumed by the driver + * when the packet is being transmitted. 'completion' union member is + * filled by the driver when the transmit completion arrives. + */ +struct xsk_tx_metadata { +	__u64 flags; + +	union { +		struct { +			/* XDP_TXMD_FLAGS_CHECKSUM */ + +			/* Offset from desc->addr where checksumming should start. */ +			__u16 csum_start; +			/* Offset from csum_start where checksum should be stored. */ +			__u16 csum_offset; + +			/* XDP_TXMD_FLAGS_LAUNCH_TIME */ +			/* Launch time in nanosecond against the PTP HW Clock */ +			__u64 launch_time; +		} request; + +		struct { +			/* XDP_TXMD_FLAGS_TIMESTAMP */ +			__u64 tx_timestamp; +		} completion; +	}; +}; +  /* Rx/Tx descriptor */  struct xdp_desc {  	__u64 addr; @@ -108,4 +171,14 @@ struct xdp_desc {  /* UMEM descriptor is __u64 */ -#endif /* _LINUX_IF_XDP_H */ +/* Flag indicating that the packet continues with the buffer pointed out by the + * next frame in the ring. The end of the packet is signalled by setting this + * bit to zero. For single buffer packets, every descriptor has 'options' set + * to 0 and this maintains backward compatibility. + */ +#define XDP_PKT_CONTD (1 << 0) + +/* TX packet carries valid metadata. */ +#define XDP_TX_METADATA (1 << 1) + +#endif /* _UAPI_LINUX_IF_XDP_H */ diff --git a/include/uapi/linux/igmp.h b/include/uapi/linux/igmp.h index 90c28bc466c6..5930f2437cd1 100644 --- a/include/uapi/linux/igmp.h +++ b/include/uapi/linux/igmp.h @@ -48,7 +48,7 @@ struct igmpv3_grec {  	__u8	grec_auxwords;  	__be16	grec_nsrcs;  	__be32	grec_mca; -	__be32	grec_src[0]; +	__be32	grec_src[];  };  struct igmpv3_report { @@ -57,7 +57,7 @@ struct igmpv3_report {  	__sum16 csum;  	__be16 resv2;  	__be16 ngrec; -	struct igmpv3_grec grec[0]; +	struct igmpv3_grec grec[];  };  struct igmpv3_query { @@ -78,7 +78,7 @@ struct igmpv3_query {  #endif  	__u8 qqic;  	__be16 nsrcs; -	__be32 srcs[0]; +	__be32 srcs[];  };  #define IGMP_HOST_MEMBERSHIP_QUERY	0x11	/* From RFC1112 */ diff --git a/include/uapi/linux/iio/buffer.h b/include/uapi/linux/iio/buffer.h new file mode 100644 index 000000000000..c666aa95e532 --- /dev/null +++ b/include/uapi/linux/iio/buffer.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* industrial I/O buffer definitions needed both in and out of kernel + */ + +#ifndef _UAPI_IIO_BUFFER_H_ +#define _UAPI_IIO_BUFFER_H_ + +#include <linux/types.h> + +/* Flags for iio_dmabuf.flags */ +#define IIO_BUFFER_DMABUF_CYCLIC		(1 << 0) +#define IIO_BUFFER_DMABUF_SUPPORTED_FLAGS	0x00000001 + +/** + * struct iio_dmabuf - Descriptor for a single IIO DMABUF object + * @fd:		file descriptor of the DMABUF object + * @flags:	one or more IIO_BUFFER_DMABUF_* flags + * @bytes_used:	number of bytes used in this DMABUF for the data transfer. + *		Should generally be set to the DMABUF's size. + */ +struct iio_dmabuf { +	__u32 fd; +	__u32 flags; +	__u64 bytes_used; +}; + +#define IIO_BUFFER_GET_FD_IOCTL			_IOWR('i', 0x91, int) +#define IIO_BUFFER_DMABUF_ATTACH_IOCTL		_IOW('i', 0x92, int) +#define IIO_BUFFER_DMABUF_DETACH_IOCTL		_IOW('i', 0x93, int) +#define IIO_BUFFER_DMABUF_ENQUEUE_IOCTL		_IOW('i', 0x94, struct iio_dmabuf) + +#endif /* _UAPI_IIO_BUFFER_H_ */ diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h index fdd81affca4b..3eb0821af7a4 100644 --- a/include/uapi/linux/iio/types.h +++ b/include/uapi/linux/iio/types.h @@ -47,6 +47,11 @@ enum iio_chan_type {  	IIO_POSITIONRELATIVE,  	IIO_PHASE,  	IIO_MASSCONCENTRATION, +	IIO_DELTA_ANGL, +	IIO_DELTA_VELOCITY, +	IIO_COLORTEMP, +	IIO_CHROMATICITY, +	IIO_ATTENTION,  };  enum iio_modifier { @@ -94,6 +99,15 @@ enum iio_modifier {  	IIO_MOD_PM10,  	IIO_MOD_ETHANOL,  	IIO_MOD_H2, +	IIO_MOD_O2, +	IIO_MOD_LINEAR_X, +	IIO_MOD_LINEAR_Y, +	IIO_MOD_LINEAR_Z, +	IIO_MOD_PITCH, +	IIO_MOD_YAW, +	IIO_MOD_ROLL, +	IIO_MOD_LIGHT_UVA, +	IIO_MOD_LIGHT_UVB,  };  enum iio_event_type { @@ -103,6 +117,9 @@ enum iio_event_type {  	IIO_EV_TYPE_THRESH_ADAPTIVE,  	IIO_EV_TYPE_MAG_ADAPTIVE,  	IIO_EV_TYPE_CHANGE, +	IIO_EV_TYPE_MAG_REFERENCED, +	IIO_EV_TYPE_GESTURE, +	IIO_EV_TYPE_FAULT,  };  enum iio_event_direction { @@ -110,7 +127,9 @@ enum iio_event_direction {  	IIO_EV_DIR_RISING,  	IIO_EV_DIR_FALLING,  	IIO_EV_DIR_NONE, +	IIO_EV_DIR_SINGLETAP, +	IIO_EV_DIR_DOUBLETAP, +	IIO_EV_DIR_FAULT_OPENWIRE,  };  #endif /* _UAPI_IIO_TYPES_H_ */ - diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h index 7d6687618d80..ced0fc3c3aa5 100644 --- a/include/uapi/linux/in.h +++ b/include/uapi/linux/in.h @@ -20,6 +20,7 @@  #define _UAPI_LINUX_IN_H  #include <linux/types.h> +#include <linux/stddef.h>  #include <linux/libc-compat.h>  #include <linux/socket.h> @@ -68,6 +69,8 @@ enum {  #define IPPROTO_PIM		IPPROTO_PIM    IPPROTO_COMP = 108,		/* Compression Header Protocol		*/  #define IPPROTO_COMP		IPPROTO_COMP +  IPPROTO_L2TP = 115,		/* Layer 2 Tunnelling Protocol		*/ +#define IPPROTO_L2TP		IPPROTO_L2TP    IPPROTO_SCTP = 132,		/* Stream Control Transport Protocol	*/  #define IPPROTO_SCTP		IPPROTO_SCTP    IPPROTO_UDPLITE = 136,	/* UDP-Lite (RFC 3828)			*/ @@ -76,8 +79,12 @@ enum {  #define IPPROTO_MPLS		IPPROTO_MPLS    IPPROTO_ETHERNET = 143,	/* Ethernet-within-IPv6 Encapsulation	*/  #define IPPROTO_ETHERNET	IPPROTO_ETHERNET +  IPPROTO_AGGFRAG = 144,	/* AGGFRAG in ESP (RFC 9347)		*/ +#define IPPROTO_AGGFRAG		IPPROTO_AGGFRAG    IPPROTO_RAW = 255,		/* Raw IP packets			*/  #define IPPROTO_RAW		IPPROTO_RAW +  IPPROTO_SMC = 256,		/* Shared Memory Communications		*/ +#define IPPROTO_SMC		IPPROTO_SMC    IPPROTO_MPTCP = 262,		/* Multipath TCP connection		*/  #define IPPROTO_MPTCP		IPPROTO_MPTCP    IPPROTO_MAX @@ -136,7 +143,7 @@ struct in_addr {   */  #define IP_PMTUDISC_INTERFACE		4  /* weaker version of IP_PMTUDISC_INTERFACE, which allows packets to get - * fragmented if they exeed the interface mtu + * fragmented if they exceed the interface mtu   */  #define IP_PMTUDISC_OMIT		5 @@ -159,6 +166,8 @@ struct in_addr {  #define MCAST_MSFILTER			48  #define IP_MULTICAST_ALL		49  #define IP_UNICAST_IF			50 +#define IP_LOCAL_PORT_RANGE		51 +#define IP_PROTOCOL			52  #define MCAST_EXCLUDE	0  #define MCAST_INCLUDE	1 @@ -192,7 +201,10 @@ struct ip_msfilter {  	__be32		imsf_interface;  	__u32		imsf_fmode;  	__u32		imsf_numsrc; -	__be32		imsf_slist[1]; +	union { +		__be32		imsf_slist[1]; +		__DECLARE_FLEX_ARRAY(__be32, imsf_slist_flex); +	};  };  #define IP_MSFILTER_SIZE(numsrc) \ @@ -211,11 +223,22 @@ struct group_source_req {  };  struct group_filter { -	__u32				 gf_interface;	/* interface index */ -	struct __kernel_sockaddr_storage gf_group;	/* multicast address */ -	__u32				 gf_fmode;	/* filter mode */ -	__u32				 gf_numsrc;	/* number of sources */ -	struct __kernel_sockaddr_storage gf_slist[1];	/* interface index */ +	union { +		struct { +			__u32				 gf_interface_aux; /* interface index */ +			struct __kernel_sockaddr_storage gf_group_aux;	   /* multicast address */ +			__u32				 gf_fmode_aux;	   /* filter mode */ +			__u32				 gf_numsrc_aux;	   /* number of sources */ +			struct __kernel_sockaddr_storage gf_slist[1];	   /* interface index */ +		}; +		struct { +			__u32				 gf_interface;	  /* interface index */ +			struct __kernel_sockaddr_storage gf_group;	  /* multicast address */ +			__u32				 gf_fmode;	  /* filter mode */ +			__u32				 gf_numsrc;	  /* number of sources */ +			struct __kernel_sockaddr_storage gf_slist_flex[]; /* interface index */ +		}; +	};  };  #define GROUP_FILTER_SIZE(numsrc) \ @@ -289,6 +312,9 @@ struct sockaddr_in {  /* Address indicating an error return. */  #define	INADDR_NONE		((unsigned long int) 0xffffffff) +/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */ +#define	INADDR_DUMMY		((unsigned long int) 0xc0000008) +  /* Network number for local host loopback. */  #define	IN_LOOPBACKNET		127 diff --git a/include/uapi/linux/in6.h b/include/uapi/linux/in6.h index 5ad396a57eb3..5a47339ef7d7 100644 --- a/include/uapi/linux/in6.h +++ b/include/uapi/linux/in6.h @@ -145,13 +145,13 @@ struct in6_flowlabel_req {  #define IPV6_TLV_PADN		1  #define IPV6_TLV_ROUTERALERT	5  #define IPV6_TLV_CALIPSO	7	/* RFC 5570 */ +#define IPV6_TLV_IOAM		49	/* RFC 9486 */  #define IPV6_TLV_JUMBO		194  #define IPV6_TLV_HAO		201	/* home address option */  /*   *	IPV6 socket options   */ -#if __UAPI_DEF_IPV6_OPTIONS  #define IPV6_ADDRFORM		1  #define IPV6_2292PKTINFO	2  #define IPV6_2292HOPOPTS	3 @@ -168,8 +168,10 @@ struct in6_flowlabel_req {  #define IPV6_MULTICAST_IF	17  #define IPV6_MULTICAST_HOPS	18  #define IPV6_MULTICAST_LOOP	19 +#if __UAPI_DEF_IPV6_OPTIONS  #define IPV6_ADD_MEMBERSHIP	20  #define IPV6_DROP_MEMBERSHIP	21 +#endif  #define IPV6_ROUTER_ALERT	22  #define IPV6_MTU_DISCOVER	23  #define IPV6_MTU		24 @@ -202,7 +204,6 @@ struct in6_flowlabel_req {  #define IPV6_IPSEC_POLICY	34  #define IPV6_XFRM_POLICY	35  #define IPV6_HDRINCL		36 -#endif  /*   * Multicast: diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h index 5ba122c1949a..86bb2e8b17c9 100644 --- a/include/uapi/linux/inet_diag.h +++ b/include/uapi/linux/inet_diag.h @@ -104,7 +104,7 @@ struct inet_diag_hostcond {  	__u8	family;  	__u8	prefix_len;  	int	port; -	__be32	addr[0]; +	__be32	addr[];  };  struct inet_diag_markcond { @@ -143,7 +143,7 @@ enum {  	INET_DIAG_SHUTDOWN,  	/* -	 * Next extenstions cannot be requested in struct inet_diag_req_v2: +	 * Next extensions cannot be requested in struct inet_diag_req_v2:  	 * its field idiag_ext has only 8 bits.  	 */ @@ -160,6 +160,7 @@ enum {  	INET_DIAG_ULP_INFO,  	INET_DIAG_SK_BPF_STORAGES,  	INET_DIAG_CGROUP_ID, +	INET_DIAG_SOCKOPT,  	__INET_DIAG_MAX,  }; @@ -183,6 +184,23 @@ struct inet_diag_meminfo {  	__u32	idiag_tmem;  }; +/* INET_DIAG_SOCKOPT */ + +struct inet_diag_sockopt { +	__u8	recverr:1, +		is_icsk:1, +		freebind:1, +		hdrincl:1, +		mc_loop:1, +		transparent:1, +		mc_all:1, +		nodefrag:1; +	__u8	bind_address_no_port:1, +		recverr_rfc4884:1, +		defer_connect:1, +		unused:5; +}; +  /* INET_DIAG_VEGASINFO */  struct tcpvegas_info { diff --git a/include/uapi/linux/inotify.h b/include/uapi/linux/inotify.h index 884b4846b630..d94f20e38e5d 100644 --- a/include/uapi/linux/inotify.h +++ b/include/uapi/linux/inotify.h @@ -23,15 +23,15 @@ struct inotify_event {  	__u32		mask;		/* watch mask */  	__u32		cookie;		/* cookie to synchronize two events */  	__u32		len;		/* length (including nulls) of name */ -	char		name[0];	/* stub for possible name */ +	char		name[];	/* stub for possible name */  };  /* the following are legal, implemented events that user-space can watch for */  #define IN_ACCESS		0x00000001	/* File was accessed */  #define IN_MODIFY		0x00000002	/* File was modified */  #define IN_ATTRIB		0x00000004	/* Metadata changed */ -#define IN_CLOSE_WRITE		0x00000008	/* Writtable file was closed */ -#define IN_CLOSE_NOWRITE	0x00000010	/* Unwrittable file closed */ +#define IN_CLOSE_WRITE		0x00000008	/* Writable file was closed */ +#define IN_CLOSE_NOWRITE	0x00000010	/* Unwritable file closed */  #define IN_OPEN			0x00000020	/* File was opened */  #define IN_MOVED_FROM		0x00000040	/* File was moved from X */  #define IN_MOVED_TO		0x00000080	/* File was moved to Y */ diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h index 0c2e27d28e0a..ca5851e97fac 100644 --- a/include/uapi/linux/input-event-codes.h +++ b/include/uapi/linux/input-event-codes.h @@ -278,7 +278,8 @@  #define KEY_PAUSECD		201  #define KEY_PROG3		202  #define KEY_PROG4		203 -#define KEY_DASHBOARD		204	/* AL Dashboard */ +#define KEY_ALL_APPLICATIONS	204	/* AC Desktop Show All Applications */ +#define KEY_DASHBOARD		KEY_ALL_APPLICATIONS  #define KEY_SUSPEND		205  #define KEY_CLOSE		206	/* AC Close */  #define KEY_PLAY		207 @@ -515,6 +516,10 @@  #define KEY_10CHANNELSUP	0x1b8	/* 10 channels up (10+) */  #define KEY_10CHANNELSDOWN	0x1b9	/* 10 channels down (10-) */  #define KEY_IMAGES		0x1ba	/* AL Image Browser */ +#define KEY_NOTIFICATION_CENTER	0x1bc	/* Show/hide the notification center */ +#define KEY_PICKUP_PHONE	0x1bd	/* Answer incoming call */ +#define KEY_HANGUP_PHONE	0x1be	/* Decline incoming call */ +#define KEY_LINK_PHONE		0x1bf   /* AL Phone Syncing */  #define KEY_DEL_EOL		0x1c0  #define KEY_DEL_EOS		0x1c1 @@ -542,6 +547,7 @@  #define KEY_FN_F		0x1e2  #define KEY_FN_S		0x1e3  #define KEY_FN_B		0x1e4 +#define KEY_FN_RIGHT_SHIFT	0x1e5  #define KEY_BRL_DOT1		0x1f1  #define KEY_BRL_DOT2		0x1f2 @@ -595,8 +601,14 @@  #define BTN_DPAD_LEFT		0x222  #define BTN_DPAD_RIGHT		0x223 +#define BTN_GRIPL		0x224 +#define BTN_GRIPR		0x225 +#define BTN_GRIPL2		0x226 +#define BTN_GRIPR2		0x227 +  #define KEY_ALS_TOGGLE		0x230	/* Ambient light sensor */  #define KEY_ROTATE_LOCK_TOGGLE	0x231	/* Display rotation lock */ +#define KEY_REFRESH_RATE_TOGGLE	0x232	/* Display refresh rate toggle */  #define KEY_BUTTONCONFIG		0x240	/* AL Button Configuration */  #define KEY_TASKMANAGER		0x241	/* AL Task/Project Manager */ @@ -607,6 +619,13 @@  #define KEY_VOICECOMMAND		0x246	/* Listening Voice Command */  #define KEY_ASSISTANT		0x247	/* AL Context-aware desktop assistant */  #define KEY_KBD_LAYOUT_NEXT	0x248	/* AC Next Keyboard Layout Select */ +#define KEY_EMOJI_PICKER	0x249	/* Show/hide emoji picker (HUTRR101) */ +#define KEY_DICTATE		0x24a	/* Start or Stop Voice Dictation Session (HUTRR99) */ +#define KEY_CAMERA_ACCESS_ENABLE	0x24b	/* Enables programmatic access to camera devices. (HUTRR72) */ +#define KEY_CAMERA_ACCESS_DISABLE	0x24c	/* Disables programmatic access to camera devices. (HUTRR72) */ +#define KEY_CAMERA_ACCESS_TOGGLE	0x24d	/* Toggles the current state of the camera access control. (HUTRR72) */ +#define KEY_ACCESSIBILITY		0x24e	/* Toggles the system bound accessibility UI/command (HUTRR116) */ +#define KEY_DO_NOT_DISTURB		0x24f	/* Toggles the system-wide "Do Not Disturb" control (HUTRR94)*/  #define KEY_BRIGHTNESS_MIN		0x250	/* Set Brightness to Minimum */  #define KEY_BRIGHTNESS_MAX		0x251	/* Set Brightness to Maximum */ @@ -655,6 +674,27 @@  /* Select an area of screen to be copied */  #define KEY_SELECTIVE_SCREENSHOT	0x27a +/* Move the focus to the next or previous user controllable element within a UI container */ +#define KEY_NEXT_ELEMENT               0x27b +#define KEY_PREVIOUS_ELEMENT           0x27c + +/* Toggle Autopilot engagement */ +#define KEY_AUTOPILOT_ENGAGE_TOGGLE    0x27d + +/* Shortcut Keys */ +#define KEY_MARK_WAYPOINT              0x27e +#define KEY_SOS                                0x27f +#define KEY_NAV_CHART                  0x280 +#define KEY_FISHING_CHART              0x281 +#define KEY_SINGLE_RANGE_RADAR         0x282 +#define KEY_DUAL_RANGE_RADAR           0x283 +#define KEY_RADAR_OVERLAY              0x284 +#define KEY_TRADITIONAL_SONAR          0x285 +#define KEY_CLEARVU_SONAR              0x286 +#define KEY_SIDEVU_SONAR               0x287 +#define KEY_NAV_INFO                   0x288 +#define KEY_BRIGHTNESS_MENU            0x289 +  /*   * Some keyboards have keys which do not have a defined meaning, these keys   * are intended to be programmed / bound to macros by the user. For most @@ -730,6 +770,9 @@  #define KEY_KBD_LCD_MENU4		0x2bb  #define KEY_KBD_LCD_MENU5		0x2bc +/* Performance Boost key (Alienware)/G-Mode key (Dell) */ +#define KEY_PERFORMANCE			0x2bd +  #define BTN_TRIGGER_HAPPY		0x2c0  #define BTN_TRIGGER_HAPPY1		0x2c0  #define BTN_TRIGGER_HAPPY2		0x2c1 @@ -834,6 +877,7 @@  #define ABS_TOOL_WIDTH		0x1c  #define ABS_VOLUME		0x20 +#define ABS_PROFILE		0x21  #define ABS_MISC		0x28 @@ -889,7 +933,8 @@  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */  #define SW_MACHINE_COVER	0x10  /* set = cover closed */ -#define SW_MAX			0x10 +#define SW_USB_INSERT		0x11  /* set = USB audio device connected */ +#define SW_MAX			0x11  #define SW_CNT			(SW_MAX+1)  /* diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index 9a61c28ed3ae..127119c287cf 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h @@ -78,13 +78,16 @@ struct input_id {   * Note that input core does not clamp reported values to the   * [minimum, maximum] limits, such task is left to userspace.   * - * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z) - * is reported in units per millimeter (units/mm), resolution - * for rotational axes (ABS_RX, ABS_RY, ABS_RZ) is reported - * in units per radian. + * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z, + * ABS_MT_POSITION_X, ABS_MT_POSITION_Y) is reported in units + * per millimeter (units/mm), resolution for rotational axes + * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian. + * The resolution for the size axes (ABS_MT_TOUCH_MAJOR, + * ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR) + * is reported in units per millimeter (units/mm).   * When INPUT_PROP_ACCELEROMETER is set the resolution changes.   * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in - * in units per g (units/g) and in units per degree per second + * units per g (units/g) and in units per degree per second   * (units/deg/s) for rotational axes (ABS_RX, ABS_RY, ABS_RZ).   */  struct input_absinfo { @@ -271,6 +274,8 @@ struct input_mask {  #define BUS_RMI			0x1D  #define BUS_CEC			0x1E  #define BUS_INTEL_ISHTP		0x1F +#define BUS_AMD_SFH		0x20 +#define BUS_SDW			0x21  /*   * MT_TOOL types diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index d65fde732518..6957dc539d83 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -10,6 +10,19 @@  #include <linux/fs.h>  #include <linux/types.h> +/* + * this file is shared with liburing and that has to autodetect + * if linux/time_types.h is available or not, it can + * define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H + * if linux/time_types.h is not available + */ +#ifndef UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H +#include <linux/time_types.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif  /*   * IO submission data structure (Submission Queue Entry) @@ -22,14 +35,22 @@ struct io_uring_sqe {  	union {  		__u64	off;	/* offset into file */  		__u64	addr2; +		struct { +			__u32	cmd_op; +			__u32	__pad1; +		};  	};  	union {  		__u64	addr;	/* pointer to buffer or iovecs */  		__u64	splice_off_in; +		struct { +			__u32	level; +			__u32	optname; +		};  	};  	__u32	len;		/* buffer size or number of iovecs */  	union { -		__kernel_rwf_t	rw_flags; +		__u32		rw_flags;  		__u32		fsync_flags;  		__u16		poll_events;	/* compatibility */  		__u32		poll32_events;	/* word-reversed for BE */ @@ -42,32 +63,89 @@ struct io_uring_sqe {  		__u32		statx_flags;  		__u32		fadvise_advice;  		__u32		splice_flags; +		__u32		rename_flags; +		__u32		unlink_flags; +		__u32		hardlink_flags; +		__u32		xattr_flags; +		__u32		msg_ring_flags; +		__u32		uring_cmd_flags; +		__u32		waitid_flags; +		__u32		futex_flags; +		__u32		install_fd_flags; +		__u32		nop_flags; +		__u32		pipe_flags;  	};  	__u64	user_data;	/* data to be passed back at completion time */ +	/* pack this to avoid bogus arm OABI complaints */ +	union { +		/* index into fixed buffers, if used */ +		__u16	buf_index; +		/* for grouped buffer selection */ +		__u16	buf_group; +	} __attribute__((packed)); +	/* personality to use, if used */ +	__u16	personality;  	union { +		__s32	splice_fd_in; +		__u32	file_index; +		__u32	zcrx_ifq_idx; +		__u32	optlen; +		struct { +			__u16	addr_len; +			__u16	__pad3[1]; +		};  		struct { -			/* pack this to avoid bogus arm OABI complaints */ -			union { -				/* index into fixed buffers, if used */ -				__u16	buf_index; -				/* for grouped buffer selection */ -				__u16	buf_group; -			} __attribute__((packed)); -			/* personality to use, if used */ -			__u16	personality; -			__s32	splice_fd_in; +			__u8	write_stream; +			__u8	__pad4[3];  		}; -		__u64	__pad2[3]; +	}; +	union { +		struct { +			__u64	addr3; +			__u64	__pad2[1]; +		}; +		struct { +			__u64	attr_ptr; /* pointer to attribute information */ +			__u64	attr_type_mask; /* bit mask of attributes */ +		}; +		__u64	optval; +		/* +		 * If the ring is initialized with IORING_SETUP_SQE128, then +		 * this field is used for 80 bytes of arbitrary command data +		 */ +		__u8	cmd[0];  	};  }; -enum { +/* sqe->attr_type_mask flags */ +#define IORING_RW_ATTR_FLAG_PI	(1U << 0) +/* PI attribute information */ +struct io_uring_attr_pi { +		__u16	flags; +		__u16	app_tag; +		__u32	len; +		__u64	addr; +		__u64	seed; +		__u64	rsvd; +}; + +/* + * If sqe->file_index is set to this for opcodes that instantiate a new + * direct descriptor (like openat/openat2/accept), then io_uring will allocate + * an available direct descriptor instead of having the application pass one + * in. The picked direct descriptor will be returned in cqe->res, or -ENFILE + * if the space is full. + */ +#define IORING_FILE_INDEX_ALLOC		(~0U) + +enum io_uring_sqe_flags_bit {  	IOSQE_FIXED_FILE_BIT,  	IOSQE_IO_DRAIN_BIT,  	IOSQE_IO_LINK_BIT,  	IOSQE_IO_HARDLINK_BIT,  	IOSQE_ASYNC_BIT,  	IOSQE_BUFFER_SELECT_BIT, +	IOSQE_CQE_SKIP_SUCCESS_BIT,  };  /* @@ -85,6 +163,8 @@ enum {  #define IOSQE_ASYNC		(1U << IOSQE_ASYNC_BIT)  /* select buffer from sqe->buf_group */  #define IOSQE_BUFFER_SELECT	(1U << IOSQE_BUFFER_SELECT_BIT) +/* don't post CQE if request succeeded */ +#define IOSQE_CQE_SKIP_SUCCESS	(1U << IOSQE_CQE_SKIP_SUCCESS_BIT)  /*   * io_uring_setup() flags @@ -95,8 +175,57 @@ enum {  #define IORING_SETUP_CQSIZE	(1U << 3)	/* app defines CQ size */  #define IORING_SETUP_CLAMP	(1U << 4)	/* clamp SQ/CQ ring sizes */  #define IORING_SETUP_ATTACH_WQ	(1U << 5)	/* attach to existing wq */ +#define IORING_SETUP_R_DISABLED	(1U << 6)	/* start with ring disabled */ +#define IORING_SETUP_SUBMIT_ALL	(1U << 7)	/* continue submit on error */ +/* + * Cooperative task running. When requests complete, they often require + * forcing the submitter to transition to the kernel to complete. If this + * flag is set, work will be done when the task transitions anyway, rather + * than force an inter-processor interrupt reschedule. This avoids interrupting + * a task running in userspace, and saves an IPI. + */ +#define IORING_SETUP_COOP_TASKRUN	(1U << 8) +/* + * If COOP_TASKRUN is set, get notified if task work is available for + * running and a kernel transition would be needed to run it. This sets + * IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN. + */ +#define IORING_SETUP_TASKRUN_FLAG	(1U << 9) +#define IORING_SETUP_SQE128		(1U << 10) /* SQEs are 128 byte */ +#define IORING_SETUP_CQE32		(1U << 11) /* CQEs are 32 byte */ +/* + * Only one task is allowed to submit requests + */ +#define IORING_SETUP_SINGLE_ISSUER	(1U << 12) -enum { +/* + * Defer running task work to get events. + * Rather than running bits of task work whenever the task transitions + * try to do it just before it is needed. + */ +#define IORING_SETUP_DEFER_TASKRUN	(1U << 13) + +/* + * Application provides the memory for the rings + */ +#define IORING_SETUP_NO_MMAP		(1U << 14) + +/* + * Register the ring fd in itself for use with + * IORING_REGISTER_USE_REGISTERED_RING; return a registered fd index rather + * than an fd. + */ +#define IORING_SETUP_REGISTERED_FD_ONLY	(1U << 15) + +/* + * Removes indirection through the SQ index array. + */ +#define IORING_SETUP_NO_SQARRAY		(1U << 16) + +/* Use hybrid poll in iopoll process */ +#define IORING_SETUP_HYBRID_IOPOLL	(1U << 17) + +enum io_uring_op {  	IORING_OP_NOP,  	IORING_OP_READV,  	IORING_OP_WRITEV, @@ -131,12 +260,50 @@ enum {  	IORING_OP_PROVIDE_BUFFERS,  	IORING_OP_REMOVE_BUFFERS,  	IORING_OP_TEE, +	IORING_OP_SHUTDOWN, +	IORING_OP_RENAMEAT, +	IORING_OP_UNLINKAT, +	IORING_OP_MKDIRAT, +	IORING_OP_SYMLINKAT, +	IORING_OP_LINKAT, +	IORING_OP_MSG_RING, +	IORING_OP_FSETXATTR, +	IORING_OP_SETXATTR, +	IORING_OP_FGETXATTR, +	IORING_OP_GETXATTR, +	IORING_OP_SOCKET, +	IORING_OP_URING_CMD, +	IORING_OP_SEND_ZC, +	IORING_OP_SENDMSG_ZC, +	IORING_OP_READ_MULTISHOT, +	IORING_OP_WAITID, +	IORING_OP_FUTEX_WAIT, +	IORING_OP_FUTEX_WAKE, +	IORING_OP_FUTEX_WAITV, +	IORING_OP_FIXED_FD_INSTALL, +	IORING_OP_FTRUNCATE, +	IORING_OP_BIND, +	IORING_OP_LISTEN, +	IORING_OP_RECV_ZC, +	IORING_OP_EPOLL_WAIT, +	IORING_OP_READV_FIXED, +	IORING_OP_WRITEV_FIXED, +	IORING_OP_PIPE,  	/* this goes last, obviously */  	IORING_OP_LAST,  };  /* + * sqe->uring_cmd_flags		top 8bits aren't available for userspace + * IORING_URING_CMD_FIXED	use registered buffer; pass this flag + *				along with setting sqe->buf_index. + */ +#define IORING_URING_CMD_FIXED	(1U << 0) +#define IORING_URING_CMD_MASK	IORING_URING_CMD_FIXED + + +/*   * sqe->fsync_flags   */  #define IORING_FSYNC_DATASYNC	(1U << 0) @@ -144,8 +311,15 @@ enum {  /*   * sqe->timeout_flags   */ -#define IORING_TIMEOUT_ABS	(1U << 0) - +#define IORING_TIMEOUT_ABS		(1U << 0) +#define IORING_TIMEOUT_UPDATE		(1U << 1) +#define IORING_TIMEOUT_BOOTTIME		(1U << 2) +#define IORING_TIMEOUT_REALTIME		(1U << 3) +#define IORING_LINK_TIMEOUT_UPDATE	(1U << 4) +#define IORING_TIMEOUT_ETIME_SUCCESS	(1U << 5) +#define IORING_TIMEOUT_MULTISHOT	(1U << 6) +#define IORING_TIMEOUT_CLOCK_MASK	(IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME) +#define IORING_TIMEOUT_UPDATE_MASK	(IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE)  /*   * sqe->splice_flags   * extends splice(2) flags @@ -153,24 +327,174 @@ enum {  #define SPLICE_F_FD_IN_FIXED	(1U << 31) /* the last bit of __u32 */  /* + * POLL_ADD flags. Note that since sqe->poll_events is the flag space, the + * command flags for POLL_ADD are stored in sqe->len. + * + * IORING_POLL_ADD_MULTI	Multishot poll. Sets IORING_CQE_F_MORE if + *				the poll handler will continue to report + *				CQEs on behalf of the same SQE. + * + * IORING_POLL_UPDATE		Update existing poll request, matching + *				sqe->addr as the old user_data field. + * + * IORING_POLL_LEVEL		Level triggered poll. + */ +#define IORING_POLL_ADD_MULTI	(1U << 0) +#define IORING_POLL_UPDATE_EVENTS	(1U << 1) +#define IORING_POLL_UPDATE_USER_DATA	(1U << 2) +#define IORING_POLL_ADD_LEVEL		(1U << 3) + +/* + * ASYNC_CANCEL flags. + * + * IORING_ASYNC_CANCEL_ALL	Cancel all requests that match the given key + * IORING_ASYNC_CANCEL_FD	Key off 'fd' for cancelation rather than the + *				request 'user_data' + * IORING_ASYNC_CANCEL_ANY	Match any request + * IORING_ASYNC_CANCEL_FD_FIXED	'fd' passed in is a fixed descriptor + * IORING_ASYNC_CANCEL_USERDATA	Match on user_data, default for no other key + * IORING_ASYNC_CANCEL_OP	Match request based on opcode + */ +#define IORING_ASYNC_CANCEL_ALL	(1U << 0) +#define IORING_ASYNC_CANCEL_FD	(1U << 1) +#define IORING_ASYNC_CANCEL_ANY	(1U << 2) +#define IORING_ASYNC_CANCEL_FD_FIXED	(1U << 3) +#define IORING_ASYNC_CANCEL_USERDATA	(1U << 4) +#define IORING_ASYNC_CANCEL_OP	(1U << 5) + +/* + * send/sendmsg and recv/recvmsg flags (sqe->ioprio) + * + * IORING_RECVSEND_POLL_FIRST	If set, instead of first attempting to send + *				or receive and arm poll if that yields an + *				-EAGAIN result, arm poll upfront and skip + *				the initial transfer attempt. + * + * IORING_RECV_MULTISHOT	Multishot recv. Sets IORING_CQE_F_MORE if + *				the handler will continue to report + *				CQEs on behalf of the same SQE. + * + * IORING_RECVSEND_FIXED_BUF	Use registered buffers, the index is stored in + *				the buf_index field. + * + * IORING_SEND_ZC_REPORT_USAGE + *				If set, SEND[MSG]_ZC should report + *				the zerocopy usage in cqe.res + *				for the IORING_CQE_F_NOTIF cqe. + *				0 is reported if zerocopy was actually possible. + *				IORING_NOTIF_USAGE_ZC_COPIED if data was copied + *				(at least partially). + * + * IORING_RECVSEND_BUNDLE	Used with IOSQE_BUFFER_SELECT. If set, send or + *				recv will grab as many buffers from the buffer + *				group ID given and send them all. The completion + *				result 	will be the number of buffers send, with + *				the starting buffer ID in cqe->flags as per + *				usual for provided buffer usage. The buffers + *				will be	contiguous from the starting buffer ID. + * + * IORING_SEND_VECTORIZED	If set, SEND[_ZC] will take a pointer to a io_vec + * 				to allow vectorized send operations. + */ +#define IORING_RECVSEND_POLL_FIRST	(1U << 0) +#define IORING_RECV_MULTISHOT		(1U << 1) +#define IORING_RECVSEND_FIXED_BUF	(1U << 2) +#define IORING_SEND_ZC_REPORT_USAGE	(1U << 3) +#define IORING_RECVSEND_BUNDLE		(1U << 4) +#define IORING_SEND_VECTORIZED		(1U << 5) + +/* + * cqe.res for IORING_CQE_F_NOTIF if + * IORING_SEND_ZC_REPORT_USAGE was requested + * + * It should be treated as a flag, all other + * bits of cqe.res should be treated as reserved! + */ +#define IORING_NOTIF_USAGE_ZC_COPIED    (1U << 31) + +/* + * accept flags stored in sqe->ioprio + */ +#define IORING_ACCEPT_MULTISHOT	(1U << 0) +#define IORING_ACCEPT_DONTWAIT	(1U << 1) +#define IORING_ACCEPT_POLL_FIRST	(1U << 2) + +/* + * IORING_OP_MSG_RING command types, stored in sqe->addr + */ +enum io_uring_msg_ring_flags { +	IORING_MSG_DATA,	/* pass sqe->len as 'res' and off as user_data */ +	IORING_MSG_SEND_FD,	/* send a registered fd to another ring */ +}; + +/* + * IORING_OP_MSG_RING flags (sqe->msg_ring_flags) + * + * IORING_MSG_RING_CQE_SKIP	Don't post a CQE to the target ring. Not + *				applicable for IORING_MSG_DATA, obviously. + */ +#define IORING_MSG_RING_CQE_SKIP	(1U << 0) +/* Pass through the flags from sqe->file_index to cqe->flags */ +#define IORING_MSG_RING_FLAGS_PASS	(1U << 1) + +/* + * IORING_OP_FIXED_FD_INSTALL flags (sqe->install_fd_flags) + * + * IORING_FIXED_FD_NO_CLOEXEC	Don't mark the fd as O_CLOEXEC + */ +#define IORING_FIXED_FD_NO_CLOEXEC	(1U << 0) + +/* + * IORING_OP_NOP flags (sqe->nop_flags) + * + * IORING_NOP_INJECT_RESULT	Inject result from sqe->result + */ +#define IORING_NOP_INJECT_RESULT	(1U << 0) +#define IORING_NOP_FILE			(1U << 1) +#define IORING_NOP_FIXED_FILE		(1U << 2) +#define IORING_NOP_FIXED_BUFFER		(1U << 3) +#define IORING_NOP_TW			(1U << 4) + +/*   * IO completion data structure (Completion Queue Entry)   */  struct io_uring_cqe { -	__u64	user_data;	/* sqe->data submission passed back */ +	__u64	user_data;	/* sqe->user_data value passed back */  	__s32	res;		/* result code for this event */  	__u32	flags; + +	/* +	 * If the ring is initialized with IORING_SETUP_CQE32, then this field +	 * contains 16-bytes of padding, doubling the size of the CQE. +	 */ +	__u64 big_cqe[];  };  /*   * cqe->flags   *   * IORING_CQE_F_BUFFER	If set, the upper 16 bits are the buffer ID + * IORING_CQE_F_MORE	If set, parent SQE will generate more CQE entries + * IORING_CQE_F_SOCK_NONEMPTY	If set, more data to read after socket recv + * IORING_CQE_F_NOTIF	Set for notification CQEs. Can be used to distinct + * 			them from sends. + * IORING_CQE_F_BUF_MORE If set, the buffer ID set in the completion will get + *			more completions. In other words, the buffer is being + *			partially consumed, and will be used by the kernel for + *			more completions. This is only set for buffers used via + *			the incremental buffer consumption, as provided by + *			a ring buffer setup with IOU_PBUF_RING_INC. For any + *			other provided buffer type, all completions with a + *			buffer passed back is automatically returned to the + *			application.   */  #define IORING_CQE_F_BUFFER		(1U << 0) +#define IORING_CQE_F_MORE		(1U << 1) +#define IORING_CQE_F_SOCK_NONEMPTY	(1U << 2) +#define IORING_CQE_F_NOTIF		(1U << 3) +#define IORING_CQE_F_BUF_MORE		(1U << 4) -enum { -	IORING_CQE_BUFFER_SHIFT		= 16, -}; +#define IORING_CQE_BUFFER_SHIFT		16  /*   * Magic offsets for the application to mmap the data it needs @@ -178,6 +502,9 @@ enum {  #define IORING_OFF_SQ_RING		0ULL  #define IORING_OFF_CQ_RING		0x8000000ULL  #define IORING_OFF_SQES			0x10000000ULL +#define IORING_OFF_PBUF_RING		0x80000000ULL +#define IORING_OFF_PBUF_SHIFT		16 +#define IORING_OFF_MMAP_MASK		0xf8000000ULL  /*   * Filled with the offset for mmap(2) @@ -191,7 +518,7 @@ struct io_sqring_offsets {  	__u32 dropped;  	__u32 array;  	__u32 resv1; -	__u64 resv2; +	__u64 user_addr;  };  /* @@ -199,6 +526,7 @@ struct io_sqring_offsets {   */  #define IORING_SQ_NEED_WAKEUP	(1U << 0) /* needs io_uring_enter wakeup */  #define IORING_SQ_CQ_OVERFLOW	(1U << 1) /* CQ ring is overflown */ +#define IORING_SQ_TASKRUN	(1U << 2) /* task should enter the kernel */  struct io_cqring_offsets {  	__u32 head; @@ -209,7 +537,7 @@ struct io_cqring_offsets {  	__u32 cqes;  	__u32 flags;  	__u32 resv1; -	__u64 resv2; +	__u64 user_addr;  };  /* @@ -222,8 +550,14 @@ struct io_cqring_offsets {  /*   * io_uring_enter(2) flags   */ -#define IORING_ENTER_GETEVENTS	(1U << 0) -#define IORING_ENTER_SQ_WAKEUP	(1U << 1) +#define IORING_ENTER_GETEVENTS		(1U << 0) +#define IORING_ENTER_SQ_WAKEUP		(1U << 1) +#define IORING_ENTER_SQ_WAIT		(1U << 2) +#define IORING_ENTER_EXT_ARG		(1U << 3) +#define IORING_ENTER_REGISTERED_RING	(1U << 4) +#define IORING_ENTER_ABS_TIMER		(1U << 5) +#define IORING_ENTER_EXT_ARG_REG	(1U << 6) +#define IORING_ENTER_NO_IOWAIT		(1U << 7)  /*   * Passed in for io_uring_setup(2). Copied back with updated info on success @@ -251,28 +585,163 @@ struct io_uring_params {  #define IORING_FEAT_CUR_PERSONALITY	(1U << 4)  #define IORING_FEAT_FAST_POLL		(1U << 5)  #define IORING_FEAT_POLL_32BITS 	(1U << 6) +#define IORING_FEAT_SQPOLL_NONFIXED	(1U << 7) +#define IORING_FEAT_EXT_ARG		(1U << 8) +#define IORING_FEAT_NATIVE_WORKERS	(1U << 9) +#define IORING_FEAT_RSRC_TAGS		(1U << 10) +#define IORING_FEAT_CQE_SKIP		(1U << 11) +#define IORING_FEAT_LINKED_FILE		(1U << 12) +#define IORING_FEAT_REG_REG_RING	(1U << 13) +#define IORING_FEAT_RECVSEND_BUNDLE	(1U << 14) +#define IORING_FEAT_MIN_TIMEOUT		(1U << 15) +#define IORING_FEAT_RW_ATTR		(1U << 16) +#define IORING_FEAT_NO_IOWAIT		(1U << 17)  /*   * io_uring_register(2) opcodes and arguments   */ -#define IORING_REGISTER_BUFFERS		0 -#define IORING_UNREGISTER_BUFFERS	1 -#define IORING_REGISTER_FILES		2 -#define IORING_UNREGISTER_FILES		3 -#define IORING_REGISTER_EVENTFD		4 -#define IORING_UNREGISTER_EVENTFD	5 -#define IORING_REGISTER_FILES_UPDATE	6 -#define IORING_REGISTER_EVENTFD_ASYNC	7 -#define IORING_REGISTER_PROBE		8 -#define IORING_REGISTER_PERSONALITY	9 -#define IORING_UNREGISTER_PERSONALITY	10 +enum io_uring_register_op { +	IORING_REGISTER_BUFFERS			= 0, +	IORING_UNREGISTER_BUFFERS		= 1, +	IORING_REGISTER_FILES			= 2, +	IORING_UNREGISTER_FILES			= 3, +	IORING_REGISTER_EVENTFD			= 4, +	IORING_UNREGISTER_EVENTFD		= 5, +	IORING_REGISTER_FILES_UPDATE		= 6, +	IORING_REGISTER_EVENTFD_ASYNC		= 7, +	IORING_REGISTER_PROBE			= 8, +	IORING_REGISTER_PERSONALITY		= 9, +	IORING_UNREGISTER_PERSONALITY		= 10, +	IORING_REGISTER_RESTRICTIONS		= 11, +	IORING_REGISTER_ENABLE_RINGS		= 12, + +	/* extended with tagging */ +	IORING_REGISTER_FILES2			= 13, +	IORING_REGISTER_FILES_UPDATE2		= 14, +	IORING_REGISTER_BUFFERS2		= 15, +	IORING_REGISTER_BUFFERS_UPDATE		= 16, + +	/* set/clear io-wq thread affinities */ +	IORING_REGISTER_IOWQ_AFF		= 17, +	IORING_UNREGISTER_IOWQ_AFF		= 18, + +	/* set/get max number of io-wq workers */ +	IORING_REGISTER_IOWQ_MAX_WORKERS	= 19, + +	/* register/unregister io_uring fd with the ring */ +	IORING_REGISTER_RING_FDS		= 20, +	IORING_UNREGISTER_RING_FDS		= 21, + +	/* register ring based provide buffer group */ +	IORING_REGISTER_PBUF_RING		= 22, +	IORING_UNREGISTER_PBUF_RING		= 23, + +	/* sync cancelation API */ +	IORING_REGISTER_SYNC_CANCEL		= 24, + +	/* register a range of fixed file slots for automatic slot allocation */ +	IORING_REGISTER_FILE_ALLOC_RANGE	= 25, + +	/* return status information for a buffer group */ +	IORING_REGISTER_PBUF_STATUS		= 26, + +	/* set/clear busy poll settings */ +	IORING_REGISTER_NAPI			= 27, +	IORING_UNREGISTER_NAPI			= 28, + +	IORING_REGISTER_CLOCK			= 29, + +	/* clone registered buffers from source ring to current ring */ +	IORING_REGISTER_CLONE_BUFFERS		= 30, + +	/* send MSG_RING without having a ring */ +	IORING_REGISTER_SEND_MSG_RING		= 31, +	/* register a netdev hw rx queue for zerocopy */ +	IORING_REGISTER_ZCRX_IFQ		= 32, + +	/* resize CQ ring */ +	IORING_REGISTER_RESIZE_RINGS		= 33, + +	IORING_REGISTER_MEM_REGION		= 34, + +	/* this goes last */ +	IORING_REGISTER_LAST, + +	/* flag added to the opcode to use a registered ring fd */ +	IORING_REGISTER_USE_REGISTERED_RING	= 1U << 31 +}; + +/* io-wq worker categories */ +enum io_wq_type { +	IO_WQ_BOUND, +	IO_WQ_UNBOUND, +}; + +/* deprecated, see struct io_uring_rsrc_update */  struct io_uring_files_update {  	__u32 offset;  	__u32 resv;  	__aligned_u64 /* __s32 * */ fds;  }; +enum { +	/* initialise with user provided memory pointed by user_addr */ +	IORING_MEM_REGION_TYPE_USER		= 1, +}; + +struct io_uring_region_desc { +	__u64 user_addr; +	__u64 size; +	__u32 flags; +	__u32 id; +	__u64 mmap_offset; +	__u64 __resv[4]; +}; + +enum { +	/* expose the region as registered wait arguments */ +	IORING_MEM_REGION_REG_WAIT_ARG		= 1, +}; + +struct io_uring_mem_region_reg { +	__u64 region_uptr; /* struct io_uring_region_desc * */ +	__u64 flags; +	__u64 __resv[2]; +}; + +/* + * Register a fully sparse file space, rather than pass in an array of all + * -1 file descriptors. + */ +#define IORING_RSRC_REGISTER_SPARSE	(1U << 0) + +struct io_uring_rsrc_register { +	__u32 nr; +	__u32 flags; +	__u64 resv2; +	__aligned_u64 data; +	__aligned_u64 tags; +}; + +struct io_uring_rsrc_update { +	__u32 offset; +	__u32 resv; +	__aligned_u64 data; +}; + +struct io_uring_rsrc_update2 { +	__u32 offset; +	__u32 resv; +	__aligned_u64 data; +	__aligned_u64 tags; +	__u32 nr; +	__u32 resv2; +}; + +/* Skip updating fd indexes set to this value in the fd table */ +#define IORING_REGISTER_FILES_SKIP	(-2) +  #define IO_URING_OP_SUPPORTED	(1U << 0)  struct io_uring_probe_op { @@ -287,7 +756,298 @@ struct io_uring_probe {  	__u8 ops_len;	/* length of ops[] array below */  	__u16 resv;  	__u32 resv2[3]; -	struct io_uring_probe_op ops[0]; +	struct io_uring_probe_op ops[]; +}; + +struct io_uring_restriction { +	__u16 opcode; +	union { +		__u8 register_op; /* IORING_RESTRICTION_REGISTER_OP */ +		__u8 sqe_op;      /* IORING_RESTRICTION_SQE_OP */ +		__u8 sqe_flags;   /* IORING_RESTRICTION_SQE_FLAGS_* */ +	}; +	__u8 resv; +	__u32 resv2[3]; +}; + +struct io_uring_clock_register { +	__u32	clockid; +	__u32	__resv[3]; +}; + +enum { +	IORING_REGISTER_SRC_REGISTERED	= (1U << 0), +	IORING_REGISTER_DST_REPLACE	= (1U << 1), +}; + +struct io_uring_clone_buffers { +	__u32	src_fd; +	__u32	flags; +	__u32	src_off; +	__u32	dst_off; +	__u32	nr; +	__u32	pad[3]; +}; + +struct io_uring_buf { +	__u64	addr; +	__u32	len; +	__u16	bid; +	__u16	resv; +}; + +struct io_uring_buf_ring { +	union { +		/* +		 * To avoid spilling into more pages than we need to, the +		 * ring tail is overlaid with the io_uring_buf->resv field. +		 */ +		struct { +			__u64	resv1; +			__u32	resv2; +			__u16	resv3; +			__u16	tail; +		}; +		__DECLARE_FLEX_ARRAY(struct io_uring_buf, bufs); +	}; +}; + +/* + * Flags for IORING_REGISTER_PBUF_RING. + * + * IOU_PBUF_RING_MMAP:	If set, kernel will allocate the memory for the ring. + *			The application must not set a ring_addr in struct + *			io_uring_buf_reg, instead it must subsequently call + *			mmap(2) with the offset set as: + *			IORING_OFF_PBUF_RING | (bgid << IORING_OFF_PBUF_SHIFT) + *			to get a virtual mapping for the ring. + * IOU_PBUF_RING_INC:	If set, buffers consumed from this buffer ring can be + *			consumed incrementally. Normally one (or more) buffers + *			are fully consumed. With incremental consumptions, it's + *			feasible to register big ranges of buffers, and each + *			use of it will consume only as much as it needs. This + *			requires that both the kernel and application keep + *			track of where the current read/recv index is at. + */ +enum io_uring_register_pbuf_ring_flags { +	IOU_PBUF_RING_MMAP	= 1, +	IOU_PBUF_RING_INC	= 2, +}; + +/* argument for IORING_(UN)REGISTER_PBUF_RING */ +struct io_uring_buf_reg { +	__u64	ring_addr; +	__u32	ring_entries; +	__u16	bgid; +	__u16	flags; +	__u64	resv[3]; +}; + +/* argument for IORING_REGISTER_PBUF_STATUS */ +struct io_uring_buf_status { +	__u32	buf_group;	/* input */ +	__u32	head;		/* output */ +	__u32	resv[8]; +}; + +enum io_uring_napi_op { +	/* register/ungister backward compatible opcode */ +	IO_URING_NAPI_REGISTER_OP = 0, + +	/* opcodes to update napi_list when static tracking is used */ +	IO_URING_NAPI_STATIC_ADD_ID = 1, +	IO_URING_NAPI_STATIC_DEL_ID = 2 +}; + +enum io_uring_napi_tracking_strategy { +	/* value must be 0 for backward compatibility */ +	IO_URING_NAPI_TRACKING_DYNAMIC = 0, +	IO_URING_NAPI_TRACKING_STATIC = 1, +	IO_URING_NAPI_TRACKING_INACTIVE = 255 +}; + +/* argument for IORING_(UN)REGISTER_NAPI */ +struct io_uring_napi { +	__u32	busy_poll_to; +	__u8	prefer_busy_poll; + +	/* a io_uring_napi_op value */ +	__u8	opcode; +	__u8	pad[2]; + +	/* +	 * for IO_URING_NAPI_REGISTER_OP, it is a +	 * io_uring_napi_tracking_strategy value. +	 * +	 * for IO_URING_NAPI_STATIC_ADD_ID/IO_URING_NAPI_STATIC_DEL_ID +	 * it is the napi id to add/del from napi_list. +	 */ +	__u32	op_param; +	__u32	resv;  }; +/* + * io_uring_restriction->opcode values + */ +enum io_uring_register_restriction_op { +	/* Allow an io_uring_register(2) opcode */ +	IORING_RESTRICTION_REGISTER_OP		= 0, + +	/* Allow an sqe opcode */ +	IORING_RESTRICTION_SQE_OP		= 1, + +	/* Allow sqe flags */ +	IORING_RESTRICTION_SQE_FLAGS_ALLOWED	= 2, + +	/* Require sqe flags (these flags must be set on each submission) */ +	IORING_RESTRICTION_SQE_FLAGS_REQUIRED	= 3, + +	IORING_RESTRICTION_LAST +}; + +enum { +	IORING_REG_WAIT_TS		= (1U << 0), +}; + +/* + * Argument for io_uring_enter(2) with + * IORING_GETEVENTS | IORING_ENTER_EXT_ARG_REG set, where the actual argument + * is an index into a previously registered fixed wait region described by + * the below structure. + */ +struct io_uring_reg_wait { +	struct __kernel_timespec	ts; +	__u32				min_wait_usec; +	__u32				flags; +	__u64				sigmask; +	__u32				sigmask_sz; +	__u32				pad[3]; +	__u64				pad2[2]; +}; + +/* + * Argument for io_uring_enter(2) with IORING_GETEVENTS | IORING_ENTER_EXT_ARG + */ +struct io_uring_getevents_arg { +	__u64	sigmask; +	__u32	sigmask_sz; +	__u32	min_wait_usec; +	__u64	ts; +}; + +/* + * Argument for IORING_REGISTER_SYNC_CANCEL + */ +struct io_uring_sync_cancel_reg { +	__u64				addr; +	__s32				fd; +	__u32				flags; +	struct __kernel_timespec	timeout; +	__u8				opcode; +	__u8				pad[7]; +	__u64				pad2[3]; +}; + +/* + * Argument for IORING_REGISTER_FILE_ALLOC_RANGE + * The range is specified as [off, off + len) + */ +struct io_uring_file_index_range { +	__u32	off; +	__u32	len; +	__u64	resv; +}; + +struct io_uring_recvmsg_out { +	__u32 namelen; +	__u32 controllen; +	__u32 payloadlen; +	__u32 flags; +}; + +/* + * Argument for IORING_OP_URING_CMD when file is a socket + */ +enum io_uring_socket_op { +	SOCKET_URING_OP_SIOCINQ		= 0, +	SOCKET_URING_OP_SIOCOUTQ, +	SOCKET_URING_OP_GETSOCKOPT, +	SOCKET_URING_OP_SETSOCKOPT, +	SOCKET_URING_OP_TX_TIMESTAMP, +}; + +/* + * SOCKET_URING_OP_TX_TIMESTAMP definitions + */ + +#define IORING_TIMESTAMP_HW_SHIFT	16 +/* The cqe->flags bit from which the timestamp type is stored */ +#define IORING_TIMESTAMP_TYPE_SHIFT	(IORING_TIMESTAMP_HW_SHIFT + 1) +/* The cqe->flags flag signifying whether it's a hardware timestamp */ +#define IORING_CQE_F_TSTAMP_HW		((__u32)1 << IORING_TIMESTAMP_HW_SHIFT) + +struct io_timespec { +	__u64		tv_sec; +	__u64		tv_nsec; +}; + +/* Zero copy receive refill queue entry */ +struct io_uring_zcrx_rqe { +	__u64	off; +	__u32	len; +	__u32	__pad; +}; + +struct io_uring_zcrx_cqe { +	__u64	off; +	__u64	__pad; +}; + +/* The bit from which area id is encoded into offsets */ +#define IORING_ZCRX_AREA_SHIFT	48 +#define IORING_ZCRX_AREA_MASK	(~(((__u64)1 << IORING_ZCRX_AREA_SHIFT) - 1)) + +struct io_uring_zcrx_offsets { +	__u32	head; +	__u32	tail; +	__u32	rqes; +	__u32	__resv2; +	__u64	__resv[2]; +}; + +enum io_uring_zcrx_area_flags { +	IORING_ZCRX_AREA_DMABUF		= 1, +}; + +struct io_uring_zcrx_area_reg { +	__u64	addr; +	__u64	len; +	__u64	rq_area_token; +	__u32	flags; +	__u32	dmabuf_fd; +	__u64	__resv2[2]; +}; + +/* + * Argument for IORING_REGISTER_ZCRX_IFQ + */ +struct io_uring_zcrx_ifq_reg { +	__u32	if_idx; +	__u32	if_rxq; +	__u32	rq_entries; +	__u32	flags; + +	__u64	area_ptr; /* pointer to struct io_uring_zcrx_area_reg */ +	__u64	region_ptr; /* struct io_uring_region_desc * */ + +	struct io_uring_zcrx_offsets offsets; +	__u32	zcrx_id; +	__u32	__resv2; +	__u64	__resv[3]; +}; + +#ifdef __cplusplus +} +#endif +  #endif diff --git a/include/uapi/linux/io_uring/mock_file.h b/include/uapi/linux/io_uring/mock_file.h new file mode 100644 index 000000000000..debeee8e4527 --- /dev/null +++ b/include/uapi/linux/io_uring/mock_file.h @@ -0,0 +1,47 @@ +#ifndef LINUX_IO_URING_MOCK_FILE_H +#define LINUX_IO_URING_MOCK_FILE_H + +#include <linux/types.h> + +enum { +	IORING_MOCK_FEAT_CMD_COPY, +	IORING_MOCK_FEAT_RW_ZERO, +	IORING_MOCK_FEAT_RW_NOWAIT, +	IORING_MOCK_FEAT_RW_ASYNC, +	IORING_MOCK_FEAT_POLL, + +	IORING_MOCK_FEAT_END, +}; + +struct io_uring_mock_probe { +	__u64		features; +	__u64		__resv[9]; +}; + +enum { +	IORING_MOCK_CREATE_F_SUPPORT_NOWAIT			= 1, +	IORING_MOCK_CREATE_F_POLL				= 2, +}; + +struct io_uring_mock_create { +	__u32		out_fd; +	__u32		flags; +	__u64		file_size; +	__u64		rw_delay_ns; +	__u64		__resv[13]; +}; + +enum { +	IORING_MOCK_MGR_CMD_PROBE, +	IORING_MOCK_MGR_CMD_CREATE, +}; + +enum { +	IORING_MOCK_CMD_COPY_REGBUF, +}; + +enum { +	IORING_MOCK_COPY_FROM			= 1, +}; + +#endif diff --git a/include/uapi/linux/ioam6.h b/include/uapi/linux/ioam6.h new file mode 100644 index 000000000000..8f72b24fefb3 --- /dev/null +++ b/include/uapi/linux/ioam6.h @@ -0,0 +1,133 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + *  IPv6 IOAM implementation + * + *  Author: + *  Justin Iurman <justin.iurman@uliege.be> + */ + +#ifndef _UAPI_LINUX_IOAM6_H +#define _UAPI_LINUX_IOAM6_H + +#include <asm/byteorder.h> +#include <linux/types.h> + +#define IOAM6_U16_UNAVAILABLE U16_MAX +#define IOAM6_U32_UNAVAILABLE U32_MAX +#define IOAM6_U64_UNAVAILABLE U64_MAX + +#define IOAM6_DEFAULT_ID (IOAM6_U32_UNAVAILABLE >> 8) +#define IOAM6_DEFAULT_ID_WIDE (IOAM6_U64_UNAVAILABLE >> 8) +#define IOAM6_DEFAULT_IF_ID IOAM6_U16_UNAVAILABLE +#define IOAM6_DEFAULT_IF_ID_WIDE IOAM6_U32_UNAVAILABLE + +/* + * IPv6 IOAM Option Header + */ +struct ioam6_hdr { +	__u8 opt_type; +	__u8 opt_len; +	__u8 :8;				/* reserved */ +#define IOAM6_TYPE_PREALLOC 0 +	__u8 type; +} __attribute__((packed)); + +/* + * IOAM Trace Header + */ +struct ioam6_trace_hdr { +	__be16	namespace_id; + +#if defined(__LITTLE_ENDIAN_BITFIELD) + +	__u8	:1,				/* unused */ +		:1,				/* unused */ +		overflow:1, +		nodelen:5; + +	__u8	remlen:7, +		:1;				/* unused */ + +	union { +		__be32 type_be32; + +		struct { +			__u32	bit7:1, +				bit6:1, +				bit5:1, +				bit4:1, +				bit3:1, +				bit2:1, +				bit1:1, +				bit0:1, +				bit15:1,	/* unused */ +				bit14:1,	/* unused */ +				bit13:1,	/* unused */ +				bit12:1,	/* unused */ +				bit11:1, +				bit10:1, +				bit9:1, +				bit8:1, +				bit23:1,	/* reserved */ +				bit22:1, +				bit21:1,	/* unused */ +				bit20:1,	/* unused */ +				bit19:1,	/* unused */ +				bit18:1,	/* unused */ +				bit17:1,	/* unused */ +				bit16:1,	/* unused */ +				:8;		/* reserved */ +		} type; +	}; + +#elif defined(__BIG_ENDIAN_BITFIELD) + +	__u8	nodelen:5, +		overflow:1, +		:1,				/* unused */ +		:1;				/* unused */ + +	__u8	:1,				/* unused */ +		remlen:7; + +	union { +		__be32 type_be32; + +		struct { +			__u32	bit0:1, +				bit1:1, +				bit2:1, +				bit3:1, +				bit4:1, +				bit5:1, +				bit6:1, +				bit7:1, +				bit8:1, +				bit9:1, +				bit10:1, +				bit11:1, +				bit12:1,	/* unused */ +				bit13:1,	/* unused */ +				bit14:1,	/* unused */ +				bit15:1,	/* unused */ +				bit16:1,	/* unused */ +				bit17:1,	/* unused */ +				bit18:1,	/* unused */ +				bit19:1,	/* unused */ +				bit20:1,	/* unused */ +				bit21:1,	/* unused */ +				bit22:1, +				bit23:1,	/* reserved */ +				:8;		/* reserved */ +		} type; +	}; + +#else +#error "Please fix <asm/byteorder.h>" +#endif + +#define IOAM6_TRACE_DATA_SIZE_MAX 244 +	__u8	data[]; +} __attribute__((packed)); + +#endif /* _UAPI_LINUX_IOAM6_H */ diff --git a/include/uapi/linux/ioam6_genl.h b/include/uapi/linux/ioam6_genl.h new file mode 100644 index 000000000000..1733fbc51fb5 --- /dev/null +++ b/include/uapi/linux/ioam6_genl.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + *  IPv6 IOAM Generic Netlink API + * + *  Author: + *  Justin Iurman <justin.iurman@uliege.be> + */ + +#ifndef _UAPI_LINUX_IOAM6_GENL_H +#define _UAPI_LINUX_IOAM6_GENL_H + +#define IOAM6_GENL_NAME "IOAM6" +#define IOAM6_GENL_VERSION 0x1 + +enum { +	IOAM6_ATTR_UNSPEC, + +	IOAM6_ATTR_NS_ID,	/* u16 */ +	IOAM6_ATTR_NS_DATA,	/* u32 */ +	IOAM6_ATTR_NS_DATA_WIDE,/* u64 */ + +#define IOAM6_MAX_SCHEMA_DATA_LEN (255 * 4) +	IOAM6_ATTR_SC_ID,	/* u32 */ +	IOAM6_ATTR_SC_DATA,	/* Binary */ +	IOAM6_ATTR_SC_NONE,	/* Flag */ + +	IOAM6_ATTR_PAD, + +	__IOAM6_ATTR_MAX, +}; + +#define IOAM6_ATTR_MAX (__IOAM6_ATTR_MAX - 1) + +enum { +	IOAM6_CMD_UNSPEC, + +	IOAM6_CMD_ADD_NAMESPACE, +	IOAM6_CMD_DEL_NAMESPACE, +	IOAM6_CMD_DUMP_NAMESPACES, + +	IOAM6_CMD_ADD_SCHEMA, +	IOAM6_CMD_DEL_SCHEMA, +	IOAM6_CMD_DUMP_SCHEMAS, + +	IOAM6_CMD_NS_SET_SCHEMA, + +	__IOAM6_CMD_MAX, +}; + +#define IOAM6_CMD_MAX (__IOAM6_CMD_MAX - 1) + +#define IOAM6_GENL_EV_GRP_NAME "ioam6_events" + +enum ioam6_event_type { +	IOAM6_EVENT_UNSPEC, +	IOAM6_EVENT_TRACE, +}; + +enum ioam6_event_attr { +	IOAM6_EVENT_ATTR_UNSPEC, + +	IOAM6_EVENT_ATTR_TRACE_NAMESPACE,	/* u16 */ +	IOAM6_EVENT_ATTR_TRACE_NODELEN,		/* u8 */ +	IOAM6_EVENT_ATTR_TRACE_TYPE,		/* u32 */ +	IOAM6_EVENT_ATTR_TRACE_DATA,		/* Binary */ + +	__IOAM6_EVENT_ATTR_MAX +}; + +#define IOAM6_EVENT_ATTR_MAX (__IOAM6_EVENT_ATTR_MAX - 1) + +#endif /* _UAPI_LINUX_IOAM6_GENL_H */ diff --git a/include/uapi/linux/ioam6_iptunnel.h b/include/uapi/linux/ioam6_iptunnel.h new file mode 100644 index 000000000000..8aef21e4a8c1 --- /dev/null +++ b/include/uapi/linux/ioam6_iptunnel.h @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + *  IPv6 IOAM Lightweight Tunnel API + * + *  Author: + *  Justin Iurman <justin.iurman@uliege.be> + */ + +#ifndef _UAPI_LINUX_IOAM6_IPTUNNEL_H +#define _UAPI_LINUX_IOAM6_IPTUNNEL_H + +/* Encap modes: + *  - inline: direct insertion + *  - encap: ip6ip6 encapsulation + *  - auto: inline for local packets, encap for in-transit packets + */ +enum { +	__IOAM6_IPTUNNEL_MODE_MIN, + +	IOAM6_IPTUNNEL_MODE_INLINE, +	IOAM6_IPTUNNEL_MODE_ENCAP, +	IOAM6_IPTUNNEL_MODE_AUTO, + +	__IOAM6_IPTUNNEL_MODE_MAX, +}; + +#define IOAM6_IPTUNNEL_MODE_MIN (__IOAM6_IPTUNNEL_MODE_MIN + 1) +#define IOAM6_IPTUNNEL_MODE_MAX (__IOAM6_IPTUNNEL_MODE_MAX - 1) + +enum { +	IOAM6_IPTUNNEL_UNSPEC, + +	/* Encap mode */ +	IOAM6_IPTUNNEL_MODE,		/* u8 */ + +	/* Tunnel dst address. +	 * For encap,auto modes. +	 */ +	IOAM6_IPTUNNEL_DST,		/* struct in6_addr */ + +	/* IOAM Trace Header */ +	IOAM6_IPTUNNEL_TRACE,		/* struct ioam6_trace_hdr */ + +	/* Insertion frequency: +	 * "k over n" packets (0 < k <= n) +	 * [0.0001% ... 100%] +	 */ +#define IOAM6_IPTUNNEL_FREQ_MIN 1 +#define IOAM6_IPTUNNEL_FREQ_MAX 1000000 +	IOAM6_IPTUNNEL_FREQ_K,		/* u32 */ +	IOAM6_IPTUNNEL_FREQ_N,		/* u32 */ + +	/* Tunnel src address. +	 * For encap,auto modes. +	 * Optional (automatic if not provided). +	 */ +	IOAM6_IPTUNNEL_SRC,		/* struct in6_addr */ + +	__IOAM6_IPTUNNEL_MAX, +}; + +#define IOAM6_IPTUNNEL_MAX (__IOAM6_IPTUNNEL_MAX - 1) + +#endif /* _UAPI_LINUX_IOAM6_IPTUNNEL_H */ diff --git a/include/uapi/linux/iommu.h b/include/uapi/linux/iommu.h deleted file mode 100644 index c2b2caf9ed41..000000000000 --- a/include/uapi/linux/iommu.h +++ /dev/null @@ -1,333 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * IOMMU user API definitions - */ - -#ifndef _UAPI_IOMMU_H -#define _UAPI_IOMMU_H - -#include <linux/types.h> - -#define IOMMU_FAULT_PERM_READ	(1 << 0) /* read */ -#define IOMMU_FAULT_PERM_WRITE	(1 << 1) /* write */ -#define IOMMU_FAULT_PERM_EXEC	(1 << 2) /* exec */ -#define IOMMU_FAULT_PERM_PRIV	(1 << 3) /* privileged */ - -/* Generic fault types, can be expanded IRQ remapping fault */ -enum iommu_fault_type { -	IOMMU_FAULT_DMA_UNRECOV = 1,	/* unrecoverable fault */ -	IOMMU_FAULT_PAGE_REQ,		/* page request fault */ -}; - -enum iommu_fault_reason { -	IOMMU_FAULT_REASON_UNKNOWN = 0, - -	/* Could not access the PASID table (fetch caused external abort) */ -	IOMMU_FAULT_REASON_PASID_FETCH, - -	/* PASID entry is invalid or has configuration errors */ -	IOMMU_FAULT_REASON_BAD_PASID_ENTRY, - -	/* -	 * PASID is out of range (e.g. exceeds the maximum PASID -	 * supported by the IOMMU) or disabled. -	 */ -	IOMMU_FAULT_REASON_PASID_INVALID, - -	/* -	 * An external abort occurred fetching (or updating) a translation -	 * table descriptor -	 */ -	IOMMU_FAULT_REASON_WALK_EABT, - -	/* -	 * Could not access the page table entry (Bad address), -	 * actual translation fault -	 */ -	IOMMU_FAULT_REASON_PTE_FETCH, - -	/* Protection flag check failed */ -	IOMMU_FAULT_REASON_PERMISSION, - -	/* access flag check failed */ -	IOMMU_FAULT_REASON_ACCESS, - -	/* Output address of a translation stage caused Address Size fault */ -	IOMMU_FAULT_REASON_OOR_ADDRESS, -}; - -/** - * struct iommu_fault_unrecoverable - Unrecoverable fault data - * @reason: reason of the fault, from &enum iommu_fault_reason - * @flags: parameters of this fault (IOMMU_FAULT_UNRECOV_* values) - * @pasid: Process Address Space ID - * @perm: requested permission access using by the incoming transaction - *        (IOMMU_FAULT_PERM_* values) - * @addr: offending page address - * @fetch_addr: address that caused a fetch abort, if any - */ -struct iommu_fault_unrecoverable { -	__u32	reason; -#define IOMMU_FAULT_UNRECOV_PASID_VALID		(1 << 0) -#define IOMMU_FAULT_UNRECOV_ADDR_VALID		(1 << 1) -#define IOMMU_FAULT_UNRECOV_FETCH_ADDR_VALID	(1 << 2) -	__u32	flags; -	__u32	pasid; -	__u32	perm; -	__u64	addr; -	__u64	fetch_addr; -}; - -/** - * struct iommu_fault_page_request - Page Request data - * @flags: encodes whether the corresponding fields are valid and whether this - *         is the last page in group (IOMMU_FAULT_PAGE_REQUEST_* values). - *         When IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID is set, the page response - *         must have the same PASID value as the page request. When it is clear, - *         the page response should not have a PASID. - * @pasid: Process Address Space ID - * @grpid: Page Request Group Index - * @perm: requested page permissions (IOMMU_FAULT_PERM_* values) - * @addr: page address - * @private_data: device-specific private information - */ -struct iommu_fault_page_request { -#define IOMMU_FAULT_PAGE_REQUEST_PASID_VALID	(1 << 0) -#define IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE	(1 << 1) -#define IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA	(1 << 2) -#define IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID	(1 << 3) -	__u32	flags; -	__u32	pasid; -	__u32	grpid; -	__u32	perm; -	__u64	addr; -	__u64	private_data[2]; -}; - -/** - * struct iommu_fault - Generic fault data - * @type: fault type from &enum iommu_fault_type - * @padding: reserved for future use (should be zero) - * @event: fault event, when @type is %IOMMU_FAULT_DMA_UNRECOV - * @prm: Page Request message, when @type is %IOMMU_FAULT_PAGE_REQ - * @padding2: sets the fault size to allow for future extensions - */ -struct iommu_fault { -	__u32	type; -	__u32	padding; -	union { -		struct iommu_fault_unrecoverable event; -		struct iommu_fault_page_request prm; -		__u8 padding2[56]; -	}; -}; - -/** - * enum iommu_page_response_code - Return status of fault handlers - * @IOMMU_PAGE_RESP_SUCCESS: Fault has been handled and the page tables - *	populated, retry the access. This is "Success" in PCI PRI. - * @IOMMU_PAGE_RESP_FAILURE: General error. Drop all subsequent faults from - *	this device if possible. This is "Response Failure" in PCI PRI. - * @IOMMU_PAGE_RESP_INVALID: Could not handle this fault, don't retry the - *	access. This is "Invalid Request" in PCI PRI. - */ -enum iommu_page_response_code { -	IOMMU_PAGE_RESP_SUCCESS = 0, -	IOMMU_PAGE_RESP_INVALID, -	IOMMU_PAGE_RESP_FAILURE, -}; - -/** - * struct iommu_page_response - Generic page response information - * @version: API version of this structure - * @flags: encodes whether the corresponding fields are valid - *         (IOMMU_FAULT_PAGE_RESPONSE_* values) - * @pasid: Process Address Space ID - * @grpid: Page Request Group Index - * @code: response code from &enum iommu_page_response_code - */ -struct iommu_page_response { -#define IOMMU_PAGE_RESP_VERSION_1	1 -	__u32	version; -#define IOMMU_PAGE_RESP_PASID_VALID	(1 << 0) -	__u32	flags; -	__u32	pasid; -	__u32	grpid; -	__u32	code; -}; - -/* defines the granularity of the invalidation */ -enum iommu_inv_granularity { -	IOMMU_INV_GRANU_DOMAIN,	/* domain-selective invalidation */ -	IOMMU_INV_GRANU_PASID,	/* PASID-selective invalidation */ -	IOMMU_INV_GRANU_ADDR,	/* page-selective invalidation */ -	IOMMU_INV_GRANU_NR,	/* number of invalidation granularities */ -}; - -/** - * struct iommu_inv_addr_info - Address Selective Invalidation Structure - * - * @flags: indicates the granularity of the address-selective invalidation - * - If the PASID bit is set, the @pasid field is populated and the invalidation - *   relates to cache entries tagged with this PASID and matching the address - *   range. - * - If ARCHID bit is set, @archid is populated and the invalidation relates - *   to cache entries tagged with this architecture specific ID and matching - *   the address range. - * - Both PASID and ARCHID can be set as they may tag different caches. - * - If neither PASID or ARCHID is set, global addr invalidation applies. - * - The LEAF flag indicates whether only the leaf PTE caching needs to be - *   invalidated and other paging structure caches can be preserved. - * @pasid: process address space ID - * @archid: architecture-specific ID - * @addr: first stage/level input address - * @granule_size: page/block size of the mapping in bytes - * @nb_granules: number of contiguous granules to be invalidated - */ -struct iommu_inv_addr_info { -#define IOMMU_INV_ADDR_FLAGS_PASID	(1 << 0) -#define IOMMU_INV_ADDR_FLAGS_ARCHID	(1 << 1) -#define IOMMU_INV_ADDR_FLAGS_LEAF	(1 << 2) -	__u32	flags; -	__u32	archid; -	__u64	pasid; -	__u64	addr; -	__u64	granule_size; -	__u64	nb_granules; -}; - -/** - * struct iommu_inv_pasid_info - PASID Selective Invalidation Structure - * - * @flags: indicates the granularity of the PASID-selective invalidation - * - If the PASID bit is set, the @pasid field is populated and the invalidation - *   relates to cache entries tagged with this PASID and matching the address - *   range. - * - If the ARCHID bit is set, the @archid is populated and the invalidation - *   relates to cache entries tagged with this architecture specific ID and - *   matching the address range. - * - Both PASID and ARCHID can be set as they may tag different caches. - * - At least one of PASID or ARCHID must be set. - * @pasid: process address space ID - * @archid: architecture-specific ID - */ -struct iommu_inv_pasid_info { -#define IOMMU_INV_PASID_FLAGS_PASID	(1 << 0) -#define IOMMU_INV_PASID_FLAGS_ARCHID	(1 << 1) -	__u32	flags; -	__u32	archid; -	__u64	pasid; -}; - -/** - * struct iommu_cache_invalidate_info - First level/stage invalidation - *     information - * @version: API version of this structure - * @cache: bitfield that allows to select which caches to invalidate - * @granularity: defines the lowest granularity used for the invalidation: - *     domain > PASID > addr - * @padding: reserved for future use (should be zero) - * @pasid_info: invalidation data when @granularity is %IOMMU_INV_GRANU_PASID - * @addr_info: invalidation data when @granularity is %IOMMU_INV_GRANU_ADDR - * - * Not all the combinations of cache/granularity are valid: - * - * +--------------+---------------+---------------+---------------+ - * | type /       |   DEV_IOTLB   |     IOTLB     |      PASID    | - * | granularity  |               |               |      cache    | - * +==============+===============+===============+===============+ - * | DOMAIN       |       N/A     |       Y       |       Y       | - * +--------------+---------------+---------------+---------------+ - * | PASID        |       Y       |       Y       |       Y       | - * +--------------+---------------+---------------+---------------+ - * | ADDR         |       Y       |       Y       |       N/A     | - * +--------------+---------------+---------------+---------------+ - * - * Invalidations by %IOMMU_INV_GRANU_DOMAIN don't take any argument other than - * @version and @cache. - * - * If multiple cache types are invalidated simultaneously, they all - * must support the used granularity. - */ -struct iommu_cache_invalidate_info { -#define IOMMU_CACHE_INVALIDATE_INFO_VERSION_1 1 -	__u32	version; -/* IOMMU paging structure cache */ -#define IOMMU_CACHE_INV_TYPE_IOTLB	(1 << 0) /* IOMMU IOTLB */ -#define IOMMU_CACHE_INV_TYPE_DEV_IOTLB	(1 << 1) /* Device IOTLB */ -#define IOMMU_CACHE_INV_TYPE_PASID	(1 << 2) /* PASID cache */ -#define IOMMU_CACHE_INV_TYPE_NR		(3) -	__u8	cache; -	__u8	granularity; -	__u8	padding[2]; -	union { -		struct iommu_inv_pasid_info pasid_info; -		struct iommu_inv_addr_info addr_info; -	}; -}; - -/** - * struct iommu_gpasid_bind_data_vtd - Intel VT-d specific data on device and guest - * SVA binding. - * - * @flags:	VT-d PASID table entry attributes - * @pat:	Page attribute table data to compute effective memory type - * @emt:	Extended memory type - * - * Only guest vIOMMU selectable and effective options are passed down to - * the host IOMMU. - */ -struct iommu_gpasid_bind_data_vtd { -#define IOMMU_SVA_VTD_GPASID_SRE	(1 << 0) /* supervisor request */ -#define IOMMU_SVA_VTD_GPASID_EAFE	(1 << 1) /* extended access enable */ -#define IOMMU_SVA_VTD_GPASID_PCD	(1 << 2) /* page-level cache disable */ -#define IOMMU_SVA_VTD_GPASID_PWT	(1 << 3) /* page-level write through */ -#define IOMMU_SVA_VTD_GPASID_EMTE	(1 << 4) /* extended mem type enable */ -#define IOMMU_SVA_VTD_GPASID_CD		(1 << 5) /* PASID-level cache disable */ -	__u64 flags; -	__u32 pat; -	__u32 emt; -}; - -#define IOMMU_SVA_VTD_GPASID_MTS_MASK	(IOMMU_SVA_VTD_GPASID_CD | \ -					 IOMMU_SVA_VTD_GPASID_EMTE | \ -					 IOMMU_SVA_VTD_GPASID_PCD |  \ -					 IOMMU_SVA_VTD_GPASID_PWT) - -/** - * struct iommu_gpasid_bind_data - Information about device and guest PASID binding - * @version:	Version of this data structure - * @format:	PASID table entry format - * @flags:	Additional information on guest bind request - * @gpgd:	Guest page directory base of the guest mm to bind - * @hpasid:	Process address space ID used for the guest mm in host IOMMU - * @gpasid:	Process address space ID used for the guest mm in guest IOMMU - * @addr_width:	Guest virtual address width - * @padding:	Reserved for future use (should be zero) - * @vtd:	Intel VT-d specific data - * - * Guest to host PASID mapping can be an identity or non-identity, where guest - * has its own PASID space. For non-identify mapping, guest to host PASID lookup - * is needed when VM programs guest PASID into an assigned device. VMM may - * trap such PASID programming then request host IOMMU driver to convert guest - * PASID to host PASID based on this bind data. - */ -struct iommu_gpasid_bind_data { -#define IOMMU_GPASID_BIND_VERSION_1	1 -	__u32 version; -#define IOMMU_PASID_FORMAT_INTEL_VTD	1 -	__u32 format; -#define IOMMU_SVA_GPASID_VAL	(1 << 0) /* guest PASID valid */ -	__u64 flags; -	__u64 gpgd; -	__u64 hpasid; -	__u64 gpasid; -	__u32 addr_width; -	__u8  padding[12]; -	/* Vendor specific data */ -	union { -		struct iommu_gpasid_bind_data_vtd vtd; -	}; -}; - -#endif /* _UAPI_IOMMU_H */ diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h new file mode 100644 index 000000000000..c218c89e0e2e --- /dev/null +++ b/include/uapi/linux/iommufd.h @@ -0,0 +1,1292 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES. + */ +#ifndef _UAPI_IOMMUFD_H +#define _UAPI_IOMMUFD_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define IOMMUFD_TYPE (';') + +/** + * DOC: General ioctl format + * + * The ioctl interface follows a general format to allow for extensibility. Each + * ioctl is passed in a structure pointer as the argument providing the size of + * the structure in the first u32. The kernel checks that any structure space + * beyond what it understands is 0. This allows userspace to use the backward + * compatible portion while consistently using the newer, larger, structures. + * + * ioctls use a standard meaning for common errnos: + * + *  - ENOTTY: The IOCTL number itself is not supported at all + *  - E2BIG: The IOCTL number is supported, but the provided structure has + *    non-zero in a part the kernel does not understand. + *  - EOPNOTSUPP: The IOCTL number is supported, and the structure is + *    understood, however a known field has a value the kernel does not + *    understand or support. + *  - EINVAL: Everything about the IOCTL was understood, but a field is not + *    correct. + *  - ENOENT: An ID or IOVA provided does not exist. + *  - ENOMEM: Out of memory. + *  - EOVERFLOW: Mathematics overflowed. + * + * As well as additional errnos, within specific ioctls. + */ +enum { +	IOMMUFD_CMD_BASE = 0x80, +	IOMMUFD_CMD_DESTROY = IOMMUFD_CMD_BASE, +	IOMMUFD_CMD_IOAS_ALLOC = 0x81, +	IOMMUFD_CMD_IOAS_ALLOW_IOVAS = 0x82, +	IOMMUFD_CMD_IOAS_COPY = 0x83, +	IOMMUFD_CMD_IOAS_IOVA_RANGES = 0x84, +	IOMMUFD_CMD_IOAS_MAP = 0x85, +	IOMMUFD_CMD_IOAS_UNMAP = 0x86, +	IOMMUFD_CMD_OPTION = 0x87, +	IOMMUFD_CMD_VFIO_IOAS = 0x88, +	IOMMUFD_CMD_HWPT_ALLOC = 0x89, +	IOMMUFD_CMD_GET_HW_INFO = 0x8a, +	IOMMUFD_CMD_HWPT_SET_DIRTY_TRACKING = 0x8b, +	IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP = 0x8c, +	IOMMUFD_CMD_HWPT_INVALIDATE = 0x8d, +	IOMMUFD_CMD_FAULT_QUEUE_ALLOC = 0x8e, +	IOMMUFD_CMD_IOAS_MAP_FILE = 0x8f, +	IOMMUFD_CMD_VIOMMU_ALLOC = 0x90, +	IOMMUFD_CMD_VDEVICE_ALLOC = 0x91, +	IOMMUFD_CMD_IOAS_CHANGE_PROCESS = 0x92, +	IOMMUFD_CMD_VEVENTQ_ALLOC = 0x93, +	IOMMUFD_CMD_HW_QUEUE_ALLOC = 0x94, +}; + +/** + * struct iommu_destroy - ioctl(IOMMU_DESTROY) + * @size: sizeof(struct iommu_destroy) + * @id: iommufd object ID to destroy. Can be any destroyable object type. + * + * Destroy any object held within iommufd. + */ +struct iommu_destroy { +	__u32 size; +	__u32 id; +}; +#define IOMMU_DESTROY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_DESTROY) + +/** + * struct iommu_ioas_alloc - ioctl(IOMMU_IOAS_ALLOC) + * @size: sizeof(struct iommu_ioas_alloc) + * @flags: Must be 0 + * @out_ioas_id: Output IOAS ID for the allocated object + * + * Allocate an IO Address Space (IOAS) which holds an IO Virtual Address (IOVA) + * to memory mapping. + */ +struct iommu_ioas_alloc { +	__u32 size; +	__u32 flags; +	__u32 out_ioas_id; +}; +#define IOMMU_IOAS_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOC) + +/** + * struct iommu_iova_range - ioctl(IOMMU_IOVA_RANGE) + * @start: First IOVA + * @last: Inclusive last IOVA + * + * An interval in IOVA space. + */ +struct iommu_iova_range { +	__aligned_u64 start; +	__aligned_u64 last; +}; + +/** + * struct iommu_ioas_iova_ranges - ioctl(IOMMU_IOAS_IOVA_RANGES) + * @size: sizeof(struct iommu_ioas_iova_ranges) + * @ioas_id: IOAS ID to read ranges from + * @num_iovas: Input/Output total number of ranges in the IOAS + * @__reserved: Must be 0 + * @allowed_iovas: Pointer to the output array of struct iommu_iova_range + * @out_iova_alignment: Minimum alignment required for mapping IOVA + * + * Query an IOAS for ranges of allowed IOVAs. Mapping IOVA outside these ranges + * is not allowed. num_iovas will be set to the total number of iovas and + * the allowed_iovas[] will be filled in as space permits. + * + * The allowed ranges are dependent on the HW path the DMA operation takes, and + * can change during the lifetime of the IOAS. A fresh empty IOAS will have a + * full range, and each attached device will narrow the ranges based on that + * device's HW restrictions. Detaching a device can widen the ranges. Userspace + * should query ranges after every attach/detach to know what IOVAs are valid + * for mapping. + * + * On input num_iovas is the length of the allowed_iovas array. On output it is + * the total number of iovas filled in. The ioctl will return -EMSGSIZE and set + * num_iovas to the required value if num_iovas is too small. In this case the + * caller should allocate a larger output array and re-issue the ioctl. + * + * out_iova_alignment returns the minimum IOVA alignment that can be given + * to IOMMU_IOAS_MAP/COPY. IOVA's must satisfy:: + * + *   starting_iova % out_iova_alignment == 0 + *   (starting_iova + length) % out_iova_alignment == 0 + * + * out_iova_alignment can be 1 indicating any IOVA is allowed. It cannot + * be higher than the system PAGE_SIZE. + */ +struct iommu_ioas_iova_ranges { +	__u32 size; +	__u32 ioas_id; +	__u32 num_iovas; +	__u32 __reserved; +	__aligned_u64 allowed_iovas; +	__aligned_u64 out_iova_alignment; +}; +#define IOMMU_IOAS_IOVA_RANGES _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_IOVA_RANGES) + +/** + * struct iommu_ioas_allow_iovas - ioctl(IOMMU_IOAS_ALLOW_IOVAS) + * @size: sizeof(struct iommu_ioas_allow_iovas) + * @ioas_id: IOAS ID to allow IOVAs from + * @num_iovas: Input/Output total number of ranges in the IOAS + * @__reserved: Must be 0 + * @allowed_iovas: Pointer to array of struct iommu_iova_range + * + * Ensure a range of IOVAs are always available for allocation. If this call + * succeeds then IOMMU_IOAS_IOVA_RANGES will never return a list of IOVA ranges + * that are narrower than the ranges provided here. This call will fail if + * IOMMU_IOAS_IOVA_RANGES is currently narrower than the given ranges. + * + * When an IOAS is first created the IOVA_RANGES will be maximally sized, and as + * devices are attached the IOVA will narrow based on the device restrictions. + * When an allowed range is specified any narrowing will be refused, ie device + * attachment can fail if the device requires limiting within the allowed range. + * + * Automatic IOVA allocation is also impacted by this call. MAP will only + * allocate within the allowed IOVAs if they are present. + * + * This call replaces the entire allowed list with the given list. + */ +struct iommu_ioas_allow_iovas { +	__u32 size; +	__u32 ioas_id; +	__u32 num_iovas; +	__u32 __reserved; +	__aligned_u64 allowed_iovas; +}; +#define IOMMU_IOAS_ALLOW_IOVAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOW_IOVAS) + +/** + * enum iommufd_ioas_map_flags - Flags for map and copy + * @IOMMU_IOAS_MAP_FIXED_IOVA: If clear the kernel will compute an appropriate + *                             IOVA to place the mapping at + * @IOMMU_IOAS_MAP_WRITEABLE: DMA is allowed to write to this mapping + * @IOMMU_IOAS_MAP_READABLE: DMA is allowed to read from this mapping + */ +enum iommufd_ioas_map_flags { +	IOMMU_IOAS_MAP_FIXED_IOVA = 1 << 0, +	IOMMU_IOAS_MAP_WRITEABLE = 1 << 1, +	IOMMU_IOAS_MAP_READABLE = 1 << 2, +}; + +/** + * struct iommu_ioas_map - ioctl(IOMMU_IOAS_MAP) + * @size: sizeof(struct iommu_ioas_map) + * @flags: Combination of enum iommufd_ioas_map_flags + * @ioas_id: IOAS ID to change the mapping of + * @__reserved: Must be 0 + * @user_va: Userspace pointer to start mapping from + * @length: Number of bytes to map + * @iova: IOVA the mapping was placed at. If IOMMU_IOAS_MAP_FIXED_IOVA is set + *        then this must be provided as input. + * + * Set an IOVA mapping from a user pointer. If FIXED_IOVA is specified then the + * mapping will be established at iova, otherwise a suitable location based on + * the reserved and allowed lists will be automatically selected and returned in + * iova. + * + * If IOMMU_IOAS_MAP_FIXED_IOVA is specified then the iova range must currently + * be unused, existing IOVA cannot be replaced. + */ +struct iommu_ioas_map { +	__u32 size; +	__u32 flags; +	__u32 ioas_id; +	__u32 __reserved; +	__aligned_u64 user_va; +	__aligned_u64 length; +	__aligned_u64 iova; +}; +#define IOMMU_IOAS_MAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP) + +/** + * struct iommu_ioas_map_file - ioctl(IOMMU_IOAS_MAP_FILE) + * @size: sizeof(struct iommu_ioas_map_file) + * @flags: same as for iommu_ioas_map + * @ioas_id: same as for iommu_ioas_map + * @fd: the memfd to map + * @start: byte offset from start of file to map from + * @length: same as for iommu_ioas_map + * @iova: same as for iommu_ioas_map + * + * Set an IOVA mapping from a memfd file.  All other arguments and semantics + * match those of IOMMU_IOAS_MAP. + */ +struct iommu_ioas_map_file { +	__u32 size; +	__u32 flags; +	__u32 ioas_id; +	__s32 fd; +	__aligned_u64 start; +	__aligned_u64 length; +	__aligned_u64 iova; +}; +#define IOMMU_IOAS_MAP_FILE _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP_FILE) + +/** + * struct iommu_ioas_copy - ioctl(IOMMU_IOAS_COPY) + * @size: sizeof(struct iommu_ioas_copy) + * @flags: Combination of enum iommufd_ioas_map_flags + * @dst_ioas_id: IOAS ID to change the mapping of + * @src_ioas_id: IOAS ID to copy from + * @length: Number of bytes to copy and map + * @dst_iova: IOVA the mapping was placed at. If IOMMU_IOAS_MAP_FIXED_IOVA is + *            set then this must be provided as input. + * @src_iova: IOVA to start the copy + * + * Copy an already existing mapping from src_ioas_id and establish it in + * dst_ioas_id. The src iova/length must exactly match a range used with + * IOMMU_IOAS_MAP. + * + * This may be used to efficiently clone a subset of an IOAS to another, or as a + * kind of 'cache' to speed up mapping. Copy has an efficiency advantage over + * establishing equivalent new mappings, as internal resources are shared, and + * the kernel will pin the user memory only once. + */ +struct iommu_ioas_copy { +	__u32 size; +	__u32 flags; +	__u32 dst_ioas_id; +	__u32 src_ioas_id; +	__aligned_u64 length; +	__aligned_u64 dst_iova; +	__aligned_u64 src_iova; +}; +#define IOMMU_IOAS_COPY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_COPY) + +/** + * struct iommu_ioas_unmap - ioctl(IOMMU_IOAS_UNMAP) + * @size: sizeof(struct iommu_ioas_unmap) + * @ioas_id: IOAS ID to change the mapping of + * @iova: IOVA to start the unmapping at + * @length: Number of bytes to unmap, and return back the bytes unmapped + * + * Unmap an IOVA range. The iova/length must be a superset of a previously + * mapped range used with IOMMU_IOAS_MAP or IOMMU_IOAS_COPY. Splitting or + * truncating ranges is not allowed. The values 0 to U64_MAX will unmap + * everything. + */ +struct iommu_ioas_unmap { +	__u32 size; +	__u32 ioas_id; +	__aligned_u64 iova; +	__aligned_u64 length; +}; +#define IOMMU_IOAS_UNMAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_UNMAP) + +/** + * enum iommufd_option - ioctl(IOMMU_OPTION_RLIMIT_MODE) and + *                       ioctl(IOMMU_OPTION_HUGE_PAGES) + * @IOMMU_OPTION_RLIMIT_MODE: + *    Change how RLIMIT_MEMLOCK accounting works. The caller must have privilege + *    to invoke this. Value 0 (default) is user based accounting, 1 uses process + *    based accounting. Global option, object_id must be 0 + * @IOMMU_OPTION_HUGE_PAGES: + *    Value 1 (default) allows contiguous pages to be combined when generating + *    iommu mappings. Value 0 disables combining, everything is mapped to + *    PAGE_SIZE. This can be useful for benchmarking.  This is a per-IOAS + *    option, the object_id must be the IOAS ID. + */ +enum iommufd_option { +	IOMMU_OPTION_RLIMIT_MODE = 0, +	IOMMU_OPTION_HUGE_PAGES = 1, +}; + +/** + * enum iommufd_option_ops - ioctl(IOMMU_OPTION_OP_SET) and + *                           ioctl(IOMMU_OPTION_OP_GET) + * @IOMMU_OPTION_OP_SET: Set the option's value + * @IOMMU_OPTION_OP_GET: Get the option's value + */ +enum iommufd_option_ops { +	IOMMU_OPTION_OP_SET = 0, +	IOMMU_OPTION_OP_GET = 1, +}; + +/** + * struct iommu_option - iommu option multiplexer + * @size: sizeof(struct iommu_option) + * @option_id: One of enum iommufd_option + * @op: One of enum iommufd_option_ops + * @__reserved: Must be 0 + * @object_id: ID of the object if required + * @val64: Option value to set or value returned on get + * + * Change a simple option value. This multiplexor allows controlling options + * on objects. IOMMU_OPTION_OP_SET will load an option and IOMMU_OPTION_OP_GET + * will return the current value. + */ +struct iommu_option { +	__u32 size; +	__u32 option_id; +	__u16 op; +	__u16 __reserved; +	__u32 object_id; +	__aligned_u64 val64; +}; +#define IOMMU_OPTION _IO(IOMMUFD_TYPE, IOMMUFD_CMD_OPTION) + +/** + * enum iommufd_vfio_ioas_op - IOMMU_VFIO_IOAS_* ioctls + * @IOMMU_VFIO_IOAS_GET: Get the current compatibility IOAS + * @IOMMU_VFIO_IOAS_SET: Change the current compatibility IOAS + * @IOMMU_VFIO_IOAS_CLEAR: Disable VFIO compatibility + */ +enum iommufd_vfio_ioas_op { +	IOMMU_VFIO_IOAS_GET = 0, +	IOMMU_VFIO_IOAS_SET = 1, +	IOMMU_VFIO_IOAS_CLEAR = 2, +}; + +/** + * struct iommu_vfio_ioas - ioctl(IOMMU_VFIO_IOAS) + * @size: sizeof(struct iommu_vfio_ioas) + * @ioas_id: For IOMMU_VFIO_IOAS_SET the input IOAS ID to set + *           For IOMMU_VFIO_IOAS_GET will output the IOAS ID + * @op: One of enum iommufd_vfio_ioas_op + * @__reserved: Must be 0 + * + * The VFIO compatibility support uses a single ioas because VFIO APIs do not + * support the ID field. Set or Get the IOAS that VFIO compatibility will use. + * When VFIO_GROUP_SET_CONTAINER is used on an iommufd it will get the + * compatibility ioas, either by taking what is already set, or auto creating + * one. From then on VFIO will continue to use that ioas and is not effected by + * this ioctl. SET or CLEAR does not destroy any auto-created IOAS. + */ +struct iommu_vfio_ioas { +	__u32 size; +	__u32 ioas_id; +	__u16 op; +	__u16 __reserved; +}; +#define IOMMU_VFIO_IOAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VFIO_IOAS) + +/** + * enum iommufd_hwpt_alloc_flags - Flags for HWPT allocation + * @IOMMU_HWPT_ALLOC_NEST_PARENT: If set, allocate a HWPT that can serve as + *                                the parent HWPT in a nesting configuration. + * @IOMMU_HWPT_ALLOC_DIRTY_TRACKING: Dirty tracking support for device IOMMU is + *                                   enforced on device attachment + * @IOMMU_HWPT_FAULT_ID_VALID: The fault_id field of hwpt allocation data is + *                             valid. + * @IOMMU_HWPT_ALLOC_PASID: Requests a domain that can be used with PASID. The + *                          domain can be attached to any PASID on the device. + *                          Any domain attached to the non-PASID part of the + *                          device must also be flagged, otherwise attaching a + *                          PASID will blocked. + *                          For the user that wants to attach PASID, ioas is + *                          not recommended for both the non-PASID part + *                          and PASID part of the device. + *                          If IOMMU does not support PASID it will return + *                          error (-EOPNOTSUPP). + */ +enum iommufd_hwpt_alloc_flags { +	IOMMU_HWPT_ALLOC_NEST_PARENT = 1 << 0, +	IOMMU_HWPT_ALLOC_DIRTY_TRACKING = 1 << 1, +	IOMMU_HWPT_FAULT_ID_VALID = 1 << 2, +	IOMMU_HWPT_ALLOC_PASID = 1 << 3, +}; + +/** + * enum iommu_hwpt_vtd_s1_flags - Intel VT-d stage-1 page table + *                                entry attributes + * @IOMMU_VTD_S1_SRE: Supervisor request + * @IOMMU_VTD_S1_EAFE: Extended access enable + * @IOMMU_VTD_S1_WPE: Write protect enable + */ +enum iommu_hwpt_vtd_s1_flags { +	IOMMU_VTD_S1_SRE = 1 << 0, +	IOMMU_VTD_S1_EAFE = 1 << 1, +	IOMMU_VTD_S1_WPE = 1 << 2, +}; + +/** + * struct iommu_hwpt_vtd_s1 - Intel VT-d stage-1 page table + *                            info (IOMMU_HWPT_DATA_VTD_S1) + * @flags: Combination of enum iommu_hwpt_vtd_s1_flags + * @pgtbl_addr: The base address of the stage-1 page table. + * @addr_width: The address width of the stage-1 page table + * @__reserved: Must be 0 + */ +struct iommu_hwpt_vtd_s1 { +	__aligned_u64 flags; +	__aligned_u64 pgtbl_addr; +	__u32 addr_width; +	__u32 __reserved; +}; + +/** + * struct iommu_hwpt_arm_smmuv3 - ARM SMMUv3 nested STE + *                                (IOMMU_HWPT_DATA_ARM_SMMUV3) + * + * @ste: The first two double words of the user space Stream Table Entry for + *       the translation. Must be little-endian. + *       Allowed fields: (Refer to "5.2 Stream Table Entry" in SMMUv3 HW Spec) + *       - word-0: V, Cfg, S1Fmt, S1ContextPtr, S1CDMax + *       - word-1: EATS, S1DSS, S1CIR, S1COR, S1CSH, S1STALLD + * + * -EIO will be returned if @ste is not legal or contains any non-allowed field. + * Cfg can be used to select a S1, Bypass or Abort configuration. A Bypass + * nested domain will translate the same as the nesting parent. The S1 will + * install a Context Descriptor Table pointing at userspace memory translated + * by the nesting parent. + */ +struct iommu_hwpt_arm_smmuv3 { +	__aligned_le64 ste[2]; +}; + +/** + * enum iommu_hwpt_data_type - IOMMU HWPT Data Type + * @IOMMU_HWPT_DATA_NONE: no data + * @IOMMU_HWPT_DATA_VTD_S1: Intel VT-d stage-1 page table + * @IOMMU_HWPT_DATA_ARM_SMMUV3: ARM SMMUv3 Context Descriptor Table + */ +enum iommu_hwpt_data_type { +	IOMMU_HWPT_DATA_NONE = 0, +	IOMMU_HWPT_DATA_VTD_S1 = 1, +	IOMMU_HWPT_DATA_ARM_SMMUV3 = 2, +}; + +/** + * struct iommu_hwpt_alloc - ioctl(IOMMU_HWPT_ALLOC) + * @size: sizeof(struct iommu_hwpt_alloc) + * @flags: Combination of enum iommufd_hwpt_alloc_flags + * @dev_id: The device to allocate this HWPT for + * @pt_id: The IOAS or HWPT or vIOMMU to connect this HWPT to + * @out_hwpt_id: The ID of the new HWPT + * @__reserved: Must be 0 + * @data_type: One of enum iommu_hwpt_data_type + * @data_len: Length of the type specific data + * @data_uptr: User pointer to the type specific data + * @fault_id: The ID of IOMMUFD_FAULT object. Valid only if flags field of + *            IOMMU_HWPT_FAULT_ID_VALID is set. + * @__reserved2: Padding to 64-bit alignment. Must be 0. + * + * Explicitly allocate a hardware page table object. This is the same object + * type that is returned by iommufd_device_attach() and represents the + * underlying iommu driver's iommu_domain kernel object. + * + * A kernel-managed HWPT will be created with the mappings from the given + * IOAS via the @pt_id. The @data_type for this allocation must be set to + * IOMMU_HWPT_DATA_NONE. The HWPT can be allocated as a parent HWPT for a + * nesting configuration by passing IOMMU_HWPT_ALLOC_NEST_PARENT via @flags. + * + * A user-managed nested HWPT will be created from a given vIOMMU (wrapping a + * parent HWPT) or a parent HWPT via @pt_id, in which the parent HWPT must be + * allocated previously via the same ioctl from a given IOAS (@pt_id). In this + * case, the @data_type must be set to a pre-defined type corresponding to an + * I/O page table type supported by the underlying IOMMU hardware. The device + * via @dev_id and the vIOMMU via @pt_id must be associated to the same IOMMU + * instance. + * + * If the @data_type is set to IOMMU_HWPT_DATA_NONE, @data_len and + * @data_uptr should be zero. Otherwise, both @data_len and @data_uptr + * must be given. + */ +struct iommu_hwpt_alloc { +	__u32 size; +	__u32 flags; +	__u32 dev_id; +	__u32 pt_id; +	__u32 out_hwpt_id; +	__u32 __reserved; +	__u32 data_type; +	__u32 data_len; +	__aligned_u64 data_uptr; +	__u32 fault_id; +	__u32 __reserved2; +}; +#define IOMMU_HWPT_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_ALLOC) + +/** + * enum iommu_hw_info_vtd_flags - Flags for VT-d hw_info + * @IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17: If set, disallow read-only mappings + *                                         on a nested_parent domain. + *                                         https://www.intel.com/content/www/us/en/content-details/772415/content-details.html + */ +enum iommu_hw_info_vtd_flags { +	IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17 = 1 << 0, +}; + +/** + * struct iommu_hw_info_vtd - Intel VT-d hardware information + * + * @flags: Combination of enum iommu_hw_info_vtd_flags + * @__reserved: Must be 0 + * + * @cap_reg: Value of Intel VT-d capability register defined in VT-d spec + *           section 11.4.2 Capability Register. + * @ecap_reg: Value of Intel VT-d capability register defined in VT-d spec + *            section 11.4.3 Extended Capability Register. + * + * User needs to understand the Intel VT-d specification to decode the + * register value. + */ +struct iommu_hw_info_vtd { +	__u32 flags; +	__u32 __reserved; +	__aligned_u64 cap_reg; +	__aligned_u64 ecap_reg; +}; + +/** + * struct iommu_hw_info_arm_smmuv3 - ARM SMMUv3 hardware information + *                                   (IOMMU_HW_INFO_TYPE_ARM_SMMUV3) + * + * @flags: Must be set to 0 + * @__reserved: Must be 0 + * @idr: Implemented features for ARM SMMU Non-secure programming interface + * @iidr: Information about the implementation and implementer of ARM SMMU, + *        and architecture version supported + * @aidr: ARM SMMU architecture version + * + * For the details of @idr, @iidr and @aidr, please refer to the chapters + * from 6.3.1 to 6.3.6 in the SMMUv3 Spec. + * + * This reports the raw HW capability, and not all bits are meaningful to be + * read by userspace. Only the following fields should be used: + * + * idr[0]: ST_LEVEL, TERM_MODEL, STALL_MODEL, TTENDIAN , CD2L, ASID16, TTF + * idr[1]: SIDSIZE, SSIDSIZE + * idr[3]: BBML, RIL + * idr[5]: VAX, GRAN64K, GRAN16K, GRAN4K + * + * - S1P should be assumed to be true if a NESTED HWPT can be created + * - VFIO/iommufd only support platforms with COHACC, it should be assumed to be + *   true. + * - ATS is a per-device property. If the VMM describes any devices as ATS + *   capable in ACPI/DT it should set the corresponding idr. + * + * This list may expand in future (eg E0PD, AIE, PBHA, D128, DS etc). It is + * important that VMMs do not read bits outside the list to allow for + * compatibility with future kernels. Several features in the SMMUv3 + * architecture are not currently supported by the kernel for nesting: HTTU, + * BTM, MPAM and others. + */ +struct iommu_hw_info_arm_smmuv3 { +	__u32 flags; +	__u32 __reserved; +	__u32 idr[6]; +	__u32 iidr; +	__u32 aidr; +}; + +/** + * struct iommu_hw_info_tegra241_cmdqv - NVIDIA Tegra241 CMDQV Hardware + *         Information (IOMMU_HW_INFO_TYPE_TEGRA241_CMDQV) + * + * @flags: Must be 0 + * @version: Version number for the CMDQ-V HW for PARAM bits[03:00] + * @log2vcmdqs: Log2 of the total number of VCMDQs for PARAM bits[07:04] + * @log2vsids: Log2 of the total number of SID replacements for PARAM bits[15:12] + * @__reserved: Must be 0 + * + * VMM can use these fields directly in its emulated global PARAM register. Note + * that only one Virtual Interface (VINTF) should be exposed to a VM, i.e. PARAM + * bits[11:08] should be set to 0 for log2 of the total number of VINTFs. + */ +struct iommu_hw_info_tegra241_cmdqv { +	__u32 flags; +	__u8 version; +	__u8 log2vcmdqs; +	__u8 log2vsids; +	__u8 __reserved; +}; + +/** + * enum iommu_hw_info_type - IOMMU Hardware Info Types + * @IOMMU_HW_INFO_TYPE_NONE: Output by the drivers that do not report hardware + *                           info + * @IOMMU_HW_INFO_TYPE_DEFAULT: Input to request for a default type + * @IOMMU_HW_INFO_TYPE_INTEL_VTD: Intel VT-d iommu info type + * @IOMMU_HW_INFO_TYPE_ARM_SMMUV3: ARM SMMUv3 iommu info type + * @IOMMU_HW_INFO_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV (extension for ARM + *                                     SMMUv3) info type + */ +enum iommu_hw_info_type { +	IOMMU_HW_INFO_TYPE_NONE = 0, +	IOMMU_HW_INFO_TYPE_DEFAULT = 0, +	IOMMU_HW_INFO_TYPE_INTEL_VTD = 1, +	IOMMU_HW_INFO_TYPE_ARM_SMMUV3 = 2, +	IOMMU_HW_INFO_TYPE_TEGRA241_CMDQV = 3, +}; + +/** + * enum iommufd_hw_capabilities + * @IOMMU_HW_CAP_DIRTY_TRACKING: IOMMU hardware support for dirty tracking + *                               If available, it means the following APIs + *                               are supported: + * + *                                   IOMMU_HWPT_GET_DIRTY_BITMAP + *                                   IOMMU_HWPT_SET_DIRTY_TRACKING + * + * @IOMMU_HW_CAP_PCI_PASID_EXEC: Execute Permission Supported, user ignores it + *                               when the struct + *                               iommu_hw_info::out_max_pasid_log2 is zero. + * @IOMMU_HW_CAP_PCI_PASID_PRIV: Privileged Mode Supported, user ignores it + *                               when the struct + *                               iommu_hw_info::out_max_pasid_log2 is zero. + */ +enum iommufd_hw_capabilities { +	IOMMU_HW_CAP_DIRTY_TRACKING = 1 << 0, +	IOMMU_HW_CAP_PCI_PASID_EXEC = 1 << 1, +	IOMMU_HW_CAP_PCI_PASID_PRIV = 1 << 2, +}; + +/** + * enum iommufd_hw_info_flags - Flags for iommu_hw_info + * @IOMMU_HW_INFO_FLAG_INPUT_TYPE: If set, @in_data_type carries an input type + *                                 for user space to request for a specific info + */ +enum iommufd_hw_info_flags { +	IOMMU_HW_INFO_FLAG_INPUT_TYPE = 1 << 0, +}; + +/** + * struct iommu_hw_info - ioctl(IOMMU_GET_HW_INFO) + * @size: sizeof(struct iommu_hw_info) + * @flags: Must be 0 + * @dev_id: The device bound to the iommufd + * @data_len: Input the length of a user buffer in bytes. Output the length of + *            data that kernel supports + * @data_uptr: User pointer to a user-space buffer used by the kernel to fill + *             the iommu type specific hardware information data + * @in_data_type: This shares the same field with @out_data_type, making it be + *                a bidirectional field. When IOMMU_HW_INFO_FLAG_INPUT_TYPE is + *                set, an input type carried via this @in_data_type field will + *                be valid, requesting for the info data to the given type. If + *                IOMMU_HW_INFO_FLAG_INPUT_TYPE is unset, any input value will + *                be seen as IOMMU_HW_INFO_TYPE_DEFAULT + * @out_data_type: Output the iommu hardware info type as defined in the enum + *                 iommu_hw_info_type. + * @out_capabilities: Output the generic iommu capability info type as defined + *                    in the enum iommu_hw_capabilities. + * @out_max_pasid_log2: Output the width of PASIDs. 0 means no PASID support. + *                      PCI devices turn to out_capabilities to check if the + *                      specific capabilities is supported or not. + * @__reserved: Must be 0 + * + * Query an iommu type specific hardware information data from an iommu behind + * a given device that has been bound to iommufd. This hardware info data will + * be used to sync capabilities between the virtual iommu and the physical + * iommu, e.g. a nested translation setup needs to check the hardware info, so + * a guest stage-1 page table can be compatible with the physical iommu. + * + * To capture an iommu type specific hardware information data, @data_uptr and + * its length @data_len must be provided. Trailing bytes will be zeroed if the + * user buffer is larger than the data that kernel has. Otherwise, kernel only + * fills the buffer using the given length in @data_len. If the ioctl succeeds, + * @data_len will be updated to the length that kernel actually supports, + * @out_data_type will be filled to decode the data filled in the buffer + * pointed by @data_uptr. Input @data_len == zero is allowed. + */ +struct iommu_hw_info { +	__u32 size; +	__u32 flags; +	__u32 dev_id; +	__u32 data_len; +	__aligned_u64 data_uptr; +	union { +		__u32 in_data_type; +		__u32 out_data_type; +	}; +	__u8 out_max_pasid_log2; +	__u8 __reserved[3]; +	__aligned_u64 out_capabilities; +}; +#define IOMMU_GET_HW_INFO _IO(IOMMUFD_TYPE, IOMMUFD_CMD_GET_HW_INFO) + +/* + * enum iommufd_hwpt_set_dirty_tracking_flags - Flags for steering dirty + *                                              tracking + * @IOMMU_HWPT_DIRTY_TRACKING_ENABLE: Enable dirty tracking + */ +enum iommufd_hwpt_set_dirty_tracking_flags { +	IOMMU_HWPT_DIRTY_TRACKING_ENABLE = 1, +}; + +/** + * struct iommu_hwpt_set_dirty_tracking - ioctl(IOMMU_HWPT_SET_DIRTY_TRACKING) + * @size: sizeof(struct iommu_hwpt_set_dirty_tracking) + * @flags: Combination of enum iommufd_hwpt_set_dirty_tracking_flags + * @hwpt_id: HW pagetable ID that represents the IOMMU domain + * @__reserved: Must be 0 + * + * Toggle dirty tracking on an HW pagetable. + */ +struct iommu_hwpt_set_dirty_tracking { +	__u32 size; +	__u32 flags; +	__u32 hwpt_id; +	__u32 __reserved; +}; +#define IOMMU_HWPT_SET_DIRTY_TRACKING _IO(IOMMUFD_TYPE, \ +					  IOMMUFD_CMD_HWPT_SET_DIRTY_TRACKING) + +/** + * enum iommufd_hwpt_get_dirty_bitmap_flags - Flags for getting dirty bits + * @IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR: Just read the PTEs without clearing + *                                        any dirty bits metadata. This flag + *                                        can be passed in the expectation + *                                        where the next operation is an unmap + *                                        of the same IOVA range. + * + */ +enum iommufd_hwpt_get_dirty_bitmap_flags { +	IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR = 1, +}; + +/** + * struct iommu_hwpt_get_dirty_bitmap - ioctl(IOMMU_HWPT_GET_DIRTY_BITMAP) + * @size: sizeof(struct iommu_hwpt_get_dirty_bitmap) + * @hwpt_id: HW pagetable ID that represents the IOMMU domain + * @flags: Combination of enum iommufd_hwpt_get_dirty_bitmap_flags + * @__reserved: Must be 0 + * @iova: base IOVA of the bitmap first bit + * @length: IOVA range size + * @page_size: page size granularity of each bit in the bitmap + * @data: bitmap where to set the dirty bits. The bitmap bits each + *        represent a page_size which you deviate from an arbitrary iova. + * + * Checking a given IOVA is dirty: + * + *  data[(iova / page_size) / 64] & (1ULL << ((iova / page_size) % 64)) + * + * Walk the IOMMU pagetables for a given IOVA range to return a bitmap + * with the dirty IOVAs. In doing so it will also by default clear any + * dirty bit metadata set in the IOPTE. + */ +struct iommu_hwpt_get_dirty_bitmap { +	__u32 size; +	__u32 hwpt_id; +	__u32 flags; +	__u32 __reserved; +	__aligned_u64 iova; +	__aligned_u64 length; +	__aligned_u64 page_size; +	__aligned_u64 data; +}; +#define IOMMU_HWPT_GET_DIRTY_BITMAP _IO(IOMMUFD_TYPE, \ +					IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP) + +/** + * enum iommu_hwpt_invalidate_data_type - IOMMU HWPT Cache Invalidation + *                                        Data Type + * @IOMMU_HWPT_INVALIDATE_DATA_VTD_S1: Invalidation data for VTD_S1 + * @IOMMU_VIOMMU_INVALIDATE_DATA_ARM_SMMUV3: Invalidation data for ARM SMMUv3 + */ +enum iommu_hwpt_invalidate_data_type { +	IOMMU_HWPT_INVALIDATE_DATA_VTD_S1 = 0, +	IOMMU_VIOMMU_INVALIDATE_DATA_ARM_SMMUV3 = 1, +}; + +/** + * enum iommu_hwpt_vtd_s1_invalidate_flags - Flags for Intel VT-d + *                                           stage-1 cache invalidation + * @IOMMU_VTD_INV_FLAGS_LEAF: Indicates whether the invalidation applies + *                            to all-levels page structure cache or just + *                            the leaf PTE cache. + */ +enum iommu_hwpt_vtd_s1_invalidate_flags { +	IOMMU_VTD_INV_FLAGS_LEAF = 1 << 0, +}; + +/** + * struct iommu_hwpt_vtd_s1_invalidate - Intel VT-d cache invalidation + *                                       (IOMMU_HWPT_INVALIDATE_DATA_VTD_S1) + * @addr: The start address of the range to be invalidated. It needs to + *        be 4KB aligned. + * @npages: Number of contiguous 4K pages to be invalidated. + * @flags: Combination of enum iommu_hwpt_vtd_s1_invalidate_flags + * @__reserved: Must be 0 + * + * The Intel VT-d specific invalidation data for user-managed stage-1 cache + * invalidation in nested translation. Userspace uses this structure to + * tell the impacted cache scope after modifying the stage-1 page table. + * + * Invalidating all the caches related to the page table by setting @addr + * to be 0 and @npages to be U64_MAX. + * + * The device TLB will be invalidated automatically if ATS is enabled. + */ +struct iommu_hwpt_vtd_s1_invalidate { +	__aligned_u64 addr; +	__aligned_u64 npages; +	__u32 flags; +	__u32 __reserved; +}; + +/** + * struct iommu_viommu_arm_smmuv3_invalidate - ARM SMMUv3 cache invalidation + *         (IOMMU_VIOMMU_INVALIDATE_DATA_ARM_SMMUV3) + * @cmd: 128-bit cache invalidation command that runs in SMMU CMDQ. + *       Must be little-endian. + * + * Supported command list only when passing in a vIOMMU via @hwpt_id: + *     CMDQ_OP_TLBI_NSNH_ALL + *     CMDQ_OP_TLBI_NH_VA + *     CMDQ_OP_TLBI_NH_VAA + *     CMDQ_OP_TLBI_NH_ALL + *     CMDQ_OP_TLBI_NH_ASID + *     CMDQ_OP_ATC_INV + *     CMDQ_OP_CFGI_CD + *     CMDQ_OP_CFGI_CD_ALL + * + * -EIO will be returned if the command is not supported. + */ +struct iommu_viommu_arm_smmuv3_invalidate { +	__aligned_le64 cmd[2]; +}; + +/** + * struct iommu_hwpt_invalidate - ioctl(IOMMU_HWPT_INVALIDATE) + * @size: sizeof(struct iommu_hwpt_invalidate) + * @hwpt_id: ID of a nested HWPT or a vIOMMU, for cache invalidation + * @data_uptr: User pointer to an array of driver-specific cache invalidation + *             data. + * @data_type: One of enum iommu_hwpt_invalidate_data_type, defining the data + *             type of all the entries in the invalidation request array. It + *             should be a type supported by the hwpt pointed by @hwpt_id. + * @entry_len: Length (in bytes) of a request entry in the request array + * @entry_num: Input the number of cache invalidation requests in the array. + *             Output the number of requests successfully handled by kernel. + * @__reserved: Must be 0. + * + * Invalidate iommu cache for user-managed page table or vIOMMU. Modifications + * on a user-managed page table should be followed by this operation, if a HWPT + * is passed in via @hwpt_id. Other caches, such as device cache or descriptor + * cache can be flushed if a vIOMMU is passed in via the @hwpt_id field. + * + * Each ioctl can support one or more cache invalidation requests in the array + * that has a total size of @entry_len * @entry_num. + * + * An empty invalidation request array by setting @entry_num==0 is allowed, and + * @entry_len and @data_uptr would be ignored in this case. This can be used to + * check if the given @data_type is supported or not by kernel. + */ +struct iommu_hwpt_invalidate { +	__u32 size; +	__u32 hwpt_id; +	__aligned_u64 data_uptr; +	__u32 data_type; +	__u32 entry_len; +	__u32 entry_num; +	__u32 __reserved; +}; +#define IOMMU_HWPT_INVALIDATE _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_INVALIDATE) + +/** + * enum iommu_hwpt_pgfault_flags - flags for struct iommu_hwpt_pgfault + * @IOMMU_PGFAULT_FLAGS_PASID_VALID: The pasid field of the fault data is + *                                   valid. + * @IOMMU_PGFAULT_FLAGS_LAST_PAGE: It's the last fault of a fault group. + */ +enum iommu_hwpt_pgfault_flags { +	IOMMU_PGFAULT_FLAGS_PASID_VALID		= (1 << 0), +	IOMMU_PGFAULT_FLAGS_LAST_PAGE		= (1 << 1), +}; + +/** + * enum iommu_hwpt_pgfault_perm - perm bits for struct iommu_hwpt_pgfault + * @IOMMU_PGFAULT_PERM_READ: request for read permission + * @IOMMU_PGFAULT_PERM_WRITE: request for write permission + * @IOMMU_PGFAULT_PERM_EXEC: (PCIE 10.4.1) request with a PASID that has the + *                           Execute Requested bit set in PASID TLP Prefix. + * @IOMMU_PGFAULT_PERM_PRIV: (PCIE 10.4.1) request with a PASID that has the + *                           Privileged Mode Requested bit set in PASID TLP + *                           Prefix. + */ +enum iommu_hwpt_pgfault_perm { +	IOMMU_PGFAULT_PERM_READ			= (1 << 0), +	IOMMU_PGFAULT_PERM_WRITE		= (1 << 1), +	IOMMU_PGFAULT_PERM_EXEC			= (1 << 2), +	IOMMU_PGFAULT_PERM_PRIV			= (1 << 3), +}; + +/** + * struct iommu_hwpt_pgfault - iommu page fault data + * @flags: Combination of enum iommu_hwpt_pgfault_flags + * @dev_id: id of the originated device + * @pasid: Process Address Space ID + * @grpid: Page Request Group Index + * @perm: Combination of enum iommu_hwpt_pgfault_perm + * @__reserved: Must be 0. + * @addr: Fault address + * @length: a hint of how much data the requestor is expecting to fetch. For + *          example, if the PRI initiator knows it is going to do a 10MB + *          transfer, it could fill in 10MB and the OS could pre-fault in + *          10MB of IOVA. It's default to 0 if there's no such hint. + * @cookie: kernel-managed cookie identifying a group of fault messages. The + *          cookie number encoded in the last page fault of the group should + *          be echoed back in the response message. + */ +struct iommu_hwpt_pgfault { +	__u32 flags; +	__u32 dev_id; +	__u32 pasid; +	__u32 grpid; +	__u32 perm; +	__u32 __reserved; +	__aligned_u64 addr; +	__u32 length; +	__u32 cookie; +}; + +/** + * enum iommufd_page_response_code - Return status of fault handlers + * @IOMMUFD_PAGE_RESP_SUCCESS: Fault has been handled and the page tables + *                             populated, retry the access. This is the + *                             "Success" defined in PCI 10.4.2.1. + * @IOMMUFD_PAGE_RESP_INVALID: Could not handle this fault, don't retry the + *                             access. This is the "Invalid Request" in PCI + *                             10.4.2.1. + */ +enum iommufd_page_response_code { +	IOMMUFD_PAGE_RESP_SUCCESS = 0, +	IOMMUFD_PAGE_RESP_INVALID = 1, +}; + +/** + * struct iommu_hwpt_page_response - IOMMU page fault response + * @cookie: The kernel-managed cookie reported in the fault message. + * @code: One of response code in enum iommufd_page_response_code. + */ +struct iommu_hwpt_page_response { +	__u32 cookie; +	__u32 code; +}; + +/** + * struct iommu_fault_alloc - ioctl(IOMMU_FAULT_QUEUE_ALLOC) + * @size: sizeof(struct iommu_fault_alloc) + * @flags: Must be 0 + * @out_fault_id: The ID of the new FAULT + * @out_fault_fd: The fd of the new FAULT + * + * Explicitly allocate a fault handling object. + */ +struct iommu_fault_alloc { +	__u32 size; +	__u32 flags; +	__u32 out_fault_id; +	__u32 out_fault_fd; +}; +#define IOMMU_FAULT_QUEUE_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_FAULT_QUEUE_ALLOC) + +/** + * enum iommu_viommu_type - Virtual IOMMU Type + * @IOMMU_VIOMMU_TYPE_DEFAULT: Reserved for future use + * @IOMMU_VIOMMU_TYPE_ARM_SMMUV3: ARM SMMUv3 driver specific type + * @IOMMU_VIOMMU_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV (extension for ARM + *                                    SMMUv3) enabled ARM SMMUv3 type + */ +enum iommu_viommu_type { +	IOMMU_VIOMMU_TYPE_DEFAULT = 0, +	IOMMU_VIOMMU_TYPE_ARM_SMMUV3 = 1, +	IOMMU_VIOMMU_TYPE_TEGRA241_CMDQV = 2, +}; + +/** + * struct iommu_viommu_tegra241_cmdqv - NVIDIA Tegra241 CMDQV Virtual Interface + *                                      (IOMMU_VIOMMU_TYPE_TEGRA241_CMDQV) + * @out_vintf_mmap_offset: mmap offset argument for VINTF's page0 + * @out_vintf_mmap_length: mmap length argument for VINTF's page0 + * + * Both @out_vintf_mmap_offset and @out_vintf_mmap_length are reported by kernel + * for user space to mmap the VINTF page0 from the host physical address space + * to the guest physical address space so that a guest kernel can directly R/W + * access to the VINTF page0 in order to control its virtual command queues. + */ +struct iommu_viommu_tegra241_cmdqv { +	__aligned_u64 out_vintf_mmap_offset; +	__aligned_u64 out_vintf_mmap_length; +}; + +/** + * struct iommu_viommu_alloc - ioctl(IOMMU_VIOMMU_ALLOC) + * @size: sizeof(struct iommu_viommu_alloc) + * @flags: Must be 0 + * @type: Type of the virtual IOMMU. Must be defined in enum iommu_viommu_type + * @dev_id: The device's physical IOMMU will be used to back the virtual IOMMU + * @hwpt_id: ID of a nesting parent HWPT to associate to + * @out_viommu_id: Output virtual IOMMU ID for the allocated object + * @data_len: Length of the type specific data + * @__reserved: Must be 0 + * @data_uptr: User pointer to a driver-specific virtual IOMMU data + * + * Allocate a virtual IOMMU object, representing the underlying physical IOMMU's + * virtualization support that is a security-isolated slice of the real IOMMU HW + * that is unique to a specific VM. Operations global to the IOMMU are connected + * to the vIOMMU, such as: + * - Security namespace for guest owned ID, e.g. guest-controlled cache tags + * - Non-device-affiliated event reporting, e.g. invalidation queue errors + * - Access to a sharable nesting parent pagetable across physical IOMMUs + * - Virtualization of various platforms IDs, e.g. RIDs and others + * - Delivery of paravirtualized invalidation + * - Direct assigned invalidation queues + * - Direct assigned interrupts + */ +struct iommu_viommu_alloc { +	__u32 size; +	__u32 flags; +	__u32 type; +	__u32 dev_id; +	__u32 hwpt_id; +	__u32 out_viommu_id; +	__u32 data_len; +	__u32 __reserved; +	__aligned_u64 data_uptr; +}; +#define IOMMU_VIOMMU_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VIOMMU_ALLOC) + +/** + * struct iommu_vdevice_alloc - ioctl(IOMMU_VDEVICE_ALLOC) + * @size: sizeof(struct iommu_vdevice_alloc) + * @viommu_id: vIOMMU ID to associate with the virtual device + * @dev_id: The physical device to allocate a virtual instance on the vIOMMU + * @out_vdevice_id: Object handle for the vDevice. Pass to IOMMU_DESTORY + * @virt_id: Virtual device ID per vIOMMU, e.g. vSID of ARM SMMUv3, vDeviceID + *           of AMD IOMMU, and vRID of Intel VT-d + * + * Allocate a virtual device instance (for a physical device) against a vIOMMU. + * This instance holds the device's information (related to its vIOMMU) in a VM. + * User should use IOMMU_DESTROY to destroy the virtual device before + * destroying the physical device (by closing vfio_cdev fd). Otherwise the + * virtual device would be forcibly destroyed on physical device destruction, + * its vdevice_id would be permanently leaked (unremovable & unreusable) until + * iommu fd closed. + */ +struct iommu_vdevice_alloc { +	__u32 size; +	__u32 viommu_id; +	__u32 dev_id; +	__u32 out_vdevice_id; +	__aligned_u64 virt_id; +}; +#define IOMMU_VDEVICE_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VDEVICE_ALLOC) + +/** + * struct iommu_ioas_change_process - ioctl(VFIO_IOAS_CHANGE_PROCESS) + * @size: sizeof(struct iommu_ioas_change_process) + * @__reserved: Must be 0 + * + * This transfers pinned memory counts for every memory map in every IOAS + * in the context to the current process.  This only supports maps created + * with IOMMU_IOAS_MAP_FILE, and returns EINVAL if other maps are present. + * If the ioctl returns a failure status, then nothing is changed. + * + * This API is useful for transferring operation of a device from one process + * to another, such as during userland live update. + */ +struct iommu_ioas_change_process { +	__u32 size; +	__u32 __reserved; +}; + +#define IOMMU_IOAS_CHANGE_PROCESS \ +	_IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_CHANGE_PROCESS) + +/** + * enum iommu_veventq_flag - flag for struct iommufd_vevent_header + * @IOMMU_VEVENTQ_FLAG_LOST_EVENTS: vEVENTQ has lost vEVENTs + */ +enum iommu_veventq_flag { +	IOMMU_VEVENTQ_FLAG_LOST_EVENTS = (1U << 0), +}; + +/** + * struct iommufd_vevent_header - Virtual Event Header for a vEVENTQ Status + * @flags: Combination of enum iommu_veventq_flag + * @sequence: The sequence index of a vEVENT in the vEVENTQ, with a range of + *            [0, INT_MAX] where the following index of INT_MAX is 0 + * + * Each iommufd_vevent_header reports a sequence index of the following vEVENT: + * + * +----------------------+-------+----------------------+-------+---+-------+ + * | header0 {sequence=0} | data0 | header1 {sequence=1} | data1 |...| dataN | + * +----------------------+-------+----------------------+-------+---+-------+ + * + * And this sequence index is expected to be monotonic to the sequence index of + * the previous vEVENT. If two adjacent sequence indexes has a delta larger than + * 1, it means that delta - 1 number of vEVENTs has lost, e.g. two lost vEVENTs: + * + * +-----+----------------------+-------+----------------------+-------+-----+ + * | ... | header3 {sequence=3} | data3 | header6 {sequence=6} | data6 | ... | + * +-----+----------------------+-------+----------------------+-------+-----+ + * + * If a vEVENT lost at the tail of the vEVENTQ and there is no following vEVENT + * providing the next sequence index, an IOMMU_VEVENTQ_FLAG_LOST_EVENTS header + * would be added to the tail, and no data would follow this header: + * + * +--+----------------------+-------+-----------------------------------------+ + * |..| header3 {sequence=3} | data3 | header4 {flags=LOST_EVENTS, sequence=4} | + * +--+----------------------+-------+-----------------------------------------+ + */ +struct iommufd_vevent_header { +	__u32 flags; +	__u32 sequence; +}; + +/** + * enum iommu_veventq_type - Virtual Event Queue Type + * @IOMMU_VEVENTQ_TYPE_DEFAULT: Reserved for future use + * @IOMMU_VEVENTQ_TYPE_ARM_SMMUV3: ARM SMMUv3 Virtual Event Queue + * @IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV Extension IRQ + */ +enum iommu_veventq_type { +	IOMMU_VEVENTQ_TYPE_DEFAULT = 0, +	IOMMU_VEVENTQ_TYPE_ARM_SMMUV3 = 1, +	IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV = 2, +}; + +/** + * struct iommu_vevent_arm_smmuv3 - ARM SMMUv3 Virtual Event + *                                  (IOMMU_VEVENTQ_TYPE_ARM_SMMUV3) + * @evt: 256-bit ARM SMMUv3 Event record, little-endian. + *       Reported event records: (Refer to "7.3 Event records" in SMMUv3 HW Spec) + *       - 0x04 C_BAD_STE + *       - 0x06 F_STREAM_DISABLED + *       - 0x08 C_BAD_SUBSTREAMID + *       - 0x0a C_BAD_CD + *       - 0x10 F_TRANSLATION + *       - 0x11 F_ADDR_SIZE + *       - 0x12 F_ACCESS + *       - 0x13 F_PERMISSION + * + * StreamID field reports a virtual device ID. To receive a virtual event for a + * device, a vDEVICE must be allocated via IOMMU_VDEVICE_ALLOC. + */ +struct iommu_vevent_arm_smmuv3 { +	__aligned_le64 evt[4]; +}; + +/** + * struct iommu_vevent_tegra241_cmdqv - Tegra241 CMDQV IRQ + *                                      (IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV) + * @lvcmdq_err_map: 128-bit logical vcmdq error map, little-endian. + *                  (Refer to register LVCMDQ_ERR_MAPs per VINTF ) + * + * The 128-bit register value from HW exclusively reflect the error bits for a + * Virtual Interface represented by a vIOMMU object. Read and report directly. + */ +struct iommu_vevent_tegra241_cmdqv { +	__aligned_le64 lvcmdq_err_map[2]; +}; + +/** + * struct iommu_veventq_alloc - ioctl(IOMMU_VEVENTQ_ALLOC) + * @size: sizeof(struct iommu_veventq_alloc) + * @flags: Must be 0 + * @viommu_id: virtual IOMMU ID to associate the vEVENTQ with + * @type: Type of the vEVENTQ. Must be defined in enum iommu_veventq_type + * @veventq_depth: Maximum number of events in the vEVENTQ + * @out_veventq_id: The ID of the new vEVENTQ + * @out_veventq_fd: The fd of the new vEVENTQ. User space must close the + *                  successfully returned fd after using it + * @__reserved: Must be 0 + * + * Explicitly allocate a virtual event queue interface for a vIOMMU. A vIOMMU + * can have multiple FDs for different types, but is confined to one per @type. + * User space should open the @out_veventq_fd to read vEVENTs out of a vEVENTQ, + * if there are vEVENTs available. A vEVENTQ will lose events due to overflow, + * if the number of the vEVENTs hits @veventq_depth. + * + * Each vEVENT in a vEVENTQ encloses a struct iommufd_vevent_header followed by + * a type-specific data structure, in a normal case: + * + * +-+---------+-------+---------+-------+-----+---------+-------+-+ + * | | header0 | data0 | header1 | data1 | ... | headerN | dataN | | + * +-+---------+-------+---------+-------+-----+---------+-------+-+ + * + * unless a tailing IOMMU_VEVENTQ_FLAG_LOST_EVENTS header is logged (refer to + * struct iommufd_vevent_header). + */ +struct iommu_veventq_alloc { +	__u32 size; +	__u32 flags; +	__u32 viommu_id; +	__u32 type; +	__u32 veventq_depth; +	__u32 out_veventq_id; +	__u32 out_veventq_fd; +	__u32 __reserved; +}; +#define IOMMU_VEVENTQ_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VEVENTQ_ALLOC) + +/** + * enum iommu_hw_queue_type - HW Queue Type + * @IOMMU_HW_QUEUE_TYPE_DEFAULT: Reserved for future use + * @IOMMU_HW_QUEUE_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV (extension for ARM + *                                      SMMUv3) Virtual Command Queue (VCMDQ) + */ +enum iommu_hw_queue_type { +	IOMMU_HW_QUEUE_TYPE_DEFAULT = 0, +	/* +	 * TEGRA241_CMDQV requirements (otherwise, allocation will fail) +	 * - alloc starts from the lowest @index=0 in ascending order +	 * - destroy starts from the last allocated @index in descending order +	 * - @base_addr must be aligned to @length in bytes and mapped in IOAS +	 * - @length must be a power of 2, with a minimum 32 bytes and a maximum +	 *   2 ^ idr[1].CMDQS * 16 bytes (use GET_HW_INFO call to read idr[1] +	 *   from struct iommu_hw_info_arm_smmuv3) +	 * - suggest to back the queue memory with contiguous physical pages or +	 *   a single huge page with alignment of the queue size, and limit the +	 *   emulated vSMMU's IDR1.CMDQS to log2(huge page size / 16 bytes) +	 */ +	IOMMU_HW_QUEUE_TYPE_TEGRA241_CMDQV = 1, +}; + +/** + * struct iommu_hw_queue_alloc - ioctl(IOMMU_HW_QUEUE_ALLOC) + * @size: sizeof(struct iommu_hw_queue_alloc) + * @flags: Must be 0 + * @viommu_id: Virtual IOMMU ID to associate the HW queue with + * @type: One of enum iommu_hw_queue_type + * @index: The logical index to the HW queue per virtual IOMMU for a multi-queue + *         model + * @out_hw_queue_id: The ID of the new HW queue + * @nesting_parent_iova: Base address of the queue memory in the guest physical + *                       address space + * @length: Length of the queue memory + * + * Allocate a HW queue object for a vIOMMU-specific HW-accelerated queue, which + * allows HW to access a guest queue memory described using @nesting_parent_iova + * and @length. + * + * A vIOMMU can allocate multiple queues, but it must use a different @index per + * type to separate each allocation, e.g:: + * + *     Type1 HW queue0, Type1 HW queue1, Type2 HW queue0, ... + */ +struct iommu_hw_queue_alloc { +	__u32 size; +	__u32 flags; +	__u32 viommu_id; +	__u32 type; +	__u32 index; +	__u32 out_hw_queue_id; +	__aligned_u64 nesting_parent_iova; +	__aligned_u64 length; +}; +#define IOMMU_HW_QUEUE_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HW_QUEUE_ALLOC) +#endif diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h new file mode 100644 index 000000000000..bee2bdb0eedb --- /dev/null +++ b/include/uapi/linux/ioprio.h @@ -0,0 +1,127 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_IOPRIO_H +#define _UAPI_LINUX_IOPRIO_H + +#include <linux/stddef.h> +#include <linux/types.h> + +/* + * Gives us 8 prio classes with 13-bits of data for each class + */ +#define IOPRIO_CLASS_SHIFT	13 +#define IOPRIO_NR_CLASSES	8 +#define IOPRIO_CLASS_MASK	(IOPRIO_NR_CLASSES - 1) +#define IOPRIO_PRIO_MASK	((1UL << IOPRIO_CLASS_SHIFT) - 1) + +#define IOPRIO_PRIO_CLASS(ioprio)	\ +	(((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK) +#define IOPRIO_PRIO_DATA(ioprio)	((ioprio) & IOPRIO_PRIO_MASK) + +/* + * These are the io priority classes as implemented by the BFQ and mq-deadline + * schedulers. RT is the realtime class, it always gets premium service. For + * ATA disks supporting NCQ IO priority, RT class IOs will be processed using + * high priority NCQ commands. BE is the best-effort scheduling class, the + * default for any process. IDLE is the idle scheduling class, it is only + * served when no one else is using the disk. + */ +enum { +	IOPRIO_CLASS_NONE	= 0, +	IOPRIO_CLASS_RT		= 1, +	IOPRIO_CLASS_BE		= 2, +	IOPRIO_CLASS_IDLE	= 3, + +	/* Special class to indicate an invalid ioprio value */ +	IOPRIO_CLASS_INVALID	= 7, +}; + +/* + * The RT and BE priority classes both support up to 8 priority levels that + * can be specified using the lower 3-bits of the priority data. + */ +#define IOPRIO_LEVEL_NR_BITS		3 +#define IOPRIO_NR_LEVELS		(1 << IOPRIO_LEVEL_NR_BITS) +#define IOPRIO_LEVEL_MASK		(IOPRIO_NR_LEVELS - 1) +#define IOPRIO_PRIO_LEVEL(ioprio)	((ioprio) & IOPRIO_LEVEL_MASK) + +#define IOPRIO_BE_NR			IOPRIO_NR_LEVELS + +/* + * Possible values for the "which" argument of the ioprio_get() and + * ioprio_set() system calls (see "man ioprio_set"). + */ +enum { +	IOPRIO_WHO_PROCESS = 1, +	IOPRIO_WHO_PGRP, +	IOPRIO_WHO_USER, +}; + +/* + * Fallback BE class priority level. + */ +#define IOPRIO_NORM	4 +#define IOPRIO_BE_NORM	IOPRIO_NORM + +/* + * The 10 bits between the priority class and the priority level are used to + * optionally define I/O hints for any combination of I/O priority class and + * level. Depending on the kernel configuration, I/O scheduler being used and + * the target I/O device being used, hints can influence how I/Os are processed + * without affecting the I/O scheduling ordering defined by the I/O priority + * class and level. + */ +#define IOPRIO_HINT_SHIFT		IOPRIO_LEVEL_NR_BITS +#define IOPRIO_HINT_NR_BITS		10 +#define IOPRIO_NR_HINTS			(1 << IOPRIO_HINT_NR_BITS) +#define IOPRIO_HINT_MASK		(IOPRIO_NR_HINTS - 1) +#define IOPRIO_PRIO_HINT(ioprio)	\ +	(((ioprio) >> IOPRIO_HINT_SHIFT) & IOPRIO_HINT_MASK) + +/* + * I/O hints. + */ +enum { +	/* No hint */ +	IOPRIO_HINT_NONE = 0, + +	/* +	 * Device command duration limits: indicate to the device a desired +	 * duration limit for the commands that will be used to process an I/O. +	 * These will currently only be effective for SCSI and ATA devices that +	 * support the command duration limits feature. If this feature is +	 * enabled, then the commands issued to the device to process an I/O with +	 * one of these hints set will have the duration limit index (dld field) +	 * set to the value of the hint. +	 */ +	IOPRIO_HINT_DEV_DURATION_LIMIT_1 = 1, +	IOPRIO_HINT_DEV_DURATION_LIMIT_2 = 2, +	IOPRIO_HINT_DEV_DURATION_LIMIT_3 = 3, +	IOPRIO_HINT_DEV_DURATION_LIMIT_4 = 4, +	IOPRIO_HINT_DEV_DURATION_LIMIT_5 = 5, +	IOPRIO_HINT_DEV_DURATION_LIMIT_6 = 6, +	IOPRIO_HINT_DEV_DURATION_LIMIT_7 = 7, +}; + +#define IOPRIO_BAD_VALUE(val, max) ((val) < 0 || (val) >= (max)) + +/* + * Return an I/O priority value based on a class, a level and a hint. + */ +static __always_inline __u16 ioprio_value(int prioclass, int priolevel, +					  int priohint) +{ +	if (IOPRIO_BAD_VALUE(prioclass, IOPRIO_NR_CLASSES) || +	    IOPRIO_BAD_VALUE(priolevel, IOPRIO_NR_LEVELS) || +	    IOPRIO_BAD_VALUE(priohint, IOPRIO_NR_HINTS)) +		return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT; + +	return (prioclass << IOPRIO_CLASS_SHIFT) | +		(priohint << IOPRIO_HINT_SHIFT) | priolevel; +} + +#define IOPRIO_PRIO_VALUE(prioclass, priolevel)			\ +	ioprio_value(prioclass, priolevel, IOPRIO_HINT_NONE) +#define IOPRIO_PRIO_VALUE_HINT(prioclass, priolevel, priohint)	\ +	ioprio_value(prioclass, priolevel, priohint) + +#endif /* _UAPI_LINUX_IOPRIO_H */ diff --git a/include/uapi/linux/ip.h b/include/uapi/linux/ip.h index e42d13b55cf3..5bd7ce934d74 100644 --- a/include/uapi/linux/ip.h +++ b/include/uapi/linux/ip.h @@ -18,6 +18,7 @@  #ifndef _UAPI_LINUX_IP_H  #define _UAPI_LINUX_IP_H  #include <linux/types.h> +#include <linux/stddef.h>  #include <asm/byteorder.h>  #define IPTOS_TOS_MASK		0x1E @@ -100,8 +101,10 @@ struct iphdr {  	__u8	ttl;  	__u8	protocol;  	__sum16	check; -	__be32	saddr; -	__be32	daddr; +	__struct_group(/* no tag */, addrs, /* no attrs */, +		__be32	saddr; +		__be32	daddr; +	);  	/*The options start here. */  }; @@ -112,13 +115,13 @@ struct ip_auth_hdr {  	__be16 reserved;  	__be32 spi;  	__be32 seq_no;		/* Sequence number */ -	__u8  auth_data[0];	/* Variable len but >=4. Mind the 64 bit alignment! */ +	__u8  auth_data[];	/* Variable len but >=4. Mind the 64 bit alignment! */  };  struct ip_esp_hdr {  	__be32 spi;  	__be32 seq_no;		/* Sequence number */ -	__u8  enc_data[0];	/* Variable len but >=8. Mind the 64 bit alignment! */ +	__u8  enc_data[];	/* Variable len but >=8. Mind the 64 bit alignment! */  };  struct ip_comp_hdr { @@ -134,6 +137,22 @@ struct ip_beet_phdr {  	__u8 reserved;  }; +struct ip_iptfs_hdr { +	__u8 subtype;		/* 0*: basic, 1: CC */ +	__u8 flags; +	__be16 block_offset; +}; + +struct ip_iptfs_cc_hdr { +	__u8 subtype;		/* 0: basic, 1*: CC */ +	__u8 flags; +	__be16 block_offset; +	__be32 loss_rate; +	__be64 rtt_adelay_xdelay; +	__be32 tval; +	__be32 techo; +}; +  /* index values for the variables in ipv4_devconf */  enum  { @@ -169,6 +188,7 @@ enum  	IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,  	IPV4_DEVCONF_DROP_GRATUITOUS_ARP,  	IPV4_DEVCONF_BC_FORWARDING, +	IPV4_DEVCONF_ARP_EVICT_NOCARRIER,  	__IPV4_DEVCONF_MAX  }; diff --git a/include/uapi/linux/ip6_tunnel.h b/include/uapi/linux/ip6_tunnel.h index 0245269b037c..85182a839d42 100644 --- a/include/uapi/linux/ip6_tunnel.h +++ b/include/uapi/linux/ip6_tunnel.h @@ -1,6 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _IP6_TUNNEL_H -#define _IP6_TUNNEL_H +#ifndef _UAPI_IP6_TUNNEL_H +#define _UAPI_IP6_TUNNEL_H  #include <linux/types.h>  #include <linux/if.h>		/* For IFNAMSIZ. */ diff --git a/include/uapi/linux/ip_vs.h b/include/uapi/linux/ip_vs.h index 4102ddcb4e14..1ed234e7f251 100644 --- a/include/uapi/linux/ip_vs.h +++ b/include/uapi/linux/ip_vs.h @@ -254,7 +254,7 @@ struct ip_vs_get_dests {  	unsigned int		num_dests;  	/* the real servers */ -	struct ip_vs_dest_entry	entrytable[0]; +	struct ip_vs_dest_entry	entrytable[];  }; @@ -264,7 +264,7 @@ struct ip_vs_get_services {  	unsigned int		num_services;  	/* service table */ -	struct ip_vs_service_entry entrytable[0]; +	struct ip_vs_service_entry entrytable[];  }; diff --git a/include/uapi/linux/ipmi.h b/include/uapi/linux/ipmi.h index 32d148309b16..966c3070959b 100644 --- a/include/uapi/linux/ipmi.h +++ b/include/uapi/linux/ipmi.h @@ -81,6 +81,20 @@ struct ipmi_ipmb_addr {  };  /* + * Used for messages received directly from an IPMB that have not gone + * through a MC.  This is for systems that sit right on an IPMB so + * they can receive commands and respond to them. + */ +#define IPMI_IPMB_DIRECT_ADDR_TYPE	0x81 +struct ipmi_ipmb_direct_addr { +	int           addr_type; +	short         channel; +	unsigned char slave_addr; +	unsigned char rs_lun; +	unsigned char rq_lun; +}; + +/*   * A LAN Address.  This is an address to/from a LAN interface bridged   * by the BMC, not an address actually out on the LAN.   * @@ -158,7 +172,7 @@ struct kernel_ipmi_msg {   * is used for the receive in-kernel interface and in the receive   * IOCTL.   * - * The "IPMI_RESPONSE_RESPNOSE_TYPE" is a little strange sounding, but + * The "IPMI_RESPONSE_RESPONSE_TYPE" is a little strange sounding, but   * it allows you to get the message results when you send a response   * message.   */ diff --git a/include/uapi/linux/ipmi_msgdefs.h b/include/uapi/linux/ipmi_msgdefs.h index c2b23a9fdf3d..0934af3b8037 100644 --- a/include/uapi/linux/ipmi_msgdefs.h +++ b/include/uapi/linux/ipmi_msgdefs.h @@ -69,6 +69,8 @@  #define IPMI_ERR_MSG_TRUNCATED		0xc6  #define IPMI_REQ_LEN_INVALID_ERR	0xc7  #define IPMI_REQ_LEN_EXCEEDED_ERR	0xc8 +#define IPMI_DEVICE_IN_FW_UPDATE_ERR	0xd1 +#define IPMI_DEVICE_IN_INIT_ERR		0xd2  #define IPMI_NOT_IN_MY_STATE_ERR	0xd5	/* IPMI 2.0 */  #define IPMI_LOST_ARBITRATION_ERR	0x81  #define IPMI_BUS_ERR			0x82 diff --git a/include/uapi/linux/ipmi_ssif_bmc.h b/include/uapi/linux/ipmi_ssif_bmc.h new file mode 100644 index 000000000000..1c6a753dad08 --- /dev/null +++ b/include/uapi/linux/ipmi_ssif_bmc.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note*/ +/* + * Copyright (c) 2022, Ampere Computing LLC. + */ + +#ifndef _UAPI_LINUX_IPMI_SSIF_BMC_H +#define _UAPI_LINUX_IPMI_SSIF_BMC_H + +#include <linux/types.h> + +/* Max length of ipmi ssif message included netfn and cmd field */ +#define IPMI_SSIF_PAYLOAD_MAX         254 +struct ipmi_ssif_msg { +	unsigned int len; +	__u8    payload[IPMI_SSIF_PAYLOAD_MAX]; +}; + +#endif /* _UAPI_LINUX_IPMI_SSIF_BMC_H */ diff --git a/include/uapi/linux/ipsec.h b/include/uapi/linux/ipsec.h index 50d8ee1791e2..696b790f4346 100644 --- a/include/uapi/linux/ipsec.h +++ b/include/uapi/linux/ipsec.h @@ -14,7 +14,8 @@ enum {  	IPSEC_MODE_ANY		= 0,	/* We do not support this for SA */  	IPSEC_MODE_TRANSPORT	= 1,  	IPSEC_MODE_TUNNEL	= 2, -	IPSEC_MODE_BEET         = 3 +	IPSEC_MODE_BEET         = 3, +	IPSEC_MODE_IPTFS        = 4  };  enum { diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h index 13e8751bf24a..d4d3ae774b26 100644 --- a/include/uapi/linux/ipv6.h +++ b/include/uapi/linux/ipv6.h @@ -4,6 +4,7 @@  #include <linux/libc-compat.h>  #include <linux/types.h> +#include <linux/stddef.h>  #include <linux/in6.h>  #include <asm/byteorder.h> @@ -80,7 +81,7 @@ struct ipv6_opt_hdr {  struct rt0_hdr {  	struct ipv6_rt_hdr	rt_hdr;  	__u32			reserved; -	struct in6_addr		addr[0]; +	struct in6_addr		addr[];  #define rt0_type		rt_hdr.type  }; @@ -130,8 +131,10 @@ struct ipv6hdr {  	__u8			nexthdr;  	__u8			hop_limit; -	struct	in6_addr	saddr; -	struct	in6_addr	daddr; +	__struct_group(/* no tag */, addrs, /* no attrs */, +		struct	in6_addr	saddr; +		struct	in6_addr	daddr; +	);  }; @@ -189,6 +192,14 @@ enum {  	DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN,  	DEVCONF_NDISC_TCLASS,  	DEVCONF_RPL_SEG_ENABLED, +	DEVCONF_RA_DEFRTR_METRIC, +	DEVCONF_IOAM6_ENABLED, +	DEVCONF_IOAM6_ID, +	DEVCONF_IOAM6_ID_WIDE, +	DEVCONF_NDISC_EVICT_NOCARRIER, +	DEVCONF_ACCEPT_UNTRACKED_NA, +	DEVCONF_ACCEPT_RA_MIN_LFT, +	DEVCONF_FORCE_FORWARDING,  	DEVCONF_MAX  }; diff --git a/include/uapi/linux/ipx.h b/include/uapi/linux/ipx.h deleted file mode 100644 index 3168137adae8..000000000000 --- a/include/uapi/linux/ipx.h +++ /dev/null @@ -1,87 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _IPX_H_ -#define _IPX_H_ -#include <linux/libc-compat.h>	/* for compatibility with glibc netipx/ipx.h */ -#include <linux/types.h> -#include <linux/sockios.h> -#include <linux/socket.h> -#define IPX_NODE_LEN	6 -#define IPX_MTU		576 - -#if __UAPI_DEF_SOCKADDR_IPX -struct sockaddr_ipx { -	__kernel_sa_family_t sipx_family; -	__be16		sipx_port; -	__be32		sipx_network; -	unsigned char 	sipx_node[IPX_NODE_LEN]; -	__u8		sipx_type; -	unsigned char	sipx_zero;	/* 16 byte fill */ -}; -#endif /* __UAPI_DEF_SOCKADDR_IPX */ - -/* - * So we can fit the extra info for SIOCSIFADDR into the address nicely - */ -#define sipx_special	sipx_port -#define sipx_action	sipx_zero -#define IPX_DLTITF	0 -#define IPX_CRTITF	1 - -#if __UAPI_DEF_IPX_ROUTE_DEFINITION -struct ipx_route_definition { -	__be32        ipx_network; -	__be32        ipx_router_network; -	unsigned char ipx_router_node[IPX_NODE_LEN]; -}; -#endif /* __UAPI_DEF_IPX_ROUTE_DEFINITION */ - -#if __UAPI_DEF_IPX_INTERFACE_DEFINITION -struct ipx_interface_definition { -	__be32        ipx_network; -	unsigned char ipx_device[16]; -	unsigned char ipx_dlink_type; -#define IPX_FRAME_NONE		0 -#define IPX_FRAME_SNAP		1 -#define IPX_FRAME_8022		2 -#define IPX_FRAME_ETHERII	3 -#define IPX_FRAME_8023		4 -#define IPX_FRAME_TR_8022       5 /* obsolete */ -	unsigned char ipx_special; -#define IPX_SPECIAL_NONE	0 -#define IPX_PRIMARY		1 -#define IPX_INTERNAL		2 -	unsigned char ipx_node[IPX_NODE_LEN]; -}; -#endif /* __UAPI_DEF_IPX_INTERFACE_DEFINITION */ - -#if __UAPI_DEF_IPX_CONFIG_DATA -struct ipx_config_data { -	unsigned char	ipxcfg_auto_select_primary; -	unsigned char	ipxcfg_auto_create_interfaces; -}; -#endif /* __UAPI_DEF_IPX_CONFIG_DATA */ - -/* - * OLD Route Definition for backward compatibility. - */ - -#if __UAPI_DEF_IPX_ROUTE_DEF -struct ipx_route_def { -	__be32		ipx_network; -	__be32		ipx_router_network; -#define IPX_ROUTE_NO_ROUTER	0 -	unsigned char	ipx_router_node[IPX_NODE_LEN]; -	unsigned char	ipx_device[16]; -	unsigned short	ipx_flags; -#define IPX_RT_SNAP		8 -#define IPX_RT_8022		4 -#define IPX_RT_BLUEBOOK		2 -#define IPX_RT_ROUTED		1 -}; -#endif /* __UAPI_DEF_IPX_ROUTE_DEF */ - -#define SIOCAIPXITFCRT		(SIOCPROTOPRIVATE) -#define SIOCAIPXPRISLT		(SIOCPROTOPRIVATE + 1) -#define SIOCIPXCFGDATA		(SIOCPROTOPRIVATE + 2) -#define SIOCIPXNCPCONN		(SIOCPROTOPRIVATE + 3) -#endif /* _IPX_H_ */ diff --git a/include/uapi/linux/iso_fs.h b/include/uapi/linux/iso_fs.h index a2555176f6d1..758178f5b52d 100644 --- a/include/uapi/linux/iso_fs.h +++ b/include/uapi/linux/iso_fs.h @@ -137,7 +137,7 @@ struct iso_path_table{  	__u8  name_len[2];	/* 721 */  	__u8  extent[4];	/* 731 */  	__u8  parent[2];	/* 721 */ -	char name[0]; +	char name[];  } __attribute__((packed));  /* high sierra is identical to iso, except that the date is only 6 bytes, and @@ -154,7 +154,7 @@ struct iso_directory_record {  	__u8 interleave			[ISODCL (28, 28)]; /* 711 */  	__u8 volume_sequence_number	[ISODCL (29, 32)]; /* 723 */  	__u8 name_len			[ISODCL (33, 33)]; /* 711 */ -	char name			[0]; +	char name			[];  } __attribute__((packed));  #define ISOFS_BLOCK_BITS 11 diff --git a/include/uapi/linux/isst_if.h b/include/uapi/linux/isst_if.h index ba078f8e9add..8197a4800604 100644 --- a/include/uapi/linux/isst_if.h +++ b/include/uapi/linux/isst_if.h @@ -163,10 +163,339 @@ struct isst_if_msr_cmds {  	struct isst_if_msr_cmd msr_cmd[1];  }; +/** + * struct isst_core_power - Structure to get/set core_power feature + * @get_set:	0: Get, 1: Set + * @socket_id:	Socket/package id + * @power_domain: Power Domain id + * @enable:	Feature enable status + * @priority_type: Priority type for the feature (ordered/proportional) + * + * Structure to get/set core_power feature state using IOCTL + * ISST_IF_CORE_POWER_STATE. + */ +struct isst_core_power { +	__u8 get_set; +	__u8 socket_id; +	__u8 power_domain_id; +	__u8 enable; +	__u8 supported; +	__u8 priority_type; +}; + +/** + * struct isst_clos_param - Structure to get/set clos praram + * @get_set:	0: Get, 1: Set + * @socket_id:	Socket/package id + * @power_domain:	Power Domain id + * clos:	Clos ID for the parameters + * min_freq_mhz: Minimum frequency in MHz + * max_freq_mhz: Maximum frequency in MHz + * prop_prio:	Proportional priority from 0-15 + * + * Structure to get/set per clos property using IOCTL + * ISST_IF_CLOS_PARAM. + */ +struct isst_clos_param { +	__u8 get_set; +	__u8 socket_id; +	__u8 power_domain_id; +	__u8 clos; +	__u16 min_freq_mhz; +	__u16 max_freq_mhz; +	__u8 prop_prio; +}; + +/** + * struct isst_if_clos_assoc - Structure to assign clos to a CPU + * @socket_id:	Socket/package id + * @power_domain:	Power Domain id + * @logical_cpu: CPU number + * @clos:	Clos ID to assign to the logical CPU + * + * Structure to get/set core_power feature. + */ +struct isst_if_clos_assoc { +	__u8 socket_id; +	__u8 power_domain_id; +	__u16 logical_cpu; +	__u16 clos; +}; + +/** + * struct isst_if_clos_assoc_cmds - Structure to assign clos to CPUs + * @cmd_count:	Number of cmds (cpus) in this request + * @get_set:	Request is for get or set + * @punit_cpu_map: Set to 1 if the CPU number is punit numbering not + *		   Linux CPU number + * + * Structure used to get/set associate CPUs to clos using IOCTL + * ISST_IF_CLOS_ASSOC. + */ +struct isst_if_clos_assoc_cmds { +	__u16 cmd_count; +	__u16 get_set; +	__u16 punit_cpu_map; +	struct isst_if_clos_assoc assoc_info[1]; +}; + +/** + * struct isst_tpmi_instance_count - Get number of TPMI instances per socket + * @socket_id:	Socket/package id + * @count:	Number of instances + * @valid_mask: Mask of instances as there can be holes + * + * Structure used to get TPMI instances information using + * IOCTL ISST_IF_COUNT_TPMI_INSTANCES. + */ +struct isst_tpmi_instance_count { +	__u8 socket_id; +	__u8 count; +	__u16 valid_mask; +}; + +/** + * struct isst_perf_level_info - Structure to get information on SST-PP levels + * @socket_id:	Socket/package id + * @power_domain:	Power Domain id + * @logical_cpu: CPU number + * @clos:	Clos ID to assign to the logical CPU + * @max_level: Maximum performance level supported by the platform + * @feature_rev: The feature revision for SST-PP supported by the platform + * @level_mask: Mask of supported performance levels + * @current_level: Current performance level + * @feature_state: SST-BF and SST-TF (enabled/disabled) status at current level + * @locked: SST-PP performance level change is locked/unlocked + * @enabled: SST-PP feature is enabled or not + * @sst-tf_support: SST-TF support status at this level + * @sst-bf_support: SST-BF support status at this level + * + * Structure to get SST-PP details using IOCTL ISST_IF_PERF_LEVELS. + */ +struct isst_perf_level_info { +	__u8 socket_id; +	__u8 power_domain_id; +	__u8 max_level; +	__u8 feature_rev; +	__u8 level_mask; +	__u8 current_level; +	__u8 feature_state; +	__u8 locked; +	__u8 enabled; +	__u8 sst_tf_support; +	__u8 sst_bf_support; +}; + +/** + * struct isst_perf_level_control - Structure to set SST-PP level + * @socket_id:	Socket/package id + * @power_domain:	Power Domain id + * @level:	level to set + * + * Structure used change SST-PP level using IOCTL ISST_IF_PERF_SET_LEVEL. + */ +struct isst_perf_level_control { +	__u8 socket_id; +	__u8 power_domain_id; +	__u8 level; +}; + +/** + * struct isst_perf_feature_control - Structure to activate SST-BF/SST-TF + * @socket_id:	Socket/package id + * @power_domain:	Power Domain id + * @feature:	bit 0 = SST-BF state, bit 1 = SST-TF state + * + * Structure used to enable SST-BF/SST-TF using IOCTL ISST_IF_PERF_SET_FEATURE. + */ +struct isst_perf_feature_control { +	__u8 socket_id; +	__u8 power_domain_id; +	__u8 feature; +}; + +#define TRL_MAX_BUCKETS	8 +#define TRL_MAX_LEVELS		6 + +/** + * struct isst_perf_level_data_info - Structure to get SST-PP level details + * @socket_id:	Socket/package id + * @power_domain:	Power Domain id + * @level:	SST-PP level for which caller wants to get information + * @tdp_ratio: TDP Ratio + * @base_freq_mhz: Base frequency in MHz + * @base_freq_avx2_mhz: AVX2 Base frequency in MHz + * @base_freq_avx512_mhz: AVX512 base frequency in MHz + * @base_freq_amx_mhz: AMX base frequency in MHz + * @thermal_design_power_w: Thermal design (TDP) power + * @tjunction_max_c: Max junction temperature + * @max_memory_freq_mhz: Max memory frequency in MHz + * @cooling_type: Type of cooling is used + * @p0_freq_mhz: core maximum frequency + * @p1_freq_mhz: Core TDP frequency + * @pn_freq_mhz: Core maximum efficiency frequency + * @pm_freq_mhz: Core minimum frequency + * @p0_fabric_freq_mhz: Fabric (Uncore) maximum frequency + * @p1_fabric_freq_mhz: Fabric (Uncore) TDP frequency + * @pn_fabric_freq_mhz: Fabric (Uncore) minimum efficiency frequency + * @pm_fabric_freq_mhz: Fabric (Uncore) minimum frequency + * @max_buckets: Maximum trl buckets + * @max_trl_levels: Maximum trl levels + * @bucket_core_counts[TRL_MAX_BUCKETS]: Number of cores per bucket + * @trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS]: maximum frequency + * for a bucket and trl level + * + * Structure used to get information on frequencies and TDP for a SST-PP + * level using ISST_IF_GET_PERF_LEVEL_INFO. + */ +struct isst_perf_level_data_info { +	__u8 socket_id; +	__u8 power_domain_id; +	__u16 level; +	__u16 tdp_ratio; +	__u16 base_freq_mhz; +	__u16 base_freq_avx2_mhz; +	__u16 base_freq_avx512_mhz; +	__u16 base_freq_amx_mhz; +	__u16 thermal_design_power_w; +	__u16 tjunction_max_c; +	__u16 max_memory_freq_mhz; +	__u16 cooling_type; +	__u16 p0_freq_mhz; +	__u16 p1_freq_mhz; +	__u16 pn_freq_mhz; +	__u16 pm_freq_mhz; +	__u16 p0_fabric_freq_mhz; +	__u16 p1_fabric_freq_mhz; +	__u16 pn_fabric_freq_mhz; +	__u16 pm_fabric_freq_mhz; +	__u16 max_buckets; +	__u16 max_trl_levels; +	__u16 bucket_core_counts[TRL_MAX_BUCKETS]; +	__u16 trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS]; +}; + +#define MAX_FABRIC_COUNT	8 + +/** + * struct isst_perf_level_fabric_info - Structure to get SST-PP fabric details + * @socket_id:		Socket/package id + * @power_domain_id:	Power Domain id + * @level:		SST-PP level for which caller wants to get information + * @max_fabrics:	Count of fabrics in resonse + * @p0_fabric_freq_mhz: Fabric (Uncore) maximum frequency + * @p1_fabric_freq_mhz: Fabric (Uncore) TDP frequency + * @pm_fabric_freq_mhz: Fabric (Uncore) minimum frequency + * + * Structure used to get information on frequencies for fabrics. + */ +struct isst_perf_level_fabric_info { +	__u8 socket_id; +	__u8 power_domain_id; +	__u16 level; +	__u16 max_fabrics; +	__u16 p0_fabric_freq_mhz[MAX_FABRIC_COUNT]; +	__u16 p1_fabric_freq_mhz[MAX_FABRIC_COUNT]; +	__u16 pm_fabric_freq_mhz[MAX_FABRIC_COUNT]; +}; + +/** + * struct isst_perf_level_cpu_mask - Structure to get SST-PP level CPU mask + * @socket_id:	Socket/package id + * @power_domain:	Power Domain id + * @level:	SST-PP level for which caller wants to get information + * @punit_cpu_map: Set to 1 if the CPU number is punit numbering not + *		   Linux CPU number. If 0 CPU buffer is copied to user space + *		   supplied cpu_buffer of size cpu_buffer_size. Punit + *		   cpu mask is copied to "mask" field. + * @mask:	cpu mask for this PP level (punit CPU numbering) + * @cpu_buffer_size: size of cpu_buffer also used to return the copied CPU + *		buffer size. + * @cpu_buffer:	Buffer to copy CPU mask when punit_cpu_map is 0 + * + * Structure used to get cpumask for a SST-PP level using + * IOCTL ISST_IF_GET_PERF_LEVEL_CPU_MASK. Also used to get CPU mask for + * IOCTL ISST_IF_GET_BASE_FREQ_CPU_MASK for SST-BF. + */ +struct isst_perf_level_cpu_mask { +	__u8 socket_id; +	__u8 power_domain_id; +	__u8 level; +	__u8 punit_cpu_map; +	__u64 mask; +	__u16 cpu_buffer_size; +	__s8 cpu_buffer[1]; +}; + +/** + * struct isst_base_freq_info - Structure to get SST-BF frequencies + * @socket_id:	Socket/package id + * @power_domain:	Power Domain id + * @level:	SST-PP level for which caller wants to get information + * @high_base_freq_mhz: High priority CPU base frequency + * @low_base_freq_mhz: Low priority CPU base frequency + * @tjunction_max_c: Max junction temperature + * @thermal_design_power_w: Thermal design power in watts + * + * Structure used to get SST-BF information using + * IOCTL ISST_IF_GET_BASE_FREQ_INFO. + */ +struct isst_base_freq_info { +	__u8 socket_id; +	__u8 power_domain_id; +	__u16 level; +	__u16 high_base_freq_mhz; +	__u16 low_base_freq_mhz; +	__u16 tjunction_max_c; +	__u16 thermal_design_power_w; +}; + +/** + * struct isst_turbo_freq_info - Structure to get SST-TF frequencies + * @socket_id:	Socket/package id + * @power_domain:	Power Domain id + * @level:	SST-PP level for which caller wants to get information + * @max_clip_freqs: Maximum number of low priority core clipping frequencies + * @lp_clip_freq_mhz: Clip frequencies per trl level + * @bucket_core_counts: Maximum number of cores for a bucket + * @trl_freq_mhz: Frequencies per trl level for each bucket + * + * Structure used to get SST-TF information using + * IOCTL ISST_IF_GET_TURBO_FREQ_INFO. + */ +struct isst_turbo_freq_info { +	__u8 socket_id; +	__u8 power_domain_id; +	__u16 level; +	__u16 max_clip_freqs; +	__u16 max_buckets; +	__u16 max_trl_levels; +	__u16 lp_clip_freq_mhz[TRL_MAX_LEVELS]; +	__u16 bucket_core_counts[TRL_MAX_BUCKETS]; +	__u16 trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS]; +}; +  #define ISST_IF_MAGIC			0xFE  #define ISST_IF_GET_PLATFORM_INFO	_IOR(ISST_IF_MAGIC, 0, struct isst_if_platform_info *)  #define ISST_IF_GET_PHY_ID		_IOWR(ISST_IF_MAGIC, 1, struct isst_if_cpu_map *)  #define ISST_IF_IO_CMD		_IOW(ISST_IF_MAGIC, 2, struct isst_if_io_regs *)  #define ISST_IF_MBOX_COMMAND	_IOWR(ISST_IF_MAGIC, 3, struct isst_if_mbox_cmds *)  #define ISST_IF_MSR_COMMAND	_IOWR(ISST_IF_MAGIC, 4, struct isst_if_msr_cmds *) + +#define ISST_IF_COUNT_TPMI_INSTANCES	_IOR(ISST_IF_MAGIC, 5, struct isst_tpmi_instance_count *) +#define ISST_IF_CORE_POWER_STATE _IOWR(ISST_IF_MAGIC, 6, struct isst_core_power *) +#define ISST_IF_CLOS_PARAM	_IOWR(ISST_IF_MAGIC, 7, struct isst_clos_param *) +#define ISST_IF_CLOS_ASSOC	_IOWR(ISST_IF_MAGIC, 8, struct isst_if_clos_assoc_cmds *) + +#define ISST_IF_PERF_LEVELS	_IOWR(ISST_IF_MAGIC, 9, struct isst_perf_level_info *) +#define ISST_IF_PERF_SET_LEVEL	_IOW(ISST_IF_MAGIC, 10, struct isst_perf_level_control *) +#define ISST_IF_PERF_SET_FEATURE _IOW(ISST_IF_MAGIC, 11, struct isst_perf_feature_control *) +#define ISST_IF_GET_PERF_LEVEL_INFO	_IOR(ISST_IF_MAGIC, 12, struct isst_perf_level_data_info *) +#define ISST_IF_GET_PERF_LEVEL_CPU_MASK	_IOR(ISST_IF_MAGIC, 13, struct isst_perf_level_cpu_mask *) +#define ISST_IF_GET_BASE_FREQ_INFO	_IOR(ISST_IF_MAGIC, 14, struct isst_base_freq_info *) +#define ISST_IF_GET_BASE_FREQ_CPU_MASK	_IOR(ISST_IF_MAGIC, 15, struct isst_perf_level_cpu_mask *) +#define ISST_IF_GET_TURBO_FREQ_INFO	_IOR(ISST_IF_MAGIC, 16, struct isst_turbo_freq_info *) +#define ISST_IF_GET_PERF_LEVEL_FABRIC_INFO _IOR(ISST_IF_MAGIC, 17,\ +						struct isst_perf_level_fabric_info *) +  #endif diff --git a/include/uapi/linux/jffs2.h b/include/uapi/linux/jffs2.h index 784ba0b9690a..637ee4a793cf 100644 --- a/include/uapi/linux/jffs2.h +++ b/include/uapi/linux/jffs2.h @@ -123,7 +123,7 @@ struct jffs2_raw_dirent  	__u8 unused[2];  	jint32_t node_crc;  	jint32_t name_crc; -	__u8 name[0]; +	__u8 name[];  };  /* The JFFS2 raw inode structure: Used for storage on physical media.  */ @@ -155,7 +155,7 @@ struct jffs2_raw_inode  	jint16_t flags;	     /* See JFFS2_INO_FLAG_* */  	jint32_t data_crc;   /* CRC for the (compressed) data.  */  	jint32_t node_crc;   /* CRC for the raw inode (excluding data)  */ -	__u8 data[0]; +	__u8 data[];  };  struct jffs2_raw_xattr { @@ -170,7 +170,7 @@ struct jffs2_raw_xattr {  	jint16_t value_len;  	jint32_t data_crc;  	jint32_t node_crc; -	__u8 data[0]; +	__u8 data[];  } __attribute__((packed));  struct jffs2_raw_xref @@ -196,7 +196,7 @@ struct jffs2_raw_summary  	jint32_t padded;	/* sum of the size of padding nodes */  	jint32_t sum_crc;	/* summary information crc */  	jint32_t node_crc; 	/* node crc */ -	jint32_t sum[0]; 	/* inode summary info */ +	jint32_t sum[]; 	/* inode summary info */  };  union jffs2_node_union diff --git a/include/uapi/linux/kcov.h b/include/uapi/linux/kcov.h index 1d0350e44ae3..ed95dba9fa37 100644 --- a/include/uapi/linux/kcov.h +++ b/include/uapi/linux/kcov.h @@ -13,7 +13,7 @@ struct kcov_remote_arg {  	__u32		area_size;	/* Length of coverage buffer in words */  	__u32		num_handles;	/* Size of handles array */  	__aligned_u64	common_handle; -	__aligned_u64	handles[0]; +	__aligned_u64	handles[];  };  #define KCOV_REMOTE_MAX_HANDLES		0x100 diff --git a/include/uapi/linux/kd.h b/include/uapi/linux/kd.h index 4616b31f84da..6b384065c013 100644 --- a/include/uapi/linux/kd.h +++ b/include/uapi/linux/kd.h @@ -161,19 +161,25 @@ struct console_font_op {  	unsigned int flags;	/* KD_FONT_FLAG_* */  	unsigned int width, height;	/* font size */  	unsigned int charcount; -	unsigned char __user *data;	/* font data with height fixed to 32 */ +	unsigned char __user *data;	/* font data with vpitch fixed to 32 for +					 * KD_FONT_OP_SET/GET +					 */  };  struct console_font {  	unsigned int width, height;	/* font size */  	unsigned int charcount; -	unsigned char *data;	/* font data with height fixed to 32 */ +	unsigned char *data;	/* font data with vpitch fixed to 32 for +				 * KD_FONT_OP_SET/GET +				 */  };  #define KD_FONT_OP_SET		0	/* Set font */  #define KD_FONT_OP_GET		1	/* Get font */  #define KD_FONT_OP_SET_DEFAULT	2	/* Set font to default, data points to name / NULL */ -#define KD_FONT_OP_COPY		3	/* Copy from another console */ +#define KD_FONT_OP_COPY		3	/* Obsolete, do not use */ +#define KD_FONT_OP_SET_TALL	4	/* Set font with vpitch = height */ +#define KD_FONT_OP_GET_TALL	5	/* Get font with vpitch = height */  #define KD_FONT_FLAG_DONT_RECALC 	1	/* Don't recalculate hw charcell size [compat] */ diff --git a/include/uapi/linux/kernel-page-flags.h b/include/uapi/linux/kernel-page-flags.h index 6f2f2720f3ac..ff8032227876 100644 --- a/include/uapi/linux/kernel-page-flags.h +++ b/include/uapi/linux/kernel-page-flags.h @@ -7,7 +7,7 @@   */  #define KPF_LOCKED		0 -#define KPF_ERROR		1 +#define KPF_ERROR		1	/* Now unused */  #define KPF_REFERENCED		2  #define KPF_UPTODATE		3  #define KPF_DIRTY		4 diff --git a/include/uapi/linux/kernel.h b/include/uapi/linux/kernel.h index 0ff8f7477847..fadf2db71fe8 100644 --- a/include/uapi/linux/kernel.h +++ b/include/uapi/linux/kernel.h @@ -3,13 +3,6 @@  #define _UAPI_LINUX_KERNEL_H  #include <linux/sysinfo.h> - -/* - * 'kernel.h' contains some often-used function prototypes etc - */ -#define __ALIGN_KERNEL(x, a)		__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) -#define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask)) - -#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) +#include <linux/const.h>  #endif /* _UAPI_LINUX_KERNEL_H */ diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h index 05669c87a0af..8958ebfcff94 100644 --- a/include/uapi/linux/kexec.h +++ b/include/uapi/linux/kexec.h @@ -12,6 +12,8 @@  /* kexec flags for different usage scenarios */  #define KEXEC_ON_CRASH		0x00000001  #define KEXEC_PRESERVE_CONTEXT	0x00000002 +#define KEXEC_UPDATE_ELFCOREHDR	0x00000004 +#define KEXEC_CRASH_HOTPLUG_SUPPORT 0x00000008  #define KEXEC_ARCH_MASK		0xffff0000  /* @@ -24,6 +26,8 @@  #define KEXEC_FILE_UNLOAD	0x00000001  #define KEXEC_FILE_ON_CRASH	0x00000002  #define KEXEC_FILE_NO_INITRAMFS	0x00000004 +#define KEXEC_FILE_DEBUG	0x00000008 +#define KEXEC_FILE_NO_CMA	0x00000010  /* These values match the ELF architecture values.   * Unless there is a good reason that should continue to be the case. @@ -42,6 +46,8 @@  #define KEXEC_ARCH_MIPS_LE (10 << 16)  #define KEXEC_ARCH_MIPS    ( 8 << 16)  #define KEXEC_ARCH_AARCH64 (183 << 16) +#define KEXEC_ARCH_RISCV   (243 << 16) +#define KEXEC_ARCH_LOONGARCH	(258 << 16)  /* The artificial cap on the number of segments passed to kexec_load. */  #define KEXEC_SEGMENT_MAX 16 @@ -53,9 +59,9 @@   */  struct kexec_segment {  	const void *buf; -	size_t bufsz; +	__kernel_size_t bufsz;  	const void *mem; -	size_t memsz; +	__kernel_size_t memsz;  };  #endif /* __KERNEL__ */ diff --git a/include/uapi/linux/keyboard.h b/include/uapi/linux/keyboard.h index 4846716e7c5c..36d230cedf12 100644 --- a/include/uapi/linux/keyboard.h +++ b/include/uapi/linux/keyboard.h @@ -27,7 +27,6 @@  #define MAX_NR_FUNC	256	/* max nr of strings assigned to keys */  #define KT_LATIN	0	/* we depend on this being zero */ -#define KT_LETTER	11	/* symbol that can be acted upon by CapsLock */  #define KT_FN		1  #define KT_SPEC		2  #define KT_PAD		3 @@ -38,6 +37,7 @@  #define KT_META		8  #define KT_ASCII	9  #define KT_LOCK		10 +#define KT_LETTER	11	/* symbol that can be acted upon by CapsLock */  #define KT_SLOCK	12  #define KT_DEAD2	13  #define KT_BRL		14 diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h index f738c3b53f4e..04c7d283dc7d 100644 --- a/include/uapi/linux/kfd_ioctl.h +++ b/include/uapi/linux/kfd_ioctl.h @@ -29,9 +29,24 @@  /*   * - 1.1 - initial version   * - 1.3 - Add SMI events support + * - 1.4 - Indicate new SRAM EDC bit in device properties + * - 1.5 - Add SVM API + * - 1.6 - Query clear flags in SVM get_attr API + * - 1.7 - Checkpoint Restore (CRIU) API + * - 1.8 - CRIU - Support for SDMA transfers with GTT BOs + * - 1.9 - Add available memory ioctl + * - 1.10 - Add SMI profiler event log + * - 1.11 - Add unified memory for ctx save/restore area + * - 1.12 - Add DMA buf export ioctl + * - 1.13 - Add debugger API + * - 1.14 - Update kfd_event_data + * - 1.15 - Enable managing mappings in compute VMs with GEM_VA ioctl + * - 1.16 - Add contiguous VRAM allocation flag + * - 1.17 - Add SDMA queue creation with target SDMA engine ID + * - 1.18 - Rename pad in set_memory_policy_args to misc_process_flag   */  #define KFD_IOCTL_MAJOR_VERSION 1 -#define KFD_IOCTL_MINOR_VERSION 3 +#define KFD_IOCTL_MINOR_VERSION 18  struct kfd_ioctl_get_version_args {  	__u32 major_version;	/* from KFD */ @@ -43,10 +58,13 @@ struct kfd_ioctl_get_version_args {  #define KFD_IOC_QUEUE_TYPE_SDMA			0x1  #define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL		0x2  #define KFD_IOC_QUEUE_TYPE_SDMA_XGMI		0x3 +#define KFD_IOC_QUEUE_TYPE_SDMA_BY_ENG_ID	0x4  #define KFD_MAX_QUEUE_PERCENTAGE	100  #define KFD_MAX_QUEUE_PRIORITY		15 +#define KFD_MIN_QUEUE_RING_SIZE		1024 +  struct kfd_ioctl_create_queue_args {  	__u64 ring_base_address;	/* to KFD */  	__u64 write_pointer_address;	/* from KFD */ @@ -65,6 +83,8 @@ struct kfd_ioctl_create_queue_args {  	__u64 ctx_save_restore_address; /* to KFD */  	__u32 ctx_save_restore_size;	/* to KFD */  	__u32 ctl_stack_size;		/* to KFD */ +	__u32 sdma_engine_id;		/* to KFD */ +	__u32 pad;  };  struct kfd_ioctl_destroy_queue_args { @@ -95,10 +115,45 @@ struct kfd_ioctl_get_queue_wave_state_args {  	__u32 pad;  }; +struct kfd_ioctl_get_available_memory_args { +	__u64 available;	/* from KFD */ +	__u32 gpu_id;		/* to KFD */ +	__u32 pad; +}; + +struct kfd_dbg_device_info_entry { +	__u64 exception_status; +	__u64 lds_base; +	__u64 lds_limit; +	__u64 scratch_base; +	__u64 scratch_limit; +	__u64 gpuvm_base; +	__u64 gpuvm_limit; +	__u32 gpu_id; +	__u32 location_id; +	__u32 vendor_id; +	__u32 device_id; +	__u32 revision_id; +	__u32 subsystem_vendor_id; +	__u32 subsystem_device_id; +	__u32 fw_version; +	__u32 gfx_target_version; +	__u32 simd_count; +	__u32 max_waves_per_simd; +	__u32 array_count; +	__u32 simd_arrays_per_engine; +	__u32 num_xcc; +	__u32 capability; +	__u32 debug_prop; +}; +  /* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */  #define KFD_IOC_CACHE_POLICY_COHERENT 0  #define KFD_IOC_CACHE_POLICY_NONCOHERENT 1 +/* Misc. per process flags */ +#define KFD_PROC_FLAG_MFMA_HIGH_PRECISION (1 << 0) +  struct kfd_ioctl_set_memory_policy_args {  	__u64 alternate_aperture_base;	/* to KFD */  	__u64 alternate_aperture_size;	/* to KFD */ @@ -106,7 +161,7 @@ struct kfd_ioctl_set_memory_policy_args {  	__u32 gpu_id;			/* to KFD */  	__u32 default_policy;		/* to KFD */  	__u32 alternate_policy;		/* to KFD */ -	__u32 pad; +	__u32 misc_process_flag;        /* to KFD */  };  /* @@ -191,6 +246,8 @@ struct kfd_ioctl_dbg_wave_control_args {  	__u32 buf_size_in_bytes;	/*including gpu_id and buf_size */  }; +#define KFD_INVALID_FD     0xffffffff +  /* Matching HSA_EVENTTYPE */  #define KFD_IOC_EVENT_SIGNAL			0  #define KFD_IOC_EVENT_NODECHANGE		1 @@ -276,12 +333,20 @@ struct kfd_hsa_hw_exception_data {  	__u32 gpu_id;  }; +/* hsa signal event data */ +struct kfd_hsa_signal_event_data { +	__u64 last_event_age;	/* to and from KFD */ +}; +  /* Event data */  struct kfd_event_data {  	union { +		/* From KFD */  		struct kfd_hsa_memory_exception_data memory_exception_data;  		struct kfd_hsa_hw_exception_data hw_exception_data; -	};				/* From KFD */ +		/* To and From KFD */ +		struct kfd_hsa_signal_event_data signal_event_data; +	};  	__u64 kfd_event_data_ext;	/* pointer to an extension structure  					   for future exception types */  	__u32 event_id;		/* to KFD */ @@ -351,6 +416,9 @@ struct kfd_ioctl_acquire_vm_args {  #define KFD_IOC_ALLOC_MEM_FLAGS_NO_SUBSTITUTE	(1 << 28)  #define KFD_IOC_ALLOC_MEM_FLAGS_AQL_QUEUE_MEM	(1 << 27)  #define KFD_IOC_ALLOC_MEM_FLAGS_COHERENT	(1 << 26) +#define KFD_IOC_ALLOC_MEM_FLAGS_UNCACHED	(1 << 25) +#define KFD_IOC_ALLOC_MEM_FLAGS_EXT_COHERENT	(1 << 24) +#define KFD_IOC_ALLOC_MEM_FLAGS_CONTIGUOUS	(1 << 23)  /* Allocate memory for later SVM (shared virtual memory) mapping.   * @@ -446,17 +514,224 @@ struct kfd_ioctl_import_dmabuf_args {  	__u32 dmabuf_fd;	/* to KFD */  }; +struct kfd_ioctl_export_dmabuf_args { +	__u64 handle;		/* to KFD */ +	__u32 flags;		/* to KFD */ +	__u32 dmabuf_fd;	/* from KFD */ +}; +  /*   * KFD SMI(System Management Interface) events   */ -/* Event type (defined by bitmask) */ -#define KFD_SMI_EVENT_VMFAULT     0x0000000000000001 +enum kfd_smi_event { +	KFD_SMI_EVENT_NONE = 0, /* not used */ +	KFD_SMI_EVENT_VMFAULT = 1, /* event start counting at 1 */ +	KFD_SMI_EVENT_THERMAL_THROTTLE = 2, +	KFD_SMI_EVENT_GPU_PRE_RESET = 3, +	KFD_SMI_EVENT_GPU_POST_RESET = 4, +	KFD_SMI_EVENT_MIGRATE_START = 5, +	KFD_SMI_EVENT_MIGRATE_END = 6, +	KFD_SMI_EVENT_PAGE_FAULT_START = 7, +	KFD_SMI_EVENT_PAGE_FAULT_END = 8, +	KFD_SMI_EVENT_QUEUE_EVICTION = 9, +	KFD_SMI_EVENT_QUEUE_RESTORE = 10, +	KFD_SMI_EVENT_UNMAP_FROM_GPU = 11, +	KFD_SMI_EVENT_PROCESS_START = 12, +	KFD_SMI_EVENT_PROCESS_END = 13, + +	/* +	 * max event number, as a flag bit to get events from all processes, +	 * this requires super user permission, otherwise will not be able to +	 * receive event from any process. Without this flag to receive events +	 * from same process. +	 */ +	KFD_SMI_EVENT_ALL_PROCESS = 64 +}; + +/* The reason of the page migration event */ +enum KFD_MIGRATE_TRIGGERS { +	KFD_MIGRATE_TRIGGER_PREFETCH,		/* Prefetch to GPU VRAM or system memory */ +	KFD_MIGRATE_TRIGGER_PAGEFAULT_GPU,	/* GPU page fault recover */ +	KFD_MIGRATE_TRIGGER_PAGEFAULT_CPU,	/* CPU page fault recover */ +	KFD_MIGRATE_TRIGGER_TTM_EVICTION	/* TTM eviction */ +}; + +/* The reason of user queue evition event */ +enum KFD_QUEUE_EVICTION_TRIGGERS { +	KFD_QUEUE_EVICTION_TRIGGER_SVM,		/* SVM buffer migration */ +	KFD_QUEUE_EVICTION_TRIGGER_USERPTR,	/* userptr movement */ +	KFD_QUEUE_EVICTION_TRIGGER_TTM,		/* TTM move buffer */ +	KFD_QUEUE_EVICTION_TRIGGER_SUSPEND,	/* GPU suspend */ +	KFD_QUEUE_EVICTION_CRIU_CHECKPOINT,	/* CRIU checkpoint */ +	KFD_QUEUE_EVICTION_CRIU_RESTORE		/* CRIU restore */ +}; + +/* The reason of unmap buffer from GPU event */ +enum KFD_SVM_UNMAP_TRIGGERS { +	KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY,	/* MMU notifier CPU buffer movement */ +	KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY_MIGRATE,/* MMU notifier page migration */ +	KFD_SVM_UNMAP_TRIGGER_UNMAP_FROM_CPU	/* Unmap to free the buffer */ +}; + +#define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1)) +#define KFD_SMI_EVENT_MSG_SIZE	96  struct kfd_ioctl_smi_events_args {  	__u32 gpuid;	/* to KFD */  	__u32 anon_fd;	/* from KFD */  }; +/* + * SVM event tracing via SMI system management interface + * + * Open event file descriptor + *    use ioctl AMDKFD_IOC_SMI_EVENTS, pass in gpuid and return a anonymous file + *    descriptor to receive SMI events. + *    If calling with sudo permission, then file descriptor can be used to receive + *    SVM events from all processes, otherwise, to only receive SVM events of same + *    process. + * + * To enable the SVM event + *    Write event file descriptor with KFD_SMI_EVENT_MASK_FROM_INDEX(event) bitmap + *    mask to start record the event to the kfifo, use bitmap mask combination + *    for multiple events. New event mask will overwrite the previous event mask. + *    KFD_SMI_EVENT_MASK_FROM_INDEX(KFD_SMI_EVENT_ALL_PROCESS) bit requires sudo + *    permisson to receive SVM events from all process. + * + * To receive the event + *    Application can poll file descriptor to wait for the events, then read event + *    from the file into a buffer. Each event is one line string message, starting + *    with the event id, then the event specific information. + * + * To decode event information + *    The following event format string macro can be used with sscanf to decode + *    the specific event information. + *    event triggers: the reason to generate the event, defined as enum for unmap, + *    eviction and migrate events. + *    node, from, to, prefetch_loc, preferred_loc: GPU ID, or 0 for system memory. + *    addr: user mode address, in pages + *    size: in pages + *    pid: the process ID to generate the event + *    ns: timestamp in nanosecond-resolution, starts at system boot time but + *        stops during suspend + *    migrate_update: GPU page fault is recovered by 'M' for migrate, 'U' for update + *    rw: 'W' for write page fault, 'R' for read page fault + *    rescheduled: 'R' if the queue restore failed and rescheduled to try again + *    error_code: migrate failure error code, 0 if no error + */ +#define KFD_EVENT_FMT_UPDATE_GPU_RESET(reset_seq_num, reset_cause)\ +		"%x %s\n", (reset_seq_num), (reset_cause) + +#define KFD_EVENT_FMT_THERMAL_THROTTLING(bitmask, counter)\ +		"%llx:%llx\n", (bitmask), (counter) + +#define KFD_EVENT_FMT_VMFAULT(pid, task_name)\ +		"%x:%s\n", (pid), (task_name) + +#define KFD_EVENT_FMT_PAGEFAULT_START(ns, pid, addr, node, rw)\ +		"%lld -%d @%lx(%x) %c\n", (ns), (pid), (addr), (node), (rw) + +#define KFD_EVENT_FMT_PAGEFAULT_END(ns, pid, addr, node, migrate_update)\ +		"%lld -%d @%lx(%x) %c\n", (ns), (pid), (addr), (node), (migrate_update) + +#define KFD_EVENT_FMT_MIGRATE_START(ns, pid, start, size, from, to, prefetch_loc,\ +		preferred_loc, migrate_trigger)\ +		"%lld -%d @%lx(%lx) %x->%x %x:%x %d\n", (ns), (pid), (start), (size),\ +		(from), (to), (prefetch_loc), (preferred_loc), (migrate_trigger) + +#define KFD_EVENT_FMT_MIGRATE_END(ns, pid, start, size, from, to, migrate_trigger, error_code) \ +		"%lld -%d @%lx(%lx) %x->%x %d %d\n", (ns), (pid), (start), (size),\ +		(from), (to), (migrate_trigger), (error_code) + +#define KFD_EVENT_FMT_QUEUE_EVICTION(ns, pid, node, evict_trigger)\ +		"%lld -%d %x %d\n", (ns), (pid), (node), (evict_trigger) + +#define KFD_EVENT_FMT_QUEUE_RESTORE(ns, pid, node, rescheduled)\ +		"%lld -%d %x %c\n", (ns), (pid), (node), (rescheduled) + +#define KFD_EVENT_FMT_UNMAP_FROM_GPU(ns, pid, addr, size, node, unmap_trigger)\ +		"%lld -%d @%lx(%lx) %x %d\n", (ns), (pid), (addr), (size),\ +		(node), (unmap_trigger) + +#define KFD_EVENT_FMT_PROCESS(pid, task_name)\ +		"%x %s\n", (pid), (task_name) + +/************************************************************************************************** + * CRIU IOCTLs (Checkpoint Restore In Userspace) + * + * When checkpointing a process, the userspace application will perform: + * 1. PROCESS_INFO op to determine current process information. This pauses execution and evicts + *    all the queues. + * 2. CHECKPOINT op to checkpoint process contents (BOs, queues, events, svm-ranges) + * 3. UNPAUSE op to un-evict all the queues + * + * When restoring a process, the CRIU userspace application will perform: + * + * 1. RESTORE op to restore process contents + * 2. RESUME op to start the process + * + * Note: Queues are forced into an evicted state after a successful PROCESS_INFO. User + * application needs to perform an UNPAUSE operation after calling PROCESS_INFO. + */ + +enum kfd_criu_op { +	KFD_CRIU_OP_PROCESS_INFO, +	KFD_CRIU_OP_CHECKPOINT, +	KFD_CRIU_OP_UNPAUSE, +	KFD_CRIU_OP_RESTORE, +	KFD_CRIU_OP_RESUME, +}; + +/** + * kfd_ioctl_criu_args - Arguments perform CRIU operation + * @devices:		[in/out] User pointer to memory location for devices information. + * 			This is an array of type kfd_criu_device_bucket. + * @bos:		[in/out] User pointer to memory location for BOs information + * 			This is an array of type kfd_criu_bo_bucket. + * @priv_data:		[in/out] User pointer to memory location for private data + * @priv_data_size:	[in/out] Size of priv_data in bytes + * @num_devices:	[in/out] Number of GPUs used by process. Size of @devices array. + * @num_bos		[in/out] Number of BOs used by process. Size of @bos array. + * @num_objects:	[in/out] Number of objects used by process. Objects are opaque to + *				 user application. + * @pid:		[in/out] PID of the process being checkpointed + * @op			[in] Type of operation (kfd_criu_op) + * + * Return: 0 on success, -errno on failure + */ +struct kfd_ioctl_criu_args { +	__u64 devices;		/* Used during ops: CHECKPOINT, RESTORE */ +	__u64 bos;		/* Used during ops: CHECKPOINT, RESTORE */ +	__u64 priv_data;	/* Used during ops: CHECKPOINT, RESTORE */ +	__u64 priv_data_size;	/* Used during ops: PROCESS_INFO, RESTORE */ +	__u32 num_devices;	/* Used during ops: PROCESS_INFO, RESTORE */ +	__u32 num_bos;		/* Used during ops: PROCESS_INFO, RESTORE */ +	__u32 num_objects;	/* Used during ops: PROCESS_INFO, RESTORE */ +	__u32 pid;		/* Used during ops: PROCESS_INFO, RESUME */ +	__u32 op; +}; + +struct kfd_criu_device_bucket { +	__u32 user_gpu_id; +	__u32 actual_gpu_id; +	__u32 drm_fd; +	__u32 pad; +}; + +struct kfd_criu_bo_bucket { +	__u64 addr; +	__u64 size; +	__u64 offset; +	__u64 restored_offset;    /* During restore, updated offset for BO */ +	__u32 gpu_id;             /* This is the user_gpu_id */ +	__u32 alloc_flags; +	__u32 dmabuf_fd; +	__u32 pad; +}; + +/* CRIU IOCTLs - END */ +/**************************************************************************************************/ +  /* Register offset inside the remapped mmio page   */  enum kfd_mmio_remap { @@ -464,6 +739,818 @@ enum kfd_mmio_remap {  	KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL = 4,  }; +/* Guarantee host access to memory */ +#define KFD_IOCTL_SVM_FLAG_HOST_ACCESS 0x00000001 +/* Fine grained coherency between all devices with access */ +#define KFD_IOCTL_SVM_FLAG_COHERENT    0x00000002 +/* Use any GPU in same hive as preferred device */ +#define KFD_IOCTL_SVM_FLAG_HIVE_LOCAL  0x00000004 +/* GPUs only read, allows replication */ +#define KFD_IOCTL_SVM_FLAG_GPU_RO      0x00000008 +/* Allow execution on GPU */ +#define KFD_IOCTL_SVM_FLAG_GPU_EXEC    0x00000010 +/* GPUs mostly read, may allow similar optimizations as RO, but writes fault */ +#define KFD_IOCTL_SVM_FLAG_GPU_READ_MOSTLY     0x00000020 +/* Keep GPU memory mapping always valid as if XNACK is disable */ +#define KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED   0x00000040 +/* Fine grained coherency between all devices using device-scope atomics */ +#define KFD_IOCTL_SVM_FLAG_EXT_COHERENT        0x00000080 + +/** + * kfd_ioctl_svm_op - SVM ioctl operations + * + * @KFD_IOCTL_SVM_OP_SET_ATTR: Modify one or more attributes + * @KFD_IOCTL_SVM_OP_GET_ATTR: Query one or more attributes + */ +enum kfd_ioctl_svm_op { +	KFD_IOCTL_SVM_OP_SET_ATTR, +	KFD_IOCTL_SVM_OP_GET_ATTR +}; + +/** kfd_ioctl_svm_location - Enum for preferred and prefetch locations + * + * GPU IDs are used to specify GPUs as preferred and prefetch locations. + * Below definitions are used for system memory or for leaving the preferred + * location unspecified. + */ +enum kfd_ioctl_svm_location { +	KFD_IOCTL_SVM_LOCATION_SYSMEM = 0, +	KFD_IOCTL_SVM_LOCATION_UNDEFINED = 0xffffffff +}; + +/** + * kfd_ioctl_svm_attr_type - SVM attribute types + * + * @KFD_IOCTL_SVM_ATTR_PREFERRED_LOC: gpuid of the preferred location, 0 for + *                                    system memory + * @KFD_IOCTL_SVM_ATTR_PREFETCH_LOC: gpuid of the prefetch location, 0 for + *                                   system memory. Setting this triggers an + *                                   immediate prefetch (migration). + * @KFD_IOCTL_SVM_ATTR_ACCESS: + * @KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE: + * @KFD_IOCTL_SVM_ATTR_NO_ACCESS: specify memory access for the gpuid given + *                                by the attribute value + * @KFD_IOCTL_SVM_ATTR_SET_FLAGS: bitmask of flags to set (see + *                                KFD_IOCTL_SVM_FLAG_...) + * @KFD_IOCTL_SVM_ATTR_CLR_FLAGS: bitmask of flags to clear + * @KFD_IOCTL_SVM_ATTR_GRANULARITY: migration granularity + *                                  (log2 num pages) + */ +enum kfd_ioctl_svm_attr_type { +	KFD_IOCTL_SVM_ATTR_PREFERRED_LOC, +	KFD_IOCTL_SVM_ATTR_PREFETCH_LOC, +	KFD_IOCTL_SVM_ATTR_ACCESS, +	KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE, +	KFD_IOCTL_SVM_ATTR_NO_ACCESS, +	KFD_IOCTL_SVM_ATTR_SET_FLAGS, +	KFD_IOCTL_SVM_ATTR_CLR_FLAGS, +	KFD_IOCTL_SVM_ATTR_GRANULARITY +}; + +/** + * kfd_ioctl_svm_attribute - Attributes as pairs of type and value + * + * The meaning of the @value depends on the attribute type. + * + * @type: attribute type (see enum @kfd_ioctl_svm_attr_type) + * @value: attribute value + */ +struct kfd_ioctl_svm_attribute { +	__u32 type; +	__u32 value; +}; + +/** + * kfd_ioctl_svm_args - Arguments for SVM ioctl + * + * @op specifies the operation to perform (see enum + * @kfd_ioctl_svm_op).  @start_addr and @size are common for all + * operations. + * + * A variable number of attributes can be given in @attrs. + * @nattr specifies the number of attributes. New attributes can be + * added in the future without breaking the ABI. If unknown attributes + * are given, the function returns -EINVAL. + * + * @KFD_IOCTL_SVM_OP_SET_ATTR sets attributes for a virtual address + * range. It may overlap existing virtual address ranges. If it does, + * the existing ranges will be split such that the attribute changes + * only apply to the specified address range. + * + * @KFD_IOCTL_SVM_OP_GET_ATTR returns the intersection of attributes + * over all memory in the given range and returns the result as the + * attribute value. If different pages have different preferred or + * prefetch locations, 0xffffffff will be returned for + * @KFD_IOCTL_SVM_ATTR_PREFERRED_LOC or + * @KFD_IOCTL_SVM_ATTR_PREFETCH_LOC resepctively. For + * @KFD_IOCTL_SVM_ATTR_SET_FLAGS, flags of all pages will be + * aggregated by bitwise AND. That means, a flag will be set in the + * output, if that flag is set for all pages in the range. For + * @KFD_IOCTL_SVM_ATTR_CLR_FLAGS, flags of all pages will be + * aggregated by bitwise NOR. That means, a flag will be set in the + * output, if that flag is clear for all pages in the range. + * The minimum migration granularity throughout the range will be + * returned for @KFD_IOCTL_SVM_ATTR_GRANULARITY. + * + * Querying of accessibility attributes works by initializing the + * attribute type to @KFD_IOCTL_SVM_ATTR_ACCESS and the value to the + * GPUID being queried. Multiple attributes can be given to allow + * querying multiple GPUIDs. The ioctl function overwrites the + * attribute type to indicate the access for the specified GPU. + */ +struct kfd_ioctl_svm_args { +	__u64 start_addr; +	__u64 size; +	__u32 op; +	__u32 nattr; +	/* Variable length array of attributes */ +	struct kfd_ioctl_svm_attribute attrs[]; +}; + +/** + * kfd_ioctl_set_xnack_mode_args - Arguments for set_xnack_mode + * + * @xnack_enabled:       [in/out] Whether to enable XNACK mode for this process + * + * @xnack_enabled indicates whether recoverable page faults should be + * enabled for the current process. 0 means disabled, positive means + * enabled, negative means leave unchanged. If enabled, virtual address + * translations on GFXv9 and later AMD GPUs can return XNACK and retry + * the access until a valid PTE is available. This is used to implement + * device page faults. + * + * On output, @xnack_enabled returns the (new) current mode (0 or + * positive). Therefore, a negative input value can be used to query + * the current mode without changing it. + * + * The XNACK mode fundamentally changes the way SVM managed memory works + * in the driver, with subtle effects on application performance and + * functionality. + * + * Enabling XNACK mode requires shader programs to be compiled + * differently. Furthermore, not all GPUs support changing the mode + * per-process. Therefore changing the mode is only allowed while no + * user mode queues exist in the process. This ensure that no shader + * code is running that may be compiled for the wrong mode. And GPUs + * that cannot change to the requested mode will prevent the XNACK + * mode from occurring. All GPUs used by the process must be in the + * same XNACK mode. + * + * GFXv8 or older GPUs do not support 48 bit virtual addresses or SVM. + * Therefore those GPUs are not considered for the XNACK mode switch. + * + * Return: 0 on success, -errno on failure + */ +struct kfd_ioctl_set_xnack_mode_args { +	__s32 xnack_enabled; +}; + +/* Wave launch override modes */ +enum kfd_dbg_trap_override_mode { +	KFD_DBG_TRAP_OVERRIDE_OR = 0, +	KFD_DBG_TRAP_OVERRIDE_REPLACE = 1 +}; + +/* Wave launch overrides */ +enum kfd_dbg_trap_mask { +	KFD_DBG_TRAP_MASK_FP_INVALID = 1, +	KFD_DBG_TRAP_MASK_FP_INPUT_DENORMAL = 2, +	KFD_DBG_TRAP_MASK_FP_DIVIDE_BY_ZERO = 4, +	KFD_DBG_TRAP_MASK_FP_OVERFLOW = 8, +	KFD_DBG_TRAP_MASK_FP_UNDERFLOW = 16, +	KFD_DBG_TRAP_MASK_FP_INEXACT = 32, +	KFD_DBG_TRAP_MASK_INT_DIVIDE_BY_ZERO = 64, +	KFD_DBG_TRAP_MASK_DBG_ADDRESS_WATCH = 128, +	KFD_DBG_TRAP_MASK_DBG_MEMORY_VIOLATION = 256, +	KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_START = (1 << 30), +	KFD_DBG_TRAP_MASK_TRAP_ON_WAVE_END = (1 << 31) +}; + +/* Wave launch modes */ +enum kfd_dbg_trap_wave_launch_mode { +	KFD_DBG_TRAP_WAVE_LAUNCH_MODE_NORMAL = 0, +	KFD_DBG_TRAP_WAVE_LAUNCH_MODE_HALT = 1, +	KFD_DBG_TRAP_WAVE_LAUNCH_MODE_DEBUG = 3 +}; + +/* Address watch modes */ +enum kfd_dbg_trap_address_watch_mode { +	KFD_DBG_TRAP_ADDRESS_WATCH_MODE_READ = 0, +	KFD_DBG_TRAP_ADDRESS_WATCH_MODE_NONREAD = 1, +	KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ATOMIC = 2, +	KFD_DBG_TRAP_ADDRESS_WATCH_MODE_ALL = 3 +}; + +/* Additional wave settings */ +enum kfd_dbg_trap_flags { +	KFD_DBG_TRAP_FLAG_SINGLE_MEM_OP = 1, +	KFD_DBG_TRAP_FLAG_SINGLE_ALU_OP = 2, +}; + +/* Trap exceptions */ +enum kfd_dbg_trap_exception_code { +	EC_NONE = 0, +	/* per queue */ +	EC_QUEUE_WAVE_ABORT = 1, +	EC_QUEUE_WAVE_TRAP = 2, +	EC_QUEUE_WAVE_MATH_ERROR = 3, +	EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION = 4, +	EC_QUEUE_WAVE_MEMORY_VIOLATION = 5, +	EC_QUEUE_WAVE_APERTURE_VIOLATION = 6, +	EC_QUEUE_PACKET_DISPATCH_DIM_INVALID = 16, +	EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID = 17, +	EC_QUEUE_PACKET_DISPATCH_CODE_INVALID = 18, +	EC_QUEUE_PACKET_RESERVED = 19, +	EC_QUEUE_PACKET_UNSUPPORTED = 20, +	EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID = 21, +	EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID = 22, +	EC_QUEUE_PACKET_VENDOR_UNSUPPORTED = 23, +	EC_QUEUE_PREEMPTION_ERROR = 30, +	EC_QUEUE_NEW = 31, +	/* per device */ +	EC_DEVICE_QUEUE_DELETE = 32, +	EC_DEVICE_MEMORY_VIOLATION = 33, +	EC_DEVICE_RAS_ERROR = 34, +	EC_DEVICE_FATAL_HALT = 35, +	EC_DEVICE_NEW = 36, +	/* per process */ +	EC_PROCESS_RUNTIME = 48, +	EC_PROCESS_DEVICE_REMOVE = 49, +	EC_MAX +}; + +/* Mask generated by ecode in kfd_dbg_trap_exception_code */ +#define KFD_EC_MASK(ecode)	(1ULL << (ecode - 1)) + +/* Masks for exception code type checks below */ +#define KFD_EC_MASK_QUEUE	(KFD_EC_MASK(EC_QUEUE_WAVE_ABORT) |	\ +				 KFD_EC_MASK(EC_QUEUE_WAVE_TRAP) |	\ +				 KFD_EC_MASK(EC_QUEUE_WAVE_MATH_ERROR) |	\ +				 KFD_EC_MASK(EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION) |	\ +				 KFD_EC_MASK(EC_QUEUE_WAVE_MEMORY_VIOLATION) |	\ +				 KFD_EC_MASK(EC_QUEUE_WAVE_APERTURE_VIOLATION) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_DIM_INVALID) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_CODE_INVALID) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_RESERVED) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_UNSUPPORTED) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_VENDOR_UNSUPPORTED)	|	\ +				 KFD_EC_MASK(EC_QUEUE_PREEMPTION_ERROR)	|	\ +				 KFD_EC_MASK(EC_QUEUE_NEW)) +#define KFD_EC_MASK_DEVICE	(KFD_EC_MASK(EC_DEVICE_QUEUE_DELETE) |		\ +				 KFD_EC_MASK(EC_DEVICE_RAS_ERROR) |		\ +				 KFD_EC_MASK(EC_DEVICE_FATAL_HALT) |		\ +				 KFD_EC_MASK(EC_DEVICE_MEMORY_VIOLATION) |	\ +				 KFD_EC_MASK(EC_DEVICE_NEW)) +#define KFD_EC_MASK_PROCESS	(KFD_EC_MASK(EC_PROCESS_RUNTIME) |	\ +				 KFD_EC_MASK(EC_PROCESS_DEVICE_REMOVE)) +#define KFD_EC_MASK_PACKET	(KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_DIM_INVALID) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_CODE_INVALID) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_RESERVED) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_UNSUPPORTED) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID) |	\ +				 KFD_EC_MASK(EC_QUEUE_PACKET_VENDOR_UNSUPPORTED)) + +/* Checks for exception code types for KFD search */ +#define KFD_DBG_EC_IS_VALID(ecode) (ecode > EC_NONE && ecode < EC_MAX) +#define KFD_DBG_EC_TYPE_IS_QUEUE(ecode)					\ +			(KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_QUEUE)) +#define KFD_DBG_EC_TYPE_IS_DEVICE(ecode)				\ +			(KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_DEVICE)) +#define KFD_DBG_EC_TYPE_IS_PROCESS(ecode)				\ +			(KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_PROCESS)) +#define KFD_DBG_EC_TYPE_IS_PACKET(ecode)				\ +			(KFD_DBG_EC_IS_VALID(ecode) && !!(KFD_EC_MASK(ecode) & KFD_EC_MASK_PACKET)) + + +/* Runtime enable states */ +enum kfd_dbg_runtime_state { +	DEBUG_RUNTIME_STATE_DISABLED = 0, +	DEBUG_RUNTIME_STATE_ENABLED = 1, +	DEBUG_RUNTIME_STATE_ENABLED_BUSY = 2, +	DEBUG_RUNTIME_STATE_ENABLED_ERROR = 3 +}; + +/* Runtime enable status */ +struct kfd_runtime_info { +	__u64 r_debug; +	__u32 runtime_state; +	__u32 ttmp_setup; +}; + +/* Enable modes for runtime enable */ +#define KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK	1 +#define KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK	2 + +/** + * kfd_ioctl_runtime_enable_args - Arguments for runtime enable + * + * Coordinates debug exception signalling and debug device enablement with runtime. + * + * @r_debug - pointer to user struct for sharing information between ROCr and the debuggger + * @mode_mask - mask to set mode + *	KFD_RUNTIME_ENABLE_MODE_ENABLE_MASK - enable runtime for debugging, otherwise disable + *	KFD_RUNTIME_ENABLE_MODE_TTMP_SAVE_MASK - enable trap temporary setup (ignore on disable) + * @capabilities_mask - mask to notify runtime on what KFD supports + * + * Return - 0 on SUCCESS. + *	  - EBUSY if runtime enable call already pending. + *	  - EEXIST if user queues already active prior to call. + *	    If process is debug enabled, runtime enable will enable debug devices and + *	    wait for debugger process to send runtime exception EC_PROCESS_RUNTIME + *	    to unblock - see kfd_ioctl_dbg_trap_args. + * + */ +struct kfd_ioctl_runtime_enable_args { +	__u64 r_debug; +	__u32 mode_mask; +	__u32 capabilities_mask; +}; + +/* Queue information */ +struct kfd_queue_snapshot_entry { +	__u64 exception_status; +	__u64 ring_base_address; +	__u64 write_pointer_address; +	__u64 read_pointer_address; +	__u64 ctx_save_restore_address; +	__u32 queue_id; +	__u32 gpu_id; +	__u32 ring_size; +	__u32 queue_type; +	__u32 ctx_save_restore_area_size; +	__u32 reserved; +}; + +/* Queue status return for suspend/resume */ +#define KFD_DBG_QUEUE_ERROR_BIT		30 +#define KFD_DBG_QUEUE_INVALID_BIT	31 +#define KFD_DBG_QUEUE_ERROR_MASK	(1 << KFD_DBG_QUEUE_ERROR_BIT) +#define KFD_DBG_QUEUE_INVALID_MASK	(1 << KFD_DBG_QUEUE_INVALID_BIT) + +/* Context save area header information */ +struct kfd_context_save_area_header { +	struct { +		__u32 control_stack_offset; +		__u32 control_stack_size; +		__u32 wave_state_offset; +		__u32 wave_state_size; +	} wave_state; +	__u32 debug_offset; +	__u32 debug_size; +	__u64 err_payload_addr; +	__u32 err_event_id; +	__u32 reserved1; +}; + +/* + * Debug operations + * + * For specifics on usage and return values, see documentation per operation + * below.  Otherwise, generic error returns apply: + *	- ESRCH if the process to debug does not exist. + * + *	- EINVAL (with KFD_IOC_DBG_TRAP_ENABLE exempt) if operation + *		 KFD_IOC_DBG_TRAP_ENABLE has not succeeded prior. + *		 Also returns this error if GPU hardware scheduling is not supported. + * + *	- EPERM (with KFD_IOC_DBG_TRAP_DISABLE exempt) if target process is not + *		 PTRACE_ATTACHED.  KFD_IOC_DBG_TRAP_DISABLE is exempt to allow + *		 clean up of debug mode as long as process is debug enabled. + * + *	- EACCES if any DBG_HW_OP (debug hardware operation) is requested when + *		 AMDKFD_IOC_RUNTIME_ENABLE has not succeeded prior. + * + *	- ENODEV if any GPU does not support debugging on a DBG_HW_OP call. + * + *	- Other errors may be returned when a DBG_HW_OP occurs while the GPU + *	  is in a fatal state. + * + */ +enum kfd_dbg_trap_operations { +	KFD_IOC_DBG_TRAP_ENABLE = 0, +	KFD_IOC_DBG_TRAP_DISABLE = 1, +	KFD_IOC_DBG_TRAP_SEND_RUNTIME_EVENT = 2, +	KFD_IOC_DBG_TRAP_SET_EXCEPTIONS_ENABLED = 3, +	KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE = 4,  /* DBG_HW_OP */ +	KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE = 5,      /* DBG_HW_OP */ +	KFD_IOC_DBG_TRAP_SUSPEND_QUEUES = 6,		/* DBG_HW_OP */ +	KFD_IOC_DBG_TRAP_RESUME_QUEUES = 7,		/* DBG_HW_OP */ +	KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH = 8,	/* DBG_HW_OP */ +	KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH = 9,	/* DBG_HW_OP */ +	KFD_IOC_DBG_TRAP_SET_FLAGS = 10, +	KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT = 11, +	KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO = 12, +	KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT = 13, +	KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT = 14 +}; + +/** + * kfd_ioctl_dbg_trap_enable_args + * + *     Arguments for KFD_IOC_DBG_TRAP_ENABLE. + * + *     Enables debug session for target process. Call @op KFD_IOC_DBG_TRAP_DISABLE in + *     kfd_ioctl_dbg_trap_args to disable debug session. + * + *     @exception_mask (IN)	- exceptions to raise to the debugger + *     @rinfo_ptr      (IN)	- pointer to runtime info buffer (see kfd_runtime_info) + *     @rinfo_size     (IN/OUT)	- size of runtime info buffer in bytes + *     @dbg_fd	       (IN)	- fd the KFD will nofify the debugger with of raised + *				  exceptions set in exception_mask. + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + *		Copies KFD saved kfd_runtime_info to @rinfo_ptr on enable. + *		Size of kfd_runtime saved by the KFD returned to @rinfo_size. + *            - EBADF if KFD cannot get a reference to dbg_fd. + *            - EFAULT if KFD cannot copy runtime info to rinfo_ptr. + *            - EINVAL if target process is already debug enabled. + * + */ +struct kfd_ioctl_dbg_trap_enable_args { +	__u64 exception_mask; +	__u64 rinfo_ptr; +	__u32 rinfo_size; +	__u32 dbg_fd; +}; + +/** + * kfd_ioctl_dbg_trap_send_runtime_event_args + * + * + *     Arguments for KFD_IOC_DBG_TRAP_SEND_RUNTIME_EVENT. + *     Raises exceptions to runtime. + * + *     @exception_mask (IN) - exceptions to raise to runtime + *     @gpu_id	       (IN) - target device id + *     @queue_id       (IN) - target queue id + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + *	      - ENODEV if gpu_id not found. + *		If exception_mask contains EC_PROCESS_RUNTIME, unblocks pending + *		AMDKFD_IOC_RUNTIME_ENABLE call - see kfd_ioctl_runtime_enable_args. + *		All other exceptions are raised to runtime through err_payload_addr. + *		See kfd_context_save_area_header. + */ +struct kfd_ioctl_dbg_trap_send_runtime_event_args { +	__u64 exception_mask; +	__u32 gpu_id; +	__u32 queue_id; +}; + +/** + * kfd_ioctl_dbg_trap_set_exceptions_enabled_args + * + *     Arguments for KFD_IOC_SET_EXCEPTIONS_ENABLED + *     Set new exceptions to be raised to the debugger. + * + *     @exception_mask (IN) - new exceptions to raise the debugger + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + */ +struct kfd_ioctl_dbg_trap_set_exceptions_enabled_args { +	__u64 exception_mask; +}; + +/** + * kfd_ioctl_dbg_trap_set_wave_launch_override_args + * + *     Arguments for KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE + *     Enable HW exceptions to raise trap. + * + *     @override_mode	     (IN)     - see kfd_dbg_trap_override_mode + *     @enable_mask	     (IN/OUT) - reference kfd_dbg_trap_mask. + *					IN is the override modes requested to be enabled. + *					OUT is referenced in Return below. + *     @support_request_mask (IN/OUT) - reference kfd_dbg_trap_mask. + *					IN is the override modes requested for support check. + *					OUT is referenced in Return below. + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + *		Previous enablement is returned in @enable_mask. + *		Actual override support is returned in @support_request_mask. + *	      - EINVAL if override mode is not supported. + *	      - EACCES if trap support requested is not actually supported. + *		i.e. enable_mask (IN) is not a subset of support_request_mask (OUT). + *		Otherwise it is considered a generic error (see kfd_dbg_trap_operations). + */ +struct kfd_ioctl_dbg_trap_set_wave_launch_override_args { +	__u32 override_mode; +	__u32 enable_mask; +	__u32 support_request_mask; +	__u32 pad; +}; + +/** + * kfd_ioctl_dbg_trap_set_wave_launch_mode_args + * + *     Arguments for KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE + *     Set wave launch mode. + * + *     @mode (IN) - see kfd_dbg_trap_wave_launch_mode + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + */ +struct kfd_ioctl_dbg_trap_set_wave_launch_mode_args { +	__u32 launch_mode; +	__u32 pad; +}; + +/** + * kfd_ioctl_dbg_trap_suspend_queues_ags + * + *     Arguments for KFD_IOC_DBG_TRAP_SUSPEND_QUEUES + *     Suspend queues. + * + *     @exception_mask	(IN) - raised exceptions to clear + *     @queue_array_ptr (IN) - pointer to array of queue ids (u32 per queue id) + *			       to suspend + *     @num_queues	(IN) - number of queues to suspend in @queue_array_ptr + *     @grace_period	(IN) - wave time allowance before preemption + *			       per 1K GPU clock cycle unit + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Destruction of a suspended queue is blocked until the queue is + *     resumed.  This allows the debugger to access queue information and + *     the its context save area without running into a race condition on + *     queue destruction. + *     Automatically copies per queue context save area header information + *     into the save area base + *     (see kfd_queue_snapshot_entry and kfd_context_save_area_header). + * + *     Return - Number of queues suspended on SUCCESS. + *	.	KFD_DBG_QUEUE_ERROR_MASK and KFD_DBG_QUEUE_INVALID_MASK masked + *		for each queue id in @queue_array_ptr array reports unsuccessful + *		suspend reason. + *		KFD_DBG_QUEUE_ERROR_MASK = HW failure. + *		KFD_DBG_QUEUE_INVALID_MASK = queue does not exist, is new or + *		is being destroyed. + */ +struct kfd_ioctl_dbg_trap_suspend_queues_args { +	__u64 exception_mask; +	__u64 queue_array_ptr; +	__u32 num_queues; +	__u32 grace_period; +}; + +/** + * kfd_ioctl_dbg_trap_resume_queues_args + * + *     Arguments for KFD_IOC_DBG_TRAP_RESUME_QUEUES + *     Resume queues. + * + *     @queue_array_ptr (IN) - pointer to array of queue ids (u32 per queue id) + *			       to resume + *     @num_queues	(IN) - number of queues to resume in @queue_array_ptr + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - Number of queues resumed on SUCCESS. + *		KFD_DBG_QUEUE_ERROR_MASK and KFD_DBG_QUEUE_INVALID_MASK mask + *		for each queue id in @queue_array_ptr array reports unsuccessful + *		resume reason. + *		KFD_DBG_QUEUE_ERROR_MASK = HW failure. + *		KFD_DBG_QUEUE_INVALID_MASK = queue does not exist. + */ +struct kfd_ioctl_dbg_trap_resume_queues_args { +	__u64 queue_array_ptr; +	__u32 num_queues; +	__u32 pad; +}; + +/** + * kfd_ioctl_dbg_trap_set_node_address_watch_args + * + *     Arguments for KFD_IOC_DBG_TRAP_SET_NODE_ADDRESS_WATCH + *     Sets address watch for device. + * + *     @address	(IN)  - watch address to set + *     @mode    (IN)  - see kfd_dbg_trap_address_watch_mode + *     @mask    (IN)  - watch address mask + *     @gpu_id  (IN)  - target gpu to set watch point + *     @id      (OUT) - watch id allocated + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + *		Allocated watch ID returned to @id. + *	      - ENODEV if gpu_id not found. + *	      - ENOMEM if watch IDs can be allocated + */ +struct kfd_ioctl_dbg_trap_set_node_address_watch_args { +	__u64 address; +	__u32 mode; +	__u32 mask; +	__u32 gpu_id; +	__u32 id; +}; + +/** + * kfd_ioctl_dbg_trap_clear_node_address_watch_args + * + *     Arguments for KFD_IOC_DBG_TRAP_CLEAR_NODE_ADDRESS_WATCH + *     Clear address watch for device. + * + *     @gpu_id  (IN)  - target device to clear watch point + *     @id      (IN) - allocated watch id to clear + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + *	      - ENODEV if gpu_id not found. + *	      - EINVAL if watch ID has not been allocated. + */ +struct kfd_ioctl_dbg_trap_clear_node_address_watch_args { +	__u32 gpu_id; +	__u32 id; +}; + +/** + * kfd_ioctl_dbg_trap_set_flags_args + * + *     Arguments for KFD_IOC_DBG_TRAP_SET_FLAGS + *     Sets flags for wave behaviour. + * + *     @flags (IN/OUT) - IN = flags to enable, OUT = flags previously enabled + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + *	      - EACCESS if any debug device does not allow flag options. + */ +struct kfd_ioctl_dbg_trap_set_flags_args { +	__u32 flags; +	__u32 pad; +}; + +/** + * kfd_ioctl_dbg_trap_query_debug_event_args + * + *     Arguments for KFD_IOC_DBG_TRAP_QUERY_DEBUG_EVENT + * + *     Find one or more raised exceptions. This function can return multiple + *     exceptions from a single queue or a single device with one call. To find + *     all raised exceptions, this function must be called repeatedly until it + *     returns -EAGAIN. Returned exceptions can optionally be cleared by + *     setting the corresponding bit in the @exception_mask input parameter. + *     However, clearing an exception prevents retrieving further information + *     about it with KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO. + * + *     @exception_mask (IN/OUT) - exception to clear (IN) and raised (OUT) + *     @gpu_id	       (OUT)    - gpu id of exceptions raised + *     @queue_id       (OUT)    - queue id of exceptions raised + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on raised exception found + *              Raised exceptions found are returned in @exception mask + *              with reported source id returned in @gpu_id or @queue_id. + *            - EAGAIN if no raised exception has been found + */ +struct kfd_ioctl_dbg_trap_query_debug_event_args { +	__u64 exception_mask; +	__u32 gpu_id; +	__u32 queue_id; +}; + +/** + * kfd_ioctl_dbg_trap_query_exception_info_args + * + *     Arguments KFD_IOC_DBG_TRAP_QUERY_EXCEPTION_INFO + *     Get additional info on raised exception. + * + *     @info_ptr	(IN)	 - pointer to exception info buffer to copy to + *     @info_size	(IN/OUT) - exception info buffer size (bytes) + *     @source_id	(IN)     - target gpu or queue id + *     @exception_code	(IN)     - target exception + *     @clear_exception	(IN)     - clear raised @exception_code exception + *				   (0 = false, 1 = true) + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + *              If @exception_code is EC_DEVICE_MEMORY_VIOLATION, copy @info_size(OUT) + *		bytes of memory exception data to @info_ptr. + *              If @exception_code is EC_PROCESS_RUNTIME, copy saved + *              kfd_runtime_info to @info_ptr. + *              Actual required @info_ptr size (bytes) is returned in @info_size. + */ +struct kfd_ioctl_dbg_trap_query_exception_info_args { +	__u64 info_ptr; +	__u32 info_size; +	__u32 source_id; +	__u32 exception_code; +	__u32 clear_exception; +}; + +/** + * kfd_ioctl_dbg_trap_get_queue_snapshot_args + * + *     Arguments KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT + *     Get queue information. + * + *     @exception_mask	 (IN)	  - exceptions raised to clear + *     @snapshot_buf_ptr (IN)	  - queue snapshot entry buffer (see kfd_queue_snapshot_entry) + *     @num_queues	 (IN/OUT) - number of queue snapshot entries + *         The debugger specifies the size of the array allocated in @num_queues. + *         KFD returns the number of queues that actually existed. If this is + *         larger than the size specified by the debugger, KFD will not overflow + *         the array allocated by the debugger. + * + *     @entry_size	 (IN/OUT) - size per entry in bytes + *         The debugger specifies sizeof(struct kfd_queue_snapshot_entry) in + *         @entry_size. KFD returns the number of bytes actually populated per + *         entry. The debugger should use the KFD_IOCTL_MINOR_VERSION to determine, + *         which fields in struct kfd_queue_snapshot_entry are valid. This allows + *         growing the ABI in a backwards compatible manner. + *         Note that entry_size(IN) should still be used to stride the snapshot buffer in the + *         event that it's larger than actual kfd_queue_snapshot_entry. + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + *              Copies @num_queues(IN) queue snapshot entries of size @entry_size(IN) + *              into @snapshot_buf_ptr if @num_queues(IN) > 0. + *              Otherwise return @num_queues(OUT) queue snapshot entries that exist. + */ +struct kfd_ioctl_dbg_trap_queue_snapshot_args { +	__u64 exception_mask; +	__u64 snapshot_buf_ptr; +	__u32 num_queues; +	__u32 entry_size; +}; + +/** + * kfd_ioctl_dbg_trap_get_device_snapshot_args + * + *     Arguments for KFD_IOC_DBG_TRAP_GET_DEVICE_SNAPSHOT + *     Get device information. + * + *     @exception_mask	 (IN)	  - exceptions raised to clear + *     @snapshot_buf_ptr (IN)	  - pointer to snapshot buffer (see kfd_dbg_device_info_entry) + *     @num_devices	 (IN/OUT) - number of debug devices to snapshot + *         The debugger specifies the size of the array allocated in @num_devices. + *         KFD returns the number of devices that actually existed. If this is + *         larger than the size specified by the debugger, KFD will not overflow + *         the array allocated by the debugger. + * + *     @entry_size	 (IN/OUT) - size per entry in bytes + *         The debugger specifies sizeof(struct kfd_dbg_device_info_entry) in + *         @entry_size. KFD returns the number of bytes actually populated. The + *         debugger should use KFD_IOCTL_MINOR_VERSION to determine, which fields + *         in struct kfd_dbg_device_info_entry are valid. This allows growing the + *         ABI in a backwards compatible manner. + *         Note that entry_size(IN) should still be used to stride the snapshot buffer in the + *         event that it's larger than actual kfd_dbg_device_info_entry. + * + *     Generic errors apply (see kfd_dbg_trap_operations). + *     Return - 0 on SUCCESS. + *              Copies @num_devices(IN) device snapshot entries of size @entry_size(IN) + *              into @snapshot_buf_ptr if @num_devices(IN) > 0. + *              Otherwise return @num_devices(OUT) queue snapshot entries that exist. + */ +struct kfd_ioctl_dbg_trap_device_snapshot_args { +	__u64 exception_mask; +	__u64 snapshot_buf_ptr; +	__u32 num_devices; +	__u32 entry_size; +}; + +/** + * kfd_ioctl_dbg_trap_args + * + * Arguments to debug target process. + * + *     @pid - target process to debug + *     @op  - debug operation (see kfd_dbg_trap_operations) + * + *     @op determines which union struct args to use. + *     Refer to kern docs for each kfd_ioctl_dbg_trap_*_args struct. + */ +struct kfd_ioctl_dbg_trap_args { +	__u32 pid; +	__u32 op; + +	union { +		struct kfd_ioctl_dbg_trap_enable_args enable; +		struct kfd_ioctl_dbg_trap_send_runtime_event_args send_runtime_event; +		struct kfd_ioctl_dbg_trap_set_exceptions_enabled_args set_exceptions_enabled; +		struct kfd_ioctl_dbg_trap_set_wave_launch_override_args launch_override; +		struct kfd_ioctl_dbg_trap_set_wave_launch_mode_args launch_mode; +		struct kfd_ioctl_dbg_trap_suspend_queues_args suspend_queues; +		struct kfd_ioctl_dbg_trap_resume_queues_args resume_queues; +		struct kfd_ioctl_dbg_trap_set_node_address_watch_args set_node_address_watch; +		struct kfd_ioctl_dbg_trap_clear_node_address_watch_args clear_node_address_watch; +		struct kfd_ioctl_dbg_trap_set_flags_args set_flags; +		struct kfd_ioctl_dbg_trap_query_debug_event_args query_debug_event; +		struct kfd_ioctl_dbg_trap_query_exception_info_args query_exception_info; +		struct kfd_ioctl_dbg_trap_queue_snapshot_args queue_snapshot; +		struct kfd_ioctl_dbg_trap_device_snapshot_args device_snapshot; +	}; +}; +  #define AMDKFD_IOCTL_BASE 'K'  #define AMDKFD_IO(nr)			_IO(AMDKFD_IOCTL_BASE, nr)  #define AMDKFD_IOR(nr, type)		_IOR(AMDKFD_IOCTL_BASE, nr, type) @@ -506,16 +1593,16 @@ enum kfd_mmio_remap {  #define AMDKFD_IOC_WAIT_EVENTS			\  		AMDKFD_IOWR(0x0C, struct kfd_ioctl_wait_events_args) -#define AMDKFD_IOC_DBG_REGISTER			\ +#define AMDKFD_IOC_DBG_REGISTER_DEPRECATED	\  		AMDKFD_IOW(0x0D, struct kfd_ioctl_dbg_register_args) -#define AMDKFD_IOC_DBG_UNREGISTER		\ +#define AMDKFD_IOC_DBG_UNREGISTER_DEPRECATED	\  		AMDKFD_IOW(0x0E, struct kfd_ioctl_dbg_unregister_args) -#define AMDKFD_IOC_DBG_ADDRESS_WATCH		\ +#define AMDKFD_IOC_DBG_ADDRESS_WATCH_DEPRECATED	\  		AMDKFD_IOW(0x0F, struct kfd_ioctl_dbg_address_watch_args) -#define AMDKFD_IOC_DBG_WAVE_CONTROL		\ +#define AMDKFD_IOC_DBG_WAVE_CONTROL_DEPRECATED	\  		AMDKFD_IOW(0x10, struct kfd_ioctl_dbg_wave_control_args)  #define AMDKFD_IOC_SET_SCRATCH_BACKING_VA	\ @@ -564,7 +1651,27 @@ enum kfd_mmio_remap {  #define AMDKFD_IOC_SMI_EVENTS			\  		AMDKFD_IOWR(0x1F, struct kfd_ioctl_smi_events_args) +#define AMDKFD_IOC_SVM	AMDKFD_IOWR(0x20, struct kfd_ioctl_svm_args) + +#define AMDKFD_IOC_SET_XNACK_MODE		\ +		AMDKFD_IOWR(0x21, struct kfd_ioctl_set_xnack_mode_args) + +#define AMDKFD_IOC_CRIU_OP			\ +		AMDKFD_IOWR(0x22, struct kfd_ioctl_criu_args) + +#define AMDKFD_IOC_AVAILABLE_MEMORY		\ +		AMDKFD_IOWR(0x23, struct kfd_ioctl_get_available_memory_args) + +#define AMDKFD_IOC_EXPORT_DMABUF		\ +		AMDKFD_IOWR(0x24, struct kfd_ioctl_export_dmabuf_args) + +#define AMDKFD_IOC_RUNTIME_ENABLE		\ +		AMDKFD_IOWR(0x25, struct kfd_ioctl_runtime_enable_args) + +#define AMDKFD_IOC_DBG_TRAP			\ +		AMDKFD_IOWR(0x26, struct kfd_ioctl_dbg_trap_args) +  #define AMDKFD_COMMAND_START		0x01 -#define AMDKFD_COMMAND_END		0x20 +#define AMDKFD_COMMAND_END		0x27  #endif diff --git a/include/uapi/linux/kfd_sysfs.h b/include/uapi/linux/kfd_sysfs.h new file mode 100644 index 000000000000..1125fe47959f --- /dev/null +++ b/include/uapi/linux/kfd_sysfs.h @@ -0,0 +1,128 @@ +/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */ +/* + * Copyright 2021 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef KFD_SYSFS_H_INCLUDED +#define KFD_SYSFS_H_INCLUDED + +/* Capability bits in node properties */ +#define HSA_CAP_HOT_PLUGGABLE			0x00000001 +#define HSA_CAP_ATS_PRESENT			0x00000002 +#define HSA_CAP_SHARED_WITH_GRAPHICS		0x00000004 +#define HSA_CAP_QUEUE_SIZE_POW2			0x00000008 +#define HSA_CAP_QUEUE_SIZE_32BIT		0x00000010 +#define HSA_CAP_QUEUE_IDLE_EVENT		0x00000020 +#define HSA_CAP_VA_LIMIT			0x00000040 +#define HSA_CAP_WATCH_POINTS_SUPPORTED		0x00000080 +#define HSA_CAP_WATCH_POINTS_TOTALBITS_MASK	0x00000f00 +#define HSA_CAP_WATCH_POINTS_TOTALBITS_SHIFT	8 +#define HSA_CAP_DOORBELL_TYPE_TOTALBITS_MASK	0x00003000 +#define HSA_CAP_DOORBELL_TYPE_TOTALBITS_SHIFT	12 + +#define HSA_CAP_DOORBELL_TYPE_PRE_1_0		0x0 +#define HSA_CAP_DOORBELL_TYPE_1_0		0x1 +#define HSA_CAP_DOORBELL_TYPE_2_0		0x2 +#define HSA_CAP_AQL_QUEUE_DOUBLE_MAP		0x00004000 + +#define HSA_CAP_TRAP_DEBUG_SUPPORT              0x00008000 +#define HSA_CAP_TRAP_DEBUG_WAVE_LAUNCH_TRAP_OVERRIDE_SUPPORTED  0x00010000 +#define HSA_CAP_TRAP_DEBUG_WAVE_LAUNCH_MODE_SUPPORTED           0x00020000 +#define HSA_CAP_TRAP_DEBUG_PRECISE_MEMORY_OPERATIONS_SUPPORTED  0x00040000 + +/* Old buggy user mode depends on this being 0 */ +#define HSA_CAP_RESERVED_WAS_SRAM_EDCSUPPORTED	0x00080000 + +#define HSA_CAP_MEM_EDCSUPPORTED				0x00100000 +#define HSA_CAP_RASEVENTNOTIFY					0x00200000 +#define HSA_CAP_ASIC_REVISION_MASK				0x03c00000 +#define HSA_CAP_ASIC_REVISION_SHIFT				22 +#define HSA_CAP_SRAM_EDCSUPPORTED				0x04000000 +#define HSA_CAP_SVMAPI_SUPPORTED				0x08000000 +#define HSA_CAP_FLAGS_COHERENTHOSTACCESS			0x10000000 +#define HSA_CAP_TRAP_DEBUG_FIRMWARE_SUPPORTED			0x20000000 +#define HSA_CAP_TRAP_DEBUG_PRECISE_ALU_OPERATIONS_SUPPORTED	0x40000000 +#define HSA_CAP_PER_QUEUE_RESET_SUPPORTED			0x80000000 +#define HSA_CAP_RESERVED					0x000f8000 + +#define HSA_CAP2_PER_SDMA_QUEUE_RESET_SUPPORTED			0x00000001 +#define HSA_CAP2_RESERVED					0xfffffffe + +/* debug_prop bits in node properties */ +#define HSA_DBG_WATCH_ADDR_MASK_LO_BIT_MASK     0x0000000f +#define HSA_DBG_WATCH_ADDR_MASK_LO_BIT_SHIFT    0 +#define HSA_DBG_WATCH_ADDR_MASK_HI_BIT_MASK     0x000003f0 +#define HSA_DBG_WATCH_ADDR_MASK_HI_BIT_SHIFT    4 +#define HSA_DBG_DISPATCH_INFO_ALWAYS_VALID      0x00000400 +#define HSA_DBG_WATCHPOINTS_EXCLUSIVE           0x00000800 +#define HSA_DBG_RESERVED                0xfffffffffffff000ull + +/* Heap types in memory properties */ +#define HSA_MEM_HEAP_TYPE_SYSTEM	0 +#define HSA_MEM_HEAP_TYPE_FB_PUBLIC	1 +#define HSA_MEM_HEAP_TYPE_FB_PRIVATE	2 +#define HSA_MEM_HEAP_TYPE_GPU_GDS	3 +#define HSA_MEM_HEAP_TYPE_GPU_LDS	4 +#define HSA_MEM_HEAP_TYPE_GPU_SCRATCH	5 + +/* Flag bits in memory properties */ +#define HSA_MEM_FLAGS_HOT_PLUGGABLE		0x00000001 +#define HSA_MEM_FLAGS_NON_VOLATILE		0x00000002 +#define HSA_MEM_FLAGS_RESERVED			0xfffffffc + +/* Cache types in cache properties */ +#define HSA_CACHE_TYPE_DATA		0x00000001 +#define HSA_CACHE_TYPE_INSTRUCTION	0x00000002 +#define HSA_CACHE_TYPE_CPU		0x00000004 +#define HSA_CACHE_TYPE_HSACU		0x00000008 +#define HSA_CACHE_TYPE_RESERVED		0xfffffff0 + +/* Link types in IO link properties (matches CRAT link types) */ +#define HSA_IOLINK_TYPE_UNDEFINED	0 +#define HSA_IOLINK_TYPE_HYPERTRANSPORT	1 +#define HSA_IOLINK_TYPE_PCIEXPRESS	2 +#define HSA_IOLINK_TYPE_AMBA		3 +#define HSA_IOLINK_TYPE_MIPI		4 +#define HSA_IOLINK_TYPE_QPI_1_1	5 +#define HSA_IOLINK_TYPE_RESERVED1	6 +#define HSA_IOLINK_TYPE_RESERVED2	7 +#define HSA_IOLINK_TYPE_RAPID_IO	8 +#define HSA_IOLINK_TYPE_INFINIBAND	9 +#define HSA_IOLINK_TYPE_RESERVED3	10 +#define HSA_IOLINK_TYPE_XGMI		11 +#define HSA_IOLINK_TYPE_XGOP		12 +#define HSA_IOLINK_TYPE_GZ		13 +#define HSA_IOLINK_TYPE_ETHERNET_RDMA	14 +#define HSA_IOLINK_TYPE_RDMA_OTHER	15 +#define HSA_IOLINK_TYPE_OTHER		16 + +/* Flag bits in IO link properties (matches CRAT flags, excluding the + * bi-directional flag, which is not offially part of the CRAT spec, and + * only used internally in KFD) + */ +#define HSA_IOLINK_FLAGS_ENABLED		(1 << 0) +#define HSA_IOLINK_FLAGS_NON_COHERENT		(1 << 1) +#define HSA_IOLINK_FLAGS_NO_ATOMICS_32_BIT	(1 << 2) +#define HSA_IOLINK_FLAGS_NO_ATOMICS_64_BIT	(1 << 3) +#define HSA_IOLINK_FLAGS_NO_PEER_TO_PEER_DMA	(1 << 4) +#define HSA_IOLINK_FLAGS_RESERVED		0xffffffe0 + +#endif diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index f6d86033c4fa..f0f0d49d2544 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -8,6 +8,7 @@   * Note: you must update KVM_API_VERSION if you change this interface.   */ +#include <linux/const.h>  #include <linux/types.h>  #include <linux/compiler.h>  #include <linux/ioctl.h> @@ -15,100 +16,41 @@  #define KVM_API_VERSION 12 -/* *** Deprecated interfaces *** */ - -#define KVM_TRC_SHIFT           16 - -#define KVM_TRC_ENTRYEXIT       (1 << KVM_TRC_SHIFT) -#define KVM_TRC_HANDLER         (1 << (KVM_TRC_SHIFT + 1)) - -#define KVM_TRC_VMENTRY         (KVM_TRC_ENTRYEXIT + 0x01) -#define KVM_TRC_VMEXIT          (KVM_TRC_ENTRYEXIT + 0x02) -#define KVM_TRC_PAGE_FAULT      (KVM_TRC_HANDLER + 0x01) - -#define KVM_TRC_HEAD_SIZE       12 -#define KVM_TRC_CYCLE_SIZE      8 -#define KVM_TRC_EXTRA_MAX       7 - -#define KVM_TRC_INJ_VIRQ         (KVM_TRC_HANDLER + 0x02) -#define KVM_TRC_REDELIVER_EVT    (KVM_TRC_HANDLER + 0x03) -#define KVM_TRC_PEND_INTR        (KVM_TRC_HANDLER + 0x04) -#define KVM_TRC_IO_READ          (KVM_TRC_HANDLER + 0x05) -#define KVM_TRC_IO_WRITE         (KVM_TRC_HANDLER + 0x06) -#define KVM_TRC_CR_READ          (KVM_TRC_HANDLER + 0x07) -#define KVM_TRC_CR_WRITE         (KVM_TRC_HANDLER + 0x08) -#define KVM_TRC_DR_READ          (KVM_TRC_HANDLER + 0x09) -#define KVM_TRC_DR_WRITE         (KVM_TRC_HANDLER + 0x0A) -#define KVM_TRC_MSR_READ         (KVM_TRC_HANDLER + 0x0B) -#define KVM_TRC_MSR_WRITE        (KVM_TRC_HANDLER + 0x0C) -#define KVM_TRC_CPUID            (KVM_TRC_HANDLER + 0x0D) -#define KVM_TRC_INTR             (KVM_TRC_HANDLER + 0x0E) -#define KVM_TRC_NMI              (KVM_TRC_HANDLER + 0x0F) -#define KVM_TRC_VMMCALL          (KVM_TRC_HANDLER + 0x10) -#define KVM_TRC_HLT              (KVM_TRC_HANDLER + 0x11) -#define KVM_TRC_CLTS             (KVM_TRC_HANDLER + 0x12) -#define KVM_TRC_LMSW             (KVM_TRC_HANDLER + 0x13) -#define KVM_TRC_APIC_ACCESS      (KVM_TRC_HANDLER + 0x14) -#define KVM_TRC_TDP_FAULT        (KVM_TRC_HANDLER + 0x15) -#define KVM_TRC_GTLB_WRITE       (KVM_TRC_HANDLER + 0x16) -#define KVM_TRC_STLB_WRITE       (KVM_TRC_HANDLER + 0x17) -#define KVM_TRC_STLB_INVAL       (KVM_TRC_HANDLER + 0x18) -#define KVM_TRC_PPC_INSTR        (KVM_TRC_HANDLER + 0x19) - -struct kvm_user_trace_setup { -	__u32 buf_size; -	__u32 buf_nr; -}; - -#define __KVM_DEPRECATED_MAIN_W_0x06 \ -	_IOW(KVMIO, 0x06, struct kvm_user_trace_setup) -#define __KVM_DEPRECATED_MAIN_0x07 _IO(KVMIO, 0x07) -#define __KVM_DEPRECATED_MAIN_0x08 _IO(KVMIO, 0x08) - -#define __KVM_DEPRECATED_VM_R_0x70 _IOR(KVMIO, 0x70, struct kvm_assigned_irq) - -struct kvm_breakpoint { -	__u32 enabled; -	__u32 padding; -	__u64 address; -}; - -struct kvm_debug_guest { -	__u32 enabled; -	__u32 pad; -	struct kvm_breakpoint breakpoints[4]; -	__u32 singlestep; -}; - -#define __KVM_DEPRECATED_VCPU_W_0x87 _IOW(KVMIO, 0x87, struct kvm_debug_guest) - -/* *** End of deprecated interfaces *** */ - +/* + * Backwards-compatible definitions. + */ +#define __KVM_HAVE_GUEST_DEBUG -/* for KVM_CREATE_MEMORY_REGION */ -struct kvm_memory_region { +/* for KVM_SET_USER_MEMORY_REGION */ +struct kvm_userspace_memory_region {  	__u32 slot;  	__u32 flags;  	__u64 guest_phys_addr;  	__u64 memory_size; /* bytes */ +	__u64 userspace_addr; /* start of the userspace allocated memory */  }; -/* for KVM_SET_USER_MEMORY_REGION */ -struct kvm_userspace_memory_region { +/* for KVM_SET_USER_MEMORY_REGION2 */ +struct kvm_userspace_memory_region2 {  	__u32 slot;  	__u32 flags;  	__u64 guest_phys_addr; -	__u64 memory_size; /* bytes */ -	__u64 userspace_addr; /* start of the userspace allocated memory */ +	__u64 memory_size; +	__u64 userspace_addr; +	__u64 guest_memfd_offset; +	__u32 guest_memfd; +	__u32 pad1; +	__u64 pad2[14];  };  /* - * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspace, - * other bits are reserved for kvm internal use which are defined in - * include/linux/kvm_host.h. + * The bit 0 ~ bit 15 of kvm_userspace_memory_region::flags are visible for + * userspace, other bits are reserved for kvm internal use which are defined + * in include/linux/kvm_host.h.   */  #define KVM_MEM_LOG_DIRTY_PAGES	(1UL << 0)  #define KVM_MEM_READONLY	(1UL << 1) +#define KVM_MEM_GUEST_MEMFD	(1UL << 2)  /* for KVM_IRQ_LINE */  struct kvm_irq_level { @@ -148,43 +90,6 @@ struct kvm_pit_config {  #define KVM_PIT_SPEAKER_DUMMY     1 -struct kvm_s390_skeys { -	__u64 start_gfn; -	__u64 count; -	__u64 skeydata_addr; -	__u32 flags; -	__u32 reserved[9]; -}; - -#define KVM_S390_CMMA_PEEK (1 << 0) - -/** - * kvm_s390_cmma_log - Used for CMMA migration. - * - * Used both for input and output. - * - * @start_gfn: Guest page number to start from. - * @count: Size of the result buffer. - * @flags: Control operation mode via KVM_S390_CMMA_* flags - * @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty - *             pages are still remaining. - * @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set - *        in the PGSTE. - * @values: Pointer to the values buffer. - * - * Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls. - */ -struct kvm_s390_cmma_log { -	__u64 start_gfn; -	__u32 count; -	__u32 flags; -	union { -		__u64 remaining; -		__u64 mask; -	}; -	__u64 values; -}; -  struct kvm_hyperv_exit {  #define KVM_EXIT_HYPERV_SYNIC          1  #define KVM_EXIT_HYPERV_HCALL          2 @@ -216,6 +121,20 @@ struct kvm_hyperv_exit {  	} u;  }; +struct kvm_xen_exit { +#define KVM_EXIT_XEN_HCALL          1 +	__u32 type; +	union { +		struct { +			__u32 longmode; +			__u32 cpl; +			__u64 input; +			__u64 result; +			__u64 params[6]; +		} hcall; +	} u; +}; +  #define KVM_S390_GET_SKEYS_NONE   1  #define KVM_S390_SKEYS_MAX        1048576 @@ -248,6 +167,18 @@ struct kvm_hyperv_exit {  #define KVM_EXIT_IOAPIC_EOI       26  #define KVM_EXIT_HYPERV           27  #define KVM_EXIT_ARM_NISV         28 +#define KVM_EXIT_X86_RDMSR        29 +#define KVM_EXIT_X86_WRMSR        30 +#define KVM_EXIT_DIRTY_RING_FULL  31 +#define KVM_EXIT_AP_RESET_HOLD    32 +#define KVM_EXIT_X86_BUS_LOCK     33 +#define KVM_EXIT_XEN              34 +#define KVM_EXIT_RISCV_SBI        35 +#define KVM_EXIT_RISCV_CSR        36 +#define KVM_EXIT_NOTIFY           37 +#define KVM_EXIT_LOONGARCH_IOCSR  38 +#define KVM_EXIT_MEMORY_FAULT     39 +#define KVM_EXIT_TDX              40  /* For KVM_EXIT_INTERNAL_ERROR */  /* Emulate instruction failed. */ @@ -259,11 +190,27 @@ struct kvm_hyperv_exit {  /* Encounter unexpected vm-exit reason */  #define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON	4 +/* Flags that describe what fields in emulation_failure hold valid data. */ +#define KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES (1ULL << 0) + +/* + * struct kvm_run can be modified by userspace at any time, so KVM must be + * careful to avoid TOCTOU bugs. In order to protect KVM, HINT_UNSAFE_IN_KVM() + * renames fields in struct kvm_run from <symbol> to <symbol>__unsafe when + * compiled into the kernel, ensuring that any use within KVM is obvious and + * gets extra scrutiny. + */ +#ifdef __KERNEL__ +#define HINT_UNSAFE_IN_KVM(_symbol) _symbol##__unsafe +#else +#define HINT_UNSAFE_IN_KVM(_symbol) _symbol +#endif +  /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */  struct kvm_run {  	/* in */  	__u8 request_interrupt_window; -	__u8 immediate_exit; +	__u8 HINT_UNSAFE_IN_KVM(immediate_exit);  	__u8 padding1[6];  	/* out */ @@ -317,13 +264,25 @@ struct kvm_run {  			__u32 len;  			__u8  is_write;  		} mmio; +		/* KVM_EXIT_LOONGARCH_IOCSR */ +		struct { +			__u64 phys_addr; +			__u8  data[8]; +			__u32 len; +			__u8  is_write; +		} iocsr_io;  		/* KVM_EXIT_HYPERCALL */  		struct {  			__u64 nr;  			__u64 args[6];  			__u64 ret; -			__u32 longmode; -			__u32 pad; + +			union { +#ifndef __KERNEL__ +				__u32 longmode; +#endif +				__u64 flags; +			};  		} hypercall;  		/* KVM_EXIT_TPR_ACCESS */  		struct { @@ -338,11 +297,6 @@ struct kvm_run {  			__u32 ipb;  		} s390_sieic;  		/* KVM_EXIT_S390_RESET */ -#define KVM_S390_RESET_POR       1 -#define KVM_S390_RESET_CLEAR     2 -#define KVM_S390_RESET_SUBSYSTEM 4 -#define KVM_S390_RESET_CPU_INIT  8 -#define KVM_S390_RESET_IPL       16  		__u64 s390_reset_flags;  		/* KVM_EXIT_S390_UCONTROL */  		struct { @@ -362,6 +316,35 @@ struct kvm_run {  			__u32 ndata;  			__u64 data[16];  		} internal; +		/* +		 * KVM_INTERNAL_ERROR_EMULATION +		 * +		 * "struct emulation_failure" is an overlay of "struct internal" +		 * that is used for the KVM_INTERNAL_ERROR_EMULATION sub-type of +		 * KVM_EXIT_INTERNAL_ERROR.  Note, unlike other internal error +		 * sub-types, this struct is ABI!  It also needs to be backwards +		 * compatible with "struct internal".  Take special care that +		 * "ndata" is correct, that new fields are enumerated in "flags", +		 * and that each flag enumerates fields that are 64-bit aligned +		 * and sized (so that ndata+internal.data[] is valid/accurate). +		 * +		 * Space beyond the defined fields may be used to store arbitrary +		 * debug information relating to the emulation failure. It is +		 * accounted for in "ndata" but the format is unspecified and is +		 * not represented in "flags". Any such information is *not* ABI! +		 */ +		struct { +			__u32 suberror; +			__u32 ndata; +			__u64 flags; +			union { +				struct { +					__u8  insn_size; +					__u8  insn_bytes[15]; +				}; +			}; +			/* Arbitrary debug data may follow. */ +		} emulation_failure;  		/* KVM_EXIT_OSI */  		struct {  			__u64 gprs[32]; @@ -390,8 +373,18 @@ struct kvm_run {  #define KVM_SYSTEM_EVENT_SHUTDOWN       1  #define KVM_SYSTEM_EVENT_RESET          2  #define KVM_SYSTEM_EVENT_CRASH          3 +#define KVM_SYSTEM_EVENT_WAKEUP         4 +#define KVM_SYSTEM_EVENT_SUSPEND        5 +#define KVM_SYSTEM_EVENT_SEV_TERM       6 +#define KVM_SYSTEM_EVENT_TDX_FATAL      7  			__u32 type; -			__u64 flags; +			__u32 ndata; +			union { +#ifndef __KERNEL__ +				__u64 flags; +#endif +				__u64 data[16]; +			};  		} system_event;  		/* KVM_EXIT_S390_STSI */  		struct { @@ -413,6 +406,73 @@ struct kvm_run {  			__u64 esr_iss;  			__u64 fault_ipa;  		} arm_nisv; +		/* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */ +		struct { +			__u8 error; /* user -> kernel */ +			__u8 pad[7]; +#define KVM_MSR_EXIT_REASON_INVAL	(1 << 0) +#define KVM_MSR_EXIT_REASON_UNKNOWN	(1 << 1) +#define KVM_MSR_EXIT_REASON_FILTER	(1 << 2) +#define KVM_MSR_EXIT_REASON_VALID_MASK	(KVM_MSR_EXIT_REASON_INVAL   |	\ +					 KVM_MSR_EXIT_REASON_UNKNOWN |	\ +					 KVM_MSR_EXIT_REASON_FILTER) +			__u32 reason; /* kernel -> user */ +			__u32 index; /* kernel -> user */ +			__u64 data; /* kernel <-> user */ +		} msr; +		/* KVM_EXIT_XEN */ +		struct kvm_xen_exit xen; +		/* KVM_EXIT_RISCV_SBI */ +		struct { +			unsigned long extension_id; +			unsigned long function_id; +			unsigned long args[6]; +			unsigned long ret[2]; +		} riscv_sbi; +		/* KVM_EXIT_RISCV_CSR */ +		struct { +			unsigned long csr_num; +			unsigned long new_value; +			unsigned long write_mask; +			unsigned long ret_value; +		} riscv_csr; +		/* KVM_EXIT_NOTIFY */ +		struct { +#define KVM_NOTIFY_CONTEXT_INVALID	(1 << 0) +			__u32 flags; +		} notify; +		/* KVM_EXIT_MEMORY_FAULT */ +		struct { +#define KVM_MEMORY_EXIT_FLAG_PRIVATE	(1ULL << 3) +			__u64 flags; +			__u64 gpa; +			__u64 size; +		} memory_fault; +		/* KVM_EXIT_TDX */ +		struct { +			__u64 flags; +			__u64 nr; +			union { +				struct { +					__u64 ret; +					__u64 data[5]; +				} unknown; +				struct { +					__u64 ret; +					__u64 gpa; +					__u64 size; +				} get_quote; +				struct { +					__u64 ret; +					__u64 leaf; +					__u64 r11, r12, r13, r14; +				} get_tdvmcall_info; +				struct { +					__u64 ret; +					__u64 vector; +				} setup_event_notify; +			}; +		} tdx;  		/* Fix the size of the union. */  		char padding[256];  	}; @@ -459,7 +519,7 @@ struct kvm_coalesced_mmio {  struct kvm_coalesced_mmio_ring {  	__u32 first, last; -	struct kvm_coalesced_mmio coalesced_mmio[0]; +	struct kvm_coalesced_mmio coalesced_mmio[];  };  #define KVM_COALESCED_MMIO_MAX \ @@ -479,29 +539,6 @@ struct kvm_translation {  	__u8  pad[5];  }; -/* for KVM_S390_MEM_OP */ -struct kvm_s390_mem_op { -	/* in */ -	__u64 gaddr;		/* the guest address */ -	__u64 flags;		/* flags */ -	__u32 size;		/* amount of bytes */ -	__u32 op;		/* type of operation */ -	__u64 buf;		/* buffer in userspace */ -	union { -		__u8 ar;	/* the access register number */ -		__u32 sida_offset; /* offset into the sida */ -		__u8 reserved[32]; /* should be set to 0 */ -	}; -}; -/* types for kvm_s390_mem_op->op */ -#define KVM_S390_MEMOP_LOGICAL_READ	0 -#define KVM_S390_MEMOP_LOGICAL_WRITE	1 -#define KVM_S390_MEMOP_SIDA_READ	2 -#define KVM_S390_MEMOP_SIDA_WRITE	3 -/* flags for kvm_s390_mem_op->flags */ -#define KVM_S390_MEMOP_F_CHECK_ONLY		(1ULL << 0) -#define KVM_S390_MEMOP_F_INJECT_EXCEPTION	(1ULL << 1) -  /* for KVM_INTERRUPT */  struct kvm_interrupt {  	/* in */ @@ -532,7 +569,7 @@ struct kvm_clear_dirty_log {  /* for KVM_SET_SIGNAL_MASK */  struct kvm_signal_mask {  	__u32 len; -	__u8  sigset[0]; +	__u8  sigset[];  };  /* for KVM_TPR_ACCESS_REPORTING */ @@ -559,129 +596,13 @@ struct kvm_vapic_addr {  #define KVM_MP_STATE_CHECK_STOP        6  #define KVM_MP_STATE_OPERATING         7  #define KVM_MP_STATE_LOAD              8 +#define KVM_MP_STATE_AP_RESET_HOLD     9 +#define KVM_MP_STATE_SUSPENDED         10  struct kvm_mp_state {  	__u32 mp_state;  }; -struct kvm_s390_psw { -	__u64 mask; -	__u64 addr; -}; - -/* valid values for type in kvm_s390_interrupt */ -#define KVM_S390_SIGP_STOP		0xfffe0000u -#define KVM_S390_PROGRAM_INT		0xfffe0001u -#define KVM_S390_SIGP_SET_PREFIX	0xfffe0002u -#define KVM_S390_RESTART		0xfffe0003u -#define KVM_S390_INT_PFAULT_INIT	0xfffe0004u -#define KVM_S390_INT_PFAULT_DONE	0xfffe0005u -#define KVM_S390_MCHK			0xfffe1000u -#define KVM_S390_INT_CLOCK_COMP		0xffff1004u -#define KVM_S390_INT_CPU_TIMER		0xffff1005u -#define KVM_S390_INT_VIRTIO		0xffff2603u -#define KVM_S390_INT_SERVICE		0xffff2401u -#define KVM_S390_INT_EMERGENCY		0xffff1201u -#define KVM_S390_INT_EXTERNAL_CALL	0xffff1202u -/* Anything below 0xfffe0000u is taken by INT_IO */ -#define KVM_S390_INT_IO(ai,cssid,ssid,schid)   \ -	(((schid)) |			       \ -	 ((ssid) << 16) |		       \ -	 ((cssid) << 18) |		       \ -	 ((ai) << 26)) -#define KVM_S390_INT_IO_MIN		0x00000000u -#define KVM_S390_INT_IO_MAX		0xfffdffffu -#define KVM_S390_INT_IO_AI_MASK		0x04000000u - - -struct kvm_s390_interrupt { -	__u32 type; -	__u32 parm; -	__u64 parm64; -}; - -struct kvm_s390_io_info { -	__u16 subchannel_id; -	__u16 subchannel_nr; -	__u32 io_int_parm; -	__u32 io_int_word; -}; - -struct kvm_s390_ext_info { -	__u32 ext_params; -	__u32 pad; -	__u64 ext_params2; -}; - -struct kvm_s390_pgm_info { -	__u64 trans_exc_code; -	__u64 mon_code; -	__u64 per_address; -	__u32 data_exc_code; -	__u16 code; -	__u16 mon_class_nr; -	__u8 per_code; -	__u8 per_atmid; -	__u8 exc_access_id; -	__u8 per_access_id; -	__u8 op_access_id; -#define KVM_S390_PGM_FLAGS_ILC_VALID	0x01 -#define KVM_S390_PGM_FLAGS_ILC_0	0x02 -#define KVM_S390_PGM_FLAGS_ILC_1	0x04 -#define KVM_S390_PGM_FLAGS_ILC_MASK	0x06 -#define KVM_S390_PGM_FLAGS_NO_REWIND	0x08 -	__u8 flags; -	__u8 pad[2]; -}; - -struct kvm_s390_prefix_info { -	__u32 address; -}; - -struct kvm_s390_extcall_info { -	__u16 code; -}; - -struct kvm_s390_emerg_info { -	__u16 code; -}; - -#define KVM_S390_STOP_FLAG_STORE_STATUS	0x01 -struct kvm_s390_stop_info { -	__u32 flags; -}; - -struct kvm_s390_mchk_info { -	__u64 cr14; -	__u64 mcic; -	__u64 failing_storage_address; -	__u32 ext_damage_code; -	__u32 pad; -	__u8 fixed_logout[16]; -}; - -struct kvm_s390_irq { -	__u64 type; -	union { -		struct kvm_s390_io_info io; -		struct kvm_s390_ext_info ext; -		struct kvm_s390_pgm_info pgm; -		struct kvm_s390_emerg_info emerg; -		struct kvm_s390_extcall_info extcall; -		struct kvm_s390_prefix_info prefix; -		struct kvm_s390_stop_info stop; -		struct kvm_s390_mchk_info mchk; -		char reserved[64]; -	} u; -}; - -struct kvm_s390_irq_state { -	__u64 buf; -	__u32 flags;        /* will stay unused for compatibility reasons */ -	__u32 len; -	__u32 reserved[4];  /* will stay unused for compatibility reasons */ -}; -  /* for KVM_SET_GUEST_DEBUG */  #define KVM_GUESTDBG_ENABLE		0x00000001 @@ -723,10 +644,7 @@ struct kvm_ioeventfd {  #define KVM_X86_DISABLE_EXITS_HLT            (1 << 1)  #define KVM_X86_DISABLE_EXITS_PAUSE          (1 << 2)  #define KVM_X86_DISABLE_EXITS_CSTATE         (1 << 3) -#define KVM_X86_DISABLE_VALID_EXITS          (KVM_X86_DISABLE_EXITS_MWAIT | \ -                                              KVM_X86_DISABLE_EXITS_HLT | \ -                                              KVM_X86_DISABLE_EXITS_PAUSE | \ -                                              KVM_X86_DISABLE_EXITS_CSTATE) +#define KVM_X86_DISABLE_EXITS_APERFMPERF     (1 << 4)  /* for KVM_ENABLE_CAP */  struct kvm_enable_cap { @@ -737,50 +655,6 @@ struct kvm_enable_cap {  	__u8  pad[64];  }; -/* for KVM_PPC_GET_PVINFO */ - -#define KVM_PPC_PVINFO_FLAGS_EV_IDLE   (1<<0) - -struct kvm_ppc_pvinfo { -	/* out */ -	__u32 flags; -	__u32 hcall[4]; -	__u8  pad[108]; -}; - -/* for KVM_PPC_GET_SMMU_INFO */ -#define KVM_PPC_PAGE_SIZES_MAX_SZ	8 - -struct kvm_ppc_one_page_size { -	__u32 page_shift;	/* Page shift (or 0) */ -	__u32 pte_enc;		/* Encoding in the HPTE (>>12) */ -}; - -struct kvm_ppc_one_seg_page_size { -	__u32 page_shift;	/* Base page shift of segment (or 0) */ -	__u32 slb_enc;		/* SLB encoding for BookS */ -	struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; -}; - -#define KVM_PPC_PAGE_SIZES_REAL		0x00000001 -#define KVM_PPC_1T_SEGMENTS		0x00000002 -#define KVM_PPC_NO_HASH			0x00000004 - -struct kvm_ppc_smmu_info { -	__u64 flags; -	__u32 slb_size; -	__u16 data_keys;	/* # storage keys supported for data */ -	__u16 instr_keys;	/* # storage keys supported for instructions */ -	struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; -}; - -/* for KVM_PPC_RESIZE_HPT_{PREPARE,COMMIT} */ -struct kvm_ppc_resize_hpt { -	__u64 flags; -	__u32 shift; -	__u32 pad; -}; -  #define KVMIO 0xAE  /* machine type bits, to be used as argument to KVM_CREATE_VM */ @@ -790,9 +664,10 @@ struct kvm_ppc_resize_hpt {  #define KVM_VM_PPC_HV 1  #define KVM_VM_PPC_PR 2 -/* on MIPS, 0 forces trap & emulate, 1 forces VZ ASE */ -#define KVM_VM_MIPS_TE		0 +/* on MIPS, 0 indicates auto, 1 forces VZ ASE, 2 forces trap & emulate */ +#define KVM_VM_MIPS_AUTO	0  #define KVM_VM_MIPS_VZ		1 +#define KVM_VM_MIPS_TE		2  #define KVM_S390_SIE_PAGE_OFFSET 1 @@ -823,9 +698,6 @@ struct kvm_ppc_resize_hpt {   */  #define KVM_GET_VCPU_MMAP_SIZE    _IO(KVMIO,   0x04) /* in bytes */  #define KVM_GET_SUPPORTED_CPUID   _IOWR(KVMIO, 0x05, struct kvm_cpuid2) -#define KVM_TRACE_ENABLE          __KVM_DEPRECATED_MAIN_W_0x06 -#define KVM_TRACE_PAUSE           __KVM_DEPRECATED_MAIN_0x07 -#define KVM_TRACE_DISABLE         __KVM_DEPRECATED_MAIN_0x08  #define KVM_GET_EMULATED_CPUID	  _IOWR(KVMIO, 0x09, struct kvm_cpuid2)  #define KVM_GET_MSR_FEATURE_INDEX_LIST    _IOWR(KVMIO, 0x0a, struct kvm_msr_list) @@ -852,9 +724,7 @@ struct kvm_ppc_resize_hpt {  /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */  #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21  #define KVM_CAP_USER_NMI 22 -#ifdef __KVM_HAVE_GUEST_DEBUG  #define KVM_CAP_SET_GUEST_DEBUG 23 -#endif  #ifdef __KVM_HAVE_PIT  #define KVM_CAP_REINJECT_CONTROL 24  #endif @@ -1035,8 +905,63 @@ struct kvm_ppc_resize_hpt {  #define KVM_CAP_LAST_CPU 184  #define KVM_CAP_SMALLER_MAXPHYADDR 185  #define KVM_CAP_S390_DIAG318 186 - -#ifdef KVM_CAP_IRQ_ROUTING +#define KVM_CAP_STEAL_TIME 187 +#define KVM_CAP_X86_USER_SPACE_MSR 188 +#define KVM_CAP_X86_MSR_FILTER 189 +#define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190 +#define KVM_CAP_SYS_HYPERV_CPUID 191 +#define KVM_CAP_DIRTY_LOG_RING 192 +#define KVM_CAP_X86_BUS_LOCK_EXIT 193 +#define KVM_CAP_PPC_DAWR1 194 +#define KVM_CAP_SET_GUEST_DEBUG2 195 +#define KVM_CAP_SGX_ATTRIBUTE 196 +#define KVM_CAP_VM_COPY_ENC_CONTEXT_FROM 197 +#define KVM_CAP_PTP_KVM 198 +#define KVM_CAP_HYPERV_ENFORCE_CPUID 199 +#define KVM_CAP_SREGS2 200 +#define KVM_CAP_EXIT_HYPERCALL 201 +#define KVM_CAP_PPC_RPT_INVALIDATE 202 +#define KVM_CAP_BINARY_STATS_FD 203 +#define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204 +#define KVM_CAP_ARM_MTE 205 +#define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206 +#define KVM_CAP_VM_GPA_BITS 207 +#define KVM_CAP_XSAVE2 208 +#define KVM_CAP_SYS_ATTRIBUTES 209 +#define KVM_CAP_PPC_AIL_MODE_3 210 +#define KVM_CAP_S390_MEM_OP_EXTENSION 211 +#define KVM_CAP_PMU_CAPABILITY 212 +#define KVM_CAP_DISABLE_QUIRKS2 213 +#define KVM_CAP_VM_TSC_CONTROL 214 +#define KVM_CAP_SYSTEM_EVENT_DATA 215 +#define KVM_CAP_ARM_SYSTEM_SUSPEND 216 +#define KVM_CAP_S390_PROTECTED_DUMP 217 +#define KVM_CAP_X86_TRIPLE_FAULT_EVENT 218 +#define KVM_CAP_X86_NOTIFY_VMEXIT 219 +#define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220 +#define KVM_CAP_S390_ZPCI_OP 221 +#define KVM_CAP_S390_CPU_TOPOLOGY 222 +#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223 +#define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224 +#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225 +#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226 +#define KVM_CAP_COUNTER_OFFSET 227 +#define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228 +#define KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES 229 +#define KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES 230 +#define KVM_CAP_USER_MEMORY2 231 +#define KVM_CAP_MEMORY_FAULT_INFO 232 +#define KVM_CAP_MEMORY_ATTRIBUTES 233 +#define KVM_CAP_GUEST_MEMFD 234 +#define KVM_CAP_VM_TYPES 235 +#define KVM_CAP_PRE_FAULT_MEMORY 236 +#define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 +#define KVM_CAP_X86_GUEST_MODE 238 +#define KVM_CAP_ARM_WRITABLE_IMP_ID_REGS 239 +#define KVM_CAP_ARM_EL2 240 +#define KVM_CAP_ARM_EL2_E2H0 241 +#define KVM_CAP_RISCV_MP_STATE_RESET 242 +#define KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED 243  struct kvm_irq_routing_irqchip {  	__u32 irqchip; @@ -1066,11 +991,20 @@ struct kvm_irq_routing_hv_sint {  	__u32 sint;  }; +struct kvm_irq_routing_xen_evtchn { +	__u32 port; +	__u32 vcpu; +	__u32 priority; +}; + +#define KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_2LEVEL ((__u32)(-1)) +  /* gsi routing entry types */  #define KVM_IRQ_ROUTING_IRQCHIP 1  #define KVM_IRQ_ROUTING_MSI 2  #define KVM_IRQ_ROUTING_S390_ADAPTER 3  #define KVM_IRQ_ROUTING_HV_SINT 4 +#define KVM_IRQ_ROUTING_XEN_EVTCHN 5  struct kvm_irq_routing_entry {  	__u32 gsi; @@ -1082,6 +1016,7 @@ struct kvm_irq_routing_entry {  		struct kvm_irq_routing_msi msi;  		struct kvm_irq_routing_s390_adapter adapter;  		struct kvm_irq_routing_hv_sint hv_sint; +		struct kvm_irq_routing_xen_evtchn xen_evtchn;  		__u32 pad[8];  	} u;  }; @@ -1089,36 +1024,9 @@ struct kvm_irq_routing_entry {  struct kvm_irq_routing {  	__u32 nr;  	__u32 flags; -	struct kvm_irq_routing_entry entries[0]; +	struct kvm_irq_routing_entry entries[];  }; -#endif - -#ifdef KVM_CAP_MCE -/* x86 MCE */ -struct kvm_x86_mce { -	__u64 status; -	__u64 addr; -	__u64 misc; -	__u64 mcg_status; -	__u8 bank; -	__u8 pad1[7]; -	__u64 pad2[3]; -}; -#endif - -#ifdef KVM_CAP_XEN_HVM -struct kvm_xen_hvm_config { -	__u32 flags; -	__u32 msr; -	__u64 blob_addr_32; -	__u64 blob_addr_64; -	__u8 blob_size_32; -	__u8 blob_size_64; -	__u8 pad2[30]; -}; -#endif -  #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)  /*   * Available with KVM_CAP_IRQFD_RESAMPLE @@ -1141,11 +1049,16 @@ struct kvm_irqfd {  /* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags.  */  #define KVM_CLOCK_TSC_STABLE		2 +#define KVM_CLOCK_REALTIME		(1 << 2) +#define KVM_CLOCK_HOST_TSC		(1 << 3)  struct kvm_clock_data {  	__u64 clock;  	__u32 flags; -	__u32 pad[9]; +	__u32 pad0; +	__u64 realtime; +	__u64 host_tsc; +	__u32 pad[4];  };  /* For KVM_CAP_SW_TLB */ @@ -1182,9 +1095,14 @@ struct kvm_dirty_tlb {  #define KVM_REG_ARM64		0x6000000000000000ULL  #define KVM_REG_MIPS		0x7000000000000000ULL  #define KVM_REG_RISCV		0x8000000000000000ULL +#define KVM_REG_LOONGARCH	0x9000000000000000ULL  #define KVM_REG_SIZE_SHIFT	52  #define KVM_REG_SIZE_MASK	0x00f0000000000000ULL + +#define KVM_REG_SIZE(id)		\ +	(1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT)) +  #define KVM_REG_SIZE_U8		0x0000000000000000ULL  #define KVM_REG_SIZE_U16	0x0010000000000000ULL  #define KVM_REG_SIZE_U32	0x0020000000000000ULL @@ -1197,7 +1115,7 @@ struct kvm_dirty_tlb {  struct kvm_reg_list {  	__u64 n; /* number of regs */ -	__u64 reg[0]; +	__u64 reg[];  };  struct kvm_one_reg { @@ -1238,9 +1156,16 @@ struct kvm_device_attr {  	__u64	addr;		/* userspace address of attr data */  }; -#define  KVM_DEV_VFIO_GROUP			1 -#define   KVM_DEV_VFIO_GROUP_ADD			1 -#define   KVM_DEV_VFIO_GROUP_DEL			2 +#define  KVM_DEV_VFIO_FILE			1 + +#define   KVM_DEV_VFIO_FILE_ADD			1 +#define   KVM_DEV_VFIO_FILE_DEL			2 + +/* KVM_DEV_VFIO_GROUP aliases are for compile time uapi compatibility */ +#define  KVM_DEV_VFIO_GROUP	KVM_DEV_VFIO_FILE + +#define   KVM_DEV_VFIO_GROUP_ADD	KVM_DEV_VFIO_FILE_ADD +#define   KVM_DEV_VFIO_GROUP_DEL	KVM_DEV_VFIO_FILE_DEL  #define   KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE		3  enum kvm_device_type { @@ -1264,7 +1189,17 @@ enum kvm_device_type {  #define KVM_DEV_TYPE_XIVE		KVM_DEV_TYPE_XIVE  	KVM_DEV_TYPE_ARM_PV_TIME,  #define KVM_DEV_TYPE_ARM_PV_TIME	KVM_DEV_TYPE_ARM_PV_TIME +	KVM_DEV_TYPE_RISCV_AIA, +#define KVM_DEV_TYPE_RISCV_AIA		KVM_DEV_TYPE_RISCV_AIA +	KVM_DEV_TYPE_LOONGARCH_IPI, +#define KVM_DEV_TYPE_LOONGARCH_IPI	KVM_DEV_TYPE_LOONGARCH_IPI +	KVM_DEV_TYPE_LOONGARCH_EIOINTC, +#define KVM_DEV_TYPE_LOONGARCH_EIOINTC	KVM_DEV_TYPE_LOONGARCH_EIOINTC +	KVM_DEV_TYPE_LOONGARCH_PCHPIC, +#define KVM_DEV_TYPE_LOONGARCH_PCHPIC	KVM_DEV_TYPE_LOONGARCH_PCHPIC +  	KVM_DEV_TYPE_MAX, +  };  struct kvm_vfio_spapr_tce { @@ -1273,30 +1208,21 @@ struct kvm_vfio_spapr_tce {  };  /* - * ioctls for VM fds - */ -#define KVM_SET_MEMORY_REGION     _IOW(KVMIO,  0x40, struct kvm_memory_region) -/*   * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns   * a vcpu fd.   */  #define KVM_CREATE_VCPU           _IO(KVMIO,   0x41)  #define KVM_GET_DIRTY_LOG         _IOW(KVMIO,  0x42, struct kvm_dirty_log) -/* KVM_SET_MEMORY_ALIAS is obsolete: */ -#define KVM_SET_MEMORY_ALIAS      _IOW(KVMIO,  0x43, struct kvm_memory_alias)  #define KVM_SET_NR_MMU_PAGES      _IO(KVMIO,   0x44) -#define KVM_GET_NR_MMU_PAGES      _IO(KVMIO,   0x45) +#define KVM_GET_NR_MMU_PAGES      _IO(KVMIO,   0x45)  /* deprecated */  #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \  					struct kvm_userspace_memory_region)  #define KVM_SET_TSS_ADDR          _IO(KVMIO,   0x47)  #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO,  0x48, __u64) +#define KVM_SET_USER_MEMORY_REGION2 _IOW(KVMIO, 0x49, \ +					 struct kvm_userspace_memory_region2)  /* enable ucontrol for s390 */ -struct kvm_s390_ucas_mapping { -	__u64 user_addr; -	__u64 vcpu_addr; -	__u64 length; -};  #define KVM_S390_UCAS_MAP        _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping)  #define KVM_S390_UCAS_UNMAP      _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping)  #define KVM_S390_VCPU_FAULT	 _IOW(KVMIO, 0x52, unsigned long) @@ -1314,20 +1240,8 @@ struct kvm_s390_ucas_mapping {  			_IOW(KVMIO,  0x67, struct kvm_coalesced_mmio_zone)  #define KVM_UNREGISTER_COALESCED_MMIO \  			_IOW(KVMIO,  0x68, struct kvm_coalesced_mmio_zone) -#define KVM_ASSIGN_PCI_DEVICE     _IOR(KVMIO,  0x69, \ -				       struct kvm_assigned_pci_dev)  #define KVM_SET_GSI_ROUTING       _IOW(KVMIO,  0x6a, struct kvm_irq_routing) -/* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */ -#define KVM_ASSIGN_IRQ            __KVM_DEPRECATED_VM_R_0x70 -#define KVM_ASSIGN_DEV_IRQ        _IOW(KVMIO,  0x70, struct kvm_assigned_irq)  #define KVM_REINJECT_CONTROL      _IO(KVMIO,   0x71) -#define KVM_DEASSIGN_PCI_DEVICE   _IOW(KVMIO,  0x72, \ -				       struct kvm_assigned_pci_dev) -#define KVM_ASSIGN_SET_MSIX_NR    _IOW(KVMIO,  0x73, \ -				       struct kvm_assigned_msix_nr) -#define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO,  0x74, \ -				       struct kvm_assigned_msix_entry) -#define KVM_DEASSIGN_DEV_IRQ      _IOW(KVMIO,  0x75, struct kvm_assigned_irq)  #define KVM_IRQFD                 _IOW(KVMIO,  0x76, struct kvm_irqfd)  #define KVM_CREATE_PIT2		  _IOW(KVMIO,  0x77, struct kvm_pit_config)  #define KVM_SET_BOOT_CPU_ID       _IO(KVMIO,   0x78) @@ -1340,12 +1254,10 @@ struct kvm_s390_ucas_mapping {  #define KVM_SET_PIT2              _IOW(KVMIO,  0xa0, struct kvm_pit_state2)  /* Available with KVM_CAP_PPC_GET_PVINFO */  #define KVM_PPC_GET_PVINFO	  _IOW(KVMIO,  0xa1, struct kvm_ppc_pvinfo) -/* Available with KVM_CAP_TSC_CONTROL */ +/* Available with KVM_CAP_TSC_CONTROL for a vCPU, or with +*  KVM_CAP_VM_TSC_CONTROL to set defaults for a VM */  #define KVM_SET_TSC_KHZ           _IO(KVMIO,  0xa2)  #define KVM_GET_TSC_KHZ           _IO(KVMIO,  0xa3) -/* Available with KVM_CAP_PCI_2_3 */ -#define KVM_ASSIGN_SET_INTX_MASK  _IOW(KVMIO,  0xa4, \ -				       struct kvm_assigned_pci_dev)  /* Available with KVM_CAP_SIGNAL_MSI */  #define KVM_SIGNAL_MSI            _IOW(KVMIO,  0xa5, struct kvm_msi)  /* Available with KVM_CAP_PPC_GET_SMMU_INFO */ @@ -1366,15 +1278,19 @@ struct kvm_s390_ucas_mapping {  /* Available with KVM_CAP_SPAPR_RESIZE_HPT */  #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt)  #define KVM_PPC_RESIZE_HPT_COMMIT  _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt) -/* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */ +/* Available with KVM_CAP_PPC_MMU_RADIX or KVM_CAP_PPC_MMU_HASH_V3 */  #define KVM_PPC_CONFIGURE_V3_MMU  _IOW(KVMIO,  0xaf, struct kvm_ppc_mmuv3_cfg) -/* Available with KVM_CAP_PPC_RADIX_MMU */ +/* Available with KVM_CAP_PPC_MMU_RADIX */  #define KVM_PPC_GET_RMMU_INFO	  _IOW(KVMIO,  0xb0, struct kvm_ppc_rmmu_info)  /* Available with KVM_CAP_PPC_GET_CPU_CHAR */  #define KVM_PPC_GET_CPU_CHAR	  _IOR(KVMIO,  0xb1, struct kvm_ppc_cpu_char)  /* Available with KVM_CAP_PMU_EVENT_FILTER */  #define KVM_SET_PMU_EVENT_FILTER  _IOW(KVMIO,  0xb2, struct kvm_pmu_event_filter)  #define KVM_PPC_SVM_OFF		  _IO(KVMIO,  0xb3) +#define KVM_ARM_MTE_COPY_TAGS	  _IOR(KVMIO,  0xb4, struct kvm_arm_copy_mte_tags) +/* Available with KVM_CAP_COUNTER_OFFSET */ +#define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO,  0xb5, struct kvm_arm_counter_offset) +#define KVM_ARM_GET_REG_WRITABLE_MASKS _IOR(KVMIO,  0xb6, struct reg_mask_range)  /* ioctl for vm fd */  #define KVM_CREATE_DEVICE	  _IOWR(KVMIO,  0xe0, struct kvm_create_device) @@ -1394,8 +1310,6 @@ struct kvm_s390_ucas_mapping {  #define KVM_SET_SREGS             _IOW(KVMIO,  0x84, struct kvm_sregs)  #define KVM_TRANSLATE             _IOWR(KVMIO, 0x85, struct kvm_translation)  #define KVM_INTERRUPT             _IOW(KVMIO,  0x86, struct kvm_interrupt) -/* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */ -#define KVM_DEBUG_GUEST           __KVM_DEPRECATED_VCPU_W_0x87  #define KVM_GET_MSRS              _IOWR(KVMIO, 0x88, struct kvm_msrs)  #define KVM_SET_MSRS              _IOW(KVMIO,  0x89, struct kvm_msrs)  #define KVM_SET_CPUID             _IOW(KVMIO,  0x8a, struct kvm_cpuid) @@ -1437,7 +1351,7 @@ struct kvm_s390_ucas_mapping {  #define KVM_GET_DEBUGREGS         _IOR(KVMIO,  0xa1, struct kvm_debugregs)  #define KVM_SET_DEBUGREGS         _IOW(KVMIO,  0xa2, struct kvm_debugregs)  /* - * vcpu version available with KVM_ENABLE_CAP + * vcpu version available with KVM_CAP_ENABLE_CAP   * vm version available with KVM_CAP_ENABLE_CAP_VM   */  #define KVM_ENABLE_CAP            _IOW(KVMIO,  0xa3, struct kvm_enable_cap) @@ -1493,7 +1407,7 @@ struct kvm_enc_region {  /* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT_2 */  #define KVM_CLEAR_DIRTY_LOG          _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log) -/* Available with KVM_CAP_HYPERV_CPUID */ +/* Available with KVM_CAP_HYPERV_CPUID (vcpu) / KVM_CAP_SYS_HYPERV_CPUID (system) */  #define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2)  /* Available with KVM_CAP_ARM_SVE */ @@ -1503,190 +1417,201 @@ struct kvm_enc_region {  #define KVM_S390_NORMAL_RESET	_IO(KVMIO,   0xc3)  #define KVM_S390_CLEAR_RESET	_IO(KVMIO,   0xc4) -struct kvm_s390_pv_sec_parm { -	__u64 origin; -	__u64 length; -}; - -struct kvm_s390_pv_unp { -	__u64 addr; -	__u64 size; -	__u64 tweak; -}; +/* Available with KVM_CAP_S390_PROTECTED */ +#define KVM_S390_PV_COMMAND		_IOWR(KVMIO, 0xc5, struct kvm_pv_cmd) -enum pv_cmd_id { -	KVM_PV_ENABLE, -	KVM_PV_DISABLE, -	KVM_PV_SET_SEC_PARMS, -	KVM_PV_UNPACK, -	KVM_PV_VERIFY, -	KVM_PV_PREP_RESET, -	KVM_PV_UNSHARE_ALL, -}; +/* Available with KVM_CAP_X86_MSR_FILTER */ +#define KVM_X86_SET_MSR_FILTER	_IOW(KVMIO,  0xc6, struct kvm_msr_filter) -struct kvm_pv_cmd { -	__u32 cmd;	/* Command to be executed */ -	__u16 rc;	/* Ultravisor return code */ -	__u16 rrc;	/* Ultravisor return reason code */ -	__u64 data;	/* Data or address */ -	__u32 flags;    /* flags for future extensions. Must be 0 for now */ -	__u32 reserved[3]; -}; +/* Available with KVM_CAP_DIRTY_LOG_RING */ +#define KVM_RESET_DIRTY_RINGS		_IO(KVMIO, 0xc7) -/* Available with KVM_CAP_S390_PROTECTED */ -#define KVM_S390_PV_COMMAND		_IOWR(KVMIO, 0xc5, struct kvm_pv_cmd) +/* Per-VM Xen attributes */ +#define KVM_XEN_HVM_GET_ATTR	_IOWR(KVMIO, 0xc8, struct kvm_xen_hvm_attr) +#define KVM_XEN_HVM_SET_ATTR	_IOW(KVMIO,  0xc9, struct kvm_xen_hvm_attr) -/* Secure Encrypted Virtualization command */ -enum sev_cmd_id { -	/* Guest initialization commands */ -	KVM_SEV_INIT = 0, -	KVM_SEV_ES_INIT, -	/* Guest launch commands */ -	KVM_SEV_LAUNCH_START, -	KVM_SEV_LAUNCH_UPDATE_DATA, -	KVM_SEV_LAUNCH_UPDATE_VMSA, -	KVM_SEV_LAUNCH_SECRET, -	KVM_SEV_LAUNCH_MEASURE, -	KVM_SEV_LAUNCH_FINISH, -	/* Guest migration commands (outgoing) */ -	KVM_SEV_SEND_START, -	KVM_SEV_SEND_UPDATE_DATA, -	KVM_SEV_SEND_UPDATE_VMSA, -	KVM_SEV_SEND_FINISH, -	/* Guest migration commands (incoming) */ -	KVM_SEV_RECEIVE_START, -	KVM_SEV_RECEIVE_UPDATE_DATA, -	KVM_SEV_RECEIVE_UPDATE_VMSA, -	KVM_SEV_RECEIVE_FINISH, -	/* Guest status and debug commands */ -	KVM_SEV_GUEST_STATUS, -	KVM_SEV_DBG_DECRYPT, -	KVM_SEV_DBG_ENCRYPT, -	/* Guest certificates commands */ -	KVM_SEV_CERT_EXPORT, - -	KVM_SEV_NR_MAX, -}; +/* Per-vCPU Xen attributes */ +#define KVM_XEN_VCPU_GET_ATTR	_IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr) +#define KVM_XEN_VCPU_SET_ATTR	_IOW(KVMIO,  0xcb, struct kvm_xen_vcpu_attr) -struct kvm_sev_cmd { -	__u32 id; -	__u64 data; -	__u32 error; -	__u32 sev_fd; -}; +/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ +#define KVM_XEN_HVM_EVTCHN_SEND	_IOW(KVMIO,  0xd0, struct kvm_irq_routing_xen_evtchn) -struct kvm_sev_launch_start { -	__u32 handle; -	__u32 policy; -	__u64 dh_uaddr; -	__u32 dh_len; -	__u64 session_uaddr; -	__u32 session_len; -}; +#define KVM_GET_SREGS2             _IOR(KVMIO,  0xcc, struct kvm_sregs2) +#define KVM_SET_SREGS2             _IOW(KVMIO,  0xcd, struct kvm_sregs2) -struct kvm_sev_launch_update_data { -	__u64 uaddr; -	__u32 len; -}; +#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE    (1 << 0) +#define KVM_DIRTY_LOG_INITIALLY_SET            (1 << 1) +/* + * Arch needs to define the macro after implementing the dirty ring + * feature.  KVM_DIRTY_LOG_PAGE_OFFSET should be defined as the + * starting page offset of the dirty ring structures. + */ +#ifndef KVM_DIRTY_LOG_PAGE_OFFSET +#define KVM_DIRTY_LOG_PAGE_OFFSET 0 +#endif -struct kvm_sev_launch_secret { -	__u64 hdr_uaddr; -	__u32 hdr_len; -	__u64 guest_uaddr; -	__u32 guest_len; -	__u64 trans_uaddr; -	__u32 trans_len; -}; +/* + * KVM dirty GFN flags, defined as: + * + * |---------------+---------------+--------------| + * | bit 1 (reset) | bit 0 (dirty) | Status       | + * |---------------+---------------+--------------| + * |             0 |             0 | Invalid GFN  | + * |             0 |             1 | Dirty GFN    | + * |             1 |             X | GFN to reset | + * |---------------+---------------+--------------| + * + * Lifecycle of a dirty GFN goes like: + * + *      dirtied         harvested        reset + * 00 -----------> 01 -------------> 1X -------+ + *  ^                                          | + *  |                                          | + *  +------------------------------------------+ + * + * The userspace program is only responsible for the 01->1X state + * conversion after harvesting an entry.  Also, it must not skip any + * dirty bits, so that dirty bits are always harvested in sequence. + */ +#define KVM_DIRTY_GFN_F_DIRTY           _BITUL(0) +#define KVM_DIRTY_GFN_F_RESET           _BITUL(1) +#define KVM_DIRTY_GFN_F_MASK            0x3 -struct kvm_sev_launch_measure { -	__u64 uaddr; -	__u32 len; +/* + * KVM dirty rings should be mapped at KVM_DIRTY_LOG_PAGE_OFFSET of + * per-vcpu mmaped regions as an array of struct kvm_dirty_gfn.  The + * size of the gfn buffer is decided by the first argument when + * enabling KVM_CAP_DIRTY_LOG_RING. + */ +struct kvm_dirty_gfn { +	__u32 flags; +	__u32 slot; +	__u64 offset;  }; -struct kvm_sev_guest_status { -	__u32 handle; -	__u32 policy; -	__u32 state; -}; +#define KVM_BUS_LOCK_DETECTION_OFF             (1 << 0) +#define KVM_BUS_LOCK_DETECTION_EXIT            (1 << 1) -struct kvm_sev_dbg { -	__u64 src_uaddr; -	__u64 dst_uaddr; -	__u32 len; -}; +#define KVM_PMU_CAP_DISABLE                    (1 << 0) -#define KVM_DEV_ASSIGN_ENABLE_IOMMU	(1 << 0) -#define KVM_DEV_ASSIGN_PCI_2_3		(1 << 1) -#define KVM_DEV_ASSIGN_MASK_INTX	(1 << 2) +/** + * struct kvm_stats_header - Header of per vm/vcpu binary statistics data. + * @flags: Some extra information for header, always 0 for now. + * @name_size: The size in bytes of the memory which contains statistics + *             name string including trailing '\0'. The memory is allocated + *             at the send of statistics descriptor. + * @num_desc: The number of statistics the vm or vcpu has. + * @id_offset: The offset of the vm/vcpu stats' id string in the file pointed + *             by vm/vcpu stats fd. + * @desc_offset: The offset of the vm/vcpu stats' descriptor block in the file + *               pointd by vm/vcpu stats fd. + * @data_offset: The offset of the vm/vcpu stats' data block in the file + *               pointed by vm/vcpu stats fd. + * + * This is the header userspace needs to read from stats fd before any other + * readings. It is used by userspace to discover all the information about the + * vm/vcpu's binary statistics. + * Userspace reads this header from the start of the vm/vcpu's stats fd. + */ +struct kvm_stats_header { +	__u32 flags; +	__u32 name_size; +	__u32 num_desc; +	__u32 id_offset; +	__u32 desc_offset; +	__u32 data_offset; +}; + +#define KVM_STATS_TYPE_SHIFT		0 +#define KVM_STATS_TYPE_MASK		(0xF << KVM_STATS_TYPE_SHIFT) +#define KVM_STATS_TYPE_CUMULATIVE	(0x0 << KVM_STATS_TYPE_SHIFT) +#define KVM_STATS_TYPE_INSTANT		(0x1 << KVM_STATS_TYPE_SHIFT) +#define KVM_STATS_TYPE_PEAK		(0x2 << KVM_STATS_TYPE_SHIFT) +#define KVM_STATS_TYPE_LINEAR_HIST	(0x3 << KVM_STATS_TYPE_SHIFT) +#define KVM_STATS_TYPE_LOG_HIST		(0x4 << KVM_STATS_TYPE_SHIFT) +#define KVM_STATS_TYPE_MAX		KVM_STATS_TYPE_LOG_HIST + +#define KVM_STATS_UNIT_SHIFT		4 +#define KVM_STATS_UNIT_MASK		(0xF << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_NONE		(0x0 << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_BYTES		(0x1 << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_SECONDS		(0x2 << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_CYCLES		(0x3 << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_BOOLEAN		(0x4 << KVM_STATS_UNIT_SHIFT) +#define KVM_STATS_UNIT_MAX		KVM_STATS_UNIT_BOOLEAN + +#define KVM_STATS_BASE_SHIFT		8 +#define KVM_STATS_BASE_MASK		(0xF << KVM_STATS_BASE_SHIFT) +#define KVM_STATS_BASE_POW10		(0x0 << KVM_STATS_BASE_SHIFT) +#define KVM_STATS_BASE_POW2		(0x1 << KVM_STATS_BASE_SHIFT) +#define KVM_STATS_BASE_MAX		KVM_STATS_BASE_POW2 -struct kvm_assigned_pci_dev { -	__u32 assigned_dev_id; -	__u32 busnr; -	__u32 devfn; +/** + * struct kvm_stats_desc - Descriptor of a KVM statistics. + * @flags: Annotations of the stats, like type, unit, etc. + * @exponent: Used together with @flags to determine the unit. + * @size: The number of data items for this stats. + *        Every data item is of type __u64. + * @offset: The offset of the stats to the start of stat structure in + *          structure kvm or kvm_vcpu. + * @bucket_size: A parameter value used for histogram stats. It is only used + *		for linear histogram stats, specifying the size of the bucket; + * @name: The name string for the stats. Its size is indicated by the + *        &kvm_stats_header->name_size. + */ +struct kvm_stats_desc {  	__u32 flags; -	__u32 segnr; -	union { -		__u32 reserved[11]; -	}; +	__s16 exponent; +	__u16 size; +	__u32 offset; +	__u32 bucket_size; +	char name[];  }; -#define KVM_DEV_IRQ_HOST_INTX    (1 << 0) -#define KVM_DEV_IRQ_HOST_MSI     (1 << 1) -#define KVM_DEV_IRQ_HOST_MSIX    (1 << 2) +#define KVM_GET_STATS_FD  _IO(KVMIO,  0xce) -#define KVM_DEV_IRQ_GUEST_INTX   (1 << 8) -#define KVM_DEV_IRQ_GUEST_MSI    (1 << 9) -#define KVM_DEV_IRQ_GUEST_MSIX   (1 << 10) +/* Available with KVM_CAP_XSAVE2 */ +#define KVM_GET_XSAVE2		  _IOR(KVMIO,  0xcf, struct kvm_xsave) -#define KVM_DEV_IRQ_HOST_MASK	 0x00ff -#define KVM_DEV_IRQ_GUEST_MASK   0xff00 +/* Available with KVM_CAP_S390_PROTECTED_DUMP */ +#define KVM_S390_PV_CPU_COMMAND	_IOWR(KVMIO, 0xd0, struct kvm_pv_cmd) -struct kvm_assigned_irq { -	__u32 assigned_dev_id; -	__u32 host_irq; /* ignored (legacy field) */ -	__u32 guest_irq; -	__u32 flags; -	union { -		__u32 reserved[12]; -	}; -}; +/* Available with KVM_CAP_X86_NOTIFY_VMEXIT */ +#define KVM_X86_NOTIFY_VMEXIT_ENABLED		(1ULL << 0) +#define KVM_X86_NOTIFY_VMEXIT_USER		(1ULL << 1) -struct kvm_assigned_msix_nr { -	__u32 assigned_dev_id; -	__u16 entry_nr; -	__u16 padding; -}; +/* Available with KVM_CAP_S390_ZPCI_OP */ +#define KVM_S390_ZPCI_OP         _IOW(KVMIO,  0xd1, struct kvm_s390_zpci_op) -#define KVM_MAX_MSIX_PER_DEV		256 -struct kvm_assigned_msix_entry { -	__u32 assigned_dev_id; -	__u32 gsi; -	__u16 entry; /* The index of entry in the MSI-X table */ -	__u16 padding[3]; -}; +/* Available with KVM_CAP_MEMORY_ATTRIBUTES */ +#define KVM_SET_MEMORY_ATTRIBUTES              _IOW(KVMIO,  0xd2, struct kvm_memory_attributes) -#define KVM_X2APIC_API_USE_32BIT_IDS            (1ULL << 0) -#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK  (1ULL << 1) +struct kvm_memory_attributes { +	__u64 address; +	__u64 size; +	__u64 attributes; +	__u64 flags; +}; -/* Available with KVM_CAP_ARM_USER_IRQ */ +#define KVM_MEMORY_ATTRIBUTE_PRIVATE           (1ULL << 3) -/* Bits for run->s.regs.device_irq_level */ -#define KVM_ARM_DEV_EL1_VTIMER		(1 << 0) -#define KVM_ARM_DEV_EL1_PTIMER		(1 << 1) -#define KVM_ARM_DEV_PMU			(1 << 2) +#define KVM_CREATE_GUEST_MEMFD	_IOWR(KVMIO,  0xd4, struct kvm_create_guest_memfd) -struct kvm_hyperv_eventfd { -	__u32 conn_id; -	__s32 fd; -	__u32 flags; -	__u32 padding[3]; +struct kvm_create_guest_memfd { +	__u64 size; +	__u64 flags; +	__u64 reserved[6];  }; -#define KVM_HYPERV_CONN_ID_MASK		0x00ffffff -#define KVM_HYPERV_EVENTFD_DEASSIGN	(1 << 0) +#define KVM_PRE_FAULT_MEMORY	_IOWR(KVMIO, 0xd5, struct kvm_pre_fault_memory) -#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE    (1 << 0) -#define KVM_DIRTY_LOG_INITIALLY_SET            (1 << 1) +struct kvm_pre_fault_memory { +	__u64 gpa; +	__u64 size; +	__u64 flags; +	__u64 padding[5]; +};  #endif /* __LINUX_KVM_H */ diff --git a/include/uapi/linux/kvm_para.h b/include/uapi/linux/kvm_para.h index 8b86609849b9..960c7e93d1a9 100644 --- a/include/uapi/linux/kvm_para.h +++ b/include/uapi/linux/kvm_para.h @@ -29,6 +29,7 @@  #define KVM_HC_CLOCK_PAIRING		9  #define KVM_HC_SEND_IPI		10  #define KVM_HC_SCHED_YIELD		11 +#define KVM_HC_MAP_GPA_RANGE		12  /*   * hypercalls use architecture specific diff --git a/include/uapi/linux/l2tp.h b/include/uapi/linux/l2tp.h index 61158f5a1a5b..7d81c3e1ec29 100644 --- a/include/uapi/linux/l2tp.h +++ b/include/uapi/linux/l2tp.h @@ -13,8 +13,6 @@  #include <linux/in.h>  #include <linux/in6.h> -#define IPPROTO_L2TP		115 -  /**   * struct sockaddr_l2tpip - the sockaddr structure for L2TP-over-IP sockets   * @l2tp_family:  address family number AF_L2TPIP. @@ -108,7 +106,7 @@ enum {  	L2TP_ATTR_VLAN_ID,		/* u16 (not used) */  	L2TP_ATTR_COOKIE,		/* 0, 4 or 8 bytes */  	L2TP_ATTR_PEER_COOKIE,		/* 0, 4 or 8 bytes */ -	L2TP_ATTR_DEBUG,		/* u32, enum l2tp_debug_flags */ +	L2TP_ATTR_DEBUG,		/* u32, enum l2tp_debug_flags (not used) */  	L2TP_ATTR_RECV_SEQ,		/* u8 */  	L2TP_ATTR_SEND_SEQ,		/* u8 */  	L2TP_ATTR_LNS_MODE,		/* u8 */ @@ -144,6 +142,8 @@ enum {  	L2TP_ATTR_RX_OOS_PACKETS,	/* u64 */  	L2TP_ATTR_RX_ERRORS,		/* u64 */  	L2TP_ATTR_STATS_PAD, +	L2TP_ATTR_RX_COOKIE_DISCARDS,	/* u64 */ +	L2TP_ATTR_RX_INVALID,		/* u64 */  	__L2TP_ATTR_STATS_MAX,  }; @@ -177,7 +177,9 @@ enum l2tp_seqmode {  };  /** - * enum l2tp_debug_flags - debug message categories for L2TP tunnels/sessions + * enum l2tp_debug_flags - debug message categories for L2TP tunnels/sessions. + * + * Unused.   *   * @L2TP_MSG_DEBUG: verbose debug (if compiled in)   * @L2TP_MSG_CONTROL: userspace - kernel interface diff --git a/include/uapi/linux/landlock.h b/include/uapi/linux/landlock.h new file mode 100644 index 000000000000..f030adc462ee --- /dev/null +++ b/include/uapi/linux/landlock.h @@ -0,0 +1,373 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Landlock - User space API + * + * Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net> + * Copyright © 2018-2020 ANSSI + * Copyright © 2021-2025 Microsoft Corporation + */ + +#ifndef _UAPI_LINUX_LANDLOCK_H +#define _UAPI_LINUX_LANDLOCK_H + +#include <linux/types.h> + +/** + * struct landlock_ruleset_attr - Ruleset definition. + * + * Argument of sys_landlock_create_ruleset(). + * + * This structure defines a set of *handled access rights*, a set of actions on + * different object types, which should be denied by default when the ruleset is + * enacted.  Vice versa, access rights that are not specifically listed here are + * not going to be denied by this ruleset when it is enacted. + * + * For historical reasons, the %LANDLOCK_ACCESS_FS_REFER right is always denied + * by default, even when its bit is not set in @handled_access_fs.  In order to + * add new rules with this access right, the bit must still be set explicitly + * (cf. `Filesystem flags`_). + * + * The explicit listing of *handled access rights* is required for backwards + * compatibility reasons.  In most use cases, processes that use Landlock will + * *handle* a wide range or all access rights that they know about at build time + * (and that they have tested with a kernel that supported them all). + * + * This structure can grow in future Landlock versions. + */ +struct landlock_ruleset_attr { +	/** +	 * @handled_access_fs: Bitmask of handled filesystem actions +	 * (cf. `Filesystem flags`_). +	 */ +	__u64 handled_access_fs; +	/** +	 * @handled_access_net: Bitmask of handled network actions (cf. `Network +	 * flags`_). +	 */ +	__u64 handled_access_net; +	/** +	 * @scoped: Bitmask of scopes (cf. `Scope flags`_) +	 * restricting a Landlock domain from accessing outside +	 * resources (e.g. IPCs). +	 */ +	__u64 scoped; +}; + +/** + * DOC: landlock_create_ruleset_flags + * + * **Flags** + * + * %LANDLOCK_CREATE_RULESET_VERSION + *     Get the highest supported Landlock ABI version (starting at 1). + * + * %LANDLOCK_CREATE_RULESET_ERRATA + *     Get a bitmask of fixed issues for the current Landlock ABI version. + */ +/* clang-format off */ +#define LANDLOCK_CREATE_RULESET_VERSION			(1U << 0) +#define LANDLOCK_CREATE_RULESET_ERRATA			(1U << 1) +/* clang-format on */ + +/** + * DOC: landlock_restrict_self_flags + * + * **Flags** + * + * By default, denied accesses originating from programs that sandbox themselves + * are logged via the audit subsystem. Such events typically indicate unexpected + * behavior, such as bugs or exploitation attempts. However, to avoid excessive + * logging, access requests denied by a domain not created by the originating + * program are not logged by default. The rationale is that programs should know + * their own behavior, but not necessarily the behavior of other programs.  This + * default configuration is suitable for most programs that sandbox themselves. + * For specific use cases, the following flags allow programs to modify this + * default logging behavior. + * + * The %LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF and + * %LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON flags apply to the newly created + * Landlock domain. + * + * %LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF + *     Disables logging of denied accesses originating from the thread creating + *     the Landlock domain, as well as its children, as long as they continue + *     running the same executable code (i.e., without an intervening + *     :manpage:`execve(2)` call). This is intended for programs that execute + *     unknown code without invoking :manpage:`execve(2)`, such as script + *     interpreters. Programs that only sandbox themselves should not set this + *     flag, so users can be notified of unauthorized access attempts via system + *     logs. + * + * %LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON + *     Enables logging of denied accesses after an :manpage:`execve(2)` call, + *     providing visibility into unauthorized access attempts by newly executed + *     programs within the created Landlock domain. This flag is recommended + *     only when all potential executables in the domain are expected to comply + *     with the access restrictions, as excessive audit log entries could make + *     it more difficult to identify critical events. + * + * %LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF + *     Disables logging of denied accesses originating from nested Landlock + *     domains created by the caller or its descendants. This flag should be set + *     according to runtime configuration, not hardcoded, to avoid suppressing + *     important security events. It is useful for container runtimes or + *     sandboxing tools that may launch programs which themselves create + *     Landlock domains and could otherwise generate excessive logs. Unlike + *     ``LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF``, this flag only affects + *     future nested domains, not the one being created. It can also be used + *     with a @ruleset_fd value of -1 to mute subdomain logs without creating a + *     domain. + */ +/* clang-format off */ +#define LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF		(1U << 0) +#define LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON			(1U << 1) +#define LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF		(1U << 2) +/* clang-format on */ + +/** + * enum landlock_rule_type - Landlock rule type + * + * Argument of sys_landlock_add_rule(). + */ +enum landlock_rule_type { +	/** +	 * @LANDLOCK_RULE_PATH_BENEATH: Type of a &struct +	 * landlock_path_beneath_attr . +	 */ +	LANDLOCK_RULE_PATH_BENEATH = 1, +	/** +	 * @LANDLOCK_RULE_NET_PORT: Type of a &struct +	 * landlock_net_port_attr . +	 */ +	LANDLOCK_RULE_NET_PORT, +}; + +/** + * struct landlock_path_beneath_attr - Path hierarchy definition + * + * Argument of sys_landlock_add_rule(). + */ +struct landlock_path_beneath_attr { +	/** +	 * @allowed_access: Bitmask of allowed actions for this file hierarchy +	 * (cf. `Filesystem flags`_). +	 */ +	__u64 allowed_access; +	/** +	 * @parent_fd: File descriptor, preferably opened with ``O_PATH``, +	 * which identifies the parent directory of a file hierarchy, or just a +	 * file. +	 */ +	__s32 parent_fd; +	/* +	 * This struct is packed to avoid trailing reserved members. +	 * Cf. security/landlock/syscalls.c:build_check_abi() +	 */ +} __attribute__((packed)); + +/** + * struct landlock_net_port_attr - Network port definition + * + * Argument of sys_landlock_add_rule(). + */ +struct landlock_net_port_attr { +	/** +	 * @allowed_access: Bitmask of allowed network actions for a port +	 * (cf. `Network flags`_). +	 */ +	__u64 allowed_access; +	/** +	 * @port: Network port in host endianness. +	 * +	 * It should be noted that port 0 passed to :manpage:`bind(2)` will bind +	 * to an available port from the ephemeral port range.  This can be +	 * configured with the ``/proc/sys/net/ipv4/ip_local_port_range`` sysctl +	 * (also used for IPv6). +	 * +	 * A Landlock rule with port 0 and the ``LANDLOCK_ACCESS_NET_BIND_TCP`` +	 * right means that requesting to bind on port 0 is allowed and it will +	 * automatically translate to binding on the related port range. +	 */ +	__u64 port; +}; + +/** + * DOC: fs_access + * + * A set of actions on kernel objects may be defined by an attribute (e.g. + * &struct landlock_path_beneath_attr) including a bitmask of access. + * + * Filesystem flags + * ~~~~~~~~~~~~~~~~ + * + * These flags enable to restrict a sandboxed process to a set of actions on + * files and directories.  Files or directories opened before the sandboxing + * are not subject to these restrictions. + * + * The following access rights apply only to files: + * + * - %LANDLOCK_ACCESS_FS_EXECUTE: Execute a file. + * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a file with write access.  When + *   opening files for writing, you will often additionally need the + *   %LANDLOCK_ACCESS_FS_TRUNCATE right.  In many cases, these system calls + *   truncate existing files when overwriting them (e.g., :manpage:`creat(2)`). + * - %LANDLOCK_ACCESS_FS_READ_FILE: Open a file with read access. + * - %LANDLOCK_ACCESS_FS_TRUNCATE: Truncate a file with :manpage:`truncate(2)`, + *   :manpage:`ftruncate(2)`, :manpage:`creat(2)`, or :manpage:`open(2)` with + *   ``O_TRUNC``.  This access right is available since the third version of the + *   Landlock ABI. + * + * Whether an opened file can be truncated with :manpage:`ftruncate(2)` or used + * with `ioctl(2)` is determined during :manpage:`open(2)`, in the same way as + * read and write permissions are checked during :manpage:`open(2)` using + * %LANDLOCK_ACCESS_FS_READ_FILE and %LANDLOCK_ACCESS_FS_WRITE_FILE. + * + * A directory can receive access rights related to files or directories.  The + * following access right is applied to the directory itself, and the + * directories beneath it: + * + * - %LANDLOCK_ACCESS_FS_READ_DIR: Open a directory or list its content. + * + * However, the following access rights only apply to the content of a + * directory, not the directory itself: + * + * - %LANDLOCK_ACCESS_FS_REMOVE_DIR: Remove an empty directory or rename one. + * - %LANDLOCK_ACCESS_FS_REMOVE_FILE: Unlink (or rename) a file. + * - %LANDLOCK_ACCESS_FS_MAKE_CHAR: Create (or rename or link) a character + *   device. + * - %LANDLOCK_ACCESS_FS_MAKE_DIR: Create (or rename) a directory. + * - %LANDLOCK_ACCESS_FS_MAKE_REG: Create (or rename or link) a regular file. + * - %LANDLOCK_ACCESS_FS_MAKE_SOCK: Create (or rename or link) a UNIX domain + *   socket. + * - %LANDLOCK_ACCESS_FS_MAKE_FIFO: Create (or rename or link) a named pipe. + * - %LANDLOCK_ACCESS_FS_MAKE_BLOCK: Create (or rename or link) a block device. + * - %LANDLOCK_ACCESS_FS_MAKE_SYM: Create (or rename or link) a symbolic link. + * - %LANDLOCK_ACCESS_FS_REFER: Link or rename a file from or to a different + *   directory (i.e. reparent a file hierarchy). + * + *   This access right is available since the second version of the Landlock + *   ABI. + * + *   This is the only access right which is denied by default by any ruleset, + *   even if the right is not specified as handled at ruleset creation time. + *   The only way to make a ruleset grant this right is to explicitly allow it + *   for a specific directory by adding a matching rule to the ruleset. + * + *   In particular, when using the first Landlock ABI version, Landlock will + *   always deny attempts to reparent files between different directories. + * + *   In addition to the source and destination directories having the + *   %LANDLOCK_ACCESS_FS_REFER access right, the attempted link or rename + *   operation must meet the following constraints: + * + *   * The reparented file may not gain more access rights in the destination + *     directory than it previously had in the source directory.  If this is + *     attempted, the operation results in an ``EXDEV`` error. + * + *   * When linking or renaming, the ``LANDLOCK_ACCESS_FS_MAKE_*`` right for the + *     respective file type must be granted for the destination directory. + *     Otherwise, the operation results in an ``EACCES`` error. + * + *   * When renaming, the ``LANDLOCK_ACCESS_FS_REMOVE_*`` right for the + *     respective file type must be granted for the source directory.  Otherwise, + *     the operation results in an ``EACCES`` error. + * + *   If multiple requirements are not met, the ``EACCES`` error code takes + *   precedence over ``EXDEV``. + * + * The following access right applies both to files and directories: + * + * - %LANDLOCK_ACCESS_FS_IOCTL_DEV: Invoke :manpage:`ioctl(2)` commands on an opened + *   character or block device. + * + *   This access right applies to all `ioctl(2)` commands implemented by device + *   drivers.  However, the following common IOCTL commands continue to be + *   invokable independent of the %LANDLOCK_ACCESS_FS_IOCTL_DEV right: + * + *   * IOCTL commands targeting file descriptors (``FIOCLEX``, ``FIONCLEX``), + *   * IOCTL commands targeting file descriptions (``FIONBIO``, ``FIOASYNC``), + *   * IOCTL commands targeting file systems (``FIFREEZE``, ``FITHAW``, + *     ``FIGETBSZ``, ``FS_IOC_GETFSUUID``, ``FS_IOC_GETFSSYSFSPATH``) + *   * Some IOCTL commands which do not make sense when used with devices, but + *     whose implementations are safe and return the right error codes + *     (``FS_IOC_FIEMAP``, ``FICLONE``, ``FICLONERANGE``, ``FIDEDUPERANGE``) + * + *   This access right is available since the fifth version of the Landlock + *   ABI. + * + * .. warning:: + * + *   It is currently not possible to restrict some file-related actions + *   accessible through these syscall families: :manpage:`chdir(2)`, + *   :manpage:`stat(2)`, :manpage:`flock(2)`, :manpage:`chmod(2)`, + *   :manpage:`chown(2)`, :manpage:`setxattr(2)`, :manpage:`utime(2)`, + *   :manpage:`fcntl(2)`, :manpage:`access(2)`. + *   Future Landlock evolutions will enable to restrict them. + */ +/* clang-format off */ +#define LANDLOCK_ACCESS_FS_EXECUTE			(1ULL << 0) +#define LANDLOCK_ACCESS_FS_WRITE_FILE			(1ULL << 1) +#define LANDLOCK_ACCESS_FS_READ_FILE			(1ULL << 2) +#define LANDLOCK_ACCESS_FS_READ_DIR			(1ULL << 3) +#define LANDLOCK_ACCESS_FS_REMOVE_DIR			(1ULL << 4) +#define LANDLOCK_ACCESS_FS_REMOVE_FILE			(1ULL << 5) +#define LANDLOCK_ACCESS_FS_MAKE_CHAR			(1ULL << 6) +#define LANDLOCK_ACCESS_FS_MAKE_DIR			(1ULL << 7) +#define LANDLOCK_ACCESS_FS_MAKE_REG			(1ULL << 8) +#define LANDLOCK_ACCESS_FS_MAKE_SOCK			(1ULL << 9) +#define LANDLOCK_ACCESS_FS_MAKE_FIFO			(1ULL << 10) +#define LANDLOCK_ACCESS_FS_MAKE_BLOCK			(1ULL << 11) +#define LANDLOCK_ACCESS_FS_MAKE_SYM			(1ULL << 12) +#define LANDLOCK_ACCESS_FS_REFER			(1ULL << 13) +#define LANDLOCK_ACCESS_FS_TRUNCATE			(1ULL << 14) +#define LANDLOCK_ACCESS_FS_IOCTL_DEV			(1ULL << 15) +/* clang-format on */ + +/** + * DOC: net_access + * + * Network flags + * ~~~~~~~~~~~~~~~~ + * + * These flags enable to restrict a sandboxed process to a set of network + * actions. + * + * This is supported since Landlock ABI version 4. + * + * The following access rights apply to TCP port numbers: + * + * - %LANDLOCK_ACCESS_NET_BIND_TCP: Bind a TCP socket to a local port. + * - %LANDLOCK_ACCESS_NET_CONNECT_TCP: Connect an active TCP socket to + *   a remote port. + */ +/* clang-format off */ +#define LANDLOCK_ACCESS_NET_BIND_TCP			(1ULL << 0) +#define LANDLOCK_ACCESS_NET_CONNECT_TCP			(1ULL << 1) +/* clang-format on */ + +/** + * DOC: scope + * + * Scope flags + * ~~~~~~~~~~~ + * + * These flags enable to isolate a sandboxed process from a set of IPC actions. + * Setting a flag for a ruleset will isolate the Landlock domain to forbid + * connections to resources outside the domain. + * + * This is supported since Landlock ABI version 6. + * + * Scopes: + * + * - %LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET: Restrict a sandboxed process from + *   connecting to an abstract UNIX socket created by a process outside the + *   related Landlock domain (e.g., a parent domain or a non-sandboxed process). + * - %LANDLOCK_SCOPE_SIGNAL: Restrict a sandboxed process from sending a signal + *   to another process outside the domain. + */ +/* clang-format off */ +#define LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET		(1ULL << 0) +#define LANDLOCK_SCOPE_SIGNAL		                (1ULL << 1) +/* clang-format on*/ + +#endif /* _UAPI_LINUX_LANDLOCK_H */ diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h index 8254c937c9f4..0eca95ccb41e 100644 --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h @@ -140,25 +140,6 @@  #endif /* _NETINET_IN_H */ -/* Coordinate with glibc netipx/ipx.h header. */ -#if defined(__NETIPX_IPX_H) - -#define __UAPI_DEF_SOCKADDR_IPX			0 -#define __UAPI_DEF_IPX_ROUTE_DEFINITION		0 -#define __UAPI_DEF_IPX_INTERFACE_DEFINITION	0 -#define __UAPI_DEF_IPX_CONFIG_DATA		0 -#define __UAPI_DEF_IPX_ROUTE_DEF		0 - -#else /* defined(__NETIPX_IPX_H) */ - -#define __UAPI_DEF_SOCKADDR_IPX			1 -#define __UAPI_DEF_IPX_ROUTE_DEFINITION		1 -#define __UAPI_DEF_IPX_INTERFACE_DEFINITION	1 -#define __UAPI_DEF_IPX_CONFIG_DATA		1 -#define __UAPI_DEF_IPX_ROUTE_DEF		1 - -#endif /* defined(__NETIPX_IPX_H) */ -  /* Definitions for xattr.h */  #if defined(_SYS_XATTR_H)  #define __UAPI_DEF_XATTR		0 @@ -240,23 +221,6 @@  #define __UAPI_DEF_IP6_MTUINFO		1  #endif -/* Definitions for ipx.h */ -#ifndef __UAPI_DEF_SOCKADDR_IPX -#define __UAPI_DEF_SOCKADDR_IPX			1 -#endif -#ifndef __UAPI_DEF_IPX_ROUTE_DEFINITION -#define __UAPI_DEF_IPX_ROUTE_DEFINITION		1 -#endif -#ifndef __UAPI_DEF_IPX_INTERFACE_DEFINITION -#define __UAPI_DEF_IPX_INTERFACE_DEFINITION	1 -#endif -#ifndef __UAPI_DEF_IPX_CONFIG_DATA -#define __UAPI_DEF_IPX_CONFIG_DATA		1 -#endif -#ifndef __UAPI_DEF_IPX_ROUTE_DEF -#define __UAPI_DEF_IPX_ROUTE_DEF		1 -#endif -  /* Definitions for xattr.h */  #ifndef __UAPI_DEF_XATTR  #define __UAPI_DEF_XATTR		1 diff --git a/include/uapi/linux/lightnvm.h b/include/uapi/linux/lightnvm.h deleted file mode 100644 index f9a1be7fc696..000000000000 --- a/include/uapi/linux/lightnvm.h +++ /dev/null @@ -1,225 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * Copyright (C) 2015 CNEX Labs.  All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING.  If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, - * USA. - */ - -#ifndef _UAPI_LINUX_LIGHTNVM_H -#define _UAPI_LINUX_LIGHTNVM_H - -#ifdef __KERNEL__ -#include <linux/kernel.h> -#include <linux/ioctl.h> -#else /* __KERNEL__ */ -#include <stdio.h> -#include <sys/ioctl.h> -#define DISK_NAME_LEN 32 -#endif /* __KERNEL__ */ - -#include <linux/types.h> -#include <linux/ioctl.h> - -#define NVM_TTYPE_NAME_MAX 48 -#define NVM_TTYPE_MAX 63 -#define NVM_MMTYPE_LEN 8 - -#define NVM_CTRL_FILE "/dev/lightnvm/control" - -struct nvm_ioctl_info_tgt { -	__u32 version[3]; -	__u32 reserved; -	char tgtname[NVM_TTYPE_NAME_MAX]; -}; - -struct nvm_ioctl_info { -	__u32 version[3];	/* in/out - major, minor, patch */ -	__u16 tgtsize;		/* number of targets */ -	__u16 reserved16;	/* pad to 4K page */ -	__u32 reserved[12]; -	struct nvm_ioctl_info_tgt tgts[NVM_TTYPE_MAX]; -}; - -enum { -	NVM_DEVICE_ACTIVE = 1 << 0, -}; - -struct nvm_ioctl_device_info { -	char devname[DISK_NAME_LEN]; -	char bmname[NVM_TTYPE_NAME_MAX]; -	__u32 bmversion[3]; -	__u32 flags; -	__u32 reserved[8]; -}; - -struct nvm_ioctl_get_devices { -	__u32 nr_devices; -	__u32 reserved[31]; -	struct nvm_ioctl_device_info info[31]; -}; - -struct nvm_ioctl_create_simple { -	__u32 lun_begin; -	__u32 lun_end; -}; - -struct nvm_ioctl_create_extended { -	__u16 lun_begin; -	__u16 lun_end; -	__u16 op; -	__u16 rsv; -}; - -enum { -	NVM_CONFIG_TYPE_SIMPLE = 0, -	NVM_CONFIG_TYPE_EXTENDED = 1, -}; - -struct nvm_ioctl_create_conf { -	__u32 type; -	union { -		struct nvm_ioctl_create_simple s; -		struct nvm_ioctl_create_extended e; -	}; -}; - -enum { -	NVM_TARGET_FACTORY = 1 << 0,	/* Init target in factory mode */ -}; - -struct nvm_ioctl_create { -	char dev[DISK_NAME_LEN];		/* open-channel SSD device */ -	char tgttype[NVM_TTYPE_NAME_MAX];	/* target type name */ -	char tgtname[DISK_NAME_LEN];		/* dev to expose target as */ - -	__u32 flags; - -	struct nvm_ioctl_create_conf conf; -}; - -struct nvm_ioctl_remove { -	char tgtname[DISK_NAME_LEN]; - -	__u32 flags; -}; - -struct nvm_ioctl_dev_init { -	char dev[DISK_NAME_LEN];		/* open-channel SSD device */ -	char mmtype[NVM_MMTYPE_LEN];		/* register to media manager */ - -	__u32 flags; -}; - -enum { -	NVM_FACTORY_ERASE_ONLY_USER	= 1 << 0, /* erase only blocks used as -						   * host blks or grown blks */ -	NVM_FACTORY_RESET_HOST_BLKS	= 1 << 1, /* remove host blk marks */ -	NVM_FACTORY_RESET_GRWN_BBLKS	= 1 << 2, /* remove grown blk marks */ -	NVM_FACTORY_NR_BITS		= 1 << 3, /* stops here */ -}; - -struct nvm_ioctl_dev_factory { -	char dev[DISK_NAME_LEN]; - -	__u32 flags; -}; - -struct nvm_user_vio { -	__u8 opcode; -	__u8 flags; -	__u16 control; -	__u16 nppas; -	__u16 rsvd; -	__u64 metadata; -	__u64 addr; -	__u64 ppa_list; -	__u32 metadata_len; -	__u32 data_len; -	__u64 status; -	__u32 result; -	__u32 rsvd3[3]; -}; - -struct nvm_passthru_vio { -	__u8 opcode; -	__u8 flags; -	__u8 rsvd[2]; -	__u32 nsid; -	__u32 cdw2; -	__u32 cdw3; -	__u64 metadata; -	__u64 addr; -	__u32 metadata_len; -	__u32 data_len; -	__u64 ppa_list; -	__u16 nppas; -	__u16 control; -	__u32 cdw13; -	__u32 cdw14; -	__u32 cdw15; -	__u64 status; -	__u32 result; -	__u32 timeout_ms; -}; - -/* The ioctl type, 'L', 0x20 - 0x2F documented in ioctl-number.txt */ -enum { -	/* top level cmds */ -	NVM_INFO_CMD = 0x20, -	NVM_GET_DEVICES_CMD, - -	/* device level cmds */ -	NVM_DEV_CREATE_CMD, -	NVM_DEV_REMOVE_CMD, - -	/* Init a device to support LightNVM media managers */ -	NVM_DEV_INIT_CMD, - -	/* Factory reset device */ -	NVM_DEV_FACTORY_CMD, - -	/* Vector user I/O */ -	NVM_DEV_VIO_ADMIN_CMD = 0x41, -	NVM_DEV_VIO_CMD = 0x42, -	NVM_DEV_VIO_USER_CMD = 0x43, -}; - -#define NVM_IOCTL 'L' /* 0x4c */ - -#define NVM_INFO		_IOWR(NVM_IOCTL, NVM_INFO_CMD, \ -						struct nvm_ioctl_info) -#define NVM_GET_DEVICES		_IOR(NVM_IOCTL, NVM_GET_DEVICES_CMD, \ -						struct nvm_ioctl_get_devices) -#define NVM_DEV_CREATE		_IOW(NVM_IOCTL, NVM_DEV_CREATE_CMD, \ -						struct nvm_ioctl_create) -#define NVM_DEV_REMOVE		_IOW(NVM_IOCTL, NVM_DEV_REMOVE_CMD, \ -						struct nvm_ioctl_remove) -#define NVM_DEV_INIT		_IOW(NVM_IOCTL, NVM_DEV_INIT_CMD, \ -						struct nvm_ioctl_dev_init) -#define NVM_DEV_FACTORY		_IOW(NVM_IOCTL, NVM_DEV_FACTORY_CMD, \ -						struct nvm_ioctl_dev_factory) - -#define NVME_NVM_IOCTL_IO_VIO		_IOWR(NVM_IOCTL, NVM_DEV_VIO_USER_CMD, \ -						struct nvm_passthru_vio) -#define NVME_NVM_IOCTL_ADMIN_VIO	_IOWR(NVM_IOCTL, NVM_DEV_VIO_ADMIN_CMD,\ -						struct nvm_passthru_vio) -#define NVME_NVM_IOCTL_SUBMIT_VIO	_IOWR(NVM_IOCTL, NVM_DEV_VIO_CMD,\ -						struct nvm_user_vio) - -#define NVM_VERSION_MAJOR	1 -#define NVM_VERSION_MINOR	0 -#define NVM_VERSION_PATCHLEVEL	0 - -#endif diff --git a/include/uapi/linux/lirc.h b/include/uapi/linux/lirc.h index f99d9dcae667..8d7ca7c6af42 100644 --- a/include/uapi/linux/lirc.h +++ b/include/uapi/linux/lirc.h @@ -1,7 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */  /*   * lirc.h - linux infrared remote control header file - * last modified 2010/07/13 by Jarod Wilson   */  #ifndef _LINUX_LIRC_H @@ -17,14 +16,16 @@  #define LIRC_MODE2_PULSE     0x01000000  #define LIRC_MODE2_FREQUENCY 0x02000000  #define LIRC_MODE2_TIMEOUT   0x03000000 +#define LIRC_MODE2_OVERFLOW  0x04000000  #define LIRC_VALUE_MASK      0x00FFFFFF  #define LIRC_MODE2_MASK      0xFF000000 -#define LIRC_SPACE(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_SPACE) -#define LIRC_PULSE(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_PULSE) -#define LIRC_FREQUENCY(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_FREQUENCY) -#define LIRC_TIMEOUT(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_TIMEOUT) +#define LIRC_SPACE(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_SPACE) +#define LIRC_PULSE(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_PULSE) +#define LIRC_FREQUENCY(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_FREQUENCY) +#define LIRC_TIMEOUT(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_TIMEOUT) +#define LIRC_OVERFLOW(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_OVERFLOW)  #define LIRC_VALUE(val) ((val)&LIRC_VALUE_MASK)  #define LIRC_MODE2(val) ((val)&LIRC_MODE2_MASK) @@ -33,6 +34,7 @@  #define LIRC_IS_PULSE(val) (LIRC_MODE2(val) == LIRC_MODE2_PULSE)  #define LIRC_IS_FREQUENCY(val) (LIRC_MODE2(val) == LIRC_MODE2_FREQUENCY)  #define LIRC_IS_TIMEOUT(val) (LIRC_MODE2(val) == LIRC_MODE2_TIMEOUT) +#define LIRC_IS_OVERFLOW(val) (LIRC_MODE2(val) == LIRC_MODE2_OVERFLOW)  /* used heavily by lirc userspace */  #define lirc_t int @@ -71,13 +73,10 @@  #define LIRC_CAN_REC_MASK              LIRC_MODE2REC(LIRC_CAN_SEND_MASK)  #define LIRC_CAN_SET_REC_CARRIER       (LIRC_CAN_SET_SEND_CARRIER << 16) -#define LIRC_CAN_SET_REC_DUTY_CYCLE    (LIRC_CAN_SET_SEND_DUTY_CYCLE << 16) -#define LIRC_CAN_SET_REC_DUTY_CYCLE_RANGE 0x40000000  #define LIRC_CAN_SET_REC_CARRIER_RANGE    0x80000000  #define LIRC_CAN_GET_REC_RESOLUTION       0x20000000  #define LIRC_CAN_SET_REC_TIMEOUT          0x10000000 -#define LIRC_CAN_SET_REC_FILTER           0x08000000  #define LIRC_CAN_MEASURE_CARRIER          0x02000000  #define LIRC_CAN_USE_WIDEBAND_RECEIVER    0x04000000 @@ -85,7 +84,12 @@  #define LIRC_CAN_SEND(x) ((x)&LIRC_CAN_SEND_MASK)  #define LIRC_CAN_REC(x) ((x)&LIRC_CAN_REC_MASK) -#define LIRC_CAN_NOTIFY_DECODE            0x01000000 +/* + * Unused features. These features were never implemented, in tree or + * out of tree. These definitions are here so not to break the lircd build. + */ +#define LIRC_CAN_SET_REC_FILTER		0 +#define LIRC_CAN_NOTIFY_DECODE		0  /*** IOCTL commands for lirc driver ***/ @@ -139,7 +143,7 @@   */  #define LIRC_GET_REC_TIMEOUT	       _IOR('i', 0x00000024, __u32) -/* +/**   * struct lirc_scancode - decoded scancode with protocol for use with   *	LIRC_MODE_SCANCODE   * @@ -196,6 +200,7 @@ struct lirc_scancode {   * @RC_PROTO_RCMM24: RC-MM protocol 24 bits   * @RC_PROTO_RCMM32: RC-MM protocol 32 bits   * @RC_PROTO_XBOX_DVD: Xbox DVD Movie Playback Kit protocol + * @RC_PROTO_MAX: Maximum value of enum rc_proto   */  enum rc_proto {  	RC_PROTO_UNKNOWN	= 0, @@ -226,6 +231,7 @@ enum rc_proto {  	RC_PROTO_RCMM24		= 25,  	RC_PROTO_RCMM32		= 26,  	RC_PROTO_XBOX_DVD	= 27, +	RC_PROTO_MAX		= RC_PROTO_XBOX_DVD,  };  #endif diff --git a/include/uapi/linux/loadpin.h b/include/uapi/linux/loadpin.h new file mode 100644 index 000000000000..daa6dbb8bb02 --- /dev/null +++ b/include/uapi/linux/loadpin.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Copyright (c) 2022, Google LLC + */ + +#ifndef _UAPI_LINUX_LOOP_LOADPIN_H +#define _UAPI_LINUX_LOOP_LOADPIN_H + +#define LOADPIN_IOC_MAGIC	'L' + +/** + * LOADPIN_IOC_SET_TRUSTED_VERITY_DIGESTS - Set up the root digests of verity devices + *                                          that loadpin should trust. + * + * Takes a file descriptor from which to read the root digests of trusted verity devices. The file + * is expected to contain a list of digests in ASCII format, with one line per digest. The ioctl + * must be issued on the securityfs attribute 'loadpin/dm-verity' (which can be typically found + * under /sys/kernel/security/loadpin/dm-verity). + */ +#define LOADPIN_IOC_SET_TRUSTED_VERITY_DIGESTS _IOW(LOADPIN_IOC_MAGIC, 0x00, unsigned int) + +#endif /* _UAPI_LINUX_LOOP_LOADPIN_H */ diff --git a/include/uapi/linux/lockd_netlink.h b/include/uapi/linux/lockd_netlink.h new file mode 100644 index 000000000000..21c65aec3bc6 --- /dev/null +++ b/include/uapi/linux/lockd_netlink.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/lockd.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_LOCKD_NETLINK_H +#define _UAPI_LINUX_LOCKD_NETLINK_H + +#define LOCKD_FAMILY_NAME	"lockd" +#define LOCKD_FAMILY_VERSION	1 + +enum { +	LOCKD_A_SERVER_GRACETIME = 1, +	LOCKD_A_SERVER_TCP_PORT, +	LOCKD_A_SERVER_UDP_PORT, + +	__LOCKD_A_SERVER_MAX, +	LOCKD_A_SERVER_MAX = (__LOCKD_A_SERVER_MAX - 1) +}; + +enum { +	LOCKD_CMD_SERVER_SET = 1, +	LOCKD_CMD_SERVER_GET, + +	__LOCKD_CMD_MAX, +	LOCKD_CMD_MAX = (__LOCKD_CMD_MAX - 1) +}; + +#endif /* _UAPI_LINUX_LOCKD_NETLINK_H */ diff --git a/include/uapi/linux/loop.h b/include/uapi/linux/loop.h index 24a1c45bd1ae..6f63527dd2ed 100644 --- a/include/uapi/linux/loop.h +++ b/include/uapi/linux/loop.h @@ -1,11 +1,6 @@  /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */  /* - * include/linux/loop.h - * - * Written by Theodore Ts'o, 3/29/93. - * - * Copyright 1993 by Theodore Ts'o.  Redistribution of this file is - * permitted under the GNU General Public License. + * Copyright 1993 by Theodore Ts'o.   */  #ifndef _UAPI_LINUX_LOOP_H  #define _UAPI_LINUX_LOOP_H @@ -45,7 +40,7 @@ struct loop_info {  	unsigned long	   lo_inode; 		/* ioctl r/o */  	__kernel_old_dev_t lo_rdevice; 		/* ioctl r/o */  	int		   lo_offset; -	int		   lo_encrypt_type; +	int		   lo_encrypt_type;		/* obsolete, ignored */  	int		   lo_encrypt_key_size; 	/* ioctl w/o */  	int		   lo_flags;  	char		   lo_name[LO_NAME_SIZE]; @@ -61,7 +56,7 @@ struct loop_info64 {  	__u64		   lo_offset;  	__u64		   lo_sizelimit;/* bytes, 0 == max available */  	__u32		   lo_number;			/* ioctl r/o */ -	__u32		   lo_encrypt_type; +	__u32		   lo_encrypt_type;		/* obsolete, ignored */  	__u32		   lo_encrypt_key_size;		/* ioctl w/o */  	__u32		   lo_flags;  	__u8		   lo_file_name[LO_NAME_SIZE]; diff --git a/include/uapi/linux/lsm.h b/include/uapi/linux/lsm.h new file mode 100644 index 000000000000..938593dfd5da --- /dev/null +++ b/include/uapi/linux/lsm.h @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Linux Security Modules (LSM) - User space API + * + * Copyright (C) 2022 Casey Schaufler <casey@schaufler-ca.com> + * Copyright (C) 2022 Intel Corporation + */ + +#ifndef _UAPI_LINUX_LSM_H +#define _UAPI_LINUX_LSM_H + +#include <linux/stddef.h> +#include <linux/types.h> +#include <linux/unistd.h> + +/** + * struct lsm_ctx - LSM context information + * @id: the LSM id number, see LSM_ID_XXX + * @flags: LSM specific flags + * @len: length of the lsm_ctx struct, @ctx and any other data or padding + * @ctx_len: the size of @ctx + * @ctx: the LSM context value + * + * The @len field MUST be equal to the size of the lsm_ctx struct + * plus any additional padding and/or data placed after @ctx. + * + * In all cases @ctx_len MUST be equal to the length of @ctx. + * If @ctx is a string value it should be nul terminated with + * @ctx_len equal to `strlen(@ctx) + 1`.  Binary values are + * supported. + * + * The @flags and @ctx fields SHOULD only be interpreted by the + * LSM specified by @id; they MUST be set to zero/0 when not used. + */ +struct lsm_ctx { +	__u64 id; +	__u64 flags; +	__u64 len; +	__u64 ctx_len; +	__u8 ctx[] __counted_by(ctx_len); +}; + +/* + * ID tokens to identify Linux Security Modules (LSMs) + * + * These token values are used to uniquely identify specific LSMs + * in the kernel as well as in the kernel's LSM userspace API. + * + * A value of zero/0 is considered undefined and should not be used + * outside the kernel. Values 1-99 are reserved for potential + * future use. + */ +#define LSM_ID_UNDEF		0 +#define LSM_ID_CAPABILITY	100 +#define LSM_ID_SELINUX		101 +#define LSM_ID_SMACK		102 +#define LSM_ID_TOMOYO		103 +#define LSM_ID_APPARMOR		104 +#define LSM_ID_YAMA		105 +#define LSM_ID_LOADPIN		106 +#define LSM_ID_SAFESETID	107 +#define LSM_ID_LOCKDOWN		108 +#define LSM_ID_BPF		109 +#define LSM_ID_LANDLOCK		110 +#define LSM_ID_IMA		111 +#define LSM_ID_EVM		112 +#define LSM_ID_IPE		113 + +/* + * LSM_ATTR_XXX definitions identify different LSM attributes + * which are used in the kernel's LSM userspace API. Support + * for these attributes vary across the different LSMs. None + * are required. + * + * A value of zero/0 is considered undefined and should not be used + * outside the kernel. Values 1-99 are reserved for potential + * future use. + */ +#define LSM_ATTR_UNDEF		0 +#define LSM_ATTR_CURRENT	100 +#define LSM_ATTR_EXEC		101 +#define LSM_ATTR_FSCREATE	102 +#define LSM_ATTR_KEYCREATE	103 +#define LSM_ATTR_PREV		104 +#define LSM_ATTR_SOCKCREATE	105 + +/* + * LSM_FLAG_XXX definitions identify special handling instructions + * for the API. + */ +#define LSM_FLAG_SINGLE	0x0001 + +#endif /* _UAPI_LINUX_LSM_H */ diff --git a/include/uapi/linux/lwtunnel.h b/include/uapi/linux/lwtunnel.h index 568a4303ccce..229655ef792f 100644 --- a/include/uapi/linux/lwtunnel.h +++ b/include/uapi/linux/lwtunnel.h @@ -14,6 +14,8 @@ enum lwtunnel_encap_types {  	LWTUNNEL_ENCAP_BPF,  	LWTUNNEL_ENCAP_SEG6_LOCAL,  	LWTUNNEL_ENCAP_RPL, +	LWTUNNEL_ENCAP_IOAM6, +	LWTUNNEL_ENCAP_XFRM,  	__LWTUNNEL_ENCAP_MAX,  }; @@ -110,4 +112,13 @@ enum {  #define LWT_BPF_MAX_HEADROOM 256 +enum { +	LWT_XFRM_UNSPEC, +	LWT_XFRM_IF_ID, +	LWT_XFRM_LINK, +	__LWT_XFRM_MAX, +}; + +#define LWT_XFRM_MAX (__LWT_XFRM_MAX - 1) +  #endif /* _UAPI_LWTUNNEL_H_ */ diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index f3956fc11de6..bb575f3ab45e 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -6,6 +6,7 @@  #define AFFS_SUPER_MAGIC	0xadff  #define AFS_SUPER_MAGIC                0x5346414F  #define AUTOFS_SUPER_MAGIC	0x0187 +#define CEPH_SUPER_MAGIC	0x00c36400  #define CODA_SUPER_MAGIC	0x73757245  #define CRAMFS_MAGIC		0x28cd3d45	/* some random number */  #define CRAMFS_MAGIC_WEND	0x453dcd28	/* magic number with the wrong endianess */ @@ -35,6 +36,8 @@  #define EFIVARFS_MAGIC		0xde5e81e4  #define HOSTFS_SUPER_MAGIC	0x00c0ffee  #define OVERLAYFS_SUPER_MAGIC	0x794c7630 +#define FUSE_SUPER_MAGIC	0x65735546 +#define BCACHEFS_SUPER_MAGIC	0xca451a4e  #define MINIX_SUPER_MAGIC	0x137F		/* minix v1 fs, 14 char names */  #define MINIX_SUPER_MAGIC2	0x138F		/* minix v1 fs, 30 char names */ @@ -43,6 +46,7 @@  #define MINIX3_SUPER_MAGIC	0x4d5a		/* minix v3 fs, 60 char names */  #define MSDOS_SUPER_MAGIC	0x4d44		/* MD */ +#define EXFAT_SUPER_MAGIC	0x2011BAB0  #define NCP_SUPER_MAGIC		0x564c		/* Guess, what 0x564c is :-) */  #define NFS_SUPER_MAGIC		0x6969  #define OCFS2_SUPER_MAGIC	0x7461636f @@ -51,6 +55,7 @@  #define QNX6_SUPER_MAGIC	0x68191122	/* qnx6 fs detection */  #define AFS_FS_MAGIC		0x6B414653 +  #define REISERFS_SUPER_MAGIC	0x52654973	/* used by gcc */  					/* used by file system utilities that  	                                   look at the superblock, etc.  */ @@ -59,6 +64,9 @@  #define REISER2FS_JR_SUPER_MAGIC_STRING	"ReIsEr3Fs"  #define SMB_SUPER_MAGIC		0x517B +#define CIFS_SUPER_MAGIC	0xFF534D42      /* the first four bytes of SMB PDUs */ +#define SMB2_SUPER_MAGIC	0xFE534D42 +  #define CGROUP_SUPER_MAGIC	0x27e0eb  #define CGROUP2_SUPER_MAGIC	0x63677270 @@ -91,11 +99,9 @@  /* Since UDF 2.01 is ISO 13346 based... */  #define UDF_SUPER_MAGIC		0x15013346 -#define BALLOON_KVM_MAGIC	0x13661366 -#define ZSMALLOC_MAGIC		0x58295829  #define DMA_BUF_MAGIC		0x444d4142	/* "DMAB" */  #define DEVMEM_MAGIC		0x454d444d	/* "DMEM" */ -#define Z3FOLD_MAGIC		0x33 -#define PPC_CMM_MAGIC		0xc7571590 +#define SECRETMEM_MAGIC		0x5345434d	/* "SECM" */ +#define PID_FS_MAGIC		0x50494446	/* "PIDF" */  #endif /* __LINUX_MAGIC_H__ */ diff --git a/include/uapi/linux/major.h b/include/uapi/linux/major.h index 7e5fa8e15c43..4e5f2b3a3d54 100644 --- a/include/uapi/linux/major.h +++ b/include/uapi/linux/major.h @@ -34,8 +34,6 @@  #define GOLDSTAR_CDROM_MAJOR	16  #define OPTICS_CDROM_MAJOR	17  #define SANYO_CDROM_MAJOR	18 -#define CYCLADES_MAJOR		19 -#define CYCLADESAUX_MAJOR	20  #define MITSUMI_X_CDROM_MAJOR	20  #define MFM_ACORN_MAJOR		21	/* ARM Linux /dev/mfm */  #define SCSI_GENERIC_MAJOR	21 diff --git a/include/uapi/linux/map_to_14segment.h b/include/uapi/linux/map_to_14segment.h new file mode 100644 index 000000000000..0346ef76543b --- /dev/null +++ b/include/uapi/linux/map_to_14segment.h @@ -0,0 +1,241 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Copyright (C) 2021 Glider bv + * + * Based on include/uapi/linux/map_to_7segment.h: + + * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com> + */ + +#ifndef MAP_TO_14SEGMENT_H +#define MAP_TO_14SEGMENT_H + +/* This file provides translation primitives and tables for the conversion + * of (ASCII) characters to a 14-segments notation. + * + * The 14 segment's wikipedia notation below is used as standard. + * See: https://en.wikipedia.org/wiki/Fourteen-segment_display + * + * Notation:	+---a---+ + *		|\  |  /| + *		f h i j b + *		|  \|/  | + *		+-g1+-g2+ + *		|  /|\  | + *		e k l m c + *		|/  |  \| + *		+---d---+ + * + * Usage: + * + *   Register a map variable, and fill it with a character set: + *	static SEG14_DEFAULT_MAP(map_seg14); + * + * + *   Then use for conversion: + *	seg14 = map_to_seg14(&map_seg14, some_char); + *	... + * + * In device drivers it is recommended, if required, to make the char map + * accessible via the sysfs interface using the following scheme: + * + * static ssize_t map_seg14_show(struct device *dev, + *				 struct device_attribute *attr, char *buf) + * { + *	memcpy(buf, &map_seg14, sizeof(map_seg14)); + *	return sizeof(map_seg14); + * } + * static ssize_t map_seg14_store(struct device *dev, + *				  struct device_attribute *attr, + *				  const char *buf, size_t cnt) + * { + *	if (cnt != sizeof(map_seg14)) + *		return -EINVAL; + *	memcpy(&map_seg14, buf, cnt); + *	return cnt; + * } + * static DEVICE_ATTR_RW(map_seg14); + */ +#include <linux/errno.h> +#include <linux/types.h> + +#include <asm/byteorder.h> + +#define BIT_SEG14_A		0 +#define BIT_SEG14_B		1 +#define BIT_SEG14_C		2 +#define BIT_SEG14_D		3 +#define BIT_SEG14_E		4 +#define BIT_SEG14_F		5 +#define BIT_SEG14_G1		6 +#define BIT_SEG14_G2		7 +#define BIT_SEG14_H		8 +#define BIT_SEG14_I		9 +#define BIT_SEG14_J		10 +#define BIT_SEG14_K		11 +#define BIT_SEG14_L		12 +#define BIT_SEG14_M		13 +#define BIT_SEG14_RESERVED1	14 +#define BIT_SEG14_RESERVED2	15 + +struct seg14_conversion_map { +	__be16 table[128]; +}; + +static __inline__ int map_to_seg14(struct seg14_conversion_map *map, int c) +{ +	if (c < 0 || c >= sizeof(map->table) / sizeof(map->table[0])) +		return -EINVAL; + +	return __be16_to_cpu(map->table[c]); +} + +#define SEG14_CONVERSION_MAP(_name, _map)	\ +	struct seg14_conversion_map _name = { .table = { _map } } + +/* + * It is recommended to use a facility that allows user space to redefine + * custom character sets for LCD devices. Please use a sysfs interface + * as described above. + */ +#define MAP_TO_SEG14_SYSFS_FILE	"map_seg14" + +/******************************************************************************* + * ASCII conversion table + ******************************************************************************/ + +#define _SEG14(sym, a, b, c, d, e, f, g1, g2, h, j, k, l, m, n)	\ +	__cpu_to_be16( a << BIT_SEG14_A  |  b << BIT_SEG14_B  |	\ +		       c << BIT_SEG14_C  |  d << BIT_SEG14_D  |	\ +		       e << BIT_SEG14_E  |  f << BIT_SEG14_F  |	\ +		      g1 << BIT_SEG14_G1 | g2 << BIT_SEG14_G2 |	\ +		       h << BIT_SEG14_H  |  j << BIT_SEG14_I  |	\ +		       k << BIT_SEG14_J  |  l << BIT_SEG14_K  |	\ +		       m << BIT_SEG14_L  |  n << BIT_SEG14_M ) + +#define _MAP_0_32_ASCII_SEG14_NON_PRINTABLE				\ +	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + +#define _MAP_33_47_ASCII_SEG14_SYMBOL				\ +	_SEG14('!', 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('"', 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0),	\ +	_SEG14('#', 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0),	\ +	_SEG14('$', 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0),	\ +	_SEG14('%', 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0),	\ +	_SEG14('&', 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1),	\ +	_SEG14('\'',0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0),	\ +	_SEG14('(', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1),	\ +	_SEG14(')', 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0),	\ +	_SEG14('*', 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1),	\ +	_SEG14('+', 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0),	\ +	_SEG14(',', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0),	\ +	_SEG14('-', 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),	\ +	_SEG14('/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0), + +#define _MAP_48_57_ASCII_SEG14_NUMERIC				\ +	_SEG14('0', 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0),	\ +	_SEG14('1', 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0),	\ +	_SEG14('2', 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('3', 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('4', 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('5', 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1),	\ +	_SEG14('6', 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('7', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0),	\ +	_SEG14('8', 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('9', 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0), + +#define _MAP_58_64_ASCII_SEG14_SYMBOL				\ +	_SEG14(':', 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0),	\ +	_SEG14(';', 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0),	\ +	_SEG14('<', 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1),	\ +	_SEG14('=', 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('>', 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0),	\ +	_SEG14('?', 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0),	\ +	_SEG14('@', 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0), + +#define _MAP_65_90_ASCII_SEG14_ALPHA_UPPER			\ +	_SEG14('A', 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('B', 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0),	\ +	_SEG14('C', 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('D', 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0),	\ +	_SEG14('E', 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('F', 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('G', 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('H', 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('I', 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0),	\ +	_SEG14('J', 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('K', 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1),	\ +	_SEG14('L', 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('M', 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0),	\ +	_SEG14('N', 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1),	\ +	_SEG14('O', 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('P', 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('Q', 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1),	\ +	_SEG14('R', 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1),	\ +	_SEG14('S', 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('T', 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0),	\ +	_SEG14('U', 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('V', 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0),	\ +	_SEG14('W', 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1),	\ +	_SEG14('X', 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1),	\ +	_SEG14('Y', 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0),	\ +	_SEG14('Z', 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0), + +#define _MAP_91_96_ASCII_SEG14_SYMBOL				\ +	_SEG14('[', 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('\\',0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1),	\ +	_SEG14(']', 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1),	\ +	_SEG14('_', 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('`', 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), + +#define _MAP_97_122_ASCII_SEG14_ALPHA_LOWER			\ +	_SEG14('a', 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0),	\ +	_SEG14('b', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1),	\ +	_SEG14('c', 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('d', 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0),	\ +	_SEG14('e', 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0),	\ +	_SEG14('f', 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0),	\ +	_SEG14('g', 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0),	\ +	_SEG14('h', 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0),	\ +	_SEG14('i', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0),	\ +	_SEG14('j', 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0),	\ +	_SEG14('k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1),	\ +	_SEG14('l', 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('m', 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0),	\ +	_SEG14('n', 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0),	\ +	_SEG14('o', 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('p', 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0),	\ +	_SEG14('q', 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0),	\ +	_SEG14('r', 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('s', 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1),	\ +	_SEG14('t', 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('u', 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),	\ +	_SEG14('v', 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0),	\ +	_SEG14('w', 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1),	\ +	_SEG14('x', 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1),	\ +	_SEG14('y', 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0),	\ +	_SEG14('z', 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0), + +#define _MAP_123_126_ASCII_SEG14_SYMBOL				\ +	_SEG14('{', 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0),	\ +	_SEG14('|', 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0),	\ +	_SEG14('}', 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1),	\ +	_SEG14('~', 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0), + +/* Maps */ +#define MAP_ASCII14SEG_ALPHANUM			\ +	_MAP_0_32_ASCII_SEG14_NON_PRINTABLE	\ +	_MAP_33_47_ASCII_SEG14_SYMBOL		\ +	_MAP_48_57_ASCII_SEG14_NUMERIC		\ +	_MAP_58_64_ASCII_SEG14_SYMBOL		\ +	_MAP_65_90_ASCII_SEG14_ALPHA_UPPER	\ +	_MAP_91_96_ASCII_SEG14_SYMBOL		\ +	_MAP_97_122_ASCII_SEG14_ALPHA_LOWER	\ +	_MAP_123_126_ASCII_SEG14_SYMBOL + +#define SEG14_DEFAULT_MAP(_name)		\ +	SEG14_CONVERSION_MAP(_name, MAP_ASCII14SEG_ALPHANUM) + +#endif	/* MAP_TO_14SEGMENT_H */ diff --git a/include/uapi/linux/map_to_7segment.h b/include/uapi/linux/map_to_7segment.h index 13a06e5e966e..04c8b55812e7 100644 --- a/include/uapi/linux/map_to_7segment.h +++ b/include/uapi/linux/map_to_7segment.h @@ -1,20 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */  /*   * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA   */  #ifndef MAP_TO_7SEGMENT_H @@ -45,17 +31,22 @@   * In device drivers it is recommended, if required, to make the char map   * accessible via the sysfs interface using the following scheme:   * - * static ssize_t show_map(struct device *dev, char *buf) { + * static ssize_t map_seg7_show(struct device *dev, + *				struct device_attribute *attr, char *buf) + * {   *	memcpy(buf, &map_seg7, sizeof(map_seg7));   *	return sizeof(map_seg7);   * } - * static ssize_t store_map(struct device *dev, const char *buf, size_t cnt) { + * static ssize_t map_seg7_store(struct device *dev, + *				 struct device_attribute *attr, const char *buf, + *				 size_t cnt) + * {   *	if(cnt != sizeof(map_seg7))   *		return -EINVAL;   *	memcpy(&map_seg7, buf, cnt);   *	return cnt;   * } - * static DEVICE_ATTR(map_seg7, PERMS_RW, show_map, store_map); + * static DEVICE_ATTR_RW(map_seg7);   *   * History:   * 2005-05-31	RFC linux-kernel@vger.kernel.org diff --git a/include/uapi/linux/mctp.h b/include/uapi/linux/mctp.h new file mode 100644 index 000000000000..19ad12a0cd4b --- /dev/null +++ b/include/uapi/linux/mctp.h @@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Management Component Transport Protocol (MCTP) + * + * Copyright (c) 2021 Code Construct + * Copyright (c) 2021 Google + */ + +#ifndef __UAPI_MCTP_H +#define __UAPI_MCTP_H + +#include <linux/types.h> +#include <linux/socket.h> +#include <linux/netdevice.h> + +typedef __u8			mctp_eid_t; + +struct mctp_addr { +	mctp_eid_t		s_addr; +}; + +struct sockaddr_mctp { +	__kernel_sa_family_t	smctp_family; +	__u16			__smctp_pad0; +	unsigned int		smctp_network; +	struct mctp_addr	smctp_addr; +	__u8			smctp_type; +	__u8			smctp_tag; +	__u8			__smctp_pad1; +}; + +struct sockaddr_mctp_ext { +	struct sockaddr_mctp	smctp_base; +	int			smctp_ifindex; +	__u8			smctp_halen; +	__u8			__smctp_pad0[3]; +	__u8			smctp_haddr[MAX_ADDR_LEN]; +}; + +/* A "fully qualified" MCTP address, which includes the system-local network ID, + * required to uniquely resolve a routable EID. + */ +struct mctp_fq_addr { +	unsigned int	net; +	mctp_eid_t	eid; +}; + +#define MCTP_NET_ANY		0x0 + +#define MCTP_ADDR_NULL		0x00 +#define MCTP_ADDR_ANY		0xff + +#define MCTP_TAG_MASK		0x07 +#define MCTP_TAG_OWNER		0x08 +#define MCTP_TAG_PREALLOC	0x10 + +#define MCTP_OPT_ADDR_EXT	1 + +#define SIOCMCTPALLOCTAG	(SIOCPROTOPRIVATE + 0) +#define SIOCMCTPDROPTAG		(SIOCPROTOPRIVATE + 1) +#define SIOCMCTPALLOCTAG2	(SIOCPROTOPRIVATE + 2) +#define SIOCMCTPDROPTAG2	(SIOCPROTOPRIVATE + 3) + +/* Deprecated: use mctp_ioc_tag_ctl2 / TAG2 ioctls instead, which defines the + * MCTP network ID as part of the allocated tag. Using this assumes the default + * net ID for allocated tags, which may not give correct behaviour on system + * with multiple networks configured. + */ +struct mctp_ioc_tag_ctl { +	mctp_eid_t	peer_addr; + +	/* For SIOCMCTPALLOCTAG: must be passed as zero, kernel will +	 * populate with the allocated tag value. Returned tag value will +	 * always have TO and PREALLOC set. +	 * +	 * For SIOCMCTPDROPTAG: userspace provides tag value to drop, from +	 * a prior SIOCMCTPALLOCTAG call (and so must have TO and PREALLOC set). +	 */ +	__u8		tag; +	__u16		flags; +}; + +struct mctp_ioc_tag_ctl2 { +	/* Peer details: network ID, peer EID, local EID. All set by the +	 * caller. +	 * +	 * Local EID must be MCTP_ADDR_NULL or MCTP_ADDR_ANY in current +	 * kernels. +	 */ +	unsigned int	net; +	mctp_eid_t	peer_addr; +	mctp_eid_t	local_addr; + +	/* Set by caller, but no flags defined currently. Must be 0 */ +	__u16		flags; + +	/* For SIOCMCTPALLOCTAG2: must be passed as zero, kernel will +	 * populate with the allocated tag value. Returned tag value will +	 * always have TO and PREALLOC set. +	 * +	 * For SIOCMCTPDROPTAG2: userspace provides tag value to drop, from +	 * a prior SIOCMCTPALLOCTAG2 call (and so must have TO and PREALLOC set). +	 */ +	__u8		tag; + +}; + +#endif /* __UAPI_MCTP_H */ diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h index 3f302e2523b2..6975f182b22c 100644 --- a/include/uapi/linux/mdio.h +++ b/include/uapi/linux/mdio.h @@ -23,6 +23,7 @@  #define MDIO_MMD_DTEXS		5	/* DTE Extender Sublayer */  #define MDIO_MMD_TC		6	/* Transmission Convergence */  #define MDIO_MMD_AN		7	/* Auto-Negotiation */ +#define MDIO_MMD_POWER_UNIT	13	/* PHY Power Unit */  #define MDIO_MMD_C22EXT		29	/* Clause 22 extension */  #define MDIO_MMD_VEND1		30	/* Vendor specific 1 */  #define MDIO_MMD_VEND2		31	/* Vendor specific 2 */ @@ -53,18 +54,37 @@  #define MDIO_AN_EEE_LPABLE	61	/* EEE link partner ability */  #define MDIO_AN_EEE_ADV2	62	/* EEE advertisement 2 */  #define MDIO_AN_EEE_LPABLE2	63	/* EEE link partner ability 2 */ +#define MDIO_AN_CTRL2		64	/* AN THP bypass request control */  /* Media-dependent registers. */  #define MDIO_PMA_10GBT_SWAPPOL	130	/* 10GBASE-T pair swap & polarity */  #define MDIO_PMA_10GBT_TXPWR	131	/* 10GBASE-T TX power control */  #define MDIO_PMA_10GBT_SNR	133	/* 10GBASE-T SNR margin, lane A.  					 * Lanes B-D are numbered 134-136. */ +#define MDIO_PMA_10GBR_FSRT_CSR	147	/* 10GBASE-R fast retrain status and control */  #define MDIO_PMA_10GBR_FECABLE	170	/* 10GBASE-R FEC ability */  #define MDIO_PCS_10GBX_STAT1	24	/* 10GBASE-X PCS status 1 */  #define MDIO_PCS_10GBRT_STAT1	32	/* 10GBASE-R/-T PCS status 1 */  #define MDIO_PCS_10GBRT_STAT2	33	/* 10GBASE-R/-T PCS status 2 */  #define MDIO_AN_10GBT_CTRL	32	/* 10GBASE-T auto-negotiation control */  #define MDIO_AN_10GBT_STAT	33	/* 10GBASE-T auto-negotiation status */ +#define MDIO_B10L_PMA_CTRL	2294	/* 10BASE-T1L PMA control */ +#define MDIO_PMA_10T1L_STAT	2295	/* 10BASE-T1L PMA status */ +#define MDIO_PCS_10T1L_CTRL	2278	/* 10BASE-T1L PCS control */ +#define MDIO_PMA_PMD_BT1	18	/* BASE-T1 PMA/PMD extended ability */ +#define MDIO_AN_T1_CTRL		512	/* BASE-T1 AN control */ +#define MDIO_AN_T1_STAT		513	/* BASE-T1 AN status */ +#define MDIO_AN_T1_ADV_L	514	/* BASE-T1 AN advertisement register [15:0] */ +#define MDIO_AN_T1_ADV_M	515	/* BASE-T1 AN advertisement register [31:16] */ +#define MDIO_AN_T1_ADV_H	516	/* BASE-T1 AN advertisement register [47:32] */ +#define MDIO_AN_T1_LP_L		517	/* BASE-T1 AN LP Base Page ability register [15:0] */ +#define MDIO_AN_T1_LP_M		518	/* BASE-T1 AN LP Base Page ability register [31:16] */ +#define MDIO_AN_T1_LP_H		519	/* BASE-T1 AN LP Base Page ability register [47:32] */ +#define MDIO_AN_10BT1_AN_CTRL	526	/* 10BASE-T1 AN control register */ +#define MDIO_AN_10BT1_AN_STAT	527	/* 10BASE-T1 AN status register */ +#define MDIO_PMA_PMD_BT1_CTRL	2100	/* BASE-T1 PMA/PMD control register */ +#define MDIO_PCS_1000BT1_CTRL	2304	/* 1000BASE-T1 PCS control register */ +#define MDIO_PCS_1000BT1_STAT	2305	/* 1000BASE-T1 PCS status register */  /* LASI (Link Alarm Status Interrupt) registers, defined by XENPAK MSA. */  #define MDIO_PMA_LASI_RXCTRL	0x9000	/* RX_ALARM control */ @@ -105,6 +125,7 @@  #define MDIO_STAT1_LPOWERABLE		0x0002	/* Low-power ability */  #define MDIO_STAT1_LSTATUS		BMSR_LSTATUS  #define MDIO_STAT1_FAULT		0x0080	/* Fault */ +#define MDIO_PCS_STAT1_CLKSTOP_CAP	0x0040  #define MDIO_AN_STAT1_LPABLE		0x0001	/* Link partner AN ability */  #define MDIO_AN_STAT1_ABLE		BMSR_ANEGCAPABLE  #define MDIO_AN_STAT1_RFAULT		BMSR_RFAULT @@ -119,7 +140,11 @@  #define MDIO_PMA_SPEED_1000		0x0010	/* 1000M capable */  #define MDIO_PMA_SPEED_100		0x0020	/* 100M capable */  #define MDIO_PMA_SPEED_10		0x0040	/* 10M capable */ +#define MDIO_PMA_SPEED_2_5G		0x2000	/* 2.5G capable */ +#define MDIO_PMA_SPEED_5G		0x4000	/* 5G capable */  #define MDIO_PCS_SPEED_10P2B		0x0002	/* 10PASS-TS/2BASE-TL capable */ +#define MDIO_PCS_SPEED_2_5G		0x0040	/* 2.5G capable */ +#define MDIO_PCS_SPEED_5G		0x0080	/* 5G capable */  /* Device present registers. */  #define MDIO_DEVS_PRESENT(devad)	(1 << (devad)) @@ -155,6 +180,7 @@  #define MDIO_PMA_CTRL2_10BT		0x000f	/* 10BASE-T type */  #define MDIO_PMA_CTRL2_2_5GBT		0x0030  /* 2.5GBaseT type */  #define MDIO_PMA_CTRL2_5GBT		0x0031  /* 5GBaseT type */ +#define MDIO_PMA_CTRL2_BASET1		0x003D  /* BASE-T1 type */  #define MDIO_PCS_CTRL2_TYPE		0x0003	/* PCS type selection */  #define MDIO_PCS_CTRL2_10GBR		0x0000	/* 10GBASE-R type */  #define MDIO_PCS_CTRL2_10GBX		0x0001	/* 10GBASE-X type */ @@ -208,8 +234,33 @@  #define MDIO_PMA_EXTABLE_1000BKX	0x0040	/* 1000BASE-KX ability */  #define MDIO_PMA_EXTABLE_100BTX		0x0080	/* 100BASE-TX ability */  #define MDIO_PMA_EXTABLE_10BT		0x0100	/* 10BASE-T ability */ +#define MDIO_PMA_EXTABLE_BT1		0x0800	/* BASE-T1 ability */  #define MDIO_PMA_EXTABLE_NBT		0x4000  /* 2.5/5GBASE-T ability */ +/* AN Clause 73 linkword */ +#define MDIO_AN_C73_0_S_MASK		GENMASK(4, 0) +#define MDIO_AN_C73_0_E_MASK		GENMASK(9, 5) +#define MDIO_AN_C73_0_PAUSE		BIT(10) +#define MDIO_AN_C73_0_ASM_DIR		BIT(11) +#define MDIO_AN_C73_0_C2		BIT(12) +#define MDIO_AN_C73_0_RF		BIT(13) +#define MDIO_AN_C73_0_ACK		BIT(14) +#define MDIO_AN_C73_0_NP		BIT(15) +#define MDIO_AN_C73_1_T_MASK		GENMASK(4, 0) +#define MDIO_AN_C73_1_1000BASE_KX	BIT(5) +#define MDIO_AN_C73_1_10GBASE_KX4	BIT(6) +#define MDIO_AN_C73_1_10GBASE_KR	BIT(7) +#define MDIO_AN_C73_1_40GBASE_KR4	BIT(8) +#define MDIO_AN_C73_1_40GBASE_CR4	BIT(9) +#define MDIO_AN_C73_1_100GBASE_CR10	BIT(10) +#define MDIO_AN_C73_1_100GBASE_KP4	BIT(11) +#define MDIO_AN_C73_1_100GBASE_KR4	BIT(12) +#define MDIO_AN_C73_1_100GBASE_CR4	BIT(13) +#define MDIO_AN_C73_1_25GBASE_R_S	BIT(14) +#define MDIO_AN_C73_1_25GBASE_R		BIT(15) +#define MDIO_AN_C73_2_2500BASE_KX	BIT(0) +#define MDIO_AN_C73_2_5GBASE_KR		BIT(1) +  /* PHY XGXS lane state register. */  #define MDIO_PHYXS_LNSTAT_SYNC0		0x0001  #define MDIO_PHYXS_LNSTAT_SYNC1		0x0002 @@ -237,6 +288,9 @@  #define MDIO_PMA_10GBR_FECABLE_ABLE	0x0001	/* FEC ability */  #define MDIO_PMA_10GBR_FECABLE_ERRABLE	0x0002	/* FEC error indic. ability */ +/* PMA 10GBASE-R Fast Retrain status and control register. */ +#define MDIO_PMA_10GBR_FSRT_ENABLE	0x0001	/* Fast retrain enable */ +  /* PCS 10GBASE-R/-T status register 1. */  #define MDIO_PCS_10GBRT_STAT1_BLKLK	0x0001	/* Block lock attained */ @@ -245,6 +299,7 @@  #define MDIO_PCS_10GBRT_STAT2_BER	0x3f00  /* AN 10GBASE-T control register. */ +#define MDIO_AN_10GBT_CTRL_ADVFSRT2_5G	0x0020	/* Advertise 2.5GBASE-T fast retrain */  #define MDIO_AN_10GBT_CTRL_ADV2_5G	0x0080	/* Advertise 2.5GBASE-T */  #define MDIO_AN_10GBT_CTRL_ADV5G	0x0100	/* Advertise 5GBASE-T */  #define MDIO_AN_10GBT_CTRL_ADV10G	0x1000	/* Advertise 10GBASE-T */ @@ -260,6 +315,88 @@  #define MDIO_AN_10GBT_STAT_MS		0x4000	/* Master/slave config */  #define MDIO_AN_10GBT_STAT_MSFLT	0x8000	/* Master/slave config fault */ +/* 10BASE-T1L PMA control */ +#define MDIO_PMA_10T1L_CTRL_LB_EN	0x0001	/* Enable loopback mode */ +#define MDIO_PMA_10T1L_CTRL_EEE_EN	0x0400	/* Enable EEE mode */ +#define MDIO_PMA_10T1L_CTRL_LOW_POWER	0x0800	/* Low-power mode */ +#define MDIO_PMA_10T1L_CTRL_2V4_EN	0x1000	/* Enable 2.4 Vpp operating mode */ +#define MDIO_PMA_10T1L_CTRL_TX_DIS	0x4000	/* Transmit disable */ +#define MDIO_PMA_10T1L_CTRL_PMA_RST	0x8000	/* MA reset */ + +/* 10BASE-T1L PMA status register. */ +#define MDIO_PMA_10T1L_STAT_LINK	0x0001	/* PMA receive link up */ +#define MDIO_PMA_10T1L_STAT_FAULT	0x0002	/* Fault condition detected */ +#define MDIO_PMA_10T1L_STAT_POLARITY	0x0004	/* Receive polarity is reversed */ +#define MDIO_PMA_10T1L_STAT_RECV_FAULT	0x0200	/* Able to detect fault on receive path */ +#define MDIO_PMA_10T1L_STAT_EEE		0x0400	/* PHY has EEE ability */ +#define MDIO_PMA_10T1L_STAT_LOW_POWER	0x0800	/* PMA has low-power ability */ +#define MDIO_PMA_10T1L_STAT_2V4_ABLE	0x1000	/* PHY has 2.4 Vpp operating mode ability */ +#define MDIO_PMA_10T1L_STAT_LB_ABLE	0x2000	/* PHY has loopback ability */ + +/* 10BASE-T1L PCS control register. */ +#define MDIO_PCS_10T1L_CTRL_LB		0x4000	/* Enable PCS level loopback mode */ +#define MDIO_PCS_10T1L_CTRL_RESET	0x8000	/* PCS reset */ + +/* BASE-T1 PMA/PMD extended ability register. */ +#define MDIO_PMA_PMD_BT1_B100_ABLE	0x0001	/* 100BASE-T1 Ability */ +#define MDIO_PMA_PMD_BT1_B1000_ABLE	0x0002	/* 1000BASE-T1 Ability */ +#define MDIO_PMA_PMD_BT1_B10L_ABLE	0x0004	/* 10BASE-T1L Ability */ + +/* BASE-T1 auto-negotiation advertisement register [15:0] */ +#define MDIO_AN_T1_ADV_L_PAUSE_CAP	ADVERTISE_PAUSE_CAP +#define MDIO_AN_T1_ADV_L_PAUSE_ASYM	ADVERTISE_PAUSE_ASYM +#define MDIO_AN_T1_ADV_L_FORCE_MS	0x1000	/* Force Master/slave Configuration */ +#define MDIO_AN_T1_ADV_L_REMOTE_FAULT	ADVERTISE_RFAULT +#define MDIO_AN_T1_ADV_L_ACK		ADVERTISE_LPACK +#define MDIO_AN_T1_ADV_L_NEXT_PAGE_REQ	ADVERTISE_NPAGE + +/* BASE-T1 auto-negotiation advertisement register [31:16] */ +#define MDIO_AN_T1_ADV_M_B10L		0x4000	/* device is compatible with 10BASE-T1L */ +#define MDIO_AN_T1_ADV_M_1000BT1	0x0080	/* advertise 1000BASE-T1 */ +#define MDIO_AN_T1_ADV_M_100BT1		0x0020	/* advertise 100BASE-T1 */ +#define MDIO_AN_T1_ADV_M_MST		0x0010	/* advertise master preference */ + +/* BASE-T1 auto-negotiation advertisement register [47:32] */ +#define MDIO_AN_T1_ADV_H_10L_TX_HI_REQ	0x1000	/* 10BASE-T1L High Level Transmit Request */ +#define MDIO_AN_T1_ADV_H_10L_TX_HI	0x2000	/* 10BASE-T1L High Level Transmit Ability */ + +/* BASE-T1 AN LP Base Page ability register [15:0] */ +#define MDIO_AN_T1_LP_L_PAUSE_CAP	LPA_PAUSE_CAP +#define MDIO_AN_T1_LP_L_PAUSE_ASYM	LPA_PAUSE_ASYM +#define MDIO_AN_T1_LP_L_FORCE_MS	0x1000	/* LP Force Master/slave Configuration */ +#define MDIO_AN_T1_LP_L_REMOTE_FAULT	LPA_RFAULT +#define MDIO_AN_T1_LP_L_ACK		LPA_LPACK +#define MDIO_AN_T1_LP_L_NEXT_PAGE_REQ	LPA_NPAGE + +/* BASE-T1 AN LP Base Page ability register [31:16] */ +#define MDIO_AN_T1_LP_M_MST		0x0010	/* LP master preference */ +#define MDIO_AN_T1_LP_M_B10L		0x4000	/* LP is compatible with 10BASE-T1L */ + +/* BASE-T1 AN LP Base Page ability register [47:32] */ +#define MDIO_AN_T1_LP_H_10L_TX_HI_REQ	0x1000	/* 10BASE-T1L High Level LP Transmit Request */ +#define MDIO_AN_T1_LP_H_10L_TX_HI	0x2000	/* 10BASE-T1L High Level LP Transmit Ability */ + +/* 10BASE-T1 AN control register */ +#define MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L	0x4000 /* 10BASE-T1L EEE ability advertisement */ + +/* 10BASE-T1 AN status register */ +#define MDIO_AN_10BT1_AN_STAT_LPA_EEE_T1L	0x4000 /* 10BASE-T1L LP EEE ability advertisement */ + +/* BASE-T1 PMA/PMD control register */ +#define MDIO_PMA_PMD_BT1_CTRL_STRAP		0x000F /* Type selection (Strap) */ +#define MDIO_PMA_PMD_BT1_CTRL_STRAP_B1000	0x0001 /* Select 1000BASE-T1 */ +#define MDIO_PMA_PMD_BT1_CTRL_CFG_MST		0x4000 /* MASTER-SLAVE config value */ + +/* 1000BASE-T1 PCS control register */ +#define MDIO_PCS_1000BT1_CTRL_LOW_POWER		0x0800 /* Low power mode */ +#define MDIO_PCS_1000BT1_CTRL_DISABLE_TX	0x4000 /* Global PMA transmit disable */ +#define MDIO_PCS_1000BT1_CTRL_RESET		0x8000 /* Software reset value */ + +/* 1000BASE-T1 PCS status register */ +#define MDIO_PCS_1000BT1_STAT_LINK	0x0004 /* PCS Link is up */ +#define MDIO_PCS_1000BT1_STAT_FAULT	0x0080 /* There is a fault condition */ + +  /* EEE Supported/Advertisement/LP Advertisement registers.   *   * EEE capability Register (3.20), Advertisement (7.60) and @@ -287,6 +424,9 @@  #define MDIO_EEE_2_5GT		0x0001	/* 2.5GT EEE cap */  #define MDIO_EEE_5GT		0x0002	/* 5GT EEE cap */ +/* AN MultiGBASE-T AN control 2 */ +#define MDIO_AN_THP_BP2_5GT	0x0008	/* 2.5GT THP bypass request */ +  /* 2.5G/5G Extended abilities register. */  #define MDIO_PMA_NG_EXTABLE_2_5GBT	0x0001	/* 2.5GBASET ability */  #define MDIO_PMA_NG_EXTABLE_5GBT	0x0002	/* 5GBASET ability */ diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h index 84fa53ffb13f..ff62056feed5 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -34,7 +34,7 @@  #define MEDIA_BUS_FMT_FIXED			0x0001 -/* RGB - next is	0x101d */ +/* RGB - next is	0x1028 */  #define MEDIA_BUS_FMT_RGB444_1X12		0x1016  #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE	0x1001  #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE	0x1002 @@ -46,8 +46,12 @@  #define MEDIA_BUS_FMT_RGB565_2X8_BE		0x1007  #define MEDIA_BUS_FMT_RGB565_2X8_LE		0x1008  #define MEDIA_BUS_FMT_RGB666_1X18		0x1009 +#define MEDIA_BUS_FMT_RGB666_2X9_BE		0x1025 +#define MEDIA_BUS_FMT_BGR666_1X18		0x1023  #define MEDIA_BUS_FMT_RBG888_1X24		0x100e  #define MEDIA_BUS_FMT_RGB666_1X24_CPADHI	0x1015 +#define MEDIA_BUS_FMT_BGR666_1X24_CPADHI	0x1024 +#define MEDIA_BUS_FMT_RGB565_1X24_CPADHI	0x1022  #define MEDIA_BUS_FMT_RGB666_1X7X3_SPWG		0x1010  #define MEDIA_BUS_FMT_BGR888_1X24		0x1013  #define MEDIA_BUS_FMT_BGR888_3X8		0x101b @@ -56,15 +60,22 @@  #define MEDIA_BUS_FMT_RGB888_2X12_BE		0x100b  #define MEDIA_BUS_FMT_RGB888_2X12_LE		0x100c  #define MEDIA_BUS_FMT_RGB888_3X8		0x101c +#define MEDIA_BUS_FMT_RGB888_3X8_DELTA		0x101d  #define MEDIA_BUS_FMT_RGB888_1X7X4_SPWG		0x1011  #define MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA	0x1012 +#define MEDIA_BUS_FMT_RGB666_1X30_CPADLO	0x101e +#define MEDIA_BUS_FMT_RGB888_1X30_CPADLO	0x101f  #define MEDIA_BUS_FMT_ARGB8888_1X32		0x100d  #define MEDIA_BUS_FMT_RGB888_1X32_PADHI		0x100f  #define MEDIA_BUS_FMT_RGB101010_1X30		0x1018 +#define MEDIA_BUS_FMT_RGB101010_1X7X5_SPWG	0x1026 +#define MEDIA_BUS_FMT_RGB101010_1X7X5_JEIDA	0x1027 +#define MEDIA_BUS_FMT_RGB666_1X36_CPADLO	0x1020 +#define MEDIA_BUS_FMT_RGB888_1X36_CPADLO	0x1021  #define MEDIA_BUS_FMT_RGB121212_1X36		0x1019  #define MEDIA_BUS_FMT_RGB161616_1X48		0x101a -/* YUV (including grey) - next is	0x202e */ +/* YUV (including grey) - next is	0x202f */  #define MEDIA_BUS_FMT_Y8_1X8			0x2001  #define MEDIA_BUS_FMT_UV8_1X8			0x2015  #define MEDIA_BUS_FMT_UYVY8_1_5X8		0x2002 @@ -87,6 +98,7 @@  #define MEDIA_BUS_FMT_YUYV12_2X12		0x201e  #define MEDIA_BUS_FMT_YVYU12_2X12		0x201f  #define MEDIA_BUS_FMT_Y14_1X14			0x202d +#define MEDIA_BUS_FMT_Y16_1X16			0x202e  #define MEDIA_BUS_FMT_UYVY8_1X16		0x200f  #define MEDIA_BUS_FMT_VYUY8_1X16		0x2010  #define MEDIA_BUS_FMT_YUYV8_1X16		0x2011 @@ -156,4 +168,21 @@  /* HSV - next is	0x6002 */  #define MEDIA_BUS_FMT_AHSV8888_1X32		0x6001 +/* + * This format should be used when the same driver handles + * both sides of the link and the bus format is a fixed + * metadata format that is not configurable from userspace. + * Width and height will be set to 0 for this format. + */ +#define MEDIA_BUS_FMT_METADATA_FIXED		0x7001 + +/* Generic line based metadata formats for serial buses. Next is 0x8008. */ +#define MEDIA_BUS_FMT_META_8			0x8001 +#define MEDIA_BUS_FMT_META_10			0x8002 +#define MEDIA_BUS_FMT_META_12			0x8003 +#define MEDIA_BUS_FMT_META_14			0x8004 +#define MEDIA_BUS_FMT_META_16			0x8005 +#define MEDIA_BUS_FMT_META_20			0x8006 +#define MEDIA_BUS_FMT_META_24			0x8007 +  #endif /* __LINUX_MEDIA_BUS_FORMAT_H */ diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 383ac7b7d8f0..1c80b1d6bbaf 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -20,9 +20,6 @@  #ifndef __LINUX_MEDIA_H  #define __LINUX_MEDIA_H -#ifndef __KERNEL__ -#include <stdint.h> -#endif  #include <linux/ioctl.h>  #include <linux/types.h> @@ -127,6 +124,7 @@ struct media_device_info {  #define MEDIA_ENT_F_PROC_VIDEO_STATISTICS	(MEDIA_ENT_F_BASE + 0x4006)  #define MEDIA_ENT_F_PROC_VIDEO_ENCODER		(MEDIA_ENT_F_BASE + 0x4007)  #define MEDIA_ENT_F_PROC_VIDEO_DECODER		(MEDIA_ENT_F_BASE + 0x4008) +#define MEDIA_ENT_F_PROC_VIDEO_ISP		(MEDIA_ENT_F_BASE + 0x4009)  /*   * Switch and bridge entity functions @@ -142,8 +140,8 @@ struct media_device_info {  #define MEDIA_ENT_F_DV_ENCODER			(MEDIA_ENT_F_BASE + 0x6002)  /* Entity flags */ -#define MEDIA_ENT_FL_DEFAULT			(1 << 0) -#define MEDIA_ENT_FL_CONNECTOR			(1 << 1) +#define MEDIA_ENT_FL_DEFAULT			(1U << 0) +#define MEDIA_ENT_FL_CONNECTOR			(1U << 1)  /* OR with the entity id value to find the next entity */  #define MEDIA_ENT_ID_FLAG_NEXT			(1U << 31) @@ -207,9 +205,9 @@ struct media_entity_desc {  	};  }; -#define MEDIA_PAD_FL_SINK			(1 << 0) -#define MEDIA_PAD_FL_SOURCE			(1 << 1) -#define MEDIA_PAD_FL_MUST_CONNECT		(1 << 2) +#define MEDIA_PAD_FL_SINK			(1U << 0) +#define MEDIA_PAD_FL_SOURCE			(1U << 1) +#define MEDIA_PAD_FL_MUST_CONNECT		(1U << 2)  struct media_pad_desc {  	__u32 entity;		/* entity ID */ @@ -218,13 +216,14 @@ struct media_pad_desc {  	__u32 reserved[2];  }; -#define MEDIA_LNK_FL_ENABLED			(1 << 0) -#define MEDIA_LNK_FL_IMMUTABLE			(1 << 1) -#define MEDIA_LNK_FL_DYNAMIC			(1 << 2) +#define MEDIA_LNK_FL_ENABLED			(1U << 0) +#define MEDIA_LNK_FL_IMMUTABLE			(1U << 1) +#define MEDIA_LNK_FL_DYNAMIC			(1U << 2)  #define MEDIA_LNK_FL_LINK_TYPE			(0xf << 28) -#  define MEDIA_LNK_FL_DATA_LINK		(0 << 28) -#  define MEDIA_LNK_FL_INTERFACE_LINK		(1 << 28) +#  define MEDIA_LNK_FL_DATA_LINK		(0U << 28) +#  define MEDIA_LNK_FL_INTERFACE_LINK		(1U << 28) +#  define MEDIA_LNK_FL_ANCILLARY_LINK		(2U << 28)  struct media_link_desc {  	struct media_pad_desc source; @@ -294,7 +293,7 @@ struct media_links_enum {   * struct media_device_info.   */  #define MEDIA_V2_ENTITY_HAS_FLAGS(media_version) \ -	((media_version) >= ((4 << 16) | (19 << 8) | 0)) +	((media_version) >= ((4U << 16) | (19U << 8) | 0U))  struct media_v2_entity {  	__u32 id; @@ -329,7 +328,7 @@ struct media_v2_interface {   * struct media_device_info.   */  #define MEDIA_V2_PAD_HAS_INDEX(media_version) \ -	((media_version) >= ((4 << 16) | (19 << 8) | 0)) +	((media_version) >= ((4U << 16) | (19U << 8) | 0U))  struct media_v2_pad {  	__u32 id; @@ -433,7 +432,7 @@ struct media_v2_topology {  #define MEDIA_INTF_T_ALSA_TIMER                (MEDIA_INTF_T_ALSA_BASE + 7)  /* Obsolete symbol for media_version, no longer used in the kernel */ -#define MEDIA_API_VERSION			((0 << 16) | (1 << 8) | 0) +#define MEDIA_API_VERSION			((0U << 16) | (1U << 8) | 0U)  #endif diff --git a/include/uapi/linux/media/amlogic/c3-isp-config.h b/include/uapi/linux/media/amlogic/c3-isp-config.h new file mode 100644 index 000000000000..ed085ea62a57 --- /dev/null +++ b/include/uapi/linux/media/amlogic/c3-isp-config.h @@ -0,0 +1,564 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * Copyright (C) 2024 Amlogic, Inc. All rights reserved + */ + +#ifndef _UAPI_C3_ISP_CONFIG_H_ +#define _UAPI_C3_ISP_CONFIG_H_ + +#include <linux/types.h> + +/* + * Frames are split into zones of almost equal width and height - a zone is a + * rectangular tile of a frame. The metering blocks within the ISP collect + * aggregated statistics per zone. + */ +#define C3_ISP_AE_MAX_ZONES (17 * 15) +#define C3_ISP_AF_MAX_ZONES (17 * 15) +#define C3_ISP_AWB_MAX_ZONES (32 * 24) + +/* The maximum number of point on the diagonal of the frame for statistics */ +#define C3_ISP_AE_MAX_PT_NUM 18 +#define C3_ISP_AF_MAX_PT_NUM 18 +#define C3_ISP_AWB_MAX_PT_NUM 33 + +/** + * struct c3_isp_awb_zone_stats - AWB statistics of a zone + * + * AWB zone stats is aligned with 8 bytes + * + * @rg: the ratio of R / G in a zone + * @bg: the ratio of B / G in a zone + * @pixel_sum: the total number of pixels used in a zone + */ +struct c3_isp_awb_zone_stats { +	__u16 rg; +	__u16 bg; +	__u32 pixel_sum; +}; + +/** + * struct c3_isp_awb_stats - Auto white balance statistics information. + * + * AWB statistical information of all zones. + * + * @stats: array of auto white balance statistics + */ +struct c3_isp_awb_stats { +	struct c3_isp_awb_zone_stats stats[C3_ISP_AWB_MAX_ZONES]; +} __attribute__((aligned(16))); + +/** + * struct c3_isp_ae_zone_stats - AE statistics of a zone + * + * AE zone stats is aligned with 8 bytes. + * This is a 5-bin histogram and the total sum is normalized to 0xffff. + * So hist2 = 0xffff - (hist0 + hist1 + hist3 + hist4) + * + * @hist0: the global normalized pixel count for bin 0 + * @hist1: the global normalized pixel count for bin 1 + * @hist3: the global normalized pixel count for bin 3 + * @hist4: the global normalized pixel count for bin 4 + */ +struct c3_isp_ae_zone_stats { +	__u16 hist0; +	__u16 hist1; +	__u16 hist3; +	__u16 hist4; +}; + +/** + * struct c3_isp_ae_stats - Exposure statistics information + * + * AE statistical information consists of all blocks information and a 1024-bin + * histogram. + * + * @stats: array of auto exposure block statistics + * @reserved: undefined buffer space + * @hist: a 1024-bin histogram for the entire image + */ +struct c3_isp_ae_stats { +	struct c3_isp_ae_zone_stats stats[C3_ISP_AE_MAX_ZONES]; +	__u32 reserved[2]; +	__u32 hist[1024]; +} __attribute__((aligned(16))); + +/** + * struct c3_isp_af_zone_stats - AF statistics of a zone + * + * AF zone stats is aligned with 8 bytes. + * The zonal accumulated contrast metrics are stored in floating point format + * with 16 bits mantissa and 5 or 6 bits exponent. Apart from contrast metrics + * we accumulate squared image and quartic image data over the zone. + * + * @i2_mat: the mantissa of zonal squared image pixel sum + * @i4_mat: the mantissa of zonal quartic image pixel sum + * @e4_mat: the mantissa of zonal multi-directional quartic edge sum + * @e4_exp: the exponent of zonal multi-directional quartic edge sum + * @i2_exp: the exponent of zonal squared image pixel sum + * @i4_exp: the exponent of zonal quartic image pixel sum + */ +struct c3_isp_af_zone_stats { +	__u16 i2_mat; +	__u16 i4_mat; +	__u16 e4_mat; +	__u16 e4_exp : 5; +	__u16 i2_exp : 5; +	__u16 i4_exp : 6; +}; + +/** + * struct c3_isp_af_stats - Auto Focus statistics information + * + * AF statistical information of each zone + * + * @stats: array of auto focus block statistics + * @reserved: undefined buffer space + */ +struct c3_isp_af_stats { +	struct c3_isp_af_zone_stats stats[C3_ISP_AF_MAX_ZONES]; +	__u32 reserved[2]; +} __attribute__((aligned(16))); + +/** + * struct c3_isp_stats_info - V4L2_META_FMT_C3ISP_STATS + * + * Contains ISP statistics + * + * @awb: auto white balance stats + * @ae: auto exposure stats + * @af: auto focus stats + */ +struct c3_isp_stats_info { +	struct c3_isp_awb_stats awb; +	struct c3_isp_ae_stats ae; +	struct c3_isp_af_stats af; +}; + +/** + * enum c3_isp_params_buffer_version -  C3 ISP parameters block versioning + * + * @C3_ISP_PARAMS_BUFFER_V0: First version of C3 ISP parameters block + */ +enum c3_isp_params_buffer_version { +	C3_ISP_PARAMS_BUFFER_V0, +}; + +/** + * enum c3_isp_params_block_type - Enumeration of C3 ISP parameter blocks + * + * Each block configures a specific processing block of the C3 ISP. + * The block type allows the driver to correctly interpret the parameters block + * data. + * + * @C3_ISP_PARAMS_BLOCK_AWB_GAINS: White balance gains + * @C3_ISP_PARAMS_BLOCK_AWB_CONFIG: AWB statistic format configuration for all + *                                  blocks that control how stats are generated + * @C3_ISP_PARAMS_BLOCK_AE_CONFIG: AE statistic format configuration for all + *                                 blocks that control how stats are generated + * @C3_ISP_PARAMS_BLOCK_AF_CONFIG: AF statistic format configuration for all + *                                 blocks that control how stats are generated + * @C3_ISP_PARAMS_BLOCK_PST_GAMMA: post gamma parameters + * @C3_ISP_PARAMS_BLOCK_CCM: Color correction matrix parameters + * @C3_ISP_PARAMS_BLOCK_CSC: Color space conversion parameters + * @C3_ISP_PARAMS_BLOCK_BLC: Black level correction parameters + * @C3_ISP_PARAMS_BLOCK_SENTINEL: First non-valid block index + */ +enum c3_isp_params_block_type { +	C3_ISP_PARAMS_BLOCK_AWB_GAINS, +	C3_ISP_PARAMS_BLOCK_AWB_CONFIG, +	C3_ISP_PARAMS_BLOCK_AE_CONFIG, +	C3_ISP_PARAMS_BLOCK_AF_CONFIG, +	C3_ISP_PARAMS_BLOCK_PST_GAMMA, +	C3_ISP_PARAMS_BLOCK_CCM, +	C3_ISP_PARAMS_BLOCK_CSC, +	C3_ISP_PARAMS_BLOCK_BLC, +	C3_ISP_PARAMS_BLOCK_SENTINEL +}; + +#define C3_ISP_PARAMS_BLOCK_FL_DISABLE (1U << 0) +#define C3_ISP_PARAMS_BLOCK_FL_ENABLE (1U << 1) + +/** + * struct c3_isp_params_block_header - C3 ISP parameter block header + * + * This structure represents the common part of all the ISP configuration + * blocks. Each parameters block shall embed an instance of this structure type + * as its first member, followed by the block-specific configuration data. The + * driver inspects this common header to discern the block type and its size and + * properly handle the block content by casting it to the correct block-specific + * type. + * + * The @type field is one of the values enumerated by + * :c:type:`c3_isp_params_block_type` and specifies how the data should be + * interpreted by the driver. The @size field specifies the size of the + * parameters block and is used by the driver for validation purposes. The + * @flags field is a bitmask of per-block flags C3_ISP_PARAMS_FL*. + * + * When userspace wants to disable an ISP block the + * C3_ISP_PARAMS_BLOCK_FL_DISABLED bit should be set in the @flags field. In + * this case userspace may optionally omit the remainder of the configuration + * block, which will be ignored by the driver. + * + * When a new configuration of an ISP block needs to be applied userspace + * shall fully populate the ISP block and omit setting the + * C3_ISP_PARAMS_BLOCK_FL_DISABLED bit in the @flags field. + * + * Userspace is responsible for correctly populating the parameters block header + * fields (@type, @flags and @size) and the block-specific parameters. + * + * For example: + * + * .. code-block:: c + * + *	void populate_pst_gamma(struct c3_isp_params_block_header *block) { + *		struct c3_isp_params_pst_gamma *gamma = + *			(struct c3_isp_params_pst_gamma *)block; + * + *		gamma->header.type = C3_ISP_PARAMS_BLOCK_PST_GAMMA; + *		gamma->header.flags = C3_ISP_PARAMS_BLOCK_FL_ENABLE; + *		gamma->header.size = sizeof(*gamma); + * + *		for (unsigned int i = 0; i < 129; i++) + *			gamma->pst_gamma_lut[i] = i; + *	} + * + * @type: The parameters block type from :c:type:`c3_isp_params_block_type` + * @flags: A bitmask of block flags + * @size: Size (in bytes) of the parameters block, including this header + */ +struct c3_isp_params_block_header { +	__u16 type; +	__u16 flags; +	__u32 size; +}; + +/** + * struct c3_isp_params_awb_gains - Gains for auto-white balance + * + * This struct allows users to configure the gains for white balance. + * There are four gain settings corresponding to each colour channel in + * the bayer domain. All of the gains are stored in Q4.8 format. + * + * header.type should be set to C3_ISP_PARAMS_BLOCK_AWB_GAINS + * from :c:type:`c3_isp_params_block_type` + * + * @header: The C3 ISP parameters block header + * @gr_gain: Multiplier for Gr channel (Q4.8 format) + * @r_gain: Multiplier for R channel (Q4.8 format) + * @b_gain: Multiplier for B channel (Q4.8 format) + * @gb_gain: Multiplier for Gb channel (Q4.8 format) + */ +struct c3_isp_params_awb_gains { +	struct c3_isp_params_block_header header; +	__u16 gr_gain; +	__u16 r_gain; +	__u16 b_gain; +	__u16 gb_gain; +} __attribute__((aligned(8))); + +/** + * enum c3_isp_params_awb_tap_points - Tap points for the AWB statistics + * @C3_ISP_AWB_STATS_TAP_OFE: immediately after the optical frontend block + * @C3_ISP_AWB_STATS_TAP_GE: immediately after the green equal block + * @C3_ISP_AWB_STATS_TAP_BEFORE_WB: immediately before the white balance block + * @C3_ISP_AWB_STATS_TAP_AFTER_WB: immediately after the white balance block + */ +enum c3_isp_params_awb_tap_points { +	C3_ISP_AWB_STATS_TAP_OFE = 0, +	C3_ISP_AWB_STATS_TAP_GE, +	C3_ISP_AWB_STATS_TAP_BEFORE_WB, +	C3_ISP_AWB_STATS_TAP_AFTER_WB, +}; + +/** + * struct c3_isp_params_awb_config - Stats settings for auto-white balance + * + * This struct allows the configuration of the statistics generated for auto + * white balance. + * + * header.type should be set to C3_ISP_PARAMS_BLOCK_AWB_CONFIG + * from :c:type:`c3_isp_params_block_type` + * + * @header: the C3 ISP parameters block header + * @tap_point: the tap point from enum c3_isp_params_awb_tap_point + * @satur_vald: AWB statistic over saturation control + *		value: 0: disable, 1: enable + * @horiz_zones_num: active number of hotizontal zones [0..32] + * @vert_zones_num: active number of vertical zones [0..24] + * @rg_min: minimum R/G ratio (Q4.8 format) + * @rg_max: maximum R/G ratio (Q4.8 format) + * @bg_min: minimum B/G ratio (Q4.8 format) + * @bg_max: maximum B/G ratio (Q4.8 format) + * @rg_low: R/G ratio trim low (Q4.8 format) + * @rg_high: R/G ratio trim hight (Q4.8 format) + * @bg_low: B/G ratio trim low (Q4.8 format) + * @bg_high: B/G ratio trim high (Q4.8 format) + * @zone_weight: array of weights for AWB statistics zones [0..15] + * @horiz_coord: the horizontal coordinate of points on the diagonal [0..2888] + * @vert_coord: the vertical coordinate of points on the diagonal [0..2240] + */ +struct c3_isp_params_awb_config { +	struct c3_isp_params_block_header header; +	__u8 tap_point; +	__u8 satur_vald; +	__u8 horiz_zones_num; +	__u8 vert_zones_num; +	__u16 rg_min; +	__u16 rg_max; +	__u16 bg_min; +	__u16 bg_max; +	__u16 rg_low; +	__u16 rg_high; +	__u16 bg_low; +	__u16 bg_high; +	__u8 zone_weight[C3_ISP_AWB_MAX_ZONES]; +	__u16 horiz_coord[C3_ISP_AWB_MAX_PT_NUM]; +	__u16 vert_coord[C3_ISP_AWB_MAX_PT_NUM]; +} __attribute__((aligned(8))); + +/** + * enum c3_isp_params_ae_tap_points - Tap points for the AE statistics + * @C3_ISP_AE_STATS_TAP_GE: immediately after the green equal block + * @C3_ISP_AE_STATS_TAP_MLS: immediately after the mesh lens shading block + */ +enum c3_isp_params_ae_tap_points { +	C3_ISP_AE_STATS_TAP_GE = 0, +	C3_ISP_AE_STATS_TAP_MLS, +}; + +/** + * struct c3_isp_params_ae_config - Stats settings for auto-exposure + * + * This struct allows the configuration of the statistics generated for + * auto exposure. + * + * header.type should be set to C3_ISP_PARAMS_BLOCK_AE_CONFIG + * from :c:type:`c3_isp_params_block_type` + * + * @header: the C3 ISP parameters block header + * @horiz_zones_num: active number of horizontal zones [0..17] + * @vert_zones_num: active number of vertical zones [0..15] + * @tap_point: the tap point from enum c3_isp_params_ae_tap_point + * @zone_weight: array of weights for AE statistics zones [0..15] + * @horiz_coord: the horizontal coordinate of points on the diagonal [0..2888] + * @vert_coord: the vertical coordinate of points on the diagonal [0..2240] + * @reserved: applications must zero this array + */ +struct c3_isp_params_ae_config { +	struct c3_isp_params_block_header header; +	__u8 tap_point; +	__u8 horiz_zones_num; +	__u8 vert_zones_num; +	__u8 zone_weight[C3_ISP_AE_MAX_ZONES]; +	__u16 horiz_coord[C3_ISP_AE_MAX_PT_NUM]; +	__u16 vert_coord[C3_ISP_AE_MAX_PT_NUM]; +	__u16 reserved[3]; +} __attribute__((aligned(8))); + +/** + * enum c3_isp_params_af_tap_points - Tap points for the AF statistics + * @C3_ISP_AF_STATS_TAP_SNR: immediately after the spatial noise reduce block + * @C3_ISP_AF_STATS_TAP_DMS: immediately after the demosaic block + */ +enum c3_isp_params_af_tap_points { +	C3_ISP_AF_STATS_TAP_SNR = 0, +	C3_ISP_AF_STATS_TAP_DMS, +}; + +/** + * struct c3_isp_params_af_config - Stats settings for auto-focus + * + * This struct allows the configuration of the statistics generated for + * auto focus. + * + * header.type should be set to C3_ISP_PARAMS_BLOCK_AF_CONFIG + * from :c:type:`c3_isp_params_block_type` + * + * @header: the C3 ISP parameters block header + * @tap_point: the tap point from enum c3_isp_params_af_tap_point + * @horiz_zones_num: active number of hotizontal zones [0..17] + * @vert_zones_num: active number of vertical zones [0..15] + * @reserved: applications must zero this array + * @horiz_coord: the horizontal coordinate of points on the diagonal [0..2888] + * @vert_coord: the vertical coordinate of points on the diagonal [0..2240] + */ +struct c3_isp_params_af_config { +	struct c3_isp_params_block_header header; +	__u8 tap_point; +	__u8 horiz_zones_num; +	__u8 vert_zones_num; +	__u8 reserved[5]; +	__u16 horiz_coord[C3_ISP_AF_MAX_PT_NUM]; +	__u16 vert_coord[C3_ISP_AF_MAX_PT_NUM]; +} __attribute__((aligned(8))); + +/** + * struct c3_isp_params_pst_gamma - Post gamma configuration + * + * This struct allows the configuration of the look up table for + * post gamma. The gamma curve consists of 129 points, so need to + * set lut[129]. + * + * header.type should be set to C3_ISP_PARAMS_BLOCK_PST_GAMMA + * from :c:type:`c3_isp_params_block_type` + * + * @header: the C3 ISP parameters block header + * @lut: lookup table for P-Stitch gamma [0..1023] + * @reserved: applications must zero this array + */ +struct c3_isp_params_pst_gamma { +	struct c3_isp_params_block_header header; +	__u16 lut[129]; +	__u16 reserved[3]; +} __attribute__((aligned(8))); + +/** + * struct c3_isp_params_ccm - ISP CCM configuration + * + * This struct allows the configuration of the matrix for + * color correction. The matrix consists of 3 x 3 points, + * so need to set matrix[3][3]. + * + * header.type should be set to C3_ISP_PARAMS_BLOCK_CCM + * from :c:type:`c3_isp_params_block_type` + * + * @header: the C3 ISP parameters block header + * @matrix: a 3 x 3 matrix used for color correction, + *          the value of matrix[x][y] is orig_value x 256. [-4096..4095] + * @reserved: applications must zero this array + */ +struct c3_isp_params_ccm { +	struct c3_isp_params_block_header header; +	__s16 matrix[3][3]; +	__u16 reserved[3]; +} __attribute__((aligned(8))); + +/** + * struct c3_isp_params_csc - ISP Color Space Conversion configuration + * + * This struct allows the configuration of the matrix for color space + * conversion. The matrix consists of 3 x 3 points, so need to set matrix[3][3]. + * + * header.type should be set to C3_ISP_PARAMS_BLOCK_CSC + * from :c:type:`c3_isp_params_block_type` + * + * @header: the C3 ISP parameters block header + * @matrix: a 3x3 matrix used for the color space conversion, + *          the value of matrix[x][y] is orig_value x 256. [-4096..4095] + * @reserved: applications must zero this array + */ +struct c3_isp_params_csc { +	struct c3_isp_params_block_header header; +	__s16 matrix[3][3]; +	__u16 reserved[3]; +} __attribute__((aligned(8))); + +/** + * struct c3_isp_params_blc - ISP Black Level Correction configuration + * + * This struct allows the configuration of the block level offset for each + * color channel. + * + * header.type should be set to C3_ISP_PARAMS_BLOCK_BLC + * from :c:type:`c3_isp_params_block_type` + * + * @header: the C3 ISP parameters block header + * @gr_ofst: Gr blc offset (Q4.12 format) + * @r_ofst: R blc offset (Q4.12 format) + * @b_ofst: B blc offset (Q4.12 format) + * @gb_ofst: Gb blc offset(Q4.12 format) + */ +struct c3_isp_params_blc { +	struct c3_isp_params_block_header header; +	__u16 gr_ofst; +	__u16 r_ofst; +	__u16 b_ofst; +	__u16 gb_ofst; +}; + +/** + * define C3_ISP_PARAMS_MAX_SIZE - Maximum size of all C3 ISP Parameters + * + * Though the parameters for the C3 ISP are passed as optional blocks, the + * driver still needs to know the absolute maximum size so that it can allocate + * a buffer sized appropriately to accommodate userspace attempting to set all + * possible parameters in a single frame. + */ +#define C3_ISP_PARAMS_MAX_SIZE                     \ +	(sizeof(struct c3_isp_params_awb_gains) +  \ +	 sizeof(struct c3_isp_params_awb_config) + \ +	 sizeof(struct c3_isp_params_ae_config) +  \ +	 sizeof(struct c3_isp_params_af_config) +  \ +	 sizeof(struct c3_isp_params_pst_gamma) +  \ +	 sizeof(struct c3_isp_params_ccm) +        \ +	 sizeof(struct c3_isp_params_csc) +        \ +	 sizeof(struct c3_isp_params_blc)) + +/** + * struct c3_isp_params_cfg - C3 ISP configuration parameters + * + * This struct contains the configuration parameters of the C3 ISP + * algorithms, serialized by userspace into an opaque data buffer. Each + * configuration parameter block is represented by a block-specific structure + * which contains a :c:type:`c3_isp_param_block_header` entry as first + * member. Userspace populates the @data buffer with configuration parameters + * for the blocks that it intends to configure. As a consequence, the data + * buffer effective size changes according to the number of ISP blocks that + * userspace intends to configure. + * + * The parameters buffer is versioned by the @version field to allow modifying + * and extending its definition. Userspace should populate the @version field to + * inform the driver about the version it intends to use. The driver will parse + * and handle the @data buffer according to the data layout specific to the + * indicated revision and return an error if the desired revision is not + * supported. + * + * For each ISP block that userspace wants to configure, a block-specific + * structure is appended to the @data buffer, one after the other without gaps + * in between nor overlaps. Userspace shall populate the @total_size field with + * the effective size, in bytes, of the @data buffer. + * + * The expected memory layout of the parameters buffer is:: + * + *	+-------------------- struct c3_isp_params_cfg ---- ------------------+ + *	| version = C3_ISP_PARAM_BUFFER_V0;                                   | + *	| data_size = sizeof(struct c3_isp_params_awb_gains) +                | + *	|              sizeof(struct c3_isp_params_awb_config);       | + *	| +------------------------- data  ---------------------------------+ | + *	| | +------------ struct c3_isp_params_awb_gains) ------------------+ | + *	| | | +---------  struct c3_isp_params_block_header header -----+ | | | + *	| | | | type = C3_ISP_PARAMS_BLOCK_AWB_GAINS;                   | | | | + *	| | | | flags = C3_ISP_PARAMS_BLOCK_FL_NONE;                    | | | | + *	| | | | size = sizeof(struct c3_isp_params_awb_gains);          | | | | + *	| | | +---------------------------------------------------------+ | | | + *	| | | gr_gain = ...;                                              | | | + *	| | | r_gain = ...;                                               | | | + *	| | | b_gain = ...;                                               | | | + *	| | | gb_gain = ...;                                              | | | + *	| | +------------------ struct c3_isp_params_awb_config ----------+ | | + *	| | | +---------- struct c3_isp_param_block_header header ------+ | | | + *	| | | | type = C3_ISP_PARAMS_BLOCK_AWB_CONFIG;                  | | | | + *	| | | | flags = C3_ISP_PARAMS_BLOCK_FL_NONE;                    | | | | + *	| | | | size = sizeof(struct c3_isp_params_awb_config)          | | | | + *	| | | +---------------------------------------------------------+ | | | + *	| | | tap_point = ...;                                            | | | + *	| | | satur_vald = ...;                                           | | | + *	| | | horiz_zones_num = ...;                                      | | | + *	| | | vert_zones_num = ...;                                       | | | + *	| | +-------------------------------------------------------------+ | | + *	| +-----------------------------------------------------------------+ | + *	+---------------------------------------------------------------------+ + * + * @version: The C3 ISP parameters buffer version + * @data_size: The C3 ISP configuration data effective size, excluding this + *             header + * @data: The C3 ISP configuration blocks data + */ +struct c3_isp_params_cfg { +	__u32 version; +	__u32 data_size; +	__u8 data[C3_ISP_PARAMS_MAX_SIZE]; +}; + +#endif diff --git a/include/uapi/linux/media/raspberrypi/pisp_be_config.h b/include/uapi/linux/media/raspberrypi/pisp_be_config.h new file mode 100644 index 000000000000..2ad3b90684d7 --- /dev/null +++ b/include/uapi/linux/media/raspberrypi/pisp_be_config.h @@ -0,0 +1,969 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * PiSP Back End configuration definitions. + * + * Copyright (C) 2021 - Raspberry Pi Ltd + * + */ +#ifndef _UAPI_PISP_BE_CONFIG_H_ +#define _UAPI_PISP_BE_CONFIG_H_ + +#include <linux/types.h> + +#include "pisp_common.h" + +/* byte alignment for inputs */ +#define PISP_BACK_END_INPUT_ALIGN 4u +/* alignment for compressed inputs */ +#define PISP_BACK_END_COMPRESSED_ALIGN 8u +/* minimum required byte alignment for outputs */ +#define PISP_BACK_END_OUTPUT_MIN_ALIGN 16u +/* preferred byte alignment for outputs */ +#define PISP_BACK_END_OUTPUT_MAX_ALIGN 64u + +/* minimum allowed tile sizes anywhere in the pipeline */ +#define PISP_BACK_END_MIN_TILE_WIDTH	16u +#define PISP_BACK_END_MIN_TILE_HEIGHT	16u +#define PISP_BACK_END_MAX_TILE_WIDTH	65536u +#define PISP_BACK_END_MAX_TILE_HEIGHT	65536u + +#define PISP_BACK_END_NUM_OUTPUTS 2 +#define PISP_BACK_END_HOG_OUTPUT 1 + +#define PISP_BACK_END_NUM_TILES 64 + +enum pisp_be_bayer_enable { +	PISP_BE_BAYER_ENABLE_INPUT = 0x000001, +	PISP_BE_BAYER_ENABLE_DECOMPRESS = 0x000002, +	PISP_BE_BAYER_ENABLE_DPC = 0x000004, +	PISP_BE_BAYER_ENABLE_GEQ = 0x000008, +	PISP_BE_BAYER_ENABLE_TDN_INPUT = 0x000010, +	PISP_BE_BAYER_ENABLE_TDN_DECOMPRESS = 0x000020, +	PISP_BE_BAYER_ENABLE_TDN = 0x000040, +	PISP_BE_BAYER_ENABLE_TDN_COMPRESS = 0x000080, +	PISP_BE_BAYER_ENABLE_TDN_OUTPUT = 0x000100, +	PISP_BE_BAYER_ENABLE_SDN = 0x000200, +	PISP_BE_BAYER_ENABLE_BLC = 0x000400, +	PISP_BE_BAYER_ENABLE_STITCH_INPUT = 0x000800, +	PISP_BE_BAYER_ENABLE_STITCH_DECOMPRESS = 0x001000, +	PISP_BE_BAYER_ENABLE_STITCH = 0x002000, +	PISP_BE_BAYER_ENABLE_STITCH_COMPRESS = 0x004000, +	PISP_BE_BAYER_ENABLE_STITCH_OUTPUT = 0x008000, +	PISP_BE_BAYER_ENABLE_WBG = 0x010000, +	PISP_BE_BAYER_ENABLE_CDN = 0x020000, +	PISP_BE_BAYER_ENABLE_LSC = 0x040000, +	PISP_BE_BAYER_ENABLE_TONEMAP = 0x080000, +	PISP_BE_BAYER_ENABLE_CAC = 0x100000, +	PISP_BE_BAYER_ENABLE_DEBIN = 0x200000, +	PISP_BE_BAYER_ENABLE_DEMOSAIC = 0x400000, +}; + +enum pisp_be_rgb_enable { +	PISP_BE_RGB_ENABLE_INPUT = 0x000001, +	PISP_BE_RGB_ENABLE_CCM = 0x000002, +	PISP_BE_RGB_ENABLE_SAT_CONTROL = 0x000004, +	PISP_BE_RGB_ENABLE_YCBCR = 0x000008, +	PISP_BE_RGB_ENABLE_FALSE_COLOUR = 0x000010, +	PISP_BE_RGB_ENABLE_SHARPEN = 0x000020, +	/* Preferred colours would occupy 0x000040 */ +	PISP_BE_RGB_ENABLE_YCBCR_INVERSE = 0x000080, +	PISP_BE_RGB_ENABLE_GAMMA = 0x000100, +	PISP_BE_RGB_ENABLE_CSC0 = 0x000200, +	PISP_BE_RGB_ENABLE_CSC1 = 0x000400, +	PISP_BE_RGB_ENABLE_DOWNSCALE0 = 0x001000, +	PISP_BE_RGB_ENABLE_DOWNSCALE1 = 0x002000, +	PISP_BE_RGB_ENABLE_RESAMPLE0 = 0x008000, +	PISP_BE_RGB_ENABLE_RESAMPLE1 = 0x010000, +	PISP_BE_RGB_ENABLE_OUTPUT0 = 0x040000, +	PISP_BE_RGB_ENABLE_OUTPUT1 = 0x080000, +	PISP_BE_RGB_ENABLE_HOG = 0x200000 +}; + +#define PISP_BE_RGB_ENABLE_CSC(i) (PISP_BE_RGB_ENABLE_CSC0 << (i)) +#define PISP_BE_RGB_ENABLE_DOWNSCALE(i) (PISP_BE_RGB_ENABLE_DOWNSCALE0 << (i)) +#define PISP_BE_RGB_ENABLE_RESAMPLE(i) (PISP_BE_RGB_ENABLE_RESAMPLE0 << (i)) +#define PISP_BE_RGB_ENABLE_OUTPUT(i) (PISP_BE_RGB_ENABLE_OUTPUT0 << (i)) + +/* + * We use the enable flags to show when blocks are "dirty", but we need some + * extra ones too. + */ +enum pisp_be_dirty { +	PISP_BE_DIRTY_GLOBAL = 0x0001, +	PISP_BE_DIRTY_SH_FC_COMBINE = 0x0002, +	PISP_BE_DIRTY_CROP = 0x0004 +}; + +/** + * struct pisp_be_global_config - PiSP global enable bitmaps + * @bayer_enables:	Bayer input enable flags + * @rgb_enables:	RGB output enable flags + * @bayer_order:	Bayer input format ordering + * @pad:		Padding bytes + */ +struct pisp_be_global_config { +	__u32 bayer_enables; +	__u32 rgb_enables; +	__u8 bayer_order; +	__u8 pad[3]; +} __attribute__((packed)); + +/** + * struct pisp_be_input_buffer_config - PiSP Back End input buffer + * @addr:		Input buffer address + */ +struct pisp_be_input_buffer_config { +	/* low 32 bits followed by high 32 bits (for each of up to 3 planes) */ +	__u32 addr[3][2]; +} __attribute__((packed)); + +/** + * struct pisp_be_dpc_config - PiSP Back End DPC config + * + * Defective Pixel Correction configuration + * + * @coeff_level:	Coefficient for the darkest neighbouring pixel value + * @coeff_range:	Coefficient for the range of pixels for this Bayer channel + * @pad:		Padding byte + * @flags:		DPC configuration flags + */ +struct pisp_be_dpc_config { +	__u8 coeff_level; +	__u8 coeff_range; +	__u8 pad; +#define PISP_BE_DPC_FLAG_FOLDBACK 1 +	__u8 flags; +} __attribute__((packed)); + +/** + * struct pisp_be_geq_config - PiSP Back End GEQ config + * + * Green Equalisation configuration + * + * @offset:		Offset value for threshold calculation + * @slope_sharper:	Slope/Sharper configuration + * @min:		Minimum value the threshold may have + * @max:		Maximum value the threshold may have + */ +struct pisp_be_geq_config { +	__u16 offset; +#define PISP_BE_GEQ_SHARPER (1U << 15) +#define PISP_BE_GEQ_SLOPE ((1 << 10) - 1) +	/* top bit is the "sharper" flag, slope value is bottom 10 bits */ +	__u16 slope_sharper; +	__u16 min; +	__u16 max; +} __attribute__((packed)); + +/** + * struct pisp_be_tdn_input_buffer_config - PiSP Back End TDN input buffer + * @addr:		TDN input buffer address + */ +struct pisp_be_tdn_input_buffer_config { +	/* low 32 bits followed by high 32 bits */ +	__u32 addr[2]; +} __attribute__((packed)); + +/** + * struct pisp_be_tdn_config - PiSP Back End TDN config + * + * Temporal Denoise configuration + * + * @black_level:	Black level value subtracted from pixels + * @ratio:		Multiplier for the LTA input frame + * @noise_constant:	Constant offset value used in noise estimation + * @noise_slope:	Noise estimation multiplier + * @threshold:		Threshold for TDN operations + * @reset:		Disable TDN operations + * @pad:		Padding byte + */ +struct pisp_be_tdn_config { +	__u16 black_level; +	__u16 ratio; +	__u16 noise_constant; +	__u16 noise_slope; +	__u16 threshold; +	__u8 reset; +	__u8 pad; +} __attribute__((packed)); + +/** + * struct pisp_be_tdn_output_buffer_config - PiSP Back End TDN output buffer + * @addr:		TDN output buffer address + */ +struct pisp_be_tdn_output_buffer_config { +	/* low 32 bits followed by high 32 bits */ +	__u32 addr[2]; +} __attribute__((packed)); + +/** + * struct pisp_be_sdn_config - PiSP Back End SDN config + * + * Spatial Denoise configuration + * + * @black_level:	Black level subtracted from pixel for noise estimation + * @leakage:		Proportion of the original undenoised value to mix in + *			denoised output + * @pad:		Padding byte + * @noise_constant:	Noise constant used for noise estimation + * @noise_slope:	Noise slope value used for noise estimation + * @noise_constant2:	Second noise constant used for noise estimation + * @noise_slope2:	Second slope value used for noise estimation + */ +struct pisp_be_sdn_config { +	__u16 black_level; +	__u8 leakage; +	__u8 pad; +	__u16 noise_constant; +	__u16 noise_slope; +	__u16 noise_constant2; +	__u16 noise_slope2; +} __attribute__((packed)); + +/** + * struct pisp_be_stitch_input_buffer_config - PiSP Back End Stitch input + * @addr:		Stitch input buffer address + */ +struct pisp_be_stitch_input_buffer_config { +	/* low 32 bits followed by high 32 bits */ +	__u32 addr[2]; +} __attribute__((packed)); + +#define PISP_BE_STITCH_STREAMING_LONG 0x8000 +#define PISP_BE_STITCH_EXPOSURE_RATIO_MASK 0x7fff + +/** + * struct pisp_be_stitch_config - PiSP Back End Stitch config + * + * Stitch block configuration + * + * @threshold_lo:		Low threshold value + * @threshold_diff_power:	Low and high threshold difference + * @pad:			Padding bytes + * @exposure_ratio:		Multiplier to convert long exposure pixels into + *				short exposure pixels + * @motion_threshold_256:	Motion threshold above which short exposure + *				pixels are used + * @motion_threshold_recip:	Reciprocal of motion_threshold_256 value + */ +struct pisp_be_stitch_config { +	__u16 threshold_lo; +	__u8 threshold_diff_power; +	__u8 pad; + +	/* top bit indicates whether streaming input is the long exposure */ +	__u16 exposure_ratio; + +	__u8 motion_threshold_256; +	__u8 motion_threshold_recip; +} __attribute__((packed)); + +/** + * struct pisp_be_stitch_output_buffer_config - PiSP Back End Stitch output + * @addr:		Stitch input buffer address + */ +struct pisp_be_stitch_output_buffer_config { +	/* low 32 bits followed by high 32 bits */ +	__u32 addr[2]; +} __attribute__((packed)); + +/** + * struct pisp_be_cdn_config - PiSP Back End CDN config + * + * Colour Denoise configuration + * + * @thresh:		Constant for noise estimation + * @iir_strength:	Relative strength of the IIR part of the filter + * @g_adjust:		Proportion of the change assigned to the G channel + */ +struct pisp_be_cdn_config { +	__u16 thresh; +	__u8 iir_strength; +	__u8 g_adjust; +} __attribute__((packed)); + +#define PISP_BE_LSC_LOG_GRID_SIZE 5 +#define PISP_BE_LSC_GRID_SIZE (1 << PISP_BE_LSC_LOG_GRID_SIZE) +#define PISP_BE_LSC_STEP_PRECISION 18 + +/** + * struct pisp_be_lsc_config - PiSP Back End LSC config + * + * Lens Shading Correction configuration + * + * @grid_step_x:	Reciprocal of cell size width + * @grid_step_y:	Reciprocal of cell size height + * @lut_packed:		Jointly-coded RGB gains for each LSC grid + */ +struct pisp_be_lsc_config { +	/* (1<<18) / grid_cell_width */ +	__u16 grid_step_x; +	/* (1<<18) / grid_cell_height */ +	__u16 grid_step_y; +	/* RGB gains jointly encoded in 32 bits */ +#define PISP_BE_LSC_LUT_SIZE	(PISP_BE_LSC_GRID_SIZE + 1) +	__u32 lut_packed[PISP_BE_LSC_LUT_SIZE][PISP_BE_LSC_LUT_SIZE]; +} __attribute__((packed)); + +/** + * struct pisp_be_lsc_extra - PiSP Back End LSC Extra config + * @offset_x:		Horizontal offset into the LSC table of this tile + * @offset_y:		Vertical offset into the LSC table of this tile + */ +struct pisp_be_lsc_extra { +	__u16 offset_x; +	__u16 offset_y; +} __attribute__((packed)); + +#define PISP_BE_CAC_LOG_GRID_SIZE 3 +#define PISP_BE_CAC_GRID_SIZE (1 << PISP_BE_CAC_LOG_GRID_SIZE) +#define PISP_BE_CAC_STEP_PRECISION 20 + +/** + * struct pisp_be_cac_config - PiSP Back End CAC config + * + * Chromatic Aberration Correction config + * + * @grid_step_x:	Reciprocal of cell size width + * @grid_step_y:	Reciprocal of cell size height + * @lut:		Pixel shift for the CAC grid + */ +struct pisp_be_cac_config { +	/* (1<<20) / grid_cell_width */ +	__u16 grid_step_x; +	/* (1<<20) / grid_cell_height */ +	__u16 grid_step_y; +	/* [gridy][gridx][rb][xy] */ +#define PISP_BE_CAC_LUT_SIZE		(PISP_BE_CAC_GRID_SIZE + 1) +	__s8 lut[PISP_BE_CAC_LUT_SIZE][PISP_BE_CAC_LUT_SIZE][2][2]; +} __attribute__((packed)); + +/** + * struct pisp_be_cac_extra - PiSP Back End CAC extra config + * @offset_x:		Horizontal offset into the CAC table of this tile + * @offset_y:		Horizontal offset into the CAC table of this tile + */ +struct pisp_be_cac_extra { +	__u16 offset_x; +	__u16 offset_y; +} __attribute__((packed)); + +#define PISP_BE_DEBIN_NUM_COEFFS 4 + +/** + * struct pisp_be_debin_config - PiSP Back End Debin config + * + * Debinning configuration + * + * @coeffs:		Filter coefficients for debinning + * @h_enable:		Horizontal debinning enable + * @v_enable:		Vertical debinning enable + * @pad:		Padding bytes + */ +struct pisp_be_debin_config { +	__s8 coeffs[PISP_BE_DEBIN_NUM_COEFFS]; +	__s8 h_enable; +	__s8 v_enable; +	__s8 pad[2]; +} __attribute__((packed)); + +#define PISP_BE_TONEMAP_LUT_SIZE 64 + +/** + * struct pisp_be_tonemap_config - PiSP Back End Tonemap config + * + * Tonemapping configuration + * + * @detail_constant:	Constant value for threshold calculation + * @detail_slope:	Slope value for threshold calculation + * @iir_strength:	Relative strength of the IIR fiter + * @strength:		Strength factor + * @lut:		Look-up table for tonemap curve + */ +struct pisp_be_tonemap_config { +	__u16 detail_constant; +	__u16 detail_slope; +	__u16 iir_strength; +	__u16 strength; +	__u32 lut[PISP_BE_TONEMAP_LUT_SIZE]; +} __attribute__((packed)); + +/** + * struct pisp_be_demosaic_config - PiSP Back End Demosaic config + * + * Demosaic configuration + * + * @sharper:		Use other Bayer channels to increase sharpness + * @fc_mode:		Built-in false colour suppression mode + * @pad:		Padding bytes + */ +struct pisp_be_demosaic_config { +	__u8 sharper; +	__u8 fc_mode; +	__u8 pad[2]; +} __attribute__((packed)); + +/** + * struct pisp_be_ccm_config - PiSP Back End CCM config + * + * Colour Correction Matrix configuration + * + * @coeffs:		Matrix coefficients + * @pad:		Padding bytes + * @offsets:		Offsets triplet + */ +struct pisp_be_ccm_config { +	__s16 coeffs[9]; +	__u8 pad[2]; +	__s32 offsets[3]; +} __attribute__((packed)); + +/** + * struct pisp_be_sat_control_config - PiSP Back End SAT config + * + * Saturation Control configuration + * + * @shift_r:		Left shift for Red colour channel + * @shift_g:		Left shift for Green colour channel + * @shift_b:		Left shift for Blue colour channel + * @pad:		Padding byte + */ +struct pisp_be_sat_control_config { +	__u8 shift_r; +	__u8 shift_g; +	__u8 shift_b; +	__u8 pad; +} __attribute__((packed)); + +/** + * struct pisp_be_false_colour_config - PiSP Back End False Colour config + * + * False Colour configuration + * + * @distance:		Distance of neighbouring pixels, either 1 or 2 + * @pad:		Padding bytes + */ +struct pisp_be_false_colour_config { +	__u8 distance; +	__u8 pad[3]; +} __attribute__((packed)); + +#define PISP_BE_SHARPEN_SIZE 5 +#define PISP_BE_SHARPEN_FUNC_NUM_POINTS 9 + +/** + * struct pisp_be_sharpen_config - PiSP Back End Sharpening config + * + * Sharpening configuration + * + * @kernel0:		Coefficient for filter 0 + * @pad0:		Padding byte + * @kernel1:		Coefficient for filter 1 + * @pad1:		Padding byte + * @kernel2:		Coefficient for filter 2 + * @pad2:		Padding byte + * @kernel3:		Coefficient for filter 3 + * @pad3:		Padding byte + * @kernel4:		Coefficient for filter 4 + * @pad4:		Padding byte + * @threshold_offset0:	Offset for filter 0 response calculation + * @threshold_slope0:	Slope multiplier for the filter 0 response calculation + * @scale0:		Scale factor for filter 0 response calculation + * @pad5:		Padding byte + * @threshold_offset1:	Offset for filter 0 response calculation + * @threshold_slope1:	Slope multiplier for the filter 0 response calculation + * @scale1:		Scale factor for filter 0 response calculation + * @pad6:		Padding byte + * @threshold_offset2:	Offset for filter 0 response calculation + * @threshold_slope2:	Slope multiplier for the filter 0 response calculation + * @scale2:		Scale factor for filter 0 response calculation + * @pad7:		Padding byte + * @threshold_offset3:	Offset for filter 0 response calculation + * @threshold_slope3:	Slope multiplier for the filter 0 response calculation + * @scale3:		Scale factor for filter 0 response calculation + * @pad8:		Padding byte + * @threshold_offset4:	Offset for filter 0 response calculation + * @threshold_slope4:	Slope multiplier for the filter 0 response calculation + * @scale4:		Scale factor for filter 0 response calculation + * @pad9:		Padding byte + * @positive_strength:	Factor to scale the positive sharpening strength + * @positive_pre_limit:	Maximum allowed possible positive sharpening value + * @positive_func:	Gain factor applied to positive sharpening response + * @positive_limit:	Final gain factor applied to positive sharpening + * @negative_strength:	Factor to scale the negative sharpening strength + * @negative_pre_limit:	Maximum allowed possible negative sharpening value + * @negative_func:	Gain factor applied to negative sharpening response + * @negative_limit:	Final gain factor applied to negative sharpening + * @enables:		Filter enable mask + * @white:		White output pixel filter mask + * @black:		Black output pixel filter mask + * @grey:		Grey output pixel filter mask + */ +struct pisp_be_sharpen_config { +	__s8 kernel0[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE]; +	__s8 pad0[3]; +	__s8 kernel1[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE]; +	__s8 pad1[3]; +	__s8 kernel2[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE]; +	__s8 pad2[3]; +	__s8 kernel3[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE]; +	__s8 pad3[3]; +	__s8 kernel4[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE]; +	__s8 pad4[3]; +	__u16 threshold_offset0; +	__u16 threshold_slope0; +	__u16 scale0; +	__u16 pad5; +	__u16 threshold_offset1; +	__u16 threshold_slope1; +	__u16 scale1; +	__u16 pad6; +	__u16 threshold_offset2; +	__u16 threshold_slope2; +	__u16 scale2; +	__u16 pad7; +	__u16 threshold_offset3; +	__u16 threshold_slope3; +	__u16 scale3; +	__u16 pad8; +	__u16 threshold_offset4; +	__u16 threshold_slope4; +	__u16 scale4; +	__u16 pad9; +	__u16 positive_strength; +	__u16 positive_pre_limit; +	__u16 positive_func[PISP_BE_SHARPEN_FUNC_NUM_POINTS]; +	__u16 positive_limit; +	__u16 negative_strength; +	__u16 negative_pre_limit; +	__u16 negative_func[PISP_BE_SHARPEN_FUNC_NUM_POINTS]; +	__u16 negative_limit; +	__u8 enables; +	__u8 white; +	__u8 black; +	__u8 grey; +} __attribute__((packed)); + +/** + * struct pisp_be_sh_fc_combine_config - PiSP Back End Sharpening and + *					 False Colour config + * + * Sharpening and False Colour configuration + * + * @y_factor:		Control amount of desaturation of pixels being darkened + * @c1_factor:		Control amount of brightening of a pixel for the Cb + *			channel + * @c2_factor:		Control amount of brightening of a pixel for the Cr + *			channel + * @pad:		Padding byte + */ +struct pisp_be_sh_fc_combine_config { +	__u8 y_factor; +	__u8 c1_factor; +	__u8 c2_factor; +	__u8 pad; +} __attribute__((packed)); + +#define PISP_BE_GAMMA_LUT_SIZE 64 + +/** + * struct pisp_be_gamma_config - PiSP Back End Gamma configuration + * @lut:		Gamma curve look-up table + */ +struct pisp_be_gamma_config { +	__u32 lut[PISP_BE_GAMMA_LUT_SIZE]; +} __attribute__((packed)); + +/** + * struct pisp_be_crop_config - PiSP Back End Crop config + * + * Crop configuration + * + * @offset_x:		Number of pixels cropped from the left of the tile + * @offset_y:		Number of pixels cropped from the top of the tile + * @width:		Width of the cropped tile output + * @height:		Height of the cropped tile output + */ +struct pisp_be_crop_config { +	__u16 offset_x, offset_y; +	__u16 width, height; +} __attribute__((packed)); + +#define PISP_BE_RESAMPLE_FILTER_SIZE 96 + +/** + * struct pisp_be_resample_config - PiSP Back End Resampling config + * + * Resample configuration + * + * @scale_factor_h:	Horizontal scale factor + * @scale_factor_v:	Vertical scale factor + * @coef:		Resample coefficients + */ +struct pisp_be_resample_config { +	__u16 scale_factor_h, scale_factor_v; +	__s16 coef[PISP_BE_RESAMPLE_FILTER_SIZE]; +} __attribute__((packed)); + +/** + * struct pisp_be_resample_extra - PiSP Back End Resample config + * + * Resample configuration + * + * @scaled_width:	Width in pixels of the scaled output + * @scaled_height:	Height in pixels of the scaled output + * @initial_phase_h:	Initial horizontal phase + * @initial_phase_v:	Initial vertical phase + */ +struct pisp_be_resample_extra { +	__u16 scaled_width; +	__u16 scaled_height; +	__s16 initial_phase_h[3]; +	__s16 initial_phase_v[3]; +} __attribute__((packed)); + +/** + * struct pisp_be_downscale_config - PiSP Back End Downscale config + * + * Downscale configuration + * + * @scale_factor_h:	Horizontal scale factor + * @scale_factor_v:	Vertical scale factor + * @scale_recip_h:	Horizontal reciprocal factor + * @scale_recip_v:	Vertical reciprocal factor + */ +struct pisp_be_downscale_config { +	__u16 scale_factor_h; +	__u16 scale_factor_v; +	__u16 scale_recip_h; +	__u16 scale_recip_v; +} __attribute__((packed)); + +/** + * struct pisp_be_downscale_extra - PiSP Back End Downscale Extra config + * @scaled_width:	Scaled image width + * @scaled_height:	Scaled image height + */ +struct pisp_be_downscale_extra { +	__u16 scaled_width; +	__u16 scaled_height; +} __attribute__((packed)); + +/** + * struct pisp_be_hog_config - PiSP Back End HOG config + * + * Histogram of Oriented Gradients configuration + * + * @compute_signed:	Set 0 for unsigned gradients, 1 for signed + * @channel_mix:	Channels proportions to use + * @stride:		Stride in bytes between blocks directly below + */ +struct pisp_be_hog_config { +	__u8 compute_signed; +	__u8 channel_mix[3]; +	__u32 stride; +} __attribute__((packed)); + +struct pisp_be_axi_config { +	__u8 r_qos; /* Read QoS */ +	__u8 r_cache_prot; /* Read { prot[2:0], cache[3:0] } */ +	__u8 w_qos; /* Write QoS */ +	__u8 w_cache_prot; /* Write { prot[2:0], cache[3:0] } */ +} __attribute__((packed)); + +/** + * enum pisp_be_transform - PiSP Back End Transform flags + * @PISP_BE_TRANSFORM_NONE:	No transform + * @PISP_BE_TRANSFORM_HFLIP:	Horizontal flip + * @PISP_BE_TRANSFORM_VFLIP:	Vertical flip + * @PISP_BE_TRANSFORM_ROT180:	180 degress rotation + */ +enum pisp_be_transform { +	PISP_BE_TRANSFORM_NONE = 0x0, +	PISP_BE_TRANSFORM_HFLIP = 0x1, +	PISP_BE_TRANSFORM_VFLIP = 0x2, +	PISP_BE_TRANSFORM_ROT180 = +		(PISP_BE_TRANSFORM_HFLIP | PISP_BE_TRANSFORM_VFLIP) +}; + +struct pisp_be_output_format_config { +	struct pisp_image_format_config image; +	__u8 transform; +	__u8 pad[3]; +	__u16 lo; +	__u16 hi; +	__u16 lo2; +	__u16 hi2; +} __attribute__((packed)); + +/** + * struct pisp_be_output_buffer_config - PiSP Back End Output buffer + * @addr:		Output buffer address + */ +struct pisp_be_output_buffer_config { +	/* low 32 bits followed by high 32 bits (for each of 3 planes) */ +	__u32 addr[3][2]; +} __attribute__((packed)); + +/** + * struct pisp_be_hog_buffer_config - PiSP Back End HOG buffer + * @addr:		HOG buffer address + */ +struct pisp_be_hog_buffer_config { +	/* low 32 bits followed by high 32 bits */ +	__u32 addr[2]; +} __attribute__((packed)); + +/** + * struct pisp_be_config - RaspberryPi PiSP Back End Processing configuration + * + * @input_buffer:		Input buffer addresses + * @tdn_input_buffer:		TDN input buffer addresses + * @stitch_input_buffer:	Stitch input buffer addresses + * @tdn_output_buffer:		TDN output buffer addresses + * @stitch_output_buffer:	Stitch output buffer addresses + * @output_buffer:		Output buffers addresses + * @hog_buffer:			HOG buffer addresses + * @global:			Global PiSP configuration + * @input_format:		Input image format + * @decompress:			Decompress configuration + * @dpc:			Defective Pixel Correction configuration + * @geq:			Green Equalisation configuration + * @tdn_input_format:		Temporal Denoise input format + * @tdn_decompress:		Temporal Denoise decompress configuration + * @tdn:			Temporal Denoise configuration + * @tdn_compress:		Temporal Denoise compress configuration + * @tdn_output_format:		Temporal Denoise output format + * @sdn:			Spatial Denoise configuration + * @blc:			Black Level Correction configuration + * @stitch_compress:		Stitch compress configuration + * @stitch_output_format:	Stitch output format + * @stitch_input_format:	Stitch input format + * @stitch_decompress:		Stitch decompress configuration + * @stitch:			Stitch configuration + * @lsc:			Lens Shading Correction configuration + * @wbg:			White Balance Gain configuration + * @cdn:			Colour Denoise configuration + * @cac:			Colour Aberration Correction configuration + * @debin:			Debinning configuration + * @tonemap:			Tonemapping configuration + * @demosaic:			Demosaicing configuration + * @ccm:			Colour Correction Matrix configuration + * @sat_control:		Saturation Control configuration + * @ycbcr:			YCbCr colour correction configuration + * @sharpen:			Sharpening configuration + * @false_colour:		False colour correction + * @sh_fc_combine:		Sharpening and False Colour correction + * @ycbcr_inverse:		Inverse YCbCr colour correction + * @gamma:			Gamma curve configuration + * @csc:			Color Space Conversion configuration + * @downscale:			Downscale configuration + * @resample:			Resampling configuration + * @output_format:		Output format configuration + * @hog:			HOG configuration + * @axi:			AXI bus configuration + * @lsc_extra:			LSC extra info + * @cac_extra:			CAC extra info + * @downscale_extra:		Downscaler extra info + * @resample_extra:		Resample extra info + * @crop:			Crop configuration + * @hog_format:			HOG format info + * @dirty_flags_bayer:		Bayer enable dirty flags + *				(:c:type:`pisp_be_bayer_enable`) + * @dirty_flags_rgb:		RGB enable dirty flags + *				(:c:type:`pisp_be_rgb_enable`) + * @dirty_flags_extra:		Extra dirty flags + */ +struct pisp_be_config { +	/* I/O configuration: */ +	struct pisp_be_input_buffer_config input_buffer; +	struct pisp_be_tdn_input_buffer_config tdn_input_buffer; +	struct pisp_be_stitch_input_buffer_config stitch_input_buffer; +	struct pisp_be_tdn_output_buffer_config tdn_output_buffer; +	struct pisp_be_stitch_output_buffer_config stitch_output_buffer; +	struct pisp_be_output_buffer_config +				output_buffer[PISP_BACK_END_NUM_OUTPUTS]; +	struct pisp_be_hog_buffer_config hog_buffer; +	/* Processing configuration: */ +	struct pisp_be_global_config global; +	struct pisp_image_format_config input_format; +	struct pisp_decompress_config decompress; +	struct pisp_be_dpc_config dpc; +	struct pisp_be_geq_config geq; +	struct pisp_image_format_config tdn_input_format; +	struct pisp_decompress_config tdn_decompress; +	struct pisp_be_tdn_config tdn; +	struct pisp_compress_config tdn_compress; +	struct pisp_image_format_config tdn_output_format; +	struct pisp_be_sdn_config sdn; +	struct pisp_bla_config blc; +	struct pisp_compress_config stitch_compress; +	struct pisp_image_format_config stitch_output_format; +	struct pisp_image_format_config stitch_input_format; +	struct pisp_decompress_config stitch_decompress; +	struct pisp_be_stitch_config stitch; +	struct pisp_be_lsc_config lsc; +	struct pisp_wbg_config wbg; +	struct pisp_be_cdn_config cdn; +	struct pisp_be_cac_config cac; +	struct pisp_be_debin_config debin; +	struct pisp_be_tonemap_config tonemap; +	struct pisp_be_demosaic_config demosaic; +	struct pisp_be_ccm_config ccm; +	struct pisp_be_sat_control_config sat_control; +	struct pisp_be_ccm_config ycbcr; +	struct pisp_be_sharpen_config sharpen; +	struct pisp_be_false_colour_config false_colour; +	struct pisp_be_sh_fc_combine_config sh_fc_combine; +	struct pisp_be_ccm_config ycbcr_inverse; +	struct pisp_be_gamma_config gamma; +	struct pisp_be_ccm_config csc[PISP_BACK_END_NUM_OUTPUTS]; +	struct pisp_be_downscale_config downscale[PISP_BACK_END_NUM_OUTPUTS]; +	struct pisp_be_resample_config resample[PISP_BACK_END_NUM_OUTPUTS]; +	struct pisp_be_output_format_config +				output_format[PISP_BACK_END_NUM_OUTPUTS]; +	struct pisp_be_hog_config hog; +	struct pisp_be_axi_config axi; +	/* Non-register fields: */ +	struct pisp_be_lsc_extra lsc_extra; +	struct pisp_be_cac_extra cac_extra; +	struct pisp_be_downscale_extra +				downscale_extra[PISP_BACK_END_NUM_OUTPUTS]; +	struct pisp_be_resample_extra resample_extra[PISP_BACK_END_NUM_OUTPUTS]; +	struct pisp_be_crop_config crop; +	struct pisp_image_format_config hog_format; +	__u32 dirty_flags_bayer; /* these use pisp_be_bayer_enable */ +	__u32 dirty_flags_rgb; /* use pisp_be_rgb_enable */ +	__u32 dirty_flags_extra; /* these use pisp_be_dirty_t */ +} __attribute__((packed)); + +/** + * enum pisp_tile_edge - PiSP Back End Tile position + * @PISP_LEFT_EDGE:		Left edge tile + * @PISP_RIGHT_EDGE:		Right edge tile + * @PISP_TOP_EDGE:		Top edge tile + * @PISP_BOTTOM_EDGE:		Bottom edge tile + */ +enum pisp_tile_edge { +	PISP_LEFT_EDGE = (1 << 0), +	PISP_RIGHT_EDGE = (1 << 1), +	PISP_TOP_EDGE = (1 << 2), +	PISP_BOTTOM_EDGE = (1 << 3) +}; + +/** + * struct pisp_tile - Raspberry Pi PiSP Back End tile configuration + * + * Tile parameters: each set of tile parameters is a 160-bytes block of data + * which contains the tile processing parameters. + * + * @edge:			Edge tile flag + * @pad0:			Padding bytes + * @input_addr_offset:		Top-left pixel offset, in bytes + * @input_addr_offset2:		Top-left pixel offset, in bytes for the second/ + *				third image planes + * @input_offset_x:		Horizontal offset in pixels of this tile in the + *				input image + * @input_offset_y:		Vertical offset in pixels of this tile in the + *				input image + * @input_width:		Width in pixels of this tile + * @input_height:		Height in pixels of the this tile + * @tdn_input_addr_offset:	TDN input image offset, in bytes + * @tdn_output_addr_offset:	TDN output image offset, in bytes + * @stitch_input_addr_offset:	Stitch input image offset, in bytes + * @stitch_output_addr_offset:	Stitch output image offset, in bytes + * @lsc_grid_offset_x:		Horizontal offset in the LSC table for this tile + * @lsc_grid_offset_y:		Vertical offset in the LSC table for this tile + * @cac_grid_offset_x:		Horizontal offset in the CAC table for this tile + * @cac_grid_offset_y:		Horizontal offset in the CAC table for this tile + * @crop_x_start:		Number of pixels cropped from the left of the + *				tile + * @crop_x_end:			Number of pixels cropped from the right of the + *				tile + * @crop_y_start:		Number of pixels cropped from the top of the + *				tile + * @crop_y_end:			Number of pixels cropped from the bottom of the + *				tile + * @downscale_phase_x:		Initial horizontal phase in pixels + * @downscale_phase_y:		Initial vertical phase in pixels + * @resample_in_width:		Width in pixels of the tile entering the + *				Resample block + * @resample_in_height:		Height in pixels of the tile entering the + *				Resample block + * @resample_phase_x:		Initial horizontal phase for the Resample block + * @resample_phase_y:		Initial vertical phase for the Resample block + * @output_offset_x:		Horizontal offset in pixels where the tile will + *				be written into the output image + * @output_offset_y:		Vertical offset in pixels where the tile will be + *				written into the output image + * @output_width:		Width in pixels in the output image of this tile + * @output_height:		Height in pixels in the output image of this tile + * @output_addr_offset:		Offset in bytes into the output buffer + * @output_addr_offset2:	Offset in bytes into the output buffer for the + *				second and third plane + * @output_hog_addr_offset:	Offset in bytes into the HOG buffer where + *				results of this tile are to be written + */ +struct pisp_tile { +	__u8 edge; /* enum pisp_tile_edge */ +	__u8 pad0[3]; +	/* 4 bytes */ +	__u32 input_addr_offset; +	__u32 input_addr_offset2; +	__u16 input_offset_x; +	__u16 input_offset_y; +	__u16 input_width; +	__u16 input_height; +	/* 20 bytes */ +	__u32 tdn_input_addr_offset; +	__u32 tdn_output_addr_offset; +	__u32 stitch_input_addr_offset; +	__u32 stitch_output_addr_offset; +	/* 36 bytes */ +	__u32 lsc_grid_offset_x; +	__u32 lsc_grid_offset_y; +	/* 44 bytes */ +	__u32 cac_grid_offset_x; +	__u32 cac_grid_offset_y; +	/* 52 bytes */ +	__u16 crop_x_start[PISP_BACK_END_NUM_OUTPUTS]; +	__u16 crop_x_end[PISP_BACK_END_NUM_OUTPUTS]; +	__u16 crop_y_start[PISP_BACK_END_NUM_OUTPUTS]; +	__u16 crop_y_end[PISP_BACK_END_NUM_OUTPUTS]; +	/* 68 bytes */ +	/* Ordering is planes then branches */ +	__u16 downscale_phase_x[3 * PISP_BACK_END_NUM_OUTPUTS]; +	__u16 downscale_phase_y[3 * PISP_BACK_END_NUM_OUTPUTS]; +	/* 92 bytes */ +	__u16 resample_in_width[PISP_BACK_END_NUM_OUTPUTS]; +	__u16 resample_in_height[PISP_BACK_END_NUM_OUTPUTS]; +	/* 100 bytes */ +	/* Ordering is planes then branches */ +	__u16 resample_phase_x[3 * PISP_BACK_END_NUM_OUTPUTS]; +	__u16 resample_phase_y[3 * PISP_BACK_END_NUM_OUTPUTS]; +	/* 124 bytes */ +	__u16 output_offset_x[PISP_BACK_END_NUM_OUTPUTS]; +	__u16 output_offset_y[PISP_BACK_END_NUM_OUTPUTS]; +	__u16 output_width[PISP_BACK_END_NUM_OUTPUTS]; +	__u16 output_height[PISP_BACK_END_NUM_OUTPUTS]; +	/* 140 bytes */ +	__u32 output_addr_offset[PISP_BACK_END_NUM_OUTPUTS]; +	__u32 output_addr_offset2[PISP_BACK_END_NUM_OUTPUTS]; +	/* 156 bytes */ +	__u32 output_hog_addr_offset; +	/* 160 bytes */ +} __attribute__((packed)); + +/** + * struct pisp_be_tiles_config - Raspberry Pi PiSP Back End configuration + * @tiles:	Tile descriptors + * @num_tiles:	Number of tiles + * @config:	PiSP Back End configuration + */ +struct pisp_be_tiles_config { +	struct pisp_be_config config; +	struct pisp_tile tiles[PISP_BACK_END_NUM_TILES]; +	__u32 num_tiles; +} __attribute__((packed)); + +#endif /* _UAPI_PISP_BE_CONFIG_H_ */ diff --git a/include/uapi/linux/media/raspberrypi/pisp_common.h b/include/uapi/linux/media/raspberrypi/pisp_common.h new file mode 100644 index 000000000000..cbdccfed1261 --- /dev/null +++ b/include/uapi/linux/media/raspberrypi/pisp_common.h @@ -0,0 +1,202 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * RP1 PiSP common definitions. + * + * Copyright (C) 2021 - Raspberry Pi Ltd. + * + */ +#ifndef _UAPI_PISP_COMMON_H_ +#define _UAPI_PISP_COMMON_H_ + +#include <linux/types.h> + +struct pisp_image_format_config { +	/* size in pixels */ +	__u16 width; +	__u16 height; +	/* must match struct pisp_image_format below */ +	__u32 format; +	__s32 stride; +	/* some planar image formats will need a second stride */ +	__s32 stride2; +} __attribute__((packed)); + +enum pisp_bayer_order { +	/* +	 * Note how bayer_order&1 tells you if G is on the even pixels of the +	 * checkerboard or not, and bayer_order&2 tells you if R is on the even +	 * rows or is swapped with B. Note that if the top (of the 8) bits is +	 * set, this denotes a monochrome or greyscale image, and the lower bits +	 * should all be ignored. +	 */ +	PISP_BAYER_ORDER_RGGB = 0, +	PISP_BAYER_ORDER_GBRG = 1, +	PISP_BAYER_ORDER_BGGR = 2, +	PISP_BAYER_ORDER_GRBG = 3, +	PISP_BAYER_ORDER_GREYSCALE = 128 +}; + +enum pisp_image_format { +	/* +	 * Precise values are mostly tbd. Generally these will be portmanteau +	 * values comprising bit fields and flags. This format must be shared +	 * throughout the PiSP. +	 */ +	PISP_IMAGE_FORMAT_BPS_8 = 0x00000000, +	PISP_IMAGE_FORMAT_BPS_10 = 0x00000001, +	PISP_IMAGE_FORMAT_BPS_12 = 0x00000002, +	PISP_IMAGE_FORMAT_BPS_16 = 0x00000003, +	PISP_IMAGE_FORMAT_BPS_MASK = 0x00000003, + +	PISP_IMAGE_FORMAT_PLANARITY_INTERLEAVED = 0x00000000, +	PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR = 0x00000010, +	PISP_IMAGE_FORMAT_PLANARITY_PLANAR = 0x00000020, +	PISP_IMAGE_FORMAT_PLANARITY_MASK = 0x00000030, + +	PISP_IMAGE_FORMAT_SAMPLING_444 = 0x00000000, +	PISP_IMAGE_FORMAT_SAMPLING_422 = 0x00000100, +	PISP_IMAGE_FORMAT_SAMPLING_420 = 0x00000200, +	PISP_IMAGE_FORMAT_SAMPLING_MASK = 0x00000300, + +	PISP_IMAGE_FORMAT_ORDER_NORMAL = 0x00000000, +	PISP_IMAGE_FORMAT_ORDER_SWAPPED = 0x00001000, + +	PISP_IMAGE_FORMAT_SHIFT_0 = 0x00000000, +	PISP_IMAGE_FORMAT_SHIFT_1 = 0x00010000, +	PISP_IMAGE_FORMAT_SHIFT_2 = 0x00020000, +	PISP_IMAGE_FORMAT_SHIFT_3 = 0x00030000, +	PISP_IMAGE_FORMAT_SHIFT_4 = 0x00040000, +	PISP_IMAGE_FORMAT_SHIFT_5 = 0x00050000, +	PISP_IMAGE_FORMAT_SHIFT_6 = 0x00060000, +	PISP_IMAGE_FORMAT_SHIFT_7 = 0x00070000, +	PISP_IMAGE_FORMAT_SHIFT_8 = 0x00080000, +	PISP_IMAGE_FORMAT_SHIFT_MASK = 0x000f0000, + +	PISP_IMAGE_FORMAT_BPP_32 = 0x00100000, + +	PISP_IMAGE_FORMAT_UNCOMPRESSED = 0x00000000, +	PISP_IMAGE_FORMAT_COMPRESSION_MODE_1 = 0x01000000, +	PISP_IMAGE_FORMAT_COMPRESSION_MODE_2 = 0x02000000, +	PISP_IMAGE_FORMAT_COMPRESSION_MODE_3 = 0x03000000, +	PISP_IMAGE_FORMAT_COMPRESSION_MASK = 0x03000000, + +	PISP_IMAGE_FORMAT_HOG_SIGNED = 0x04000000, +	PISP_IMAGE_FORMAT_HOG_UNSIGNED = 0x08000000, +	PISP_IMAGE_FORMAT_INTEGRAL_IMAGE = 0x10000000, +	PISP_IMAGE_FORMAT_WALLPAPER_ROLL = 0x20000000, +	PISP_IMAGE_FORMAT_THREE_CHANNEL = 0x40000000, + +	/* Lastly a few specific instantiations of the above. */ +	PISP_IMAGE_FORMAT_SINGLE_16 = PISP_IMAGE_FORMAT_BPS_16, +	PISP_IMAGE_FORMAT_THREE_16 = PISP_IMAGE_FORMAT_BPS_16 | +				     PISP_IMAGE_FORMAT_THREE_CHANNEL +}; + +#define PISP_IMAGE_FORMAT_BPS_8(fmt)                                           \ +	(((fmt) & PISP_IMAGE_FORMAT_BPS_MASK) == PISP_IMAGE_FORMAT_BPS_8) +#define PISP_IMAGE_FORMAT_BPS_10(fmt)                                          \ +	(((fmt) & PISP_IMAGE_FORMAT_BPS_MASK) == PISP_IMAGE_FORMAT_BPS_10) +#define PISP_IMAGE_FORMAT_BPS_12(fmt)                                          \ +	(((fmt) & PISP_IMAGE_FORMAT_BPS_MASK) == PISP_IMAGE_FORMAT_BPS_12) +#define PISP_IMAGE_FORMAT_BPS_16(fmt)                                          \ +	(((fmt) & PISP_IMAGE_FORMAT_BPS_MASK) == PISP_IMAGE_FORMAT_BPS_16) +#define PISP_IMAGE_FORMAT_BPS(fmt)                                             \ +	(((fmt) & PISP_IMAGE_FORMAT_BPS_MASK) ?                                \ +	       8 + (2 << (((fmt) & PISP_IMAGE_FORMAT_BPS_MASK) - 1)) : 8) +#define PISP_IMAGE_FORMAT_SHIFT(fmt)                                           \ +	(((fmt) & PISP_IMAGE_FORMAT_SHIFT_MASK) / PISP_IMAGE_FORMAT_SHIFT_1) +#define PISP_IMAGE_FORMAT_THREE_CHANNEL(fmt)                                   \ +	((fmt) & PISP_IMAGE_FORMAT_THREE_CHANNEL) +#define PISP_IMAGE_FORMAT_SINGLE_CHANNEL(fmt)                                  \ +	(!((fmt) & PISP_IMAGE_FORMAT_THREE_CHANNEL)) +#define PISP_IMAGE_FORMAT_COMPRESSED(fmt)                                      \ +	(((fmt) & PISP_IMAGE_FORMAT_COMPRESSION_MASK) !=                       \ +	 PISP_IMAGE_FORMAT_UNCOMPRESSED) +#define PISP_IMAGE_FORMAT_SAMPLING_444(fmt)                                    \ +	(((fmt) & PISP_IMAGE_FORMAT_SAMPLING_MASK) ==                          \ +	 PISP_IMAGE_FORMAT_SAMPLING_444) +#define PISP_IMAGE_FORMAT_SAMPLING_422(fmt)                                    \ +	(((fmt) & PISP_IMAGE_FORMAT_SAMPLING_MASK) ==                          \ +	 PISP_IMAGE_FORMAT_SAMPLING_422) +#define PISP_IMAGE_FORMAT_SAMPLING_420(fmt)                                    \ +	(((fmt) & PISP_IMAGE_FORMAT_SAMPLING_MASK) ==                          \ +	 PISP_IMAGE_FORMAT_SAMPLING_420) +#define PISP_IMAGE_FORMAT_ORDER_NORMAL(fmt)                                    \ +	(!((fmt) & PISP_IMAGE_FORMAT_ORDER_SWAPPED)) +#define PISP_IMAGE_FORMAT_ORDER_SWAPPED(fmt)                                   \ +	((fmt) & PISP_IMAGE_FORMAT_ORDER_SWAPPED) +#define PISP_IMAGE_FORMAT_INTERLEAVED(fmt)                                     \ +	(((fmt) & PISP_IMAGE_FORMAT_PLANARITY_MASK) ==                         \ +	 PISP_IMAGE_FORMAT_PLANARITY_INTERLEAVED) +#define PISP_IMAGE_FORMAT_SEMIPLANAR(fmt)                                      \ +	(((fmt) & PISP_IMAGE_FORMAT_PLANARITY_MASK) ==                         \ +	 PISP_IMAGE_FORMAT_PLANARITY_SEMI_PLANAR) +#define PISP_IMAGE_FORMAT_PLANAR(fmt)                                          \ +	(((fmt) & PISP_IMAGE_FORMAT_PLANARITY_MASK) ==                         \ +	 PISP_IMAGE_FORMAT_PLANARITY_PLANAR) +#define PISP_IMAGE_FORMAT_WALLPAPER(fmt)                                       \ +	((fmt) & PISP_IMAGE_FORMAT_WALLPAPER_ROLL) +#define PISP_IMAGE_FORMAT_BPP_32(fmt) ((fmt) & PISP_IMAGE_FORMAT_BPP_32) +#define PISP_IMAGE_FORMAT_HOG(fmt)                                             \ +	((fmt) &                                                               \ +	 (PISP_IMAGE_FORMAT_HOG_SIGNED | PISP_IMAGE_FORMAT_HOG_UNSIGNED)) + +#define PISP_WALLPAPER_WIDTH 128 /* in bytes */ + +struct pisp_bla_config { +	__u16 black_level_r; +	__u16 black_level_gr; +	__u16 black_level_gb; +	__u16 black_level_b; +	__u16 output_black_level; +	__u8 pad[2]; +} __attribute__((packed)); + +struct pisp_wbg_config { +	__u16 gain_r; +	__u16 gain_g; +	__u16 gain_b; +	__u8 pad[2]; +} __attribute__((packed)); + +struct pisp_compress_config { +	/* value subtracted from incoming data */ +	__u16 offset; +	__u8 pad; +	/* 1 => Companding; 2 => Delta (recommended); 3 => Combined (for HDR) */ +	__u8 mode; +} __attribute__((packed)); + +struct pisp_decompress_config { +	/* value added to reconstructed data */ +	__u16 offset; +	__u8 pad; +	/* 1 => Companding; 2 => Delta (recommended); 3 => Combined (for HDR) */ +	__u8 mode; +} __attribute__((packed)); + +enum pisp_axi_flags { +	/* +	 * round down bursts to end at a 32-byte boundary, to align following +	 * bursts +	 */ +	PISP_AXI_FLAG_ALIGN = 128, +	/* for FE writer: force WSTRB high, to pad output to 16-byte boundary */ +	PISP_AXI_FLAG_PAD = 64, +	/* for FE writer: Use Output FIFO level to trigger "panic" */ +	PISP_AXI_FLAG_PANIC = 32, +}; + +struct pisp_axi_config { +	/* +	 * burst length minus one, which must be in the range 0:15; OR'd with +	 * flags +	 */ +	__u8 maxlen_flags; +	/* { prot[2:0], cache[3:0] } fields, echoed on AXI bus */ +	__u8 cache_prot; +	/* QoS field(s) (4x4 bits for FE writer; 4 bits for other masters) */ +	__u16 qos; +} __attribute__((packed)); + +#endif /* _UAPI_PISP_COMMON_H_ */ diff --git a/include/uapi/linux/media/raspberrypi/pisp_fe_config.h b/include/uapi/linux/media/raspberrypi/pisp_fe_config.h new file mode 100644 index 000000000000..77237460a3b5 --- /dev/null +++ b/include/uapi/linux/media/raspberrypi/pisp_fe_config.h @@ -0,0 +1,273 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * RP1 PiSP Front End Driver Configuration structures + * + * Copyright (C) 2021 - Raspberry Pi Ltd. + * + */ +#ifndef _UAPI_PISP_FE_CONFIG_ +#define _UAPI_PISP_FE_CONFIG_ + +#include <linux/types.h> + +#include "pisp_common.h" +#include "pisp_fe_statistics.h" + +#define PISP_FE_NUM_OUTPUTS 2 + +enum pisp_fe_enable { +	PISP_FE_ENABLE_INPUT = 0x000001, +	PISP_FE_ENABLE_DECOMPRESS = 0x000002, +	PISP_FE_ENABLE_DECOMPAND = 0x000004, +	PISP_FE_ENABLE_BLA = 0x000008, +	PISP_FE_ENABLE_DPC = 0x000010, +	PISP_FE_ENABLE_STATS_CROP = 0x000020, +	PISP_FE_ENABLE_DECIMATE = 0x000040, +	PISP_FE_ENABLE_BLC = 0x000080, +	PISP_FE_ENABLE_CDAF_STATS = 0x000100, +	PISP_FE_ENABLE_AWB_STATS = 0x000200, +	PISP_FE_ENABLE_RGBY = 0x000400, +	PISP_FE_ENABLE_LSC = 0x000800, +	PISP_FE_ENABLE_AGC_STATS = 0x001000, +	PISP_FE_ENABLE_CROP0 = 0x010000, +	PISP_FE_ENABLE_DOWNSCALE0 = 0x020000, +	PISP_FE_ENABLE_COMPRESS0 = 0x040000, +	PISP_FE_ENABLE_OUTPUT0 = 0x080000, +	PISP_FE_ENABLE_CROP1 = 0x100000, +	PISP_FE_ENABLE_DOWNSCALE1 = 0x200000, +	PISP_FE_ENABLE_COMPRESS1 = 0x400000, +	PISP_FE_ENABLE_OUTPUT1 = 0x800000 +}; + +#define PISP_FE_ENABLE_CROP(i) (PISP_FE_ENABLE_CROP0 << (4 * (i))) +#define PISP_FE_ENABLE_DOWNSCALE(i) (PISP_FE_ENABLE_DOWNSCALE0 << (4 * (i))) +#define PISP_FE_ENABLE_COMPRESS(i) (PISP_FE_ENABLE_COMPRESS0 << (4 * (i))) +#define PISP_FE_ENABLE_OUTPUT(i) (PISP_FE_ENABLE_OUTPUT0 << (4 * (i))) + +/* + * We use the enable flags to show when blocks are "dirty", but we need some + * extra ones too. + */ +enum pisp_fe_dirty { +	PISP_FE_DIRTY_GLOBAL = 0x0001, +	PISP_FE_DIRTY_FLOATING = 0x0002, +	PISP_FE_DIRTY_OUTPUT_AXI = 0x0004 +}; + +struct pisp_fe_global_config { +	__u32 enables; +	__u8 bayer_order; +	__u8 pad[3]; +} __attribute__((packed)); + +struct pisp_fe_input_axi_config { +	/* burst length minus one, in the range 0..15; OR'd with flags */ +	__u8 maxlen_flags; +	/* { prot[2:0], cache[3:0] } fields */ +	__u8 cache_prot; +	/* QoS (only 4 LS bits are used) */ +	__u16 qos; +} __attribute__((packed)); + +struct pisp_fe_output_axi_config { +	/* burst length minus one, in the range 0..15; OR'd with flags */ +	__u8 maxlen_flags; +	/* { prot[2:0], cache[3:0] } fields */ +	__u8 cache_prot; +	/* QoS (4 bitfields of 4 bits each for different panic levels) */ +	__u16 qos; +	/*  For Panic mode: Output FIFO panic threshold */ +	__u16 thresh; +	/*  For Panic mode: Output FIFO statistics throttle threshold */ +	__u16 throttle; +} __attribute__((packed)); + +struct pisp_fe_input_config { +	__u8 streaming; +	__u8 pad[3]; +	struct pisp_image_format_config format; +	struct pisp_fe_input_axi_config axi; +	/* Extra cycles delay before issuing each burst request */ +	__u8 holdoff; +	__u8 pad2[3]; +} __attribute__((packed)); + +struct pisp_fe_output_config { +	struct pisp_image_format_config format; +	__u16 ilines; +	__u8 pad[2]; +} __attribute__((packed)); + +struct pisp_fe_input_buffer_config { +	__u32 addr_lo; +	__u32 addr_hi; +	__u16 frame_id; +	__u16 pad; +} __attribute__((packed)); + +#define PISP_FE_DECOMPAND_LUT_SIZE 65 + +struct pisp_fe_decompand_config { +	__u16 lut[PISP_FE_DECOMPAND_LUT_SIZE]; +	__u16 pad; +} __attribute__((packed)); + +struct pisp_fe_dpc_config { +	__u8 coeff_level; +	__u8 coeff_range; +	__u8 coeff_range2; +#define PISP_FE_DPC_FLAG_FOLDBACK 1 +#define PISP_FE_DPC_FLAG_VFLAG 2 +	__u8 flags; +} __attribute__((packed)); + +#define PISP_FE_LSC_LUT_SIZE 16 + +struct pisp_fe_lsc_config { +	__u8 shift; +	__u8 pad0; +	__u16 scale; +	__u16 centre_x; +	__u16 centre_y; +	__u16 lut[PISP_FE_LSC_LUT_SIZE]; +} __attribute__((packed)); + +struct pisp_fe_rgby_config { +	__u16 gain_r; +	__u16 gain_g; +	__u16 gain_b; +	__u8 maxflag; +	__u8 pad; +} __attribute__((packed)); + +struct pisp_fe_agc_stats_config { +	__u16 offset_x; +	__u16 offset_y; +	__u16 size_x; +	__u16 size_y; +	/* each weight only 4 bits */ +	__u8 weights[PISP_AGC_STATS_NUM_ZONES / 2]; +	__u16 row_offset_x; +	__u16 row_offset_y; +	__u16 row_size_x; +	__u16 row_size_y; +	__u8 row_shift; +	__u8 float_shift; +	__u8 pad1[2]; +} __attribute__((packed)); + +struct pisp_fe_awb_stats_config { +	__u16 offset_x; +	__u16 offset_y; +	__u16 size_x; +	__u16 size_y; +	__u8 shift; +	__u8 pad[3]; +	__u16 r_lo; +	__u16 r_hi; +	__u16 g_lo; +	__u16 g_hi; +	__u16 b_lo; +	__u16 b_hi; +} __attribute__((packed)); + +struct pisp_fe_floating_stats_region { +	__u16 offset_x; +	__u16 offset_y; +	__u16 size_x; +	__u16 size_y; +} __attribute__((packed)); + +struct pisp_fe_floating_stats_config { +	struct pisp_fe_floating_stats_region +		regions[PISP_FLOATING_STATS_NUM_ZONES]; +} __attribute__((packed)); + +#define PISP_FE_CDAF_NUM_WEIGHTS 8 + +struct pisp_fe_cdaf_stats_config { +	__u16 noise_constant; +	__u16 noise_slope; +	__u16 offset_x; +	__u16 offset_y; +	__u16 size_x; +	__u16 size_y; +	__u16 skip_x; +	__u16 skip_y; +	__u32 mode; +} __attribute__((packed)); + +struct pisp_fe_stats_buffer_config { +	__u32 addr_lo; +	__u32 addr_hi; +} __attribute__((packed)); + +struct pisp_fe_crop_config { +	__u16 offset_x; +	__u16 offset_y; +	__u16 width; +	__u16 height; +} __attribute__((packed)); + +enum pisp_fe_downscale_flags { +	/* downscale the four Bayer components independently... */ +	DOWNSCALE_BAYER = 1, +	/* ...without trying to preserve their spatial relationship */ +	DOWNSCALE_BIN = 2, +}; + +struct pisp_fe_downscale_config { +	__u8 xin; +	__u8 xout; +	__u8 yin; +	__u8 yout; +	__u8 flags; /* enum pisp_fe_downscale_flags */ +	__u8 pad[3]; +	__u16 output_width; +	__u16 output_height; +} __attribute__((packed)); + +struct pisp_fe_output_buffer_config { +	__u32 addr_lo; +	__u32 addr_hi; +} __attribute__((packed)); + +/* Each of the two output channels/branches: */ +struct pisp_fe_output_branch_config { +	struct pisp_fe_crop_config crop; +	struct pisp_fe_downscale_config downscale; +	struct pisp_compress_config compress; +	struct pisp_fe_output_config output; +	__u32 pad; +} __attribute__((packed)); + +/* And finally one to rule them all: */ +struct pisp_fe_config { +	/* I/O configuration: */ +	struct pisp_fe_stats_buffer_config stats_buffer; +	struct pisp_fe_output_buffer_config output_buffer[PISP_FE_NUM_OUTPUTS]; +	struct pisp_fe_input_buffer_config input_buffer; +	/* processing configuration: */ +	struct pisp_fe_global_config global; +	struct pisp_fe_input_config input; +	struct pisp_decompress_config decompress; +	struct pisp_fe_decompand_config decompand; +	struct pisp_bla_config bla; +	struct pisp_fe_dpc_config dpc; +	struct pisp_fe_crop_config stats_crop; +	__u32 spare1; /* placeholder for future decimate configuration */ +	struct pisp_bla_config blc; +	struct pisp_fe_rgby_config rgby; +	struct pisp_fe_lsc_config lsc; +	struct pisp_fe_agc_stats_config agc_stats; +	struct pisp_fe_awb_stats_config awb_stats; +	struct pisp_fe_cdaf_stats_config cdaf_stats; +	struct pisp_fe_floating_stats_config floating_stats; +	struct pisp_fe_output_axi_config output_axi; +	struct pisp_fe_output_branch_config ch[PISP_FE_NUM_OUTPUTS]; +	/* non-register fields: */ +	__u32 dirty_flags; /* these use pisp_fe_enable */ +	__u32 dirty_flags_extra; /* these use pisp_fe_dirty */ +} __attribute__((packed)); + +#endif /* _UAPI_PISP_FE_CONFIG_ */ diff --git a/include/uapi/linux/media/raspberrypi/pisp_fe_statistics.h b/include/uapi/linux/media/raspberrypi/pisp_fe_statistics.h new file mode 100644 index 000000000000..a7d42985aee8 --- /dev/null +++ b/include/uapi/linux/media/raspberrypi/pisp_fe_statistics.h @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * RP1 PiSP Front End statistics definitions + * + * Copyright (C) 2021 - Raspberry Pi Ltd. + * + */ +#ifndef _UAPI_PISP_FE_STATISTICS_H_ +#define _UAPI_PISP_FE_STATISTICS_H_ + +#include <linux/types.h> + +#define PISP_FLOATING_STATS_NUM_ZONES 4 +#define PISP_AGC_STATS_NUM_BINS 1024 +#define PISP_AGC_STATS_SIZE 16 +#define PISP_AGC_STATS_NUM_ZONES (PISP_AGC_STATS_SIZE * PISP_AGC_STATS_SIZE) +#define PISP_AGC_STATS_NUM_ROW_SUMS 512 + +struct pisp_agc_statistics_zone { +	__u64 Y_sum; +	__u32 counted; +	__u32 pad; +} __attribute__((packed)); + +struct pisp_agc_statistics { +	__u32 row_sums[PISP_AGC_STATS_NUM_ROW_SUMS]; +	/* +	 * 32-bits per bin means an image (just less than) 16384x16384 pixels +	 * in size can weight every pixel from 0 to 15. +	 */ +	__u32 histogram[PISP_AGC_STATS_NUM_BINS]; +	struct pisp_agc_statistics_zone floating[PISP_FLOATING_STATS_NUM_ZONES]; +} __attribute__((packed)); + +#define PISP_AWB_STATS_SIZE 32 +#define PISP_AWB_STATS_NUM_ZONES (PISP_AWB_STATS_SIZE * PISP_AWB_STATS_SIZE) + +struct pisp_awb_statistics_zone { +	__u32 R_sum; +	__u32 G_sum; +	__u32 B_sum; +	__u32 counted; +} __attribute__((packed)); + +struct pisp_awb_statistics { +	struct pisp_awb_statistics_zone zones[PISP_AWB_STATS_NUM_ZONES]; +	struct pisp_awb_statistics_zone floating[PISP_FLOATING_STATS_NUM_ZONES]; +} __attribute__((packed)); + +#define PISP_CDAF_STATS_SIZE 8 +#define PISP_CDAF_STATS_NUM_FOMS (PISP_CDAF_STATS_SIZE * PISP_CDAF_STATS_SIZE) + +struct pisp_cdaf_statistics { +	__u64 foms[PISP_CDAF_STATS_NUM_FOMS]; +	__u64 floating[PISP_FLOATING_STATS_NUM_ZONES]; +} __attribute__((packed)); + +struct pisp_statistics { +	struct pisp_awb_statistics awb; +	struct pisp_agc_statistics agc; +	struct pisp_cdaf_statistics cdaf; +} __attribute__((packed)); + +#endif /* _UAPI_PISP_FE_STATISTICS_H_ */ diff --git a/include/uapi/linux/mei.h b/include/uapi/linux/mei.h index c6aec86cc5de..68a0272e99b7 100644 --- a/include/uapi/linux/mei.h +++ b/include/uapi/linux/mei.h @@ -7,15 +7,15 @@  #ifndef _LINUX_MEI_H  #define _LINUX_MEI_H -#include <linux/uuid.h> +#include <linux/mei_uuid.h>  /*   * This IOCTL is used to associate the current file descriptor with a   * FW Client (given by UUID). This opens a communication channel   * between a host client and a FW client. From this point every read and write   * will communicate with the associated FW client. - * Only in close() (file_operation release()) the communication between - * the clients is disconnected + * Only in close() (file_operation release()) is the communication between + * the clients disconnected.   *   * The IOCTL argument is a struct with a union that contains   * the input parameter and the output parameter for this IOCTL. @@ -51,7 +51,7 @@ struct mei_connect_client_data {   * DOC: set and unset event notification for a connected client   *   * The IOCTL argument is 1 for enabling event notification and 0 for - * disabling the service + * disabling the service.   * Return:  -EOPNOTSUPP if the devices doesn't support the feature   */  #define IOCTL_MEI_NOTIFY_SET _IOW('H', 0x02, __u32) @@ -59,11 +59,60 @@ struct mei_connect_client_data {  /**   * DOC: retrieve notification   * - * The IOCTL output argument is 1 if an event was is pending and 0 otherwise - * the ioctl has to be called in order to acknowledge pending event + * The IOCTL output argument is 1 if an event was pending and 0 otherwise. + * The ioctl has to be called in order to acknowledge pending event.   *   * Return:  -EOPNOTSUPP if the devices doesn't support the feature   */  #define IOCTL_MEI_NOTIFY_GET _IOR('H', 0x03, __u32) +/** + * struct mei_connect_client_vtag - mei client information struct with vtag + * + * @in_client_uuid: UUID of client to connect + * @vtag: virtual tag + * @reserved: reserved for future use + */ +struct mei_connect_client_vtag { +	uuid_le in_client_uuid; +	__u8 vtag; +	__u8 reserved[3]; +}; + +/** + * struct mei_connect_client_data_vtag - IOCTL connect data union + * + * @connect: input connect data + * @out_client_properties: output client data + */ +struct mei_connect_client_data_vtag { +	union { +		struct mei_connect_client_vtag connect; +		struct mei_client out_client_properties; +	}; +}; + +/** + * DOC: + * This IOCTL is used to associate the current file descriptor with a + * FW Client (given by UUID), and virtual tag (vtag). + * The IOCTL opens a communication channel between a host client and + * a FW client on a tagged channel. From this point on, every read + * and write will communicate with the associated FW client + * on the tagged channel. + * Upon close() the communication is terminated. + * + * The IOCTL argument is a struct with a union that contains + * the input parameter and the output parameter for this IOCTL. + * + * The input parameter is UUID of the FW Client, a vtag [0,255]. + * The output parameter is the properties of the FW client + * (FW protocol version and max message size). + * + * Clients that do not support tagged connection + * will respond with -EOPNOTSUPP. + */ +#define IOCTL_MEI_CONNECT_CLIENT_VTAG \ +	_IOWR('H', 0x04, struct mei_connect_client_data_vtag) +  #endif /* _LINUX_MEI_H  */ diff --git a/include/uapi/linux/mei_uuid.h b/include/uapi/linux/mei_uuid.h new file mode 100644 index 000000000000..676ebe12d623 --- /dev/null +++ b/include/uapi/linux/mei_uuid.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * MEI UUID definition + * + * Copyright (C) 2010, Intel Corp. + *	Huang Ying <ying.huang@intel.com> + */ + +#ifndef _UAPI_LINUX_MEI_UUID_H_ +#define _UAPI_LINUX_MEI_UUID_H_ + +#include <linux/types.h> + +typedef struct { +	__u8 b[16]; +} uuid_le; + +#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\ +((uuid_le)								\ +{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ +   (b) & 0xff, ((b) >> 8) & 0xff,					\ +   (c) & 0xff, ((c) >> 8) & 0xff,					\ +   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) + +#define NULL_UUID_LE							\ +	UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\ +	     0x00, 0x00, 0x00, 0x00) + +#endif /* _UAPI_LINUX_MEI_UUID_H_ */ diff --git a/include/uapi/linux/membarrier.h b/include/uapi/linux/membarrier.h index 5891d7614c8c..5f3ad6d5be6f 100644 --- a/include/uapi/linux/membarrier.h +++ b/include/uapi/linux/membarrier.h @@ -114,9 +114,32 @@   *                          If this command is not implemented by an   *                          architecture, -EINVAL is returned.   *                          Returns 0 on success. + * @MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: + *                          Ensure the caller thread, upon return from + *                          system call, that all its running thread + *                          siblings have any currently running rseq + *                          critical sections restarted if @flags + *                          parameter is 0; if @flags parameter is + *                          MEMBARRIER_CMD_FLAG_CPU, + *                          then this operation is performed only + *                          on CPU indicated by @cpu_id. If this command is + *                          not implemented by an architecture, -EINVAL + *                          is returned. A process needs to register its + *                          intent to use the private expedited rseq + *                          command prior to using it, otherwise + *                          this command returns -EPERM. + * @MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: + *                          Register the process intent to use + *                          MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ. + *                          If this command is not implemented by an + *                          architecture, -EINVAL is returned. + *                          Returns 0 on success.   * @MEMBARRIER_CMD_SHARED:   *                          Alias to MEMBARRIER_CMD_GLOBAL. Provided for   *                          header backward compatibility. + * @MEMBARRIER_CMD_GET_REGISTRATIONS: + *                          Returns a bitmask of previously issued + *                          registration commands.   *   * Command to be passed to the membarrier system call. The commands need to   * be a single bit each, except for MEMBARRIER_CMD_QUERY which is assigned to @@ -131,9 +154,16 @@ enum membarrier_cmd {  	MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED		= (1 << 4),  	MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE		= (1 << 5),  	MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE	= (1 << 6), +	MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ			= (1 << 7), +	MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ		= (1 << 8), +	MEMBARRIER_CMD_GET_REGISTRATIONS			= (1 << 9),  	/* Alias for header backward compatibility. */  	MEMBARRIER_CMD_SHARED			= MEMBARRIER_CMD_GLOBAL,  }; +enum membarrier_cmd_flag { +	MEMBARRIER_CMD_FLAG_CPU		= (1 << 0), +}; +  #endif /* _UAPI_LINUX_MEMBARRIER_H */ diff --git a/include/uapi/linux/memfd.h b/include/uapi/linux/memfd.h index 7a8a26751c23..273a4e15dfcf 100644 --- a/include/uapi/linux/memfd.h +++ b/include/uapi/linux/memfd.h @@ -8,6 +8,10 @@  #define MFD_CLOEXEC		0x0001U  #define MFD_ALLOW_SEALING	0x0002U  #define MFD_HUGETLB		0x0004U +/* not executable and sealed to prevent changing to executable. */ +#define MFD_NOEXEC_SEAL		0x0008U +/* executable */ +#define MFD_EXEC		0x0010U  /*   * Huge page size encoding when MFD_HUGETLB is specified, and a huge page diff --git a/include/uapi/linux/mempolicy.h b/include/uapi/linux/mempolicy.h index 3354774af61e..1f9bb10d1a47 100644 --- a/include/uapi/linux/mempolicy.h +++ b/include/uapi/linux/mempolicy.h @@ -22,18 +22,22 @@ enum {  	MPOL_BIND,  	MPOL_INTERLEAVE,  	MPOL_LOCAL, +	MPOL_PREFERRED_MANY, +	MPOL_WEIGHTED_INTERLEAVE,  	MPOL_MAX,	/* always last member of enum */  };  /* Flags for set_mempolicy */  #define MPOL_F_STATIC_NODES	(1 << 15)  #define MPOL_F_RELATIVE_NODES	(1 << 14) +#define MPOL_F_NUMA_BALANCING	(1 << 13) /* Optimize with NUMA balancing if possible */  /*   * MPOL_MODE_FLAGS is the union of all possible optional mode flags passed to   * either set_mempolicy() or mbind().   */ -#define MPOL_MODE_FLAGS	(MPOL_F_STATIC_NODES | MPOL_F_RELATIVE_NODES) +#define MPOL_MODE_FLAGS							\ +	(MPOL_F_STATIC_NODES | MPOL_F_RELATIVE_NODES | MPOL_F_NUMA_BALANCING)  /* Flags for get_mempolicy */  #define MPOL_F_NODE	(1<<0)	/* return next IL mode instead of node mask */ @@ -45,7 +49,7 @@ enum {  #define MPOL_MF_MOVE	 (1<<1)	/* Move pages owned by this process to conform  				   to policy */  #define MPOL_MF_MOVE_ALL (1<<2)	/* Move every page to conform to policy */ -#define MPOL_MF_LAZY	 (1<<3)	/* Modifies '_MOVE:  lazy migrate on fault */ +#define MPOL_MF_LAZY	 (1<<3)	/* UNSUPPORTED FLAG: Lazy migrate on fault */  #define MPOL_MF_INTERNAL (1<<4)	/* Internal flags start here */  #define MPOL_MF_VALID	(MPOL_MF_STRICT   | 	\ @@ -58,9 +62,15 @@ enum {   * are never OR'ed into the mode in mempolicy API arguments.   */  #define MPOL_F_SHARED  (1 << 0)	/* identify shared policies */ -#define MPOL_F_LOCAL   (1 << 1)	/* preferred local allocation */  #define MPOL_F_MOF	(1 << 3) /* this policy wants migrate on fault */  #define MPOL_F_MORON	(1 << 4) /* Migrate On protnone Reference On Node */ +/* + * These bit locations are exposed in the vm.zone_reclaim_mode sysctl + * ABI.  New bits are OK, but existing bits can never change. + */ +#define RECLAIM_ZONE	(1<<0)	/* Run shrink_inactive_list on the zone */ +#define RECLAIM_WRITE	(1<<1)	/* Writeout pages during reclaim */ +#define RECLAIM_UNMAP	(1<<2)	/* Unmap pages during reclaim */  #endif /* _UAPI_LINUX_MEMPOLICY_H */ diff --git a/include/uapi/linux/meye.h b/include/uapi/linux/meye.h deleted file mode 100644 index de9e3a954f3d..000000000000 --- a/include/uapi/linux/meye.h +++ /dev/null @@ -1,65 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ -/* - * Motion Eye video4linux driver for Sony Vaio PictureBook - * - * Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net> - * - * Copyright (C) 2001-2002 Alcôve <www.alcove.com> - * - * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com> - * - * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras. - * - * Some parts borrowed from various video4linux drivers, especially - * bttv-driver.c and zoran.c, see original files for credits. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _MEYE_H_ -#define _MEYE_H_ - -/****************************************************************************/ -/* Private API for handling mjpeg capture / playback.                       */ -/****************************************************************************/ - -struct meye_params { -	unsigned char subsample; -	unsigned char quality; -	unsigned char sharpness; -	unsigned char agc; -	unsigned char picture; -	unsigned char framerate; -}; - -/* query the extended parameters */ -#define MEYEIOC_G_PARAMS	_IOR ('v', BASE_VIDIOC_PRIVATE+0, struct meye_params) -/* set the extended parameters */ -#define MEYEIOC_S_PARAMS	_IOW ('v', BASE_VIDIOC_PRIVATE+1, struct meye_params) -/* queue a buffer for mjpeg capture */ -#define MEYEIOC_QBUF_CAPT	_IOW ('v', BASE_VIDIOC_PRIVATE+2, int) -/* sync a previously queued mjpeg buffer */ -#define MEYEIOC_SYNC		_IOWR('v', BASE_VIDIOC_PRIVATE+3, int) -/* get a still uncompressed snapshot */ -#define MEYEIOC_STILLCAPT	_IO  ('v', BASE_VIDIOC_PRIVATE+4) -/* get a jpeg compressed snapshot */ -#define MEYEIOC_STILLJCAPT	_IOR ('v', BASE_VIDIOC_PRIVATE+5, int) - -/* V4L2 private controls */ -#define V4L2_CID_MEYE_AGC		(V4L2_CID_USER_MEYE_BASE + 0) -#define V4L2_CID_MEYE_PICTURE		(V4L2_CID_USER_MEYE_BASE + 1) -#define V4L2_CID_MEYE_FRAMERATE		(V4L2_CID_USER_MEYE_BASE + 2) - -#endif diff --git a/include/uapi/linux/mic_common.h b/include/uapi/linux/mic_common.h deleted file mode 100644 index 504e523f702c..000000000000 --- a/include/uapi/linux/mic_common.h +++ /dev/null @@ -1,235 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * Intel MIC Platform Software Stack (MPSS) - * - * Copyright(c) 2013 Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Intel MIC driver. - * - */ -#ifndef __MIC_COMMON_H_ -#define __MIC_COMMON_H_ - -#include <linux/virtio_ring.h> - -#define __mic_align(a, x) (((a) + (x) - 1) & ~((x) - 1)) - -/** - * struct mic_device_desc: Virtio device information shared between the - * virtio driver and userspace backend - * - * @type: Device type: console/network/disk etc.  Type 0/-1 terminates. - * @num_vq: Number of virtqueues. - * @feature_len: Number of bytes of feature bits.  Multiply by 2: one for -   host features and one for guest acknowledgements. - * @config_len: Number of bytes of the config array after virtqueues. - * @status: A status byte, written by the Guest. - * @config: Start of the following variable length config. - */ -struct mic_device_desc { -	__s8 type; -	__u8 num_vq; -	__u8 feature_len; -	__u8 config_len; -	__u8 status; -	__le64 config[0]; -} __attribute__ ((aligned(8))); - -/** - * struct mic_device_ctrl: Per virtio device information in the device page - * used internally by the host and card side drivers. - * - * @vdev: Used for storing MIC vdev information by the guest. - * @config_change: Set to 1 by host when a config change is requested. - * @vdev_reset: Set to 1 by guest to indicate virtio device has been reset. - * @guest_ack: Set to 1 by guest to ack a command. - * @host_ack: Set to 1 by host to ack a command. - * @used_address_updated: Set to 1 by guest when the used address should be - * updated. - * @c2h_vdev_db: The doorbell number to be used by guest. Set by host. - * @h2c_vdev_db: The doorbell number to be used by host. Set by guest. - */ -struct mic_device_ctrl { -	__le64 vdev; -	__u8 config_change; -	__u8 vdev_reset; -	__u8 guest_ack; -	__u8 host_ack; -	__u8 used_address_updated; -	__s8 c2h_vdev_db; -	__s8 h2c_vdev_db; -} __attribute__ ((aligned(8))); - -/** - * struct mic_bootparam: Virtio device independent information in device page - * - * @magic: A magic value used by the card to ensure it can see the host - * @h2c_config_db: Host to Card Virtio config doorbell set by card - * @node_id: Unique id of the node - * @h2c_scif_db - Host to card SCIF doorbell set by card - * @c2h_scif_db - Card to host SCIF doorbell set by host - * @scif_host_dma_addr - SCIF host queue pair DMA address - * @scif_card_dma_addr - SCIF card queue pair DMA address - */ -struct mic_bootparam { -	__le32 magic; -	__s8 h2c_config_db; -	__u8 node_id; -	__u8 h2c_scif_db; -	__u8 c2h_scif_db; -	__u64 scif_host_dma_addr; -	__u64 scif_card_dma_addr; -} __attribute__ ((aligned(8))); - -/** - * struct mic_device_page: High level representation of the device page - * - * @bootparam: The bootparam structure is used for sharing information and - * status updates between MIC host and card drivers. - * @desc: Array of MIC virtio device descriptors. - */ -struct mic_device_page { -	struct mic_bootparam bootparam; -	struct mic_device_desc desc[0]; -}; -/** - * struct mic_vqconfig: This is how we expect the device configuration field - * for a virtqueue to be laid out in config space. - * - * @address: Guest/MIC physical address of the virtio ring - * (avail and desc rings) - * @used_address: Guest/MIC physical address of the used ring - * @num: The number of entries in the virtio_ring - */ -struct mic_vqconfig { -	__le64 address; -	__le64 used_address; -	__le16 num; -} __attribute__ ((aligned(8))); - -/* - * The alignment to use between consumer and producer parts of vring. - * This is pagesize for historical reasons. - */ -#define MIC_VIRTIO_RING_ALIGN		4096 - -#define MIC_MAX_VRINGS			4 -#define MIC_VRING_ENTRIES		128 - -/* - * Max vring entries (power of 2) to ensure desc and avail rings - * fit in a single page - */ -#define MIC_MAX_VRING_ENTRIES		128 - -/** - * Max size of the desc block in bytes: includes: - *	- struct mic_device_desc - *	- struct mic_vqconfig (num_vq of these) - *	- host and guest features - *	- virtio device config space - */ -#define MIC_MAX_DESC_BLK_SIZE		256 - -/** - * struct _mic_vring_info - Host vring info exposed to userspace backend - * for the avail index and magic for the card. - * - * @avail_idx: host avail idx - * @magic: A magic debug cookie. - */ -struct _mic_vring_info { -	__u16 avail_idx; -	__le32 magic; -}; - -/** - * struct mic_vring - Vring information. - * - * @vr: The virtio ring. - * @info: Host vring information exposed to the userspace backend for the - * avail index and magic for the card. - * @va: The va for the buffer allocated for vr and info. - * @len: The length of the buffer required for allocating vr and info. - */ -struct mic_vring { -	struct vring vr; -	struct _mic_vring_info *info; -	void *va; -	int len; -}; - -#define mic_aligned_desc_size(d) __mic_align(mic_desc_size(d), 8) - -#ifndef INTEL_MIC_CARD -static inline unsigned mic_desc_size(const struct mic_device_desc *desc) -{ -	return sizeof(*desc) + desc->num_vq * sizeof(struct mic_vqconfig) -		+ desc->feature_len * 2 + desc->config_len; -} - -static inline struct mic_vqconfig * -mic_vq_config(const struct mic_device_desc *desc) -{ -	return (struct mic_vqconfig *)(desc + 1); -} - -static inline __u8 *mic_vq_features(const struct mic_device_desc *desc) -{ -	return (__u8 *)(mic_vq_config(desc) + desc->num_vq); -} - -static inline __u8 *mic_vq_configspace(const struct mic_device_desc *desc) -{ -	return mic_vq_features(desc) + desc->feature_len * 2; -} -static inline unsigned mic_total_desc_size(struct mic_device_desc *desc) -{ -	return mic_aligned_desc_size(desc) + sizeof(struct mic_device_ctrl); -} -#endif - -/* Device page size */ -#define MIC_DP_SIZE 4096 - -#define MIC_MAGIC 0xc0ffee00 - -/** - * enum mic_states - MIC states. - */ -enum mic_states { -	MIC_READY = 0, -	MIC_BOOTING, -	MIC_ONLINE, -	MIC_SHUTTING_DOWN, -	MIC_RESETTING, -	MIC_RESET_FAILED, -	MIC_LAST -}; - -/** - * enum mic_status - MIC status reported by card after - * a host or card initiated shutdown or a card crash. - */ -enum mic_status { -	MIC_NOP = 0, -	MIC_CRASHED, -	MIC_HALTED, -	MIC_POWER_OFF, -	MIC_RESTART, -	MIC_STATUS_LAST -}; - -#endif diff --git a/include/uapi/linux/mic_ioctl.h b/include/uapi/linux/mic_ioctl.h deleted file mode 100644 index 687b9cd9d3e2..000000000000 --- a/include/uapi/linux/mic_ioctl.h +++ /dev/null @@ -1,77 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * Intel MIC Platform Software Stack (MPSS) - * - * Copyright(c) 2013 Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Intel MIC Host driver. - * - */ -#ifndef _MIC_IOCTL_H_ -#define _MIC_IOCTL_H_ - -#include <linux/types.h> - -/* - * mic_copy - MIC virtio descriptor copy. - * - * @iov: An array of IOVEC structures containing user space buffers. - * @iovcnt: Number of IOVEC structures in iov. - * @vr_idx: The vring index. - * @update_used: A non zero value results in used index being updated. - * @out_len: The aggregate of the total length written to or read from - *	the virtio device. - */ -struct mic_copy_desc { -#ifdef __KERNEL__ -	struct iovec __user *iov; -#else -	struct iovec *iov; -#endif -	__u32 iovcnt; -	__u8 vr_idx; -	__u8 update_used; -	__u32 out_len; -}; - -/* - * Add a new virtio device - * The (struct mic_device_desc *) pointer points to a device page entry - *	for the virtio device consisting of: - *	- struct mic_device_desc - *	- struct mic_vqconfig (num_vq of these) - *	- host and guest features - *	- virtio device config space - * The total size referenced by the pointer should equal the size returned - * by desc_size() in mic_common.h - */ -#define MIC_VIRTIO_ADD_DEVICE _IOWR('s', 1, struct mic_device_desc *) - -/* - * Copy the number of entries in the iovec and update the used index - * if requested by the user. - */ -#define MIC_VIRTIO_COPY_DESC	_IOWR('s', 2, struct mic_copy_desc *) - -/* - * Notify virtio device of a config change - * The (__u8 *) pointer points to config space values for the device - * as they should be written into the device page. The total size - * referenced by the pointer should equal the config_len field of struct - * mic_device_desc. - */ -#define MIC_VIRTIO_CONFIG_CHANGE _IOWR('s', 5, __u8 *) - -#endif diff --git a/include/uapi/linux/minix_fs.h b/include/uapi/linux/minix_fs.h index 95dbcb17eacd..8d9ca8b2c357 100644 --- a/include/uapi/linux/minix_fs.h +++ b/include/uapi/linux/minix_fs.h @@ -97,11 +97,11 @@ struct minix3_super_block {  struct minix_dir_entry {  	__u16 inode; -	char name[0]; +	char name[];  };  struct minix3_dir_entry {  	__u32 inode; -	char name[0]; +	char name[];  };  #endif diff --git a/include/uapi/linux/misc/bcm_vk.h b/include/uapi/linux/misc/bcm_vk.h new file mode 100644 index 000000000000..ec28e0bd46a9 --- /dev/null +++ b/include/uapi/linux/misc/bcm_vk.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Copyright 2018-2020 Broadcom. + */ + +#ifndef __UAPI_LINUX_MISC_BCM_VK_H +#define __UAPI_LINUX_MISC_BCM_VK_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define BCM_VK_MAX_FILENAME 64 + +struct vk_image { +	__u32 type; /* Type of image */ +#define VK_IMAGE_TYPE_BOOT1 1 /* 1st stage (load to SRAM) */ +#define VK_IMAGE_TYPE_BOOT2 2 /* 2nd stage (load to DDR) */ +	__u8 filename[BCM_VK_MAX_FILENAME]; /* Filename of image */ +}; + +struct vk_reset { +	__u32 arg1; +	__u32 arg2; +}; + +#define VK_MAGIC		0x5e + +/* Load image to Valkyrie */ +#define VK_IOCTL_LOAD_IMAGE	_IOW(VK_MAGIC, 0x2, struct vk_image) + +/* Send Reset to Valkyrie */ +#define VK_IOCTL_RESET		_IOW(VK_MAGIC, 0x4, struct vk_reset) + +/* + * Firmware Status accessed directly via BAR space + */ +#define VK_BAR_FWSTS			0x41c +#define VK_BAR_COP_FWSTS		0x428 +/* VK_FWSTS definitions */ +#define VK_FWSTS_RELOCATION_ENTRY	(1UL << 0) +#define VK_FWSTS_RELOCATION_EXIT	(1UL << 1) +#define VK_FWSTS_INIT_START		(1UL << 2) +#define VK_FWSTS_ARCH_INIT_DONE		(1UL << 3) +#define VK_FWSTS_PRE_KNL1_INIT_DONE	(1UL << 4) +#define VK_FWSTS_PRE_KNL2_INIT_DONE	(1UL << 5) +#define VK_FWSTS_POST_KNL_INIT_DONE	(1UL << 6) +#define VK_FWSTS_INIT_DONE		(1UL << 7) +#define VK_FWSTS_APP_INIT_START		(1UL << 8) +#define VK_FWSTS_APP_INIT_DONE		(1UL << 9) +#define VK_FWSTS_MASK			0xffffffff +#define VK_FWSTS_READY			(VK_FWSTS_INIT_START | \ +					 VK_FWSTS_ARCH_INIT_DONE | \ +					 VK_FWSTS_PRE_KNL1_INIT_DONE | \ +					 VK_FWSTS_PRE_KNL2_INIT_DONE | \ +					 VK_FWSTS_POST_KNL_INIT_DONE | \ +					 VK_FWSTS_INIT_DONE | \ +					 VK_FWSTS_APP_INIT_START | \ +					 VK_FWSTS_APP_INIT_DONE) +/* Deinit */ +#define VK_FWSTS_APP_DEINIT_START	(1UL << 23) +#define VK_FWSTS_APP_DEINIT_DONE	(1UL << 24) +#define VK_FWSTS_DRV_DEINIT_START	(1UL << 25) +#define VK_FWSTS_DRV_DEINIT_DONE	(1UL << 26) +#define VK_FWSTS_RESET_DONE		(1UL << 27) +#define VK_FWSTS_DEINIT_TRIGGERED	(VK_FWSTS_APP_DEINIT_START | \ +					 VK_FWSTS_APP_DEINIT_DONE  | \ +					 VK_FWSTS_DRV_DEINIT_START | \ +					 VK_FWSTS_DRV_DEINIT_DONE) +/* Last nibble for reboot reason */ +#define VK_FWSTS_RESET_REASON_SHIFT	28 +#define VK_FWSTS_RESET_REASON_MASK	(0xf << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_SYS_PWRUP	(0x0 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_MBOX_DB		(0x1 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_M7_WDOG		(0x2 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_TEMP		(0x3 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_PCI_FLR		(0x4 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_PCI_HOT		(0x5 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_PCI_WARM		(0x6 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_PCI_COLD		(0x7 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_L1		(0x8 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_L0		(0x9 << VK_FWSTS_RESET_REASON_SHIFT) +#define VK_FWSTS_RESET_UNKNOWN		(0xf << VK_FWSTS_RESET_REASON_SHIFT) + +#endif /* __UAPI_LINUX_MISC_BCM_VK_H */ diff --git a/include/uapi/linux/mman.h b/include/uapi/linux/mman.h index 923cc162609c..e89d00528f2f 100644 --- a/include/uapi/linux/mman.h +++ b/include/uapi/linux/mman.h @@ -4,6 +4,7 @@  #include <asm/mman.h>  #include <asm-generic/hugetlb_encode.h> +#include <linux/types.h>  #define MREMAP_MAYMOVE		1  #define MREMAP_FIXED		2 @@ -16,6 +17,7 @@  #define MAP_SHARED	0x01		/* Share changes */  #define MAP_PRIVATE	0x02		/* Changes are private */  #define MAP_SHARED_VALIDATE 0x03	/* share + validate extension flags */ +#define MAP_DROPPABLE	0x08		/* Zero memory under memory pressure. */  /*   * Huge page size encoding when MAP_HUGETLB is specified, and a huge page @@ -27,6 +29,7 @@  #define MAP_HUGE_SHIFT	HUGETLB_FLAG_ENCODE_SHIFT  #define MAP_HUGE_MASK	HUGETLB_FLAG_ENCODE_MASK +#define MAP_HUGE_16KB	HUGETLB_FLAG_ENCODE_16KB  #define MAP_HUGE_64KB	HUGETLB_FLAG_ENCODE_64KB  #define MAP_HUGE_512KB	HUGETLB_FLAG_ENCODE_512KB  #define MAP_HUGE_1MB	HUGETLB_FLAG_ENCODE_1MB @@ -40,4 +43,17 @@  #define MAP_HUGE_2GB	HUGETLB_FLAG_ENCODE_2GB  #define MAP_HUGE_16GB	HUGETLB_FLAG_ENCODE_16GB +struct cachestat_range { +	__u64 off; +	__u64 len; +}; + +struct cachestat { +	__u64 nr_cache; +	__u64 nr_dirty; +	__u64 nr_writeback; +	__u64 nr_evicted; +	__u64 nr_recently_evicted; +}; +  #endif /* _UAPI_LINUX_MMAN_H */ diff --git a/include/uapi/linux/mmc/ioctl.h b/include/uapi/linux/mmc/ioctl.h index 27a39847d55c..e7401ade6822 100644 --- a/include/uapi/linux/mmc/ioctl.h +++ b/include/uapi/linux/mmc/ioctl.h @@ -58,7 +58,7 @@ struct mmc_ioc_cmd {   */  struct mmc_ioc_multi_cmd {  	__u64 num_of_cmds; -	struct mmc_ioc_cmd cmds[0]; +	struct mmc_ioc_cmd cmds[];  };  #define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd) diff --git a/include/uapi/linux/module.h b/include/uapi/linux/module.h index 50d98ec5e866..03a33ffffcba 100644 --- a/include/uapi/linux/module.h +++ b/include/uapi/linux/module.h @@ -5,5 +5,6 @@  /* Flags for sys_finit_module: */  #define MODULE_INIT_IGNORE_MODVERSIONS	1  #define MODULE_INIT_IGNORE_VERMAGIC	2 +#define MODULE_INIT_COMPRESSED_FILE	4  #endif /* _UAPI_LINUX_MODULE_H */ diff --git a/include/uapi/linux/mount.h b/include/uapi/linux/mount.h index 96a0240f23fe..7fa67c2031a5 100644 --- a/include/uapi/linux/mount.h +++ b/include/uapi/linux/mount.h @@ -1,6 +1,8 @@  #ifndef _UAPI_LINUX_MOUNT_H  #define _UAPI_LINUX_MOUNT_H +#include <linux/types.h> +  /*   * These are the fs-independent mount-flags: up to 32 flags are supported   * @@ -16,6 +18,7 @@  #define MS_REMOUNT	32	/* Alter flags of a mounted FS */  #define MS_MANDLOCK	64	/* Allow mandatory locks on an FS */  #define MS_DIRSYNC	128	/* Directory modifications are synchronous */ +#define MS_NOSYMFOLLOW	256	/* Do not follow symlinks */  #define MS_NOATIME	1024	/* Do not update access times. */  #define MS_NODIRATIME	2048	/* Do not update directory access times */  #define MS_BIND		4096 @@ -70,7 +73,9 @@  #define MOVE_MOUNT_T_SYMLINKS		0x00000010 /* Follow symlinks on to path */  #define MOVE_MOUNT_T_AUTOMOUNTS		0x00000020 /* Follow automounts on to path */  #define MOVE_MOUNT_T_EMPTY_PATH		0x00000040 /* Empty to path permitted */ -#define MOVE_MOUNT__MASK		0x00000077 +#define MOVE_MOUNT_SET_GROUP		0x00000100 /* Set sharing group instead */ +#define MOVE_MOUNT_BENEATH		0x00000200 /* Mount beneath top mount */ +#define MOVE_MOUNT__MASK		0x00000377  /*   * fsopen() flags. @@ -95,8 +100,9 @@ enum fsconfig_command {  	FSCONFIG_SET_PATH	= 3,	/* Set parameter, supplying an object by path */  	FSCONFIG_SET_PATH_EMPTY	= 4,	/* Set parameter, supplying an object by (empty) path */  	FSCONFIG_SET_FD		= 5,	/* Set parameter, supplying an object by fd */ -	FSCONFIG_CMD_CREATE	= 6,	/* Invoke superblock creation */ +	FSCONFIG_CMD_CREATE	= 6,	/* Create new or reuse existing superblock */  	FSCONFIG_CMD_RECONFIGURE = 7,	/* Invoke superblock reconfiguration */ +	FSCONFIG_CMD_CREATE_EXCL = 8,	/* Create new superblock, fail if reusing existing superblock */  };  /* @@ -116,5 +122,114 @@ enum fsconfig_command {  #define MOUNT_ATTR_NOATIME	0x00000010 /* - Do not update access times. */  #define MOUNT_ATTR_STRICTATIME	0x00000020 /* - Always perform atime updates */  #define MOUNT_ATTR_NODIRATIME	0x00000080 /* Do not update directory access times */ +#define MOUNT_ATTR_IDMAP	0x00100000 /* Idmap mount to @userns_fd in struct mount_attr. */ +#define MOUNT_ATTR_NOSYMFOLLOW	0x00200000 /* Do not follow symlinks */ + +/* + * mount_setattr() + */ +struct mount_attr { +	__u64 attr_set; +	__u64 attr_clr; +	__u64 propagation; +	__u64 userns_fd; +}; + +/* List of all mount_attr versions. */ +#define MOUNT_ATTR_SIZE_VER0	32 /* sizeof first published struct */ + + +/* + * Structure for getting mount/superblock/filesystem info with statmount(2). + * + * The interface is similar to statx(2): individual fields or groups can be + * selected with the @mask argument of statmount().  Kernel will set the @mask + * field according to the supported fields. + * + * If string fields are selected, then the caller needs to pass a buffer that + * has space after the fixed part of the structure.  Nul terminated strings are + * copied there and offsets relative to @str are stored in the relevant fields. + * If the buffer is too small, then EOVERFLOW is returned.  The actually used + * size is returned in @size. + */ +struct statmount { +	__u32 size;		/* Total size, including strings */ +	__u32 mnt_opts;		/* [str] Options (comma separated, escaped) */ +	__u64 mask;		/* What results were written */ +	__u32 sb_dev_major;	/* Device ID */ +	__u32 sb_dev_minor; +	__u64 sb_magic;		/* ..._SUPER_MAGIC */ +	__u32 sb_flags;		/* SB_{RDONLY,SYNCHRONOUS,DIRSYNC,LAZYTIME} */ +	__u32 fs_type;		/* [str] Filesystem type */ +	__u64 mnt_id;		/* Unique ID of mount */ +	__u64 mnt_parent_id;	/* Unique ID of parent (for root == mnt_id) */ +	__u32 mnt_id_old;	/* Reused IDs used in proc/.../mountinfo */ +	__u32 mnt_parent_id_old; +	__u64 mnt_attr;		/* MOUNT_ATTR_... */ +	__u64 mnt_propagation;	/* MS_{SHARED,SLAVE,PRIVATE,UNBINDABLE} */ +	__u64 mnt_peer_group;	/* ID of shared peer group */ +	__u64 mnt_master;	/* Mount receives propagation from this ID */ +	__u64 propagate_from;	/* Propagation from in current namespace */ +	__u32 mnt_root;		/* [str] Root of mount relative to root of fs */ +	__u32 mnt_point;	/* [str] Mountpoint relative to current root */ +	__u64 mnt_ns_id;	/* ID of the mount namespace */ +	__u32 fs_subtype;	/* [str] Subtype of fs_type (if any) */ +	__u32 sb_source;	/* [str] Source string of the mount */ +	__u32 opt_num;		/* Number of fs options */ +	__u32 opt_array;	/* [str] Array of nul terminated fs options */ +	__u32 opt_sec_num;	/* Number of security options */ +	__u32 opt_sec_array;	/* [str] Array of nul terminated security options */ +	__u64 supported_mask;	/* Mask flags that this kernel supports */ +	__u32 mnt_uidmap_num;	/* Number of uid mappings */ +	__u32 mnt_uidmap;	/* [str] Array of uid mappings (as seen from callers namespace) */ +	__u32 mnt_gidmap_num;	/* Number of gid mappings */ +	__u32 mnt_gidmap;	/* [str] Array of gid mappings (as seen from callers namespace) */ +	__u64 __spare2[43]; +	char str[];		/* Variable size part containing strings */ +}; + +/* + * Structure for passing mount ID and miscellaneous parameters to statmount(2) + * and listmount(2). + * + * For statmount(2) @param represents the request mask. + * For listmount(2) @param represents the last listed mount id (or zero). + */ +struct mnt_id_req { +	__u32 size; +	__u32 spare; +	__u64 mnt_id; +	__u64 param; +	__u64 mnt_ns_id; +}; + +/* List of all mnt_id_req versions. */ +#define MNT_ID_REQ_SIZE_VER0	24 /* sizeof first published struct */ +#define MNT_ID_REQ_SIZE_VER1	32 /* sizeof second published struct */ + +/* + * @mask bits for statmount(2) + */ +#define STATMOUNT_SB_BASIC		0x00000001U     /* Want/got sb_... */ +#define STATMOUNT_MNT_BASIC		0x00000002U	/* Want/got mnt_... */ +#define STATMOUNT_PROPAGATE_FROM	0x00000004U	/* Want/got propagate_from */ +#define STATMOUNT_MNT_ROOT		0x00000008U	/* Want/got mnt_root  */ +#define STATMOUNT_MNT_POINT		0x00000010U	/* Want/got mnt_point */ +#define STATMOUNT_FS_TYPE		0x00000020U	/* Want/got fs_type */ +#define STATMOUNT_MNT_NS_ID		0x00000040U	/* Want/got mnt_ns_id */ +#define STATMOUNT_MNT_OPTS		0x00000080U	/* Want/got mnt_opts */ +#define STATMOUNT_FS_SUBTYPE		0x00000100U	/* Want/got fs_subtype */ +#define STATMOUNT_SB_SOURCE		0x00000200U	/* Want/got sb_source */ +#define STATMOUNT_OPT_ARRAY		0x00000400U	/* Want/got opt_... */ +#define STATMOUNT_OPT_SEC_ARRAY		0x00000800U	/* Want/got opt_sec... */ +#define STATMOUNT_SUPPORTED_MASK	0x00001000U	/* Want/got supported mask flags */ +#define STATMOUNT_MNT_UIDMAP		0x00002000U	/* Want/got uidmap... */ +#define STATMOUNT_MNT_GIDMAP		0x00004000U	/* Want/got gidmap... */ + +/* + * Special @mnt_id values that can be passed to listmount + */ +#define LSMT_ROOT		0xffffffffffffffff	/* root mount */ +#define LISTMOUNT_REVERSE	(1 << 0) /* List later mounts first */  #endif /* _UAPI_LINUX_MOUNT_H */ diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 9762660df741..67d015df8893 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -2,8 +2,16 @@  #ifndef _UAPI_MPTCP_H  #define _UAPI_MPTCP_H +#ifndef __KERNEL__ +#include <netinet/in.h>		/* for sockaddr_in and sockaddr_in6	*/ +#include <sys/socket.h>		/* for struct sockaddr			*/ +#endif +  #include <linux/const.h>  #include <linux/types.h> +#include <linux/in.h>		/* for sockaddr_in			*/ +#include <linux/in6.h>		/* for sockaddr_in6			*/ +#include <linux/socket.h>	/* for sockaddr_storage and sa_family	*/  #define MPTCP_SUBFLOW_FLAG_MCAP_REM		_BITUL(0)  #define MPTCP_SUBFLOW_FLAG_MCAP_LOC		_BITUL(1) @@ -15,80 +23,20 @@  #define MPTCP_SUBFLOW_FLAG_CONNECTED		_BITUL(7)  #define MPTCP_SUBFLOW_FLAG_MAPVALID		_BITUL(8) -enum { -	MPTCP_SUBFLOW_ATTR_UNSPEC, -	MPTCP_SUBFLOW_ATTR_TOKEN_REM, -	MPTCP_SUBFLOW_ATTR_TOKEN_LOC, -	MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ, -	MPTCP_SUBFLOW_ATTR_MAP_SEQ, -	MPTCP_SUBFLOW_ATTR_MAP_SFSEQ, -	MPTCP_SUBFLOW_ATTR_SSN_OFFSET, -	MPTCP_SUBFLOW_ATTR_MAP_DATALEN, -	MPTCP_SUBFLOW_ATTR_FLAGS, -	MPTCP_SUBFLOW_ATTR_ID_REM, -	MPTCP_SUBFLOW_ATTR_ID_LOC, -	MPTCP_SUBFLOW_ATTR_PAD, -	__MPTCP_SUBFLOW_ATTR_MAX -}; - -#define MPTCP_SUBFLOW_ATTR_MAX (__MPTCP_SUBFLOW_ATTR_MAX - 1) - -/* netlink interface */ -#define MPTCP_PM_NAME		"mptcp_pm"  #define MPTCP_PM_CMD_GRP_NAME	"mptcp_pm_cmds" -#define MPTCP_PM_VER		0x1 - -/* - * ATTR types defined for MPTCP - */ -enum { -	MPTCP_PM_ATTR_UNSPEC, - -	MPTCP_PM_ATTR_ADDR,				/* nested address */ -	MPTCP_PM_ATTR_RCV_ADD_ADDRS,			/* u32 */ -	MPTCP_PM_ATTR_SUBFLOWS,				/* u32 */ - -	__MPTCP_PM_ATTR_MAX -}; - -#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1) - -enum { -	MPTCP_PM_ADDR_ATTR_UNSPEC, - -	MPTCP_PM_ADDR_ATTR_FAMILY,			/* u16 */ -	MPTCP_PM_ADDR_ATTR_ID,				/* u8 */ -	MPTCP_PM_ADDR_ATTR_ADDR4,			/* struct in_addr */ -	MPTCP_PM_ADDR_ATTR_ADDR6,			/* struct in6_addr */ -	MPTCP_PM_ADDR_ATTR_PORT,			/* u16 */ -	MPTCP_PM_ADDR_ATTR_FLAGS,			/* u32 */ -	MPTCP_PM_ADDR_ATTR_IF_IDX,			/* s32 */ - -	__MPTCP_PM_ADDR_ATTR_MAX -}; +#define MPTCP_PM_EV_GRP_NAME	"mptcp_pm_events" -#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1) - -#define MPTCP_PM_ADDR_FLAG_SIGNAL			(1 << 0) -#define MPTCP_PM_ADDR_FLAG_SUBFLOW			(1 << 1) -#define MPTCP_PM_ADDR_FLAG_BACKUP			(1 << 2) - -enum { -	MPTCP_PM_CMD_UNSPEC, - -	MPTCP_PM_CMD_ADD_ADDR, -	MPTCP_PM_CMD_DEL_ADDR, -	MPTCP_PM_CMD_GET_ADDR, -	MPTCP_PM_CMD_FLUSH_ADDRS, -	MPTCP_PM_CMD_SET_LIMITS, -	MPTCP_PM_CMD_GET_LIMITS, - -	__MPTCP_PM_CMD_AFTER_LAST -}; +#include <linux/mptcp_pm.h>  #define MPTCP_INFO_FLAG_FALLBACK		_BITUL(0)  #define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED	_BITUL(1) +#define MPTCP_PM_ADDR_FLAG_SIGNAL                      (1 << 0) +#define MPTCP_PM_ADDR_FLAG_SUBFLOW                     (1 << 1) +#define MPTCP_PM_ADDR_FLAG_BACKUP                      (1 << 2) +#define MPTCP_PM_ADDR_FLAG_FULLMESH                    (1 << 3) +#define MPTCP_PM_ADDR_FLAG_IMPLICIT                    (1 << 4) +  struct mptcp_info {  	__u8	mptcpi_subflows;  	__u8	mptcpi_add_addr_signal; @@ -101,6 +49,80 @@ struct mptcp_info {  	__u64	mptcpi_write_seq;  	__u64	mptcpi_snd_una;  	__u64	mptcpi_rcv_nxt; +	__u8	mptcpi_local_addr_used; +	__u8	mptcpi_local_addr_max; +	__u8	mptcpi_csum_enabled; +	__u32	mptcpi_retransmits; +	__u64	mptcpi_bytes_retrans; +	__u64	mptcpi_bytes_sent; +	__u64	mptcpi_bytes_received; +	__u64	mptcpi_bytes_acked; +	__u8	mptcpi_subflows_total; +	__u8	reserved[3]; +	__u32	mptcpi_last_data_sent; +	__u32	mptcpi_last_data_recv; +	__u32	mptcpi_last_ack_recv;  }; +/* MPTCP Reset reason codes, rfc8684 */ +#define MPTCP_RST_EUNSPEC	0 +#define MPTCP_RST_EMPTCP	1 +#define MPTCP_RST_ERESOURCE	2 +#define MPTCP_RST_EPROHIBIT	3 +#define MPTCP_RST_EWQ2BIG	4 +#define MPTCP_RST_EBADPERF	5 +#define MPTCP_RST_EMIDDLEBOX	6 + +struct mptcp_subflow_data { +	__u32		size_subflow_data;		/* size of this structure in userspace */ +	__u32		num_subflows;			/* must be 0, set by kernel */ +	__u32		size_kernel;			/* must be 0, set by kernel */ +	__u32		size_user;			/* size of one element in data[] */ +} __attribute__((aligned(8))); + +struct mptcp_subflow_addrs { +	union { +		__kernel_sa_family_t sa_family; +		struct sockaddr sa_local; +		struct sockaddr_in sin_local; +		struct sockaddr_in6 sin6_local; +		struct __kernel_sockaddr_storage ss_local; +	}; +	union { +		struct sockaddr sa_remote; +		struct sockaddr_in sin_remote; +		struct sockaddr_in6 sin6_remote; +		struct __kernel_sockaddr_storage ss_remote; +	}; +}; + +struct mptcp_subflow_info { +	__u32				id; +	struct mptcp_subflow_addrs	addrs; +}; + +struct mptcp_full_info { +	__u32		size_tcpinfo_kernel;	/* must be 0, set by kernel */ +	__u32		size_tcpinfo_user; +	__u32		size_sfinfo_kernel;	/* must be 0, set by kernel */ +	__u32		size_sfinfo_user; +	__u32		num_subflows;		/* must be 0, set by kernel (real subflow count) */ +	__u32		size_arrays_user;	/* max subflows that userspace is interested in; +						 * the buffers at subflow_info/tcp_info +						 * are respectively at least: +						 *  size_arrays * size_sfinfo_user +						 *  size_arrays * size_tcpinfo_user +						 * bytes wide +						 */ +	__aligned_u64		subflow_info; +	__aligned_u64		tcp_info; +	struct mptcp_info	mptcp_info; +}; + +/* MPTCP socket options */ +#define MPTCP_INFO		1 +#define MPTCP_TCPINFO		2 +#define MPTCP_SUBFLOW_ADDRS	3 +#define MPTCP_FULL_INFO		4 +  #endif /* _UAPI_MPTCP_H */ diff --git a/include/uapi/linux/mptcp_pm.h b/include/uapi/linux/mptcp_pm.h new file mode 100644 index 000000000000..6ac84b2f636c --- /dev/null +++ b/include/uapi/linux/mptcp_pm.h @@ -0,0 +1,152 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/mptcp_pm.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_MPTCP_PM_H +#define _UAPI_LINUX_MPTCP_PM_H + +#define MPTCP_PM_NAME	"mptcp_pm" +#define MPTCP_PM_VER	1 + +/** + * enum mptcp_event_type + * @MPTCP_EVENT_UNSPEC: unused event + * @MPTCP_EVENT_CREATED: A new MPTCP connection has been created. It is the + *   good time to allocate memory and send ADD_ADDR if needed. Depending on the + *   traffic-patterns it can take a long time until the MPTCP_EVENT_ESTABLISHED + *   is sent. Attributes: token, family, saddr4 | saddr6, daddr4 | daddr6, + *   sport, dport, server-side. + * @MPTCP_EVENT_ESTABLISHED: A MPTCP connection is established (can start new + *   subflows). Attributes: token, family, saddr4 | saddr6, daddr4 | daddr6, + *   sport, dport, server-side. + * @MPTCP_EVENT_CLOSED: A MPTCP connection has stopped. Attribute: token. + * @MPTCP_EVENT_ANNOUNCED: A new address has been announced by the peer. + *   Attributes: token, rem_id, family, daddr4 | daddr6 [, dport]. + * @MPTCP_EVENT_REMOVED: An address has been lost by the peer. Attributes: + *   token, rem_id. + * @MPTCP_EVENT_SUB_ESTABLISHED: A new subflow has been established. 'error' + *   should not be set. Attributes: token, family, loc_id, rem_id, saddr4 | + *   saddr6, daddr4 | daddr6, sport, dport, backup, if-idx [, error]. + * @MPTCP_EVENT_SUB_CLOSED: A subflow has been closed. An error (copy of + *   sk_err) could be set if an error has been detected for this subflow. + *   Attributes: token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 | + *   daddr6, sport, dport, backup, if-idx [, error]. + * @MPTCP_EVENT_SUB_PRIORITY: The priority of a subflow has changed. 'error' + *   should not be set. Attributes: token, family, loc_id, rem_id, saddr4 | + *   saddr6, daddr4 | daddr6, sport, dport, backup, if-idx [, error]. + * @MPTCP_EVENT_LISTENER_CREATED: A new PM listener is created. Attributes: + *   family, sport, saddr4 | saddr6. + * @MPTCP_EVENT_LISTENER_CLOSED: A PM listener is closed. Attributes: family, + *   sport, saddr4 | saddr6. + */ +enum mptcp_event_type { +	MPTCP_EVENT_UNSPEC, +	MPTCP_EVENT_CREATED, +	MPTCP_EVENT_ESTABLISHED, +	MPTCP_EVENT_CLOSED, +	MPTCP_EVENT_ANNOUNCED = 6, +	MPTCP_EVENT_REMOVED, +	MPTCP_EVENT_SUB_ESTABLISHED = 10, +	MPTCP_EVENT_SUB_CLOSED, +	MPTCP_EVENT_SUB_PRIORITY = 13, +	MPTCP_EVENT_LISTENER_CREATED = 15, +	MPTCP_EVENT_LISTENER_CLOSED, +}; + +enum { +	MPTCP_PM_ADDR_ATTR_UNSPEC, +	MPTCP_PM_ADDR_ATTR_FAMILY, +	MPTCP_PM_ADDR_ATTR_ID, +	MPTCP_PM_ADDR_ATTR_ADDR4, +	MPTCP_PM_ADDR_ATTR_ADDR6, +	MPTCP_PM_ADDR_ATTR_PORT, +	MPTCP_PM_ADDR_ATTR_FLAGS, +	MPTCP_PM_ADDR_ATTR_IF_IDX, + +	__MPTCP_PM_ADDR_ATTR_MAX +}; +#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1) + +enum { +	MPTCP_SUBFLOW_ATTR_UNSPEC, +	MPTCP_SUBFLOW_ATTR_TOKEN_REM, +	MPTCP_SUBFLOW_ATTR_TOKEN_LOC, +	MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ, +	MPTCP_SUBFLOW_ATTR_MAP_SEQ, +	MPTCP_SUBFLOW_ATTR_MAP_SFSEQ, +	MPTCP_SUBFLOW_ATTR_SSN_OFFSET, +	MPTCP_SUBFLOW_ATTR_MAP_DATALEN, +	MPTCP_SUBFLOW_ATTR_FLAGS, +	MPTCP_SUBFLOW_ATTR_ID_REM, +	MPTCP_SUBFLOW_ATTR_ID_LOC, +	MPTCP_SUBFLOW_ATTR_PAD, + +	__MPTCP_SUBFLOW_ATTR_MAX +}; +#define MPTCP_SUBFLOW_ATTR_MAX (__MPTCP_SUBFLOW_ATTR_MAX - 1) + +enum { +	MPTCP_PM_ENDPOINT_ADDR = 1, + +	__MPTCP_PM_ENDPOINT_MAX +}; +#define MPTCP_PM_ENDPOINT_MAX (__MPTCP_PM_ENDPOINT_MAX - 1) + +enum { +	MPTCP_PM_ATTR_UNSPEC, +	MPTCP_PM_ATTR_ADDR, +	MPTCP_PM_ATTR_RCV_ADD_ADDRS, +	MPTCP_PM_ATTR_SUBFLOWS, +	MPTCP_PM_ATTR_TOKEN, +	MPTCP_PM_ATTR_LOC_ID, +	MPTCP_PM_ATTR_ADDR_REMOTE, + +	__MPTCP_ATTR_AFTER_LAST +}; +#define MPTCP_PM_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1) + +enum mptcp_event_attr { +	MPTCP_ATTR_UNSPEC, +	MPTCP_ATTR_TOKEN, +	MPTCP_ATTR_FAMILY, +	MPTCP_ATTR_LOC_ID, +	MPTCP_ATTR_REM_ID, +	MPTCP_ATTR_SADDR4, +	MPTCP_ATTR_SADDR6, +	MPTCP_ATTR_DADDR4, +	MPTCP_ATTR_DADDR6, +	MPTCP_ATTR_SPORT, +	MPTCP_ATTR_DPORT, +	MPTCP_ATTR_BACKUP, +	MPTCP_ATTR_ERROR, +	MPTCP_ATTR_FLAGS, +	MPTCP_ATTR_TIMEOUT, +	MPTCP_ATTR_IF_IDX, +	MPTCP_ATTR_RESET_REASON, +	MPTCP_ATTR_RESET_FLAGS, +	MPTCP_ATTR_SERVER_SIDE, + +	__MPTCP_ATTR_MAX +}; +#define MPTCP_ATTR_MAX (__MPTCP_ATTR_MAX - 1) + +enum { +	MPTCP_PM_CMD_UNSPEC, +	MPTCP_PM_CMD_ADD_ADDR, +	MPTCP_PM_CMD_DEL_ADDR, +	MPTCP_PM_CMD_GET_ADDR, +	MPTCP_PM_CMD_FLUSH_ADDRS, +	MPTCP_PM_CMD_SET_LIMITS, +	MPTCP_PM_CMD_GET_LIMITS, +	MPTCP_PM_CMD_SET_FLAGS, +	MPTCP_PM_CMD_ANNOUNCE, +	MPTCP_PM_CMD_REMOVE, +	MPTCP_PM_CMD_SUBFLOW_CREATE, +	MPTCP_PM_CMD_SUBFLOW_DESTROY, + +	__MPTCP_PM_CMD_AFTER_LAST +}; +#define MPTCP_PM_CMD_MAX (__MPTCP_PM_CMD_AFTER_LAST - 1) + +#endif /* _UAPI_LINUX_MPTCP_PM_H */ diff --git a/include/uapi/linux/mroute.h b/include/uapi/linux/mroute.h index 11c8c1fc1124..1a42f5f9b31b 100644 --- a/include/uapi/linux/mroute.h +++ b/include/uapi/linux/mroute.h @@ -113,8 +113,8 @@ struct igmpmsg {  	__u32 unused1,unused2;  	unsigned char im_msgtype;		/* What is this */  	unsigned char im_mbz;			/* Must be zero */ -	unsigned char im_vif;			/* Interface (this ought to be a vifi_t!) */ -	unsigned char unused3; +	unsigned char im_vif;			/* Low 8 bits of Interface */ +	unsigned char im_vif_hi;		/* High 8 bits of Interface */  	struct in_addr im_src,im_dst;  }; @@ -169,6 +169,7 @@ enum {  	IPMRA_CREPORT_SRC_ADDR,  	IPMRA_CREPORT_DST_ADDR,  	IPMRA_CREPORT_PKT, +	IPMRA_CREPORT_TABLE,  	__IPMRA_CREPORT_MAX  };  #define IPMRA_CREPORT_MAX (__IPMRA_CREPORT_MAX - 1) diff --git a/include/uapi/linux/mroute6.h b/include/uapi/linux/mroute6.h index c36177a86516..1d90c21a6251 100644 --- a/include/uapi/linux/mroute6.h +++ b/include/uapi/linux/mroute6.h @@ -2,7 +2,7 @@  #ifndef _UAPI__LINUX_MROUTE6_H  #define _UAPI__LINUX_MROUTE6_H -#include <linux/kernel.h> +#include <linux/const.h>  #include <linux/types.h>  #include <linux/sockios.h>  #include <linux/in6.h>		/* For struct sockaddr_in6. */ @@ -134,6 +134,7 @@ struct mrt6msg {  #define MRT6MSG_NOCACHE		1  #define MRT6MSG_WRONGMIF	2  #define MRT6MSG_WHOLEPKT	3		/* used for use level encap */ +#define MRT6MSG_WRMIFWHOLE	4		/* For PIM Register and assert processing */  	__u8		im6_mbz;		/* must be zero		   */  	__u8		im6_msgtype;		/* what type of message    */  	__u16		im6_mif;		/* mif rec'd on		   */ diff --git a/include/uapi/linux/mrp_bridge.h b/include/uapi/linux/mrp_bridge.h index 6aeb13ef0b1e..bd4424de56ff 100644 --- a/include/uapi/linux/mrp_bridge.h +++ b/include/uapi/linux/mrp_bridge.h @@ -61,6 +61,7 @@ enum br_mrp_tlv_header_type {  	BR_MRP_TLV_HEADER_IN_TOPO = 0x7,  	BR_MRP_TLV_HEADER_IN_LINK_DOWN = 0x8,  	BR_MRP_TLV_HEADER_IN_LINK_UP = 0x9, +	BR_MRP_TLV_HEADER_IN_LINK_STATUS = 0xa,  	BR_MRP_TLV_HEADER_OPTION = 0x7f,  }; @@ -70,90 +71,4 @@ enum br_mrp_sub_tlv_header_type {  	BR_MRP_SUB_TLV_HEADER_TEST_AUTO_MGR = 0x3,  }; -struct br_mrp_tlv_hdr { -	__u8 type; -	__u8 length; -}; - -struct br_mrp_sub_tlv_hdr { -	__u8 type; -	__u8 length; -}; - -struct br_mrp_end_hdr { -	struct br_mrp_tlv_hdr hdr; -}; - -struct br_mrp_common_hdr { -	__be16 seq_id; -	__u8 domain[MRP_DOMAIN_UUID_LENGTH]; -}; - -struct br_mrp_ring_test_hdr { -	__be16 prio; -	__u8 sa[ETH_ALEN]; -	__be16 port_role; -	__be16 state; -	__be16 transitions; -	__be32 timestamp; -}; - -struct br_mrp_ring_topo_hdr { -	__be16 prio; -	__u8 sa[ETH_ALEN]; -	__be16 interval; -}; - -struct br_mrp_ring_link_hdr { -	__u8 sa[ETH_ALEN]; -	__be16 port_role; -	__be16 interval; -	__be16 blocked; -}; - -struct br_mrp_sub_opt_hdr { -	__u8 type; -	__u8 manufacture_data[MRP_MANUFACTURE_DATA_LENGTH]; -}; - -struct br_mrp_test_mgr_nack_hdr { -	__be16 prio; -	__u8 sa[ETH_ALEN]; -	__be16 other_prio; -	__u8 other_sa[ETH_ALEN]; -}; - -struct br_mrp_test_prop_hdr { -	__be16 prio; -	__u8 sa[ETH_ALEN]; -	__be16 other_prio; -	__u8 other_sa[ETH_ALEN]; -}; - -struct br_mrp_oui_hdr { -	__u8 oui[MRP_OUI_LENGTH]; -}; - -struct br_mrp_in_test_hdr { -	__be16 id; -	__u8 sa[ETH_ALEN]; -	__be16 port_role; -	__be16 state; -	__be16 transitions; -	__be32 timestamp; -}; - -struct br_mrp_in_topo_hdr { -	__u8 sa[ETH_ALEN]; -	__be16 id; -	__be16 interval; -}; - -struct br_mrp_in_link_hdr { -	__u8 sa[ETH_ALEN]; -	__be16 port_role; -	__be16 id; -	__be16 interval; -}; -  #endif diff --git a/include/uapi/linux/mshv.h b/include/uapi/linux/mshv.h new file mode 100644 index 000000000000..876bfe4e4227 --- /dev/null +++ b/include/uapi/linux/mshv.h @@ -0,0 +1,291 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Userspace interfaces for /dev/mshv* devices and derived fds + * + * This file is divided into sections containing data structures and IOCTLs for + * a particular set of related devices or derived file descriptors. + * + * The IOCTL definitions are at the end of each section. They are grouped by + * device/fd, so that new IOCTLs can easily be added with a monotonically + * increasing number. + */ +#ifndef _UAPI_LINUX_MSHV_H +#define _UAPI_LINUX_MSHV_H + +#include <linux/types.h> + +#define MSHV_IOCTL	0xB8 + +/* + ******************************************* + * Entry point to main VMM APIs: /dev/mshv * + ******************************************* + */ + +enum { +	MSHV_PT_BIT_LAPIC, +	MSHV_PT_BIT_X2APIC, +	MSHV_PT_BIT_GPA_SUPER_PAGES, +	MSHV_PT_BIT_COUNT, +}; + +#define MSHV_PT_FLAGS_MASK ((1 << MSHV_PT_BIT_COUNT) - 1) + +enum { +	MSHV_PT_ISOLATION_NONE, +	MSHV_PT_ISOLATION_COUNT, +}; + +/** + * struct mshv_create_partition - arguments for MSHV_CREATE_PARTITION + * @pt_flags: Bitmask of 1 << MSHV_PT_BIT_* + * @pt_isolation: MSHV_PT_ISOLATION_* + * + * Returns a file descriptor to act as a handle to a guest partition. + * At this point the partition is not yet initialized in the hypervisor. + * Some operations must be done with the partition in this state, e.g. setting + * so-called "early" partition properties. The partition can then be + * initialized with MSHV_INITIALIZE_PARTITION. + */ +struct mshv_create_partition { +	__u64 pt_flags; +	__u64 pt_isolation; +}; + +/* /dev/mshv */ +#define MSHV_CREATE_PARTITION	_IOW(MSHV_IOCTL, 0x00, struct mshv_create_partition) + +/* + ************************ + * Child partition APIs * + ************************ + */ + +struct mshv_create_vp { +	__u32 vp_index; +}; + +enum { +	MSHV_SET_MEM_BIT_WRITABLE, +	MSHV_SET_MEM_BIT_EXECUTABLE, +	MSHV_SET_MEM_BIT_UNMAP, +	MSHV_SET_MEM_BIT_COUNT +}; + +#define MSHV_SET_MEM_FLAGS_MASK ((1 << MSHV_SET_MEM_BIT_COUNT) - 1) + +/* The hypervisor's "native" page size */ +#define MSHV_HV_PAGE_SIZE	0x1000 + +/** + * struct mshv_user_mem_region - arguments for MSHV_SET_GUEST_MEMORY + * @size: Size of the memory region (bytes). Must be aligned to + *        MSHV_HV_PAGE_SIZE + * @guest_pfn: Base guest page number to map + * @userspace_addr: Base address of userspace memory. Must be aligned to + *                  MSHV_HV_PAGE_SIZE + * @flags: Bitmask of 1 << MSHV_SET_MEM_BIT_*. If (1 << MSHV_SET_MEM_BIT_UNMAP) + *         is set, ignore other bits. + * @rsvd: MBZ + * + * Map or unmap a region of userspace memory to Guest Physical Addresses (GPA). + * Mappings can't overlap in GPA space or userspace. + * To unmap, these fields must match an existing mapping. + */ +struct mshv_user_mem_region { +	__u64 size; +	__u64 guest_pfn; +	__u64 userspace_addr; +	__u8 flags; +	__u8 rsvd[7]; +}; + +enum { +	MSHV_IRQFD_BIT_DEASSIGN, +	MSHV_IRQFD_BIT_RESAMPLE, +	MSHV_IRQFD_BIT_COUNT, +}; + +#define MSHV_IRQFD_FLAGS_MASK	((1 << MSHV_IRQFD_BIT_COUNT) - 1) + +struct mshv_user_irqfd { +	__s32 fd; +	__s32 resamplefd; +	__u32 gsi; +	__u32 flags; +}; + +enum { +	MSHV_IOEVENTFD_BIT_DATAMATCH, +	MSHV_IOEVENTFD_BIT_PIO, +	MSHV_IOEVENTFD_BIT_DEASSIGN, +	MSHV_IOEVENTFD_BIT_COUNT, +}; + +#define MSHV_IOEVENTFD_FLAGS_MASK	((1 << MSHV_IOEVENTFD_BIT_COUNT) - 1) + +struct mshv_user_ioeventfd { +	__u64 datamatch; +	__u64 addr;	   /* legal pio/mmio address */ +	__u32 len;	   /* 1, 2, 4, or 8 bytes    */ +	__s32 fd; +	__u32 flags; +	__u8  rsvd[4]; +}; + +struct mshv_user_irq_entry { +	__u32 gsi; +	__u32 address_lo; +	__u32 address_hi; +	__u32 data; +}; + +struct mshv_user_irq_table { +	__u32 nr; +	__u32 rsvd; /* MBZ */ +	struct mshv_user_irq_entry entries[]; +}; + +enum { +	MSHV_GPAP_ACCESS_TYPE_ACCESSED, +	MSHV_GPAP_ACCESS_TYPE_DIRTY, +	MSHV_GPAP_ACCESS_TYPE_COUNT		/* Count of enum members */ +}; + +enum { +	MSHV_GPAP_ACCESS_OP_NOOP, +	MSHV_GPAP_ACCESS_OP_CLEAR, +	MSHV_GPAP_ACCESS_OP_SET, +	MSHV_GPAP_ACCESS_OP_COUNT		/* Count of enum members */ +}; + +/** + * struct mshv_gpap_access_bitmap - arguments for MSHV_GET_GPAP_ACCESS_BITMAP + * @access_type: MSHV_GPAP_ACCESS_TYPE_* - The type of access to record in the + *               bitmap + * @access_op: MSHV_GPAP_ACCESS_OP_* - Allows an optional clear or set of all + *             the access states in the range, after retrieving the current + *             states. + * @rsvd: MBZ + * @page_count: Number of pages + * @gpap_base: Base gpa page number + * @bitmap_ptr: Output buffer for bitmap, at least (page_count + 7) / 8 bytes + * + * Retrieve a bitmap of either ACCESSED or DIRTY bits for a given range of guest + * memory, and optionally clear or set the bits. + */ +struct mshv_gpap_access_bitmap { +	__u8 access_type; +	__u8 access_op; +	__u8 rsvd[6]; +	__u64 page_count; +	__u64 gpap_base; +	__u64 bitmap_ptr; +}; + +/** + * struct mshv_root_hvcall - arguments for MSHV_ROOT_HVCALL + * @code: Hypercall code (HVCALL_*) + * @reps: in: Rep count ('repcount') + *	  out: Reps completed ('repcomp'). MBZ unless rep hvcall + * @in_sz: Size of input incl rep data. <= MSHV_HV_PAGE_SIZE + * @out_sz: Size of output buffer. <= MSHV_HV_PAGE_SIZE. MBZ if out_ptr is 0 + * @status: in: MBZ + *	    out: HV_STATUS_* from hypercall + * @rsvd: MBZ + * @in_ptr: Input data buffer (struct hv_input_*). If used with partition or + *	    vp fd, partition id field is populated by kernel. + * @out_ptr: Output data buffer (optional) + */ +struct mshv_root_hvcall { +	__u16 code; +	__u16 reps; +	__u16 in_sz; +	__u16 out_sz; +	__u16 status; +	__u8 rsvd[6]; +	__u64 in_ptr; +	__u64 out_ptr; +}; + +/* Partition fds created with MSHV_CREATE_PARTITION */ +#define MSHV_INITIALIZE_PARTITION	_IO(MSHV_IOCTL, 0x00) +#define MSHV_CREATE_VP			_IOW(MSHV_IOCTL, 0x01, struct mshv_create_vp) +#define MSHV_SET_GUEST_MEMORY		_IOW(MSHV_IOCTL, 0x02, struct mshv_user_mem_region) +#define MSHV_IRQFD			_IOW(MSHV_IOCTL, 0x03, struct mshv_user_irqfd) +#define MSHV_IOEVENTFD			_IOW(MSHV_IOCTL, 0x04, struct mshv_user_ioeventfd) +#define MSHV_SET_MSI_ROUTING		_IOW(MSHV_IOCTL, 0x05, struct mshv_user_irq_table) +#define MSHV_GET_GPAP_ACCESS_BITMAP	_IOWR(MSHV_IOCTL, 0x06, struct mshv_gpap_access_bitmap) +/* Generic hypercall */ +#define MSHV_ROOT_HVCALL		_IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall) + +/* + ******************************** + * VP APIs for child partitions * + ******************************** + */ + +#define MSHV_RUN_VP_BUF_SZ 256 + +/* + * VP state pages may be mapped to userspace via mmap(). + * To specify which state page, use MSHV_VP_MMAP_OFFSET_ values multiplied by + * the system page size. + * e.g. + * long page_size = sysconf(_SC_PAGE_SIZE); + * void *reg_page = mmap(NULL, MSHV_HV_PAGE_SIZE, PROT_READ|PROT_WRITE, + *                       MAP_SHARED, vp_fd, + *                       MSHV_VP_MMAP_OFFSET_REGISTERS * page_size); + */ +enum { +	MSHV_VP_MMAP_OFFSET_REGISTERS, +	MSHV_VP_MMAP_OFFSET_INTERCEPT_MESSAGE, +	MSHV_VP_MMAP_OFFSET_GHCB, +	MSHV_VP_MMAP_OFFSET_COUNT +}; + +/** + * struct mshv_run_vp - argument for MSHV_RUN_VP + * @msg_buf: On success, the intercept message is copied here. It can be + *           interpreted using the relevant hypervisor definitions. + */ +struct mshv_run_vp { +	__u8 msg_buf[MSHV_RUN_VP_BUF_SZ]; +}; + +enum { +	MSHV_VP_STATE_LAPIC,		/* Local interrupt controller state (either arch) */ +	MSHV_VP_STATE_XSAVE,		/* XSAVE data in compacted form (x86_64) */ +	MSHV_VP_STATE_SIMP, +	MSHV_VP_STATE_SIEFP, +	MSHV_VP_STATE_SYNTHETIC_TIMERS, +	MSHV_VP_STATE_COUNT, +}; + +/** + * struct mshv_get_set_vp_state - arguments for MSHV_[GET,SET]_VP_STATE + * @type: MSHV_VP_STATE_* + * @rsvd: MBZ + * @buf_sz: in: 4k page-aligned size of buffer + *          out: Actual size of data (on EINVAL, check this to see if buffer + *               was too small) + * @buf_ptr: 4k page-aligned data buffer + */ +struct mshv_get_set_vp_state { +	__u8 type; +	__u8 rsvd[3]; +	__u32 buf_sz; +	__u64 buf_ptr; +}; + +/* VP fds created with MSHV_CREATE_VP */ +#define MSHV_RUN_VP			_IOR(MSHV_IOCTL, 0x00, struct mshv_run_vp) +#define MSHV_GET_VP_STATE		_IOWR(MSHV_IOCTL, 0x01, struct mshv_get_set_vp_state) +#define MSHV_SET_VP_STATE		_IOWR(MSHV_IOCTL, 0x02, struct mshv_get_set_vp_state) +/* + * Generic hypercall + * Defined above in partition IOCTLs, avoid redefining it here + * #define MSHV_ROOT_HVCALL			_IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall) + */ + +#endif diff --git a/include/uapi/linux/n_r3964.h b/include/uapi/linux/n_r3964.h deleted file mode 100644 index 6bbd18520f30..000000000000 --- a/include/uapi/linux/n_r3964.h +++ /dev/null @@ -1,99 +0,0 @@ -/* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */ -/* r3964 linediscipline for linux - * - * ----------------------------------------------------------- - * Copyright by - * Philips Automation Projects - * Kassel (Germany) - * ----------------------------------------------------------- - * This software may be used and distributed according to the terms of - * the GNU General Public License, incorporated herein by reference. - * - * Author: - * L. Haag - * - * $Log: r3964.h,v $ - * Revision 1.4  2005/12/21 19:54:24  Kurt Huwig <kurt huwig de> - * Fixed HZ usage on 2.6 kernels - * Removed unnecessary include - * - * Revision 1.3  2001/03/18 13:02:24  dwmw2 - * Fix timer usage, use spinlocks properly. - * - * Revision 1.2  2001/03/18 12:53:15  dwmw2 - * Merge changes in 2.4.2 - * - * Revision 1.1.1.1  1998/10/13 16:43:14  dwmw2 - * This'll screw the version control - * - * Revision 1.6  1998/09/30 00:40:38  dwmw2 - * Updated to use kernel's N_R3964 if available - * - * Revision 1.4  1998/04/02 20:29:44  lhaag - * select, blocking, ... - * - * Revision 1.3  1998/02/12 18:58:43  root - * fixed some memory leaks - * calculation of checksum characters - * - * Revision 1.2  1998/02/07 13:03:17  root - * ioctl read_telegram - * - * Revision 1.1  1998/02/06 19:19:43  root - * Initial revision - * - * - */ - -#ifndef _UAPI__LINUX_N_R3964_H__ -#define _UAPI__LINUX_N_R3964_H__ - -/* line disciplines for r3964 protocol */ - - -/* - * Ioctl-commands - */ - -#define R3964_ENABLE_SIGNALS      0x5301 -#define R3964_SETPRIORITY         0x5302 -#define R3964_USE_BCC             0x5303 -#define R3964_READ_TELEGRAM       0x5304 - -/* Options for R3964_SETPRIORITY */ -#define R3964_MASTER   0 -#define R3964_SLAVE    1 - -/* Options for R3964_ENABLE_SIGNALS */ -#define R3964_SIG_ACK   0x0001 -#define R3964_SIG_DATA  0x0002 -#define R3964_SIG_ALL   0x000f -#define R3964_SIG_NONE  0x0000 -#define R3964_USE_SIGIO 0x1000 - -/* - * r3964 operation states: - */ - -/* types for msg_id: */ -enum {R3964_MSG_ACK=1, R3964_MSG_DATA }; - -#define R3964_MAX_MSG_COUNT 32 - -/* error codes for client messages */ -#define R3964_OK 0        /* no error. */ -#define R3964_TX_FAIL -1  /* transmission error, block NOT sent */ -#define R3964_OVERFLOW -2 /* msg queue overflow */ - -/* the client gets this struct when calling read(fd,...): */ -struct r3964_client_message { -	  int     msg_id; -	  int     arg; -	  int     error_code; -}; - -#define R3964_MTU      256 - - - -#endif /* _UAPI__LINUX_N_R3964_H__ */ diff --git a/include/uapi/linux/nbd-netlink.h b/include/uapi/linux/nbd-netlink.h index c5d0ef7aa7d5..2d0b90964227 100644 --- a/include/uapi/linux/nbd-netlink.h +++ b/include/uapi/linux/nbd-netlink.h @@ -35,6 +35,7 @@ enum {  	NBD_ATTR_SOCKETS,  	NBD_ATTR_DEAD_CONN_TIMEOUT,  	NBD_ATTR_DEVICE_LIST, +	NBD_ATTR_BACKEND_IDENTIFIER,  	__NBD_ATTR_MAX,  };  #define NBD_ATTR_MAX (__NBD_ATTR_MAX - 1) diff --git a/include/uapi/linux/nbd.h b/include/uapi/linux/nbd.h index 20d6cc91435d..f1d468acfb25 100644 --- a/include/uapi/linux/nbd.h +++ b/include/uapi/linux/nbd.h @@ -11,6 +11,8 @@   *            Cleanup PARANOIA usage & code.   * 2004/02/19 Paul Clements   *            Removed PARANOIA, plus various cleanup and comments + * 2023 Copyright Red Hat + *            Link to userspace extensions, favor cookie over handle.   */  #ifndef _UAPILINUX_NBD_H @@ -30,12 +32,19 @@  #define NBD_SET_TIMEOUT _IO( 0xab, 9 )  #define NBD_SET_FLAGS   _IO( 0xab, 10) +/* + * See also https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md + * for additional userspace extensions not yet utilized in the kernel module. + */ +  enum {  	NBD_CMD_READ = 0,  	NBD_CMD_WRITE = 1,  	NBD_CMD_DISC = 2,  	NBD_CMD_FLUSH = 3, -	NBD_CMD_TRIM = 4 +	NBD_CMD_TRIM = 4, +	/* userspace defines additional extension commands */ +	NBD_CMD_WRITE_ZEROES = 6,  };  /* values for flags field, these are server interaction specific. */ @@ -43,12 +52,15 @@ enum {  #define NBD_FLAG_READ_ONLY	(1 << 1) /* device is read-only */  #define NBD_FLAG_SEND_FLUSH	(1 << 2) /* can flush writeback cache */  #define NBD_FLAG_SEND_FUA	(1 << 3) /* send FUA (forced unit access) */ -/* there is a gap here to match userspace */ +#define NBD_FLAG_ROTATIONAL	(1 << 4) /* device is rotational */  #define NBD_FLAG_SEND_TRIM	(1 << 5) /* send trim/discard */ +#define NBD_FLAG_SEND_WRITE_ZEROES (1 << 6) /* supports WRITE_ZEROES */ +/* there is a gap here to match userspace */  #define NBD_FLAG_CAN_MULTI_CONN	(1 << 8)	/* Server supports multiple connections per export. */  /* values for cmd flags in the upper 16 bits of request type */  #define NBD_CMD_FLAG_FUA	(1 << 16) /* FUA (forced unit access) op */ +#define NBD_CMD_FLAG_NO_HOLE	(1 << 17) /* Do not punch a hole for WRITE_ZEROES */  /* These are client behavior specific flags. */  #define NBD_CFLAG_DESTROY_ON_DISCONNECT	(1 << 0) /* delete the nbd device on @@ -64,15 +76,19 @@ enum {  #define NBD_REQUEST_MAGIC 0x25609513  #define NBD_REPLY_MAGIC 0x67446698  /* Do *not* use magics: 0x12560953 0x96744668. */ +/* magic 0x668e33ef for structured reply not supported by kernel yet */  /*   * This is the packet used for communication between client and   * server. All data are in network byte order.   */  struct nbd_request { -	__be32 magic; -	__be32 type;	/* == READ || == WRITE 	*/ -	char handle[8]; +	__be32 magic;	/* NBD_REQUEST_MAGIC	*/ +	__be32 type;	/* See NBD_CMD_*	*/ +	union { +		__be64 cookie;	/* Opaque identifier for request	*/ +		char handle[8];	/* older spelling of cookie		*/ +	};  	__be64 from;  	__be32 len;  } __attribute__((packed)); @@ -82,8 +98,11 @@ struct nbd_request {   * it has completed an I/O request (or an error occurs).   */  struct nbd_reply { -	__be32 magic; +	__be32 magic;		/* NBD_REPLY_MAGIC	*/  	__be32 error;		/* 0 = ok, else error	*/ -	char handle[8];		/* handle you got from request	*/ +	union { +		__be64 cookie;	/* Opaque identifier from request	*/ +		char handle[8];	/* older spelling of cookie		*/ +	};  };  #endif /* _UAPILINUX_NBD_H */ diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h index 8cf1e4884fd5..73516e263627 100644 --- a/include/uapi/linux/ndctl.h +++ b/include/uapi/linux/ndctl.h @@ -30,25 +30,25 @@ struct nd_cmd_get_config_data_hdr {  	__u32 in_offset;  	__u32 in_length;  	__u32 status; -	__u8 out_buf[0]; +	__u8 out_buf[];  } __packed;  struct nd_cmd_set_config_hdr {  	__u32 in_offset;  	__u32 in_length; -	__u8 in_buf[0]; +	__u8 in_buf[];  } __packed;  struct nd_cmd_vendor_hdr {  	__u32 opcode;  	__u32 in_length; -	__u8 in_buf[0]; +	__u8 in_buf[];  } __packed;  struct nd_cmd_vendor_tail {  	__u32 status;  	__u32 out_length; -	__u8 out_buf[0]; +	__u8 out_buf[];  } __packed;  struct nd_cmd_ars_cap { @@ -86,7 +86,7 @@ struct nd_cmd_ars_status {  		__u32 reserved;  		__u64 err_address;  		__u64 length; -	} __packed records[0]; +	} __packed records[];  } __packed;  struct nd_cmd_clear_error { @@ -189,7 +189,6 @@ static inline const char *nvdimm_cmd_name(unsigned cmd)  #define ND_DEVICE_REGION_BLK 3      /* nd_region: (parent of BLK namespaces) */  #define ND_DEVICE_NAMESPACE_IO 4    /* legacy persistent memory */  #define ND_DEVICE_NAMESPACE_PMEM 5  /* PMEM namespace (may alias with BLK) */ -#define ND_DEVICE_NAMESPACE_BLK 6   /* BLK namespace (may alias with PMEM) */  #define ND_DEVICE_DAX_PMEM 7        /* Device DAX interface to pmem */  enum nd_driver_flags { @@ -198,7 +197,6 @@ enum nd_driver_flags {  	ND_DRIVER_REGION_BLK      = 1 << ND_DEVICE_REGION_BLK,  	ND_DRIVER_NAMESPACE_IO    = 1 << ND_DEVICE_NAMESPACE_IO,  	ND_DRIVER_NAMESPACE_PMEM  = 1 << ND_DEVICE_NAMESPACE_PMEM, -	ND_DRIVER_NAMESPACE_BLK   = 1 << ND_DEVICE_NAMESPACE_BLK,  	ND_DRIVER_DAX_PMEM	  = 1 << ND_DEVICE_DAX_PMEM,  }; diff --git a/include/uapi/linux/neighbour.h b/include/uapi/linux/neighbour.h index dc8b72201f6c..c34a81245f87 100644 --- a/include/uapi/linux/neighbour.h +++ b/include/uapi/linux/neighbour.h @@ -1,6 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_NEIGHBOUR_H -#define __LINUX_NEIGHBOUR_H +#ifndef _UAPI__LINUX_NEIGHBOUR_H +#define _UAPI__LINUX_NEIGHBOUR_H  #include <linux/types.h>  #include <linux/netlink.h> @@ -31,6 +31,9 @@ enum {  	NDA_PROTOCOL,  /* Originator of entry */  	NDA_NH_ID,  	NDA_FDB_EXT_ATTRS, +	NDA_FLAGS_EXT, +	NDA_NDM_STATE_MASK, +	NDA_NDM_FLAGS_MASK,  	__NDA_MAX  }; @@ -40,14 +43,18 @@ enum {   *	Neighbor Cache Entry Flags   */ -#define NTF_USE		0x01 -#define NTF_SELF	0x02 -#define NTF_MASTER	0x04 -#define NTF_PROXY	0x08	/* == ATF_PUBL */ -#define NTF_EXT_LEARNED	0x10 -#define NTF_OFFLOADED   0x20 -#define NTF_STICKY	0x40 -#define NTF_ROUTER	0x80 +#define NTF_USE		(1 << 0) +#define NTF_SELF	(1 << 1) +#define NTF_MASTER	(1 << 2) +#define NTF_PROXY	(1 << 3)	/* == ATF_PUBL */ +#define NTF_EXT_LEARNED	(1 << 4) +#define NTF_OFFLOADED   (1 << 5) +#define NTF_STICKY	(1 << 6) +#define NTF_ROUTER	(1 << 7) +/* Extended flags under NDA_FLAGS_EXT: */ +#define NTF_EXT_MANAGED		(1 << 0) +#define NTF_EXT_LOCKED		(1 << 1) +#define NTF_EXT_EXT_VALIDATED	(1 << 2)  /*   *	Neighbor Cache Entry States. @@ -65,9 +72,31 @@ enum {  #define NUD_PERMANENT	0x80  #define NUD_NONE	0x00 -/* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change -   and make no address resolution or NUD. -   NUD_PERMANENT also cannot be deleted by garbage collectors. +/* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change and make no + * address resolution or NUD. + * + * NUD_PERMANENT also cannot be deleted by garbage collectors. This holds true + * for dynamic entries with NTF_EXT_LEARNED flag as well. However, upon carrier + * down event, NUD_PERMANENT entries are not flushed whereas NTF_EXT_LEARNED + * flagged entries explicitly are (which is also consistent with the routing + * subsystem). + * + * When NTF_EXT_LEARNED is set for a bridge fdb entry the different cache entry + * states don't make sense and thus are ignored. Such entries don't age and + * can roam. + * + * NTF_EXT_MANAGED flagged neigbor entries are managed by the kernel on behalf + * of a user space control plane, and automatically refreshed so that (if + * possible) they remain in NUD_REACHABLE state. + * + * NTF_EXT_LOCKED flagged bridge FDB entries are entries generated by the + * bridge in response to a host trying to communicate via a locked bridge port + * with MAB enabled. Their purpose is to notify user space that a host requires + * authentication. + * + * NTF_EXT_EXT_VALIDATED flagged neighbor entries were externally validated by + * a user space control plane. The kernel will not remove or invalidate them, + * but it can probe them and notify user space when they become reachable.   */  struct nda_cacheinfo { @@ -136,6 +165,7 @@ enum {  	NDTPA_QUEUE_LENBYTES,		/* u32 */  	NDTPA_MCAST_REPROBES,		/* u32 */  	NDTPA_PAD, +	NDTPA_INTERVAL_PROBE_TIME_MS,	/* u64, msecs */  	__NDTPA_MAX  };  #define NDTPA_MAX (__NDTPA_MAX - 1) diff --git a/include/uapi/linux/net_dropmon.h b/include/uapi/linux/net_dropmon.h index 66048cc5d7b3..87cbef48d4c7 100644 --- a/include/uapi/linux/net_dropmon.h +++ b/include/uapi/linux/net_dropmon.h @@ -1,6 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __NET_DROPMON_H -#define __NET_DROPMON_H +#ifndef _UAPI__NET_DROPMON_H +#define _UAPI__NET_DROPMON_H  #include <linux/types.h>  #include <linux/netlink.h> @@ -10,13 +10,6 @@ struct net_dm_drop_point {  	__u32 count;  }; -#define is_drop_point_hw(x) do {\ -	int ____i, ____j;\ -	for (____i = 0; ____i < 8; i ____i++)\ -		____j |= x[____i];\ -	____j;\ -} while (0) -  #define NET_DM_CFG_VERSION  0  #define NET_DM_CFG_ALERT_COUNT  1  #define NET_DM_CFG_ALERT_DELAY 2 @@ -29,12 +22,12 @@ struct net_dm_config_entry {  struct net_dm_config_msg {  	__u32 entries; -	struct net_dm_config_entry options[0]; +	struct net_dm_config_entry options[];  };  struct net_dm_alert_msg {  	__u32 entries; -	struct net_dm_drop_point points[0]; +	struct net_dm_drop_point points[];  };  struct net_dm_user_msg { @@ -93,6 +86,7 @@ enum net_dm_attr {  	NET_DM_ATTR_SW_DROPS,			/* flag */  	NET_DM_ATTR_HW_DROPS,			/* flag */  	NET_DM_ATTR_FLOW_ACTION_COOKIE,		/* binary */ +	NET_DM_ATTR_REASON,			/* string */  	__NET_DM_ATTR_MAX,  	NET_DM_ATTR_MAX = __NET_DM_ATTR_MAX - 1 diff --git a/include/uapi/linux/net_shaper.h b/include/uapi/linux/net_shaper.h new file mode 100644 index 000000000000..d8834b59f7d7 --- /dev/null +++ b/include/uapi/linux/net_shaper.h @@ -0,0 +1,95 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/net_shaper.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_NET_SHAPER_H +#define _UAPI_LINUX_NET_SHAPER_H + +#define NET_SHAPER_FAMILY_NAME		"net-shaper" +#define NET_SHAPER_FAMILY_VERSION	1 + +/** + * enum net_shaper_scope - Defines the shaper @id interpretation. + * @NET_SHAPER_SCOPE_UNSPEC: The scope is not specified. + * @NET_SHAPER_SCOPE_NETDEV: The main shaper for the given network device. + * @NET_SHAPER_SCOPE_QUEUE: The shaper is attached to the given device queue, + *   the @id represents the queue number. + * @NET_SHAPER_SCOPE_NODE: The shaper allows grouping of queues or other node + *   shapers; can be nested in either @netdev shapers or other @node shapers, + *   allowing placement in any location of the scheduling tree, except leaves + *   and root. + */ +enum net_shaper_scope { +	NET_SHAPER_SCOPE_UNSPEC, +	NET_SHAPER_SCOPE_NETDEV, +	NET_SHAPER_SCOPE_QUEUE, +	NET_SHAPER_SCOPE_NODE, + +	/* private: */ +	__NET_SHAPER_SCOPE_MAX, +	NET_SHAPER_SCOPE_MAX = (__NET_SHAPER_SCOPE_MAX - 1) +}; + +/** + * enum net_shaper_metric - Different metric supported by the shaper. + * @NET_SHAPER_METRIC_BPS: Shaper operates on a bits per second basis. + * @NET_SHAPER_METRIC_PPS: Shaper operates on a packets per second basis. + */ +enum net_shaper_metric { +	NET_SHAPER_METRIC_BPS, +	NET_SHAPER_METRIC_PPS, +}; + +enum { +	NET_SHAPER_A_HANDLE = 1, +	NET_SHAPER_A_METRIC, +	NET_SHAPER_A_BW_MIN, +	NET_SHAPER_A_BW_MAX, +	NET_SHAPER_A_BURST, +	NET_SHAPER_A_PRIORITY, +	NET_SHAPER_A_WEIGHT, +	NET_SHAPER_A_IFINDEX, +	NET_SHAPER_A_PARENT, +	NET_SHAPER_A_LEAVES, + +	__NET_SHAPER_A_MAX, +	NET_SHAPER_A_MAX = (__NET_SHAPER_A_MAX - 1) +}; + +enum { +	NET_SHAPER_A_HANDLE_SCOPE = 1, +	NET_SHAPER_A_HANDLE_ID, + +	__NET_SHAPER_A_HANDLE_MAX, +	NET_SHAPER_A_HANDLE_MAX = (__NET_SHAPER_A_HANDLE_MAX - 1) +}; + +enum { +	NET_SHAPER_A_CAPS_IFINDEX = 1, +	NET_SHAPER_A_CAPS_SCOPE, +	NET_SHAPER_A_CAPS_SUPPORT_METRIC_BPS, +	NET_SHAPER_A_CAPS_SUPPORT_METRIC_PPS, +	NET_SHAPER_A_CAPS_SUPPORT_NESTING, +	NET_SHAPER_A_CAPS_SUPPORT_BW_MIN, +	NET_SHAPER_A_CAPS_SUPPORT_BW_MAX, +	NET_SHAPER_A_CAPS_SUPPORT_BURST, +	NET_SHAPER_A_CAPS_SUPPORT_PRIORITY, +	NET_SHAPER_A_CAPS_SUPPORT_WEIGHT, + +	__NET_SHAPER_A_CAPS_MAX, +	NET_SHAPER_A_CAPS_MAX = (__NET_SHAPER_A_CAPS_MAX - 1) +}; + +enum { +	NET_SHAPER_CMD_GET = 1, +	NET_SHAPER_CMD_SET, +	NET_SHAPER_CMD_DELETE, +	NET_SHAPER_CMD_GROUP, +	NET_SHAPER_CMD_CAP_GET, + +	__NET_SHAPER_CMD_MAX, +	NET_SHAPER_CMD_MAX = (__NET_SHAPER_CMD_MAX - 1) +}; + +#endif /* _UAPI_LINUX_NET_SHAPER_H */ diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h index 7ed0b3d1c00a..a93e6ea37fb3 100644 --- a/include/uapi/linux/net_tstamp.h +++ b/include/uapi/linux/net_tstamp.h @@ -7,13 +7,24 @@   *   */ -#ifndef _NET_TIMESTAMPING_H -#define _NET_TIMESTAMPING_H +#ifndef _UAPI_NET_TIMESTAMPING_H +#define _UAPI_NET_TIMESTAMPING_H  #include <linux/types.h>  #include <linux/socket.h>   /* for SO_TIMESTAMPING */ -/* SO_TIMESTAMPING gets an integer bit field comprised of these values */ +/* + * Possible type of hwtstamp provider. Mainly "precise" the default one + * is for IEEE 1588 quality and "approx" is for NICs DMA point. + */ +enum hwtstamp_provider_qualifier { +	HWTSTAMP_PROVIDER_QUALIFIER_PRECISE, +	HWTSTAMP_PROVIDER_QUALIFIER_APPROX, + +	HWTSTAMP_PROVIDER_QUALIFIER_CNT, +}; + +/* SO_TIMESTAMPING flags */  enum {  	SOF_TIMESTAMPING_TX_HARDWARE = (1<<0),  	SOF_TIMESTAMPING_TX_SOFTWARE = (1<<1), @@ -30,8 +41,12 @@ enum {  	SOF_TIMESTAMPING_OPT_STATS = (1<<12),  	SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13),  	SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14), +	SOF_TIMESTAMPING_BIND_PHC = (1 << 15), +	SOF_TIMESTAMPING_OPT_ID_TCP = (1 << 16), +	SOF_TIMESTAMPING_OPT_RX_FILTER = (1 << 17), +	SOF_TIMESTAMPING_TX_COMPLETION = (1 << 18), -	SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_TX_SWHW, +	SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_TX_COMPLETION,  	SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |  				 SOF_TIMESTAMPING_LAST  }; @@ -44,12 +59,25 @@ enum {  #define SOF_TIMESTAMPING_TX_RECORD_MASK	(SOF_TIMESTAMPING_TX_HARDWARE | \  					 SOF_TIMESTAMPING_TX_SOFTWARE | \  					 SOF_TIMESTAMPING_TX_SCHED | \ -					 SOF_TIMESTAMPING_TX_ACK) +					 SOF_TIMESTAMPING_TX_ACK | \ +					 SOF_TIMESTAMPING_TX_COMPLETION) + +/** + * struct so_timestamping - SO_TIMESTAMPING parameter + * + * @flags:	SO_TIMESTAMPING flags + * @bind_phc:	Index of PTP virtual clock bound to sock. This is available + *		if flag SOF_TIMESTAMPING_BIND_PHC is set. + */ +struct so_timestamping { +	int flags; +	int bind_phc; +};  /**   * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter   * - * @flags:	no flags defined right now, must be zero for %SIOCSHWTSTAMP + * @flags:	one of HWTSTAMP_FLAG_*   * @tx_type:	one of HWTSTAMP_TX_*   * @rx_filter:	one of HWTSTAMP_FILTER_*   * @@ -65,6 +93,21 @@ struct hwtstamp_config {  	int rx_filter;  }; +/* possible values for hwtstamp_config->flags */ +enum hwtstamp_flags { +	/* +	 * With this flag, the user could get bond active interface's +	 * PHC index. Note this PHC index is not stable as when there +	 * is a failover, the bond active interface will be changed, so +	 * will be the PHC index. +	 */ +	HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0), +#define HWTSTAMP_FLAG_BONDED_PHC_INDEX	HWTSTAMP_FLAG_BONDED_PHC_INDEX + +	HWTSTAMP_FLAG_LAST = HWTSTAMP_FLAG_BONDED_PHC_INDEX, +	HWTSTAMP_FLAG_MASK = (HWTSTAMP_FLAG_LAST - 1) | HWTSTAMP_FLAG_LAST +}; +  /* possible values for hwtstamp_config->tx_type */  enum hwtstamp_tx_types {  	/* @@ -173,4 +216,4 @@ struct sock_txtime {  	__u32			flags;	/* as defined by enum txtime_flags */  }; -#endif /* _NET_TIMESTAMPING_H */ +#endif /* _UAPI_NET_TIMESTAMPING_H */ diff --git a/include/uapi/linux/netconf.h b/include/uapi/linux/netconf.h index fac4edd55379..1c8c84d65ae3 100644 --- a/include/uapi/linux/netconf.h +++ b/include/uapi/linux/netconf.h @@ -19,6 +19,7 @@ enum {  	NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,  	NETCONFA_INPUT,  	NETCONFA_BC_FORWARDING, +	NETCONFA_FORCE_FORWARDING,  	__NETCONFA_MAX  };  #define NETCONFA_MAX	(__NETCONFA_MAX - 1) diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h new file mode 100644 index 000000000000..48eb49aa03d4 --- /dev/null +++ b/include/uapi/linux/netdev.h @@ -0,0 +1,237 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/netdev.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_NETDEV_H +#define _UAPI_LINUX_NETDEV_H + +#define NETDEV_FAMILY_NAME	"netdev" +#define NETDEV_FAMILY_VERSION	1 + +/** + * enum netdev_xdp_act + * @NETDEV_XDP_ACT_BASIC: XDP features set supported by all drivers + *   (XDP_ABORTED, XDP_DROP, XDP_PASS, XDP_TX) + * @NETDEV_XDP_ACT_REDIRECT: The netdev supports XDP_REDIRECT + * @NETDEV_XDP_ACT_NDO_XMIT: This feature informs if netdev implements + *   ndo_xdp_xmit callback. + * @NETDEV_XDP_ACT_XSK_ZEROCOPY: This feature informs if netdev supports AF_XDP + *   in zero copy mode. + * @NETDEV_XDP_ACT_HW_OFFLOAD: This feature informs if netdev supports XDP hw + *   offloading. + * @NETDEV_XDP_ACT_RX_SG: This feature informs if netdev implements non-linear + *   XDP buffer support in the driver napi callback. + * @NETDEV_XDP_ACT_NDO_XMIT_SG: This feature informs if netdev implements + *   non-linear XDP buffer support in ndo_xdp_xmit callback. + */ +enum netdev_xdp_act { +	NETDEV_XDP_ACT_BASIC = 1, +	NETDEV_XDP_ACT_REDIRECT = 2, +	NETDEV_XDP_ACT_NDO_XMIT = 4, +	NETDEV_XDP_ACT_XSK_ZEROCOPY = 8, +	NETDEV_XDP_ACT_HW_OFFLOAD = 16, +	NETDEV_XDP_ACT_RX_SG = 32, +	NETDEV_XDP_ACT_NDO_XMIT_SG = 64, + +	/* private: */ +	NETDEV_XDP_ACT_MASK = 127, +}; + +/** + * enum netdev_xdp_rx_metadata + * @NETDEV_XDP_RX_METADATA_TIMESTAMP: Device is capable of exposing receive HW + *   timestamp via bpf_xdp_metadata_rx_timestamp(). + * @NETDEV_XDP_RX_METADATA_HASH: Device is capable of exposing receive packet + *   hash via bpf_xdp_metadata_rx_hash(). + * @NETDEV_XDP_RX_METADATA_VLAN_TAG: Device is capable of exposing receive + *   packet VLAN tag via bpf_xdp_metadata_rx_vlan_tag(). + */ +enum netdev_xdp_rx_metadata { +	NETDEV_XDP_RX_METADATA_TIMESTAMP = 1, +	NETDEV_XDP_RX_METADATA_HASH = 2, +	NETDEV_XDP_RX_METADATA_VLAN_TAG = 4, +}; + +/** + * enum netdev_xsk_flags + * @NETDEV_XSK_FLAGS_TX_TIMESTAMP: HW timestamping egress packets is supported + *   by the driver. + * @NETDEV_XSK_FLAGS_TX_CHECKSUM: L3 checksum HW offload is supported by the + *   driver. + * @NETDEV_XSK_FLAGS_TX_LAUNCH_TIME_FIFO: Launch time HW offload is supported + *   by the driver. + */ +enum netdev_xsk_flags { +	NETDEV_XSK_FLAGS_TX_TIMESTAMP = 1, +	NETDEV_XSK_FLAGS_TX_CHECKSUM = 2, +	NETDEV_XSK_FLAGS_TX_LAUNCH_TIME_FIFO = 4, +}; + +enum netdev_queue_type { +	NETDEV_QUEUE_TYPE_RX, +	NETDEV_QUEUE_TYPE_TX, +}; + +enum netdev_qstats_scope { +	NETDEV_QSTATS_SCOPE_QUEUE = 1, +}; + +enum netdev_napi_threaded { +	NETDEV_NAPI_THREADED_DISABLED, +	NETDEV_NAPI_THREADED_ENABLED, +}; + +enum { +	NETDEV_A_DEV_IFINDEX = 1, +	NETDEV_A_DEV_PAD, +	NETDEV_A_DEV_XDP_FEATURES, +	NETDEV_A_DEV_XDP_ZC_MAX_SEGS, +	NETDEV_A_DEV_XDP_RX_METADATA_FEATURES, +	NETDEV_A_DEV_XSK_FEATURES, + +	__NETDEV_A_DEV_MAX, +	NETDEV_A_DEV_MAX = (__NETDEV_A_DEV_MAX - 1) +}; + +enum { +	__NETDEV_A_IO_URING_PROVIDER_INFO_MAX, +	NETDEV_A_IO_URING_PROVIDER_INFO_MAX = (__NETDEV_A_IO_URING_PROVIDER_INFO_MAX - 1) +}; + +enum { +	NETDEV_A_PAGE_POOL_ID = 1, +	NETDEV_A_PAGE_POOL_IFINDEX, +	NETDEV_A_PAGE_POOL_NAPI_ID, +	NETDEV_A_PAGE_POOL_INFLIGHT, +	NETDEV_A_PAGE_POOL_INFLIGHT_MEM, +	NETDEV_A_PAGE_POOL_DETACH_TIME, +	NETDEV_A_PAGE_POOL_DMABUF, +	NETDEV_A_PAGE_POOL_IO_URING, + +	__NETDEV_A_PAGE_POOL_MAX, +	NETDEV_A_PAGE_POOL_MAX = (__NETDEV_A_PAGE_POOL_MAX - 1) +}; + +enum { +	NETDEV_A_PAGE_POOL_STATS_INFO = 1, +	NETDEV_A_PAGE_POOL_STATS_ALLOC_FAST = 8, +	NETDEV_A_PAGE_POOL_STATS_ALLOC_SLOW, +	NETDEV_A_PAGE_POOL_STATS_ALLOC_SLOW_HIGH_ORDER, +	NETDEV_A_PAGE_POOL_STATS_ALLOC_EMPTY, +	NETDEV_A_PAGE_POOL_STATS_ALLOC_REFILL, +	NETDEV_A_PAGE_POOL_STATS_ALLOC_WAIVE, +	NETDEV_A_PAGE_POOL_STATS_RECYCLE_CACHED, +	NETDEV_A_PAGE_POOL_STATS_RECYCLE_CACHE_FULL, +	NETDEV_A_PAGE_POOL_STATS_RECYCLE_RING, +	NETDEV_A_PAGE_POOL_STATS_RECYCLE_RING_FULL, +	NETDEV_A_PAGE_POOL_STATS_RECYCLE_RELEASED_REFCNT, + +	__NETDEV_A_PAGE_POOL_STATS_MAX, +	NETDEV_A_PAGE_POOL_STATS_MAX = (__NETDEV_A_PAGE_POOL_STATS_MAX - 1) +}; + +enum { +	NETDEV_A_NAPI_IFINDEX = 1, +	NETDEV_A_NAPI_ID, +	NETDEV_A_NAPI_IRQ, +	NETDEV_A_NAPI_PID, +	NETDEV_A_NAPI_DEFER_HARD_IRQS, +	NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, +	NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT, +	NETDEV_A_NAPI_THREADED, + +	__NETDEV_A_NAPI_MAX, +	NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1) +}; + +enum { +	__NETDEV_A_XSK_INFO_MAX, +	NETDEV_A_XSK_INFO_MAX = (__NETDEV_A_XSK_INFO_MAX - 1) +}; + +enum { +	NETDEV_A_QUEUE_ID = 1, +	NETDEV_A_QUEUE_IFINDEX, +	NETDEV_A_QUEUE_TYPE, +	NETDEV_A_QUEUE_NAPI_ID, +	NETDEV_A_QUEUE_DMABUF, +	NETDEV_A_QUEUE_IO_URING, +	NETDEV_A_QUEUE_XSK, + +	__NETDEV_A_QUEUE_MAX, +	NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1) +}; + +enum { +	NETDEV_A_QSTATS_IFINDEX = 1, +	NETDEV_A_QSTATS_QUEUE_TYPE, +	NETDEV_A_QSTATS_QUEUE_ID, +	NETDEV_A_QSTATS_SCOPE, +	NETDEV_A_QSTATS_RX_PACKETS = 8, +	NETDEV_A_QSTATS_RX_BYTES, +	NETDEV_A_QSTATS_TX_PACKETS, +	NETDEV_A_QSTATS_TX_BYTES, +	NETDEV_A_QSTATS_RX_ALLOC_FAIL, +	NETDEV_A_QSTATS_RX_HW_DROPS, +	NETDEV_A_QSTATS_RX_HW_DROP_OVERRUNS, +	NETDEV_A_QSTATS_RX_CSUM_COMPLETE, +	NETDEV_A_QSTATS_RX_CSUM_UNNECESSARY, +	NETDEV_A_QSTATS_RX_CSUM_NONE, +	NETDEV_A_QSTATS_RX_CSUM_BAD, +	NETDEV_A_QSTATS_RX_HW_GRO_PACKETS, +	NETDEV_A_QSTATS_RX_HW_GRO_BYTES, +	NETDEV_A_QSTATS_RX_HW_GRO_WIRE_PACKETS, +	NETDEV_A_QSTATS_RX_HW_GRO_WIRE_BYTES, +	NETDEV_A_QSTATS_RX_HW_DROP_RATELIMITS, +	NETDEV_A_QSTATS_TX_HW_DROPS, +	NETDEV_A_QSTATS_TX_HW_DROP_ERRORS, +	NETDEV_A_QSTATS_TX_CSUM_NONE, +	NETDEV_A_QSTATS_TX_NEEDS_CSUM, +	NETDEV_A_QSTATS_TX_HW_GSO_PACKETS, +	NETDEV_A_QSTATS_TX_HW_GSO_BYTES, +	NETDEV_A_QSTATS_TX_HW_GSO_WIRE_PACKETS, +	NETDEV_A_QSTATS_TX_HW_GSO_WIRE_BYTES, +	NETDEV_A_QSTATS_TX_HW_DROP_RATELIMITS, +	NETDEV_A_QSTATS_TX_STOP, +	NETDEV_A_QSTATS_TX_WAKE, + +	__NETDEV_A_QSTATS_MAX, +	NETDEV_A_QSTATS_MAX = (__NETDEV_A_QSTATS_MAX - 1) +}; + +enum { +	NETDEV_A_DMABUF_IFINDEX = 1, +	NETDEV_A_DMABUF_QUEUES, +	NETDEV_A_DMABUF_FD, +	NETDEV_A_DMABUF_ID, + +	__NETDEV_A_DMABUF_MAX, +	NETDEV_A_DMABUF_MAX = (__NETDEV_A_DMABUF_MAX - 1) +}; + +enum { +	NETDEV_CMD_DEV_GET = 1, +	NETDEV_CMD_DEV_ADD_NTF, +	NETDEV_CMD_DEV_DEL_NTF, +	NETDEV_CMD_DEV_CHANGE_NTF, +	NETDEV_CMD_PAGE_POOL_GET, +	NETDEV_CMD_PAGE_POOL_ADD_NTF, +	NETDEV_CMD_PAGE_POOL_DEL_NTF, +	NETDEV_CMD_PAGE_POOL_CHANGE_NTF, +	NETDEV_CMD_PAGE_POOL_STATS_GET, +	NETDEV_CMD_QUEUE_GET, +	NETDEV_CMD_NAPI_GET, +	NETDEV_CMD_QSTATS_GET, +	NETDEV_CMD_BIND_RX, +	NETDEV_CMD_NAPI_SET, +	NETDEV_CMD_BIND_TX, + +	__NETDEV_CMD_MAX, +	NETDEV_CMD_MAX = (__NETDEV_CMD_MAX - 1) +}; + +#define NETDEV_MCGRP_MGMT	"mgmt" +#define NETDEV_MCGRP_PAGE_POOL	"page-pool" + +#endif /* _UAPI_LINUX_NETDEV_H */ diff --git a/include/uapi/linux/netfilter.h b/include/uapi/linux/netfilter.h index ca9e63d6e0e4..5a79ccb76701 100644 --- a/include/uapi/linux/netfilter.h +++ b/include/uapi/linux/netfilter.h @@ -45,11 +45,13 @@ enum nf_inet_hooks {  	NF_INET_FORWARD,  	NF_INET_LOCAL_OUT,  	NF_INET_POST_ROUTING, -	NF_INET_NUMHOOKS +	NF_INET_NUMHOOKS, +	NF_INET_INGRESS = NF_INET_NUMHOOKS,  };  enum nf_dev_hooks {  	NF_NETDEV_INGRESS, +	NF_NETDEV_EGRESS,  	NF_NETDEV_NUMHOOKS  }; @@ -61,7 +63,9 @@ enum {  	NFPROTO_NETDEV =  5,  	NFPROTO_BRIDGE =  7,  	NFPROTO_IPV6   = 10, +#ifndef __KERNEL__ /* no longer supported by kernel */  	NFPROTO_DECNET = 12, +#endif  	NFPROTO_NUMPROTO,  }; diff --git a/include/uapi/linux/netfilter/ipset/ip_set.h b/include/uapi/linux/netfilter/ipset/ip_set.h index 11a72a938eb1..333807efd32b 100644 --- a/include/uapi/linux/netfilter/ipset/ip_set.h +++ b/include/uapi/linux/netfilter/ipset/ip_set.h @@ -3,10 +3,6 @@   *                         Patrick Schaaf <bof@bof.de>   *                         Martin Josefsson <gandalf@wlug.westbo.se>   * Copyright (C) 2003-2011 Jozsef Kadlecsik <kadlec@netfilter.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation.   */  #ifndef _UAPI_IP_SET_H  #define _UAPI_IP_SET_H @@ -89,14 +85,15 @@ enum {  	IPSET_ATTR_CADT_LINENO = IPSET_ATTR_LINENO,	/* 9 */  	IPSET_ATTR_MARK,	/* 10 */  	IPSET_ATTR_MARKMASK,	/* 11 */ +	IPSET_ATTR_BITMASK,	/* 12 */  	/* Reserve empty slots */  	IPSET_ATTR_CADT_MAX = 16,  	/* Create-only specific attributes */ -	IPSET_ATTR_GC, +	IPSET_ATTR_INITVAL,	/* was unused IPSET_ATTR_GC */  	IPSET_ATTR_HASHSIZE,  	IPSET_ATTR_MAXELEM,  	IPSET_ATTR_NETMASK, -	IPSET_ATTR_PROBES, +	IPSET_ATTR_BUCKETSIZE,	/* was unused IPSET_ATTR_PROBES */  	IPSET_ATTR_RESIZE,  	IPSET_ATTR_SIZE,  	/* Kernel-only */ @@ -157,6 +154,7 @@ enum ipset_errno {  	IPSET_ERR_COMMENT,  	IPSET_ERR_INVALID_MARKMASK,  	IPSET_ERR_SKBINFO, +	IPSET_ERR_BITMASK_NETMASK_EXCL,  	/* Type specific error codes */  	IPSET_ERR_TYPE_SPECIFIC = 4352, @@ -214,6 +212,8 @@ enum ipset_cadt_flags {  enum ipset_create_flags {  	IPSET_CREATE_FLAG_BIT_FORCEADD = 0,  	IPSET_CREATE_FLAG_FORCEADD = (1 << IPSET_CREATE_FLAG_BIT_FORCEADD), +	IPSET_CREATE_FLAG_BIT_BUCKETSIZE = 1, +	IPSET_CREATE_FLAG_BUCKETSIZE = (1 << IPSET_CREATE_FLAG_BIT_BUCKETSIZE),  	IPSET_CREATE_FLAG_BIT_MAX = 7,  }; diff --git a/include/uapi/linux/netfilter/nf_conntrack_common.h b/include/uapi/linux/netfilter/nf_conntrack_common.h index 4b3395082d15..26071021e986 100644 --- a/include/uapi/linux/netfilter/nf_conntrack_common.h +++ b/include/uapi/linux/netfilter/nf_conntrack_common.h @@ -106,7 +106,7 @@ enum ip_conntrack_status {  	IPS_NAT_CLASH = IPS_UNTRACKED,  #endif -	/* Conntrack got a helper explicitly attached via CT target. */ +	/* Conntrack got a helper explicitly attached (ruleset, ctnetlink). */  	IPS_HELPER_BIT = 13,  	IPS_HELPER = (1 << IPS_HELPER_BIT), diff --git a/include/uapi/linux/netfilter/nf_conntrack_sctp.h b/include/uapi/linux/netfilter/nf_conntrack_sctp.h index edc6ddab0de6..2d6f80d75ae7 100644 --- a/include/uapi/linux/netfilter/nf_conntrack_sctp.h +++ b/include/uapi/linux/netfilter/nf_conntrack_sctp.h @@ -15,7 +15,7 @@ enum sctp_conntrack {  	SCTP_CONNTRACK_SHUTDOWN_RECD,  	SCTP_CONNTRACK_SHUTDOWN_ACK_SENT,  	SCTP_CONNTRACK_HEARTBEAT_SENT, -	SCTP_CONNTRACK_HEARTBEAT_ACKED, +	SCTP_CONNTRACK_HEARTBEAT_ACKED,	/* no longer used */  	SCTP_CONNTRACK_MAX  }; diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h index 2b8e12f7a4a6..8e0eb832bc01 100644 --- a/include/uapi/linux/netfilter/nf_tables.h +++ b/include/uapi/linux/netfilter/nf_tables.h @@ -97,6 +97,15 @@ enum nft_verdicts {   * @NFT_MSG_NEWFLOWTABLE: add new flow table (enum nft_flowtable_attributes)   * @NFT_MSG_GETFLOWTABLE: get flow table (enum nft_flowtable_attributes)   * @NFT_MSG_DELFLOWTABLE: delete flow table (enum nft_flowtable_attributes) + * @NFT_MSG_GETRULE_RESET: get rules and reset stateful expressions (enum nft_obj_attributes) + * @NFT_MSG_DESTROYTABLE: destroy a table (enum nft_table_attributes) + * @NFT_MSG_DESTROYCHAIN: destroy a chain (enum nft_chain_attributes) + * @NFT_MSG_DESTROYRULE: destroy a rule (enum nft_rule_attributes) + * @NFT_MSG_DESTROYSET: destroy a set (enum nft_set_attributes) + * @NFT_MSG_DESTROYSETELEM: destroy a set element (enum nft_set_elem_attributes) + * @NFT_MSG_DESTROYOBJ: destroy a stateful object (enum nft_object_attributes) + * @NFT_MSG_DESTROYFLOWTABLE: destroy flow table (enum nft_flowtable_attributes) + * @NFT_MSG_GETSETELEM_RESET: get set elements and reset attached stateful expressions (enum nft_set_elem_attributes)   */  enum nf_tables_msg_types {  	NFT_MSG_NEWTABLE, @@ -124,6 +133,15 @@ enum nf_tables_msg_types {  	NFT_MSG_NEWFLOWTABLE,  	NFT_MSG_GETFLOWTABLE,  	NFT_MSG_DELFLOWTABLE, +	NFT_MSG_GETRULE_RESET, +	NFT_MSG_DESTROYTABLE, +	NFT_MSG_DESTROYCHAIN, +	NFT_MSG_DESTROYRULE, +	NFT_MSG_DESTROYSET, +	NFT_MSG_DESTROYSETELEM, +	NFT_MSG_DESTROYOBJ, +	NFT_MSG_DESTROYFLOWTABLE, +	NFT_MSG_GETSETELEM_RESET,  	NFT_MSG_MAX,  }; @@ -161,10 +179,17 @@ enum nft_hook_attributes {   * enum nft_table_flags - nf_tables table flags   *   * @NFT_TABLE_F_DORMANT: this table is not active + * @NFT_TABLE_F_OWNER:   this table is owned by a process + * @NFT_TABLE_F_PERSIST: this table shall outlive its owner   */  enum nft_table_flags {  	NFT_TABLE_F_DORMANT	= 0x1, +	NFT_TABLE_F_OWNER	= 0x2, +	NFT_TABLE_F_PERSIST	= 0x4,  }; +#define NFT_TABLE_F_MASK	(NFT_TABLE_F_DORMANT | \ +				 NFT_TABLE_F_OWNER | \ +				 NFT_TABLE_F_PERSIST)  /**   * enum nft_table_attributes - nf_tables table netlink attributes @@ -172,6 +197,8 @@ enum nft_table_flags {   * @NFTA_TABLE_NAME: name of the table (NLA_STRING)   * @NFTA_TABLE_FLAGS: bitmask of enum nft_table_flags (NLA_U32)   * @NFTA_TABLE_USE: number of chains in this table (NLA_U32) + * @NFTA_TABLE_USERDATA: user data (NLA_BINARY) + * @NFTA_TABLE_OWNER: owner of this table through netlink portID (NLA_U32)   */  enum nft_table_attributes {  	NFTA_TABLE_UNSPEC, @@ -180,6 +207,8 @@ enum nft_table_attributes {  	NFTA_TABLE_USE,  	NFTA_TABLE_HANDLE,  	NFTA_TABLE_PAD, +	NFTA_TABLE_USERDATA, +	NFTA_TABLE_OWNER,  	__NFTA_TABLE_MAX  };  #define NFTA_TABLE_MAX		(__NFTA_TABLE_MAX - 1) @@ -206,6 +235,7 @@ enum nft_chain_flags {   * @NFTA_CHAIN_COUNTERS: counter specification of the chain (NLA_NESTED: nft_counter_attributes)   * @NFTA_CHAIN_FLAGS: chain flags   * @NFTA_CHAIN_ID: uniquely identifies a chain in a transaction (NLA_U32) + * @NFTA_CHAIN_USERDATA: user data (NLA_BINARY)   */  enum nft_chain_attributes {  	NFTA_CHAIN_UNSPEC, @@ -220,6 +250,7 @@ enum nft_chain_attributes {  	NFTA_CHAIN_PAD,  	NFTA_CHAIN_FLAGS,  	NFTA_CHAIN_ID, +	NFTA_CHAIN_USERDATA,  	__NFTA_CHAIN_MAX  };  #define NFTA_CHAIN_MAX		(__NFTA_CHAIN_MAX - 1) @@ -236,6 +267,7 @@ enum nft_chain_attributes {   * @NFTA_RULE_USERDATA: user data (NLA_BINARY, NFT_USERDATA_MAXLEN)   * @NFTA_RULE_ID: uniquely identifies a rule in a transaction (NLA_U32)   * @NFTA_RULE_POSITION_ID: transaction unique identifier of the previous rule (NLA_U32) + * @NFTA_RULE_CHAIN_ID: add the rule to chain by ID, alternative to @NFTA_RULE_CHAIN (NLA_U32)   */  enum nft_rule_attributes {  	NFTA_RULE_UNSPEC, @@ -257,9 +289,11 @@ enum nft_rule_attributes {  /**   * enum nft_rule_compat_flags - nf_tables rule compat flags   * + * @NFT_RULE_COMPAT_F_UNUSED: unused   * @NFT_RULE_COMPAT_F_INV: invert the check result   */  enum nft_rule_compat_flags { +	NFT_RULE_COMPAT_F_UNUSED = (1 << 0),  	NFT_RULE_COMPAT_F_INV	= (1 << 1),  	NFT_RULE_COMPAT_F_MASK	= NFT_RULE_COMPAT_F_INV,  }; @@ -289,6 +323,7 @@ enum nft_rule_compat_attributes {   * @NFT_SET_EVAL: set can be updated from the evaluation path   * @NFT_SET_OBJECT: set contains stateful objects   * @NFT_SET_CONCAT: set contains a concatenation + * @NFT_SET_EXPR: set contains expressions   */  enum nft_set_flags {  	NFT_SET_ANONYMOUS		= 0x1, @@ -299,6 +334,7 @@ enum nft_set_flags {  	NFT_SET_EVAL			= 0x20,  	NFT_SET_OBJECT			= 0x40,  	NFT_SET_CONCAT			= 0x80, +	NFT_SET_EXPR			= 0x100,  };  /** @@ -357,6 +393,9 @@ enum nft_set_field_attributes {   * @NFTA_SET_OBJ_TYPE: stateful object type (NLA_U32: NFT_OBJECT_*)   * @NFTA_SET_HANDLE: set handle (NLA_U64)   * @NFTA_SET_EXPR: set expression (NLA_NESTED: nft_expr_attributes) + * @NFTA_SET_EXPRESSIONS: list of expressions (NLA_NESTED: nft_list_attributes) + * @NFTA_SET_TYPE: set backend type (NLA_STRING) + * @NFTA_SET_COUNT: number of set elements (NLA_U32)   */  enum nft_set_attributes {  	NFTA_SET_UNSPEC, @@ -377,6 +416,9 @@ enum nft_set_attributes {  	NFTA_SET_OBJ_TYPE,  	NFTA_SET_HANDLE,  	NFTA_SET_EXPR, +	NFTA_SET_EXPRESSIONS, +	NFTA_SET_TYPE, +	NFTA_SET_COUNT,  	__NFTA_SET_MAX  };  #define NFTA_SET_MAX		(__NFTA_SET_MAX - 1) @@ -385,9 +427,11 @@ enum nft_set_attributes {   * enum nft_set_elem_flags - nf_tables set element flags   *   * @NFT_SET_ELEM_INTERVAL_END: element ends the previous interval + * @NFT_SET_ELEM_CATCHALL: special catch-all element   */  enum nft_set_elem_flags {  	NFT_SET_ELEM_INTERVAL_END	= 0x1, +	NFT_SET_ELEM_CATCHALL		= 0x2,  };  /** @@ -396,12 +440,13 @@ enum nft_set_elem_flags {   * @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data)   * @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes)   * @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32) - * @NFTA_SET_ELEM_TIMEOUT: timeout value (NLA_U64) + * @NFTA_SET_ELEM_TIMEOUT: timeout value, zero means never times out (NLA_U64)   * @NFTA_SET_ELEM_EXPIRATION: expiration time (NLA_U64)   * @NFTA_SET_ELEM_USERDATA: user data (NLA_BINARY)   * @NFTA_SET_ELEM_EXPR: expression (NLA_NESTED: nft_expr_attributes)   * @NFTA_SET_ELEM_OBJREF: stateful object reference (NLA_STRING)   * @NFTA_SET_ELEM_KEY_END: closing key value (NLA_NESTED: nft_data) + * @NFTA_SET_ELEM_EXPRESSIONS: list of expressions (NLA_NESTED: nft_list_attributes)   */  enum nft_set_elem_attributes {  	NFTA_SET_ELEM_UNSPEC, @@ -415,6 +460,7 @@ enum nft_set_elem_attributes {  	NFTA_SET_ELEM_PAD,  	NFTA_SET_ELEM_OBJREF,  	NFTA_SET_ELEM_KEY_END, +	NFTA_SET_ELEM_EXPRESSIONS,  	__NFTA_SET_ELEM_MAX  };  #define NFTA_SET_ELEM_MAX	(__NFTA_SET_ELEM_MAX - 1) @@ -522,16 +568,26 @@ enum nft_immediate_attributes {  /**   * enum nft_bitwise_ops - nf_tables bitwise operations   * - * @NFT_BITWISE_BOOL: mask-and-xor operation used to implement NOT, AND, OR and - *                    XOR boolean operations + * @NFT_BITWISE_MASK_XOR: mask-and-xor operation used to implement NOT, AND, OR + *                        and XOR boolean operations   * @NFT_BITWISE_LSHIFT: left-shift operation   * @NFT_BITWISE_RSHIFT: right-shift operation + * @NFT_BITWISE_AND: and operation + * @NFT_BITWISE_OR: or operation + * @NFT_BITWISE_XOR: xor operation   */  enum nft_bitwise_ops { -	NFT_BITWISE_BOOL, +	NFT_BITWISE_MASK_XOR,  	NFT_BITWISE_LSHIFT,  	NFT_BITWISE_RSHIFT, +	NFT_BITWISE_AND, +	NFT_BITWISE_OR, +	NFT_BITWISE_XOR,  }; +/* + * Old name for NFT_BITWISE_MASK_XOR.  Retained for backwards-compatibility. + */ +#define NFT_BITWISE_BOOL NFT_BITWISE_MASK_XOR  /**   * enum nft_bitwise_attributes - nf_tables bitwise expression netlink attributes @@ -544,6 +600,7 @@ enum nft_bitwise_ops {   * @NFTA_BITWISE_OP: type of operation (NLA_U32: nft_bitwise_ops)   * @NFTA_BITWISE_DATA: argument for non-boolean operations   *                     (NLA_NESTED: nft_data_attributes) + * @NFTA_BITWISE_SREG2: second source register (NLA_U32: nft_registers)   *   * The bitwise expression supports boolean and shift operations.  It implements   * the boolean operations by performing the following operation: @@ -567,6 +624,7 @@ enum nft_bitwise_attributes {  	NFTA_BITWISE_XOR,  	NFTA_BITWISE_OP,  	NFTA_BITWISE_DATA, +	NFTA_BITWISE_SREG2,  	__NFTA_BITWISE_MAX  };  #define NFTA_BITWISE_MAX	(__NFTA_BITWISE_MAX - 1) @@ -652,7 +710,7 @@ enum nft_range_ops {   * enum nft_range_attributes - nf_tables range expression netlink attributes   *   * @NFTA_RANGE_SREG: source register of data to compare (NLA_U32: nft_registers) - * @NFTA_RANGE_OP: cmp operation (NLA_U32: nft_cmp_ops) + * @NFTA_RANGE_OP: cmp operation (NLA_U32: nft_range_ops)   * @NFTA_RANGE_FROM_DATA: data range from (NLA_NESTED: nft_data_attributes)   * @NFTA_RANGE_TO_DATA: data range to (NLA_NESTED: nft_data_attributes)   */ @@ -698,6 +756,7 @@ enum nft_dynset_ops {  enum nft_dynset_flags {  	NFT_DYNSET_F_INV	= (1 << 0), +	NFT_DYNSET_F_EXPR	= (1 << 1),  };  /** @@ -711,6 +770,7 @@ enum nft_dynset_flags {   * @NFTA_DYNSET_TIMEOUT: timeout value for the new element (NLA_U64)   * @NFTA_DYNSET_EXPR: expression (NLA_NESTED: nft_expr_attributes)   * @NFTA_DYNSET_FLAGS: flags (NLA_U32) + * @NFTA_DYNSET_EXPRESSIONS: list of expressions (NLA_NESTED: nft_list_attributes)   */  enum nft_dynset_attributes {  	NFTA_DYNSET_UNSPEC, @@ -723,6 +783,7 @@ enum nft_dynset_attributes {  	NFTA_DYNSET_EXPR,  	NFTA_DYNSET_PAD,  	NFTA_DYNSET_FLAGS, +	NFTA_DYNSET_EXPRESSIONS,  	__NFTA_DYNSET_MAX,  };  #define NFTA_DYNSET_MAX		(__NFTA_DYNSET_MAX - 1) @@ -733,11 +794,14 @@ enum nft_dynset_attributes {   * @NFT_PAYLOAD_LL_HEADER: link layer header   * @NFT_PAYLOAD_NETWORK_HEADER: network header   * @NFT_PAYLOAD_TRANSPORT_HEADER: transport header + * @NFT_PAYLOAD_INNER_HEADER: inner header / payload   */  enum nft_payload_bases {  	NFT_PAYLOAD_LL_HEADER,  	NFT_PAYLOAD_NETWORK_HEADER,  	NFT_PAYLOAD_TRANSPORT_HEADER, +	NFT_PAYLOAD_INNER_HEADER, +	NFT_PAYLOAD_TUN_HEADER,  };  /** @@ -745,16 +809,44 @@ enum nft_payload_bases {   *   * @NFT_PAYLOAD_CSUM_NONE: no checksumming   * @NFT_PAYLOAD_CSUM_INET: internet checksum (RFC 791) + * @NFT_PAYLOAD_CSUM_SCTP: CRC-32c, for use in SCTP header (RFC 3309)   */  enum nft_payload_csum_types {  	NFT_PAYLOAD_CSUM_NONE,  	NFT_PAYLOAD_CSUM_INET, +	NFT_PAYLOAD_CSUM_SCTP,  };  enum nft_payload_csum_flags {  	NFT_PAYLOAD_L4CSUM_PSEUDOHDR = (1 << 0),  }; +enum nft_inner_type { +	NFT_INNER_UNSPEC	= 0, +	NFT_INNER_VXLAN, +	NFT_INNER_GENEVE, +}; + +enum nft_inner_flags { +	NFT_INNER_HDRSIZE	= (1 << 0), +	NFT_INNER_LL		= (1 << 1), +	NFT_INNER_NH		= (1 << 2), +	NFT_INNER_TH		= (1 << 3), +}; +#define NFT_INNER_MASK		(NFT_INNER_HDRSIZE | NFT_INNER_LL | \ +				 NFT_INNER_NH | NFT_INNER_TH) + +enum nft_inner_attributes { +	NFTA_INNER_UNSPEC, +	NFTA_INNER_NUM, +	NFTA_INNER_TYPE, +	NFTA_INNER_FLAGS, +	NFTA_INNER_HDRSIZE, +	NFTA_INNER_EXPR, +	__NFTA_INNER_MAX +}; +#define NFTA_INNER_MAX	(__NFTA_INNER_MAX - 1) +  /**   * enum nft_payload_attributes - nf_tables payload expression netlink attributes   * @@ -791,11 +883,15 @@ enum nft_exthdr_flags {   * @NFT_EXTHDR_OP_IPV6: match against ipv6 extension headers   * @NFT_EXTHDR_OP_TCP: match against tcp options   * @NFT_EXTHDR_OP_IPV4: match against ipv4 options + * @NFT_EXTHDR_OP_SCTP: match against sctp chunks + * @NFT_EXTHDR_OP_DCCP: match against dccp otions   */  enum nft_exthdr_op {  	NFT_EXTHDR_OP_IPV6,  	NFT_EXTHDR_OP_TCPOPT,  	NFT_EXTHDR_OP_IPV4, +	NFT_EXTHDR_OP_SCTP, +	NFT_EXTHDR_OP_DCCP,  	__NFT_EXTHDR_OP_MAX  };  #define NFT_EXTHDR_OP_MAX	(__NFT_EXTHDR_OP_MAX - 1) @@ -809,7 +905,7 @@ enum nft_exthdr_op {   * @NFTA_EXTHDR_LEN: extension header length (NLA_U32)   * @NFTA_EXTHDR_FLAGS: extension header flags (NLA_U32)   * @NFTA_EXTHDR_OP: option match type (NLA_U32) - * @NFTA_EXTHDR_SREG: option match type (NLA_U32) + * @NFTA_EXTHDR_SREG: source register (NLA_U32: nft_registers)   */  enum nft_exthdr_attributes {  	NFTA_EXTHDR_UNSPEC, @@ -862,6 +958,7 @@ enum nft_exthdr_attributes {   * @NFT_META_TIME_HOUR: hour of day (in seconds)   * @NFT_META_SDIF: slave device interface index   * @NFT_META_SDIFNAME: slave device interface name + * @NFT_META_BRI_BROUTE: packet br_netfilter_broute bit   */  enum nft_meta_keys {  	NFT_META_LEN, @@ -872,7 +969,8 @@ enum nft_meta_keys {  	NFT_META_OIF,  	NFT_META_IIFNAME,  	NFT_META_OIFNAME, -	NFT_META_IIFTYPE, +	NFT_META_IFTYPE, +#define NFT_META_IIFTYPE	NFT_META_IFTYPE  	NFT_META_OIFTYPE,  	NFT_META_SKUID,  	NFT_META_SKGID, @@ -899,6 +997,8 @@ enum nft_meta_keys {  	NFT_META_TIME_HOUR,  	NFT_META_SDIF,  	NFT_META_SDIFNAME, +	NFT_META_BRI_BROUTE, +	__NFT_META_IIFTYPE,  };  /** @@ -994,11 +1094,13 @@ enum nft_rt_attributes {   *   * @NFTA_SOCKET_KEY: socket key to match   * @NFTA_SOCKET_DREG: destination register + * @NFTA_SOCKET_LEVEL: cgroups2 ancestor level (only for cgroupsv2)   */  enum nft_socket_attributes {  	NFTA_SOCKET_UNSPEC,  	NFTA_SOCKET_KEY,  	NFTA_SOCKET_DREG, +	NFTA_SOCKET_LEVEL,  	__NFTA_SOCKET_MAX  };  #define NFTA_SOCKET_MAX		(__NFTA_SOCKET_MAX - 1) @@ -1008,10 +1110,14 @@ enum nft_socket_attributes {   *   * @NFT_SOCKET_TRANSPARENT: Value of the IP(V6)_TRANSPARENT socket option   * @NFT_SOCKET_MARK: Value of the socket mark + * @NFT_SOCKET_WILDCARD: Whether the socket is zero-bound (e.g. 0.0.0.0 or ::0) + * @NFT_SOCKET_CGROUPV2: Match on cgroups version 2   */  enum nft_socket_keys {  	NFT_SOCKET_TRANSPARENT,  	NFT_SOCKET_MARK, +	NFT_SOCKET_WILDCARD, +	NFT_SOCKET_CGROUPV2,  	__NFT_SOCKET_MAX  };  #define NFT_SOCKET_MAX	(__NFT_SOCKET_MAX - 1) @@ -1166,12 +1272,27 @@ enum nft_counter_attributes {  #define NFTA_COUNTER_MAX	(__NFTA_COUNTER_MAX - 1)  /** + * enum nft_last_attributes - nf_tables last expression netlink attributes + * + * @NFTA_LAST_SET: last update has been set, zero means never updated (NLA_U32) + * @NFTA_LAST_MSECS: milliseconds since last update (NLA_U64) + */ +enum nft_last_attributes { +	NFTA_LAST_UNSPEC, +	NFTA_LAST_SET, +	NFTA_LAST_MSECS, +	NFTA_LAST_PAD, +	__NFTA_LAST_MAX +}; +#define NFTA_LAST_MAX	(__NFTA_LAST_MAX - 1) + +/**   * enum nft_log_attributes - nf_tables log expression netlink attributes   * - * @NFTA_LOG_GROUP: netlink group to send messages to (NLA_U32) + * @NFTA_LOG_GROUP: netlink group to send messages to (NLA_U16)   * @NFTA_LOG_PREFIX: prefix to prepend to log messages (NLA_STRING)   * @NFTA_LOG_SNAPLEN: length of payload to include in netlink message (NLA_U32) - * @NFTA_LOG_QTHRESHOLD: queue threshold (NLA_U32) + * @NFTA_LOG_QTHRESHOLD: queue threshold (NLA_U16)   * @NFTA_LOG_LEVEL: log level (NLA_U32)   * @NFTA_LOG_FLAGS: logging flags (NLA_U32)   */ @@ -1271,7 +1392,7 @@ enum nft_secmark_attributes {  #define NFTA_SECMARK_MAX	(__NFTA_SECMARK_MAX - 1)  /* Max security context length */ -#define NFT_SECMARK_CTX_MAXLEN		256 +#define NFT_SECMARK_CTX_MAXLEN		4096  /**   * enum nft_reject_types - nf_tables reject expression reject types @@ -1555,6 +1676,7 @@ enum nft_ct_expectation_attributes {   * @NFTA_OBJ_DATA: stateful object data (NLA_NESTED)   * @NFTA_OBJ_USE: number of references to this expression (NLA_U32)   * @NFTA_OBJ_HANDLE: object handle (NLA_U64) + * @NFTA_OBJ_USERDATA: user data (NLA_BINARY)   */  enum nft_object_attributes {  	NFTA_OBJ_UNSPEC, @@ -1565,6 +1687,7 @@ enum nft_object_attributes {  	NFTA_OBJ_USE,  	NFTA_OBJ_HANDLE,  	NFTA_OBJ_PAD, +	NFTA_OBJ_USERDATA,  	__NFTA_OBJ_MAX  };  #define NFTA_OBJ_MAX		(__NFTA_OBJ_MAX - 1) @@ -1587,7 +1710,7 @@ enum nft_flowtable_flags {   *   * @NFTA_FLOWTABLE_TABLE: name of the table containing the expression (NLA_STRING)   * @NFTA_FLOWTABLE_NAME: name of this flow table (NLA_STRING) - * @NFTA_FLOWTABLE_HOOK: netfilter hook configuration(NLA_U32) + * @NFTA_FLOWTABLE_HOOK: netfilter hook configuration (NLA_NESTED)   * @NFTA_FLOWTABLE_USE: number of references to this flow table (NLA_U32)   * @NFTA_FLOWTABLE_HANDLE: object handle (NLA_U64)   * @NFTA_FLOWTABLE_FLAGS: flags (NLA_U32) @@ -1661,10 +1784,12 @@ enum nft_synproxy_attributes {   * enum nft_device_attributes - nf_tables device netlink attributes   *   * @NFTA_DEVICE_NAME: name of this device (NLA_STRING) + * @NFTA_DEVICE_PREFIX: device name prefix, a simple wildcard (NLA_STRING)   */  enum nft_devices_attributes {  	NFTA_DEVICE_UNSPEC,  	NFTA_DEVICE_NAME, +	NFTA_DEVICE_PREFIX,  	__NFTA_DEVICE_MAX  };  #define NFTA_DEVICE_MAX		(__NFTA_DEVICE_MAX - 1) @@ -1718,6 +1843,10 @@ enum nft_xfrm_keys {   * @NFTA_TRACE_MARK: nfmark (NLA_U32)   * @NFTA_TRACE_NFPROTO: nf protocol processed (NLA_U32)   * @NFTA_TRACE_POLICY: policy that decided fate of packet (NLA_U32) + * @NFTA_TRACE_CT_ID: conntrack id (NLA_U32) + * @NFTA_TRACE_CT_DIRECTION: packets direction (NLA_U8) + * @NFTA_TRACE_CT_STATUS: conntrack status (NLA_U32) + * @NFTA_TRACE_CT_STATE: packet state (new, established, ...) (NLA_U32)   */  enum nft_trace_attributes {  	NFTA_TRACE_UNSPEC, @@ -1738,6 +1867,10 @@ enum nft_trace_attributes {  	NFTA_TRACE_NFPROTO,  	NFTA_TRACE_POLICY,  	NFTA_TRACE_PAD, +	NFTA_TRACE_CT_ID, +	NFTA_TRACE_CT_DIRECTION, +	NFTA_TRACE_CT_STATUS, +	NFTA_TRACE_CT_STATE,  	__NFTA_TRACE_MAX  };  #define NFTA_TRACE_MAX (__NFTA_TRACE_MAX - 1) diff --git a/include/uapi/linux/netfilter/nfnetlink.h b/include/uapi/linux/netfilter/nfnetlink.h index 5bc960f220b3..6cd58cd2a6f0 100644 --- a/include/uapi/linux/netfilter/nfnetlink.h +++ b/include/uapi/linux/netfilter/nfnetlink.h @@ -60,7 +60,8 @@ struct nfgenmsg {  #define NFNL_SUBSYS_CTHELPER		9  #define NFNL_SUBSYS_NFTABLES		10  #define NFNL_SUBSYS_NFT_COMPAT		11 -#define NFNL_SUBSYS_COUNT		12 +#define NFNL_SUBSYS_HOOK		12 +#define NFNL_SUBSYS_COUNT		13  /* Reserved control nfnetlink messages */  #define NFNL_MSG_BATCH_BEGIN		NLMSG_MIN_TYPE diff --git a/include/uapi/linux/netfilter/nfnetlink_conntrack.h b/include/uapi/linux/netfilter/nfnetlink_conntrack.h index 262881792671..43233af75b9d 100644 --- a/include/uapi/linux/netfilter/nfnetlink_conntrack.h +++ b/include/uapi/linux/netfilter/nfnetlink_conntrack.h @@ -56,6 +56,8 @@ enum ctattr_type {  	CTA_LABELS_MASK,  	CTA_SYNPROXY,  	CTA_FILTER, +	CTA_STATUS_MASK, +	CTA_TIMESTAMP_EVENT,  	__CTA_MAX  };  #define CTA_MAX (__CTA_MAX - 1) @@ -247,7 +249,7 @@ enum ctattr_stats_cpu {  	CTA_STATS_FOUND,  	CTA_STATS_NEW,		/* no longer used */  	CTA_STATS_INVALID, -	CTA_STATS_IGNORE, +	CTA_STATS_IGNORE,	/* no longer used */  	CTA_STATS_DELETE,	/* no longer used */  	CTA_STATS_DELETE_LIST,	/* no longer used */  	CTA_STATS_INSERT, @@ -256,6 +258,8 @@ enum ctattr_stats_cpu {  	CTA_STATS_EARLY_DROP,  	CTA_STATS_ERROR,  	CTA_STATS_SEARCH_RESTART, +	CTA_STATS_CLASH_RESOLVE, +	CTA_STATS_CHAIN_TOOLONG,  	__CTA_STATS_MAX,  };  #define CTA_STATS_MAX (__CTA_STATS_MAX - 1) diff --git a/include/uapi/linux/netfilter/nfnetlink_cthelper.h b/include/uapi/linux/netfilter/nfnetlink_cthelper.h index a13137afc429..70af02092d16 100644 --- a/include/uapi/linux/netfilter/nfnetlink_cthelper.h +++ b/include/uapi/linux/netfilter/nfnetlink_cthelper.h @@ -5,7 +5,7 @@  #define NFCT_HELPER_STATUS_DISABLED	0  #define NFCT_HELPER_STATUS_ENABLED	1 -enum nfnl_acct_msg_types { +enum nfnl_cthelper_msg_types {  	NFNL_MSG_CTHELPER_NEW,  	NFNL_MSG_CTHELPER_GET,  	NFNL_MSG_CTHELPER_DEL, diff --git a/include/uapi/linux/netfilter/nfnetlink_cttimeout.h b/include/uapi/linux/netfilter/nfnetlink_cttimeout.h index 6b20fb22717b..aa805e6d4e28 100644 --- a/include/uapi/linux/netfilter/nfnetlink_cttimeout.h +++ b/include/uapi/linux/netfilter/nfnetlink_cttimeout.h @@ -94,7 +94,7 @@ enum ctattr_timeout_sctp {  	CTA_TIMEOUT_SCTP_SHUTDOWN_RECD,  	CTA_TIMEOUT_SCTP_SHUTDOWN_ACK_SENT,  	CTA_TIMEOUT_SCTP_HEARTBEAT_SENT, -	CTA_TIMEOUT_SCTP_HEARTBEAT_ACKED, +	CTA_TIMEOUT_SCTP_HEARTBEAT_ACKED, /* no longer used */  	__CTA_TIMEOUT_SCTP_MAX  };  #define CTA_TIMEOUT_SCTP_MAX (__CTA_TIMEOUT_SCTP_MAX - 1) diff --git a/include/uapi/linux/netfilter/nfnetlink_hook.h b/include/uapi/linux/netfilter/nfnetlink_hook.h new file mode 100644 index 000000000000..1a2c4d6424b5 --- /dev/null +++ b/include/uapi/linux/netfilter/nfnetlink_hook.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _NFNL_HOOK_H_ +#define _NFNL_HOOK_H_ + +enum nfnl_hook_msg_types { +	NFNL_MSG_HOOK_GET, +	NFNL_MSG_HOOK_MAX, +}; + +/** + * enum nfnl_hook_attributes - netfilter hook netlink attributes + * + * @NFNLA_HOOK_HOOKNUM: netfilter hook number (NLA_U32) + * @NFNLA_HOOK_PRIORITY: netfilter hook priority (NLA_U32) + * @NFNLA_HOOK_DEV: netdevice name (NLA_STRING) + * @NFNLA_HOOK_FUNCTION_NAME: hook function name (NLA_STRING) + * @NFNLA_HOOK_MODULE_NAME: kernel module that registered this hook (NLA_STRING) + * @NFNLA_HOOK_CHAIN_INFO: basechain hook metadata (NLA_NESTED) + */ +enum nfnl_hook_attributes { +	NFNLA_HOOK_UNSPEC, +	NFNLA_HOOK_HOOKNUM, +	NFNLA_HOOK_PRIORITY, +	NFNLA_HOOK_DEV, +	NFNLA_HOOK_FUNCTION_NAME, +	NFNLA_HOOK_MODULE_NAME, +	NFNLA_HOOK_CHAIN_INFO, +	__NFNLA_HOOK_MAX +}; +#define NFNLA_HOOK_MAX		(__NFNLA_HOOK_MAX - 1) + +/** + * enum nfnl_hook_chain_info_attributes - chain description + * + * @NFNLA_HOOK_INFO_DESC: nft chain and table name (NLA_NESTED) + * @NFNLA_HOOK_INFO_TYPE: chain type (enum nfnl_hook_chaintype) (NLA_U32) + * + * NFNLA_HOOK_INFO_DESC depends on NFNLA_HOOK_INFO_TYPE value: + *   NFNL_HOOK_TYPE_NFTABLES: enum nft_table_attributes + *   NFNL_HOOK_TYPE_BPF: enum nfnl_hook_bpf_attributes + */ +enum nfnl_hook_chain_info_attributes { +	NFNLA_HOOK_INFO_UNSPEC, +	NFNLA_HOOK_INFO_DESC, +	NFNLA_HOOK_INFO_TYPE, +	__NFNLA_HOOK_INFO_MAX, +}; +#define NFNLA_HOOK_INFO_MAX (__NFNLA_HOOK_INFO_MAX - 1) + +enum nfnl_hook_chain_desc_attributes { +	NFNLA_CHAIN_UNSPEC, +	NFNLA_CHAIN_TABLE, +	NFNLA_CHAIN_FAMILY, +	NFNLA_CHAIN_NAME, +	__NFNLA_CHAIN_MAX, +}; +#define NFNLA_CHAIN_MAX (__NFNLA_CHAIN_MAX - 1) + +/** + * enum nfnl_hook_chaintype - chain type + * + * @NFNL_HOOK_TYPE_NFTABLES: nf_tables base chain + * @NFNL_HOOK_TYPE_BPF: bpf program + * @NFNL_HOOK_TYPE_NFT_FLOWTABLE: nf_tables flowtable + */ +enum nfnl_hook_chaintype { +	NFNL_HOOK_TYPE_NFTABLES = 0x1, +	NFNL_HOOK_TYPE_BPF, +	NFNL_HOOK_TYPE_NFT_FLOWTABLE, +}; + +/** + * enum nfnl_hook_bpf_attributes - bpf prog description + * + * @NFNLA_HOOK_BPF_ID: bpf program id (NLA_U32) + */ +enum nfnl_hook_bpf_attributes { +	NFNLA_HOOK_BPF_UNSPEC, +	NFNLA_HOOK_BPF_ID, +	__NFNLA_HOOK_BPF_MAX, +}; +#define NFNLA_HOOK_BPF_MAX (__NFNLA_HOOK_BPF_MAX - 1) + +#endif /* _NFNL_HOOK_H */ diff --git a/include/uapi/linux/netfilter/nfnetlink_log.h b/include/uapi/linux/netfilter/nfnetlink_log.h index 45c8d3b027e0..0af9c113d665 100644 --- a/include/uapi/linux/netfilter/nfnetlink_log.h +++ b/include/uapi/linux/netfilter/nfnetlink_log.h @@ -61,7 +61,7 @@ enum nfulnl_attr_type {  	NFULA_HWTYPE,			/* hardware type */  	NFULA_HWHEADER,			/* hardware header */  	NFULA_HWLEN,			/* hardware header length */ -	NFULA_CT,                       /* nf_conntrack_netlink.h */ +	NFULA_CT,                       /* nfnetlink_conntrack.h */  	NFULA_CT_INFO,                  /* enum ip_conntrack_info */  	NFULA_VLAN,			/* nested attribute: packet vlan info */  	NFULA_L2HDR,			/* full L2 header */ diff --git a/include/uapi/linux/netfilter/nfnetlink_queue.h b/include/uapi/linux/netfilter/nfnetlink_queue.h index bcb2cb5d40b9..efcb7c044a74 100644 --- a/include/uapi/linux/netfilter/nfnetlink_queue.h +++ b/include/uapi/linux/netfilter/nfnetlink_queue.h @@ -51,16 +51,18 @@ enum nfqnl_attr_type {  	NFQA_IFINDEX_PHYSOUTDEV,	/* __u32 ifindex */  	NFQA_HWADDR,			/* nfqnl_msg_packet_hw */  	NFQA_PAYLOAD,			/* opaque data payload */ -	NFQA_CT,			/* nf_conntrack_netlink.h */ +	NFQA_CT,			/* nfnetlink_conntrack.h */  	NFQA_CT_INFO,			/* enum ip_conntrack_info */  	NFQA_CAP_LEN,			/* __u32 length of captured packet */  	NFQA_SKB_INFO,			/* __u32 skb meta information */ -	NFQA_EXP,			/* nf_conntrack_netlink.h */ +	NFQA_EXP,			/* nfnetlink_conntrack.h */  	NFQA_UID,			/* __u32 sk uid */  	NFQA_GID,			/* __u32 sk gid */  	NFQA_SECCTX,			/* security context string */  	NFQA_VLAN,			/* nested attribute: packet vlan info */  	NFQA_L2HDR,			/* full L2 header */ +	NFQA_PRIORITY,			/* skb->priority */ +	NFQA_CGROUP_CLASSID,		/* __u32 cgroup classid */  	__NFQA_MAX  }; diff --git a/include/uapi/linux/netfilter/x_tables.h b/include/uapi/linux/netfilter/x_tables.h index a8283f7dbc51..796af83a963a 100644 --- a/include/uapi/linux/netfilter/x_tables.h +++ b/include/uapi/linux/netfilter/x_tables.h @@ -1,7 +1,7 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */  #ifndef _UAPI_X_TABLES_H  #define _UAPI_X_TABLES_H -#include <linux/kernel.h> +#include <linux/const.h>  #include <linux/types.h>  #define XT_FUNCTION_MAXNAMELEN 30 @@ -28,7 +28,7 @@ struct xt_entry_match {  		__u16 match_size;  	} u; -	unsigned char data[0]; +	unsigned char data[];  };  struct xt_entry_target { @@ -119,7 +119,7 @@ struct xt_counters_info {  	unsigned int num_counters;  	/* The counters (actually `number' of these). */ -	struct xt_counters counters[0]; +	struct xt_counters counters[];  };  #define XT_INV_PROTO		0x40	/* Invert the sense of PROTO. */ diff --git a/include/uapi/linux/netfilter/xt_AUDIT.h b/include/uapi/linux/netfilter/xt_AUDIT.h index 1b314e2f84ac..56a3f6092e0c 100644 --- a/include/uapi/linux/netfilter/xt_AUDIT.h +++ b/include/uapi/linux/netfilter/xt_AUDIT.h @@ -4,10 +4,6 @@   *   * (C) 2010-2011 Thomas Graf <tgraf@redhat.com>   * (C) 2010-2011 Red Hat, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation.   */  #ifndef _XT_AUDIT_TARGET_H diff --git a/include/uapi/linux/netfilter/xt_IDLETIMER.h b/include/uapi/linux/netfilter/xt_IDLETIMER.h index 49ddcdc61c09..7bfb31a66fc9 100644 --- a/include/uapi/linux/netfilter/xt_IDLETIMER.h +++ b/include/uapi/linux/netfilter/xt_IDLETIMER.h @@ -1,6 +1,5 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */  /* - * linux/include/linux/netfilter/xt_IDLETIMER.h - *   * Header file for Xtables timer target module.   *   * Copyright (C) 2004, 2010 Nokia Corporation @@ -10,20 +9,6 @@   * by Luciano Coelho <luciano.coelho@nokia.com>   *   * Contact: Luciano Coelho <luciano.coelho@nokia.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA   */  #ifndef _XT_IDLETIMER_H diff --git a/include/uapi/linux/netfilter/xt_SECMARK.h b/include/uapi/linux/netfilter/xt_SECMARK.h index 1f2a708413f5..beb2cadba8a9 100644 --- a/include/uapi/linux/netfilter/xt_SECMARK.h +++ b/include/uapi/linux/netfilter/xt_SECMARK.h @@ -20,4 +20,10 @@ struct xt_secmark_target_info {  	char secctx[SECMARK_SECCTX_MAX];  }; +struct xt_secmark_target_info_v1 { +	__u8 mode; +	char secctx[SECMARK_SECCTX_MAX]; +	__u32 secid; +}; +  #endif /*_XT_SECMARK_H_target */ diff --git a/include/uapi/linux/netfilter/xt_connmark.h b/include/uapi/linux/netfilter/xt_connmark.h index f01c19b83a2b..41b578ccd03b 100644 --- a/include/uapi/linux/netfilter/xt_connmark.h +++ b/include/uapi/linux/netfilter/xt_connmark.h @@ -1,18 +1,13 @@  /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* Copyright (C) 2002,2004 MARA Systems AB <https://www.marasystems.com> + * by Henrik Nordstrom <hno@marasystems.com> + */ +  #ifndef _XT_CONNMARK_H  #define _XT_CONNMARK_H  #include <linux/types.h> -/* Copyright (C) 2002,2004 MARA Systems AB <https://www.marasystems.com> - * by Henrik Nordstrom <hno@marasystems.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ -  enum {  	XT_CONNMARK_SET = 0,  	XT_CONNMARK_SAVE, diff --git a/include/uapi/linux/netfilter/xt_osf.h b/include/uapi/linux/netfilter/xt_osf.h index 6e466236ca4b..f1f097896bdf 100644 --- a/include/uapi/linux/netfilter/xt_osf.h +++ b/include/uapi/linux/netfilter/xt_osf.h @@ -1,20 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */  /*   * Copyright (c) 2003+ Evgeniy Polyakov <johnpol@2ka.mxt.ru> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>.   */  #ifndef _XT_OSF_H diff --git a/include/uapi/linux/netfilter_arp/arp_tables.h b/include/uapi/linux/netfilter_arp/arp_tables.h index bbf5af2b67a8..a6ac2463f787 100644 --- a/include/uapi/linux/netfilter_arp/arp_tables.h +++ b/include/uapi/linux/netfilter_arp/arp_tables.h @@ -109,7 +109,7 @@ struct arpt_entry  	struct xt_counters counters;  	/* The matches (if any), then the target. */ -	unsigned char elems[0]; +	unsigned char elems[];  };  /* @@ -181,7 +181,7 @@ struct arpt_replace {  	struct xt_counters __user *counters;  	/* The entries (hang off end: not really an array). */ -	struct arpt_entry entries[0]; +	struct arpt_entry entries[];  };  /* The argument to ARPT_SO_GET_ENTRIES. */ @@ -193,7 +193,7 @@ struct arpt_get_entries {  	unsigned int size;  	/* The entries. */ -	struct arpt_entry entrytable[0]; +	struct arpt_entry entrytable[];  };  /* Helper functions */ diff --git a/include/uapi/linux/netfilter_bridge/ebt_among.h b/include/uapi/linux/netfilter_bridge/ebt_among.h index 9acf757bc1f7..73b26a280c4f 100644 --- a/include/uapi/linux/netfilter_bridge/ebt_among.h +++ b/include/uapi/linux/netfilter_bridge/ebt_among.h @@ -40,7 +40,7 @@ struct ebt_mac_wormhash_tuple {  struct ebt_mac_wormhash {  	int table[257];  	int poolsize; -	struct ebt_mac_wormhash_tuple pool[0]; +	struct ebt_mac_wormhash_tuple pool[];  };  #define ebt_mac_wormhash_size(x) ((x) ? sizeof(struct ebt_mac_wormhash) \ diff --git a/include/uapi/linux/netfilter_bridge/ebtables.h b/include/uapi/linux/netfilter_bridge/ebtables.h index a494cf43a755..4ff328f3d339 100644 --- a/include/uapi/linux/netfilter_bridge/ebtables.h +++ b/include/uapi/linux/netfilter_bridge/ebtables.h @@ -87,7 +87,7 @@ struct ebt_entries {  	/* nr. of entries */  	unsigned int nentries;  	/* entry list */ -	char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); +	char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));  };  /* used for the bitmask of struct ebt_entry */ @@ -129,7 +129,7 @@ struct ebt_entry_match {  	} u;  	/* size of data */  	unsigned int match_size; -	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); +	unsigned char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));  };  struct ebt_entry_watcher { @@ -142,7 +142,7 @@ struct ebt_entry_watcher {  	} u;  	/* size of data */  	unsigned int watcher_size; -	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); +	unsigned char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));  };  struct ebt_entry_target { @@ -182,13 +182,15 @@ struct ebt_entry {  	unsigned char sourcemsk[ETH_ALEN];  	unsigned char destmac[ETH_ALEN];  	unsigned char destmsk[ETH_ALEN]; -	/* sizeof ebt_entry + matches */ -	unsigned int watchers_offset; -	/* sizeof ebt_entry + matches + watchers */ -	unsigned int target_offset; -	/* sizeof ebt_entry + matches + watchers + target */ -	unsigned int next_offset; -	unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); +	__struct_group(/* no tag */, offsets, /* no attrs */, +		/* sizeof ebt_entry + matches */ +		unsigned int watchers_offset; +		/* sizeof ebt_entry + matches + watchers */ +		unsigned int target_offset; +		/* sizeof ebt_entry + matches + watchers + target */ +		unsigned int next_offset; +	); +	unsigned char elems[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));  };  static __inline__ struct ebt_entry_target * diff --git a/include/uapi/linux/netfilter_decnet.h b/include/uapi/linux/netfilter_decnet.h deleted file mode 100644 index 3c77f54560f2..000000000000 --- a/include/uapi/linux/netfilter_decnet.h +++ /dev/null @@ -1,72 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_DECNET_NETFILTER_H -#define __LINUX_DECNET_NETFILTER_H - -/* DECnet-specific defines for netfilter.  - * This file (C) Steve Whitehouse 1999 derived from the - * ipv4 netfilter header file which is - * (C)1998 Rusty Russell -- This code is GPL. - */ - -#include <linux/netfilter.h> - -/* only for userspace compatibility */ -#ifndef __KERNEL__ - -#include <limits.h> /* for INT_MIN, INT_MAX */ - -/* kernel define is in netfilter_defs.h */ -#define NF_DN_NUMHOOKS		7 -#endif /* ! __KERNEL__ */ - -/* DECnet Hooks */ -/* After promisc drops, checksum checks. */ -#define NF_DN_PRE_ROUTING	0 -/* If the packet is destined for this box. */ -#define NF_DN_LOCAL_IN		1 -/* If the packet is destined for another interface. */ -#define NF_DN_FORWARD		2 -/* Packets coming from a local process. */ -#define NF_DN_LOCAL_OUT		3 -/* Packets about to hit the wire. */ -#define NF_DN_POST_ROUTING	4 -/* Input Hello Packets */ -#define NF_DN_HELLO		5 -/* Input Routing Packets */ -#define NF_DN_ROUTE		6 - -enum nf_dn_hook_priorities { -	NF_DN_PRI_FIRST = INT_MIN, -	NF_DN_PRI_CONNTRACK = -200, -	NF_DN_PRI_MANGLE = -150, -	NF_DN_PRI_NAT_DST = -100, -	NF_DN_PRI_FILTER = 0, -	NF_DN_PRI_NAT_SRC = 100, -	NF_DN_PRI_DNRTMSG = 200, -	NF_DN_PRI_LAST = INT_MAX, -}; - -struct nf_dn_rtmsg { -	int nfdn_ifindex; -}; - -#define NFDN_RTMSG(r) ((unsigned char *)(r) + NLMSG_ALIGN(sizeof(struct nf_dn_rtmsg))) - -#ifndef __KERNEL__ -/* backwards compatibility for userspace */ -#define DNRMG_L1_GROUP 0x01 -#define DNRMG_L2_GROUP 0x02 -#endif - -enum { -	DNRNG_NLGRP_NONE, -#define DNRNG_NLGRP_NONE	DNRNG_NLGRP_NONE -	DNRNG_NLGRP_L1, -#define DNRNG_NLGRP_L1		DNRNG_NLGRP_L1 -	DNRNG_NLGRP_L2, -#define DNRNG_NLGRP_L2		DNRNG_NLGRP_L2 -	__DNRNG_NLGRP_MAX -}; -#define DNRNG_NLGRP_MAX	(__DNRNG_NLGRP_MAX - 1) - -#endif /*__LINUX_DECNET_NETFILTER_H*/ diff --git a/include/uapi/linux/netfilter_ipv4/ip_tables.h b/include/uapi/linux/netfilter_ipv4/ip_tables.h index 50c7fee625ae..1485df28b239 100644 --- a/include/uapi/linux/netfilter_ipv4/ip_tables.h +++ b/include/uapi/linux/netfilter_ipv4/ip_tables.h @@ -121,7 +121,7 @@ struct ipt_entry {  	struct xt_counters counters;  	/* The matches (if any), then the target. */ -	unsigned char elems[0]; +	unsigned char elems[];  };  /* @@ -203,7 +203,7 @@ struct ipt_replace {  	struct xt_counters __user *counters;  	/* The entries (hang off end: not really an array). */ -	struct ipt_entry entries[0]; +	struct ipt_entry entries[];  };  /* The argument to IPT_SO_GET_ENTRIES. */ @@ -215,7 +215,7 @@ struct ipt_get_entries {  	unsigned int size;  	/* The entries. */ -	struct ipt_entry entrytable[0]; +	struct ipt_entry entrytable[];  };  /* Helper functions */ diff --git a/include/uapi/linux/netfilter_ipv6/ip6_tables.h b/include/uapi/linux/netfilter_ipv6/ip6_tables.h index d9e364f96a5c..766e8e0bcc68 100644 --- a/include/uapi/linux/netfilter_ipv6/ip6_tables.h +++ b/include/uapi/linux/netfilter_ipv6/ip6_tables.h @@ -243,7 +243,7 @@ struct ip6t_replace {  	struct xt_counters __user *counters;  	/* The entries (hang off end: not really an array). */ -	struct ip6t_entry entries[0]; +	struct ip6t_entry entries[];  };  /* The argument to IP6T_SO_GET_ENTRIES. */ @@ -255,7 +255,7 @@ struct ip6t_get_entries {  	unsigned int size;  	/* The entries. */ -	struct ip6t_entry entrytable[0]; +	struct ip6t_entry entrytable[];  };  /* Helper functions */ diff --git a/include/uapi/linux/netfilter_ipv6/ip6t_LOG.h b/include/uapi/linux/netfilter_ipv6/ip6t_LOG.h index 23e91a9c2583..0b7b16dbdec2 100644 --- a/include/uapi/linux/netfilter_ipv6/ip6t_LOG.h +++ b/include/uapi/linux/netfilter_ipv6/ip6t_LOG.h @@ -17,4 +17,4 @@ struct ip6t_log_info {  	char prefix[30];  }; -#endif /*_IPT_LOG_H*/ +#endif /* _IP6T_LOG_H */ diff --git a/include/uapi/linux/netlink.h b/include/uapi/linux/netlink.h index eac8a6a648ea..f87aaf28a649 100644 --- a/include/uapi/linux/netlink.h +++ b/include/uapi/linux/netlink.h @@ -2,7 +2,7 @@  #ifndef _UAPI__LINUX_NETLINK_H  #define _UAPI__LINUX_NETLINK_H -#include <linux/kernel.h> +#include <linux/const.h>  #include <linux/socket.h> /* for __kernel_sa_family_t */  #include <linux/types.h> @@ -20,7 +20,7 @@  #define NETLINK_CONNECTOR	11  #define NETLINK_NETFILTER	12	/* netfilter subsystem */  #define NETLINK_IP6_FW		13 -#define NETLINK_DNRTMSG		14	/* DECnet routing messages */ +#define NETLINK_DNRTMSG		14	/* DECnet routing messages (obsolete) */  #define NETLINK_KOBJECT_UEVENT	15	/* Kernel messages to userspace */  #define NETLINK_GENERIC		16  /* leave room for NETLINK_DM (DM Events) */ @@ -41,12 +41,20 @@ struct sockaddr_nl {         	__u32		nl_groups;	/* multicast groups mask */  }; +/** + * struct nlmsghdr - fixed format metadata header of Netlink messages + * @nlmsg_len:   Length of message including header + * @nlmsg_type:  Message content type + * @nlmsg_flags: Additional flags + * @nlmsg_seq:   Sequence number + * @nlmsg_pid:   Sending process port ID + */  struct nlmsghdr { -	__u32		nlmsg_len;	/* Length of message including header */ -	__u16		nlmsg_type;	/* Message content */ -	__u16		nlmsg_flags;	/* Additional flags */ -	__u32		nlmsg_seq;	/* Sequence number */ -	__u32		nlmsg_pid;	/* Sending process port ID */ +	__u32		nlmsg_len; +	__u16		nlmsg_type; +	__u16		nlmsg_flags; +	__u32		nlmsg_seq; +	__u32		nlmsg_pid;  };  /* Flags values */ @@ -54,7 +62,7 @@ struct nlmsghdr {  #define NLM_F_REQUEST		0x01	/* It is request message. 	*/  #define NLM_F_MULTI		0x02	/* Multipart message, terminated by NLMSG_DONE */  #define NLM_F_ACK		0x04	/* Reply with ack, with zero or error code */ -#define NLM_F_ECHO		0x08	/* Echo this request 		*/ +#define NLM_F_ECHO		0x08	/* Receive resulting notifications */  #define NLM_F_DUMP_INTR		0x10	/* Dump was inconsistent due to sequence change */  #define NLM_F_DUMP_FILTERED	0x20	/* Dump was filtered as requested */ @@ -72,6 +80,7 @@ struct nlmsghdr {  /* Modifiers to DELETE request */  #define NLM_F_NONREC	0x100	/* Do not delete recursively	*/ +#define NLM_F_BULK	0x200	/* Delete multiple objects	*/  /* Flags for ACK message */  #define NLM_F_CAPPED	0x100	/* request was capped */ @@ -91,9 +100,10 @@ struct nlmsghdr {  #define NLMSG_HDRLEN	 ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))  #define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN)  #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len)) -#define NLMSG_DATA(nlh)  ((void*)(((char*)nlh) + NLMSG_LENGTH(0))) +#define NLMSG_DATA(nlh)  ((void *)(((char *)nlh) + NLMSG_HDRLEN))  #define NLMSG_NEXT(nlh,len)	 ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ -				  (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) +				  (struct nlmsghdr *)(((char *)(nlh)) + \ +				  NLMSG_ALIGN((nlh)->nlmsg_len)))  #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \  			   (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \  			   (nlh)->nlmsg_len <= (len)) @@ -129,6 +139,11 @@ struct nlmsgerr {   * @NLMSGERR_ATTR_COOKIE: arbitrary subsystem specific cookie to   *	be used - in the success case - to identify a created   *	object or operation or similar (binary) + * @NLMSGERR_ATTR_POLICY: policy for a rejected attribute + * @NLMSGERR_ATTR_MISS_TYPE: type of a missing required attribute, + *	%NLMSGERR_ATTR_MISS_NEST will not be present if the attribute was + *	missing at the message level + * @NLMSGERR_ATTR_MISS_NEST: offset of the nest where attribute was missing   * @__NLMSGERR_ATTR_MAX: number of attributes   * @NLMSGERR_ATTR_MAX: highest attribute number   */ @@ -137,6 +152,9 @@ enum nlmsgerr_attrs {  	NLMSGERR_ATTR_MSG,  	NLMSGERR_ATTR_OFFS,  	NLMSGERR_ATTR_COOKIE, +	NLMSGERR_ATTR_POLICY, +	NLMSGERR_ATTR_MISS_TYPE, +	NLMSGERR_ATTR_MISS_NEST,  	__NLMSGERR_ATTR_MAX,  	NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1 @@ -280,6 +298,8 @@ struct nla_bitfield32 {   *	entry has attributes again, the policy for those inner ones   *	and the corresponding maxtype may be specified.   * @NL_ATTR_TYPE_BITFIELD32: &struct nla_bitfield32 attribute + * @NL_ATTR_TYPE_SINT: 32-bit or 64-bit signed attribute, aligned to 4B + * @NL_ATTR_TYPE_UINT: 32-bit or 64-bit unsigned attribute, aligned to 4B   */  enum netlink_attribute_type {  	NL_ATTR_TYPE_INVALID, @@ -304,6 +324,9 @@ enum netlink_attribute_type {  	NL_ATTR_TYPE_NESTED_ARRAY,  	NL_ATTR_TYPE_BITFIELD32, + +	NL_ATTR_TYPE_SINT, +	NL_ATTR_TYPE_UINT,  };  /** @@ -331,7 +354,11 @@ enum netlink_attribute_type {   *	the index, if limited inside the nesting (U32)   * @NL_POLICY_TYPE_ATTR_BITFIELD32_MASK: valid mask for the   *	bitfield32 type (U32) + * @NL_POLICY_TYPE_ATTR_MASK: mask of valid bits for unsigned integers (U64)   * @NL_POLICY_TYPE_ATTR_PAD: pad attribute for 64-bit alignment + * + * @__NL_POLICY_TYPE_ATTR_MAX: number of attributes + * @NL_POLICY_TYPE_ATTR_MAX: highest attribute number   */  enum netlink_policy_type_attr {  	NL_POLICY_TYPE_ATTR_UNSPEC, @@ -346,6 +373,7 @@ enum netlink_policy_type_attr {  	NL_POLICY_TYPE_ATTR_POLICY_MAXTYPE,  	NL_POLICY_TYPE_ATTR_BITFIELD32_MASK,  	NL_POLICY_TYPE_ATTR_PAD, +	NL_POLICY_TYPE_ATTR_MASK,  	/* keep last */  	__NL_POLICY_TYPE_ATTR_MAX, diff --git a/include/uapi/linux/netlink_diag.h b/include/uapi/linux/netlink_diag.h index dfa61be43d2f..ff28200204bb 100644 --- a/include/uapi/linux/netlink_diag.h +++ b/include/uapi/linux/netlink_diag.h @@ -1,6 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __NETLINK_DIAG_H__ -#define __NETLINK_DIAG_H__ +#ifndef _UAPI__NETLINK_DIAG_H__ +#define _UAPI__NETLINK_DIAG_H__  #include <linux/types.h> diff --git a/include/uapi/linux/nexthop.h b/include/uapi/linux/nexthop.h index 2d4a1e784cf0..bc49baf4a267 100644 --- a/include/uapi/linux/nexthop.h +++ b/include/uapi/linux/nexthop.h @@ -16,17 +16,31 @@ struct nhmsg {  struct nexthop_grp {  	__u32	id;	  /* nexthop id - must exist */  	__u8	weight;   /* weight of this nexthop */ -	__u8	resvd1; +	__u8	weight_high;	/* high order bits of weight */  	__u16	resvd2;  }; +static inline __u16 nexthop_grp_weight(const struct nexthop_grp *entry) +{ +	return ((entry->weight_high << 8) | entry->weight) + 1; +} +  enum { -	NEXTHOP_GRP_TYPE_MPATH,  /* default type if not specified */ +	NEXTHOP_GRP_TYPE_MPATH,  /* hash-threshold nexthop group +				  * default type if not specified +				  */ +	NEXTHOP_GRP_TYPE_RES,    /* resilient nexthop group */  	__NEXTHOP_GRP_TYPE_MAX,  };  #define NEXTHOP_GRP_TYPE_MAX (__NEXTHOP_GRP_TYPE_MAX - 1) +#define NHA_OP_FLAG_DUMP_STATS		BIT(0) +#define NHA_OP_FLAG_DUMP_HW_STATS	BIT(1) + +/* Response OP_FLAGS. */ +#define NHA_OP_FLAG_RESP_GRP_RESVD_0	BIT(31)	/* Dump clears resvd fields. */ +  enum {  	NHA_UNSPEC,  	NHA_ID,		/* u32; id for nexthop. id == 0 means auto-assign */ @@ -52,8 +66,92 @@ enum {  	NHA_FDB,	/* flag; nexthop belongs to a bridge fdb */  	/* if NHA_FDB is added, OIF, BLACKHOLE, ENCAP cannot be set */ +	/* nested; resilient nexthop group attributes */ +	NHA_RES_GROUP, +	/* nested; nexthop bucket attributes */ +	NHA_RES_BUCKET, + +	/* u32; operation-specific flags */ +	NHA_OP_FLAGS, + +	/* nested; nexthop group stats */ +	NHA_GROUP_STATS, + +	/* u32; nexthop hardware stats enable */ +	NHA_HW_STATS_ENABLE, + +	/* u32; read-only; whether any driver collects HW stats */ +	NHA_HW_STATS_USED, +  	__NHA_MAX,  };  #define NHA_MAX	(__NHA_MAX - 1) + +enum { +	NHA_RES_GROUP_UNSPEC, +	/* Pad attribute for 64-bit alignment. */ +	NHA_RES_GROUP_PAD = NHA_RES_GROUP_UNSPEC, + +	/* u16; number of nexthop buckets in a resilient nexthop group */ +	NHA_RES_GROUP_BUCKETS, +	/* clock_t as u32; nexthop bucket idle timer (per-group) */ +	NHA_RES_GROUP_IDLE_TIMER, +	/* clock_t as u32; nexthop unbalanced timer */ +	NHA_RES_GROUP_UNBALANCED_TIMER, +	/* clock_t as u64; nexthop unbalanced time */ +	NHA_RES_GROUP_UNBALANCED_TIME, + +	__NHA_RES_GROUP_MAX, +}; + +#define NHA_RES_GROUP_MAX	(__NHA_RES_GROUP_MAX - 1) + +enum { +	NHA_RES_BUCKET_UNSPEC, +	/* Pad attribute for 64-bit alignment. */ +	NHA_RES_BUCKET_PAD = NHA_RES_BUCKET_UNSPEC, + +	/* u16; nexthop bucket index */ +	NHA_RES_BUCKET_INDEX, +	/* clock_t as u64; nexthop bucket idle time */ +	NHA_RES_BUCKET_IDLE_TIME, +	/* u32; nexthop id assigned to the nexthop bucket */ +	NHA_RES_BUCKET_NH_ID, + +	__NHA_RES_BUCKET_MAX, +}; + +#define NHA_RES_BUCKET_MAX	(__NHA_RES_BUCKET_MAX - 1) + +enum { +	NHA_GROUP_STATS_UNSPEC, + +	/* nested; nexthop group entry stats */ +	NHA_GROUP_STATS_ENTRY, + +	__NHA_GROUP_STATS_MAX, +}; + +#define NHA_GROUP_STATS_MAX	(__NHA_GROUP_STATS_MAX - 1) + +enum { +	NHA_GROUP_STATS_ENTRY_UNSPEC, + +	/* u32; nexthop id of the nexthop group entry */ +	NHA_GROUP_STATS_ENTRY_ID, + +	/* uint; number of packets forwarded via the nexthop group entry */ +	NHA_GROUP_STATS_ENTRY_PACKETS, + +	/* uint; number of packets forwarded via the nexthop group entry in +	 * hardware +	 */ +	NHA_GROUP_STATS_ENTRY_PACKETS_HW, + +	__NHA_GROUP_STATS_ENTRY_MAX, +}; + +#define NHA_GROUP_STATS_ENTRY_MAX	(__NHA_GROUP_STATS_ENTRY_MAX - 1) +  #endif diff --git a/include/uapi/linux/nfc.h b/include/uapi/linux/nfc.h index f6e3c8c9c744..2f5b4be25261 100644 --- a/include/uapi/linux/nfc.h +++ b/include/uapi/linux/nfc.h @@ -164,6 +164,7 @@ enum nfc_commands {   * @NFC_ATTR_VENDOR_SUBCMD: Vendor specific sub command   * @NFC_ATTR_VENDOR_DATA: Vendor specific data, to be optionally passed   *	to a vendor specific command implementation + * @NFC_ATTR_TARGET_ATS: ISO 14443 type A target Answer To Select   */  enum nfc_attrs {  	NFC_ATTR_UNSPEC, @@ -198,6 +199,7 @@ enum nfc_attrs {  	NFC_ATTR_VENDOR_ID,  	NFC_ATTR_VENDOR_SUBCMD,  	NFC_ATTR_VENDOR_DATA, +	NFC_ATTR_TARGET_ATS,  /* private: internal use only */  	__NFC_ATTR_AFTER_LAST  }; @@ -225,6 +227,7 @@ enum nfc_sdp_attr {  #define NFC_GB_MAXSIZE			48  #define NFC_FIRMWARE_NAME_MAXSIZE	32  #define NFC_ISO15693_UID_MAXSIZE	8 +#define NFC_ATS_MAXSIZE			20  /* NFC protocols */  #define NFC_PROTO_JEWEL		1 @@ -263,7 +266,7 @@ enum nfc_sdp_attr {  #define NFC_SE_ENABLED  0x1  struct sockaddr_nfc { -	sa_family_t sa_family; +	__kernel_sa_family_t sa_family;  	__u32 dev_idx;  	__u32 target_idx;  	__u32 nfc_protocol; @@ -271,14 +274,14 @@ struct sockaddr_nfc {  #define NFC_LLCP_MAX_SERVICE_NAME 63  struct sockaddr_nfc_llcp { -	sa_family_t sa_family; +	__kernel_sa_family_t sa_family;  	__u32 dev_idx;  	__u32 target_idx;  	__u32 nfc_protocol;  	__u8 dsap; /* Destination SAP, if known */  	__u8 ssap; /* Source SAP to be bound to */  	char service_name[NFC_LLCP_MAX_SERVICE_NAME]; /* Service name URI */; -	size_t service_name_len; +	__kernel_size_t service_name_len;  };  /* NFC socket protocols */ diff --git a/include/uapi/linux/nfs.h b/include/uapi/linux/nfs.h index 946cb62d64b0..f356f2ba3814 100644 --- a/include/uapi/linux/nfs.h +++ b/include/uapi/linux/nfs.h @@ -61,7 +61,6 @@  	NFSERR_NOSPC = 28,		/* v2 v3 v4 */  	NFSERR_ROFS = 30,		/* v2 v3 v4 */  	NFSERR_MLINK = 31,		/*    v3 v4 */ -	NFSERR_OPNOTSUPP = 45,		/* v2 v3 */  	NFSERR_NAMETOOLONG = 63,	/* v2 v3 v4 */  	NFSERR_NOTEMPTY = 66,		/* v2 v3 v4 */  	NFSERR_DQUOT = 69,		/* v2 v3 v4 */ diff --git a/include/uapi/linux/nfs3.h b/include/uapi/linux/nfs3.h index 37e4b34e6b43..c22ab77713bd 100644 --- a/include/uapi/linux/nfs3.h +++ b/include/uapi/linux/nfs3.h @@ -63,6 +63,12 @@ enum nfs3_ftype {  	NF3BAD  = 8  }; +enum nfs3_time_how { +	DONT_CHANGE		= 0, +	SET_TO_SERVER_TIME	= 1, +	SET_TO_CLIENT_TIME	= 2, +}; +  struct nfs3_fh {  	unsigned short size;  	unsigned char  data[NFS3_FHSIZE]; diff --git a/include/uapi/linux/nfs4.h b/include/uapi/linux/nfs4.h index bf197e99b98f..4273e0249fcb 100644 --- a/include/uapi/linux/nfs4.h +++ b/include/uapi/linux/nfs4.h @@ -45,6 +45,8 @@  #define NFS4_OPEN_RESULT_CONFIRM		0x0002  #define NFS4_OPEN_RESULT_LOCKTYPE_POSIX		0x0004 +#define NFS4_OPEN_RESULT_PRESERVE_UNLINKED	0x0008 +#define NFS4_OPEN_RESULT_NO_OPEN_STATEID	0x0010  #define NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK	0x0020  #define NFS4_SHARE_ACCESS_MASK	0x000F @@ -56,7 +58,7 @@  #define NFS4_SHARE_DENY_BOTH	0x0003  /* nfs41 */ -#define NFS4_SHARE_WANT_MASK		0xFF00 +#define NFS4_SHARE_WANT_TYPE_MASK	0xFF00  #define NFS4_SHARE_WANT_NO_PREFERENCE	0x0000  #define NFS4_SHARE_WANT_READ_DELEG	0x0100  #define NFS4_SHARE_WANT_WRITE_DELEG	0x0200 @@ -64,10 +66,16 @@  #define NFS4_SHARE_WANT_NO_DELEG	0x0400  #define NFS4_SHARE_WANT_CANCEL		0x0500 -#define NFS4_SHARE_WHEN_MASK		0xF0000 +#define NFS4_SHARE_WHEN_MASK				0xF0000  #define NFS4_SHARE_SIGNAL_DELEG_WHEN_RESRC_AVAIL	0x10000  #define NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED		0x20000 +#define NFS4_SHARE_WANT_MOD_MASK			0xF00000 +#define NFS4_SHARE_WANT_DELEG_TIMESTAMPS		0x100000 +#define NFS4_SHARE_WANT_OPEN_XOR_DELEGATION		0x200000 + +#define NFS4_SHARE_WANT_MASK	(NFS4_SHARE_WANT_TYPE_MASK | NFS4_SHARE_WANT_MOD_MASK) +  #define NFS4_CDFC4_FORE	0x1  #define NFS4_CDFC4_BACK 0x2  #define NFS4_CDFC4_BOTH 0x3 @@ -139,6 +147,8 @@  #define EXCHGID4_FLAG_UPD_CONFIRMED_REC_A	0x40000000  #define EXCHGID4_FLAG_CONFIRMED_R		0x80000000 + +#define EXCHGID4_FLAG_SUPP_FENCE_OPS		0x00000004  /*   * Since the validity of these bits depends on whether   * they're set in the argument or response, have separate @@ -146,6 +156,7 @@   */  #define EXCHGID4_FLAG_MASK_A			0x40070103  #define EXCHGID4_FLAG_MASK_R			0x80070103 +#define EXCHGID4_2_FLAG_MASK_R			0x80070107  #define SEQ4_STATUS_CB_PATH_DOWN		0x00000001  #define SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING	0x00000002 @@ -175,9 +186,3 @@  #define NFS4_MAX_BACK_CHANNEL_OPS 2  #endif /* _UAPI_LINUX_NFS4_H */ - -/* - * Local variables: - *  c-basic-offset: 8 - * End: - */ diff --git a/include/uapi/linux/nfs_fs.h b/include/uapi/linux/nfs_fs.h index 3afe3767c55d..ae0de165c014 100644 --- a/include/uapi/linux/nfs_fs.h +++ b/include/uapi/linux/nfs_fs.h @@ -52,7 +52,7 @@  #define NFSDBG_CALLBACK		0x0100  #define NFSDBG_CLIENT		0x0200  #define NFSDBG_MOUNT		0x0400 -#define NFSDBG_FSCACHE		0x0800 +#define NFSDBG_FSCACHE		0x0800 /* unused */  #define NFSDBG_PNFS		0x1000  #define NFSDBG_PNFS_LD		0x2000  #define NFSDBG_STATE		0x4000 diff --git a/include/uapi/linux/nfsacl.h b/include/uapi/linux/nfsacl.h index ca9a8501ff30..2c2ad204d3b0 100644 --- a/include/uapi/linux/nfsacl.h +++ b/include/uapi/linux/nfsacl.h @@ -9,11 +9,13 @@  #define NFS_ACL_PROGRAM	100227 +#define ACLPROC2_NULL		0  #define ACLPROC2_GETACL		1  #define ACLPROC2_SETACL		2  #define ACLPROC2_GETATTR	3  #define ACLPROC2_ACCESS		4 +#define ACLPROC3_NULL		0  #define ACLPROC3_GETACL		1  #define ACLPROC3_SETACL		2 diff --git a/include/uapi/linux/nfsd/export.h b/include/uapi/linux/nfsd/export.h index 2124ba904779..a73ca3703abb 100644 --- a/include/uapi/linux/nfsd/export.h +++ b/include/uapi/linux/nfsd/export.h @@ -62,5 +62,18 @@  					| NFSEXP_ALLSQUASH \  					| NFSEXP_INSECURE_PORT) +/* + * Transport layer security policies that are permitted to access + * an export + */ +#define NFSEXP_XPRTSEC_NONE	0x0001 +#define NFSEXP_XPRTSEC_TLS	0x0002 +#define NFSEXP_XPRTSEC_MTLS	0x0004 + +#define NFSEXP_XPRTSEC_NUM	(3) + +#define NFSEXP_XPRTSEC_ALL	(NFSEXP_XPRTSEC_NONE | \ +				 NFSEXP_XPRTSEC_TLS | \ +				 NFSEXP_XPRTSEC_MTLS)  #endif /* _UAPINFSD_EXPORT_H */ diff --git a/include/uapi/linux/nfsd/nfsfh.h b/include/uapi/linux/nfsd/nfsfh.h deleted file mode 100644 index ff0ca88b1c8f..000000000000 --- a/include/uapi/linux/nfsd/nfsfh.h +++ /dev/null @@ -1,105 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * This file describes the layout of the file handles as passed - * over the wire. - * - * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> - */ - -#ifndef _UAPI_LINUX_NFSD_FH_H -#define _UAPI_LINUX_NFSD_FH_H - -#include <linux/types.h> -#include <linux/nfs.h> -#include <linux/nfs2.h> -#include <linux/nfs3.h> -#include <linux/nfs4.h> - -/* - * This is the old "dentry style" Linux NFSv2 file handle. - * - * The xino and xdev fields are currently used to transport the - * ino/dev of the exported inode. - */ -struct nfs_fhbase_old { -	__u32		fb_dcookie;	/* dentry cookie - always 0xfeebbaca */ -	__u32		fb_ino;		/* our inode number */ -	__u32		fb_dirino;	/* dir inode number, 0 for directories */ -	__u32		fb_dev;		/* our device */ -	__u32		fb_xdev; -	__u32		fb_xino; -	__u32		fb_generation; -}; - -/* - * This is the new flexible, extensible style NFSv2/v3/v4 file handle. - * by Neil Brown <neilb@cse.unsw.edu.au> - March 2000 - * - * The file handle starts with a sequence of four-byte words. - * The first word contains a version number (1) and three descriptor bytes - * that tell how the remaining 3 variable length fields should be handled. - * These three bytes are auth_type, fsid_type and fileid_type. - * - * All four-byte values are in host-byte-order. - * - * The auth_type field is deprecated and must be set to 0. - * - * The fsid_type identifies how the filesystem (or export point) is - *    encoded. - *  Current values: - *     0  - 4 byte device id (ms-2-bytes major, ls-2-bytes minor), 4byte inode number - *        NOTE: we cannot use the kdev_t device id value, because kdev_t.h - *              says we mustn't.  We must break it up and reassemble. - *     1  - 4 byte user specified identifier - *     2  - 4 byte major, 4 byte minor, 4 byte inode number - DEPRECATED - *     3  - 4 byte device id, encoded for user-space, 4 byte inode number - *     4  - 4 byte inode number and 4 byte uuid - *     5  - 8 byte uuid - *     6  - 16 byte uuid - *     7  - 8 byte inode number and 16 byte uuid - * - * The fileid_type identified how the file within the filesystem is encoded. - *   The values for this field are filesystem specific, exccept that - *   filesystems must not use the values '0' or '0xff'. 'See enum fid_type' - *   in include/linux/exportfs.h for currently registered values. - */ -struct nfs_fhbase_new { -	__u8		fb_version;	/* == 1, even => nfs_fhbase_old */ -	__u8		fb_auth_type; -	__u8		fb_fsid_type; -	__u8		fb_fileid_type; -	__u32		fb_auth[1]; -/*	__u32		fb_fsid[0]; floating */ -/*	__u32		fb_fileid[0]; floating */ -}; - -struct knfsd_fh { -	unsigned int	fh_size;	/* significant for NFSv3. -					 * Points to the current size while building -					 * a new file handle -					 */ -	union { -		struct nfs_fhbase_old	fh_old; -		__u32			fh_pad[NFS4_FHSIZE/4]; -		struct nfs_fhbase_new	fh_new; -	} fh_base; -}; - -#define ofh_dcookie		fh_base.fh_old.fb_dcookie -#define ofh_ino			fh_base.fh_old.fb_ino -#define ofh_dirino		fh_base.fh_old.fb_dirino -#define ofh_dev			fh_base.fh_old.fb_dev -#define ofh_xdev		fh_base.fh_old.fb_xdev -#define ofh_xino		fh_base.fh_old.fb_xino -#define ofh_generation		fh_base.fh_old.fb_generation - -#define	fh_version		fh_base.fh_new.fb_version -#define	fh_fsid_type		fh_base.fh_new.fb_fsid_type -#define	fh_auth_type		fh_base.fh_new.fb_auth_type -#define	fh_fileid_type		fh_base.fh_new.fb_fileid_type -#define	fh_fsid			fh_base.fh_new.fb_auth - -/* Do not use, provided for userspace compatiblity. */ -#define	fh_auth			fh_base.fh_new.fb_auth - -#endif /* _UAPI_LINUX_NFSD_FH_H */ diff --git a/include/uapi/linux/nfsd_netlink.h b/include/uapi/linux/nfsd_netlink.h new file mode 100644 index 000000000000..887cbd12b695 --- /dev/null +++ b/include/uapi/linux/nfsd_netlink.h @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/nfsd.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_NFSD_NETLINK_H +#define _UAPI_LINUX_NFSD_NETLINK_H + +#define NFSD_FAMILY_NAME	"nfsd" +#define NFSD_FAMILY_VERSION	1 + +enum { +	NFSD_A_RPC_STATUS_XID = 1, +	NFSD_A_RPC_STATUS_FLAGS, +	NFSD_A_RPC_STATUS_PROG, +	NFSD_A_RPC_STATUS_VERSION, +	NFSD_A_RPC_STATUS_PROC, +	NFSD_A_RPC_STATUS_SERVICE_TIME, +	NFSD_A_RPC_STATUS_PAD, +	NFSD_A_RPC_STATUS_SADDR4, +	NFSD_A_RPC_STATUS_DADDR4, +	NFSD_A_RPC_STATUS_SADDR6, +	NFSD_A_RPC_STATUS_DADDR6, +	NFSD_A_RPC_STATUS_SPORT, +	NFSD_A_RPC_STATUS_DPORT, +	NFSD_A_RPC_STATUS_COMPOUND_OPS, + +	__NFSD_A_RPC_STATUS_MAX, +	NFSD_A_RPC_STATUS_MAX = (__NFSD_A_RPC_STATUS_MAX - 1) +}; + +enum { +	NFSD_A_SERVER_THREADS = 1, +	NFSD_A_SERVER_GRACETIME, +	NFSD_A_SERVER_LEASETIME, +	NFSD_A_SERVER_SCOPE, + +	__NFSD_A_SERVER_MAX, +	NFSD_A_SERVER_MAX = (__NFSD_A_SERVER_MAX - 1) +}; + +enum { +	NFSD_A_VERSION_MAJOR = 1, +	NFSD_A_VERSION_MINOR, +	NFSD_A_VERSION_ENABLED, + +	__NFSD_A_VERSION_MAX, +	NFSD_A_VERSION_MAX = (__NFSD_A_VERSION_MAX - 1) +}; + +enum { +	NFSD_A_SERVER_PROTO_VERSION = 1, + +	__NFSD_A_SERVER_PROTO_MAX, +	NFSD_A_SERVER_PROTO_MAX = (__NFSD_A_SERVER_PROTO_MAX - 1) +}; + +enum { +	NFSD_A_SOCK_ADDR = 1, +	NFSD_A_SOCK_TRANSPORT_NAME, + +	__NFSD_A_SOCK_MAX, +	NFSD_A_SOCK_MAX = (__NFSD_A_SOCK_MAX - 1) +}; + +enum { +	NFSD_A_SERVER_SOCK_ADDR = 1, + +	__NFSD_A_SERVER_SOCK_MAX, +	NFSD_A_SERVER_SOCK_MAX = (__NFSD_A_SERVER_SOCK_MAX - 1) +}; + +enum { +	NFSD_A_POOL_MODE_MODE = 1, +	NFSD_A_POOL_MODE_NPOOLS, + +	__NFSD_A_POOL_MODE_MAX, +	NFSD_A_POOL_MODE_MAX = (__NFSD_A_POOL_MODE_MAX - 1) +}; + +enum { +	NFSD_CMD_RPC_STATUS_GET = 1, +	NFSD_CMD_THREADS_SET, +	NFSD_CMD_THREADS_GET, +	NFSD_CMD_VERSION_SET, +	NFSD_CMD_VERSION_GET, +	NFSD_CMD_LISTENER_SET, +	NFSD_CMD_LISTENER_GET, +	NFSD_CMD_POOL_MODE_SET, +	NFSD_CMD_POOL_MODE_GET, + +	__NFSD_CMD_MAX, +	NFSD_CMD_MAX = (__NFSD_CMD_MAX - 1) +}; + +#endif /* _UAPI_LINUX_NFSD_NETLINK_H */ diff --git a/include/uapi/linux/nilfs2_ondisk.h b/include/uapi/linux/nilfs2_ondisk.h index c23f91ae5fe8..3196cc44a002 100644 --- a/include/uapi/linux/nilfs2_ondisk.h +++ b/include/uapi/linux/nilfs2_ondisk.h @@ -188,7 +188,8 @@ struct nilfs_super_block {  	__le16	s_segment_usage_size;	/* Size of a segment usage */  /*98*/	__u8	s_uuid[16];		/* 128-bit uuid for volume */ -/*A8*/	char	s_volume_name[80];	/* volume name */ +/*A8*/	char	s_volume_name[80]	/* volume name */ +			__kernel_nonstring;  /*F8*/	__le32  s_c_interval;           /* Commit interval of segment */  	__le32  s_c_block_max;          /* diff --git a/include/uapi/linux/nitro_enclaves.h b/include/uapi/linux/nitro_enclaves.h new file mode 100644 index 000000000000..e808f5ba124d --- /dev/null +++ b/include/uapi/linux/nitro_enclaves.h @@ -0,0 +1,359 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Copyright 2020-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + */ + +#ifndef _UAPI_LINUX_NITRO_ENCLAVES_H_ +#define _UAPI_LINUX_NITRO_ENCLAVES_H_ + +#include <linux/types.h> + +/** + * DOC: Nitro Enclaves (NE) Kernel Driver Interface + */ + +/** + * NE_CREATE_VM - The command is used to create a slot that is associated with + *		  an enclave VM. + *		  The generated unique slot id is an output parameter. + *		  The ioctl can be invoked on the /dev/nitro_enclaves fd, before + *		  setting any resources, such as memory and vCPUs, for an + *		  enclave. Memory and vCPUs are set for the slot mapped to an enclave. + *		  A NE CPU pool has to be set before calling this function. The + *		  pool can be set after the NE driver load, using + *		  /sys/module/nitro_enclaves/parameters/ne_cpus. + *		  Its format is the detailed in the cpu-lists section: + *		  https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html + *		  CPU 0 and its siblings have to remain available for the + *		  primary / parent VM, so they cannot be set for enclaves. Full + *		  CPU core(s), from the same NUMA node, need(s) to be included + *		  in the CPU pool. + * + * Context: Process context. + * Return: + * * Enclave file descriptor		- Enclave file descriptor used with + *					  ioctl calls to set vCPUs and memory + *					  regions, then start the enclave. + * *  -1				- There was a failure in the ioctl logic. + * On failure, errno is set to: + * * EFAULT				- copy_to_user() failure. + * * ENOMEM				- Memory allocation failure for internal + *					  bookkeeping variables. + * * NE_ERR_NO_CPUS_AVAIL_IN_POOL	- No NE CPU pool set / no CPUs available + *					  in the pool. + * * Error codes from get_unused_fd_flags() and anon_inode_getfile(). + * * Error codes from the NE PCI device request. + */ +#define NE_CREATE_VM			_IOR(0xAE, 0x20, __u64) + +/** + * NE_ADD_VCPU - The command is used to set a vCPU for an enclave. The vCPU can + *		 be auto-chosen from the NE CPU pool or it can be set by the + *		 caller, with the note that it needs to be available in the NE + *		 CPU pool. Full CPU core(s), from the same NUMA node, need(s) to + *		 be associated with an enclave. + *		 The vCPU id is an input / output parameter. If its value is 0, + *		 then a CPU is chosen from the enclave CPU pool and returned via + *		 this parameter. + *		 The ioctl can be invoked on the enclave fd, before an enclave + *		 is started. + * + * Context: Process context. + * Return: + * * 0					- Logic successfully completed. + * *  -1				- There was a failure in the ioctl logic. + * On failure, errno is set to: + * * EFAULT				- copy_from_user() / copy_to_user() failure. + * * ENOMEM				- Memory allocation failure for internal + *					  bookkeeping variables. + * * EIO				- Current task mm is not the same as the one + *					  that created the enclave. + * * NE_ERR_NO_CPUS_AVAIL_IN_POOL	- No CPUs available in the NE CPU pool. + * * NE_ERR_VCPU_ALREADY_USED		- The provided vCPU is already used. + * * NE_ERR_VCPU_NOT_IN_CPU_POOL	- The provided vCPU is not available in the + *					  NE CPU pool. + * * NE_ERR_VCPU_INVALID_CPU_CORE	- The core id of the provided vCPU is invalid + *					  or out of range. + * * NE_ERR_NOT_IN_INIT_STATE		- The enclave is not in init state + *					  (init = before being started). + * * NE_ERR_INVALID_VCPU		- The provided vCPU is not in the available + *					  CPUs range. + * * Error codes from the NE PCI device request. + */ +#define NE_ADD_VCPU			_IOWR(0xAE, 0x21, __u32) + +/** + * NE_GET_IMAGE_LOAD_INFO - The command is used to get information needed for + *			    in-memory enclave image loading e.g. offset in + *			    enclave memory to start placing the enclave image. + *			    The image load info is an input / output parameter. + *			    It includes info provided by the caller - flags - + *			    and returns the offset in enclave memory where to + *			    start placing the enclave image. + *			    The ioctl can be invoked on the enclave fd, before + *			    an enclave is started. + * + * Context: Process context. + * Return: + * * 0				- Logic successfully completed. + * *  -1			- There was a failure in the ioctl logic. + * On failure, errno is set to: + * * EFAULT			- copy_from_user() / copy_to_user() failure. + * * NE_ERR_NOT_IN_INIT_STATE	- The enclave is not in init state (init = + *				  before being started). + * * NE_ERR_INVALID_FLAG_VALUE	- The value of the provided flag is invalid. + */ +#define NE_GET_IMAGE_LOAD_INFO		_IOWR(0xAE, 0x22, struct ne_image_load_info) + +/** + * NE_SET_USER_MEMORY_REGION - The command is used to set a memory region for an + *			       enclave, given the allocated memory from the + *			       userspace. Enclave memory needs to be from the + *			       same NUMA node as the enclave CPUs. + *			       The user memory region is an input parameter. It + *			       includes info provided by the caller - flags, + *			       memory size and userspace address. + *			       The ioctl can be invoked on the enclave fd, + *			       before an enclave is started. + * + * Context: Process context. + * Return: + * * 0					- Logic successfully completed. + * *  -1				- There was a failure in the ioctl logic. + * On failure, errno is set to: + * * EFAULT				- copy_from_user() failure. + * * EINVAL				- Invalid physical memory region(s) e.g. + *					  unaligned address. + * * EIO				- Current task mm is not the same as + *					  the one that created the enclave. + * * ENOMEM				- Memory allocation failure for internal + *					  bookkeeping variables. + * * NE_ERR_NOT_IN_INIT_STATE		- The enclave is not in init state + *					  (init = before being started). + * * NE_ERR_INVALID_MEM_REGION_SIZE	- The memory size of the region is not + *					  multiple of 2 MiB. + * * NE_ERR_INVALID_MEM_REGION_ADDR	- Invalid user space address given. + * * NE_ERR_UNALIGNED_MEM_REGION_ADDR	- Unaligned user space address given. + * * NE_ERR_MEM_REGION_ALREADY_USED	- The memory region is already used. + * * NE_ERR_MEM_NOT_HUGE_PAGE		- The memory region is not backed by + *					  huge pages. + * * NE_ERR_MEM_DIFFERENT_NUMA_NODE	- The memory region is not from the same + *					  NUMA node as the CPUs. + * * NE_ERR_MEM_MAX_REGIONS		- The number of memory regions set for + *					  the enclave reached maximum. + * * NE_ERR_INVALID_PAGE_SIZE		- The memory region is not backed by + *					  pages multiple of 2 MiB. + * * NE_ERR_INVALID_FLAG_VALUE		- The value of the provided flag is invalid. + * * Error codes from get_user_pages(). + * * Error codes from the NE PCI device request. + */ +#define NE_SET_USER_MEMORY_REGION	_IOW(0xAE, 0x23, struct ne_user_memory_region) + +/** + * NE_START_ENCLAVE - The command is used to trigger enclave start after the + *		      enclave resources, such as memory and CPU, have been set. + *		      The enclave start info is an input / output parameter. It + *		      includes info provided by the caller - enclave cid and + *		      flags - and returns the cid (if input cid is 0). + *		      The ioctl can be invoked on the enclave fd, after an + *		      enclave slot is created and resources, such as memory and + *		      vCPUs are set for an enclave. + * + * Context: Process context. + * Return: + * * 0					- Logic successfully completed. + * *  -1				- There was a failure in the ioctl logic. + * On failure, errno is set to: + * * EFAULT				- copy_from_user() / copy_to_user() failure. + * * NE_ERR_NOT_IN_INIT_STATE		- The enclave is not in init state + *					  (init = before being started). + * * NE_ERR_NO_MEM_REGIONS_ADDED	- No memory regions are set. + * * NE_ERR_NO_VCPUS_ADDED		- No vCPUs are set. + * *  NE_ERR_FULL_CORES_NOT_USED	- Full core(s) not set for the enclave. + * * NE_ERR_ENCLAVE_MEM_MIN_SIZE	- Enclave memory is less than minimum + *					  memory size (64 MiB). + * * NE_ERR_INVALID_FLAG_VALUE		- The value of the provided flag is invalid. + * *  NE_ERR_INVALID_ENCLAVE_CID	- The provided enclave CID is invalid. + * * Error codes from the NE PCI device request. + */ +#define NE_START_ENCLAVE		_IOWR(0xAE, 0x24, struct ne_enclave_start_info) + +/** + * DOC: NE specific error codes + */ + +/** + * NE_ERR_VCPU_ALREADY_USED - The provided vCPU is already used. + */ +#define NE_ERR_VCPU_ALREADY_USED		(256) +/** + * NE_ERR_VCPU_NOT_IN_CPU_POOL - The provided vCPU is not available in the + *				 NE CPU pool. + */ +#define NE_ERR_VCPU_NOT_IN_CPU_POOL		(257) +/** + * NE_ERR_VCPU_INVALID_CPU_CORE - The core id of the provided vCPU is invalid + *				  or out of range of the NE CPU pool. + */ +#define NE_ERR_VCPU_INVALID_CPU_CORE		(258) +/** + * NE_ERR_INVALID_MEM_REGION_SIZE - The user space memory region size is not + *				    multiple of 2 MiB. + */ +#define NE_ERR_INVALID_MEM_REGION_SIZE		(259) +/** + * NE_ERR_INVALID_MEM_REGION_ADDR - The user space memory region address range + *				    is invalid. + */ +#define NE_ERR_INVALID_MEM_REGION_ADDR		(260) +/** + * NE_ERR_UNALIGNED_MEM_REGION_ADDR - The user space memory region address is + *				      not aligned. + */ +#define NE_ERR_UNALIGNED_MEM_REGION_ADDR	(261) +/** + * NE_ERR_MEM_REGION_ALREADY_USED - The user space memory region is already used. + */ +#define NE_ERR_MEM_REGION_ALREADY_USED		(262) +/** + * NE_ERR_MEM_NOT_HUGE_PAGE - The user space memory region is not backed by + *			      contiguous physical huge page(s). + */ +#define NE_ERR_MEM_NOT_HUGE_PAGE		(263) +/** + * NE_ERR_MEM_DIFFERENT_NUMA_NODE - The user space memory region is backed by + *				    pages from different NUMA nodes than the CPUs. + */ +#define NE_ERR_MEM_DIFFERENT_NUMA_NODE		(264) +/** + * NE_ERR_MEM_MAX_REGIONS - The supported max memory regions per enclaves has + *			    been reached. + */ +#define NE_ERR_MEM_MAX_REGIONS			(265) +/** + * NE_ERR_NO_MEM_REGIONS_ADDED - The command to start an enclave is triggered + *				 and no memory regions are added. + */ +#define NE_ERR_NO_MEM_REGIONS_ADDED		(266) +/** + * NE_ERR_NO_VCPUS_ADDED - The command to start an enclave is triggered and no + *			   vCPUs are added. + */ +#define NE_ERR_NO_VCPUS_ADDED			(267) +/** + * NE_ERR_ENCLAVE_MEM_MIN_SIZE - The enclave memory size is lower than the + *				 minimum supported. + */ +#define NE_ERR_ENCLAVE_MEM_MIN_SIZE		(268) +/** + * NE_ERR_FULL_CORES_NOT_USED - The command to start an enclave is triggered and + *				full CPU cores are not set. + */ +#define NE_ERR_FULL_CORES_NOT_USED		(269) +/** + * NE_ERR_NOT_IN_INIT_STATE - The enclave is not in init state when setting + *			      resources or triggering start. + */ +#define NE_ERR_NOT_IN_INIT_STATE		(270) +/** + * NE_ERR_INVALID_VCPU - The provided vCPU is out of range of the available CPUs. + */ +#define NE_ERR_INVALID_VCPU			(271) +/** + * NE_ERR_NO_CPUS_AVAIL_IN_POOL - The command to create an enclave is triggered + *				  and no CPUs are available in the pool. + */ +#define NE_ERR_NO_CPUS_AVAIL_IN_POOL		(272) +/** + * NE_ERR_INVALID_PAGE_SIZE - The user space memory region is not backed by pages + *			      multiple of 2 MiB. + */ +#define NE_ERR_INVALID_PAGE_SIZE		(273) +/** + * NE_ERR_INVALID_FLAG_VALUE - The provided flag value is invalid. + */ +#define NE_ERR_INVALID_FLAG_VALUE		(274) +/** + * NE_ERR_INVALID_ENCLAVE_CID - The provided enclave CID is invalid, either + *				being a well-known value or the CID of the + *				parent / primary VM. + */ +#define NE_ERR_INVALID_ENCLAVE_CID		(275) + +/** + * DOC: Image load info flags + */ + +/** + * NE_EIF_IMAGE - Enclave Image Format (EIF) + */ +#define NE_EIF_IMAGE			(0x01) + +#define NE_IMAGE_LOAD_MAX_FLAG_VAL	(0x02) + +/** + * struct ne_image_load_info - Info necessary for in-memory enclave image + *			       loading (in / out). + * @flags:		Flags to determine the enclave image type + *			(e.g. Enclave Image Format - EIF) (in). + * @memory_offset:	Offset in enclave memory where to start placing the + *			enclave image (out). + */ +struct ne_image_load_info { +	__u64	flags; +	__u64	memory_offset; +}; + +/** + * DOC: User memory region flags + */ + +/** + * NE_DEFAULT_MEMORY_REGION - Memory region for enclave general usage. + */ +#define NE_DEFAULT_MEMORY_REGION	(0x00) + +#define NE_MEMORY_REGION_MAX_FLAG_VAL	(0x01) + +/** + * struct ne_user_memory_region - Memory region to be set for an enclave (in). + * @flags:		Flags to determine the usage for the memory region (in). + * @memory_size:	The size, in bytes, of the memory region to be set for + *			an enclave (in). + * @userspace_addr:	The start address of the userspace allocated memory of + *			the memory region to set for an enclave (in). + */ +struct ne_user_memory_region { +	__u64	flags; +	__u64	memory_size; +	__u64	userspace_addr; +}; + +/** + * DOC: Enclave start info flags + */ + +/** + * NE_ENCLAVE_PRODUCTION_MODE - Start enclave in production mode. + */ +#define NE_ENCLAVE_PRODUCTION_MODE	(0x00) +/** + * NE_ENCLAVE_DEBUG_MODE - Start enclave in debug mode. + */ +#define NE_ENCLAVE_DEBUG_MODE		(0x01) + +#define NE_ENCLAVE_START_MAX_FLAG_VAL	(0x02) + +/** + * struct ne_enclave_start_info - Setup info necessary for enclave start (in / out). + * @flags:		Flags for the enclave to start with (e.g. debug mode) (in). + * @enclave_cid:	Context ID (CID) for the enclave vsock device. If 0 as + *			input, the CID is autogenerated by the hypervisor and + *			returned back as output by the driver (in / out). + */ +struct ne_enclave_start_info { +	__u64	flags; +	__u64	enclave_cid; +}; + +#endif /* _UAPI_LINUX_NITRO_ENCLAVES_H_ */ diff --git a/include/uapi/linux/nl80211-vnd-intel.h b/include/uapi/linux/nl80211-vnd-intel.h new file mode 100644 index 000000000000..4ed7d0b24512 --- /dev/null +++ b/include/uapi/linux/nl80211-vnd-intel.h @@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Copyright (C) 2012-2014, 2018-2021 Intel Corporation + * Copyright (C) 2013-2015 Intel Mobile Communications GmbH + * Copyright (C) 2016-2017 Intel Deutschland GmbH + */ +#ifndef __VENDOR_CMD_INTEL_H__ +#define __VENDOR_CMD_INTEL_H__ + +#define INTEL_OUI	0x001735 + +/** + * enum iwl_mvm_vendor_cmd - supported vendor commands + * @IWL_MVM_VENDOR_CMD_GET_CSME_CONN_INFO: reports CSME connection info. + * @IWL_MVM_VENDOR_CMD_HOST_GET_OWNERSHIP: asks for ownership on the device. + *	This is useful when the CSME firmware owns the device and the kernel + *	wants to use it. In case the CSME firmware has no connection active the + *	kernel will manage on its own to get ownership of the device. + *	When the CSME firmware has an active connection, the user space + *	involvement is required. The kernel will assert the RFKILL signal with + *	the "device not owned" reason so that nobody can touch the device. Then + *	the user space can run the following flow to be able to get connected + *	to the very same AP the CSME firmware is currently connected to: + * + *	1) The user space (NetworkManager) boots and sees that the device is + *	    in RFKILL because the host doesn't own the device + *	2) The user space asks the kernel what AP the CSME firmware is + *	   connected to (with %IWL_MVM_VENDOR_CMD_GET_CSME_CONN_INFO) + *	3) The user space checks if it has a profile that matches the reply + *	   from the CSME firmware + *	4) The user space installs a network to the wpa_supplicant with a + *	   specific BSSID and a specific frequency + *	5) The user space prevents any type of full scan + *	6) The user space asks iwlmei to request ownership on the device (with + *	   this command) + *	7) iwlmei requests ownership from the CSME firmware + *	8) The CSME firmware grants ownership + *	9) iwlmei tells iwlwifi to lift the RFKILL + *	10) RFKILL OFF is reported to user space + *	11) The host boots the device, loads the firwmare, and connects to a + *	    specific BSSID without scanning including IP as fast as it can + *	12) The host reports to the CSME firmware that there is a connection + *	13) The TCP connection is preserved and the host has connectivity + * + * @IWL_MVM_VENDOR_CMD_ROAMING_FORBIDDEN_EVENT: notifies if roaming is allowed. + *	It contains a &IWL_MVM_VENDOR_ATTR_ROAMING_FORBIDDEN and a + *	&IWL_MVM_VENDOR_ATTR_VIF_ADDR attributes. + */ + +enum iwl_mvm_vendor_cmd { +	IWL_MVM_VENDOR_CMD_GET_CSME_CONN_INFO			= 0x2d, +	IWL_MVM_VENDOR_CMD_HOST_GET_OWNERSHIP			= 0x30, +	IWL_MVM_VENDOR_CMD_ROAMING_FORBIDDEN_EVENT		= 0x32, +}; + +enum iwl_vendor_auth_akm_mode { +	IWL_VENDOR_AUTH_OPEN, +	IWL_VENDOR_AUTH_RSNA = 0x6, +	IWL_VENDOR_AUTH_RSNA_PSK, +	IWL_VENDOR_AUTH_SAE = 0x9, +	IWL_VENDOR_AUTH_MAX, +}; + +/** + * enum iwl_mvm_vendor_attr - attributes used in vendor commands + * @__IWL_MVM_VENDOR_ATTR_INVALID: attribute 0 is invalid + * @IWL_MVM_VENDOR_ATTR_VIF_ADDR: interface MAC address + * @IWL_MVM_VENDOR_ATTR_ADDR: MAC address + * @IWL_MVM_VENDOR_ATTR_SSID: SSID (binary attribute, 0..32 octets) + * @IWL_MVM_VENDOR_ATTR_STA_CIPHER: the cipher to use for the station with the + *	mac address specified in &IWL_MVM_VENDOR_ATTR_ADDR. + * @IWL_MVM_VENDOR_ATTR_ROAMING_FORBIDDEN: u8 attribute. Indicates whether + *	roaming is forbidden or not. Value 1 means roaming is forbidden, + *	0 mean roaming is allowed. + * @IWL_MVM_VENDOR_ATTR_AUTH_MODE: u32 attribute. Authentication mode type + *	as specified in &enum iwl_vendor_auth_akm_mode. + * @IWL_MVM_VENDOR_ATTR_CHANNEL_NUM: u8 attribute. Contains channel number. + * @IWL_MVM_VENDOR_ATTR_BAND: u8 attribute. + *	0 for 2.4 GHz band, 1 for 5.2GHz band and 2 for 6GHz band. + * @IWL_MVM_VENDOR_ATTR_COLLOC_CHANNEL: u32 attribute. Channel number of + *	collocated AP. Relevant for 6GHz AP info. + * @IWL_MVM_VENDOR_ATTR_COLLOC_ADDR: MAC address of a collocated AP. + *	Relevant for 6GHz AP info. + * + * @NUM_IWL_MVM_VENDOR_ATTR: number of vendor attributes + * @MAX_IWL_MVM_VENDOR_ATTR: highest vendor attribute number + + */ +enum iwl_mvm_vendor_attr { +	__IWL_MVM_VENDOR_ATTR_INVALID				= 0x00, +	IWL_MVM_VENDOR_ATTR_VIF_ADDR				= 0x02, +	IWL_MVM_VENDOR_ATTR_ADDR				= 0x0a, +	IWL_MVM_VENDOR_ATTR_SSID				= 0x3d, +	IWL_MVM_VENDOR_ATTR_STA_CIPHER				= 0x51, +	IWL_MVM_VENDOR_ATTR_ROAMING_FORBIDDEN			= 0x64, +	IWL_MVM_VENDOR_ATTR_AUTH_MODE				= 0x65, +	IWL_MVM_VENDOR_ATTR_CHANNEL_NUM				= 0x66, +	IWL_MVM_VENDOR_ATTR_BAND				= 0x69, +	IWL_MVM_VENDOR_ATTR_COLLOC_CHANNEL			= 0x70, +	IWL_MVM_VENDOR_ATTR_COLLOC_ADDR				= 0x71, + +	NUM_IWL_MVM_VENDOR_ATTR, +	MAX_IWL_MVM_VENDOR_ATTR = NUM_IWL_MVM_VENDOR_ATTR - 1, +}; + +#endif /* __VENDOR_CMD_INTEL_H__ */ diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 631f3a997b3c..d1a14f2892d9 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -11,7 +11,7 @@   * Copyright 2008 Jouni Malinen <jouni.malinen@atheros.com>   * Copyright 2008 Colin McCabe <colin@cozybit.com>   * Copyright 2015-2017	Intel Deutschland GmbH - * Copyright (C) 2018-2020 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation   *   * Permission to use, copy, modify, and/or distribute this software for any   * purpose with or without fee is hereby granted, provided that the above @@ -72,7 +72,7 @@   * For drivers supporting TDLS with external setup (WIPHY_FLAG_SUPPORTS_TDLS   * and WIPHY_FLAG_TDLS_EXTERNAL_SETUP), the station lifetime is as follows:   *  - a setup station entry is added, not yet authorized, without any rate - *    or capability information, this just exists to avoid race conditions + *    or capability information; this just exists to avoid race conditions   *  - when the TDLS setup is done, a single NL80211_CMD_SET_STATION is valid   *    to add rate and capability information to the station and at the same   *    time mark it authorized. @@ -87,7 +87,7 @@   * DOC: Frame transmission/registration support   *   * Frame transmission and registration support exists to allow userspace - * management entities such as wpa_supplicant react to management frames + * management entities such as wpa_supplicant to react to management frames   * that are not being handled by the kernel. This includes, for example,   * certain classes of action frames that cannot be handled in the kernel   * for various reasons. @@ -113,7 +113,7 @@   *   * Frame transmission allows userspace to send for example the required   * responses to action frames. It is subject to some sanity checking, - * but many frames can be transmitted. When a frame was transmitted, its + * but many frames can be transmitted. When a frame is transmitted, its   * status is indicated to the sending socket.   *   * For more technical details, see the corresponding command descriptions @@ -123,7 +123,7 @@  /**   * DOC: Virtual interface / concurrency capabilities   * - * Some devices are able to operate with virtual MACs, they can have + * Some devices are able to operate with virtual MACs; they can have   * more than one virtual interface. The capability handling for this   * is a bit complex though, as there may be a number of restrictions   * on the types of concurrency that are supported. @@ -135,7 +135,7 @@   * Once concurrency is desired, more attributes must be observed:   * To start with, since some interface types are purely managed in   * software, like the AP-VLAN type in mac80211 for example, there's - * an additional list of these, they can be added at any time and + * an additional list of these; they can be added at any time and   * are only restricted by some semantic restrictions (e.g. AP-VLAN   * cannot be added without a corresponding AP interface). This list   * is exported in the %NL80211_ATTR_SOFTWARE_IFTYPES attribute. @@ -164,17 +164,17 @@   * Packet coalesce feature helps to reduce number of received interrupts   * to host by buffering these packets in firmware/hardware for some   * predefined time. Received interrupt will be generated when one of the - * following events occur. + * following events occurs.   * a) Expiration of hardware timer whose expiration time is set to maximum   * coalescing delay of matching coalesce rule. - * b) Coalescing buffer in hardware reaches it's limit. + * b) Coalescing buffer in hardware reaches its limit.   * c) Packet doesn't match any of the configured coalesce rules.   *   * User needs to configure following parameters for creating a coalesce   * rule.   * a) Maximum coalescing delay   * b) List of packet patterns which needs to be matched - * c) Condition for coalescence. pattern 'match' or 'no match' + * c) Condition for coalescence: pattern 'match' or 'no match'   * Multiple such rules can be created.   */ @@ -213,7 +213,7 @@  /**   * DOC: FILS shared key authentication offload   * - * FILS shared key authentication offload can be advertized by drivers by + * FILS shared key authentication offload can be advertised by drivers by   * setting @NL80211_EXT_FEATURE_FILS_SK_OFFLOAD flag. The drivers that support   * FILS shared key authentication offload should be able to construct the   * authentication and association frames for FILS shared key authentication and @@ -239,7 +239,7 @@   * The PMKSA can be maintained in userspace persistently so that it can be used   * later after reboots or wifi turn off/on also.   * - * %NL80211_ATTR_FILS_CACHE_ID is the cache identifier advertized by a FILS + * %NL80211_ATTR_FILS_CACHE_ID is the cache identifier advertised by a FILS   * capable AP supporting PMK caching. It specifies the scope within which the   * PMKSAs are cached in an ESS. %NL80211_CMD_SET_PMKSA and   * %NL80211_CMD_DEL_PMKSA are enhanced to allow support for PMKSA caching based @@ -252,9 +252,13 @@   * DOC: SAE authentication offload   *   * By setting @NL80211_EXT_FEATURE_SAE_OFFLOAD flag drivers can indicate they - * support offloading SAE authentication for WPA3-Personal networks. In - * %NL80211_CMD_CONNECT the password for SAE should be specified using - * %NL80211_ATTR_SAE_PASSWORD. + * support offloading SAE authentication for WPA3-Personal networks in station + * mode. Similarly @NL80211_EXT_FEATURE_SAE_OFFLOAD_AP flag can be set by + * drivers indicating the offload support in AP mode. + * + * The password for SAE should be specified using %NL80211_ATTR_SAE_PASSWORD in + * %NL80211_CMD_CONNECT and %NL80211_CMD_START_AP for station and AP mode + * respectively.   */  /** @@ -286,17 +290,60 @@   * If the configuration needs to be applied for specific peer then the MAC   * address of the peer needs to be passed in %NL80211_ATTR_MAC, otherwise the   * configuration will be applied for all the connected peers in the vif except - * any peers that have peer specific configuration for the TID by default; if - * the %NL80211_TID_CONFIG_ATTR_OVERRIDE flag is set, peer specific values + * any peers that have peer-specific configuration for the TID by default; if + * the %NL80211_TID_CONFIG_ATTR_OVERRIDE flag is set, peer-specific values   * will be overwritten.   * - * All this configuration is valid only for STA's current connection - * i.e. the configuration will be reset to default when the STA connects back + * All this configuration is valid only for STA's current connection, + * i.e., the configuration will be reset to default when the STA connects back   * after disconnection/roaming, and this configuration will be cleared when   * the interface goes down.   */  /** + * DOC: FILS shared key crypto offload + * + * This feature is applicable to drivers running in AP mode. + * + * FILS shared key crypto offload can be advertised by drivers by setting + * @NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD flag. The drivers that support + * FILS shared key crypto offload should be able to encrypt and decrypt + * association frames for FILS shared key authentication as per IEEE 802.11ai. + * With this capability, for FILS key derivation, drivers depend on userspace. + * + * After FILS key derivation, userspace shares the FILS AAD details with the + * driver and the driver stores the same to use in decryption of association + * request and in encryption of association response. The below parameters + * should be given to the driver in %NL80211_CMD_SET_FILS_AAD. + *	%NL80211_ATTR_MAC - STA MAC address, used for storing FILS AAD per STA + *	%NL80211_ATTR_FILS_KEK - Used for encryption or decryption + *	%NL80211_ATTR_FILS_NONCES - Used for encryption or decryption + *			(STA Nonce 16 bytes followed by AP Nonce 16 bytes) + * + * Once the association is done, the driver cleans the FILS AAD data. + */ + +/** + * DOC: Multi-Link Operation + * + * In Multi-Link Operation, a connection between two MLDs utilizes multiple + * links. To use this in nl80211, various commands and responses now need + * to or will include the new %NL80211_ATTR_MLO_LINKS attribute. + * Additionally, various commands that need to operate on a specific link + * now need to be given the %NL80211_ATTR_MLO_LINK_ID attribute, e.g. to + * use %NL80211_CMD_START_AP or similar functions. + */ + +/** + * DOC: OWE DH IE handling offload + * + * By setting @NL80211_EXT_FEATURE_OWE_OFFLOAD flag, drivers can indicate + * kernel/application space to avoid DH IE handling. When this flag is + * advertised, the driver/device will take care of DH IE inclusion and + * processing of peer DH IE to generate PMK. + */ + +/**   * enum nl80211_commands - supported nl80211 commands   *   * @NL80211_CMD_UNSPEC: unspecified command to catch errors @@ -333,17 +380,28 @@   * @NL80211_CMD_DEL_INTERFACE: Virtual interface was deleted, has attributes   *	%NL80211_ATTR_IFINDEX and %NL80211_ATTR_WIPHY. Can also be sent from   *	userspace to request deletion of a virtual interface, then requires - *	attribute %NL80211_ATTR_IFINDEX. + *	attribute %NL80211_ATTR_IFINDEX. If multiple BSSID advertisements are + *	enabled using %NL80211_ATTR_MBSSID_CONFIG, %NL80211_ATTR_MBSSID_ELEMS, + *	and if this command is used for the transmitting interface, then all + *	the non-transmitting interfaces are deleted as well.   *   * @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified - *	by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC. + *	by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC. %NL80211_ATTR_MAC + *	represents peer's MLD address for MLO pairwise key. For MLO group key, + *	the link is identified by %NL80211_ATTR_MLO_LINK_ID.   * @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT,   *	%NL80211_ATTR_KEY_DEFAULT_MGMT, or %NL80211_ATTR_KEY_THRESHOLD. + *	For MLO connection, the link to set default key is identified by + *	%NL80211_ATTR_MLO_LINK_ID.   * @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,   *	%NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER, - *	and %NL80211_ATTR_KEY_SEQ attributes. + *	and %NL80211_ATTR_KEY_SEQ attributes. %NL80211_ATTR_MAC represents + *	peer's MLD address for MLO pairwise key. The link to add MLO + *	group key is identified by %NL80211_ATTR_MLO_LINK_ID.   * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX - *	or %NL80211_ATTR_MAC. + *	or %NL80211_ATTR_MAC. %NL80211_ATTR_MAC represents peer's MLD address + *	for MLO pairwise key. The link to delete group key is identified by + *	%NL80211_ATTR_MLO_LINK_ID.   *   * @NL80211_CMD_GET_BEACON: (not used)   * @NL80211_CMD_SET_BEACON: change the beacon on an access point interface @@ -355,8 +413,8 @@   *	are like for %NL80211_CMD_SET_BEACON, and additionally parameters that   *	do not change are used, these include %NL80211_ATTR_BEACON_INTERVAL,   *	%NL80211_ATTR_DTIM_PERIOD, %NL80211_ATTR_SSID, - *	%NL80211_ATTR_HIDDEN_SSID, %NL80211_ATTR_CIPHERS_PAIRWISE, - *	%NL80211_ATTR_CIPHER_GROUP, %NL80211_ATTR_WPA_VERSIONS, + *	%NL80211_ATTR_HIDDEN_SSID, %NL80211_ATTR_CIPHER_SUITES_PAIRWISE, + *	%NL80211_ATTR_CIPHER_SUITE_GROUP, %NL80211_ATTR_WPA_VERSIONS,   *	%NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY,   *	%NL80211_ATTR_AUTH_TYPE, %NL80211_ATTR_INACTIVITY_TIMEOUT,   *	%NL80211_ATTR_ACL_POLICY and %NL80211_ATTR_MAC_ADDRS. @@ -375,27 +433,24 @@   *	interface identified by %NL80211_ATTR_IFINDEX.   * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC   *	or, if no MAC address given, all stations, on the interface identified - *	by %NL80211_ATTR_IFINDEX. %NL80211_ATTR_MGMT_SUBTYPE and + *	by %NL80211_ATTR_IFINDEX. For MLD station, MLD address is used in + *	%NL80211_ATTR_MAC. %NL80211_ATTR_MGMT_SUBTYPE and   *	%NL80211_ATTR_REASON_CODE can optionally be used to specify which type   *	of disconnection indication should be sent to the station   *	(Deauthentication or Disassociation frame and reason code for that - *	frame). + *	frame). %NL80211_ATTR_MLO_LINK_ID can be used optionally to remove + *	stations connected and using at least that link as one of its links.   *   * @NL80211_CMD_GET_MPATH: Get mesh path attributes for mesh path to - * 	destination %NL80211_ATTR_MAC on the interface identified by - * 	%NL80211_ATTR_IFINDEX. + *	destination %NL80211_ATTR_MAC on the interface identified by + *	%NL80211_ATTR_IFINDEX.   * @NL80211_CMD_SET_MPATH:  Set mesh path attributes for mesh path to - * 	destination %NL80211_ATTR_MAC on the interface identified by - * 	%NL80211_ATTR_IFINDEX. + *	destination %NL80211_ATTR_MAC on the interface identified by + *	%NL80211_ATTR_IFINDEX.   * @NL80211_CMD_NEW_MPATH: Create a new mesh path for the destination given by   *	%NL80211_ATTR_MAC via %NL80211_ATTR_MPATH_NEXT_HOP.   * @NL80211_CMD_DEL_MPATH: Delete a mesh path to the destination given by   *	%NL80211_ATTR_MAC. - * @NL80211_CMD_NEW_PATH: Add a mesh path with given attributes to the - *	interface identified by %NL80211_ATTR_IFINDEX. - * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC - *	or, if no MAC address given, all mesh paths, on the interface identified - *	by %NL80211_ATTR_IFINDEX.   * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by   *	%NL80211_ATTR_IFINDEX.   * @@ -416,15 +471,15 @@   *	after being queried by the kernel. CRDA replies by sending a regulatory   *	domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our   *	current alpha2 if it found a match. It also provides - * 	NL80211_ATTR_REG_RULE_FLAGS, and a set of regulatory rules. Each - * 	regulatory rule is a nested set of attributes  given by - * 	%NL80211_ATTR_REG_RULE_FREQ_[START|END] and - * 	%NL80211_ATTR_FREQ_RANGE_MAX_BW with an attached power rule given by - * 	%NL80211_ATTR_REG_RULE_POWER_MAX_ANT_GAIN and - * 	%NL80211_ATTR_REG_RULE_POWER_MAX_EIRP. + *	NL80211_ATTR_REG_RULE_FLAGS, and a set of regulatory rules. Each + *	regulatory rule is a nested set of attributes  given by + *	%NL80211_ATTR_REG_RULE_FREQ_[START|END] and + *	%NL80211_ATTR_FREQ_RANGE_MAX_BW with an attached power rule given by + *	%NL80211_ATTR_REG_RULE_POWER_MAX_ANT_GAIN and + *	%NL80211_ATTR_REG_RULE_POWER_MAX_EIRP.   * @NL80211_CMD_REQ_SET_REG: ask the wireless core to set the regulatory domain - * 	to the specified ISO/IEC 3166-1 alpha2 country code. The core will - * 	store this as a valid request and then query userspace for it. + *	to the specified ISO/IEC 3166-1 alpha2 country code. The core will + *	store this as a valid request and then query userspace for it.   *   * @NL80211_CMD_GET_MESH_CONFIG: Get mesh networking properties for the   *	interface identified by %NL80211_ATTR_IFINDEX @@ -462,7 +517,7 @@   *	%NL80211_ATTR_SCHED_SCAN_PLANS. If %NL80211_ATTR_SCHED_SCAN_PLANS is   *	not specified and only %NL80211_ATTR_SCHED_SCAN_INTERVAL is specified,   *	scheduled scan will run in an infinite loop with the specified interval. - *	These attributes are mutually exculsive, + *	These attributes are mutually exclusive,   *	i.e. NL80211_ATTR_SCHED_SCAN_INTERVAL must not be passed if   *	NL80211_ATTR_SCHED_SCAN_PLANS is defined.   *	If for some reason scheduled scan is aborted by the driver, all scan @@ -493,7 +548,7 @@   *	%NL80211_CMD_STOP_SCHED_SCAN command is received or when the interface   *	is brought down while a scheduled scan was running.   * - * @NL80211_CMD_GET_SURVEY: get survey resuls, e.g. channel occupation + * @NL80211_CMD_GET_SURVEY: get survey results, e.g. channel occupation   *      or noise level   * @NL80211_CMD_NEW_SURVEY_RESULTS: survey data notification (as a reply to   *	NL80211_CMD_GET_SURVEY and on the "scan" multicast group) @@ -504,40 +559,41 @@   *	using %NL80211_ATTR_SSID, %NL80211_ATTR_FILS_CACHE_ID,   *	%NL80211_ATTR_PMKID, and %NL80211_ATTR_PMK in case of FILS   *	authentication where %NL80211_ATTR_FILS_CACHE_ID is the identifier - *	advertized by a FILS capable AP identifying the scope of PMKSA in an + *	advertised by a FILS capable AP identifying the scope of PMKSA in an   *	ESS.   * @NL80211_CMD_DEL_PMKSA: Delete a PMKSA cache entry, using %NL80211_ATTR_MAC   *	(for the BSSID) and %NL80211_ATTR_PMKID or using %NL80211_ATTR_SSID,   *	%NL80211_ATTR_FILS_CACHE_ID, and %NL80211_ATTR_PMKID in case of FILS - *	authentication. + *	authentication. Additionally in case of SAE offload and OWE offloads + *	PMKSA entry can be deleted using %NL80211_ATTR_SSID.   * @NL80211_CMD_FLUSH_PMKSA: Flush all PMKSA cache entries.   *   * @NL80211_CMD_REG_CHANGE: indicates to userspace the regulatory domain - * 	has been changed and provides details of the request information - * 	that caused the change such as who initiated the regulatory request - * 	(%NL80211_ATTR_REG_INITIATOR), the wiphy_idx - * 	(%NL80211_ATTR_REG_ALPHA2) on which the request was made from if - * 	the initiator was %NL80211_REGDOM_SET_BY_COUNTRY_IE or - * 	%NL80211_REGDOM_SET_BY_DRIVER, the type of regulatory domain - * 	set (%NL80211_ATTR_REG_TYPE), if the type of regulatory domain is - * 	%NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on - * 	to (%NL80211_ATTR_REG_ALPHA2). + *	has been changed and provides details of the request information + *	that caused the change such as who initiated the regulatory request + *	(%NL80211_ATTR_REG_INITIATOR), the wiphy_idx + *	(%NL80211_ATTR_REG_ALPHA2) on which the request was made from if + *	the initiator was %NL80211_REGDOM_SET_BY_COUNTRY_IE or + *	%NL80211_REGDOM_SET_BY_DRIVER, the type of regulatory domain + *	set (%NL80211_ATTR_REG_TYPE), if the type of regulatory domain is + *	%NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on + *	to (%NL80211_ATTR_REG_ALPHA2).   * @NL80211_CMD_REG_BEACON_HINT: indicates to userspace that an AP beacon - * 	has been found while world roaming thus enabling active scan or - * 	any mode of operation that initiates TX (beacons) on a channel - * 	where we would not have been able to do either before. As an example - * 	if you are world roaming (regulatory domain set to world or if your - * 	driver is using a custom world roaming regulatory domain) and while - * 	doing a passive scan on the 5 GHz band you find an AP there (if not - * 	on a DFS channel) you will now be able to actively scan for that AP - * 	or use AP mode on your card on that same channel. Note that this will - * 	never be used for channels 1-11 on the 2 GHz band as they are always - * 	enabled world wide. This beacon hint is only sent if your device had - * 	either disabled active scanning or beaconing on a channel. We send to - * 	userspace the wiphy on which we removed a restriction from - * 	(%NL80211_ATTR_WIPHY) and the channel on which this occurred - * 	before (%NL80211_ATTR_FREQ_BEFORE) and after (%NL80211_ATTR_FREQ_AFTER) - * 	the beacon hint was processed. + *	has been found while world roaming thus enabling active scan or + *	any mode of operation that initiates TX (beacons) on a channel + *	where we would not have been able to do either before. As an example + *	if you are world roaming (regulatory domain set to world or if your + *	driver is using a custom world roaming regulatory domain) and while + *	doing a passive scan on the 5 GHz band you find an AP there (if not + *	on a DFS channel) you will now be able to actively scan for that AP + *	or use AP mode on your card on that same channel. Note that this will + *	never be used for channels 1-11 on the 2 GHz band as they are always + *	enabled world wide. This beacon hint is only sent if your device had + *	either disabled active scanning or beaconing on a channel. We send to + *	userspace the wiphy on which we removed a restriction from + *	(%NL80211_ATTR_WIPHY) and the channel on which this occurred + *	before (%NL80211_ATTR_FREQ_BEFORE) and after (%NL80211_ATTR_FREQ_AFTER) + *	the beacon hint was processed.   *   * @NL80211_CMD_AUTHENTICATE: authentication request and notification.   *	This command is used both as a command (request to authenticate) and @@ -548,7 +604,7 @@   *	BSSID in case of station mode). %NL80211_ATTR_SSID is used to specify   *	the SSID (mainly for association, but is included in authentication   *	request, too, to help BSS selection. %NL80211_ATTR_WIPHY_FREQ + - *	%NL80211_ATTR_WIPHY_FREQ_OFFSET is used to specify the frequence of the + *	%NL80211_ATTR_WIPHY_FREQ_OFFSET is used to specify the frequency of the   *	channel in MHz. %NL80211_ATTR_AUTH_TYPE is used to specify the   *	authentication type. %NL80211_ATTR_IE is used to define IEs   *	(VendorSpecificInfo, but also including RSN IE and FT IEs) to be added @@ -647,14 +703,13 @@   *	authentication/association or not receiving a response from the AP.   *	Non-zero %NL80211_ATTR_STATUS_CODE value is indicated in that case as   *	well to remain backwards compatible. - *	When establishing a security association, drivers that support 4 way - *	handshake offload should send %NL80211_CMD_PORT_AUTHORIZED event when - *	the 4 way handshake is completed successfully.   * @NL80211_CMD_ROAM: Notification indicating the card/driver roamed by itself. - *	When a security association was established with the new AP (e.g. if - *	the FT protocol was used for roaming or the driver completed the 4 way - *	handshake), this event should be followed by an + *	When a security association was established on an 802.1X network using + *	fast transition, this event should be followed by an   *	%NL80211_CMD_PORT_AUTHORIZED event. + *	Following a %NL80211_CMD_ROAM event userspace can issue + *	%NL80211_CMD_GET_SCAN in order to obtain the scan information for the + *	new BSS the card/driver roamed to.   * @NL80211_CMD_DISCONNECT: drop a given connection; also used to notify   *	userspace that a connection was dropped by the AP or due to other   *	reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and @@ -724,6 +779,13 @@   *	%NL80211_ATTR_CSA_C_OFFSETS_TX is an array of offsets to CSA   *	counters which will be updated to the current value. This attribute   *	is used during CSA period. + *	For TX on an MLD, the frequency can be omitted and the link ID be + *	specified, or if transmitting to a known peer MLD (with MLD addresses + *	in the frame) both can be omitted and the link will be selected by + *	lower layers. + *	For RX notification, %NL80211_ATTR_RX_HW_TIMESTAMP may be included to + *	indicate the frame RX timestamp and %NL80211_ATTR_TX_HW_TIMESTAMP may + *	be included to indicate the ack TX timestamp.   * @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this   *	command may be used with the corresponding cookie to cancel the wait   *	time if it is known that it is no longer necessary.  This command is @@ -734,7 +796,9 @@   *	transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies   *	the TX command and %NL80211_ATTR_FRAME includes the contents of the   *	frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged - *	the frame. + *	the frame. %NL80211_ATTR_TX_HW_TIMESTAMP may be included to indicate the + *	tx timestamp and %NL80211_ATTR_RX_HW_TIMESTAMP may be included to + *	indicate the ack RX timestamp.   * @NL80211_CMD_ACTION_TX_STATUS: Alias for @NL80211_CMD_FRAME_TX_STATUS for   *	backward compatibility.   * @@ -749,7 +813,7 @@   *	reached.   * @NL80211_CMD_SET_CHANNEL: Set the channel (using %NL80211_ATTR_WIPHY_FREQ   *	and the attributes determining channel width) the given interface - *	(identifed by %NL80211_ATTR_IFINDEX) shall operate on. + *	(identified by %NL80211_ATTR_IFINDEX) shall operate on.   *	In case multiple channels are supported by the device, the mechanism   *	with which it switches channels is implementation-defined.   *	When a monitor interface is given, it can only switch channel while @@ -757,7 +821,8 @@   *	of any other interfaces, and other interfaces will again take   *	precedence when they are used.   * - * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface. + * @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface + *	(no longer supported).   *   * @NL80211_CMD_SET_MULTICAST_TO_UNICAST: Configure if this AP should perform   *	multicast to unicast conversion. When enabled, all multicast packets @@ -820,7 +885,7 @@   *	inform userspace of the new replay counter.   *   * @NL80211_CMD_PMKSA_CANDIDATE: This is used as an event to inform userspace - *	of PMKSA caching dandidates. + *	of PMKSA caching candidates.   *   * @NL80211_CMD_TDLS_OPER: Perform a high-level TDLS command (e.g. link setup).   *	In addition, this can be used as an event to request userspace to take @@ -856,7 +921,7 @@   *   * @NL80211_CMD_PROBE_CLIENT: Probe an associated station on an AP interface   *	by sending a null data frame to it and reporting when the frame is - *	acknowleged. This is used to allow timing out inactive clients. Uses + *	acknowledged. This is used to allow timing out inactive clients. Uses   *	%NL80211_ATTR_IFINDEX and %NL80211_ATTR_MAC. The command returns a   *	direct reply with an %NL80211_ATTR_COOKIE that is later used to match   *	up the event with the request. The event includes the same data and @@ -1050,7 +1115,7 @@   *	current configuration is not changed.  If it is present but   *	set to zero, the configuration is changed to don't-care   *	(i.e. the device can decide what to do). - * @NL80211_CMD_NAN_FUNC_MATCH: Notification sent when a match is reported. + * @NL80211_CMD_NAN_MATCH: Notification sent when a match is reported.   *	This will contain a %NL80211_ATTR_NAN_MATCH nested attribute and   *	%NL80211_ATTR_COOKIE.   * @@ -1067,19 +1132,27 @@   * @NL80211_CMD_DEL_PMK: For offloaded 4-Way handshake, delete the previously   *	configured PMK for the authenticator address identified by   *	%NL80211_ATTR_MAC. - * @NL80211_CMD_PORT_AUTHORIZED: An event that indicates that the 4 way - *	handshake was completed successfully by the driver. The BSSID is - *	specified with %NL80211_ATTR_MAC. Drivers that support 4 way handshake - *	offload should send this event after indicating 802.11 association with - *	%NL80211_CMD_CONNECT or %NL80211_CMD_ROAM. If the 4 way handshake failed - *	%NL80211_CMD_DISCONNECT should be indicated instead. - * + * @NL80211_CMD_PORT_AUTHORIZED: An event that indicates port is authorized and + *	open for regular data traffic. For STA/P2P-client, this event is sent + *	with AP MAC address and for AP/P2P-GO, the event carries the STA/P2P- + *	client MAC address. + *	Drivers that support 4 way handshake offload should send this event for + *	STA/P2P-client after successful 4-way HS or after 802.1X FT following + *	NL80211_CMD_CONNECT or NL80211_CMD_ROAM. Drivers using AP/P2P-GO 4-way + *	handshake offload should send this event on successful completion of + *	4-way handshake with the peer (STA/P2P-client).   * @NL80211_CMD_CONTROL_PORT_FRAME: Control Port (e.g. PAE) frame TX request   *	and RX notification.  This command is used both as a request to transmit   *	a control port frame and as a notification that a control port frame   *	has been received. %NL80211_ATTR_FRAME is used to specify the   *	frame contents.  The frame is the raw EAPoL data, without ethernet or   *	802.11 headers. + *	For an MLD transmitter, the %NL80211_ATTR_MLO_LINK_ID may be given and + *	its effect will depend on the destination: If the destination is known + *	to be an MLD, this will be used as a hint to select the link to transmit + *	the frame on. If the destination is not an MLD, this will select both + *	the link to transmit on and the source address will be set to the link + *	address of that link.   *	When used as an event indication %NL80211_ATTR_CONTROL_PORT_ETHERTYPE,   *	%NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT and %NL80211_ATTR_MAC are added   *	indicating the protocol type of the received frame; whether the frame @@ -1104,6 +1177,23 @@   *	%NL80211_ATTR_STATUS_CODE attribute in %NL80211_CMD_EXTERNAL_AUTH   *	command interface.   * + *	Host driver sends MLD address of the AP with %NL80211_ATTR_MLD_ADDR in + *	%NL80211_CMD_EXTERNAL_AUTH event to indicate user space to enable MLO + *	during the authentication offload in STA mode while connecting to MLD + *	APs. Host driver should check %NL80211_ATTR_MLO_SUPPORT flag capability + *	in %NL80211_CMD_CONNECT to know whether the user space supports enabling + *	MLO during the authentication offload or not. + *	User space should enable MLO during the authentication only when it + *	receives the AP MLD address in authentication offload request. User + *	space shouldn't enable MLO when the authentication offload request + *	doesn't indicate the AP MLD address even if the AP is MLO capable. + *	User space should use %NL80211_ATTR_MLD_ADDR as peer's MLD address and + *	interface address identified by %NL80211_ATTR_IFINDEX as self MLD + *	address. User space and host driver to use MLD addresses in RA, TA and + *	BSSID fields of the frames between them, and host driver translates the + *	MLD addresses to/from link addresses based on the link chosen for the + *	authentication. + *   *	Host driver reports this status on an authentication failure to the   *	user space through the connect result as the user space would have   *	initiated the connection through the connect request. @@ -1179,6 +1269,81 @@   *	includes the contents of the frame. %NL80211_ATTR_ACK flag is included   *	if the recipient acknowledged the frame.   * + * @NL80211_CMD_SET_SAR_SPECS: SAR power limitation configuration is + *	passed using %NL80211_ATTR_SAR_SPEC. %NL80211_ATTR_WIPHY is used to + *	specify the wiphy index to be applied to. + * + * @NL80211_CMD_OBSS_COLOR_COLLISION: This notification is sent out whenever + *	mac80211/drv detects a bss color collision. + * + * @NL80211_CMD_COLOR_CHANGE_REQUEST: This command is used to indicate that + *	userspace wants to change the BSS color. + * + * @NL80211_CMD_COLOR_CHANGE_STARTED: Notify userland, that a color change has + *	started + * + * @NL80211_CMD_COLOR_CHANGE_ABORTED: Notify userland, that the color change has + *	been aborted + * + * @NL80211_CMD_COLOR_CHANGE_COMPLETED: Notify userland that the color change + *	has completed + * + * @NL80211_CMD_SET_FILS_AAD: Set FILS AAD data to the driver using - + *	&NL80211_ATTR_MAC - for STA MAC address + *	&NL80211_ATTR_FILS_KEK - for KEK + *	&NL80211_ATTR_FILS_NONCES - for FILS Nonces + *		(STA Nonce 16 bytes followed by AP Nonce 16 bytes) + * + * @NL80211_CMD_ASSOC_COMEBACK: notification about an association + *      temporal rejection with comeback. The event includes %NL80211_ATTR_MAC + *      to describe the BSSID address of the AP and %NL80211_ATTR_TIMEOUT to + *      specify the timeout value. + * + * @NL80211_CMD_ADD_LINK: Add a new link to an interface. The + *	%NL80211_ATTR_MLO_LINK_ID attribute is used for the new link. + * @NL80211_CMD_REMOVE_LINK: Remove a link from an interface. This may come + *	without %NL80211_ATTR_MLO_LINK_ID as an easy way to remove all links + *	in preparation for e.g. roaming to a regular (non-MLO) AP. + * + * @NL80211_CMD_ADD_LINK_STA: Add a link to an MLD station + * @NL80211_CMD_MODIFY_LINK_STA: Modify a link of an MLD station + * @NL80211_CMD_REMOVE_LINK_STA: Remove a link of an MLD station + * + * @NL80211_CMD_SET_HW_TIMESTAMP: Enable/disable HW timestamping of Timing + *	measurement and Fine timing measurement frames. If %NL80211_ATTR_MAC + *	is included, enable/disable HW timestamping only for frames to/from the + *	specified MAC address. Otherwise enable/disable HW timestamping for + *	all TM/FTM frames (including ones that were enabled with specific MAC + *	address). If %NL80211_ATTR_HW_TIMESTAMP_ENABLED is not included, disable + *	HW timestamping. + *	The number of peers that HW timestamping can be enabled for concurrently + *	is indicated by %NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS. + * + * @NL80211_CMD_LINKS_REMOVED: Notify userspace about the removal of STA MLD + *	setup links due to AP MLD removing the corresponding affiliated APs with + *	Multi-Link reconfiguration. %NL80211_ATTR_MLO_LINKS is used to provide + *	information about the removed STA MLD setup links. + * + * @NL80211_CMD_SET_TID_TO_LINK_MAPPING: Set the TID to Link Mapping for a + *      non-AP MLD station. The %NL80211_ATTR_MLO_TTLM_DLINK and + *      %NL80211_ATTR_MLO_TTLM_ULINK attributes are used to specify the + *      TID to Link mapping for downlink/uplink traffic. + * + * @NL80211_CMD_ASSOC_MLO_RECONF: For a non-AP MLD station, request to + *      add/remove links to/from the association. To indicate link + *      reconfiguration request results from the driver, this command is also + *      used as an event to notify userspace about the added links information. + *      For notifying the removed links information, the existing + *      %NL80211_CMD_LINKS_REMOVED command is used. This command is also used to + *      notify userspace about newly added links for the current connection in + *      case of AP-initiated link recommendation requests, received via + *      a BTM (BSS Transition Management) request or a link reconfig notify + *      frame, where the driver handles the link recommendation offload. + * + * @NL80211_CMD_EPCS_CFG: EPCS configuration for a station. Used by userland to + *	control EPCS configuration. Used to notify userland on the current state + *	of EPCS. + *   * @NL80211_CMD_MAX: highest used command number   * @__NL80211_CMD_AFTER_LAST: internal use   */ @@ -1409,6 +1574,36 @@ enum nl80211_commands {  	NL80211_CMD_CONTROL_PORT_FRAME_TX_STATUS, +	NL80211_CMD_SET_SAR_SPECS, + +	NL80211_CMD_OBSS_COLOR_COLLISION, + +	NL80211_CMD_COLOR_CHANGE_REQUEST, + +	NL80211_CMD_COLOR_CHANGE_STARTED, +	NL80211_CMD_COLOR_CHANGE_ABORTED, +	NL80211_CMD_COLOR_CHANGE_COMPLETED, + +	NL80211_CMD_SET_FILS_AAD, + +	NL80211_CMD_ASSOC_COMEBACK, + +	NL80211_CMD_ADD_LINK, +	NL80211_CMD_REMOVE_LINK, + +	NL80211_CMD_ADD_LINK_STA, +	NL80211_CMD_MODIFY_LINK_STA, +	NL80211_CMD_REMOVE_LINK_STA, + +	NL80211_CMD_SET_HW_TIMESTAMP, + +	NL80211_CMD_LINKS_REMOVED, + +	NL80211_CMD_SET_TID_TO_LINK_MAPPING, + +	NL80211_CMD_ASSOC_MLO_RECONF, +	NL80211_CMD_EPCS_CFG, +  	/* add new commands above here */  	/* used to define NL80211_CMD_MAX below */ @@ -1533,21 +1728,21 @@ enum nl80211_commands {   *	(see &enum nl80211_plink_action).   * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.   * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path - * 	info given for %NL80211_CMD_GET_MPATH, nested attribute described at + *	info given for %NL80211_CMD_GET_MPATH, nested attribute described at   *	&enum nl80211_mpath_info.   *   * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of   *      &enum nl80211_mntr_flags.   *   * @NL80211_ATTR_REG_ALPHA2: an ISO-3166-alpha2 country code for which the - * 	current regulatory domain should be set to or is already set to. - * 	For example, 'CR', for Costa Rica. This attribute is used by the kernel - * 	to query the CRDA to retrieve one regulatory domain. This attribute can - * 	also be used by userspace to query the kernel for the currently set - * 	regulatory domain. We chose an alpha2 as that is also used by the - * 	IEEE-802.11 country information element to identify a country. - * 	Users can also simply ask the wireless core to set regulatory domain - * 	to a specific alpha2. + *	current regulatory domain should be set to or is already set to. + *	For example, 'CR', for Costa Rica. This attribute is used by the kernel + *	to query the CRDA to retrieve one regulatory domain. This attribute can + *	also be used by userspace to query the kernel for the currently set + *	regulatory domain. We chose an alpha2 as that is also used by the + *	IEEE-802.11 country information element to identify a country. + *	Users can also simply ask the wireless core to set regulatory domain + *	to a specific alpha2.   * @NL80211_ATTR_REG_RULES: a nested array of regulatory domain regulatory   *	rules.   * @@ -1590,9 +1785,9 @@ enum nl80211_commands {   * @NL80211_ATTR_BSS: scan result BSS   *   * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain - * 	currently in effect. This could be any of the %NL80211_REGDOM_SET_BY_* + *	currently in effect. This could be any of the %NL80211_REGDOM_SET_BY_*   * @NL80211_ATTR_REG_TYPE: indicates the type of the regulatory domain currently - * 	set. This can be one of the nl80211_reg_type (%NL80211_REGDOM_TYPE_*) + *	set. This can be one of the nl80211_reg_type (%NL80211_REGDOM_TYPE_*)   *   * @NL80211_ATTR_SUPPORTED_COMMANDS: wiphy attribute that specifies   *	an array of command numbers (i.e. a mapping index to command number) @@ -1611,15 +1806,15 @@ enum nl80211_commands {   *	a u32   *   * @NL80211_ATTR_FREQ_BEFORE: A channel which has suffered a regulatory change - * 	due to considerations from a beacon hint. This attribute reflects - * 	the state of the channel _before_ the beacon hint processing. This - * 	attributes consists of a nested attribute containing - * 	NL80211_FREQUENCY_ATTR_* + *	due to considerations from a beacon hint. This attribute reflects + *	the state of the channel _before_ the beacon hint processing. This + *	attributes consists of a nested attribute containing + *	NL80211_FREQUENCY_ATTR_*   * @NL80211_ATTR_FREQ_AFTER: A channel which has suffered a regulatory change - * 	due to considerations from a beacon hint. This attribute reflects - * 	the state of the channel _after_ the beacon hint processing. This - * 	attributes consists of a nested attribute containing - * 	NL80211_FREQUENCY_ATTR_* + *	due to considerations from a beacon hint. This attribute reflects + *	the state of the channel _after_ the beacon hint processing. This + *	attributes consists of a nested attribute containing + *	NL80211_FREQUENCY_ATTR_*   *   * @NL80211_ATTR_CIPHER_SUITES: a set of u32 values indicating the supported   *	cipher suites @@ -1666,7 +1861,7 @@ enum nl80211_commands {   *	using %CMD_CONTROL_PORT_FRAME.  If control port routing over NL80211 is   *	to be used then userspace must also use the %NL80211_ATTR_SOCKET_OWNER   *	flag. When used with %NL80211_ATTR_CONTROL_PORT_NO_PREAUTH, pre-auth - *	frames are not forwared over the control port. + *	frames are not forwarded over the control port.   *   * @NL80211_ATTR_TESTDATA: Testmode data blob, passed through to the driver.   *	We recommend using nested, driver-specific attributes within this. @@ -1680,12 +1875,6 @@ enum nl80211_commands {   *	that protected APs should be used. This is also used with NEW_BEACON to   *	indicate that the BSS is to use protection.   * - * @NL80211_ATTR_CIPHERS_PAIRWISE: Used with CONNECT, ASSOCIATE, and NEW_BEACON - *	to indicate which unicast key ciphers will be used with the connection - *	(an array of u32). - * @NL80211_ATTR_CIPHER_GROUP: Used with CONNECT, ASSOCIATE, and NEW_BEACON to - *	indicate which group key cipher will be used with the connection (a - *	u32).   * @NL80211_ATTR_WPA_VERSIONS: Used with CONNECT, ASSOCIATE, and NEW_BEACON to   *	indicate which WPA version(s) the AP we want to associate with is using   *	(a u32 with flags from &enum nl80211_wpa_versions). @@ -1716,6 +1905,7 @@ enum nl80211_commands {   *	with %NL80211_KEY_* sub-attributes   *   * @NL80211_ATTR_PID: Process ID of a network namespace. + * @NL80211_ATTR_NETNS_FD: File descriptor of a network namespace.   *   * @NL80211_ATTR_GENERATION: Used to indicate consistent snapshots for   *	dumps. This number increases whenever the object list being @@ -1752,8 +1942,9 @@ enum nl80211_commands {   *	specify just a single bitrate, which is to be used for the beacon.   *	The driver must also specify support for this with the extended   *	features NL80211_EXT_FEATURE_BEACON_RATE_LEGACY, - *	NL80211_EXT_FEATURE_BEACON_RATE_HT and - *	NL80211_EXT_FEATURE_BEACON_RATE_VHT. + *	NL80211_EXT_FEATURE_BEACON_RATE_HT, + *	NL80211_EXT_FEATURE_BEACON_RATE_VHT and + *	NL80211_EXT_FEATURE_BEACON_RATE_HE.   *   * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain   *	at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME. @@ -1769,6 +1960,7 @@ enum nl80211_commands {   *   * @NL80211_ATTR_ACK: Flag attribute indicating that the frame was   *	acknowledged by the recipient. + * @NL80211_ATTR_ACK_SIGNAL: Station's ack signal strength (s32)   *   * @NL80211_ATTR_PS_STATE: powersave state, using &enum nl80211_ps_state values.   * @@ -1802,10 +1994,10 @@ enum nl80211_commands {   *	bit. Depending on which antennas are selected in the bitmap, 802.11n   *	drivers can derive which chainmasks to use (if all antennas belonging to   *	a particular chain are disabled this chain should be disabled) and if - *	a chain has diversity antennas wether diversity should be used or not. + *	a chain has diversity antennas whether diversity should be used or not.   *	HT capabilities (STBC, TX Beamforming, Antenna selection) can be   *	derived from the available chains after applying the antenna mask. - *	Non-802.11n drivers can derive wether to use diversity or not. + *	Non-802.11n drivers can derive whether to use diversity or not.   *	Drivers may reject configurations or RX/TX mask combinations they cannot   *	support by returning -EINVAL.   * @@ -1878,6 +2070,10 @@ enum nl80211_commands {   * @NL80211_ATTR_INTERFACE_COMBINATIONS: Nested attribute listing the supported   *	interface combinations. In each nested item, it contains attributes   *	defined in &enum nl80211_if_combination_attrs. + *	If the wiphy uses multiple radios (@NL80211_ATTR_WIPHY_RADIOS is set), + *	this attribute contains the interface combinations of the first radio. + *	See @NL80211_ATTR_WIPHY_INTERFACE_COMBINATIONS for the global wiphy + *	combinations for the sum of all radios.   * @NL80211_ATTR_SOFTWARE_IFTYPES: Nested attribute (just like   *	%NL80211_ATTR_SUPPORTED_IFTYPES) containing the interface types that   *	are managed in software: interfaces of these types aren't subject to @@ -1957,8 +2153,18 @@ enum nl80211_commands {   * @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire   *	probe-response frame. The DA field in the 802.11 header is zero-ed out,   *	to be filled by the FW. - * @NL80211_ATTR_DISABLE_HT:  Force HT capable interfaces to disable - *      this feature.  Currently, only supported in mac80211 drivers. + * @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable + *      this feature during association. This is a flag attribute. + *	Currently only supported in mac80211 drivers. + * @NL80211_ATTR_DISABLE_VHT: Force VHT capable interfaces to disable + *      this feature during association. This is a flag attribute. + *	Currently only supported in mac80211 drivers. + * @NL80211_ATTR_DISABLE_HE: Force HE capable interfaces to disable + *      this feature during association. This is a flag attribute. + *	Currently only supported in mac80211 drivers. + * @NL80211_ATTR_DISABLE_EHT: Force EHT capable interfaces to disable + *      this feature during association. This is a flag attribute. + *	Currently only supported in mac80211 drivers.   * @NL80211_ATTR_HT_CAPABILITY_MASK: Specify which bits of the   *      ATTR_HT_CAPABILITY to which attention should be paid.   *      Currently, only mac80211 NICs support this feature. @@ -1968,6 +2174,12 @@ enum nl80211_commands {   *      All values are treated as suggestions and may be ignored   *      by the driver as required.  The actual values may be seen in   *      the station debugfs ht_caps file. + * @NL80211_ATTR_VHT_CAPABILITY_MASK: Specify which bits of the + *      ATTR_VHT_CAPABILITY to which attention should be paid. + *      Currently, only mac80211 NICs support this feature. + *      All values are treated as suggestions and may be ignored + *      by the driver as required.  The actual values may be seen in + *      the station debugfs vht_caps file.   *   * @NL80211_ATTR_DFS_REGION: region for regulatory rules which this country   *    abides to when initiating radiation on DFS channels. A country maps @@ -2079,13 +2291,14 @@ enum nl80211_commands {   *	until the channel switch event.   * @NL80211_ATTR_CH_SWITCH_BLOCK_TX: flag attribute specifying that transmission   *	must be blocked on the current channel (before the channel switch - *	operation). + *	operation). Also included in the channel switch started event if quiet + *	was requested by the AP.   * @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information   *	for the time while performing a channel switch. - * @NL80211_ATTR_CSA_C_OFF_BEACON: An array of offsets (u16) to the channel - *	switch counters in the beacons tail (%NL80211_ATTR_BEACON_TAIL). - * @NL80211_ATTR_CSA_C_OFF_PRESP: An array of offsets (u16) to the channel - *	switch counters in the probe response (%NL80211_ATTR_PROBE_RESP). + * @NL80211_ATTR_CNTDWN_OFFS_BEACON: An array of offsets (u16) to the channel + *	switch or color change counters in the beacons tail (%NL80211_ATTR_BEACON_TAIL). + * @NL80211_ATTR_CNTDWN_OFFS_PRESP: An array of offsets (u16) to the channel + *	switch or color change counters in the probe response (%NL80211_ATTR_PROBE_RESP).   *   * @NL80211_ATTR_RXMGMT_FLAGS: flags for nl80211_send_mgmt(), u32.   *	As specified in the &enum nl80211_rxmgmt_flags. @@ -2225,7 +2438,7 @@ enum nl80211_commands {   *	scheduled scan is started.  Or the delay before a WoWLAN   *	net-detect scan is started, counting from the moment the   *	system is suspended.  This value is a u32, in seconds. - + *   * @NL80211_ATTR_REG_INDOOR: flag attribute, if set indicates that the device   *      is operating in an indoor environment.   * @@ -2259,8 +2472,10 @@ enum nl80211_commands {   *   * @NL80211_ATTR_IFTYPE_EXT_CAPA: Nested attribute of the following attributes:   *	%NL80211_ATTR_IFTYPE, %NL80211_ATTR_EXT_CAPA, - *	%NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities per - *	interface type. + *	%NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities and + *	other interface-type specific capabilities per interface type. For MLO, + *	%NL80211_ATTR_EML_CAPABILITY and %NL80211_ATTR_MLD_CAPA_AND_OPS are + *	present.   *   * @NL80211_ATTR_MU_MIMO_GROUP_DATA: array of 24 bytes that defines a MU-MIMO   *	groupID for monitor mode. @@ -2365,7 +2580,7 @@ enum nl80211_commands {   *	from successful FILS authentication and is used with   *	%NL80211_CMD_CONNECT.   * - * @NL80211_ATTR_FILS_CACHE_ID: A 2-octet identifier advertized by a FILS AP + * @NL80211_ATTR_FILS_CACHE_ID: A 2-octet identifier advertised by a FILS AP   *	identifying the scope of PMKSAs. This is used with   *	@NL80211_CMD_SET_PMKSA and @NL80211_CMD_DEL_PMKSA.   * @@ -2396,7 +2611,9 @@ enum nl80211_commands {   *	space supports external authentication. This attribute shall be used   *	with %NL80211_CMD_CONNECT and %NL80211_CMD_START_AP request. The driver   *	may offload authentication processing to user space if this capability - *	is indicated in the respective requests from the user space. + *	is indicated in the respective requests from the user space. (This flag + *	attribute deprecated for %NL80211_CMD_START_AP, use + *	%NL80211_ATTR_AP_SETTINGS_FLAGS)   *   * @NL80211_ATTR_NSS: Station's New/updated  RX_NSS value notified using this   *	u8 attribute. This is used with %NL80211_CMD_STA_OPMODE_CHANGED. @@ -2515,6 +2732,202 @@ enum nl80211_commands {   * @NL80211_ATTR_HE_6GHZ_CAPABILITY: HE 6 GHz Band Capability element (from   *	association request when used with NL80211_CMD_NEW_STATION).   * + * @NL80211_ATTR_FILS_DISCOVERY: Optional parameter to configure FILS + *	discovery. It is a nested attribute, see + *	&enum nl80211_fils_discovery_attributes. Userspace should pass an empty + *	nested attribute to disable this feature and delete the templates. + * + * @NL80211_ATTR_UNSOL_BCAST_PROBE_RESP: Optional parameter to configure + *	unsolicited broadcast probe response. It is a nested attribute, see + *	&enum nl80211_unsol_bcast_probe_resp_attributes. Userspace should pass an empty + *	nested attribute to disable this feature and delete the templates. + * + * @NL80211_ATTR_S1G_CAPABILITY: S1G Capability information element (from + *	association request when used with NL80211_CMD_NEW_STATION) + * @NL80211_ATTR_S1G_CAPABILITY_MASK: S1G Capability Information element + *	override mask. Used with NL80211_ATTR_S1G_CAPABILITY in + *	NL80211_CMD_ASSOCIATE or NL80211_CMD_CONNECT. + * + * @NL80211_ATTR_SAE_PWE: Indicates the mechanism(s) allowed for SAE PWE + *	derivation in WPA3-Personal networks which are using SAE authentication. + *	This is a u8 attribute that encapsulates one of the values from + *	&enum nl80211_sae_pwe_mechanism. + * + * @NL80211_ATTR_SAR_SPEC: SAR power limitation specification when + *	used with %NL80211_CMD_SET_SAR_SPECS. The message contains fields + *	of %nl80211_sar_attrs which specifies the sar type and related + *	sar specs. Sar specs contains array of %nl80211_sar_specs_attrs. + * + * @NL80211_ATTR_RECONNECT_REQUESTED: flag attribute, used with deauth and + *	disassoc events to indicate that an immediate reconnect to the AP + *	is desired. + * + * @NL80211_ATTR_OBSS_COLOR_BITMAP: bitmap of the u64 BSS colors for the + *	%NL80211_CMD_OBSS_COLOR_COLLISION event. + * + * @NL80211_ATTR_COLOR_CHANGE_COUNT: u8 attribute specifying the number of TBTT's + *	until the color switch event. + * @NL80211_ATTR_COLOR_CHANGE_COLOR: u8 attribute specifying the color that we are + *	switching to + * @NL80211_ATTR_COLOR_CHANGE_ELEMS: Nested set of attributes containing the IE + *	information for the time while performing a color switch. + * + * @NL80211_ATTR_MBSSID_CONFIG: Nested attribute for multiple BSSID + *	advertisements (MBSSID) parameters in AP mode. + *	Kernel uses this attribute to indicate the driver's support for MBSSID + *	and enhanced multi-BSSID advertisements (EMA AP) to the userspace. + *	Userspace should use this attribute to configure per interface MBSSID + *	parameters. + *	See &enum nl80211_mbssid_config_attributes for details. + * + * @NL80211_ATTR_MBSSID_ELEMS: Nested parameter to pass multiple BSSID elements. + *	Mandatory parameter for the transmitting interface to enable MBSSID. + *	Optional for the non-transmitting interfaces. + * + * @NL80211_ATTR_RADAR_BACKGROUND: Configure dedicated offchannel chain + *	available for radar/CAC detection on some hw. This chain can't be used + *	to transmit or receive frames and it is bounded to a running wdev. + *	Background radar/CAC detection allows to avoid the CAC downtime + *	switching on a different channel during CAC detection on the selected + *	radar channel. + * + * @NL80211_ATTR_AP_SETTINGS_FLAGS: u32 attribute contains ap settings flags, + *	enumerated in &enum nl80211_ap_settings_flags. This attribute shall be + *	used with %NL80211_CMD_START_AP request. + * + * @NL80211_ATTR_EHT_CAPABILITY: EHT Capability information element (from + *	association request when used with NL80211_CMD_NEW_STATION). Can be set + *	only if %NL80211_STA_FLAG_WME is set. + * + * @NL80211_ATTR_MLO_LINK_ID: A (u8) link ID for use with MLO, to be used with + *	various commands that need a link ID to operate. + * @NL80211_ATTR_MLO_LINKS: A nested array of links, each containing some + *	per-link information and a link ID. + * @NL80211_ATTR_MLD_ADDR: An MLD address, used with various commands such as + *	authenticate/associate. + * + * @NL80211_ATTR_MLO_SUPPORT: Flag attribute to indicate user space supports MLO + *	connection. Used with %NL80211_CMD_CONNECT. If this attribute is not + *	included in NL80211_CMD_CONNECT drivers must not perform MLO connection. + * + * @NL80211_ATTR_MAX_NUM_AKM_SUITES: U16 attribute. Indicates maximum number of + *	AKM suites allowed for %NL80211_CMD_CONNECT, %NL80211_CMD_ASSOCIATE and + *	%NL80211_CMD_START_AP in %NL80211_CMD_GET_WIPHY response. If this + *	attribute is not present userspace shall consider maximum number of AKM + *	suites allowed as %NL80211_MAX_NR_AKM_SUITES which is the legacy maximum + *	number prior to the introduction of this attribute. + * + * @NL80211_ATTR_EML_CAPABILITY: EML Capability information (u16) + * @NL80211_ATTR_MLD_CAPA_AND_OPS: MLD Capabilities and Operations (u16) + * + * @NL80211_ATTR_TX_HW_TIMESTAMP: Hardware timestamp for TX operation in + *	nanoseconds (u64). This is the device clock timestamp so it will + *	probably reset when the device is stopped or the firmware is reset. + *	When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the frame TX + *	timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates + *	the ack TX timestamp. + * @NL80211_ATTR_RX_HW_TIMESTAMP: Hardware timestamp for RX operation in + *	nanoseconds (u64). This is the device clock timestamp so it will + *	probably reset when the device is stopped or the firmware is reset. + *	When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the ack RX + *	timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates + *	the incoming frame RX timestamp. + * @NL80211_ATTR_TD_BITMAP: Transition Disable bitmap, for subsequent + *	(re)associations. + * + * @NL80211_ATTR_PUNCT_BITMAP: (u32) Preamble puncturing bitmap, lowest + *	bit corresponds to the lowest 20 MHz channel. Each bit set to 1 + *	indicates that the sub-channel is punctured. Higher 16 bits are + *	reserved. + * + * @NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS: Maximum number of peers that HW + *	timestamping can be enabled for concurrently (u16), a wiphy attribute. + *	A value of 0xffff indicates setting for all peers (i.e. not specifying + *	an address with %NL80211_CMD_SET_HW_TIMESTAMP) is supported. + * @NL80211_ATTR_HW_TIMESTAMP_ENABLED: Indicates whether HW timestamping should + *	be enabled or not (flag attribute). + * + * @NL80211_ATTR_EMA_RNR_ELEMS: Optional nested attribute for + *	reduced neighbor report (RNR) elements. This attribute can be used + *	only when NL80211_MBSSID_CONFIG_ATTR_EMA is enabled. + *	Userspace is responsible for splitting the RNR into multiple + *	elements such that each element excludes the non-transmitting + *	profiles already included in the MBSSID element + *	(%NL80211_ATTR_MBSSID_ELEMS) at the same index. Each EMA beacon + *	will be generated by adding MBSSID and RNR elements at the same + *	index. If the userspace includes more RNR elements than number of + *	MBSSID elements then these will be added in every EMA beacon. + * + * @NL80211_ATTR_MLO_LINK_DISABLED: Flag attribute indicating that the link is + *	disabled. + * + * @NL80211_ATTR_BSS_DUMP_INCLUDE_USE_DATA: Include BSS usage data, i.e. + *	include BSSes that can only be used in restricted scenarios and/or + *	cannot be used at all. + * + * @NL80211_ATTR_MLO_TTLM_DLINK: Binary attribute specifying the downlink TID to + *      link mapping. The length is 8 * sizeof(u16). For each TID the link + *      mapping is as defined in section 9.4.2.314 (TID-To-Link Mapping element) + *      in Draft P802.11be_D4.0. + * @NL80211_ATTR_MLO_TTLM_ULINK: Binary attribute specifying the uplink TID to + *      link mapping. The length is 8 * sizeof(u16). For each TID the link + *      mapping is as defined in section 9.4.2.314 (TID-To-Link Mapping element) + *      in Draft P802.11be_D4.0. + * + * @NL80211_ATTR_ASSOC_SPP_AMSDU: flag attribute used with + *	%NL80211_CMD_ASSOCIATE indicating the SPP A-MSDUs + *	are used on this connection + * + * @NL80211_ATTR_WIPHY_RADIOS: Nested attribute describing physical radios + *	belonging to this wiphy. See &enum nl80211_wiphy_radio_attrs. + * + * @NL80211_ATTR_WIPHY_INTERFACE_COMBINATIONS: Nested attribute listing the + *	supported interface combinations for all radios combined. In each + *	nested item, it contains attributes defined in + *	&enum nl80211_if_combination_attrs. + * + * @NL80211_ATTR_VIF_RADIO_MASK: Bitmask of allowed radios (u32). + *	A value of 0 means all radios. + * + * @NL80211_ATTR_SUPPORTED_SELECTORS: supported BSS Membership Selectors, array + *	of supported selectors as defined by IEEE Std 802.11-2020 9.4.2.3 but + *	without the length restriction (at most %NL80211_MAX_SUPP_SELECTORS). + *	This can be used to provide a list of selectors that are implemented + *	by the supplicant. If not given, support for SAE_H2E is assumed. + * + * @NL80211_ATTR_MLO_RECONF_REM_LINKS: (u16) A bitmask of the links requested + *      to be removed from the MLO association. + * + * @NL80211_ATTR_EPCS: Flag attribute indicating that EPCS is enabled for a + *	station interface. + * + * @NL80211_ATTR_ASSOC_MLD_EXT_CAPA_OPS: Extended MLD capabilities and + *	operations that userspace implements to use during association/ML + *	link reconfig, currently only "BTM MLD Recommendation For Multiple + *	APs Support". Drivers may set additional flags that they support + *	in the kernel or device. + * + * @NL80211_ATTR_WIPHY_RADIO_INDEX: (int) Integer attribute denoting the index + *	of the radio in interest. Internally a value of -1 is used to + *	indicate that the radio id is not given in user-space. This means + *	that all the attributes are applicable to all the radios. If there is + *	a radio index provided in user-space, the attributes will be + *	applicable to that specific radio only. If the radio id is greater + *	thank the number of radios, error denoting invalid value is returned. + * + * @NL80211_ATTR_S1G_LONG_BEACON_PERIOD: (u8) Integer attribute that represents + *	the number of beacon intervals between each long beacon transmission + *	for an S1G BSS with short beaconing enabled. This is a required + *	attribute for initialising an S1G short beaconing BSS. When updating + *	the short beacon data, this is not required. It has a minimum value of + *	2 (i.e 2 beacon intervals). + * + * @NL80211_ATTR_S1G_SHORT_BEACON: Nested attribute containing the short beacon + *	head and tail used to set or update the short beacon templates. When + *	bringing up a new interface, %NL80211_ATTR_S1G_LONG_BEACON_PERIOD is + *	required alongside this attribute. Refer to + *	@enum nl80211_s1g_short_beacon_attrs for the attribute definitions. + *   * @NUM_NL80211_ATTR: total number of nl80211_attrs available   * @NL80211_ATTR_MAX: highest attribute number currently defined   * @__NL80211_ATTR_AFTER_LAST: internal use @@ -2821,8 +3234,8 @@ enum nl80211_attrs {  	NL80211_ATTR_CH_SWITCH_COUNT,  	NL80211_ATTR_CH_SWITCH_BLOCK_TX,  	NL80211_ATTR_CSA_IES, -	NL80211_ATTR_CSA_C_OFF_BEACON, -	NL80211_ATTR_CSA_C_OFF_PRESP, +	NL80211_ATTR_CNTDWN_OFFS_BEACON, +	NL80211_ATTR_CNTDWN_OFFS_PRESP,  	NL80211_ATTR_RXMGMT_FLAGS, @@ -2997,6 +3410,86 @@ enum nl80211_attrs {  	NL80211_ATTR_HE_6GHZ_CAPABILITY, +	NL80211_ATTR_FILS_DISCOVERY, + +	NL80211_ATTR_UNSOL_BCAST_PROBE_RESP, + +	NL80211_ATTR_S1G_CAPABILITY, +	NL80211_ATTR_S1G_CAPABILITY_MASK, + +	NL80211_ATTR_SAE_PWE, + +	NL80211_ATTR_RECONNECT_REQUESTED, + +	NL80211_ATTR_SAR_SPEC, + +	NL80211_ATTR_DISABLE_HE, + +	NL80211_ATTR_OBSS_COLOR_BITMAP, + +	NL80211_ATTR_COLOR_CHANGE_COUNT, +	NL80211_ATTR_COLOR_CHANGE_COLOR, +	NL80211_ATTR_COLOR_CHANGE_ELEMS, + +	NL80211_ATTR_MBSSID_CONFIG, +	NL80211_ATTR_MBSSID_ELEMS, + +	NL80211_ATTR_RADAR_BACKGROUND, + +	NL80211_ATTR_AP_SETTINGS_FLAGS, + +	NL80211_ATTR_EHT_CAPABILITY, + +	NL80211_ATTR_DISABLE_EHT, + +	NL80211_ATTR_MLO_LINKS, +	NL80211_ATTR_MLO_LINK_ID, +	NL80211_ATTR_MLD_ADDR, + +	NL80211_ATTR_MLO_SUPPORT, + +	NL80211_ATTR_MAX_NUM_AKM_SUITES, + +	NL80211_ATTR_EML_CAPABILITY, +	NL80211_ATTR_MLD_CAPA_AND_OPS, + +	NL80211_ATTR_TX_HW_TIMESTAMP, +	NL80211_ATTR_RX_HW_TIMESTAMP, +	NL80211_ATTR_TD_BITMAP, + +	NL80211_ATTR_PUNCT_BITMAP, + +	NL80211_ATTR_MAX_HW_TIMESTAMP_PEERS, +	NL80211_ATTR_HW_TIMESTAMP_ENABLED, + +	NL80211_ATTR_EMA_RNR_ELEMS, + +	NL80211_ATTR_MLO_LINK_DISABLED, + +	NL80211_ATTR_BSS_DUMP_INCLUDE_USE_DATA, + +	NL80211_ATTR_MLO_TTLM_DLINK, +	NL80211_ATTR_MLO_TTLM_ULINK, + +	NL80211_ATTR_ASSOC_SPP_AMSDU, + +	NL80211_ATTR_WIPHY_RADIOS, +	NL80211_ATTR_WIPHY_INTERFACE_COMBINATIONS, + +	NL80211_ATTR_VIF_RADIO_MASK, + +	NL80211_ATTR_SUPPORTED_SELECTORS, + +	NL80211_ATTR_MLO_RECONF_REM_LINKS, +	NL80211_ATTR_EPCS, + +	NL80211_ATTR_ASSOC_MLD_EXT_CAPA_OPS, + +	NL80211_ATTR_WIPHY_RADIO_INDEX, + +	NL80211_ATTR_S1G_LONG_BEACON_PERIOD, +	NL80211_ATTR_S1G_SHORT_BEACON, +  	/* add attributes here, update the policy in nl80211.c */  	__NL80211_ATTR_AFTER_LAST, @@ -3009,6 +3502,8 @@ enum nl80211_attrs {  #define	NL80211_ATTR_MESH_PARAMS NL80211_ATTR_MESH_CONFIG  #define NL80211_ATTR_IFACE_SOCKET_OWNER NL80211_ATTR_SOCKET_OWNER  #define NL80211_ATTR_SAE_DATA NL80211_ATTR_AUTH_DATA +#define NL80211_ATTR_CSA_C_OFF_BEACON NL80211_ATTR_CNTDWN_OFFS_BEACON +#define NL80211_ATTR_CSA_C_OFF_PRESP NL80211_ATTR_CNTDWN_OFFS_PRESP  /*   * Allow user space programs to use #ifdef on new attributes by defining them @@ -3039,6 +3534,7 @@ enum nl80211_attrs {  #define NL80211_WIPHY_NAME_MAXLEN		64  #define NL80211_MAX_SUPP_RATES			32 +#define NL80211_MAX_SUPP_SELECTORS		128  #define NL80211_MAX_SUPP_HT_RATES		77  #define NL80211_MAX_SUPP_REG_RULES		128  #define NL80211_TKIP_DATA_OFFSET_ENCR_KEY	0 @@ -3049,7 +3545,14 @@ enum nl80211_attrs {  #define NL80211_HE_MIN_CAPABILITY_LEN           16  #define NL80211_HE_MAX_CAPABILITY_LEN           54  #define NL80211_MAX_NR_CIPHER_SUITES		5 + +/* + * NL80211_MAX_NR_AKM_SUITES is obsolete when %NL80211_ATTR_MAX_NUM_AKM_SUITES + * present in %NL80211_CMD_GET_WIPHY response. + */  #define NL80211_MAX_NR_AKM_SUITES		2 +#define NL80211_EHT_MIN_CAPABILITY_LEN          13 +#define NL80211_EHT_MAX_CAPABILITY_LEN          51  #define NL80211_MIN_REMAIN_ON_CHANNEL_TIME	10 @@ -3077,7 +3580,7 @@ enum nl80211_attrs {   *	and therefore can't be created in the normal ways, use the   *	%NL80211_CMD_START_P2P_DEVICE and %NL80211_CMD_STOP_P2P_DEVICE   *	commands to create and destroy one - * @NL80211_IF_TYPE_OCB: Outside Context of a BSS + * @NL80211_IFTYPE_OCB: Outside Context of a BSS   *	This mode corresponds to the MIB variable dot11OCBActivated=true   * @NL80211_IFTYPE_NAN: NAN device interface type (not a netdev)   * @NL80211_IFTYPE_MAX: highest interface type number currently defined @@ -3128,6 +3631,7 @@ enum nl80211_iftype {   * @NL80211_STA_FLAG_ASSOCIATED: station is associated; used with drivers   *	that support %NL80211_FEATURE_FULL_AP_CLIENT_STATE to transition a   *	previously added station into associated state + * @NL80211_STA_FLAG_SPP_AMSDU: station supports SPP A-MSDUs   * @NL80211_STA_FLAG_MAX: highest station flag number currently defined   * @__NL80211_STA_FLAG_AFTER_LAST: internal use   */ @@ -3140,6 +3644,7 @@ enum nl80211_sta_flags {  	NL80211_STA_FLAG_AUTHENTICATED,  	NL80211_STA_FLAG_TDLS_PEER,  	NL80211_STA_FLAG_ASSOCIATED, +	NL80211_STA_FLAG_SPP_AMSDU,  	/* keep last */  	__NL80211_STA_FLAG_AFTER_LAST, @@ -3150,7 +3655,7 @@ enum nl80211_sta_flags {   * enum nl80211_sta_p2p_ps_status - station support of P2P PS   *   * @NL80211_P2P_PS_UNSUPPORTED: station doesn't support P2P PS mechanism - * @@NL80211_P2P_PS_SUPPORTED: station supports P2P PS mechanism + * @NL80211_P2P_PS_SUPPORTED: station supports P2P PS mechanism   * @NUM_NL80211_P2P_PS_STATUS: number of values   */  enum nl80211_sta_p2p_ps_status { @@ -3187,6 +3692,18 @@ enum nl80211_he_gi {  };  /** + * enum nl80211_he_ltf - HE long training field + * @NL80211_RATE_INFO_HE_1XLTF: 3.2 usec + * @NL80211_RATE_INFO_HE_2XLTF: 6.4 usec + * @NL80211_RATE_INFO_HE_4XLTF: 12.8 usec + */ +enum nl80211_he_ltf { +	NL80211_RATE_INFO_HE_1XLTF, +	NL80211_RATE_INFO_HE_2XLTF, +	NL80211_RATE_INFO_HE_4XLTF, +}; + +/**   * enum nl80211_he_ru_alloc - HE RU allocation values   * @NL80211_RATE_INFO_HE_RU_ALLOC_26: 26-tone RU allocation   * @NL80211_RATE_INFO_HE_RU_ALLOC_52: 52-tone RU allocation @@ -3207,6 +3724,56 @@ enum nl80211_he_ru_alloc {  };  /** + * enum nl80211_eht_gi - EHT guard interval + * @NL80211_RATE_INFO_EHT_GI_0_8: 0.8 usec + * @NL80211_RATE_INFO_EHT_GI_1_6: 1.6 usec + * @NL80211_RATE_INFO_EHT_GI_3_2: 3.2 usec + */ +enum nl80211_eht_gi { +	NL80211_RATE_INFO_EHT_GI_0_8, +	NL80211_RATE_INFO_EHT_GI_1_6, +	NL80211_RATE_INFO_EHT_GI_3_2, +}; + +/** + * enum nl80211_eht_ru_alloc - EHT RU allocation values + * @NL80211_RATE_INFO_EHT_RU_ALLOC_26: 26-tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_52: 52-tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_52P26: 52+26-tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_106: 106-tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_106P26: 106+26 tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_242: 242-tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_484: 484-tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_484P242: 484+242 tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_996: 996-tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_996P484: 996+484 tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_996P484P242: 996+484+242 tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_2x996: 2x996-tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_2x996P484: 2x996+484 tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_3x996: 3x996-tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_3x996P484: 3x996+484 tone RU allocation + * @NL80211_RATE_INFO_EHT_RU_ALLOC_4x996: 4x996-tone RU allocation + */ +enum nl80211_eht_ru_alloc { +	NL80211_RATE_INFO_EHT_RU_ALLOC_26, +	NL80211_RATE_INFO_EHT_RU_ALLOC_52, +	NL80211_RATE_INFO_EHT_RU_ALLOC_52P26, +	NL80211_RATE_INFO_EHT_RU_ALLOC_106, +	NL80211_RATE_INFO_EHT_RU_ALLOC_106P26, +	NL80211_RATE_INFO_EHT_RU_ALLOC_242, +	NL80211_RATE_INFO_EHT_RU_ALLOC_484, +	NL80211_RATE_INFO_EHT_RU_ALLOC_484P242, +	NL80211_RATE_INFO_EHT_RU_ALLOC_996, +	NL80211_RATE_INFO_EHT_RU_ALLOC_996P484, +	NL80211_RATE_INFO_EHT_RU_ALLOC_996P484P242, +	NL80211_RATE_INFO_EHT_RU_ALLOC_2x996, +	NL80211_RATE_INFO_EHT_RU_ALLOC_2x996P484, +	NL80211_RATE_INFO_EHT_RU_ALLOC_3x996, +	NL80211_RATE_INFO_EHT_RU_ALLOC_3x996P484, +	NL80211_RATE_INFO_EHT_RU_ALLOC_4x996, +}; + +/**   * enum nl80211_rate_info - bitrate information   *   * These attribute types are used with %NL80211_STA_INFO_TXRATE @@ -3243,8 +3810,22 @@ enum nl80211_he_ru_alloc {   * @NL80211_RATE_INFO_HE_GI: HE guard interval identifier   *	(u8, see &enum nl80211_he_gi)   * @NL80211_RATE_INFO_HE_DCM: HE DCM value (u8, 0/1) - * @NL80211_RATE_INFO_RU_ALLOC: HE RU allocation, if not present then + * @NL80211_RATE_INFO_HE_RU_ALLOC: HE RU allocation, if not present then   *	non-OFDMA was used (u8, see &enum nl80211_he_ru_alloc) + * @NL80211_RATE_INFO_320_MHZ_WIDTH: 320 MHz bitrate + * @NL80211_RATE_INFO_EHT_MCS: EHT MCS index (u8, 0-15) + * @NL80211_RATE_INFO_EHT_NSS: EHT NSS value (u8, 1-8) + * @NL80211_RATE_INFO_EHT_GI: EHT guard interval identifier + *	(u8, see &enum nl80211_eht_gi) + * @NL80211_RATE_INFO_EHT_RU_ALLOC: EHT RU allocation, if not present then + *	non-OFDMA was used (u8, see &enum nl80211_eht_ru_alloc) + * @NL80211_RATE_INFO_S1G_MCS: S1G MCS index (u8, 0-10) + * @NL80211_RATE_INFO_S1G_NSS: S1G NSS value (u8, 1-4) + * @NL80211_RATE_INFO_1_MHZ_WIDTH: 1 MHz S1G rate + * @NL80211_RATE_INFO_2_MHZ_WIDTH: 2 MHz S1G rate + * @NL80211_RATE_INFO_4_MHZ_WIDTH: 4 MHz S1G rate + * @NL80211_RATE_INFO_8_MHZ_WIDTH: 8 MHz S1G rate + * @NL80211_RATE_INFO_16_MHZ_WIDTH: 16 MHz S1G rate   * @__NL80211_RATE_INFO_AFTER_LAST: internal use   */  enum nl80211_rate_info { @@ -3266,6 +3847,18 @@ enum nl80211_rate_info {  	NL80211_RATE_INFO_HE_GI,  	NL80211_RATE_INFO_HE_DCM,  	NL80211_RATE_INFO_HE_RU_ALLOC, +	NL80211_RATE_INFO_320_MHZ_WIDTH, +	NL80211_RATE_INFO_EHT_MCS, +	NL80211_RATE_INFO_EHT_NSS, +	NL80211_RATE_INFO_EHT_GI, +	NL80211_RATE_INFO_EHT_RU_ALLOC, +	NL80211_RATE_INFO_S1G_MCS, +	NL80211_RATE_INFO_S1G_NSS, +	NL80211_RATE_INFO_1_MHZ_WIDTH, +	NL80211_RATE_INFO_2_MHZ_WIDTH, +	NL80211_RATE_INFO_4_MHZ_WIDTH, +	NL80211_RATE_INFO_8_MHZ_WIDTH, +	NL80211_RATE_INFO_16_MHZ_WIDTH,  	/* keep last */  	__NL80211_RATE_INFO_AFTER_LAST, @@ -3320,7 +3913,7 @@ enum nl80211_sta_bss_param {   *	(u64, to this station)   * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm)   * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute - * 	containing info as possible, see &enum nl80211_rate_info + *	containing info as possible, see &enum nl80211_rate_info   * @NL80211_STA_INFO_RX_PACKETS: total received packet (MSDUs and MMPDUs)   *	(u32, from this station)   * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (MSDUs and MMPDUs) @@ -3349,8 +3942,8 @@ enum nl80211_sta_bss_param {   *	Contains a nested array of signal strength attributes (u8, dBm)   * @NL80211_STA_INFO_CHAIN_SIGNAL_AVG: per-chain signal strength average   *	Same format as NL80211_STA_INFO_CHAIN_SIGNAL. - * @NL80211_STA_EXPECTED_THROUGHPUT: expected throughput considering also the - *	802.11 header (u32, kbps) + * @NL80211_STA_INFO_EXPECTED_THROUGHPUT: expected throughput considering also + *	the 802.11 header (u32, kbps)   * @NL80211_STA_INFO_RX_DROP_MISC: RX packets dropped for unspecified reasons   *	(u64)   * @NL80211_STA_INFO_BEACON_RX: number of beacons received from this peer (u64) @@ -3536,7 +4129,7 @@ enum nl80211_mpath_flags {   * @NL80211_MPATH_INFO_METRIC: metric (cost) of this mesh path   * @NL80211_MPATH_INFO_EXPTIME: expiration time for the path, in msec from now   * @NL80211_MPATH_INFO_FLAGS: mesh path flags, enumerated in - * 	&enum nl80211_mpath_flags; + *	&enum nl80211_mpath_flags;   * @NL80211_MPATH_INFO_DISCOVERY_TIMEOUT: total path discovery timeout, in msec   * @NL80211_MPATH_INFO_DISCOVERY_RETRIES: mesh path discovery retries   * @NL80211_MPATH_INFO_HOP_COUNT: hop count to destination @@ -3576,11 +4169,20 @@ enum nl80211_mpath_info {   *     capabilities IE   * @NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE: HE PPE thresholds information as   *     defined in HE capabilities IE - * @NL80211_BAND_IFTYPE_ATTR_MAX: highest band HE capability attribute currently - *     defined   * @NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA: HE 6GHz band capabilities (__le16),   *	given for all 6 GHz band channels + * @NL80211_BAND_IFTYPE_ATTR_VENDOR_ELEMS: vendor element capabilities that are + *	advertised on this band/for this iftype (binary) + * @NL80211_BAND_IFTYPE_ATTR_EHT_CAP_MAC: EHT MAC capabilities as in EHT + *	capabilities element + * @NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PHY: EHT PHY capabilities as in EHT + *	capabilities element + * @NL80211_BAND_IFTYPE_ATTR_EHT_CAP_MCS_SET: EHT supported NSS/MCS as in EHT + *	capabilities element + * @NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PPE: EHT PPE thresholds information as + *	defined in EHT capabilities element   * @__NL80211_BAND_IFTYPE_ATTR_AFTER_LAST: internal use + * @NL80211_BAND_IFTYPE_ATTR_MAX: highest band attribute currently defined   */  enum nl80211_band_iftype_attr {  	__NL80211_BAND_IFTYPE_ATTR_INVALID, @@ -3591,6 +4193,11 @@ enum nl80211_band_iftype_attr {  	NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET,  	NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE,  	NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA, +	NL80211_BAND_IFTYPE_ATTR_VENDOR_ELEMS, +	NL80211_BAND_IFTYPE_ATTR_EHT_CAP_MAC, +	NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PHY, +	NL80211_BAND_IFTYPE_ATTR_EHT_CAP_MCS_SET, +	NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PPE,  	/* keep last */  	__NL80211_BAND_IFTYPE_ATTR_AFTER_LAST, @@ -3620,6 +4227,10 @@ enum nl80211_band_iftype_attr {   * @NL80211_BAND_ATTR_EDMG_BW_CONFIG: Channel BW Configuration subfield encodes   *	the allowed channel bandwidth configurations.   *	Defined by IEEE P802.11ay/D4.0 section 9.4.2.251, Table 13. + * @NL80211_BAND_ATTR_S1G_MCS_NSS_SET: S1G capabilities, supported S1G-MCS and NSS + *	set subfield, as in the S1G information IE, 5 bytes + * @NL80211_BAND_ATTR_S1G_CAPA: S1G capabilities information subfield as in the + *	S1G information IE, 10 bytes   * @NL80211_BAND_ATTR_MAX: highest band attribute currently defined   * @__NL80211_BAND_ATTR_AFTER_LAST: internal use   */ @@ -3640,6 +4251,9 @@ enum nl80211_band_attr {  	NL80211_BAND_ATTR_EDMG_CHANNELS,  	NL80211_BAND_ATTR_EDMG_BW_CONFIG, +	NL80211_BAND_ATTR_S1G_MCS_NSS_SET, +	NL80211_BAND_ATTR_S1G_CAPA, +  	/* keep last */  	__NL80211_BAND_ATTR_AFTER_LAST,  	NL80211_BAND_ATTR_MAX = __NL80211_BAND_ATTR_AFTER_LAST - 1 @@ -3655,7 +4269,7 @@ enum nl80211_band_attr {   * @NL80211_WMMR_CW_MAX: Maximum contention window slot.   * @NL80211_WMMR_AIFSN: Arbitration Inter Frame Space.   * @NL80211_WMMR_TXOP: Maximum allowed tx operation time. - * @nl80211_WMMR_MAX: highest possible wmm rule. + * @NL80211_WMMR_MAX: highest possible wmm rule.   * @__NL80211_WMMR_LAST: Internal use.   */  enum nl80211_wmm_rule { @@ -3677,15 +4291,16 @@ enum nl80211_wmm_rule {   * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current   *	regulatory domain.   * @NL80211_FREQUENCY_ATTR_NO_IR: no mechanisms that initiate radiation - * 	are permitted on this channel, this includes sending probe - * 	requests, or modes of operation that require beaconing. + *	are permitted on this channel, this includes sending probe + *	requests, or modes of operation that require beaconing. + * @__NL80211_FREQUENCY_ATTR_NO_IBSS: obsolete, same as _NO_IR   * @NL80211_FREQUENCY_ATTR_RADAR: Radar detection is mandatory   *	on this channel in current regulatory domain.   * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm   *	(100 * dBm).   * @NL80211_FREQUENCY_ATTR_DFS_STATE: current state for DFS   *	(enum nl80211_dfs_state) - * @NL80211_FREQUENCY_ATTR_DFS_TIME: time in miliseconds for how long + * @NL80211_FREQUENCY_ATTR_DFS_TIME: time in milliseconds for how long   *	this channel is in this DFS state.   * @NL80211_FREQUENCY_ATTR_NO_HT40_MINUS: HT40- isn't possible with this   *	channel as the control channel @@ -3725,6 +4340,37 @@ enum nl80211_wmm_rule {   * @NL80211_FREQUENCY_ATTR_NO_HE: HE operation is not allowed on this channel   *	in current regulatory domain.   * @NL80211_FREQUENCY_ATTR_OFFSET: frequency offset in KHz + * @NL80211_FREQUENCY_ATTR_1MHZ: 1 MHz operation is allowed + *	on this channel in current regulatory domain. + * @NL80211_FREQUENCY_ATTR_2MHZ: 2 MHz operation is allowed + *	on this channel in current regulatory domain. + * @NL80211_FREQUENCY_ATTR_4MHZ: 4 MHz operation is allowed + *	on this channel in current regulatory domain. + * @NL80211_FREQUENCY_ATTR_8MHZ: 8 MHz operation is allowed + *	on this channel in current regulatory domain. + * @NL80211_FREQUENCY_ATTR_16MHZ: 16 MHz operation is allowed + *	on this channel in current regulatory domain. + * @NL80211_FREQUENCY_ATTR_NO_320MHZ: any 320 MHz channel using this channel + *	as the primary or any of the secondary channels isn't possible + * @NL80211_FREQUENCY_ATTR_NO_EHT: EHT operation is not allowed on this channel + *	in current regulatory domain. + * @NL80211_FREQUENCY_ATTR_PSD: Power spectral density (in dBm) that + *	is allowed on this channel in current regulatory domain. + * @NL80211_FREQUENCY_ATTR_DFS_CONCURRENT: Operation on this channel is + *	allowed for peer-to-peer or adhoc communication under the control + *	of a DFS master which operates on the same channel (FCC-594280 D01 + *	Section B.3). Should be used together with %NL80211_RRF_DFS only. + * @NL80211_FREQUENCY_ATTR_NO_6GHZ_VLP_CLIENT: Client connection to VLP AP + *	not allowed using this channel + * @NL80211_FREQUENCY_ATTR_NO_6GHZ_AFC_CLIENT: Client connection to AFC AP + *	not allowed using this channel + * @NL80211_FREQUENCY_ATTR_CAN_MONITOR: This channel can be used in monitor + *	mode despite other (regulatory) restrictions, even if the channel is + *	otherwise completely disabled. + * @NL80211_FREQUENCY_ATTR_ALLOW_6GHZ_VLP_AP: This channel can be used for a + *	very low power (VLP) AP, despite being NO_IR. + * @NL80211_FREQUENCY_ATTR_ALLOW_20MHZ_ACTIVITY: This channel can be active in + *	20 MHz bandwidth, despite being NO_IR.   * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number   *	currently defined   * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use @@ -3756,6 +4402,20 @@ enum nl80211_frequency_attr {  	NL80211_FREQUENCY_ATTR_WMM,  	NL80211_FREQUENCY_ATTR_NO_HE,  	NL80211_FREQUENCY_ATTR_OFFSET, +	NL80211_FREQUENCY_ATTR_1MHZ, +	NL80211_FREQUENCY_ATTR_2MHZ, +	NL80211_FREQUENCY_ATTR_4MHZ, +	NL80211_FREQUENCY_ATTR_8MHZ, +	NL80211_FREQUENCY_ATTR_16MHZ, +	NL80211_FREQUENCY_ATTR_NO_320MHZ, +	NL80211_FREQUENCY_ATTR_NO_EHT, +	NL80211_FREQUENCY_ATTR_PSD, +	NL80211_FREQUENCY_ATTR_DFS_CONCURRENT, +	NL80211_FREQUENCY_ATTR_NO_6GHZ_VLP_CLIENT, +	NL80211_FREQUENCY_ATTR_NO_6GHZ_AFC_CLIENT, +	NL80211_FREQUENCY_ATTR_CAN_MONITOR, +	NL80211_FREQUENCY_ATTR_ALLOW_6GHZ_VLP_AP, +	NL80211_FREQUENCY_ATTR_ALLOW_20MHZ_ACTIVITY,  	/* keep last */  	__NL80211_FREQUENCY_ATTR_AFTER_LAST, @@ -3768,6 +4428,10 @@ enum nl80211_frequency_attr {  #define NL80211_FREQUENCY_ATTR_NO_IR		NL80211_FREQUENCY_ATTR_NO_IR  #define NL80211_FREQUENCY_ATTR_GO_CONCURRENT \  					NL80211_FREQUENCY_ATTR_IR_CONCURRENT +#define NL80211_FREQUENCY_ATTR_NO_UHB_VLP_CLIENT \ +	NL80211_FREQUENCY_ATTR_NO_6GHZ_VLP_CLIENT +#define NL80211_FREQUENCY_ATTR_NO_UHB_AFC_CLIENT \ +	NL80211_FREQUENCY_ATTR_NO_6GHZ_AFC_CLIENT  /**   * enum nl80211_bitrate_attr - bitrate attributes @@ -3790,16 +4454,16 @@ enum nl80211_bitrate_attr {  };  /** - * enum nl80211_initiator - Indicates the initiator of a reg domain request + * enum nl80211_reg_initiator - Indicates the initiator of a reg domain request   * @NL80211_REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world - * 	regulatory domain. + *	regulatory domain.   * @NL80211_REGDOM_SET_BY_USER: User asked the wireless core to set the - * 	regulatory domain. + *	regulatory domain.   * @NL80211_REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the - * 	wireless core it thinks its knows the regulatory domain we should be in. + *	wireless core it thinks its knows the regulatory domain we should be in.   * @NL80211_REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an - * 	802.11 country information element with regulatory information it - * 	thinks we should consider. cfg80211 only processes the country + *	802.11 country information element with regulatory information it + *	thinks we should consider. cfg80211 only processes the country   *	code from the IE, and relies on the regulatory domain information   *	structure passed by userspace (CRDA) from our wireless-regdb.   *	If a channel is enabled but the country code indicates it should @@ -3818,11 +4482,11 @@ enum nl80211_reg_initiator {   *	to a specific country. When this is set you can count on the   *	ISO / IEC 3166 alpha2 country code being valid.   * @NL80211_REGDOM_TYPE_WORLD: the regulatory set domain is the world regulatory - * 	domain. + *	domain.   * @NL80211_REGDOM_TYPE_CUSTOM_WORLD: the regulatory domain set is a custom - * 	driver specific world regulatory domain. These do not apply system-wide - * 	and are only applicable to the individual devices which have requested - * 	them to be applied. + *	driver specific world regulatory domain. These do not apply system-wide + *	and are only applicable to the individual devices which have requested + *	them to be applied.   * @NL80211_REGDOM_TYPE_INTERSECTION: the regulatory domain set is the product   *	of an intersection between two regulatory domains -- the previously   *	set regulatory domain on the system and the last accepted regulatory @@ -3839,23 +4503,25 @@ enum nl80211_reg_type {   * enum nl80211_reg_rule_attr - regulatory rule attributes   * @__NL80211_REG_RULE_ATTR_INVALID: attribute number 0 is reserved   * @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional - * 	considerations for a given frequency range. These are the - * 	&enum nl80211_reg_rule_flags. + *	considerations for a given frequency range. These are the + *	&enum nl80211_reg_rule_flags.   * @NL80211_ATTR_FREQ_RANGE_START: starting frequencry for the regulatory - * 	rule in KHz. This is not a center of frequency but an actual regulatory - * 	band edge. + *	rule in KHz. This is not a center of frequency but an actual regulatory + *	band edge.   * @NL80211_ATTR_FREQ_RANGE_END: ending frequency for the regulatory rule - * 	in KHz. This is not a center a frequency but an actual regulatory - * 	band edge. + *	in KHz. This is not a center a frequency but an actual regulatory + *	band edge.   * @NL80211_ATTR_FREQ_RANGE_MAX_BW: maximum allowed bandwidth for this   *	frequency range, in KHz.   * @NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN: the maximum allowed antenna gain - * 	for a given frequency range. The value is in mBi (100 * dBi). - * 	If you don't have one then don't send this. + *	for a given frequency range. The value is in mBi (100 * dBi). + *	If you don't have one then don't send this.   * @NL80211_ATTR_POWER_RULE_MAX_EIRP: the maximum allowed EIRP for - * 	a given frequency range. The value is in mBm (100 * dBm). + *	a given frequency range. The value is in mBm (100 * dBm).   * @NL80211_ATTR_DFS_CAC_TIME: DFS CAC time in milliseconds.   *	If not present or 0 default CAC time will be used. + * @NL80211_ATTR_POWER_RULE_PSD: power spectral density (in dBm). + *	This could be negative.   * @NL80211_REG_RULE_ATTR_MAX: highest regulatory rule attribute number   *	currently defined   * @__NL80211_REG_RULE_ATTR_AFTER_LAST: internal use @@ -3873,6 +4539,8 @@ enum nl80211_reg_rule_attr {  	NL80211_ATTR_DFS_CAC_TIME, +	NL80211_ATTR_POWER_RULE_PSD, +  	/* keep last */  	__NL80211_REG_RULE_ATTR_AFTER_LAST,  	NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1 @@ -3901,14 +4569,7 @@ enum nl80211_reg_rule_attr {   *	value as specified by &struct nl80211_bss_select_rssi_adjust.   * @NL80211_SCHED_SCAN_MATCH_ATTR_BSSID: BSSID to be used for matching   *	(this cannot be used together with SSID). - * @NL80211_SCHED_SCAN_MATCH_PER_BAND_RSSI: Nested attribute that carries the - *	band specific minimum rssi thresholds for the bands defined in - *	enum nl80211_band. The minimum rssi threshold value(s32) specific to a - *	band shall be encapsulated in attribute with type value equals to one - *	of the NL80211_BAND_* defined in enum nl80211_band. For example, the - *	minimum rssi threshold value for 2.4GHZ band shall be encapsulated - *	within an attribute of type NL80211_BAND_2GHZ. And one or more of such - *	attributes will be nested within this attribute. + * @NL80211_SCHED_SCAN_MATCH_PER_BAND_RSSI: Obsolete   * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter   *	attribute number currently defined   * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use @@ -3921,7 +4582,7 @@ enum nl80211_sched_scan_match_attr {  	NL80211_SCHED_SCAN_MATCH_ATTR_RELATIVE_RSSI,  	NL80211_SCHED_SCAN_MATCH_ATTR_RSSI_ADJUST,  	NL80211_SCHED_SCAN_MATCH_ATTR_BSSID, -	NL80211_SCHED_SCAN_MATCH_PER_BAND_RSSI, +	NL80211_SCHED_SCAN_MATCH_PER_BAND_RSSI, /* obsolete */  	/* keep last */  	__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST, @@ -3943,8 +4604,9 @@ enum nl80211_sched_scan_match_attr {   * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links   * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links   * @NL80211_RRF_NO_IR: no mechanisms that initiate radiation are allowed, - * 	this includes probe requests or modes of operation that require - * 	beaconing. + *	this includes probe requests or modes of operation that require + *	beaconing. + * @__NL80211_RRF_NO_IBSS: obsolete, same as NO_IR   * @NL80211_RRF_AUTO_BW: maximum available bandwidth should be calculated   *	base on contiguous rules and wider channels will be allowed to cross   *	multiple contiguous/overlapping frequency ranges. @@ -3954,24 +4616,45 @@ enum nl80211_sched_scan_match_attr {   * @NL80211_RRF_NO_80MHZ: 80MHz operation not allowed   * @NL80211_RRF_NO_160MHZ: 160MHz operation not allowed   * @NL80211_RRF_NO_HE: HE operation not allowed + * @NL80211_RRF_NO_320MHZ: 320MHz operation not allowed + * @NL80211_RRF_NO_EHT: EHT operation not allowed + * @NL80211_RRF_PSD: Ruleset has power spectral density value + * @NL80211_RRF_DFS_CONCURRENT: Operation on this channel is allowed for + *	peer-to-peer or adhoc communication under the control of a DFS master + *	which operates on the same channel (FCC-594280 D01 Section B.3). + *	Should be used together with %NL80211_RRF_DFS only. + * @NL80211_RRF_NO_6GHZ_VLP_CLIENT: Client connection to VLP AP not allowed + * @NL80211_RRF_NO_6GHZ_AFC_CLIENT: Client connection to AFC AP not allowed + * @NL80211_RRF_ALLOW_6GHZ_VLP_AP: Very low power (VLP) AP can be permitted + *	despite NO_IR configuration. + * @NL80211_RRF_ALLOW_20MHZ_ACTIVITY: Allow activity in 20 MHz bandwidth, + *	despite NO_IR configuration.   */  enum nl80211_reg_rule_flags { -	NL80211_RRF_NO_OFDM		= 1<<0, -	NL80211_RRF_NO_CCK		= 1<<1, -	NL80211_RRF_NO_INDOOR		= 1<<2, -	NL80211_RRF_NO_OUTDOOR		= 1<<3, -	NL80211_RRF_DFS			= 1<<4, -	NL80211_RRF_PTP_ONLY		= 1<<5, -	NL80211_RRF_PTMP_ONLY		= 1<<6, -	NL80211_RRF_NO_IR		= 1<<7, -	__NL80211_RRF_NO_IBSS		= 1<<8, -	NL80211_RRF_AUTO_BW		= 1<<11, -	NL80211_RRF_IR_CONCURRENT	= 1<<12, -	NL80211_RRF_NO_HT40MINUS	= 1<<13, -	NL80211_RRF_NO_HT40PLUS		= 1<<14, -	NL80211_RRF_NO_80MHZ		= 1<<15, -	NL80211_RRF_NO_160MHZ		= 1<<16, -	NL80211_RRF_NO_HE		= 1<<17, +	NL80211_RRF_NO_OFDM                 = 1 << 0, +	NL80211_RRF_NO_CCK                  = 1 << 1, +	NL80211_RRF_NO_INDOOR               = 1 << 2, +	NL80211_RRF_NO_OUTDOOR              = 1 << 3, +	NL80211_RRF_DFS                     = 1 << 4, +	NL80211_RRF_PTP_ONLY                = 1 << 5, +	NL80211_RRF_PTMP_ONLY               = 1 << 6, +	NL80211_RRF_NO_IR                   = 1 << 7, +	__NL80211_RRF_NO_IBSS               = 1 << 8, +	NL80211_RRF_AUTO_BW                 = 1 << 11, +	NL80211_RRF_IR_CONCURRENT           = 1 << 12, +	NL80211_RRF_NO_HT40MINUS            = 1 << 13, +	NL80211_RRF_NO_HT40PLUS             = 1 << 14, +	NL80211_RRF_NO_80MHZ                = 1 << 15, +	NL80211_RRF_NO_160MHZ               = 1 << 16, +	NL80211_RRF_NO_HE                   = 1 << 17, +	NL80211_RRF_NO_320MHZ               = 1 << 18, +	NL80211_RRF_NO_EHT                  = 1 << 19, +	NL80211_RRF_PSD                     = 1 << 20, +	NL80211_RRF_DFS_CONCURRENT          = 1 << 21, +	NL80211_RRF_NO_6GHZ_VLP_CLIENT      = 1 << 22, +	NL80211_RRF_NO_6GHZ_AFC_CLIENT      = 1 << 23, +	NL80211_RRF_ALLOW_6GHZ_VLP_AP       = 1 << 24, +	NL80211_RRF_ALLOW_20MHZ_ACTIVITY    = 1 << 25,  };  #define NL80211_RRF_PASSIVE_SCAN	NL80211_RRF_NO_IR @@ -3980,6 +4663,8 @@ enum nl80211_reg_rule_flags {  #define NL80211_RRF_NO_HT40		(NL80211_RRF_NO_HT40MINUS |\  					 NL80211_RRF_NO_HT40PLUS)  #define NL80211_RRF_GO_CONCURRENT	NL80211_RRF_IR_CONCURRENT +#define NL80211_RRF_NO_UHB_VLP_CLIENT	NL80211_RRF_NO_6GHZ_VLP_CLIENT +#define NL80211_RRF_NO_UHB_AFC_CLIENT	NL80211_RRF_NO_6GHZ_AFC_CLIENT  /* For backport compatibility with older userspace */  #define NL80211_RRF_NO_IR_ALL		(NL80211_RRF_NO_IR | __NL80211_RRF_NO_IBSS) @@ -4049,6 +4734,7 @@ enum nl80211_user_reg_hint_type {   *	receiving frames destined to the local BSS   * @NL80211_SURVEY_INFO_MAX: highest survey info attribute number   *	currently defined + * @NL80211_SURVEY_INFO_FREQUENCY_OFFSET: center frequency offset in KHz   * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use   */  enum nl80211_survey_info { @@ -4064,6 +4750,7 @@ enum nl80211_survey_info {  	NL80211_SURVEY_INFO_TIME_SCAN,  	NL80211_SURVEY_INFO_PAD,  	NL80211_SURVEY_INFO_TIME_BSS_RX, +	NL80211_SURVEY_INFO_FREQUENCY_OFFSET,  	/* keep last */  	__NL80211_SURVEY_INFO_AFTER_LAST, @@ -4088,10 +4775,11 @@ enum nl80211_survey_info {   * @NL80211_MNTR_FLAG_PLCPFAIL: pass frames with bad PLCP   * @NL80211_MNTR_FLAG_CONTROL: pass control frames   * @NL80211_MNTR_FLAG_OTHER_BSS: disable BSSID filtering - * @NL80211_MNTR_FLAG_COOK_FRAMES: report frames after processing. - *	overrides all other flags. + * @NL80211_MNTR_FLAG_COOK_FRAMES: deprecated + *	will unconditionally be refused   * @NL80211_MNTR_FLAG_ACTIVE: use the configured MAC address   *	and ACK incoming unicast packets. + * @NL80211_MNTR_FLAG_SKIP_TX: do not pass local tx packets   *   * @__NL80211_MNTR_FLAG_AFTER_LAST: internal use   * @NL80211_MNTR_FLAG_MAX: highest possible monitor flag @@ -4104,6 +4792,7 @@ enum nl80211_mntr_flags {  	NL80211_MNTR_FLAG_OTHER_BSS,  	NL80211_MNTR_FLAG_COOK_FRAMES,  	NL80211_MNTR_FLAG_ACTIVE, +	NL80211_MNTR_FLAG_SKIP_TX,  	/* keep last */  	__NL80211_MNTR_FLAG_AFTER_LAST, @@ -4124,8 +4813,8 @@ enum nl80211_mntr_flags {   *	alternate between Active and Doze states, but may not wake up   *	for neighbor's beacons.   * - * @__NL80211_MESH_POWER_AFTER_LAST - internal use - * @NL80211_MESH_POWER_MAX - highest possible power save level + * @__NL80211_MESH_POWER_AFTER_LAST: internal use + * @NL80211_MESH_POWER_MAX: highest possible power save level   */  enum nl80211_mesh_power_mode { @@ -4467,6 +5156,8 @@ enum nl80211_key_mode {   * @NL80211_CHAN_WIDTH_4: 4 MHz OFDM channel   * @NL80211_CHAN_WIDTH_8: 8 MHz OFDM channel   * @NL80211_CHAN_WIDTH_16: 16 MHz OFDM channel + * @NL80211_CHAN_WIDTH_320: 320 MHz channel, the %NL80211_ATTR_CENTER_FREQ1 + *	attribute must be provided as well   */  enum nl80211_chan_width {  	NL80211_CHAN_WIDTH_20_NOHT, @@ -4482,6 +5173,7 @@ enum nl80211_chan_width {  	NL80211_CHAN_WIDTH_4,  	NL80211_CHAN_WIDTH_8,  	NL80211_CHAN_WIDTH_16, +	NL80211_CHAN_WIDTH_320,  };  /** @@ -4504,6 +5196,36 @@ enum nl80211_bss_scan_width {  };  /** + * enum nl80211_bss_use_for - bitmap indicating possible BSS use + * @NL80211_BSS_USE_FOR_NORMAL: Use this BSS for normal "connection", + *	including IBSS/MBSS depending on the type. + * @NL80211_BSS_USE_FOR_MLD_LINK: This BSS can be used as a link in an + *	MLO connection. Note that for an MLO connection, all links including + *	the assoc link must have this flag set, and the assoc link must + *	additionally have %NL80211_BSS_USE_FOR_NORMAL set. + */ +enum nl80211_bss_use_for { +	NL80211_BSS_USE_FOR_NORMAL = 1 << 0, +	NL80211_BSS_USE_FOR_MLD_LINK = 1 << 1, +}; + +/** + * enum nl80211_bss_cannot_use_reasons - reason(s) connection to a + *	BSS isn't possible + * @NL80211_BSS_CANNOT_USE_NSTR_NONPRIMARY: NSTR nonprimary links aren't + *	supported by the device, and this BSS entry represents one. + * @NL80211_BSS_CANNOT_USE_6GHZ_PWR_MISMATCH: STA is not supporting + *	the AP power type (SP, VLP, AP) that the AP uses. + */ +enum nl80211_bss_cannot_use_reasons { +	NL80211_BSS_CANNOT_USE_NSTR_NONPRIMARY	= 1 << 0, +	NL80211_BSS_CANNOT_USE_6GHZ_PWR_MISMATCH	= 1 << 1, +}; + +#define NL80211_BSS_CANNOT_USE_UHB_PWR_MISMATCH \ +	NL80211_BSS_CANNOT_USE_6GHZ_PWR_MISMATCH + +/**   * enum nl80211_bss - netlink attributes for a BSS   *   * @__NL80211_BSS_INVALID: invalid @@ -4534,7 +5256,7 @@ enum nl80211_bss_scan_width {   *	elements from a Beacon frame (bin); not present if no Beacon frame has   *	yet been received   * @NL80211_BSS_CHAN_WIDTH: channel width of the control channel - *	(u32, enum nl80211_bss_scan_width) + *	(u32, enum nl80211_bss_scan_width) - No longer used!   * @NL80211_BSS_BEACON_TSF: TSF of the last received beacon (u64)   *	(not present if no beacon frame has been received yet)   * @NL80211_BSS_PRESP_DATA: the data in @NL80211_BSS_INFORMATION_ELEMENTS and @@ -4553,6 +5275,16 @@ enum nl80211_bss_scan_width {   *	Contains a nested array of signal strength attributes (u8, dBm),   *	using the nesting index as the antenna number.   * @NL80211_BSS_FREQUENCY_OFFSET: frequency offset in KHz + * @NL80211_BSS_MLO_LINK_ID: MLO link ID of the BSS (u8). + * @NL80211_BSS_MLD_ADDR: MLD address of this BSS if connected to it. + * @NL80211_BSS_USE_FOR: u32 bitmap attribute indicating what the BSS can be + *	used for, see &enum nl80211_bss_use_for. + * @NL80211_BSS_CANNOT_USE_REASONS: Indicates the reason that this BSS cannot + *	be used for all or some of the possible uses by the device reporting it, + *	even though its presence was detected. + *	This is a u64 attribute containing a bitmap of values from + *	&enum nl80211_cannot_use_reasons, note that the attribute may be missing + *	if no reasons are specified.   * @__NL80211_BSS_AFTER_LAST: internal   * @NL80211_BSS_MAX: highest BSS attribute   */ @@ -4578,6 +5310,10 @@ enum nl80211_bss {  	NL80211_BSS_PARENT_BSSID,  	NL80211_BSS_CHAIN_SIGNAL,  	NL80211_BSS_FREQUENCY_OFFSET, +	NL80211_BSS_MLO_LINK_ID, +	NL80211_BSS_MLD_ADDR, +	NL80211_BSS_USE_FOR, +	NL80211_BSS_CANNOT_USE_REASONS,  	/* keep last */  	__NL80211_BSS_AFTER_LAST, @@ -4741,6 +5477,10 @@ enum nl80211_key_attributes {   * @NL80211_TXRATE_VHT: VHT rates allowed for TX rate selection,   *	see &struct nl80211_txrate_vht   * @NL80211_TXRATE_GI: configure GI, see &enum nl80211_txrate_gi + * @NL80211_TXRATE_HE: HE rates allowed for TX rate selection, + *	see &struct nl80211_txrate_he + * @NL80211_TXRATE_HE_GI: configure HE GI, 0.8us, 1.6us and 3.2us. + * @NL80211_TXRATE_HE_LTF: configure HE LTF, 1XLTF, 2XLTF and 4XLTF.   * @__NL80211_TXRATE_AFTER_LAST: internal   * @NL80211_TXRATE_MAX: highest TX rate attribute   */ @@ -4750,6 +5490,9 @@ enum nl80211_tx_rate_attributes {  	NL80211_TXRATE_HT,  	NL80211_TXRATE_VHT,  	NL80211_TXRATE_GI, +	NL80211_TXRATE_HE, +	NL80211_TXRATE_HE_GI, +	NL80211_TXRATE_HE_LTF,  	/* keep last */  	__NL80211_TXRATE_AFTER_LAST, @@ -4767,6 +5510,15 @@ struct nl80211_txrate_vht {  	__u16 mcs[NL80211_VHT_NSS_MAX];  }; +#define NL80211_HE_NSS_MAX		8 +/** + * struct nl80211_txrate_he - HE MCS/NSS txrate bitmap + * @mcs: MCS bitmap table for each NSS (array index 0 for 1 stream, etc.) + */ +struct nl80211_txrate_he { +	__u16 mcs[NL80211_HE_NSS_MAX]; +}; +  enum nl80211_txrate_gi {  	NL80211_TXRATE_DEFAULT_GI,  	NL80211_TXRATE_FORCE_SGI, @@ -4780,6 +5532,7 @@ enum nl80211_txrate_gi {   * @NL80211_BAND_60GHZ: around 60 GHz band (58.32 - 69.12 GHz)   * @NL80211_BAND_6GHZ: around 6 GHz band (5.9 - 7.2 GHz)   * @NL80211_BAND_S1GHZ: around 900MHz, supported by S1G PHYs + * @NL80211_BAND_LC: light communication band (placeholder)   * @NUM_NL80211_BANDS: number of bands, avoid using this in userspace   *	since newer kernel versions may support more bands   */ @@ -4789,6 +5542,7 @@ enum nl80211_band {  	NL80211_BAND_60GHZ,  	NL80211_BAND_6GHZ,  	NL80211_BAND_S1GHZ, +	NL80211_BAND_LC,  	NUM_NL80211_BANDS,  }; @@ -4908,7 +5662,7 @@ enum nl80211_tx_rate_setting {   *	(%NL80211_TID_CONFIG_ATTR_TIDS, %NL80211_TID_CONFIG_ATTR_OVERRIDE).   * @NL80211_TID_CONFIG_ATTR_PEER_SUPP: same as the previous per-vif one, but   *	per peer instead. - * @NL80211_TID_CONFIG_ATTR_OVERRIDE: flag attribue, if set indicates + * @NL80211_TID_CONFIG_ATTR_OVERRIDE: flag attribute, if set indicates   *	that the new configuration overrides all previous peer   *	configurations, otherwise previous peer specific configurations   *	should be left untouched. @@ -5080,7 +5834,7 @@ struct nl80211_pattern_support {   *	"TCP connection wakeup" for more details. This is a nested attribute   *	containing the exact information for establishing and keeping alive   *	the TCP connection. - * @NL80211_WOWLAN_TRIG_TCP_WAKEUP_MATCH: For wakeup reporting only, the + * @NL80211_WOWLAN_TRIG_WAKEUP_TCP_MATCH: For wakeup reporting only, the   *	wakeup packet was received on the TCP connection   * @NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST: For wakeup reporting only, the   *	TCP connection was lost or failed to be established @@ -5109,6 +5863,8 @@ struct nl80211_pattern_support {   *	%NL80211_ATTR_SCAN_FREQUENCIES contains more than one   *	frequency, it means that the match occurred in more than one   *	channel. + * @NL80211_WOWLAN_TRIG_UNPROTECTED_DEAUTH_DISASSOC: For wakeup reporting only. + *	Wake up happened due to unprotected deauth or disassoc frame in MFP.   * @NUM_NL80211_WOWLAN_TRIG: number of wake on wireless triggers   * @MAX_NL80211_WOWLAN_TRIG: highest wowlan trigger attribute number   * @@ -5136,6 +5892,7 @@ enum nl80211_wowlan_triggers {  	NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS,  	NL80211_WOWLAN_TRIG_NET_DETECT,  	NL80211_WOWLAN_TRIG_NET_DETECT_RESULTS, +	NL80211_WOWLAN_TRIG_UNPROTECTED_DEAUTH_DISASSOC,  	/* keep last */  	NUM_NL80211_WOWLAN_TRIG, @@ -5291,7 +6048,7 @@ enum nl80211_attr_coalesce_rule {  /**   * enum nl80211_coalesce_condition - coalesce rule conditions - * @NL80211_COALESCE_CONDITION_MATCH: coalaesce Rx packets when patterns + * @NL80211_COALESCE_CONDITION_MATCH: coalesce Rx packets when patterns   *	in a rule are matched.   * @NL80211_COALESCE_CONDITION_NO_MATCH: coalesce Rx packets when patterns   *	in a rule are not matched. @@ -5355,7 +6112,7 @@ enum nl80211_iface_limit_attrs {   *	=> allows 8 of AP/GO that can have BI gcd >= min gcd   *   *	numbers = [ #{STA} <= 2 ], channels = 2, max = 2 - *	=> allows two STAs on different channels + *	=> allows two STAs on the same or on different channels   *   *	numbers = [ #{STA} <= 1, #{P2P-client,P2P-GO} <= 3 ], max = 4   *	=> allows a STA plus three P2P interfaces @@ -5390,7 +6147,7 @@ enum nl80211_if_combination_attrs {   * enum nl80211_plink_state - state of a mesh peer link finite state machine   *   * @NL80211_PLINK_LISTEN: initial state, considered the implicit - *	state of non existent mesh peer links + *	state of non-existent mesh peer links   * @NL80211_PLINK_OPN_SNT: mesh plink open frame has been sent to   *	this mesh peer   * @NL80211_PLINK_OPN_RCVD: mesh plink open frame has been received @@ -5400,7 +6157,7 @@ enum nl80211_if_combination_attrs {   * @NL80211_PLINK_ESTAB: mesh peer link is established   * @NL80211_PLINK_HOLDING: mesh peer link is being closed or cancelled   * @NL80211_PLINK_BLOCKED: all frames transmitted from this mesh - *	plink are discarded + *	plink are discarded, except for authentication frames   * @NUM_NL80211_PLINK_STATES: number of peer link states   * @MAX_NL80211_PLINK_STATES: highest numerical value of plink states   */ @@ -5426,7 +6183,7 @@ enum nl80211_plink_state {   * @NL80211_PLINK_ACTION_BLOCK: block traffic from this mesh peer   * @NUM_NL80211_PLINK_ACTIONS: number of possible actions   */ -enum plink_actions { +enum nl80211_plink_action {  	NL80211_PLINK_ACTION_NO_ACTION,  	NL80211_PLINK_ACTION_OPEN,  	NL80211_PLINK_ACTION_BLOCK, @@ -5439,6 +6196,7 @@ enum plink_actions {  #define NL80211_KEK_LEN			16  #define NL80211_KCK_EXT_LEN		24  #define NL80211_KEK_EXT_LEN		32 +#define NL80211_KCK_EXT_LEN_32		32  #define NL80211_REPLAY_CTR_LEN		8  /** @@ -5537,13 +6295,15 @@ enum nl80211_tdls_operation {  	NL80211_TDLS_DISABLE_LINK,  }; -/* +/**   * enum nl80211_ap_sme_features - device-integrated AP features - * Reserved for future use, no bits are defined in - * NL80211_ATTR_DEVICE_AP_SME yet. + * @NL80211_AP_SME_SA_QUERY_OFFLOAD: SA Query procedures offloaded to driver + *	when user space indicates support for SA Query procedures offload during + *	"start ap" with %NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT. + */  enum nl80211_ap_sme_features { +	NL80211_AP_SME_SA_QUERY_OFFLOAD		= 1 << 0,  }; - */  /**   * enum nl80211_feature_flags - device/driver features @@ -5554,7 +6314,7 @@ enum nl80211_ap_sme_features {   * @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up   *	the connected inactive stations in AP mode.   * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested - *	to work properly to suppport receiving regulatory hints from + *	to work properly to support receiving regulatory hints from   *	cellular base stations.   * @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: (no longer available, only   *	here to reserve the value for API/ABI compatibility) @@ -5680,7 +6440,7 @@ enum nl80211_feature_flags {   *	request to use RRM (see %NL80211_ATTR_USE_RRM) with   *	%NL80211_CMD_ASSOCIATE and %NL80211_CMD_CONNECT requests, which will set   *	the ASSOC_REQ_USE_RRM flag in the association request even if - *	NL80211_FEATURE_QUIET is not advertized. + *	NL80211_FEATURE_QUIET is not advertised.   * @NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER: This device supports MU-MIMO air   *	sniffer which means that it can be configured to hear packets from   *	certain groups which can be configured by the @@ -5692,13 +6452,15 @@ enum nl80211_feature_flags {   *	the BSS that the interface that requested the scan is connected to   *	(if available).   * @NL80211_EXT_FEATURE_BSS_PARENT_TSF: Per BSS, this driver reports the - *	time the last beacon/probe was received. The time is the TSF of the - *	BSS that the interface that requested the scan is connected to - *	(if available). + *	time the last beacon/probe was received. For a non-MLO connection, the + *	time is the TSF of the BSS that the interface that requested the scan is + *	connected to (if available). For an MLO connection, the time is the TSF + *	of the BSS corresponding with link ID specified in the scan request (if + *	specified).   * @NL80211_EXT_FEATURE_SET_SCAN_DWELL: This driver supports configuration of   *	channel dwell time.   * @NL80211_EXT_FEATURE_BEACON_RATE_LEGACY: Driver supports beacon rate - *	configuration (AP/mesh), supporting a legacy (non HT/VHT) rate. + *	configuration (AP/mesh), supporting a legacy (non-HT/VHT) rate.   * @NL80211_EXT_FEATURE_BEACON_RATE_HT: Driver supports beacon rate   *	configuration (AP/mesh) with HT rates.   * @NL80211_EXT_FEATURE_BEACON_RATE_VHT: Driver supports beacon rate @@ -5748,6 +6510,7 @@ enum nl80211_feature_flags {   *	receiving control port frames over nl80211 instead of the netdevice.   * @NL80211_EXT_FEATURE_ACK_SIGNAL_SUPPORT: This driver/device supports   *	(average) ACK signal strength reporting. + * @NL80211_EXT_FEATURE_DATA_ACK_SIGNAL_SUPPORT: Backward-compatible ID   * @NL80211_EXT_FEATURE_TXQS: Driver supports FQ-CoDel-enabled intermediate   *      TXQs.   * @NL80211_EXT_FEATURE_SCAN_RANDOM_SN: Driver/device supports randomizing the @@ -5772,8 +6535,7 @@ enum nl80211_feature_flags {   * @NL80211_EXT_FEATURE_AP_PMKSA_CACHING: Driver/device supports PMKSA caching   *	(set/del PMKSA operations) in AP mode.   * - * @NL80211_EXT_FEATURE_SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD: Driver supports - *	filtering of sched scan results using band specific RSSI thresholds. + * @NL80211_EXT_FEATURE_SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD: Obsolete   *   * @NL80211_EXT_FEATURE_STA_TX_PWR: This driver supports controlling tx power   *	to a station. @@ -5821,6 +6583,72 @@ enum nl80211_feature_flags {   *	handshake with PSK in AP mode (PSK is passed as part of the start AP   *	command).   * + * @NL80211_EXT_FEATURE_SAE_OFFLOAD_AP: Device wants to do SAE authentication + *	in AP mode (SAE password is passed as part of the start AP command). + * + * @NL80211_EXT_FEATURE_FILS_DISCOVERY: Driver/device supports FILS discovery + *	frames transmission + * + * @NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP: Driver/device supports + *	unsolicited broadcast probe response transmission + * + * @NL80211_EXT_FEATURE_BEACON_RATE_HE: Driver supports beacon rate + *	configuration (AP/mesh) with HE rates. + * + * @NL80211_EXT_FEATURE_SECURE_LTF: Device supports secure LTF measurement + *      exchange protocol. + * + * @NL80211_EXT_FEATURE_SECURE_RTT: Device supports secure RTT measurement + *      exchange protocol. + * + * @NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE: Device supports management + *      frame protection for all management frames exchanged during the + *      negotiation and range measurement procedure. + * + * @NL80211_EXT_FEATURE_BSS_COLOR: The driver supports BSS color collision + *	detection and change announcemnts. + * + * @NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD: Driver running in AP mode supports + *	FILS encryption and decryption for (Re)Association Request and Response + *	frames. Userspace has to share FILS AAD details to the driver by using + *	@NL80211_CMD_SET_FILS_AAD. + * + * @NL80211_EXT_FEATURE_RADAR_BACKGROUND: Device supports background radar/CAC + *	detection. + * + * @NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE: Device can perform a MAC address + *	change without having to bring the underlying network device down + *	first. For example, in station mode this can be used to vary the + *	origin MAC address prior to a connection to a new AP for privacy + *	or other reasons. Note that certain driver specific restrictions + *	might apply, e.g. no scans in progress, no offchannel operations + *	in progress, and no active connections. + * + * @NL80211_EXT_FEATURE_PUNCT: Driver supports preamble puncturing in AP mode. + * + * @NL80211_EXT_FEATURE_SECURE_NAN: Device supports NAN Pairing which enables + *	authentication, data encryption and message integrity. + * + * @NL80211_EXT_FEATURE_AUTH_AND_DEAUTH_RANDOM_TA: Device supports randomized TA + *	in authentication and deauthentication frames sent to unassociated peer + *	using @NL80211_CMD_FRAME. + * + * @NL80211_EXT_FEATURE_OWE_OFFLOAD: Driver/Device wants to do OWE DH IE + *	handling in station mode. + * + * @NL80211_EXT_FEATURE_OWE_OFFLOAD_AP: Driver/Device wants to do OWE DH IE + *	handling in AP mode. + * + * @NL80211_EXT_FEATURE_DFS_CONCURRENT: The device supports peer-to-peer or + *	ad hoc operation on DFS channels under the control of a concurrent + *	DFS master on the same channel as described in FCC-594280 D01 + *	(Section B.3). This, for example, allows P2P GO and P2P clients to + *	operate on DFS channels as long as there's a concurrent BSS connection. + * + * @NL80211_EXT_FEATURE_SPP_AMSDU_SUPPORT: The driver has support for SPP + *	(signaling and payload protected) A-MSDUs and this shall be advertised + *	in the RSNXE. + *   * @NUM_NL80211_EXT_FEATURES: number of extended features.   * @MAX_NL80211_EXT_FEATURES: highest extended feature index.   */ @@ -5862,7 +6690,7 @@ enum nl80211_ext_feature_index {  	NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER,  	NL80211_EXT_FEATURE_AIRTIME_FAIRNESS,  	NL80211_EXT_FEATURE_AP_PMKSA_CACHING, -	NL80211_EXT_FEATURE_SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD, +	NL80211_EXT_FEATURE_SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD, /* obsolete */  	NL80211_EXT_FEATURE_EXT_KEY_ID,  	NL80211_EXT_FEATURE_STA_TX_PWR,  	NL80211_EXT_FEATURE_SAE_OFFLOAD, @@ -5878,6 +6706,24 @@ enum nl80211_ext_feature_index {  	NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211_TX_STATUS,  	NL80211_EXT_FEATURE_OPERATING_CHANNEL_VALIDATION,  	NL80211_EXT_FEATURE_4WAY_HANDSHAKE_AP_PSK, +	NL80211_EXT_FEATURE_SAE_OFFLOAD_AP, +	NL80211_EXT_FEATURE_FILS_DISCOVERY, +	NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP, +	NL80211_EXT_FEATURE_BEACON_RATE_HE, +	NL80211_EXT_FEATURE_SECURE_LTF, +	NL80211_EXT_FEATURE_SECURE_RTT, +	NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE, +	NL80211_EXT_FEATURE_BSS_COLOR, +	NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD, +	NL80211_EXT_FEATURE_RADAR_BACKGROUND, +	NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE, +	NL80211_EXT_FEATURE_PUNCT, +	NL80211_EXT_FEATURE_SECURE_NAN, +	NL80211_EXT_FEATURE_AUTH_AND_DEAUTH_RANDOM_TA, +	NL80211_EXT_FEATURE_OWE_OFFLOAD, +	NL80211_EXT_FEATURE_OWE_OFFLOAD_AP, +	NL80211_EXT_FEATURE_DFS_CONCURRENT, +	NL80211_EXT_FEATURE_SPP_AMSDU_SUPPORT,  	/* add new features before the definition below */  	NUM_NL80211_EXT_FEATURES, @@ -5962,7 +6808,7 @@ enum nl80211_timeout_reason {   *	request parameters IE in the probe request   * @NL80211_SCAN_FLAG_ACCEPT_BCAST_PROBE_RESP: accept broadcast probe responses   * @NL80211_SCAN_FLAG_OCE_PROBE_REQ_HIGH_TX_RATE: send probe request frames at - *	rate of at least 5.5M. In case non OCE AP is discovered in the channel, + *	rate of at least 5.5M. In case non-OCE AP is discovered in the channel,   *	only the first probe req in the channel will be sent in high rate.   * @NL80211_SCAN_FLAG_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION: allow probe request   *	tx deferral (dot11FILSProbeDelay shall be set to 15ms) @@ -5992,6 +6838,16 @@ enum nl80211_timeout_reason {   * @NL80211_SCAN_FLAG_FREQ_KHZ: report scan results with   *	%NL80211_ATTR_SCAN_FREQ_KHZ. This also means   *	%NL80211_ATTR_SCAN_FREQUENCIES will not be included. + * @NL80211_SCAN_FLAG_COLOCATED_6GHZ: scan for collocated APs reported by + *	2.4/5 GHz APs. When the flag is set, the scan logic will use the + *	information from the RNR element found in beacons/probe responses + *	received on the 2.4/5 GHz channels to actively scan only the 6GHz + *	channels on which APs are expected to be found. Note that when not set, + *	the scan logic would scan all 6GHz channels, but since transmission of + *	probe requests on non-PSC channels is limited, it is highly likely that + *	these channels would passively be scanned. Also note that when the flag + *	is set, in addition to the colocated APs, PSC channels would also be + *	scanned if the user space has asked for it.   */  enum nl80211_scan_flags {  	NL80211_SCAN_FLAG_LOW_PRIORITY				= 1<<0, @@ -6008,6 +6864,7 @@ enum nl80211_scan_flags {  	NL80211_SCAN_FLAG_RANDOM_SN				= 1<<11,  	NL80211_SCAN_FLAG_MIN_PREQ_CONTENT			= 1<<12,  	NL80211_SCAN_FLAG_FREQ_KHZ				= 1<<13, +	NL80211_SCAN_FLAG_COLOCATED_6GHZ			= 1<<14,  };  /** @@ -6037,6 +6894,8 @@ enum nl80211_acl_policy {   * @NL80211_SMPS_STATIC: static SMPS (use a single antenna)   * @NL80211_SMPS_DYNAMIC: dynamic smps (start with a single antenna and   *	turn on other antennas after CTS/RTS). + * @__NL80211_SMPS_AFTER_LAST: internal + * @NL80211_SMPS_MAX: highest used enumeration   */  enum nl80211_smps_mode {  	NL80211_SMPS_OFF, @@ -6172,11 +7031,13 @@ struct nl80211_vendor_cmd_info {   * @NL80211_TDLS_PEER_HT: TDLS peer is HT capable.   * @NL80211_TDLS_PEER_VHT: TDLS peer is VHT capable.   * @NL80211_TDLS_PEER_WMM: TDLS peer is WMM capable. + * @NL80211_TDLS_PEER_HE: TDLS peer is HE capable.   */  enum nl80211_tdls_peer_capability {  	NL80211_TDLS_PEER_HT = 1<<0,  	NL80211_TDLS_PEER_VHT = 1<<1,  	NL80211_TDLS_PEER_WMM = 1<<2, +	NL80211_TDLS_PEER_HE = 1<<3,  };  /** @@ -6256,6 +7117,8 @@ enum nl80211_bss_select_attr {   * @NL80211_NAN_FUNC_PUBLISH: function is publish   * @NL80211_NAN_FUNC_SUBSCRIBE: function is subscribe   * @NL80211_NAN_FUNC_FOLLOW_UP: function is follow-up + * @__NL80211_NAN_FUNC_TYPE_AFTER_LAST: internal use + * @NL80211_NAN_FUNC_MAX_TYPE: internal use   */  enum nl80211_nan_function_type {  	NL80211_NAN_FUNC_PUBLISH, @@ -6317,7 +7180,7 @@ enum nl80211_nan_func_term_reason {   *	The instance ID for the follow up Service Discovery Frame. This is u8.   * @NL80211_NAN_FUNC_FOLLOW_UP_REQ_ID: relevant if the function's type   *	is follow up. This is a u8. - *	The requestor instance ID for the follow up Service Discovery Frame. + *	The requester instance ID for the follow up Service Discovery Frame.   * @NL80211_NAN_FUNC_FOLLOW_UP_DEST: the MAC address of the recipient of the   *	follow up Service Discovery Frame. This is a binary attribute.   * @NL80211_NAN_FUNC_CLOSE_RANGE: is this function limited for devices in a @@ -6416,7 +7279,7 @@ enum nl80211_nan_match_attributes {  };  /** - * nl80211_external_auth_action - Action to perform with external + * enum nl80211_external_auth_action - Action to perform with external   *     authentication request. Used by NL80211_ATTR_EXTERNAL_AUTH_ACTION.   * @NL80211_EXTERNAL_AUTH_START: Start the authentication.   * @NL80211_EXTERNAL_AUTH_ABORT: Abort the ongoing authentication. @@ -6434,7 +7297,7 @@ enum nl80211_external_auth_action {   * @NL80211_FTM_RESP_ATTR_LCI: The content of Measurement Report Element   *	(9.4.2.22 in 802.11-2016) with type 8 - LCI (9.4.2.22.10),   *	i.e. starting with the measurement token - * @NL80211_FTM_RESP_ATTR_CIVIC: The content of Measurement Report Element + * @NL80211_FTM_RESP_ATTR_CIVICLOC: The content of Measurement Report Element   *	(9.4.2.22 in 802.11-2016) with type 11 - Civic (Section 9.4.2.22.13),   *	i.e. starting with the measurement token   * @__NL80211_FTM_RESP_ATTR_LAST: Internal @@ -6707,7 +7570,7 @@ enum nl80211_peer_measurement_attrs {   * @NL80211_PMSR_FTM_CAPA_ATTR_TRIGGER_BASED: flag attribute indicating if   *	trigger based ranging measurement is supported   * @NL80211_PMSR_FTM_CAPA_ATTR_NON_TRIGGER_BASED: flag attribute indicating - *	if non trigger based ranging measurement is supported + *	if non-trigger-based ranging measurement is supported   *   * @NUM_NL80211_PMSR_FTM_CAPA_ATTR: internal   * @NL80211_PMSR_FTM_CAPA_ATTR_MAX: highest attribute number @@ -6761,13 +7624,19 @@ enum nl80211_peer_measurement_ftm_capa {   *      if neither %NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED nor   *	%NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED is set, EDCA based   *	ranging will be used. - * @NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED: request non trigger based + * @NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED: request non-trigger-based   *	ranging measurement (flag)   *	This attribute and %NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED are   *	mutually exclusive.   *      if neither %NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED nor   *	%NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED is set, EDCA based   *	ranging will be used. + * @NL80211_PMSR_FTM_REQ_ATTR_LMR_FEEDBACK: negotiate for LMR feedback. Only + *	valid if either %NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED or + *	%NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED is set. + * @NL80211_PMSR_FTM_REQ_ATTR_BSS_COLOR: optional. The BSS color of the + *	responder. Only valid if %NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED + *	or %NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED is set.   *   * @NUM_NL80211_PMSR_FTM_REQ_ATTR: internal   * @NL80211_PMSR_FTM_REQ_ATTR_MAX: highest attribute number @@ -6786,6 +7655,8 @@ enum nl80211_peer_measurement_ftm_req {  	NL80211_PMSR_FTM_REQ_ATTR_REQUEST_CIVICLOC,  	NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED,  	NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED, +	NL80211_PMSR_FTM_REQ_ATTR_LMR_FEEDBACK, +	NL80211_PMSR_FTM_REQ_ATTR_BSS_COLOR,  	/* keep last */  	NUM_NL80211_PMSR_FTM_REQ_ATTR, @@ -6831,7 +7702,7 @@ enum nl80211_peer_measurement_ftm_failure_reasons {   * @NL80211_PMSR_FTM_RESP_ATTR_NUM_FTMR_ATTEMPTS: number of FTM Request frames   *	transmitted (u32, optional)   * @NL80211_PMSR_FTM_RESP_ATTR_NUM_FTMR_SUCCESSES: number of FTM Request frames - *	that were acknowleged (u32, optional) + *	that were acknowledged (u32, optional)   * @NL80211_PMSR_FTM_RESP_ATTR_BUSY_RETRY_TIME: retry time received from the   *	busy peer (u32, seconds)   * @NL80211_PMSR_FTM_RESP_ATTR_NUM_BURSTS_EXP: actual number of bursts exponent @@ -6910,6 +7781,13 @@ enum nl80211_peer_measurement_ftm_resp {   *   * @NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET: the OBSS PD minimum tx power offset.   * @NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET: the OBSS PD maximum tx power offset. + * @NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET: the non-SRG OBSS PD maximum + *	tx power offset. + * @NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP: bitmap that indicates the BSS color + *	values used by members of the SRG. + * @NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP: bitmap that indicates the partial + *	BSSID values used by members of the SRG. + * @NL80211_HE_OBSS_PD_ATTR_SR_CTRL: The SR Control field of SRP element.   *   * @__NL80211_HE_OBSS_PD_ATTR_LAST: Internal   * @NL80211_HE_OBSS_PD_ATTR_MAX: highest OBSS PD attribute. @@ -6919,6 +7797,10 @@ enum nl80211_obss_pd_attributes {  	NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET,  	NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET, +	NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET, +	NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP, +	NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP, +	NL80211_HE_OBSS_PD_ATTR_SR_CTRL,  	/* keep last */  	__NL80211_HE_OBSS_PD_ATTR_LAST, @@ -6972,4 +7854,337 @@ enum nl80211_iftype_akm_attributes {  	NL80211_IFTYPE_AKM_ATTR_MAX = __NL80211_IFTYPE_AKM_ATTR_LAST - 1,  }; +/** + * enum nl80211_fils_discovery_attributes - FILS discovery configuration + * from IEEE Std 802.11ai-2016, Annex C.3 MIB detail. + * + * @__NL80211_FILS_DISCOVERY_ATTR_INVALID: Invalid + * + * @NL80211_FILS_DISCOVERY_ATTR_INT_MIN: Minimum packet interval (u32, TU). + *	Allowed range: 0..10000 (TU = Time Unit) + * @NL80211_FILS_DISCOVERY_ATTR_INT_MAX: Maximum packet interval (u32, TU). + *	Allowed range: 0..10000 (TU = Time Unit). If set to 0, the feature is disabled. + * @NL80211_FILS_DISCOVERY_ATTR_TMPL: Template data for FILS discovery action + *	frame including the headers. + * + * @__NL80211_FILS_DISCOVERY_ATTR_LAST: Internal + * @NL80211_FILS_DISCOVERY_ATTR_MAX: highest attribute + */ +enum nl80211_fils_discovery_attributes { +	__NL80211_FILS_DISCOVERY_ATTR_INVALID, + +	NL80211_FILS_DISCOVERY_ATTR_INT_MIN, +	NL80211_FILS_DISCOVERY_ATTR_INT_MAX, +	NL80211_FILS_DISCOVERY_ATTR_TMPL, + +	/* keep last */ +	__NL80211_FILS_DISCOVERY_ATTR_LAST, +	NL80211_FILS_DISCOVERY_ATTR_MAX = __NL80211_FILS_DISCOVERY_ATTR_LAST - 1 +}; + +/* + * FILS discovery template minimum length with action frame headers and + * mandatory fields. + */ +#define NL80211_FILS_DISCOVERY_TMPL_MIN_LEN 42 + +/** + * enum nl80211_unsol_bcast_probe_resp_attributes - Unsolicited broadcast probe + *	response configuration. Applicable only in 6GHz. + * + * @__NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INVALID: Invalid + * + * @NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INT: Maximum packet interval (u32, TU). + *	Allowed range: 0..20 (TU = Time Unit). IEEE P802.11ax/D6.0 + *	26.17.2.3.2 (AP behavior for fast passive scanning). If set to 0, the feature is + *	disabled. + * @NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_TMPL: Unsolicited broadcast probe response + *	frame template (binary). + * + * @__NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_LAST: Internal + * @NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_MAX: highest attribute + */ +enum nl80211_unsol_bcast_probe_resp_attributes { +	__NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INVALID, + +	NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INT, +	NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_TMPL, + +	/* keep last */ +	__NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_LAST, +	NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_MAX = +		__NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_LAST - 1 +}; + +/** + * enum nl80211_sae_pwe_mechanism - The mechanism(s) allowed for SAE PWE + *	derivation. Applicable only when WPA3-Personal SAE authentication is + *	used. + * + * @NL80211_SAE_PWE_UNSPECIFIED: not specified, used internally to indicate that + *	attribute is not present from userspace. + * @NL80211_SAE_PWE_HUNT_AND_PECK: hunting-and-pecking loop only + * @NL80211_SAE_PWE_HASH_TO_ELEMENT: hash-to-element only + * @NL80211_SAE_PWE_BOTH: both hunting-and-pecking loop and hash-to-element + *	can be used. + */ +enum nl80211_sae_pwe_mechanism { +	NL80211_SAE_PWE_UNSPECIFIED, +	NL80211_SAE_PWE_HUNT_AND_PECK, +	NL80211_SAE_PWE_HASH_TO_ELEMENT, +	NL80211_SAE_PWE_BOTH, +}; + +/** + * enum nl80211_sar_type - type of SAR specs + * + * @NL80211_SAR_TYPE_POWER: power limitation specified in 0.25dBm unit + * + * @NUM_NL80211_SAR_TYPE: internal + */ +enum nl80211_sar_type { +	NL80211_SAR_TYPE_POWER, + +	/* add new type here */ + +	/* Keep last */ +	NUM_NL80211_SAR_TYPE, +}; + +/** + * enum nl80211_sar_attrs - Attributes for SAR spec + * + * @__NL80211_SAR_ATTR_INVALID: Invalid + * + * @NL80211_SAR_ATTR_TYPE: the SAR type as defined in &enum nl80211_sar_type. + * + * @NL80211_SAR_ATTR_SPECS: Nested array of SAR power + *	limit specifications. Each specification contains a set + *	of %nl80211_sar_specs_attrs. + * + *	For SET operation, it contains array of %NL80211_SAR_ATTR_SPECS_POWER + *	and %NL80211_SAR_ATTR_SPECS_RANGE_INDEX. + * + *	For sar_capa dump, it contains array of + *	%NL80211_SAR_ATTR_SPECS_START_FREQ + *	and %NL80211_SAR_ATTR_SPECS_END_FREQ. + * + * @__NL80211_SAR_ATTR_LAST: Internal + * @NL80211_SAR_ATTR_MAX: highest sar attribute + * + * These attributes are used with %NL80211_CMD_SET_SAR_SPEC + */ +enum nl80211_sar_attrs { +	__NL80211_SAR_ATTR_INVALID, + +	NL80211_SAR_ATTR_TYPE, +	NL80211_SAR_ATTR_SPECS, + +	__NL80211_SAR_ATTR_LAST, +	NL80211_SAR_ATTR_MAX = __NL80211_SAR_ATTR_LAST - 1, +}; + +/** + * enum nl80211_sar_specs_attrs - Attributes for SAR power limit specs + * + * @__NL80211_SAR_ATTR_SPECS_INVALID: Invalid + * + * @NL80211_SAR_ATTR_SPECS_POWER: Required (s32)value to specify the actual + *	power limit value in units of 0.25 dBm if type is + *	NL80211_SAR_TYPE_POWER. (i.e., a value of 44 represents 11 dBm). + *	0 means userspace doesn't have SAR limitation on this associated range. + * + * @NL80211_SAR_ATTR_SPECS_RANGE_INDEX: Required (u32) value to specify the + *	index of exported freq range table and the associated power limitation + *	is applied to this range. + * + *	Userspace isn't required to set all the ranges advertised by WLAN driver, + *	and userspace can skip some certain ranges. These skipped ranges don't + *	have SAR limitations, and they are same as setting the + *	%NL80211_SAR_ATTR_SPECS_POWER to any unreasonable high value because any + *	value higher than regulatory allowed value just means SAR power + *	limitation is removed, but it's required to set at least one range. + *	It's not allowed to set duplicated range in one SET operation. + * + *	Every SET operation overwrites previous SET operation. + * + * @NL80211_SAR_ATTR_SPECS_START_FREQ: Required (u32) value to specify the start + *	frequency of this range edge when registering SAR capability to wiphy. + *	It's not a channel center frequency. The unit is kHz. + * + * @NL80211_SAR_ATTR_SPECS_END_FREQ: Required (u32) value to specify the end + *	frequency of this range edge when registering SAR capability to wiphy. + *	It's not a channel center frequency. The unit is kHz. + * + * @__NL80211_SAR_ATTR_SPECS_LAST: Internal + * @NL80211_SAR_ATTR_SPECS_MAX: highest sar specs attribute + */ +enum nl80211_sar_specs_attrs { +	__NL80211_SAR_ATTR_SPECS_INVALID, + +	NL80211_SAR_ATTR_SPECS_POWER, +	NL80211_SAR_ATTR_SPECS_RANGE_INDEX, +	NL80211_SAR_ATTR_SPECS_START_FREQ, +	NL80211_SAR_ATTR_SPECS_END_FREQ, + +	__NL80211_SAR_ATTR_SPECS_LAST, +	NL80211_SAR_ATTR_SPECS_MAX = __NL80211_SAR_ATTR_SPECS_LAST - 1, +}; + +/** + * enum nl80211_mbssid_config_attributes - multiple BSSID (MBSSID) and enhanced + * multi-BSSID advertisements (EMA) in AP mode. + * Kernel uses some of these attributes to advertise driver's support for + * MBSSID and EMA. + * Remaining attributes should be used by the userspace to configure the + * features. + * + * @__NL80211_MBSSID_CONFIG_ATTR_INVALID: Invalid + * + * @NL80211_MBSSID_CONFIG_ATTR_MAX_INTERFACES: Used by the kernel to advertise + *	the maximum number of MBSSID interfaces supported by the driver. + *	Driver should indicate MBSSID support by setting + *	wiphy->mbssid_max_interfaces to a value more than or equal to 2. + * + * @NL80211_MBSSID_CONFIG_ATTR_MAX_EMA_PROFILE_PERIODICITY: Used by the kernel + *	to advertise the maximum profile periodicity supported by the driver + *	if EMA is enabled. Driver should indicate EMA support to the userspace + *	by setting wiphy->ema_max_profile_periodicity to + *	a non-zero value. + * + * @NL80211_MBSSID_CONFIG_ATTR_INDEX: Mandatory parameter to pass the index of + *	this BSS (u8) in the multiple BSSID set. + *	Value must be set to 0 for the transmitting interface and non-zero for + *	all non-transmitting interfaces. The userspace will be responsible + *	for using unique indices for the interfaces. + *	Range: 0 to wiphy->mbssid_max_interfaces-1. + * + * @NL80211_MBSSID_CONFIG_ATTR_TX_IFINDEX: Mandatory parameter for + *	a non-transmitted profile which provides the interface index (u32) of + *	the transmitted profile. The value must match one of the interface + *	indices advertised by the kernel. Optional if the interface being set up + *	is the transmitting one, however, if provided then the value must match + *	the interface index of the same. + * + * @NL80211_MBSSID_CONFIG_ATTR_EMA: Flag used to enable EMA AP feature. + *	Setting this flag is permitted only if the driver advertises EMA support + *	by setting wiphy->ema_max_profile_periodicity to non-zero. + * + * @NL80211_MBSSID_CONFIG_ATTR_TX_LINK_ID: Link ID of the transmitted profile. + *	This parameter is mandatory when NL80211_ATTR_MBSSID_CONFIG attributes + *	are sent for a non-transmitted profile and if the transmitted profile + *	is part of an MLD. For all other cases this parameter is unnecessary. + * + * @__NL80211_MBSSID_CONFIG_ATTR_LAST: Internal + * @NL80211_MBSSID_CONFIG_ATTR_MAX: highest attribute + */ +enum nl80211_mbssid_config_attributes { +	__NL80211_MBSSID_CONFIG_ATTR_INVALID, + +	NL80211_MBSSID_CONFIG_ATTR_MAX_INTERFACES, +	NL80211_MBSSID_CONFIG_ATTR_MAX_EMA_PROFILE_PERIODICITY, +	NL80211_MBSSID_CONFIG_ATTR_INDEX, +	NL80211_MBSSID_CONFIG_ATTR_TX_IFINDEX, +	NL80211_MBSSID_CONFIG_ATTR_EMA, +	NL80211_MBSSID_CONFIG_ATTR_TX_LINK_ID, + +	/* keep last */ +	__NL80211_MBSSID_CONFIG_ATTR_LAST, +	NL80211_MBSSID_CONFIG_ATTR_MAX = __NL80211_MBSSID_CONFIG_ATTR_LAST - 1, +}; + +/** + * enum nl80211_ap_settings_flags - AP settings flags + * + * @NL80211_AP_SETTINGS_EXTERNAL_AUTH_SUPPORT: AP supports external + *	authentication. + * @NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT: Userspace supports SA Query + *	procedures offload to driver. If driver advertises + *	%NL80211_AP_SME_SA_QUERY_OFFLOAD in AP SME features, userspace shall + *	ignore SA Query procedures and validations when this flag is set by + *	userspace. + */ +enum nl80211_ap_settings_flags { +	NL80211_AP_SETTINGS_EXTERNAL_AUTH_SUPPORT	= 1 << 0, +	NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT	= 1 << 1, +}; + +/** + * enum nl80211_wiphy_radio_attrs - wiphy radio attributes + * + * @__NL80211_WIPHY_RADIO_ATTR_INVALID: Invalid + * + * @NL80211_WIPHY_RADIO_ATTR_INDEX: Index of this radio (u32) + * @NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE: Frequency range supported by this + *	radio. Attribute may be present multiple times. + * @NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION: Supported interface + *	combination for this radio. Attribute may be present multiple times + *	and contains attributes defined in &enum nl80211_if_combination_attrs. + * @NL80211_WIPHY_RADIO_ATTR_ANTENNA_MASK: bitmask (u32) of antennas + *	connected to this radio. + * @NL80211_WIPHY_RADIO_ATTR_RTS_THRESHOLD: RTS threshold (u32) of this radio. + * + * @__NL80211_WIPHY_RADIO_ATTR_LAST: Internal + * @NL80211_WIPHY_RADIO_ATTR_MAX: Highest attribute + */ +enum nl80211_wiphy_radio_attrs { +	__NL80211_WIPHY_RADIO_ATTR_INVALID, + +	NL80211_WIPHY_RADIO_ATTR_INDEX, +	NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE, +	NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION, +	NL80211_WIPHY_RADIO_ATTR_ANTENNA_MASK, +	NL80211_WIPHY_RADIO_ATTR_RTS_THRESHOLD, + +	/* keep last */ +	__NL80211_WIPHY_RADIO_ATTR_LAST, +	NL80211_WIPHY_RADIO_ATTR_MAX = __NL80211_WIPHY_RADIO_ATTR_LAST - 1, +}; + +/** + * enum nl80211_wiphy_radio_freq_range - wiphy radio frequency range + * + * @__NL80211_WIPHY_RADIO_FREQ_ATTR_INVALID: Invalid + * + * @NL80211_WIPHY_RADIO_FREQ_ATTR_START: Frequency range start (u32). + *	The unit is kHz. + * @NL80211_WIPHY_RADIO_FREQ_ATTR_END: Frequency range end (u32). + *	The unit is kHz. + * + * @__NL80211_WIPHY_RADIO_FREQ_ATTR_LAST: Internal + * @NL80211_WIPHY_RADIO_FREQ_ATTR_MAX: Highest attribute + */ +enum nl80211_wiphy_radio_freq_range { +	__NL80211_WIPHY_RADIO_FREQ_ATTR_INVALID, + +	NL80211_WIPHY_RADIO_FREQ_ATTR_START, +	NL80211_WIPHY_RADIO_FREQ_ATTR_END, + +	__NL80211_WIPHY_RADIO_FREQ_ATTR_LAST, +	NL80211_WIPHY_RADIO_FREQ_ATTR_MAX = __NL80211_WIPHY_RADIO_FREQ_ATTR_LAST - 1, +}; + +/** + * enum nl80211_s1g_short_beacon_attrs - S1G short beacon data + * + * @__NL80211_S1G_SHORT_BEACON_ATTR_INVALID: Invalid + * + * @NL80211_S1G_SHORT_BEACON_ATTR_HEAD: Short beacon head (binary). + * @NL80211_S1G_SHORT_BEACON_ATTR_TAIL: Short beacon tail (binary). + * + * @__NL80211_S1G_SHORT_BEACON_ATTR_LAST: Internal + * @NL80211_S1G_SHORT_BEACON_ATTR_MAX: Highest attribute + */ +enum nl80211_s1g_short_beacon_attrs { +	__NL80211_S1G_SHORT_BEACON_ATTR_INVALID, + +	NL80211_S1G_SHORT_BEACON_ATTR_HEAD, +	NL80211_S1G_SHORT_BEACON_ATTR_TAIL, + +	/* keep last */ +	__NL80211_S1G_SHORT_BEACON_ATTR_LAST, +	NL80211_S1G_SHORT_BEACON_ATTR_MAX = +		__NL80211_S1G_SHORT_BEACON_ATTR_LAST - 1 +}; +  #endif /* __LINUX_NL80211_H */ diff --git a/include/uapi/linux/npcm-video.h b/include/uapi/linux/npcm-video.h new file mode 100644 index 000000000000..1d39f6f38c96 --- /dev/null +++ b/include/uapi/linux/npcm-video.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Controls header for NPCM video driver + * + * Copyright (C) 2022 Nuvoton Technologies + */ + +#ifndef _UAPI_LINUX_NPCM_VIDEO_H +#define _UAPI_LINUX_NPCM_VIDEO_H + +#include <linux/v4l2-controls.h> + +/* + * Check Documentation/userspace-api/media/drivers/npcm-video.rst for control + * details. + */ + +/* + * This control is meant to set the mode of NPCM Video Capture/Differentiation + * (VCD) engine. + * + * The VCD engine supports two modes: + * COMPLETE - Capture the next complete frame into memory. + * DIFF	    - Compare the incoming frame with the frame stored in memory, and + *	      updates the differentiated frame in memory. + */ +#define V4L2_CID_NPCM_CAPTURE_MODE	(V4L2_CID_USER_NPCM_BASE + 0) + +enum v4l2_npcm_capture_mode { +	V4L2_NPCM_CAPTURE_MODE_COMPLETE	= 0, /* COMPLETE mode */ +	V4L2_NPCM_CAPTURE_MODE_DIFF	= 1, /* DIFF mode */ +}; + +/* + * This control is meant to get the count of compressed HEXTILE rectangles which + * is relevant to the number of differentiated frames if VCD is in DIFF mode. + * And the count will always be 1 if VCD is in COMPLETE mode. + */ +#define V4L2_CID_NPCM_RECT_COUNT	(V4L2_CID_USER_NPCM_BASE + 1) + +#endif /* _UAPI_LINUX_NPCM_VIDEO_H */ diff --git a/include/uapi/linux/nsfs.h b/include/uapi/linux/nsfs.h index a0c8552b64ee..97d8d80d139f 100644 --- a/include/uapi/linux/nsfs.h +++ b/include/uapi/linux/nsfs.h @@ -3,6 +3,7 @@  #define __LINUX_NSFS_H  #include <linux/ioctl.h> +#include <linux/types.h>  #define NSIO	0xb7 @@ -15,5 +16,41 @@  #define NS_GET_NSTYPE		_IO(NSIO, 0x3)  /* Get owner UID (in the caller's user namespace) for a user namespace */  #define NS_GET_OWNER_UID	_IO(NSIO, 0x4) +/* Get the id for a mount namespace */ +#define NS_GET_MNTNS_ID		_IOR(NSIO, 0x5, __u64) +/* Translate pid from target pid namespace into the caller's pid namespace. */ +#define NS_GET_PID_FROM_PIDNS	_IOR(NSIO, 0x6, int) +/* Return thread-group leader id of pid in the callers pid namespace. */ +#define NS_GET_TGID_FROM_PIDNS	_IOR(NSIO, 0x7, int) +/* Translate pid from caller's pid namespace into a target pid namespace. */ +#define NS_GET_PID_IN_PIDNS	_IOR(NSIO, 0x8, int) +/* Return thread-group leader id of pid in the target pid namespace. */ +#define NS_GET_TGID_IN_PIDNS	_IOR(NSIO, 0x9, int) + +struct mnt_ns_info { +	__u32 size; +	__u32 nr_mounts; +	__u64 mnt_ns_id; +}; + +#define MNT_NS_INFO_SIZE_VER0 16 /* size of first published struct */ + +/* Get information about namespace. */ +#define NS_MNT_GET_INFO		_IOR(NSIO, 10, struct mnt_ns_info) +/* Get next namespace. */ +#define NS_MNT_GET_NEXT		_IOR(NSIO, 11, struct mnt_ns_info) +/* Get previous namespace. */ +#define NS_MNT_GET_PREV		_IOR(NSIO, 12, struct mnt_ns_info) + +enum init_ns_ino { +	IPC_NS_INIT_INO		= 0xEFFFFFFFU, +	UTS_NS_INIT_INO		= 0xEFFFFFFEU, +	USER_NS_INIT_INO	= 0xEFFFFFFDU, +	PID_NS_INIT_INO		= 0xEFFFFFFCU, +	CGROUP_NS_INIT_INO	= 0xEFFFFFFBU, +	TIME_NS_INIT_INO	= 0xEFFFFFFAU, +	NET_NS_INIT_INO		= 0xEFFFFFF9U, +	MNT_NS_INIT_INO		= 0xEFFFFFF8U, +};  #endif /* __LINUX_NSFS_H */ diff --git a/include/uapi/linux/nsm.h b/include/uapi/linux/nsm.h new file mode 100644 index 000000000000..e529f232f6c0 --- /dev/null +++ b/include/uapi/linux/nsm.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + */ + +#ifndef __UAPI_LINUX_NSM_H +#define __UAPI_LINUX_NSM_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define NSM_MAGIC		0x0A + +#define NSM_REQUEST_MAX_SIZE	0x1000 +#define NSM_RESPONSE_MAX_SIZE	0x3000 + +struct nsm_iovec { +	__u64 addr; /* Virtual address of target buffer */ +	__u64 len;  /* Length of target buffer */ +}; + +/* Raw NSM message. Only available with CAP_SYS_ADMIN. */ +struct nsm_raw { +	/* Request from user */ +	struct nsm_iovec request; +	/* Response to user */ +	struct nsm_iovec response; +}; +#define NSM_IOCTL_RAW		_IOWR(NSM_MAGIC, 0x0, struct nsm_raw) + +#endif /* __UAPI_LINUX_NSM_H */ diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h new file mode 100644 index 000000000000..6d06793512b1 --- /dev/null +++ b/include/uapi/linux/ntsync.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Kernel support for NT synchronization primitive emulation + * + * Copyright (C) 2021-2022 Elizabeth Figura <zfigura@codeweavers.com> + */ + +#ifndef __LINUX_NTSYNC_H +#define __LINUX_NTSYNC_H + +#include <linux/types.h> + +struct ntsync_sem_args { +	__u32 count; +	__u32 max; +}; + +struct ntsync_mutex_args { +	__u32 owner; +	__u32 count; +}; + +struct ntsync_event_args { +	__u32 manual; +	__u32 signaled; +}; + +#define NTSYNC_WAIT_REALTIME	0x1 + +struct ntsync_wait_args { +	__u64 timeout; +	__u64 objs; +	__u32 count; +	__u32 index; +	__u32 flags; +	__u32 owner; +	__u32 alert; +	__u32 pad; +}; + +#define NTSYNC_MAX_WAIT_COUNT 64 + +#define NTSYNC_IOC_CREATE_SEM		_IOW ('N', 0x80, struct ntsync_sem_args) +#define NTSYNC_IOC_WAIT_ANY		_IOWR('N', 0x82, struct ntsync_wait_args) +#define NTSYNC_IOC_WAIT_ALL		_IOWR('N', 0x83, struct ntsync_wait_args) +#define NTSYNC_IOC_CREATE_MUTEX		_IOW ('N', 0x84, struct ntsync_mutex_args) +#define NTSYNC_IOC_CREATE_EVENT		_IOW ('N', 0x87, struct ntsync_event_args) + +#define NTSYNC_IOC_SEM_RELEASE		_IOWR('N', 0x81, __u32) +#define NTSYNC_IOC_MUTEX_UNLOCK		_IOWR('N', 0x85, struct ntsync_mutex_args) +#define NTSYNC_IOC_MUTEX_KILL		_IOW ('N', 0x86, __u32) +#define NTSYNC_IOC_EVENT_SET		_IOR ('N', 0x88, __u32) +#define NTSYNC_IOC_EVENT_RESET		_IOR ('N', 0x89, __u32) +#define NTSYNC_IOC_EVENT_PULSE		_IOR ('N', 0x8a, __u32) +#define NTSYNC_IOC_SEM_READ		_IOR ('N', 0x8b, struct ntsync_sem_args) +#define NTSYNC_IOC_MUTEX_READ		_IOR ('N', 0x8c, struct ntsync_mutex_args) +#define NTSYNC_IOC_EVENT_READ		_IOR ('N', 0x8d, struct ntsync_event_args) + +#endif diff --git a/include/uapi/linux/nvme_ioctl.h b/include/uapi/linux/nvme_ioctl.h index d99b5a772698..2f76cba67166 100644 --- a/include/uapi/linux/nvme_ioctl.h +++ b/include/uapi/linux/nvme_ioctl.h @@ -55,7 +55,10 @@ struct nvme_passthru_cmd64 {  	__u64	metadata;  	__u64	addr;  	__u32	metadata_len; -	__u32	data_len; +	union { +		__u32	data_len; /* for non-vectored io */ +		__u32	vec_cnt; /* for vectored io */ +	};  	__u32	cdw10;  	__u32	cdw11;  	__u32	cdw12; @@ -67,6 +70,28 @@ struct nvme_passthru_cmd64 {  	__u64	result;  }; +/* same as struct nvme_passthru_cmd64, minus the 8b result field */ +struct nvme_uring_cmd { +	__u8	opcode; +	__u8	flags; +	__u16	rsvd1; +	__u32	nsid; +	__u32	cdw2; +	__u32	cdw3; +	__u64	metadata; +	__u64	addr; +	__u32	metadata_len; +	__u32	data_len; +	__u32	cdw10; +	__u32	cdw11; +	__u32	cdw12; +	__u32	cdw13; +	__u32	cdw14; +	__u32	cdw15; +	__u32	timeout_ms; +	__u32   rsvd2; +}; +  #define nvme_admin_cmd nvme_passthru_cmd  #define NVME_IOCTL_ID		_IO('N', 0x40) @@ -78,5 +103,12 @@ struct nvme_passthru_cmd64 {  #define NVME_IOCTL_RESCAN	_IO('N', 0x46)  #define NVME_IOCTL_ADMIN64_CMD	_IOWR('N', 0x47, struct nvme_passthru_cmd64)  #define NVME_IOCTL_IO64_CMD	_IOWR('N', 0x48, struct nvme_passthru_cmd64) +#define NVME_IOCTL_IO64_CMD_VEC	_IOWR('N', 0x49, struct nvme_passthru_cmd64) + +/* io_uring async commands: */ +#define NVME_URING_CMD_IO	_IOWR('N', 0x80, struct nvme_uring_cmd) +#define NVME_URING_CMD_IO_VEC	_IOWR('N', 0x81, struct nvme_uring_cmd) +#define NVME_URING_CMD_ADMIN	_IOWR('N', 0x82, struct nvme_uring_cmd) +#define NVME_URING_CMD_ADMIN_VEC _IOWR('N', 0x83, struct nvme_uring_cmd)  #endif /* _UAPI_LINUX_NVME_IOCTL_H */ diff --git a/include/uapi/linux/omap3isp.h b/include/uapi/linux/omap3isp.h index 87b55755f4ff..d9db7ad43890 100644 --- a/include/uapi/linux/omap3isp.h +++ b/include/uapi/linux/omap3isp.h @@ -162,6 +162,7 @@ struct omap3isp_h3a_aewb_config {   * struct omap3isp_stat_data - Statistic data sent to or received from user   * @ts: Timestamp of returned framestats.   * @buf: Pointer to pass to user. + * @buf_size: Size of buffer.   * @frame_number: Frame number of requested stats.   * @cur_frame: Current frame number being processed.   * @config_counter: Number of the configuration associated with the data. @@ -176,10 +177,12 @@ struct omap3isp_stat_data {  	struct timeval ts;  #endif  	void __user *buf; -	__u32 buf_size; -	__u16 frame_number; -	__u16 cur_frame; -	__u16 config_counter; +	__struct_group(/* no tag */, frame, /* no attrs */, +		__u32 buf_size; +		__u16 frame_number; +		__u16 cur_frame; +		__u16 config_counter; +	);  };  #ifdef __KERNEL__ @@ -189,10 +192,12 @@ struct omap3isp_stat_data_time32 {  		__s32	tv_usec;  	} ts;  	__u32 buf; -	__u32 buf_size; -	__u16 frame_number; -	__u16 cur_frame; -	__u16 config_counter; +	__struct_group(/* no tag */, frame, /* no attrs */, +		__u32 buf_size; +		__u16 frame_number; +		__u16 cur_frame; +		__u16 config_counter; +	);  };  #endif diff --git a/include/uapi/linux/openat2.h b/include/uapi/linux/openat2.h index 58b1eb711360..a5feb7604948 100644 --- a/include/uapi/linux/openat2.h +++ b/include/uapi/linux/openat2.h @@ -35,5 +35,9 @@ struct open_how {  #define RESOLVE_IN_ROOT		0x10 /* Make all jumps to "/" and ".."  					be scoped inside the dirfd  					(similar to chroot(2)). */ +#define RESOLVE_CACHED		0x20 /* Only complete if resolution can be +					completed through cached lookup. May +					return -EAGAIN if that's not +					possible. */  #endif /* _UAPI_LINUX_OPENAT2_H */ diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h index 8300cc29dec8..3092c2c6f1d2 100644 --- a/include/uapi/linux/openvswitch.h +++ b/include/uapi/linux/openvswitch.h @@ -70,10 +70,14 @@ enum ovs_datapath_cmd {   * set on the datapath port (for OVS_ACTION_ATTR_MISS).  Only valid on   * %OVS_DP_CMD_NEW requests. A value of zero indicates that upcalls should   * not be sent. + * @OVS_DP_ATTR_PER_CPU_PIDS: Per-cpu array of PIDs for upcalls when + * OVS_DP_F_DISPATCH_UPCALL_PER_CPU feature is set.   * @OVS_DP_ATTR_STATS: Statistics about packets that have passed through the   * datapath.  Always present in notifications.   * @OVS_DP_ATTR_MEGAFLOW_STATS: Statistics about mega flow masks usage for the   * datapath. Always present in notifications. + * @OVS_DP_ATTR_IFINDEX: Interface index for a new datapath netdev. Only + * valid for %OVS_DP_CMD_NEW requests.   *   * These attributes follow the &struct ovs_header within the Generic Netlink   * payload for %OVS_DP_* commands. @@ -87,6 +91,10 @@ enum ovs_datapath_attr {  	OVS_DP_ATTR_USER_FEATURES,	/* OVS_DP_F_*  */  	OVS_DP_ATTR_PAD,  	OVS_DP_ATTR_MASKS_CACHE_SIZE, +	OVS_DP_ATTR_PER_CPU_PIDS,   /* Netlink PIDS to receive upcalls in +				     * per-cpu dispatch mode +				     */ +	OVS_DP_ATTR_IFINDEX,  	__OVS_DP_ATTR_MAX  }; @@ -127,6 +135,9 @@ struct ovs_vport_stats {  /* Allow tc offload recirc sharing */  #define OVS_DP_F_TC_RECIRC_SHARING	(1 << 2) +/* Allow per-cpu dispatch of upcalls */ +#define OVS_DP_F_DISPATCH_UPCALL_PER_CPU	(1 << 3) +  /* Fixed logical ports. */  #define OVSP_LOCAL      ((__u32)0) @@ -175,6 +186,11 @@ enum ovs_packet_cmd {   * %OVS_PACKET_ATTR_USERSPACE action specify the Maximum received fragment   * size.   * @OVS_PACKET_ATTR_HASH: Packet hash info (e.g. hash, sw_hash and l4_hash in skb). + * @OVS_PACKET_ATTR_UPCALL_PID: Netlink PID to use for upcalls while + * processing %OVS_PACKET_CMD_EXECUTE.  Takes precedence over all other ways + * to determine the Netlink PID including %OVS_USERSPACE_ATTR_PID, + * %OVS_DP_ATTR_UPCALL_PID, %OVS_DP_ATTR_PER_CPU_PIDS and the + * %OVS_VPORT_ATTR_UPCALL_PID.   *   * These attributes follow the &struct ovs_header within the Generic Netlink   * payload for %OVS_PACKET_* commands. @@ -194,6 +210,7 @@ enum ovs_packet_attr {  	OVS_PACKET_ATTR_MRU,	    /* Maximum received IP fragment size. */  	OVS_PACKET_ATTR_LEN,	    /* Packet size before truncation. */  	OVS_PACKET_ATTR_HASH,	    /* Packet hash. */ +	OVS_PACKET_ATTR_UPCALL_PID, /* u32 Netlink PID. */  	__OVS_PACKET_ATTR_MAX  }; @@ -266,11 +283,25 @@ enum ovs_vport_attr {  	OVS_VPORT_ATTR_PAD,  	OVS_VPORT_ATTR_IFINDEX,  	OVS_VPORT_ATTR_NETNSID, +	OVS_VPORT_ATTR_UPCALL_STATS,  	__OVS_VPORT_ATTR_MAX  };  #define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1) +/** + * enum ovs_vport_upcall_attr - attributes for %OVS_VPORT_UPCALL* commands + * @OVS_VPORT_UPCALL_SUCCESS: 64-bit upcall success packets. + * @OVS_VPORT_UPCALL_FAIL: 64-bit upcall fail packets. + */ +enum ovs_vport_upcall_attr { +	OVS_VPORT_UPCALL_ATTR_SUCCESS, +	OVS_VPORT_UPCALL_ATTR_FAIL, +	__OVS_VPORT_UPCALL_ATTR_MAX +}; + +#define OVS_VPORT_UPCALL_ATTR_MAX (__OVS_VPORT_UPCALL_ATTR_MAX - 1) +  enum {  	OVS_VXLAN_EXT_UNSPEC,  	OVS_VXLAN_EXT_GBP,	/* Flag or __u32 */ @@ -344,9 +375,20 @@ enum ovs_key_attr {  	OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6,   /* struct ovs_key_ct_tuple_ipv6 */  	OVS_KEY_ATTR_NSH,       /* Nested set of ovs_nsh_key_* */ -#ifdef __KERNEL__ -	OVS_KEY_ATTR_TUNNEL_INFO,  /* struct ip_tunnel_info */ -#endif +	/* User space decided to squat on types 29 and 30.  They are defined +	 * below, but should not be sent to the kernel. +	 * +	 * WARNING: No new types should be added unless they are defined +	 *          for both kernel and user space (no 'ifdef's).  It's hard +	 *          to keep compatibility otherwise. +	 */ +	OVS_KEY_ATTR_PACKET_TYPE,   /* be32 packet type */ +	OVS_KEY_ATTR_ND_EXTENSIONS, /* IPv6 Neighbor Discovery extensions */ + +	OVS_KEY_ATTR_TUNNEL_INFO,   /* struct ip_tunnel_info. +				     * For in-kernel use only. +				     */ +	OVS_KEY_ATTR_IPV6_EXTHDRS,  /* struct ovs_key_ipv6_exthdr */  	__OVS_KEY_ATTR_MAX  }; @@ -422,6 +464,11 @@ struct ovs_key_ipv6 {  	__u8   ipv6_frag;	/* One of OVS_FRAG_TYPE_*. */  }; +/* separate structure to support backward compatibility with older user space */ +struct ovs_key_ipv6_exthdrs { +	__u16  hdrs; +}; +  struct ovs_key_tcp {  	__be16 tcp_src;  	__be16 tcp_dst; @@ -608,7 +655,8 @@ enum ovs_flow_attr {   * Actions are passed as nested attributes.   *   * Executes the specified actions with the given probability on a per-packet - * basis. + * basis. Nested actions will be able to access the probability value of the + * parent @OVS_ACTION_ATTR_SAMPLE.   */  enum ovs_sample_attr {  	OVS_SAMPLE_ATTR_UNSPEC, @@ -724,6 +772,7 @@ struct ovs_action_push_vlan {   */  enum ovs_hash_alg {  	OVS_HASH_ALG_L4, +	OVS_HASH_ALG_SYM_L4,  };  /* @@ -872,6 +921,31 @@ struct check_pkt_len_arg {  };  #endif +#define OVS_PSAMPLE_COOKIE_MAX_SIZE 16 +/** + * enum ovs_psample_attr - Attributes for %OVS_ACTION_ATTR_PSAMPLE + * action. + * + * @OVS_PSAMPLE_ATTR_GROUP: 32-bit number to identify the source of the + * sample. + * @OVS_PSAMPLE_ATTR_COOKIE: An optional variable-length binary cookie that + * contains user-defined metadata. The maximum length is + * OVS_PSAMPLE_COOKIE_MAX_SIZE bytes. + * + * Sends the packet to the psample multicast group with the specified group and + * cookie. It is possible to combine this action with the + * %OVS_ACTION_ATTR_TRUNC action to limit the size of the sample. + */ +enum ovs_psample_attr { +	OVS_PSAMPLE_ATTR_GROUP = 1,	/* u32 number. */ +	OVS_PSAMPLE_ATTR_COOKIE,	/* Optional, user specified cookie. */ + +	/* private: */ +	__OVS_PSAMPLE_ATTR_MAX +}; + +#define OVS_PSAMPLE_ATTR_MAX (__OVS_PSAMPLE_ATTR_MAX - 1) +  /**   * enum ovs_action_attr - Action types.   * @@ -923,6 +997,9 @@ struct check_pkt_len_arg {   * start of the packet or at the start of the l3 header depending on the value   * of l3 tunnel flag in the tun_flags field of OVS_ACTION_ATTR_ADD_MPLS   * argument. + * @OVS_ACTION_ATTR_DROP: Explicit drop action. + * @OVS_ACTION_ATTR_PSAMPLE: Send a sample of the packet to external observers + * via psample.   *   * Only a single header can be set with a single %OVS_ACTION_ATTR_SET.  Not all   * fields within a header are modifiable, e.g. the IPv4 protocol and fragment @@ -960,6 +1037,8 @@ enum ovs_action_attr {  	OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */  	OVS_ACTION_ATTR_ADD_MPLS,     /* struct ovs_action_add_mpls. */  	OVS_ACTION_ATTR_DEC_TTL,      /* Nested OVS_DEC_TTL_ATTR_*. */ +	OVS_ACTION_ATTR_DROP,         /* u32 error code. */ +	OVS_ACTION_ATTR_PSAMPLE,      /* Nested OVS_PSAMPLE_ATTR_*. */  	__OVS_ACTION_ATTR_MAX,	      /* Nothing past this will be accepted  				       * from userspace. */ @@ -1058,4 +1137,6 @@ enum ovs_dec_ttl_attr {  	__OVS_DEC_TTL_ATTR_MAX  }; +#define OVS_DEC_TTL_ATTR_MAX (__OVS_DEC_TTL_ATTR_MAX - 1) +  #endif /* _LINUX_OPENVSWITCH_H */ diff --git a/include/uapi/linux/ovpn.h b/include/uapi/linux/ovpn.h new file mode 100644 index 000000000000..680d1522dc87 --- /dev/null +++ b/include/uapi/linux/ovpn.h @@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/*	Documentation/netlink/specs/ovpn.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_OVPN_H +#define _UAPI_LINUX_OVPN_H + +#define OVPN_FAMILY_NAME	"ovpn" +#define OVPN_FAMILY_VERSION	1 + +#define OVPN_NONCE_TAIL_SIZE	8 + +enum ovpn_cipher_alg { +	OVPN_CIPHER_ALG_NONE, +	OVPN_CIPHER_ALG_AES_GCM, +	OVPN_CIPHER_ALG_CHACHA20_POLY1305, +}; + +enum ovpn_del_peer_reason { +	OVPN_DEL_PEER_REASON_TEARDOWN, +	OVPN_DEL_PEER_REASON_USERSPACE, +	OVPN_DEL_PEER_REASON_EXPIRED, +	OVPN_DEL_PEER_REASON_TRANSPORT_ERROR, +	OVPN_DEL_PEER_REASON_TRANSPORT_DISCONNECT, +}; + +enum ovpn_key_slot { +	OVPN_KEY_SLOT_PRIMARY, +	OVPN_KEY_SLOT_SECONDARY, +}; + +enum { +	OVPN_A_PEER_ID = 1, +	OVPN_A_PEER_REMOTE_IPV4, +	OVPN_A_PEER_REMOTE_IPV6, +	OVPN_A_PEER_REMOTE_IPV6_SCOPE_ID, +	OVPN_A_PEER_REMOTE_PORT, +	OVPN_A_PEER_SOCKET, +	OVPN_A_PEER_SOCKET_NETNSID, +	OVPN_A_PEER_VPN_IPV4, +	OVPN_A_PEER_VPN_IPV6, +	OVPN_A_PEER_LOCAL_IPV4, +	OVPN_A_PEER_LOCAL_IPV6, +	OVPN_A_PEER_LOCAL_PORT, +	OVPN_A_PEER_KEEPALIVE_INTERVAL, +	OVPN_A_PEER_KEEPALIVE_TIMEOUT, +	OVPN_A_PEER_DEL_REASON, +	OVPN_A_PEER_VPN_RX_BYTES, +	OVPN_A_PEER_VPN_TX_BYTES, +	OVPN_A_PEER_VPN_RX_PACKETS, +	OVPN_A_PEER_VPN_TX_PACKETS, +	OVPN_A_PEER_LINK_RX_BYTES, +	OVPN_A_PEER_LINK_TX_BYTES, +	OVPN_A_PEER_LINK_RX_PACKETS, +	OVPN_A_PEER_LINK_TX_PACKETS, + +	__OVPN_A_PEER_MAX, +	OVPN_A_PEER_MAX = (__OVPN_A_PEER_MAX - 1) +}; + +enum { +	OVPN_A_KEYCONF_PEER_ID = 1, +	OVPN_A_KEYCONF_SLOT, +	OVPN_A_KEYCONF_KEY_ID, +	OVPN_A_KEYCONF_CIPHER_ALG, +	OVPN_A_KEYCONF_ENCRYPT_DIR, +	OVPN_A_KEYCONF_DECRYPT_DIR, + +	__OVPN_A_KEYCONF_MAX, +	OVPN_A_KEYCONF_MAX = (__OVPN_A_KEYCONF_MAX - 1) +}; + +enum { +	OVPN_A_KEYDIR_CIPHER_KEY = 1, +	OVPN_A_KEYDIR_NONCE_TAIL, + +	__OVPN_A_KEYDIR_MAX, +	OVPN_A_KEYDIR_MAX = (__OVPN_A_KEYDIR_MAX - 1) +}; + +enum { +	OVPN_A_IFINDEX = 1, +	OVPN_A_PEER, +	OVPN_A_KEYCONF, + +	__OVPN_A_MAX, +	OVPN_A_MAX = (__OVPN_A_MAX - 1) +}; + +enum { +	OVPN_CMD_PEER_NEW = 1, +	OVPN_CMD_PEER_SET, +	OVPN_CMD_PEER_GET, +	OVPN_CMD_PEER_DEL, +	OVPN_CMD_PEER_DEL_NTF, +	OVPN_CMD_KEY_NEW, +	OVPN_CMD_KEY_GET, +	OVPN_CMD_KEY_SWAP, +	OVPN_CMD_KEY_SWAP_NTF, +	OVPN_CMD_KEY_DEL, + +	__OVPN_CMD_MAX, +	OVPN_CMD_MAX = (__OVPN_CMD_MAX - 1) +}; + +#define OVPN_MCGRP_PEERS	"peers" + +#endif /* _UAPI_LINUX_OVPN_H */ diff --git a/include/uapi/linux/papr_pdsm.h b/include/uapi/linux/papr_pdsm.h new file mode 100644 index 000000000000..17439925045c --- /dev/null +++ b/include/uapi/linux/papr_pdsm.h @@ -0,0 +1,165 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * PAPR nvDimm Specific Methods (PDSM) and structs for libndctl + * + * (C) Copyright IBM 2020 + * + * Author: Vaibhav Jain <vaibhav at linux.ibm.com> + */ + +#ifndef _UAPI_ASM_POWERPC_PAPR_PDSM_H_ +#define _UAPI_ASM_POWERPC_PAPR_PDSM_H_ + +#include <linux/types.h> +#include <linux/ndctl.h> + +/* + * PDSM Envelope: + * + * The ioctl ND_CMD_CALL exchange data between user-space and kernel via + * envelope which consists of 2 headers sections and payload sections as + * illustrated below: + *  +-----------------+---------------+---------------------------+ + *  |   64-Bytes      |   8-Bytes     |       Max 184-Bytes       | + *  +-----------------+---------------+---------------------------+ + *  | ND-HEADER       |  PDSM-HEADER  |      PDSM-PAYLOAD         | + *  +-----------------+---------------+---------------------------+ + *  | nd_family       |               |                           | + *  | nd_size_out     | cmd_status    |                           | + *  | nd_size_in      | reserved      |     nd_pdsm_payload       | + *  | nd_command      | payload   --> |                           | + *  | nd_fw_size      |               |                           | + *  | nd_payload ---> |               |                           | + *  +---------------+-----------------+---------------------------+ + * + * ND Header: + * This is the generic libnvdimm header described as 'struct nd_cmd_pkg' + * which is interpreted by libnvdimm before passed on to papr_scm. Important + * member fields used are: + * 'nd_family'		: (In) NVDIMM_FAMILY_PAPR_SCM + * 'nd_size_in'		: (In) PDSM-HEADER + PDSM-IN-PAYLOAD (usually 0) + * 'nd_size_out'        : (In) PDSM-HEADER + PDSM-RETURN-PAYLOAD + * 'nd_command'         : (In) One of PAPR_PDSM_XXX + * 'nd_fw_size'         : (Out) PDSM-HEADER + size of actual payload returned + * + * PDSM Header: + * This is papr-scm specific header that precedes the payload. This is defined + * as nd_cmd_pdsm_pkg.  Following fields aare available in this header: + * + * 'cmd_status'		: (Out) Errors if any encountered while servicing PDSM. + * 'reserved'		: Not used, reserved for future and should be set to 0. + * 'payload'            : A union of all the possible payload structs + * + * PDSM Payload: + * + * The layout of the PDSM Payload is defined by various structs shared between + * papr_scm and libndctl so that contents of payload can be interpreted. As such + * its defined as a union of all possible payload structs as + * 'union nd_pdsm_payload'. Based on the value of 'nd_cmd_pkg.nd_command' + * appropriate member of the union is accessed. + */ + +/* Max payload size that we can handle */ +#define ND_PDSM_PAYLOAD_MAX_SIZE 184 + +/* Max payload size that we can handle */ +#define ND_PDSM_HDR_SIZE \ +	(sizeof(struct nd_pkg_pdsm) - ND_PDSM_PAYLOAD_MAX_SIZE) + +/* Various nvdimm health indicators */ +#define PAPR_PDSM_DIMM_HEALTHY       0 +#define PAPR_PDSM_DIMM_UNHEALTHY     1 +#define PAPR_PDSM_DIMM_CRITICAL      2 +#define PAPR_PDSM_DIMM_FATAL         3 + +/* struct nd_papr_pdsm_health.extension_flags field flags */ + +/* Indicate that the 'dimm_fuel_gauge' field is valid */ +#define PDSM_DIMM_HEALTH_RUN_GAUGE_VALID 1 + +/* Indicate that the 'dimm_dsc' field is valid */ +#define PDSM_DIMM_DSC_VALID 2 + +/* + * Struct exchanged between kernel & ndctl in for PAPR_PDSM_HEALTH + * Various flags indicate the health status of the dimm. + * + * extension_flags	: Any extension fields present in the struct. + * dimm_unarmed		: Dimm not armed. So contents wont persist. + * dimm_bad_shutdown	: Previous shutdown did not persist contents. + * dimm_bad_restore	: Contents from previous shutdown werent restored. + * dimm_scrubbed	: Contents of the dimm have been scrubbed. + * dimm_locked		: Contents of the dimm cant be modified until CEC reboot + * dimm_encrypted	: Contents of dimm are encrypted. + * dimm_health		: Dimm health indicator. One of PAPR_PDSM_DIMM_XXXX + * dimm_fuel_gauge	: Life remaining of DIMM as a percentage from 0-100 + */ +struct nd_papr_pdsm_health { +	union { +		struct { +			__u32 extension_flags; +			__u8 dimm_unarmed; +			__u8 dimm_bad_shutdown; +			__u8 dimm_bad_restore; +			__u8 dimm_scrubbed; +			__u8 dimm_locked; +			__u8 dimm_encrypted; +			__u16 dimm_health; + +			/* Extension flag PDSM_DIMM_HEALTH_RUN_GAUGE_VALID */ +			__u16 dimm_fuel_gauge; + +			/* Extension flag PDSM_DIMM_DSC_VALID */ +			__u64 dimm_dsc; +		}; +		__u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE]; +	}; +}; + +/* Flags for injecting specific smart errors */ +#define PDSM_SMART_INJECT_HEALTH_FATAL		(1 << 0) +#define PDSM_SMART_INJECT_BAD_SHUTDOWN		(1 << 1) + +struct nd_papr_pdsm_smart_inject { +	union { +		struct { +			/* One or more of PDSM_SMART_INJECT_ */ +			__u32 flags; +			__u8 fatal_enable; +			__u8 unsafe_shutdown_enable; +		}; +		__u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE]; +	}; +}; + +/* + * Methods to be embedded in ND_CMD_CALL request. These are sent to the kernel + * via 'nd_cmd_pkg.nd_command' member of the ioctl struct + */ +enum papr_pdsm { +	PAPR_PDSM_MIN = 0x0, +	PAPR_PDSM_HEALTH, +	PAPR_PDSM_SMART_INJECT, +	PAPR_PDSM_MAX, +}; + +/* Maximal union that can hold all possible payload types */ +union nd_pdsm_payload { +	struct nd_papr_pdsm_health health; +	struct nd_papr_pdsm_smart_inject smart_inject; +	__u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE]; +} __packed; + +/* + * PDSM-header + payload expected with ND_CMD_CALL ioctl from libnvdimm + * Valid member of union 'payload' is identified via 'nd_cmd_pkg.nd_command' + * that should always precede this struct when sent to papr_scm via CMD_CALL + * interface. + */ +struct nd_pkg_pdsm { +	__s32 cmd_status;	/* Out: Sub-cmd status returned back */ +	__u16 reserved[2];	/* Ignored and to be set as '0' */ +	union nd_pdsm_payload payload; +} __packed; + +#endif /* _UAPI_ASM_POWERPC_PAPR_PDSM_H_ */ diff --git a/include/uapi/linux/parport.h b/include/uapi/linux/parport.h index f41388f88dc3..fe93e41fc205 100644 --- a/include/uapi/linux/parport.h +++ b/include/uapi/linux/parport.h @@ -90,6 +90,9 @@ typedef enum {  /* Flags for block transfer operations. */  #define PARPORT_EPP_FAST		(1<<0) /* Unreliable counts. */  #define PARPORT_W91284PIC		(1<<1) /* have a Warp9 w91284pic in the device */ +#define PARPORT_EPP_FAST_32		PARPORT_EPP_FAST /* 32-bit EPP transfers */ +#define PARPORT_EPP_FAST_16		(1<<2) /* 16-bit EPP transfers */ +#define PARPORT_EPP_FAST_8		(1<<3) /* 8-bit EPP transfers */  /* The rest is for the kernel only */  #endif /* _UAPI_PARPORT_H_ */ diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index f9701410d3b5..f5b17745de60 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -76,9 +76,11 @@  #define PCI_CACHE_LINE_SIZE	0x0c	/* 8 bits */  #define PCI_LATENCY_TIMER	0x0d	/* 8 bits */  #define PCI_HEADER_TYPE		0x0e	/* 8 bits */ +#define  PCI_HEADER_TYPE_MASK		0x7f  #define  PCI_HEADER_TYPE_NORMAL		0  #define  PCI_HEADER_TYPE_BRIDGE		1  #define  PCI_HEADER_TYPE_CARDBUS	2 +#define  PCI_HEADER_TYPE_MFD		0x80	/* Multi-Function Device (possible) */  #define PCI_BIST		0x0f	/* 8 bits */  #define  PCI_BIST_CODE_MASK	0x0f	/* Return result */ @@ -246,7 +248,7 @@  #define  PCI_PM_CAP_PME_D0	0x0800	/* PME# from D0 */  #define  PCI_PM_CAP_PME_D1	0x1000	/* PME# from D1 */  #define  PCI_PM_CAP_PME_D2	0x2000	/* PME# from D2 */ -#define  PCI_PM_CAP_PME_D3	0x4000	/* PME# from D3 (hot) */ +#define  PCI_PM_CAP_PME_D3hot	0x4000	/* PME# from D3 (hot) */  #define  PCI_PM_CAP_PME_D3cold	0x8000	/* PME# from D3 (cold) */  #define  PCI_PM_CAP_PME_SHIFT	11	/* Start of the PME Mask in PMC */  #define PCI_PM_CTRL		4	/* PM control and status register */ @@ -300,23 +302,23 @@  #define  PCI_SID_ESR_FIC	0x20	/* First In Chassis Flag */  #define PCI_SID_CHASSIS_NR	3	/* Chassis Number */ -/* Message Signalled Interrupt registers */ +/* Message Signaled Interrupt registers */ -#define PCI_MSI_FLAGS		2	/* Message Control */ +#define PCI_MSI_FLAGS		0x02	/* Message Control */  #define  PCI_MSI_FLAGS_ENABLE	0x0001	/* MSI feature enabled */  #define  PCI_MSI_FLAGS_QMASK	0x000e	/* Maximum queue size available */  #define  PCI_MSI_FLAGS_QSIZE	0x0070	/* Message queue size configured */  #define  PCI_MSI_FLAGS_64BIT	0x0080	/* 64-bit addresses allowed */  #define  PCI_MSI_FLAGS_MASKBIT	0x0100	/* Per-vector masking capable */  #define PCI_MSI_RFU		3	/* Rest of capability flags */ -#define PCI_MSI_ADDRESS_LO	4	/* Lower 32 bits */ -#define PCI_MSI_ADDRESS_HI	8	/* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ -#define PCI_MSI_DATA_32		8	/* 16 bits of data for 32-bit devices */ -#define PCI_MSI_MASK_32		12	/* Mask bits register for 32-bit devices */ -#define PCI_MSI_PENDING_32	16	/* Pending intrs for 32-bit devices */ -#define PCI_MSI_DATA_64		12	/* 16 bits of data for 64-bit devices */ -#define PCI_MSI_MASK_64		16	/* Mask bits register for 64-bit devices */ -#define PCI_MSI_PENDING_64	20	/* Pending intrs for 64-bit devices */ +#define PCI_MSI_ADDRESS_LO	0x04	/* Lower 32 bits */ +#define PCI_MSI_ADDRESS_HI	0x08	/* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ +#define PCI_MSI_DATA_32		0x08	/* 16 bits of data for 32-bit devices */ +#define PCI_MSI_MASK_32		0x0c	/* Mask bits register for 32-bit devices */ +#define PCI_MSI_PENDING_32	0x10	/* Pending intrs for 32-bit devices */ +#define PCI_MSI_DATA_64		0x0c	/* 16 bits of data for 64-bit devices */ +#define PCI_MSI_MASK_64		0x10	/* Mask bits register for 64-bit devices */ +#define PCI_MSI_PENDING_64	0x14	/* Pending intrs for 64-bit devices */  /* MSI-X registers (in MSI-X capability) */  #define PCI_MSIX_FLAGS		2	/* Message Control */ @@ -334,11 +336,12 @@  /* MSI-X Table entry format (in memory mapped by a BAR) */  #define PCI_MSIX_ENTRY_SIZE		16 -#define PCI_MSIX_ENTRY_LOWER_ADDR	0  /* Message Address */ -#define PCI_MSIX_ENTRY_UPPER_ADDR	4  /* Message Upper Address */ -#define PCI_MSIX_ENTRY_DATA		8  /* Message Data */ -#define PCI_MSIX_ENTRY_VECTOR_CTRL	12 /* Vector Control */ -#define  PCI_MSIX_ENTRY_CTRL_MASKBIT	0x00000001 +#define PCI_MSIX_ENTRY_LOWER_ADDR	0x0  /* Message Address */ +#define PCI_MSIX_ENTRY_UPPER_ADDR	0x4  /* Message Upper Address */ +#define PCI_MSIX_ENTRY_DATA		0x8  /* Message Data */ +#define PCI_MSIX_ENTRY_VECTOR_CTRL	0xc  /* Vector Control */ +#define  PCI_MSIX_ENTRY_CTRL_MASKBIT	0x00000001  /* Mask Bit */ +#define  PCI_MSIX_ENTRY_CTRL_ST		0xffff0000  /* Steering Tag */  /* CompactPCI Hotswap Register */ @@ -469,7 +472,7 @@  /* PCI Express capability registers */ -#define PCI_EXP_FLAGS		2	/* Capabilities register */ +#define PCI_EXP_FLAGS		0x02	/* Capabilities register */  #define  PCI_EXP_FLAGS_VERS	0x000f	/* Capability version */  #define  PCI_EXP_FLAGS_TYPE	0x00f0	/* Device/Port type */  #define   PCI_EXP_TYPE_ENDPOINT	   0x0	/* Express Endpoint */ @@ -483,7 +486,8 @@  #define   PCI_EXP_TYPE_RC_EC	   0xa	/* Root Complex Event Collector */  #define  PCI_EXP_FLAGS_SLOT	0x0100	/* Slot implemented */  #define  PCI_EXP_FLAGS_IRQ	0x3e00	/* Interrupt message number */ -#define PCI_EXP_DEVCAP		4	/* Device capabilities */ +#define  PCI_EXP_FLAGS_FLIT	0x8000	/* Flit Mode Supported */ +#define PCI_EXP_DEVCAP		0x04	/* Device capabilities */  #define  PCI_EXP_DEVCAP_PAYLOAD	0x00000007 /* Max_Payload_Size */  #define  PCI_EXP_DEVCAP_PHANTOM	0x00000018 /* Phantom functions */  #define  PCI_EXP_DEVCAP_EXT_TAG	0x00000020 /* Extended tags */ @@ -496,13 +500,19 @@  #define  PCI_EXP_DEVCAP_PWR_VAL	0x03fc0000 /* Slot Power Limit Value */  #define  PCI_EXP_DEVCAP_PWR_SCL	0x0c000000 /* Slot Power Limit Scale */  #define  PCI_EXP_DEVCAP_FLR     0x10000000 /* Function Level Reset */ -#define PCI_EXP_DEVCTL		8	/* Device Control */ +#define PCI_EXP_DEVCTL		0x08	/* Device Control */  #define  PCI_EXP_DEVCTL_CERE	0x0001	/* Correctable Error Reporting En. */  #define  PCI_EXP_DEVCTL_NFERE	0x0002	/* Non-Fatal Error Reporting Enable */  #define  PCI_EXP_DEVCTL_FERE	0x0004	/* Fatal Error Reporting Enable */  #define  PCI_EXP_DEVCTL_URRE	0x0008	/* Unsupported Request Reporting En. */  #define  PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */  #define  PCI_EXP_DEVCTL_PAYLOAD	0x00e0	/* Max_Payload_Size */ +#define  PCI_EXP_DEVCTL_PAYLOAD_128B 0x0000 /* 128 Bytes */ +#define  PCI_EXP_DEVCTL_PAYLOAD_256B 0x0020 /* 256 Bytes */ +#define  PCI_EXP_DEVCTL_PAYLOAD_512B 0x0040 /* 512 Bytes */ +#define  PCI_EXP_DEVCTL_PAYLOAD_1024B 0x0060 /* 1024 Bytes */ +#define  PCI_EXP_DEVCTL_PAYLOAD_2048B 0x0080 /* 2048 Bytes */ +#define  PCI_EXP_DEVCTL_PAYLOAD_4096B 0x00a0 /* 4096 Bytes */  #define  PCI_EXP_DEVCTL_EXT_TAG	0x0100	/* Extended Tag Field Enable */  #define  PCI_EXP_DEVCTL_PHANTOM	0x0200	/* Phantom Functions Enable */  #define  PCI_EXP_DEVCTL_AUX_PME	0x0400	/* Auxiliary Power PM Enable */ @@ -515,7 +525,7 @@  #define  PCI_EXP_DEVCTL_READRQ_2048B 0x4000 /* 2048 Bytes */  #define  PCI_EXP_DEVCTL_READRQ_4096B 0x5000 /* 4096 Bytes */  #define  PCI_EXP_DEVCTL_BCR_FLR 0x8000  /* Bridge Configuration Retry / FLR */ -#define PCI_EXP_DEVSTA		10	/* Device Status */ +#define PCI_EXP_DEVSTA		0x0a	/* Device Status */  #define  PCI_EXP_DEVSTA_CED	0x0001	/* Correctable Error Detected */  #define  PCI_EXP_DEVSTA_NFED	0x0002	/* Non-Fatal Error Detected */  #define  PCI_EXP_DEVSTA_FED	0x0004	/* Fatal Error Detected */ @@ -523,15 +533,18 @@  #define  PCI_EXP_DEVSTA_AUXPD	0x0010	/* AUX Power Detected */  #define  PCI_EXP_DEVSTA_TRPND	0x0020	/* Transactions Pending */  #define PCI_CAP_EXP_RC_ENDPOINT_SIZEOF_V1	12	/* v1 endpoints without link end here */ -#define PCI_EXP_LNKCAP		12	/* Link Capabilities */ -#define  PCI_EXP_LNKCAP_SLS	0x0000000f /* Supported Link Speeds */ +#define PCI_EXP_LNKCAP		0x0c	/* Link Capabilities */ +#define  PCI_EXP_LNKCAP_SLS	0x0000000f /* Max Link Speed (prior to PCIe r3.0: Supported Link Speeds) */  #define  PCI_EXP_LNKCAP_SLS_2_5GB 0x00000001 /* LNKCAP2 SLS Vector bit 0 */  #define  PCI_EXP_LNKCAP_SLS_5_0GB 0x00000002 /* LNKCAP2 SLS Vector bit 1 */  #define  PCI_EXP_LNKCAP_SLS_8_0GB 0x00000003 /* LNKCAP2 SLS Vector bit 2 */  #define  PCI_EXP_LNKCAP_SLS_16_0GB 0x00000004 /* LNKCAP2 SLS Vector bit 3 */  #define  PCI_EXP_LNKCAP_SLS_32_0GB 0x00000005 /* LNKCAP2 SLS Vector bit 4 */ +#define  PCI_EXP_LNKCAP_SLS_64_0GB 0x00000006 /* LNKCAP2 SLS Vector bit 5 */  #define  PCI_EXP_LNKCAP_MLW	0x000003f0 /* Maximum Link Width */  #define  PCI_EXP_LNKCAP_ASPMS	0x00000c00 /* ASPM Support */ +#define  PCI_EXP_LNKCAP_ASPM_L0S 0x00000400 /* ASPM L0s Support */ +#define  PCI_EXP_LNKCAP_ASPM_L1  0x00000800 /* ASPM L1 Support */  #define  PCI_EXP_LNKCAP_L0SEL	0x00007000 /* L0s Exit Latency */  #define  PCI_EXP_LNKCAP_L1EL	0x00038000 /* L1 Exit Latency */  #define  PCI_EXP_LNKCAP_CLKPM	0x00040000 /* Clock Power Management */ @@ -539,7 +552,7 @@  #define  PCI_EXP_LNKCAP_DLLLARC	0x00100000 /* Data Link Layer Link Active Reporting Capable */  #define  PCI_EXP_LNKCAP_LBNC	0x00200000 /* Link Bandwidth Notification Capability */  #define  PCI_EXP_LNKCAP_PN	0xff000000 /* Port Number */ -#define PCI_EXP_LNKCTL		16	/* Link Control */ +#define PCI_EXP_LNKCTL		0x10	/* Link Control */  #define  PCI_EXP_LNKCTL_ASPMC	0x0003	/* ASPM Control */  #define  PCI_EXP_LNKCTL_ASPM_L0S 0x0001	/* L0s Enable */  #define  PCI_EXP_LNKCTL_ASPM_L1  0x0002	/* L1 Enable */ @@ -552,13 +565,14 @@  #define  PCI_EXP_LNKCTL_HAWD	0x0200	/* Hardware Autonomous Width Disable */  #define  PCI_EXP_LNKCTL_LBMIE	0x0400	/* Link Bandwidth Management Interrupt Enable */  #define  PCI_EXP_LNKCTL_LABIE	0x0800	/* Link Autonomous Bandwidth Interrupt Enable */ -#define PCI_EXP_LNKSTA		18	/* Link Status */ +#define PCI_EXP_LNKSTA		0x12	/* Link Status */  #define  PCI_EXP_LNKSTA_CLS	0x000f	/* Current Link Speed */  #define  PCI_EXP_LNKSTA_CLS_2_5GB 0x0001 /* Current Link Speed 2.5GT/s */  #define  PCI_EXP_LNKSTA_CLS_5_0GB 0x0002 /* Current Link Speed 5.0GT/s */  #define  PCI_EXP_LNKSTA_CLS_8_0GB 0x0003 /* Current Link Speed 8.0GT/s */  #define  PCI_EXP_LNKSTA_CLS_16_0GB 0x0004 /* Current Link Speed 16.0GT/s */  #define  PCI_EXP_LNKSTA_CLS_32_0GB 0x0005 /* Current Link Speed 32.0GT/s */ +#define  PCI_EXP_LNKSTA_CLS_64_0GB 0x0006 /* Current Link Speed 64.0GT/s */  #define  PCI_EXP_LNKSTA_NLW	0x03f0	/* Negotiated Link Width */  #define  PCI_EXP_LNKSTA_NLW_X1	0x0010	/* Current Link Width x1 */  #define  PCI_EXP_LNKSTA_NLW_X2	0x0020	/* Current Link Width x2 */ @@ -571,7 +585,7 @@  #define  PCI_EXP_LNKSTA_LBMS	0x4000	/* Link Bandwidth Management Status */  #define  PCI_EXP_LNKSTA_LABS	0x8000	/* Link Autonomous Bandwidth Status */  #define PCI_CAP_EXP_ENDPOINT_SIZEOF_V1	20	/* v1 endpoints with link end here */ -#define PCI_EXP_SLTCAP		20	/* Slot Capabilities */ +#define PCI_EXP_SLTCAP		0x14	/* Slot Capabilities */  #define  PCI_EXP_SLTCAP_ABP	0x00000001 /* Attention Button Present */  #define  PCI_EXP_SLTCAP_PCP	0x00000002 /* Power Controller Present */  #define  PCI_EXP_SLTCAP_MRLSP	0x00000004 /* MRL Sensor Present */ @@ -584,7 +598,7 @@  #define  PCI_EXP_SLTCAP_EIP	0x00020000 /* Electromechanical Interlock Present */  #define  PCI_EXP_SLTCAP_NCCS	0x00040000 /* No Command Completed Support */  #define  PCI_EXP_SLTCAP_PSN	0xfff80000 /* Physical Slot Number */ -#define PCI_EXP_SLTCTL		24	/* Slot Control */ +#define PCI_EXP_SLTCTL		0x18	/* Slot Control */  #define  PCI_EXP_SLTCTL_ABPE	0x0001	/* Attention Button Pressed Enable */  #define  PCI_EXP_SLTCTL_PFDE	0x0002	/* Power Fault Detected Enable */  #define  PCI_EXP_SLTCTL_MRLSCE	0x0004	/* MRL Sensor Changed Enable */ @@ -605,8 +619,9 @@  #define  PCI_EXP_SLTCTL_PWR_OFF        0x0400 /* Power Off */  #define  PCI_EXP_SLTCTL_EIC	0x0800	/* Electromechanical Interlock Control */  #define  PCI_EXP_SLTCTL_DLLSCE	0x1000	/* Data Link Layer State Changed Enable */ +#define  PCI_EXP_SLTCTL_ASPL_DISABLE	0x2000 /* Auto Slot Power Limit Disable */  #define  PCI_EXP_SLTCTL_IBPD_DISABLE	0x4000 /* In-band PD disable */ -#define PCI_EXP_SLTSTA		26	/* Slot Status */ +#define PCI_EXP_SLTSTA		0x1a	/* Slot Status */  #define  PCI_EXP_SLTSTA_ABP	0x0001	/* Attention Button Pressed */  #define  PCI_EXP_SLTSTA_PFD	0x0002	/* Power Fault Detected */  #define  PCI_EXP_SLTSTA_MRLSC	0x0004	/* MRL Sensor Changed */ @@ -616,15 +631,18 @@  #define  PCI_EXP_SLTSTA_PDS	0x0040	/* Presence Detect State */  #define  PCI_EXP_SLTSTA_EIS	0x0080	/* Electromechanical Interlock Status */  #define  PCI_EXP_SLTSTA_DLLSC	0x0100	/* Data Link Layer State Changed */ -#define PCI_EXP_RTCTL		28	/* Root Control */ +#define PCI_EXP_RTCTL		0x1c	/* Root Control */  #define  PCI_EXP_RTCTL_SECEE	0x0001	/* System Error on Correctable Error */  #define  PCI_EXP_RTCTL_SENFEE	0x0002	/* System Error on Non-Fatal Error */  #define  PCI_EXP_RTCTL_SEFEE	0x0004	/* System Error on Fatal Error */  #define  PCI_EXP_RTCTL_PMEIE	0x0008	/* PME Interrupt Enable */ -#define  PCI_EXP_RTCTL_CRSSVE	0x0010	/* CRS Software Visibility Enable */ -#define PCI_EXP_RTCAP		30	/* Root Capabilities */ -#define  PCI_EXP_RTCAP_CRSVIS	0x0001	/* CRS Software Visibility capability */ -#define PCI_EXP_RTSTA		32	/* Root Status */ +#define  PCI_EXP_RTCTL_RRS_SVE	0x0010	/* Config RRS Software Visibility Enable */ +#define  PCI_EXP_RTCTL_CRSSVE PCI_EXP_RTCTL_RRS_SVE /* compatibility */ +#define PCI_EXP_RTCAP		0x1e	/* Root Capabilities */ +#define  PCI_EXP_RTCAP_RRS_SV	0x0001	/* Config RRS Software Visibility */ +#define  PCI_EXP_RTCAP_CRSVIS PCI_EXP_RTCAP_RRS_SV /* compatibility */ +#define PCI_EXP_RTSTA		0x20	/* Root Status */ +#define  PCI_EXP_RTSTA_PME_RQ_ID 0x0000ffff /* PME Requester ID */  #define  PCI_EXP_RTSTA_PME	0x00010000 /* PME status */  #define  PCI_EXP_RTSTA_PENDING	0x00020000 /* PME pending */  /* @@ -635,7 +653,7 @@   * Use pcie_capability_read_word() and similar interfaces to use them   * safely.   */ -#define PCI_EXP_DEVCAP2		36	/* Device Capabilities 2 */ +#define PCI_EXP_DEVCAP2		0x24	/* Device Capabilities 2 */  #define  PCI_EXP_DEVCAP2_COMP_TMOUT_DIS	0x00000010 /* Completion Timeout Disable supported */  #define  PCI_EXP_DEVCAP2_ARI		0x00000020 /* Alternative Routing-ID */  #define  PCI_EXP_DEVCAP2_ATOMIC_ROUTE	0x00000040 /* Atomic Op routing */ @@ -643,11 +661,13 @@  #define  PCI_EXP_DEVCAP2_ATOMIC_COMP64	0x00000100 /* 64b AtomicOp completion */  #define  PCI_EXP_DEVCAP2_ATOMIC_COMP128	0x00000200 /* 128b AtomicOp completion */  #define  PCI_EXP_DEVCAP2_LTR		0x00000800 /* Latency tolerance reporting */ +#define  PCI_EXP_DEVCAP2_TPH_COMP_MASK	0x00003000 /* TPH completer support */  #define  PCI_EXP_DEVCAP2_OBFF_MASK	0x000c0000 /* OBFF support mechanism */  #define  PCI_EXP_DEVCAP2_OBFF_MSG	0x00040000 /* New message signaling */  #define  PCI_EXP_DEVCAP2_OBFF_WAKE	0x00080000 /* Re-use WAKE# for OBFF */  #define  PCI_EXP_DEVCAP2_EE_PREFIX	0x00200000 /* End-End TLP Prefix */ -#define PCI_EXP_DEVCTL2		40	/* Device Control 2 */ +#define  PCI_EXP_DEVCAP2_EE_PREFIX_MAX	0x00c00000 /* Max End-End TLP Prefixes */ +#define PCI_EXP_DEVCTL2		0x28	/* Device Control 2 */  #define  PCI_EXP_DEVCTL2_COMP_TIMEOUT	0x000f	/* Completion Timeout Value */  #define  PCI_EXP_DEVCTL2_COMP_TMOUT_DIS	0x0010	/* Completion Timeout Disable */  #define  PCI_EXP_DEVCTL2_ARI		0x0020	/* Alternative Routing-ID */ @@ -659,31 +679,35 @@  #define  PCI_EXP_DEVCTL2_OBFF_MSGA_EN	0x2000	/* Enable OBFF Message type A */  #define  PCI_EXP_DEVCTL2_OBFF_MSGB_EN	0x4000	/* Enable OBFF Message type B */  #define  PCI_EXP_DEVCTL2_OBFF_WAKE_EN	0x6000	/* OBFF using WAKE# signaling */ -#define PCI_EXP_DEVSTA2		42	/* Device Status 2 */ -#define PCI_CAP_EXP_RC_ENDPOINT_SIZEOF_V2	44	/* v2 endpoints without link end here */ -#define PCI_EXP_LNKCAP2		44	/* Link Capabilities 2 */ +#define PCI_EXP_DEVSTA2		0x2a	/* Device Status 2 */ +#define PCI_CAP_EXP_RC_ENDPOINT_SIZEOF_V2 0x2c	/* end of v2 EPs w/o link */ +#define PCI_EXP_LNKCAP2		0x2c	/* Link Capabilities 2 */ +#define  PCI_EXP_LNKCAP2_SLS		0x000000fe /* Supported Link Speeds Vector */  #define  PCI_EXP_LNKCAP2_SLS_2_5GB	0x00000002 /* Supported Speed 2.5GT/s */  #define  PCI_EXP_LNKCAP2_SLS_5_0GB	0x00000004 /* Supported Speed 5GT/s */  #define  PCI_EXP_LNKCAP2_SLS_8_0GB	0x00000008 /* Supported Speed 8GT/s */  #define  PCI_EXP_LNKCAP2_SLS_16_0GB	0x00000010 /* Supported Speed 16GT/s */  #define  PCI_EXP_LNKCAP2_SLS_32_0GB	0x00000020 /* Supported Speed 32GT/s */ +#define  PCI_EXP_LNKCAP2_SLS_64_0GB	0x00000040 /* Supported Speed 64GT/s */  #define  PCI_EXP_LNKCAP2_CROSSLINK	0x00000100 /* Crosslink supported */ -#define PCI_EXP_LNKCTL2		48	/* Link Control 2 */ +#define PCI_EXP_LNKCTL2		0x30	/* Link Control 2 */  #define  PCI_EXP_LNKCTL2_TLS		0x000f  #define  PCI_EXP_LNKCTL2_TLS_2_5GT	0x0001 /* Supported Speed 2.5GT/s */  #define  PCI_EXP_LNKCTL2_TLS_5_0GT	0x0002 /* Supported Speed 5GT/s */  #define  PCI_EXP_LNKCTL2_TLS_8_0GT	0x0003 /* Supported Speed 8GT/s */  #define  PCI_EXP_LNKCTL2_TLS_16_0GT	0x0004 /* Supported Speed 16GT/s */  #define  PCI_EXP_LNKCTL2_TLS_32_0GT	0x0005 /* Supported Speed 32GT/s */ +#define  PCI_EXP_LNKCTL2_TLS_64_0GT	0x0006 /* Supported Speed 64GT/s */  #define  PCI_EXP_LNKCTL2_ENTER_COMP	0x0010 /* Enter Compliance */  #define  PCI_EXP_LNKCTL2_TX_MARGIN	0x0380 /* Transmit Margin */  #define  PCI_EXP_LNKCTL2_HASD		0x0020 /* HW Autonomous Speed Disable */ -#define PCI_EXP_LNKSTA2		50	/* Link Status 2 */ -#define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2	52	/* v2 endpoints with link end here */ -#define PCI_EXP_SLTCAP2		52	/* Slot Capabilities 2 */ +#define PCI_EXP_LNKSTA2		0x32	/* Link Status 2 */ +#define  PCI_EXP_LNKSTA2_FLIT		0x0400 /* Flit Mode Status */ +#define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2	0x32	/* end of v2 EPs w/ link */ +#define PCI_EXP_SLTCAP2		0x34	/* Slot Capabilities 2 */  #define  PCI_EXP_SLTCAP2_IBPD	0x00000001 /* In-band PD Disable Supported */ -#define PCI_EXP_SLTCTL2		56	/* Slot Control 2 */ -#define PCI_EXP_SLTSTA2		58	/* Slot Status 2 */ +#define PCI_EXP_SLTCTL2		0x38	/* Slot Control 2 */ +#define PCI_EXP_SLTSTA2		0x3a	/* Slot Status 2 */  /* Extended Capabilities (PCI-X 2.0 and Express) */  #define PCI_EXT_CAP_ID(header)		(header & 0x0000ffff) @@ -720,15 +744,21 @@  #define PCI_EXT_CAP_ID_DPC	0x1D	/* Downstream Port Containment */  #define PCI_EXT_CAP_ID_L1SS	0x1E	/* L1 PM Substates */  #define PCI_EXT_CAP_ID_PTM	0x1F	/* Precision Time Measurement */ +#define PCI_EXT_CAP_ID_DVSEC	0x23	/* Designated Vendor-Specific */ +#define PCI_EXT_CAP_ID_VF_REBAR 0x24	/* VF Resizable BAR */  #define PCI_EXT_CAP_ID_DLF	0x25	/* Data Link Feature */  #define PCI_EXT_CAP_ID_PL_16GT	0x26	/* Physical Layer 16.0 GT/s */ -#define PCI_EXT_CAP_ID_MAX	PCI_EXT_CAP_ID_PL_16GT +#define PCI_EXT_CAP_ID_NPEM	0x29	/* Native PCIe Enclosure Management */ +#define PCI_EXT_CAP_ID_PL_32GT  0x2A    /* Physical Layer 32.0 GT/s */ +#define PCI_EXT_CAP_ID_DOE	0x2E	/* Data Object Exchange */ +#define PCI_EXT_CAP_ID_PL_64GT	0x31	/* Physical Layer 64.0 GT/s */ +#define PCI_EXT_CAP_ID_MAX	PCI_EXT_CAP_ID_PL_64GT  #define PCI_EXT_CAP_DSN_SIZEOF	12  #define PCI_EXT_CAP_MCAST_ENDPOINT_SIZEOF 40  /* Advanced Error Reporting */ -#define PCI_ERR_UNCOR_STATUS	4	/* Uncorrectable Error Status */ +#define PCI_ERR_UNCOR_STATUS	0x04	/* Uncorrectable Error Status */  #define  PCI_ERR_UNC_UND	0x00000001	/* Undefined */  #define  PCI_ERR_UNC_DLP	0x00000010	/* Data Link Protocol */  #define  PCI_ERR_UNC_SURPDN	0x00000020	/* Surprise Down */ @@ -746,11 +776,11 @@  #define  PCI_ERR_UNC_MCBTLP	0x00800000	/* MC blocked TLP */  #define  PCI_ERR_UNC_ATOMEG	0x01000000	/* Atomic egress blocked */  #define  PCI_ERR_UNC_TLPPRE	0x02000000	/* TLP prefix blocked */ -#define PCI_ERR_UNCOR_MASK	8	/* Uncorrectable Error Mask */ +#define PCI_ERR_UNCOR_MASK	0x08	/* Uncorrectable Error Mask */  	/* Same bits as above */ -#define PCI_ERR_UNCOR_SEVER	12	/* Uncorrectable Error Severity */ +#define PCI_ERR_UNCOR_SEVER	0x0c	/* Uncorrectable Error Severity */  	/* Same bits as above */ -#define PCI_ERR_COR_STATUS	16	/* Correctable Error Status */ +#define PCI_ERR_COR_STATUS	0x10	/* Correctable Error Status */  #define  PCI_ERR_COR_RCVR	0x00000001	/* Receiver Error Status */  #define  PCI_ERR_COR_BAD_TLP	0x00000040	/* Bad TLP Status */  #define  PCI_ERR_COR_BAD_DLLP	0x00000080	/* Bad DLLP Status */ @@ -759,20 +789,23 @@  #define  PCI_ERR_COR_ADV_NFAT	0x00002000	/* Advisory Non-Fatal */  #define  PCI_ERR_COR_INTERNAL	0x00004000	/* Corrected Internal */  #define  PCI_ERR_COR_LOG_OVER	0x00008000	/* Header Log Overflow */ -#define PCI_ERR_COR_MASK	20	/* Correctable Error Mask */ +#define PCI_ERR_COR_MASK	0x14	/* Correctable Error Mask */  	/* Same bits as above */ -#define PCI_ERR_CAP		24	/* Advanced Error Capabilities */ -#define  PCI_ERR_CAP_FEP(x)	((x) & 31)	/* First Error Pointer */ -#define  PCI_ERR_CAP_ECRC_GENC	0x00000020	/* ECRC Generation Capable */ -#define  PCI_ERR_CAP_ECRC_GENE	0x00000040	/* ECRC Generation Enable */ -#define  PCI_ERR_CAP_ECRC_CHKC	0x00000080	/* ECRC Check Capable */ -#define  PCI_ERR_CAP_ECRC_CHKE	0x00000100	/* ECRC Check Enable */ -#define PCI_ERR_HEADER_LOG	28	/* Header Log Register (16 bytes) */ -#define PCI_ERR_ROOT_COMMAND	44	/* Root Error Command */ +#define PCI_ERR_CAP		0x18	/* Advanced Error Capabilities & Ctrl*/ +#define  PCI_ERR_CAP_FEP(x)	((x) & 0x1f)	/* First Error Pointer */ +#define  PCI_ERR_CAP_ECRC_GENC		0x00000020 /* ECRC Generation Capable */ +#define  PCI_ERR_CAP_ECRC_GENE		0x00000040 /* ECRC Generation Enable */ +#define  PCI_ERR_CAP_ECRC_CHKC		0x00000080 /* ECRC Check Capable */ +#define  PCI_ERR_CAP_ECRC_CHKE		0x00000100 /* ECRC Check Enable */ +#define  PCI_ERR_CAP_PREFIX_LOG_PRESENT	0x00000800 /* TLP Prefix Log Present */ +#define  PCI_ERR_CAP_TLP_LOG_FLIT	0x00040000 /* TLP was logged in Flit Mode */ +#define  PCI_ERR_CAP_TLP_LOG_SIZE	0x00f80000 /* Logged TLP Size (only in Flit mode) */ +#define PCI_ERR_HEADER_LOG	0x1c	/* Header Log Register (16 bytes) */ +#define PCI_ERR_ROOT_COMMAND	0x2c	/* Root Error Command */  #define  PCI_ERR_ROOT_CMD_COR_EN	0x00000001 /* Correctable Err Reporting Enable */  #define  PCI_ERR_ROOT_CMD_NONFATAL_EN	0x00000002 /* Non-Fatal Err Reporting Enable */  #define  PCI_ERR_ROOT_CMD_FATAL_EN	0x00000004 /* Fatal Err Reporting Enable */ -#define PCI_ERR_ROOT_STATUS	48 +#define PCI_ERR_ROOT_STATUS	0x30  #define  PCI_ERR_ROOT_COR_RCV		0x00000001 /* ERR_COR Received */  #define  PCI_ERR_ROOT_MULTI_COR_RCV	0x00000002 /* Multiple ERR_COR */  #define  PCI_ERR_ROOT_UNCOR_RCV		0x00000004 /* ERR_FATAL/NONFATAL */ @@ -781,52 +814,60 @@  #define  PCI_ERR_ROOT_NONFATAL_RCV	0x00000020 /* Non-Fatal Received */  #define  PCI_ERR_ROOT_FATAL_RCV		0x00000040 /* Fatal Received */  #define  PCI_ERR_ROOT_AER_IRQ		0xf8000000 /* Advanced Error Interrupt Message Number */ -#define PCI_ERR_ROOT_ERR_SRC	52	/* Error Source Identification */ +#define PCI_ERR_ROOT_ERR_SRC	0x34	/* Error Source Identification */ +#define PCI_ERR_PREFIX_LOG	0x38	/* TLP Prefix LOG Register (up to 16 bytes) */  /* Virtual Channel */ -#define PCI_VC_PORT_CAP1	4 +#define PCI_VC_PORT_CAP1	0x04  #define  PCI_VC_CAP1_EVCC	0x00000007	/* extended VC count */  #define  PCI_VC_CAP1_LPEVCC	0x00000070	/* low prio extended VC count */  #define  PCI_VC_CAP1_ARB_SIZE	0x00000c00 -#define PCI_VC_PORT_CAP2	8 +#define PCI_VC_PORT_CAP2	0x08  #define  PCI_VC_CAP2_32_PHASE		0x00000002  #define  PCI_VC_CAP2_64_PHASE		0x00000004  #define  PCI_VC_CAP2_128_PHASE		0x00000008  #define  PCI_VC_CAP2_ARB_OFF		0xff000000 -#define PCI_VC_PORT_CTRL	12 +#define PCI_VC_PORT_CTRL	0x0c  #define  PCI_VC_PORT_CTRL_LOAD_TABLE	0x00000001 -#define PCI_VC_PORT_STATUS	14 +#define PCI_VC_PORT_STATUS	0x0e  #define  PCI_VC_PORT_STATUS_TABLE	0x00000001 -#define PCI_VC_RES_CAP		16 +#define PCI_VC_RES_CAP		0x10  #define  PCI_VC_RES_CAP_32_PHASE	0x00000002  #define  PCI_VC_RES_CAP_64_PHASE	0x00000004  #define  PCI_VC_RES_CAP_128_PHASE	0x00000008  #define  PCI_VC_RES_CAP_128_PHASE_TB	0x00000010  #define  PCI_VC_RES_CAP_256_PHASE	0x00000020  #define  PCI_VC_RES_CAP_ARB_OFF		0xff000000 -#define PCI_VC_RES_CTRL		20 +#define PCI_VC_RES_CTRL		0x14  #define  PCI_VC_RES_CTRL_LOAD_TABLE	0x00010000  #define  PCI_VC_RES_CTRL_ARB_SELECT	0x000e0000  #define  PCI_VC_RES_CTRL_ID		0x07000000  #define  PCI_VC_RES_CTRL_ENABLE		0x80000000 -#define PCI_VC_RES_STATUS	26 +#define PCI_VC_RES_STATUS	0x1a  #define  PCI_VC_RES_STATUS_TABLE	0x00000001  #define  PCI_VC_RES_STATUS_NEGO		0x00000002  #define PCI_CAP_VC_BASE_SIZEOF		0x10 -#define PCI_CAP_VC_PER_VC_SIZEOF	0x0C +#define PCI_CAP_VC_PER_VC_SIZEOF	0x0c  /* Power Budgeting */ -#define PCI_PWR_DSR		4	/* Data Select Register */ -#define PCI_PWR_DATA		8	/* Data Register */ +#define PCI_PWR_DSR		0x04	/* Data Select Register */ +#define PCI_PWR_DATA		0x08	/* Data Register */  #define  PCI_PWR_DATA_BASE(x)	((x) & 0xff)	    /* Base Power */  #define  PCI_PWR_DATA_SCALE(x)	(((x) >> 8) & 3)    /* Data Scale */  #define  PCI_PWR_DATA_PM_SUB(x)	(((x) >> 10) & 7)   /* PM Sub State */  #define  PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */  #define  PCI_PWR_DATA_TYPE(x)	(((x) >> 15) & 7)   /* Type */  #define  PCI_PWR_DATA_RAIL(x)	(((x) >> 18) & 7)   /* Power Rail */ -#define PCI_PWR_CAP		12	/* Capability */ +#define PCI_PWR_CAP		0x0c	/* Capability */  #define  PCI_PWR_CAP_BUDGET(x)	((x) & 1)	/* Included in system budget */ -#define PCI_EXT_CAP_PWR_SIZEOF	16 +#define PCI_EXT_CAP_PWR_SIZEOF	0x10 + +/* Root Complex Event Collector Endpoint Association  */ +#define PCI_RCEC_RCIEP_BITMAP	4	/* Associated Bitmap for RCiEPs */ +#define PCI_RCEC_BUSN		8	/* RCEC Associated Bus Numbers */ +#define  PCI_RCEC_BUSN_REG_VER	0x02	/* Least version with BUSN present */ +#define  PCI_RCEC_BUSN_NEXT(x)	(((x) >> 8) & 0xff) +#define  PCI_RCEC_BUSN_LAST(x)	(((x) >> 16) & 0xff)  /* Vendor-Specific (VSEC, PCI_EXT_CAP_ID_VNDR) */  #define PCI_VNDR_HEADER		4	/* Vendor-Specific Header */ @@ -905,12 +946,13 @@  /* Process Address Space ID */  #define PCI_PASID_CAP		0x04    /* PASID feature register */ -#define  PCI_PASID_CAP_EXEC	0x02	/* Exec permissions Supported */ -#define  PCI_PASID_CAP_PRIV	0x04	/* Privilege Mode Supported */ +#define  PCI_PASID_CAP_EXEC	0x0002	/* Exec permissions Supported */ +#define  PCI_PASID_CAP_PRIV	0x0004	/* Privilege Mode Supported */ +#define  PCI_PASID_CAP_WIDTH	0x1f00  #define PCI_PASID_CTRL		0x06    /* PASID control register */ -#define  PCI_PASID_CTRL_ENABLE	0x01	/* Enable bit */ -#define  PCI_PASID_CTRL_EXEC	0x02	/* Exec permissions Enable */ -#define  PCI_PASID_CTRL_PRIV	0x04	/* Privilege Mode Enable */ +#define  PCI_PASID_CTRL_ENABLE	0x0001	/* Enable bit */ +#define  PCI_PASID_CTRL_EXEC	0x0002	/* Exec permissions Enable */ +#define  PCI_PASID_CTRL_PRIV	0x0004	/* Privilege Mode Enable */  #define PCI_EXT_CAP_PASID_SIZEOF	8  /* Single Root I/O Virtualization */ @@ -943,13 +985,15 @@  #define  PCI_SRIOV_VFM_MI	0x1	/* Dormant.MigrateIn */  #define  PCI_SRIOV_VFM_MO	0x2	/* Active.MigrateOut */  #define  PCI_SRIOV_VFM_AV	0x3	/* Active.Available */ -#define PCI_EXT_CAP_SRIOV_SIZEOF 64 +#define PCI_EXT_CAP_SRIOV_SIZEOF 0x40  #define PCI_LTR_MAX_SNOOP_LAT	0x4  #define PCI_LTR_MAX_NOSNOOP_LAT	0x6  #define  PCI_LTR_VALUE_MASK	0x000003ff  #define  PCI_LTR_SCALE_MASK	0x00001c00  #define  PCI_LTR_SCALE_SHIFT	10 +#define  PCI_LTR_NOSNOOP_VALUE	0x03ff0000 /* Max No-Snoop Latency Value */ +#define  PCI_LTR_NOSNOOP_SCALE	0x1c000000 /* Scale for Max Value */  #define PCI_EXT_CAP_LTR_SIZEOF	8  /* Access Control Service */ @@ -965,9 +1009,6 @@  #define PCI_ACS_CTRL		0x06	/* ACS Control Register */  #define PCI_ACS_EGRESS_CTL_V	0x08	/* ACS Egress Control Vector */ -#define PCI_VSEC_HDR		4	/* extended cap - vendor-specific */ -#define  PCI_VSEC_HDR_LEN_SHIFT	20	/* shift for length field */ -  /* SATA capability */  #define PCI_SATA_REGS		4	/* SATA REGs specifier */  #define  PCI_SATA_REGS_MASK	0xF	/* location - BAR#/inline */ @@ -977,7 +1018,7 @@  /* Resizable BARs */  #define PCI_REBAR_CAP		4	/* capability register */ -#define  PCI_REBAR_CAP_SIZES		0x00FFFFF0  /* supported BAR sizes */ +#define  PCI_REBAR_CAP_SIZES		0xFFFFFFF0  /* supported BAR sizes */  #define PCI_REBAR_CTRL		8	/* control register */  #define  PCI_REBAR_CTRL_BAR_IDX		0x00000007  /* BAR index */  #define  PCI_REBAR_CTRL_NBAR_MASK	0x000000E0  /* # of resizable BARs */ @@ -990,38 +1031,65 @@  #define  PCI_DPA_CAP_SUBSTATE_MASK	0x1F	/* # substates - 1 */  #define PCI_DPA_BASE_SIZEOF	16	/* size with 0 substates */ +/* TPH Completer Support */ +#define PCI_EXP_DEVCAP2_TPH_COMP_NONE		0x0 /* None */ +#define PCI_EXP_DEVCAP2_TPH_COMP_TPH_ONLY	0x1 /* TPH only */ +#define PCI_EXP_DEVCAP2_TPH_COMP_EXT_TPH	0x3 /* TPH and Extended TPH */ +  /* TPH Requester */  #define PCI_TPH_CAP		4	/* capability register */ -#define  PCI_TPH_CAP_LOC_MASK	0x600	/* location mask */ -#define   PCI_TPH_LOC_NONE	0x000	/* no location */ -#define   PCI_TPH_LOC_CAP	0x200	/* in capability */ -#define   PCI_TPH_LOC_MSIX	0x400	/* in MSI-X */ -#define PCI_TPH_CAP_ST_MASK	0x07FF0000	/* st table mask */ -#define PCI_TPH_CAP_ST_SHIFT	16	/* st table shift */ -#define PCI_TPH_BASE_SIZEOF	12	/* size with no st table */ +#define  PCI_TPH_CAP_ST_NS	0x00000001 /* No ST Mode Supported */ +#define  PCI_TPH_CAP_ST_IV	0x00000002 /* Interrupt Vector Mode Supported */ +#define  PCI_TPH_CAP_ST_DS	0x00000004 /* Device Specific Mode Supported */ +#define  PCI_TPH_CAP_EXT_TPH	0x00000100 /* Ext TPH Requester Supported */ +#define  PCI_TPH_CAP_LOC_MASK	0x00000600 /* ST Table Location */ +#define   PCI_TPH_LOC_NONE	0x00000000 /* Not present */ +#define   PCI_TPH_LOC_CAP	0x00000200 /* In capability */ +#define   PCI_TPH_LOC_MSIX	0x00000400 /* In MSI-X */ +#define  PCI_TPH_CAP_ST_MASK	0x07FF0000 /* ST Table Size */ +#define  PCI_TPH_CAP_ST_SHIFT	16	/* ST Table Size shift */ +#define PCI_TPH_BASE_SIZEOF	0xc	/* Size with no ST table */ + +#define PCI_TPH_CTRL		8	/* control register */ +#define  PCI_TPH_CTRL_MODE_SEL_MASK	0x00000007 /* ST Mode Select */ +#define   PCI_TPH_ST_NS_MODE		0x0 /* No ST Mode */ +#define   PCI_TPH_ST_IV_MODE		0x1 /* Interrupt Vector Mode */ +#define   PCI_TPH_ST_DS_MODE		0x2 /* Device Specific Mode */ +#define  PCI_TPH_CTRL_REQ_EN_MASK	0x00000300 /* TPH Requester Enable */ +#define   PCI_TPH_REQ_DISABLE		0x0 /* No TPH requests allowed */ +#define   PCI_TPH_REQ_TPH_ONLY		0x1 /* TPH only requests allowed */ +#define   PCI_TPH_REQ_EXT_TPH		0x3 /* Extended TPH requests allowed */  /* Downstream Port Containment */ -#define PCI_EXP_DPC_CAP			4	/* DPC Capability */ +#define PCI_EXP_DPC_CAP			0x04	/* DPC Capability */  #define PCI_EXP_DPC_IRQ			0x001F	/* Interrupt Message Number */  #define  PCI_EXP_DPC_CAP_RP_EXT		0x0020	/* Root Port Extensions */  #define  PCI_EXP_DPC_CAP_POISONED_TLP	0x0040	/* Poisoned TLP Egress Blocking Supported */  #define  PCI_EXP_DPC_CAP_SW_TRIGGER	0x0080	/* Software Triggering Supported */ -#define  PCI_EXP_DPC_RP_PIO_LOG_SIZE	0x0F00	/* RP PIO Log Size */ +#define  PCI_EXP_DPC_RP_PIO_LOG_SIZE	0x0F00	/* RP PIO Log Size [3:0] */  #define  PCI_EXP_DPC_CAP_DL_ACTIVE	0x1000	/* ERR_COR signal on DL_Active supported */ +#define  PCI_EXP_DPC_RP_PIO_LOG_SIZE4	0x2000	/* RP PIO Log Size [4] */ -#define PCI_EXP_DPC_CTL			6	/* DPC control */ +#define PCI_EXP_DPC_CTL			0x06	/* DPC control */  #define  PCI_EXP_DPC_CTL_EN_FATAL	0x0001	/* Enable trigger on ERR_FATAL message */  #define  PCI_EXP_DPC_CTL_EN_NONFATAL	0x0002	/* Enable trigger on ERR_NONFATAL message */  #define  PCI_EXP_DPC_CTL_INT_EN		0x0008	/* DPC Interrupt Enable */ -#define PCI_EXP_DPC_STATUS		8	/* DPC Status */ +#define PCI_EXP_DPC_STATUS		0x08	/* DPC Status */  #define  PCI_EXP_DPC_STATUS_TRIGGER	    0x0001 /* Trigger Status */  #define  PCI_EXP_DPC_STATUS_TRIGGER_RSN	    0x0006 /* Trigger Reason */ +#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR  0x0000 /* Uncorrectable error */ +#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_NFE    0x0002 /* Rcvd ERR_NONFATAL */ +#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_FE     0x0004 /* Rcvd ERR_FATAL */ +#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_IN_EXT 0x0006 /* Reason in Trig Reason Extension field */  #define  PCI_EXP_DPC_STATUS_INTERRUPT	    0x0008 /* Interrupt Status */  #define  PCI_EXP_DPC_RP_BUSY		    0x0010 /* Root Port Busy */  #define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT 0x0060 /* Trig Reason Extension */ +#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_RP_PIO		0x0000	/* RP PIO error */ +#define  PCI_EXP_DPC_STATUS_TRIGGER_RSN_SW_TRIGGER	0x0020	/* DPC SW Trigger bit */ +#define  PCI_EXP_DPC_RP_PIO_FEP		    0x1f00 /* RP PIO First Err Ptr */ -#define PCI_EXP_DPC_SOURCE_ID		10	/* DPC Source Identifier */ +#define PCI_EXP_DPC_SOURCE_ID		 0x0A	/* DPC Source Identifier */  #define PCI_EXP_DPC_RP_PIO_STATUS	 0x0C	/* RP PIO Status */  #define PCI_EXP_DPC_RP_PIO_MASK		 0x10	/* RP PIO Mask */ @@ -1035,6 +1103,7 @@  /* Precision Time Measurement */  #define PCI_PTM_CAP			0x04	    /* PTM Capability */  #define  PCI_PTM_CAP_REQ		0x00000001  /* Requester capable */ +#define  PCI_PTM_CAP_RES		0x00000002  /* Responder capable */  #define  PCI_PTM_CAP_ROOT		0x00000004  /* Root capable */  #define  PCI_PTM_GRANULARITY_MASK	0x0000FF00  /* Clock granularity */  #define PCI_PTM_CTRL			0x08	    /* PTM Control */ @@ -1056,20 +1125,118 @@  #define  PCI_L1SS_CTL1_PCIPM_L1_1	0x00000002  /* PCI-PM L1.1 Enable */  #define  PCI_L1SS_CTL1_ASPM_L1_2	0x00000004  /* ASPM L1.2 Enable */  #define  PCI_L1SS_CTL1_ASPM_L1_1	0x00000008  /* ASPM L1.1 Enable */ +#define  PCI_L1SS_CTL1_L1_2_MASK	0x00000005  #define  PCI_L1SS_CTL1_L1SS_MASK	0x0000000f  #define  PCI_L1SS_CTL1_CM_RESTORE_TIME	0x0000ff00  /* Common_Mode_Restore_Time */  #define  PCI_L1SS_CTL1_LTR_L12_TH_VALUE	0x03ff0000  /* LTR_L1.2_THRESHOLD_Value */  #define  PCI_L1SS_CTL1_LTR_L12_TH_SCALE	0xe0000000  /* LTR_L1.2_THRESHOLD_Scale */  #define PCI_L1SS_CTL2		0x0c	/* Control 2 Register */ +#define  PCI_L1SS_CTL2_T_PWR_ON_SCALE	0x00000003  /* T_POWER_ON Scale */ +#define  PCI_L1SS_CTL2_T_PWR_ON_VALUE	0x000000f8  /* T_POWER_ON Value */ + +/* Designated Vendor-Specific (DVSEC, PCI_EXT_CAP_ID_DVSEC) */ +#define PCI_DVSEC_HEADER1		0x4 /* Designated Vendor-Specific Header1 */ +#define  PCI_DVSEC_HEADER1_VID(x)	((x) & 0xffff) +#define  PCI_DVSEC_HEADER1_REV(x)	(((x) >> 16) & 0xf) +#define  PCI_DVSEC_HEADER1_LEN(x)	(((x) >> 20) & 0xfff) +#define PCI_DVSEC_HEADER2		0x8 /* Designated Vendor-Specific Header2 */ +#define  PCI_DVSEC_HEADER2_ID(x)		((x) & 0xffff) + +/* VF Resizable BARs, same layout as PCI_REBAR */ +#define PCI_VF_REBAR_CAP	PCI_REBAR_CAP +#define  PCI_VF_REBAR_CAP_SIZES		PCI_REBAR_CAP_SIZES +#define PCI_VF_REBAR_CTRL	PCI_REBAR_CTRL +#define  PCI_VF_REBAR_CTRL_BAR_IDX	PCI_REBAR_CTRL_BAR_IDX +#define  PCI_VF_REBAR_CTRL_NBAR_MASK	PCI_REBAR_CTRL_NBAR_MASK +#define  PCI_VF_REBAR_CTRL_BAR_SIZE	PCI_REBAR_CTRL_BAR_SIZE  /* Data Link Feature */  #define PCI_DLF_CAP		0x04	/* Capabilities Register */  #define  PCI_DLF_EXCHANGE_ENABLE	0x80000000  /* Data Link Feature Exchange Enable */ +/* Secondary PCIe Capability 8.0 GT/s */ +#define PCI_SECPCI_LE_CTRL	0x0c /* Lane Equalization Control Register */ +  /* Physical Layer 16.0 GT/s */  #define PCI_PL_16GT_LE_CTRL	0x20	/* Lane Equalization Control Register */  #define  PCI_PL_16GT_LE_CTRL_DSP_TX_PRESET_MASK		0x0000000F  #define  PCI_PL_16GT_LE_CTRL_USP_TX_PRESET_MASK		0x000000F0  #define  PCI_PL_16GT_LE_CTRL_USP_TX_PRESET_SHIFT	4 +/* Physical Layer 32.0 GT/s */ +#define PCI_PL_32GT_LE_CTRL	0x20	/* Lane Equalization Control Register */ + +/* Physical Layer 64.0 GT/s */ +#define PCI_PL_64GT_LE_CTRL	0x20	/* Lane Equalization Control Register */ + +/* Native PCIe Enclosure Management */ +#define PCI_NPEM_CAP     0x04 /* NPEM capability register */ +#define  PCI_NPEM_CAP_CAPABLE     0x00000001 /* NPEM Capable */ + +#define PCI_NPEM_CTRL    0x08 /* NPEM control register */ +#define  PCI_NPEM_CTRL_ENABLE     0x00000001 /* NPEM Enable */ + +/* + * Native PCIe Enclosure Management indication bits and Reset command bit + * are corresponding for capability and control registers. + */ +#define  PCI_NPEM_CMD_RESET       0x00000002 /* Reset Command */ +#define  PCI_NPEM_IND_OK          0x00000004 /* OK */ +#define  PCI_NPEM_IND_LOCATE      0x00000008 /* Locate */ +#define  PCI_NPEM_IND_FAIL        0x00000010 /* Fail */ +#define  PCI_NPEM_IND_REBUILD     0x00000020 /* Rebuild */ +#define  PCI_NPEM_IND_PFA         0x00000040 /* Predicted Failure Analysis */ +#define  PCI_NPEM_IND_HOTSPARE    0x00000080 /* Hot Spare */ +#define  PCI_NPEM_IND_ICA         0x00000100 /* In Critical Array */ +#define  PCI_NPEM_IND_IFA         0x00000200 /* In Failed Array */ +#define  PCI_NPEM_IND_IDT         0x00000400 /* Device Type */ +#define  PCI_NPEM_IND_DISABLED    0x00000800 /* Disabled */ +#define  PCI_NPEM_IND_SPEC_0      0x01000000 +#define  PCI_NPEM_IND_SPEC_1      0x02000000 +#define  PCI_NPEM_IND_SPEC_2      0x04000000 +#define  PCI_NPEM_IND_SPEC_3      0x08000000 +#define  PCI_NPEM_IND_SPEC_4      0x10000000 +#define  PCI_NPEM_IND_SPEC_5      0x20000000 +#define  PCI_NPEM_IND_SPEC_6      0x40000000 +#define  PCI_NPEM_IND_SPEC_7      0x80000000 + +#define PCI_NPEM_STATUS  0x0c /* NPEM status register */ +#define  PCI_NPEM_STATUS_CC       0x00000001 /* Command Completed */ + +/* Data Object Exchange */ +#define PCI_DOE_CAP		0x04    /* DOE Capabilities Register */ +#define  PCI_DOE_CAP_INT_SUP			0x00000001  /* Interrupt Support */ +#define  PCI_DOE_CAP_INT_MSG_NUM		0x00000ffe  /* Interrupt Message Number */ +#define PCI_DOE_CTRL		0x08    /* DOE Control Register */ +#define  PCI_DOE_CTRL_ABORT			0x00000001  /* DOE Abort */ +#define  PCI_DOE_CTRL_INT_EN			0x00000002  /* DOE Interrupt Enable */ +#define  PCI_DOE_CTRL_GO			0x80000000  /* DOE Go */ +#define PCI_DOE_STATUS		0x0c    /* DOE Status Register */ +#define  PCI_DOE_STATUS_BUSY			0x00000001  /* DOE Busy */ +#define  PCI_DOE_STATUS_INT_STATUS		0x00000002  /* DOE Interrupt Status */ +#define  PCI_DOE_STATUS_ERROR			0x00000004  /* DOE Error */ +#define  PCI_DOE_STATUS_DATA_OBJECT_READY	0x80000000  /* Data Object Ready */ +#define PCI_DOE_WRITE		0x10    /* DOE Write Data Mailbox Register */ +#define PCI_DOE_READ		0x14    /* DOE Read Data Mailbox Register */ +#define PCI_DOE_CAP_SIZEOF	0x18	/* Size of DOE register block */ + +/* DOE Data Object - note not actually registers */ +#define PCI_DOE_DATA_OBJECT_HEADER_1_VID		0x0000ffff +#define PCI_DOE_DATA_OBJECT_HEADER_1_TYPE		0x00ff0000 +#define PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH		0x0003ffff + +#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX		0x000000ff +#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_VER		0x0000ff00 +#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_VID		0x0000ffff +#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_TYPE		0x00ff0000 +#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_NEXT_INDEX	0xff000000 + +/* Deprecated old name, replaced with PCI_DOE_DATA_OBJECT_DISC_RSP_3_TYPE */ +#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL		PCI_DOE_DATA_OBJECT_DISC_RSP_3_TYPE + +/* Compute Express Link (CXL r3.1, sec 8.1.5) */ +#define PCI_DVSEC_CXL_PORT				3 +#define PCI_DVSEC_CXL_PORT_CTL				0x0c +#define PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR		0x00000001 +  #endif /* LINUX_PCI_REGS_H */ diff --git a/include/uapi/linux/pcitest.h b/include/uapi/linux/pcitest.h index c3ab4c826297..d6023a45a9d0 100644 --- a/include/uapi/linux/pcitest.h +++ b/include/uapi/linux/pcitest.h @@ -1,5 +1,5 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/** +/*   * pcitest.h - PCI test uapi defines   *   * Copyright (C) 2017 Texas Instruments @@ -11,7 +11,8 @@  #define __UAPI_LINUX_PCITEST_H  #define PCITEST_BAR		_IO('P', 0x1) -#define PCITEST_LEGACY_IRQ	_IO('P', 0x2) +#define PCITEST_INTX_IRQ	_IO('P', 0x2) +#define PCITEST_LEGACY_IRQ	PCITEST_INTX_IRQ  #define PCITEST_MSI		_IOW('P', 0x3, int)  #define PCITEST_WRITE		_IOW('P', 0x4, unsigned long)  #define PCITEST_READ		_IOW('P', 0x5, unsigned long) @@ -19,8 +20,16 @@  #define PCITEST_MSIX		_IOW('P', 0x7, int)  #define PCITEST_SET_IRQTYPE	_IOW('P', 0x8, int)  #define PCITEST_GET_IRQTYPE	_IO('P', 0x9) +#define PCITEST_BARS		_IO('P', 0xa) +#define PCITEST_DOORBELL	_IO('P', 0xb)  #define PCITEST_CLEAR_IRQ	_IO('P', 0x10) +#define PCITEST_IRQ_TYPE_UNDEFINED	-1 +#define PCITEST_IRQ_TYPE_INTX		0 +#define PCITEST_IRQ_TYPE_MSI		1 +#define PCITEST_IRQ_TYPE_MSIX		2 +#define PCITEST_IRQ_TYPE_AUTO		3 +  #define PCITEST_FLAGS_USE_DMA	0x00000001  struct pci_endpoint_test_xfer_param { diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index 077e7ee69e3d..78a362b80027 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -38,6 +38,24 @@ enum perf_type_id {  };  /* + * attr.config layout for type PERF_TYPE_HARDWARE and PERF_TYPE_HW_CACHE + * + * PERF_TYPE_HARDWARE:			0xEEEEEEEE000000AA + *					AA: hardware event ID + *					EEEEEEEE: PMU type ID + * + * PERF_TYPE_HW_CACHE:			0xEEEEEEEE00DDCCBB + *					BB: hardware cache ID + *					CC: hardware cache op ID + *					DD: hardware cache op result ID + *					EEEEEEEE: PMU type ID + * + * If the PMU type ID is 0, PERF_TYPE_RAW will be applied. + */ +#define PERF_PMU_TYPE_SHIFT			32 +#define PERF_HW_EVENT_MASK			0xffffffff + +/*   * Generalized performance event event_id types, used by the   * attr.event_id parameter of the sys_perf_event_open()   * syscall: @@ -97,7 +115,7 @@ enum perf_hw_cache_op_result_id {  /*   * Special "software" events provided by the kernel, even if the hardware   * does not support performance events. These events measure various - * physical and sw events of the kernel (and allow the profiling of them as + * physical and SW events of the kernel (and allow the profiling of them as   * well):   */  enum perf_sw_ids { @@ -112,6 +130,7 @@ enum perf_sw_ids {  	PERF_COUNT_SW_EMULATION_FAULTS		= 8,  	PERF_COUNT_SW_DUMMY			= 9,  	PERF_COUNT_SW_BPF_OUTPUT		= 10, +	PERF_COUNT_SW_CGROUP_SWITCHES		= 11,  	PERF_COUNT_SW_MAX,			/* non-ABI */  }; @@ -143,14 +162,17 @@ enum perf_event_sample_format {  	PERF_SAMPLE_PHYS_ADDR			= 1U << 19,  	PERF_SAMPLE_AUX				= 1U << 20,  	PERF_SAMPLE_CGROUP			= 1U << 21, +	PERF_SAMPLE_DATA_PAGE_SIZE		= 1U << 22, +	PERF_SAMPLE_CODE_PAGE_SIZE		= 1U << 23, +	PERF_SAMPLE_WEIGHT_STRUCT		= 1U << 24, -	PERF_SAMPLE_MAX = 1U << 22,		/* non-ABI */ - -	__PERF_SAMPLE_CALLCHAIN_EARLY		= 1ULL << 63, /* non-ABI; internal use */ +	PERF_SAMPLE_MAX = 1U << 25,		/* non-ABI */  }; +#define PERF_SAMPLE_WEIGHT_TYPE	(PERF_SAMPLE_WEIGHT | PERF_SAMPLE_WEIGHT_STRUCT) +  /* - * values to program into branch_sample_type when PERF_SAMPLE_BRANCH is set + * Values to program into branch_sample_type when PERF_SAMPLE_BRANCH is set.   *   * If the user does not pass priv level information via branch_sample_type,   * the kernel uses the event's priv level. Branch and event priv levels do @@ -160,20 +182,20 @@ enum perf_event_sample_format {   * of branches and therefore it supersedes all the other types.   */  enum perf_branch_sample_type_shift { -	PERF_SAMPLE_BRANCH_USER_SHIFT		= 0, /* user branches */ -	PERF_SAMPLE_BRANCH_KERNEL_SHIFT		= 1, /* kernel branches */ -	PERF_SAMPLE_BRANCH_HV_SHIFT		= 2, /* hypervisor branches */ - -	PERF_SAMPLE_BRANCH_ANY_SHIFT		= 3, /* any branch types */ -	PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT	= 4, /* any call branch */ -	PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT	= 5, /* any return branch */ -	PERF_SAMPLE_BRANCH_IND_CALL_SHIFT	= 6, /* indirect calls */ -	PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT	= 7, /* transaction aborts */ -	PERF_SAMPLE_BRANCH_IN_TX_SHIFT		= 8, /* in transaction */ -	PERF_SAMPLE_BRANCH_NO_TX_SHIFT		= 9, /* not in transaction */ +	PERF_SAMPLE_BRANCH_USER_SHIFT		=  0, /* user branches */ +	PERF_SAMPLE_BRANCH_KERNEL_SHIFT		=  1, /* kernel branches */ +	PERF_SAMPLE_BRANCH_HV_SHIFT		=  2, /* hypervisor branches */ + +	PERF_SAMPLE_BRANCH_ANY_SHIFT		=  3, /* any branch types */ +	PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT	=  4, /* any call branch */ +	PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT	=  5, /* any return branch */ +	PERF_SAMPLE_BRANCH_IND_CALL_SHIFT	=  6, /* indirect calls */ +	PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT	=  7, /* transaction aborts */ +	PERF_SAMPLE_BRANCH_IN_TX_SHIFT		=  8, /* in transaction */ +	PERF_SAMPLE_BRANCH_NO_TX_SHIFT		=  9, /* not in transaction */  	PERF_SAMPLE_BRANCH_COND_SHIFT		= 10, /* conditional branches */ -	PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT	= 11, /* call/ret stack */ +	PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT	= 11, /* CALL/RET stack */  	PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT	= 12, /* indirect jumps */  	PERF_SAMPLE_BRANCH_CALL_SHIFT		= 13, /* direct call */ @@ -184,56 +206,104 @@ enum perf_branch_sample_type_shift {  	PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT	= 17, /* save low level index of raw branch records */ +	PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT	= 18, /* save privilege mode */ + +	PERF_SAMPLE_BRANCH_COUNTERS_SHIFT	= 19, /* save occurrences of events on a branch */ +  	PERF_SAMPLE_BRANCH_MAX_SHIFT		/* non-ABI */  };  enum perf_branch_sample_type { -	PERF_SAMPLE_BRANCH_USER		= 1U << PERF_SAMPLE_BRANCH_USER_SHIFT, -	PERF_SAMPLE_BRANCH_KERNEL	= 1U << PERF_SAMPLE_BRANCH_KERNEL_SHIFT, -	PERF_SAMPLE_BRANCH_HV		= 1U << PERF_SAMPLE_BRANCH_HV_SHIFT, +	PERF_SAMPLE_BRANCH_USER			= 1U << PERF_SAMPLE_BRANCH_USER_SHIFT, +	PERF_SAMPLE_BRANCH_KERNEL		= 1U << PERF_SAMPLE_BRANCH_KERNEL_SHIFT, +	PERF_SAMPLE_BRANCH_HV			= 1U << PERF_SAMPLE_BRANCH_HV_SHIFT, + +	PERF_SAMPLE_BRANCH_ANY			= 1U << PERF_SAMPLE_BRANCH_ANY_SHIFT, +	PERF_SAMPLE_BRANCH_ANY_CALL		= 1U << PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT, +	PERF_SAMPLE_BRANCH_ANY_RETURN		= 1U << PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT, +	PERF_SAMPLE_BRANCH_IND_CALL		= 1U << PERF_SAMPLE_BRANCH_IND_CALL_SHIFT, +	PERF_SAMPLE_BRANCH_ABORT_TX		= 1U << PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT, +	PERF_SAMPLE_BRANCH_IN_TX		= 1U << PERF_SAMPLE_BRANCH_IN_TX_SHIFT, +	PERF_SAMPLE_BRANCH_NO_TX		= 1U << PERF_SAMPLE_BRANCH_NO_TX_SHIFT, +	PERF_SAMPLE_BRANCH_COND			= 1U << PERF_SAMPLE_BRANCH_COND_SHIFT, -	PERF_SAMPLE_BRANCH_ANY		= 1U << PERF_SAMPLE_BRANCH_ANY_SHIFT, -	PERF_SAMPLE_BRANCH_ANY_CALL	= 1U << PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT, -	PERF_SAMPLE_BRANCH_ANY_RETURN	= 1U << PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT, -	PERF_SAMPLE_BRANCH_IND_CALL	= 1U << PERF_SAMPLE_BRANCH_IND_CALL_SHIFT, -	PERF_SAMPLE_BRANCH_ABORT_TX	= 1U << PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT, -	PERF_SAMPLE_BRANCH_IN_TX	= 1U << PERF_SAMPLE_BRANCH_IN_TX_SHIFT, -	PERF_SAMPLE_BRANCH_NO_TX	= 1U << PERF_SAMPLE_BRANCH_NO_TX_SHIFT, -	PERF_SAMPLE_BRANCH_COND		= 1U << PERF_SAMPLE_BRANCH_COND_SHIFT, +	PERF_SAMPLE_BRANCH_CALL_STACK		= 1U << PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT, +	PERF_SAMPLE_BRANCH_IND_JUMP		= 1U << PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT, +	PERF_SAMPLE_BRANCH_CALL			= 1U << PERF_SAMPLE_BRANCH_CALL_SHIFT, -	PERF_SAMPLE_BRANCH_CALL_STACK	= 1U << PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT, -	PERF_SAMPLE_BRANCH_IND_JUMP	= 1U << PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT, -	PERF_SAMPLE_BRANCH_CALL		= 1U << PERF_SAMPLE_BRANCH_CALL_SHIFT, +	PERF_SAMPLE_BRANCH_NO_FLAGS		= 1U << PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT, +	PERF_SAMPLE_BRANCH_NO_CYCLES		= 1U << PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT, -	PERF_SAMPLE_BRANCH_NO_FLAGS	= 1U << PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT, -	PERF_SAMPLE_BRANCH_NO_CYCLES	= 1U << PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT, +	PERF_SAMPLE_BRANCH_TYPE_SAVE		= 1U << PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT, -	PERF_SAMPLE_BRANCH_TYPE_SAVE	= -		1U << PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT, +	PERF_SAMPLE_BRANCH_HW_INDEX		= 1U << PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT, -	PERF_SAMPLE_BRANCH_HW_INDEX	= 1U << PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT, +	PERF_SAMPLE_BRANCH_PRIV_SAVE		= 1U << PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT, -	PERF_SAMPLE_BRANCH_MAX		= 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT, +	PERF_SAMPLE_BRANCH_COUNTERS		= 1U << PERF_SAMPLE_BRANCH_COUNTERS_SHIFT, + +	PERF_SAMPLE_BRANCH_MAX			= 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,  };  /* - * Common flow change classification + * Common control flow change classifications:   */  enum { -	PERF_BR_UNKNOWN		= 0,	/* unknown */ -	PERF_BR_COND		= 1,	/* conditional */ -	PERF_BR_UNCOND		= 2,	/* unconditional  */ -	PERF_BR_IND		= 3,	/* indirect */ -	PERF_BR_CALL		= 4,	/* function call */ -	PERF_BR_IND_CALL	= 5,	/* indirect function call */ -	PERF_BR_RET		= 6,	/* function return */ -	PERF_BR_SYSCALL		= 7,	/* syscall */ -	PERF_BR_SYSRET		= 8,	/* syscall return */ -	PERF_BR_COND_CALL	= 9,	/* conditional function call */ -	PERF_BR_COND_RET	= 10,	/* conditional function return */ +	PERF_BR_UNKNOWN				=  0,	/* Unknown */ +	PERF_BR_COND				=  1,	/* Conditional */ +	PERF_BR_UNCOND				=  2,	/* Unconditional  */ +	PERF_BR_IND				=  3,	/* Indirect */ +	PERF_BR_CALL				=  4,	/* Function call */ +	PERF_BR_IND_CALL			=  5,	/* Indirect function call */ +	PERF_BR_RET				=  6,	/* Function return */ +	PERF_BR_SYSCALL				=  7,	/* Syscall */ +	PERF_BR_SYSRET				=  8,	/* Syscall return */ +	PERF_BR_COND_CALL			=  9,	/* Conditional function call */ +	PERF_BR_COND_RET			= 10,	/* Conditional function return */ +	PERF_BR_ERET				= 11,	/* Exception return */ +	PERF_BR_IRQ				= 12,	/* IRQ */ +	PERF_BR_SERROR				= 13,	/* System error */ +	PERF_BR_NO_TX				= 14,	/* Not in transaction */ +	PERF_BR_EXTEND_ABI			= 15,	/* Extend ABI */  	PERF_BR_MAX,  }; +/* + * Common branch speculation outcome classifications: + */ +enum { +	PERF_BR_SPEC_NA				= 0,	/* Not available */ +	PERF_BR_SPEC_WRONG_PATH			= 1,	/* Speculative but on wrong path */ +	PERF_BR_NON_SPEC_CORRECT_PATH		= 2,	/* Non-speculative but on correct path */ +	PERF_BR_SPEC_CORRECT_PATH		= 3,	/* Speculative and on correct path */ +	PERF_BR_SPEC_MAX, +}; + +enum { +	PERF_BR_NEW_FAULT_ALGN			= 0,    /* Alignment fault */ +	PERF_BR_NEW_FAULT_DATA			= 1,    /* Data fault */ +	PERF_BR_NEW_FAULT_INST			= 2,    /* Inst fault */ +	PERF_BR_NEW_ARCH_1			= 3,    /* Architecture specific */ +	PERF_BR_NEW_ARCH_2			= 4,    /* Architecture specific */ +	PERF_BR_NEW_ARCH_3			= 5,    /* Architecture specific */ +	PERF_BR_NEW_ARCH_4			= 6,    /* Architecture specific */ +	PERF_BR_NEW_ARCH_5			= 7,    /* Architecture specific */ +	PERF_BR_NEW_MAX, +}; + +enum { +	PERF_BR_PRIV_UNKNOWN			= 0, +	PERF_BR_PRIV_USER			= 1, +	PERF_BR_PRIV_KERNEL			= 2, +	PERF_BR_PRIV_HV				= 3, +}; + +#define PERF_BR_ARM64_FIQ			PERF_BR_NEW_ARCH_1 +#define PERF_BR_ARM64_DEBUG_HALT		PERF_BR_NEW_ARCH_2 +#define PERF_BR_ARM64_DEBUG_EXIT		PERF_BR_NEW_ARCH_3 +#define PERF_BR_ARM64_DEBUG_INST		PERF_BR_NEW_ARCH_4 +#define PERF_BR_ARM64_DEBUG_DATA		PERF_BR_NEW_ARCH_5 +  #define PERF_SAMPLE_BRANCH_PLM_ALL \  	(PERF_SAMPLE_BRANCH_USER|\  	 PERF_SAMPLE_BRANCH_KERNEL|\ @@ -243,9 +313,9 @@ enum {   * Values to determine ABI of the registers dump.   */  enum perf_sample_regs_abi { -	PERF_SAMPLE_REGS_ABI_NONE	= 0, -	PERF_SAMPLE_REGS_ABI_32		= 1, -	PERF_SAMPLE_REGS_ABI_64		= 2, +	PERF_SAMPLE_REGS_ABI_NONE		= 0, +	PERF_SAMPLE_REGS_ABI_32			= 1, +	PERF_SAMPLE_REGS_ABI_64			= 2,  };  /* @@ -253,21 +323,21 @@ enum perf_sample_regs_abi {   * abort events. Multiple bits can be set.   */  enum { -	PERF_TXN_ELISION        = (1 << 0), /* From elision */ -	PERF_TXN_TRANSACTION    = (1 << 1), /* From transaction */ -	PERF_TXN_SYNC           = (1 << 2), /* Instruction is related */ -	PERF_TXN_ASYNC          = (1 << 3), /* Instruction not related */ -	PERF_TXN_RETRY          = (1 << 4), /* Retry possible */ -	PERF_TXN_CONFLICT       = (1 << 5), /* Conflict abort */ -	PERF_TXN_CAPACITY_WRITE = (1 << 6), /* Capacity write abort */ -	PERF_TXN_CAPACITY_READ  = (1 << 7), /* Capacity read abort */ +	PERF_TXN_ELISION			= (1 << 0), /* From elision */ +	PERF_TXN_TRANSACTION			= (1 << 1), /* From transaction */ +	PERF_TXN_SYNC				= (1 << 2), /* Instruction is related */ +	PERF_TXN_ASYNC				= (1 << 3), /* Instruction is not related */ +	PERF_TXN_RETRY				= (1 << 4), /* Retry possible */ +	PERF_TXN_CONFLICT			= (1 << 5), /* Conflict abort */ +	PERF_TXN_CAPACITY_WRITE			= (1 << 6), /* Capacity write abort */ +	PERF_TXN_CAPACITY_READ			= (1 << 7), /* Capacity read abort */ -	PERF_TXN_MAX	        = (1 << 8), /* non-ABI */ +	PERF_TXN_MAX				= (1 << 8), /* non-ABI */ -	/* bits 32..63 are reserved for the abort code */ +	/* Bits 32..63 are reserved for the abort code */ -	PERF_TXN_ABORT_MASK  = (0xffffffffULL << 32), -	PERF_TXN_ABORT_SHIFT = 32, +	PERF_TXN_ABORT_MASK			= (0xffffffffULL << 32), +	PERF_TXN_ABORT_SHIFT			= 32,  };  /* @@ -279,6 +349,7 @@ enum {   *	  { u64		time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED   *	  { u64		time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING   *	  { u64		id;           } && PERF_FORMAT_ID + *	  { u64		lost;         } && PERF_FORMAT_LOST   *	} && !PERF_FORMAT_GROUP   *   *	{ u64		nr; @@ -286,6 +357,7 @@ enum {   *	  { u64		time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING   *	  { u64		value;   *	    { u64	id;           } && PERF_FORMAT_ID + *	    { u64	lost;         } && PERF_FORMAT_LOST   *	  }		cntr[nr];   *	} && PERF_FORMAT_GROUP   * }; @@ -295,24 +367,27 @@ enum perf_event_read_format {  	PERF_FORMAT_TOTAL_TIME_RUNNING		= 1U << 1,  	PERF_FORMAT_ID				= 1U << 2,  	PERF_FORMAT_GROUP			= 1U << 3, +	PERF_FORMAT_LOST			= 1U << 4, -	PERF_FORMAT_MAX = 1U << 4,		/* non-ABI */ +	PERF_FORMAT_MAX = 1U << 5,		/* non-ABI */  }; -#define PERF_ATTR_SIZE_VER0	64	/* sizeof first published struct */ -#define PERF_ATTR_SIZE_VER1	72	/* add: config2 */ -#define PERF_ATTR_SIZE_VER2	80	/* add: branch_sample_type */ -#define PERF_ATTR_SIZE_VER3	96	/* add: sample_regs_user */ -					/* add: sample_stack_user */ -#define PERF_ATTR_SIZE_VER4	104	/* add: sample_regs_intr */ -#define PERF_ATTR_SIZE_VER5	112	/* add: aux_watermark */ -#define PERF_ATTR_SIZE_VER6	120	/* add: aux_sample_size */ +#define PERF_ATTR_SIZE_VER0			 64	/* Size of first published 'struct perf_event_attr' */ +#define PERF_ATTR_SIZE_VER1			 72	/* Add: config2 */ +#define PERF_ATTR_SIZE_VER2			 80	/* Add: branch_sample_type */ +#define PERF_ATTR_SIZE_VER3			 96	/* Add: sample_regs_user */ +							/* Add: sample_stack_user */ +#define PERF_ATTR_SIZE_VER4			104	/* Add: sample_regs_intr */ +#define PERF_ATTR_SIZE_VER5			112	/* Add: aux_watermark */ +#define PERF_ATTR_SIZE_VER6			120	/* Add: aux_sample_size */ +#define PERF_ATTR_SIZE_VER7			128	/* Add: sig_data */ +#define PERF_ATTR_SIZE_VER8			136	/* Add: config3 */  /* - * Hardware event_id to monitor via a performance monitoring event: - * - * @sample_max_stack: Max number of frame pointers in a callchain, - *		      should be < /proc/sys/kernel/perf_event_max_stack + * 'struct perf_event_attr' contains various attributes that define + * a performance event - most of them hardware related configuration + * details, but also a lot of behavioral switches and values implemented + * by the kernel.   */  struct perf_event_attr { @@ -322,7 +397,7 @@ struct perf_event_attr {  	__u32			type;  	/* -	 * Size of the attr structure, for fwd/bwd compat. +	 * Size of the attr structure, for forward/backwards compatibility.  	 */  	__u32			size; @@ -377,17 +452,21 @@ struct perf_event_attr {  				comm_exec      :  1, /* flag comm events that are due to an exec */  				use_clockid    :  1, /* use @clockid for time fields */  				context_switch :  1, /* context switch data */ -				write_backward :  1, /* Write ring buffer from end to beginning */ +				write_backward :  1, /* write ring buffer from end to beginning */  				namespaces     :  1, /* include namespaces data */  				ksymbol        :  1, /* include ksymbol events */ -				bpf_event      :  1, /* include bpf events */ +				bpf_event      :  1, /* include BPF events */  				aux_output     :  1, /* generate AUX records instead of events */  				cgroup         :  1, /* include cgroup events */  				text_poke      :  1, /* include text poke events */ -				__reserved_1   : 30; +				build_id       :  1, /* use build ID in mmap2 events */ +				inherit_thread :  1, /* children only inherit if cloned with CLONE_THREAD */ +				remove_on_exec :  1, /* event is removed from task on exec */ +				sigtrap        :  1, /* send synchronous SIGTRAP on event */ +				__reserved_1   : 26;  	union { -		__u32		wakeup_events;	  /* wakeup every n events */ +		__u32		wakeup_events;	  /* wake up every n events */  		__u32		wakeup_watermark; /* bytes before wakeup   */  	}; @@ -396,13 +475,13 @@ struct perf_event_attr {  		__u64		bp_addr;  		__u64		kprobe_func; /* for perf_kprobe */  		__u64		uprobe_path; /* for perf_uprobe */ -		__u64		config1; /* extension of config */ +		__u64		config1;     /* extension of config */  	};  	union {  		__u64		bp_len; -		__u64		kprobe_addr; /* when kprobe_func == NULL */ +		__u64		kprobe_addr;  /* when kprobe_func == NULL */  		__u64		probe_offset; /* for perf_[k,u]probe */ -		__u64		config2; /* extension of config1 */ +		__u64		config2;      /* extension of config1 */  	};  	__u64	branch_sample_type; /* enum perf_branch_sample_type */ @@ -432,15 +511,43 @@ struct perf_event_attr {  	 * Wakeup watermark for AUX area  	 */  	__u32	aux_watermark; + +	/* +	 * Max number of frame pointers in a callchain, should be +	 * lower than /proc/sys/kernel/perf_event_max_stack. +	 * +	 * Max number of entries of branch stack should be lower +	 * than the hardware limit. +	 */  	__u16	sample_max_stack; +  	__u16	__reserved_2;  	__u32	aux_sample_size; -	__u32	__reserved_3; + +	union { +		__u32	aux_action; +		struct { +			__u32	aux_start_paused :  1, /* start AUX area tracing paused */ +				aux_pause        :  1, /* on overflow, pause AUX area tracing */ +				aux_resume       :  1, /* on overflow, resume AUX area tracing */ +				__reserved_3     : 29; +		}; +	}; + +	/* +	 * User provided data if sigtrap=1, passed back to user via +	 * siginfo_t::si_perf_data, e.g. to permit user to identify the event. +	 * Note, siginfo_t::si_perf_data is long-sized, and sig_data will be +	 * truncated accordingly on 32 bit architectures. +	 */ +	__u64	sig_data; + +	__u64	config3; /* extension of config2 */  };  /*   * Structure used by below PERF_EVENT_IOC_QUERY_BPF command - * to query bpf programs attached to the same perf tracepoint + * to query BPF programs attached to the same perf tracepoint   * as the given perf event.   */  struct perf_event_query_bpf { @@ -456,27 +563,27 @@ struct perf_event_query_bpf {  	/*  	 * User provided buffer to store program ids  	 */ -	__u32	ids[0]; +	__u32	ids[];  };  /*   * Ioctls that can be done on a perf event fd:   */ -#define PERF_EVENT_IOC_ENABLE			_IO ('$', 0) -#define PERF_EVENT_IOC_DISABLE			_IO ('$', 1) -#define PERF_EVENT_IOC_REFRESH			_IO ('$', 2) -#define PERF_EVENT_IOC_RESET			_IO ('$', 3) -#define PERF_EVENT_IOC_PERIOD			_IOW('$', 4, __u64) -#define PERF_EVENT_IOC_SET_OUTPUT		_IO ('$', 5) -#define PERF_EVENT_IOC_SET_FILTER		_IOW('$', 6, char *) -#define PERF_EVENT_IOC_ID			_IOR('$', 7, __u64 *) -#define PERF_EVENT_IOC_SET_BPF			_IOW('$', 8, __u32) -#define PERF_EVENT_IOC_PAUSE_OUTPUT		_IOW('$', 9, __u32) +#define PERF_EVENT_IOC_ENABLE			_IO  ('$', 0) +#define PERF_EVENT_IOC_DISABLE			_IO  ('$', 1) +#define PERF_EVENT_IOC_REFRESH			_IO  ('$', 2) +#define PERF_EVENT_IOC_RESET			_IO  ('$', 3) +#define PERF_EVENT_IOC_PERIOD			_IOW ('$', 4, __u64) +#define PERF_EVENT_IOC_SET_OUTPUT		_IO  ('$', 5) +#define PERF_EVENT_IOC_SET_FILTER		_IOW ('$', 6, char *) +#define PERF_EVENT_IOC_ID			_IOR ('$', 7, __u64 *) +#define PERF_EVENT_IOC_SET_BPF			_IOW ('$', 8, __u32) +#define PERF_EVENT_IOC_PAUSE_OUTPUT		_IOW ('$', 9, __u32)  #define PERF_EVENT_IOC_QUERY_BPF		_IOWR('$', 10, struct perf_event_query_bpf *) -#define PERF_EVENT_IOC_MODIFY_ATTRIBUTES	_IOW('$', 11, struct perf_event_attr *) +#define PERF_EVENT_IOC_MODIFY_ATTRIBUTES	_IOW ('$', 11, struct perf_event_attr *)  enum perf_event_ioc_flags { -	PERF_IOC_FLAG_GROUP		= 1U << 0, +	PERF_IOC_FLAG_GROUP			= 1U << 0,  };  /* @@ -487,7 +594,7 @@ struct perf_event_mmap_page {  	__u32	compat_version;		/* lowest version this is compat with */  	/* -	 * Bits needed to read the hw events in user-space. +	 * Bits needed to read the HW events in user-space.  	 *  	 *   u32 seq, time_mult, time_shift, index, width;  	 *   u64 count, enabled, running; @@ -525,7 +632,7 @@ struct perf_event_mmap_page {  	__u32	index;			/* hardware event identifier */  	__s64	offset;			/* add to hardware event value */  	__u64	time_enabled;		/* time event active */ -	__u64	time_running;		/* time event on cpu */ +	__u64	time_running;		/* time event on CPU */  	union {  		__u64	capabilities;  		struct { @@ -553,7 +660,7 @@ struct perf_event_mmap_page {  	/*  	 * If cap_usr_time the below fields can be used to compute the time -	 * delta since time_enabled (in ns) using rdtsc or similar. +	 * delta since time_enabled (in ns) using RDTSC or similar.  	 *  	 *   u64 quot, rem;  	 *   u64 delta; @@ -626,7 +733,7 @@ struct perf_event_mmap_page {  	 * after reading this value.  	 *  	 * When the mapping is PROT_WRITE the @data_tail value should be -	 * written by userspace to reflect the last read data, after issueing +	 * written by user-space to reflect the last read data, after issuing  	 * an smp_mb() to separate the data read from the ->data_tail store.  	 * In this case the kernel will not over-write unread data.  	 * @@ -642,7 +749,7 @@ struct perf_event_mmap_page {  	/*  	 * AUX area is defined by aux_{offset,size} fields that should be set -	 * by the userspace, so that +	 * by the user-space, so that  	 *  	 *   aux_offset >= data_offset + data_size  	 * @@ -657,6 +764,22 @@ struct perf_event_mmap_page {  	__u64	aux_size;  }; +/* + * The current state of perf_event_header::misc bits usage: + * ('|' used bit, '-' unused bit) + * + *  012         CDEF + *  |||---------|||| + * + *  Where: + *    0-2     CPUMODE_MASK + * + *    C       PROC_MAP_PARSE_TIMEOUT + *    D       MMAP_DATA / COMM_EXEC / FORK_EXEC / SWITCH_OUT + *    E       MMAP_BUILD_ID / EXACT_IP / SCHED_OUT_PREEMPT + *    F       (reserved) + */ +  #define PERF_RECORD_MISC_CPUMODE_MASK		(7 << 0)  #define PERF_RECORD_MISC_CPUMODE_UNKNOWN	(0 << 0)  #define PERF_RECORD_MISC_KERNEL			(1 << 0) @@ -688,6 +811,7 @@ struct perf_event_mmap_page {   *   *   PERF_RECORD_MISC_EXACT_IP           - PERF_RECORD_SAMPLE of precise events   *   PERF_RECORD_MISC_SWITCH_OUT_PREEMPT - PERF_RECORD_SWITCH* events + *   PERF_RECORD_MISC_MMAP_BUILD_ID      - PERF_RECORD_MMAP2 event   *   *   * PERF_RECORD_MISC_EXACT_IP: @@ -697,35 +821,39 @@ struct perf_event_mmap_page {   *   * PERF_RECORD_MISC_SWITCH_OUT_PREEMPT:   *   Indicates that thread was preempted in TASK_RUNNING state. + * + * PERF_RECORD_MISC_MMAP_BUILD_ID: + *   Indicates that mmap2 event carries build ID data.   */  #define PERF_RECORD_MISC_EXACT_IP		(1 << 14)  #define PERF_RECORD_MISC_SWITCH_OUT_PREEMPT	(1 << 14) +#define PERF_RECORD_MISC_MMAP_BUILD_ID		(1 << 14)  /*   * Reserve the last bit to indicate some extended misc field   */  #define PERF_RECORD_MISC_EXT_RESERVED		(1 << 15)  struct perf_event_header { -	__u32	type; -	__u16	misc; -	__u16	size; +	__u32 type; +	__u16 misc; +	__u16 size;  };  struct perf_ns_link_info { -	__u64	dev; -	__u64	ino; +	__u64 dev; +	__u64 ino;  };  enum { -	NET_NS_INDEX		= 0, -	UTS_NS_INDEX		= 1, -	IPC_NS_INDEX		= 2, -	PID_NS_INDEX		= 3, -	USER_NS_INDEX		= 4, -	MNT_NS_INDEX		= 5, -	CGROUP_NS_INDEX		= 6, - -	NR_NAMESPACES,		/* number of available namespaces */ +	NET_NS_INDEX				= 0, +	UTS_NS_INDEX				= 1, +	IPC_NS_INDEX				= 2, +	PID_NS_INDEX				= 3, +	USER_NS_INDEX				= 4, +	MNT_NS_INDEX				= 5, +	CGROUP_NS_INDEX				= 6, + +	NR_NAMESPACES, /* number of available namespaces */  };  enum perf_event_type { @@ -741,11 +869,11 @@ enum perf_event_type {  	 * optional fields being ignored.  	 *  	 * struct sample_id { -	 * 	{ u32			pid, tid; } && PERF_SAMPLE_TID -	 * 	{ u64			time;     } && PERF_SAMPLE_TIME -	 * 	{ u64			id;       } && PERF_SAMPLE_ID -	 * 	{ u64			stream_id;} && PERF_SAMPLE_STREAM_ID -	 * 	{ u32			cpu, res; } && PERF_SAMPLE_CPU +	 *	{ u32			pid, tid; } && PERF_SAMPLE_TID +	 *	{ u64			time;     } && PERF_SAMPLE_TIME +	 *	{ u64			id;       } && PERF_SAMPLE_ID +	 *	{ u64			stream_id;} && PERF_SAMPLE_STREAM_ID +	 *	{ u32			cpu, res; } && PERF_SAMPLE_CPU  	 *	{ u64			id;	  } && PERF_SAMPLE_IDENTIFIER  	 * } && perf_event_attr::sample_id_all  	 * @@ -756,7 +884,7 @@ enum perf_event_type {  	/*  	 * The MMAP events record the PROT_EXEC mappings so that we can -	 * correlate userspace IPs to code. They have the following structure: +	 * correlate user-space IPs to code. They have the following structure:  	 *  	 * struct {  	 *	struct perf_event_header	header; @@ -766,7 +894,7 @@ enum perf_event_type {  	 *	u64				len;  	 *	u64				pgoff;  	 *	char				filename[]; -	 * 	struct sample_id		sample_id; +	 *	struct sample_id		sample_id;  	 * };  	 */  	PERF_RECORD_MMAP			= 1, @@ -776,7 +904,7 @@ enum perf_event_type {  	 *	struct perf_event_header	header;  	 *	u64				id;  	 *	u64				lost; -	 * 	struct sample_id		sample_id; +	 *	struct sample_id		sample_id;  	 * };  	 */  	PERF_RECORD_LOST			= 2, @@ -787,7 +915,7 @@ enum perf_event_type {  	 *  	 *	u32				pid, tid;  	 *	char				comm[]; -	 * 	struct sample_id		sample_id; +	 *	struct sample_id		sample_id;  	 * };  	 */  	PERF_RECORD_COMM			= 3, @@ -798,7 +926,7 @@ enum perf_event_type {  	 *	u32				pid, ppid;  	 *	u32				tid, ptid;  	 *	u64				time; -	 * 	struct sample_id		sample_id; +	 *	struct sample_id		sample_id;  	 * };  	 */  	PERF_RECORD_EXIT			= 4, @@ -809,7 +937,7 @@ enum perf_event_type {  	 *	u64				time;  	 *	u64				id;  	 *	u64				stream_id; -	 * 	struct sample_id		sample_id; +	 *	struct sample_id		sample_id;  	 * };  	 */  	PERF_RECORD_THROTTLE			= 5, @@ -821,7 +949,7 @@ enum perf_event_type {  	 *	u32				pid, ppid;  	 *	u32				tid, ptid;  	 *	u64				time; -	 * 	struct sample_id		sample_id; +	 *	struct sample_id		sample_id;  	 * };  	 */  	PERF_RECORD_FORK			= 7, @@ -832,7 +960,7 @@ enum perf_event_type {  	 *	u32				pid, tid;  	 *  	 *	struct read_format		values; -	 * 	struct sample_id		sample_id; +	 *	struct sample_id		sample_id;  	 * };  	 */  	PERF_RECORD_READ			= 8, @@ -879,21 +1007,47 @@ enum perf_event_type {  	 *	{ u64                   nr;  	 *	  { u64	hw_idx; } && PERF_SAMPLE_BRANCH_HW_INDEX  	 *        { u64 from, to, flags } lbr[nr]; +	 *        # +	 *        # The format of the counters is decided by the +	 *        # "branch_counter_nr" and "branch_counter_width", +	 *        # which are defined in the ABI. +	 *        # +	 *        { u64 counters; } cntr[nr] && PERF_SAMPLE_BRANCH_COUNTERS  	 *      } && PERF_SAMPLE_BRANCH_STACK  	 * -	 * 	{ u64			abi; # enum perf_sample_regs_abi -	 * 	  u64			regs[weight(mask)]; } && PERF_SAMPLE_REGS_USER +	 *	{ u64			abi; # enum perf_sample_regs_abi +	 *	  u64			regs[weight(mask)]; } && PERF_SAMPLE_REGS_USER  	 * -	 * 	{ u64			size; -	 * 	  char			data[size]; -	 * 	  u64			dyn_size; } && PERF_SAMPLE_STACK_USER +	 *	{ u64			size; +	 *	  char			data[size]; +	 *	  u64			dyn_size; } && PERF_SAMPLE_STACK_USER  	 * -	 *	{ u64			weight;   } && PERF_SAMPLE_WEIGHT +	 *	{ union perf_sample_weight +	 *	 { +	 *		u64		full; && PERF_SAMPLE_WEIGHT +	 *	#if defined(__LITTLE_ENDIAN_BITFIELD) +	 *		struct { +	 *			u32	var1_dw; +	 *			u16	var2_w; +	 *			u16	var3_w; +	 *		} && PERF_SAMPLE_WEIGHT_STRUCT +	 *	#elif defined(__BIG_ENDIAN_BITFIELD) +	 *		struct { +	 *			u16	var3_w; +	 *			u16	var2_w; +	 *			u32	var1_dw; +	 *		} && PERF_SAMPLE_WEIGHT_STRUCT +	 *	#endif +	 *	 } +	 *	}  	 *	{ u64			data_src; } && PERF_SAMPLE_DATA_SRC  	 *	{ u64			transaction; } && PERF_SAMPLE_TRANSACTION  	 *	{ u64			abi; # enum perf_sample_regs_abi  	 *	  u64			regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR  	 *	{ u64			phys_addr;} && PERF_SAMPLE_PHYS_ADDR +	 *	{ u64			cgroup;} && PERF_SAMPLE_CGROUP +	 *	{ u64			data_page_size;} && PERF_SAMPLE_DATA_PAGE_SIZE +	 *	{ u64			code_page_size;} && PERF_SAMPLE_CODE_PAGE_SIZE  	 *	{ u64			size;  	 *	  char			data[size]; } && PERF_SAMPLE_AUX  	 * }; @@ -911,13 +1065,23 @@ enum perf_event_type {  	 *	u64				addr;  	 *	u64				len;  	 *	u64				pgoff; -	 *	u32				maj; -	 *	u32				min; -	 *	u64				ino; -	 *	u64				ino_generation; +	 *	union { +	 *		struct { +	 *			u32		maj; +	 *			u32		min; +	 *			u64		ino; +	 *			u64		ino_generation; +	 *		}; +	 *		struct { +	 *			u8		build_id_size; +	 *			u8		__reserved_1; +	 *			u16		__reserved_2; +	 *			u8		build_id[20]; +	 *		}; +	 *	};  	 *	u32				prot, flags;  	 *	char				filename[]; -	 * 	struct sample_id		sample_id; +	 *	struct sample_id		sample_id;  	 * };  	 */  	PERF_RECORD_MMAP2			= 10, @@ -926,12 +1090,12 @@ enum perf_event_type {  	 * Records that new data landed in the AUX buffer part.  	 *  	 * struct { -	 * 	struct perf_event_header	header; +	 *	struct perf_event_header	header;  	 * -	 * 	u64				aux_offset; -	 * 	u64				aux_size; +	 *	u64				aux_offset; +	 *	u64				aux_size;  	 *	u64				flags; -	 * 	struct sample_id		sample_id; +	 *	struct sample_id		sample_id;  	 * };  	 */  	PERF_RECORD_AUX				= 11, @@ -1014,7 +1178,7 @@ enum perf_event_type {  	PERF_RECORD_KSYMBOL			= 17,  	/* -	 * Record bpf events: +	 * Record BPF events:  	 *  enum perf_bpf_event_type {  	 *	PERF_BPF_EVENT_UNKNOWN		= 0,  	 *	PERF_BPF_EVENT_PROG_LOAD	= 1, @@ -1060,6 +1224,21 @@ enum perf_event_type {  	 */  	PERF_RECORD_TEXT_POKE			= 20, +	/* +	 * Data written to the AUX area by hardware due to aux_output, may need +	 * to be matched to the event by an architecture-specific hardware ID. +	 * This records the hardware ID, but requires sample_id to provide the +	 * event ID. e.g. Intel PT uses this record to disambiguate PEBS-via-PT +	 * records from multiple events. +	 * +	 * struct { +	 *	struct perf_event_header	header; +	 *	u64				hw_id; +	 *	struct sample_id		sample_id; +	 * }; +	 */ +	PERF_RECORD_AUX_OUTPUT_HW_ID		= 21, +  	PERF_RECORD_MAX,			/* non-ABI */  }; @@ -1077,147 +1256,181 @@ enum perf_record_ksymbol_type {  #define PERF_RECORD_KSYMBOL_FLAGS_UNREGISTER	(1 << 0)  enum perf_bpf_event_type { -	PERF_BPF_EVENT_UNKNOWN		= 0, -	PERF_BPF_EVENT_PROG_LOAD	= 1, -	PERF_BPF_EVENT_PROG_UNLOAD	= 2, -	PERF_BPF_EVENT_MAX,		/* non-ABI */ +	PERF_BPF_EVENT_UNKNOWN			= 0, +	PERF_BPF_EVENT_PROG_LOAD		= 1, +	PERF_BPF_EVENT_PROG_UNLOAD		= 2, +	PERF_BPF_EVENT_MAX,			/* non-ABI */  }; -#define PERF_MAX_STACK_DEPTH		127 -#define PERF_MAX_CONTEXTS_PER_STACK	  8 +#define PERF_MAX_STACK_DEPTH			127 +#define PERF_MAX_CONTEXTS_PER_STACK		  8  enum perf_callchain_context { -	PERF_CONTEXT_HV			= (__u64)-32, -	PERF_CONTEXT_KERNEL		= (__u64)-128, -	PERF_CONTEXT_USER		= (__u64)-512, +	PERF_CONTEXT_HV				= (__u64)-32, +	PERF_CONTEXT_KERNEL			= (__u64)-128, +	PERF_CONTEXT_USER			= (__u64)-512, -	PERF_CONTEXT_GUEST		= (__u64)-2048, -	PERF_CONTEXT_GUEST_KERNEL	= (__u64)-2176, -	PERF_CONTEXT_GUEST_USER		= (__u64)-2560, +	PERF_CONTEXT_GUEST			= (__u64)-2048, +	PERF_CONTEXT_GUEST_KERNEL		= (__u64)-2176, +	PERF_CONTEXT_GUEST_USER			= (__u64)-2560, -	PERF_CONTEXT_MAX		= (__u64)-4095, +	PERF_CONTEXT_MAX			= (__u64)-4095,  };  /**   * PERF_RECORD_AUX::flags bits   */ -#define PERF_AUX_FLAG_TRUNCATED		0x01	/* record was truncated to fit */ -#define PERF_AUX_FLAG_OVERWRITE		0x02	/* snapshot from overwrite mode */ -#define PERF_AUX_FLAG_PARTIAL		0x04	/* record contains gaps */ -#define PERF_AUX_FLAG_COLLISION		0x08	/* sample collided with another */ +#define PERF_AUX_FLAG_TRUNCATED			0x0001	/* Record was truncated to fit */ +#define PERF_AUX_FLAG_OVERWRITE			0x0002	/* Snapshot from overwrite mode */ +#define PERF_AUX_FLAG_PARTIAL			0x0004	/* Record contains gaps */ +#define PERF_AUX_FLAG_COLLISION			0x0008	/* Sample collided with another */ +#define PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK	0xff00	/* PMU specific trace format type */ + +/* CoreSight PMU AUX buffer formats */ +#define PERF_AUX_FLAG_CORESIGHT_FORMAT_CORESIGHT 0x0000 /* Default for backward compatibility */ +#define PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW	 0x0100 /* Raw format of the source */ -#define PERF_FLAG_FD_NO_GROUP		(1UL << 0) -#define PERF_FLAG_FD_OUTPUT		(1UL << 1) -#define PERF_FLAG_PID_CGROUP		(1UL << 2) /* pid=cgroup id, per-cpu mode only */ -#define PERF_FLAG_FD_CLOEXEC		(1UL << 3) /* O_CLOEXEC */ +#define PERF_FLAG_FD_NO_GROUP			(1UL << 0) +#define PERF_FLAG_FD_OUTPUT			(1UL << 1) +#define PERF_FLAG_PID_CGROUP			(1UL << 2) /* pid=cgroup ID, per-CPU mode only */ +#define PERF_FLAG_FD_CLOEXEC			(1UL << 3) /* O_CLOEXEC */  #if defined(__LITTLE_ENDIAN_BITFIELD)  union perf_mem_data_src {  	__u64 val;  	struct { -		__u64   mem_op:5,	/* type of opcode */ -			mem_lvl:14,	/* memory hierarchy level */ -			mem_snoop:5,	/* snoop mode */ -			mem_lock:2,	/* lock instr */ -			mem_dtlb:7,	/* tlb access */ -			mem_lvl_num:4,	/* memory hierarchy level number */ -			mem_remote:1,   /* remote */ -			mem_snoopx:2,	/* snoop mode, ext */ -			mem_rsvd:24; +		__u64   mem_op      :  5, /* Type of opcode */ +			mem_lvl     : 14, /* Memory hierarchy level */ +			mem_snoop   :  5, /* Snoop mode */ +			mem_lock    :  2, /* Lock instr */ +			mem_dtlb    :  7, /* TLB access */ +			mem_lvl_num :  4, /* Memory hierarchy level number */ +			mem_remote  :  1, /* Remote */ +			mem_snoopx  :  2, /* Snoop mode, ext */ +			mem_blk     :  3, /* Access blocked */ +			mem_hops    :  3, /* Hop level */ +			mem_rsvd    : 18;  	};  };  #elif defined(__BIG_ENDIAN_BITFIELD)  union perf_mem_data_src {  	__u64 val;  	struct { -		__u64	mem_rsvd:24, -			mem_snoopx:2,	/* snoop mode, ext */ -			mem_remote:1,   /* remote */ -			mem_lvl_num:4,	/* memory hierarchy level number */ -			mem_dtlb:7,	/* tlb access */ -			mem_lock:2,	/* lock instr */ -			mem_snoop:5,	/* snoop mode */ -			mem_lvl:14,	/* memory hierarchy level */ -			mem_op:5;	/* type of opcode */ +		__u64	mem_rsvd    : 18, +			mem_hops    :  3, /* Hop level */ +			mem_blk     :  3, /* Access blocked */ +			mem_snoopx  :  2, /* Snoop mode, ext */ +			mem_remote  :  1, /* Remote */ +			mem_lvl_num :  4, /* Memory hierarchy level number */ +			mem_dtlb    :  7, /* TLB access */ +			mem_lock    :  2, /* Lock instr */ +			mem_snoop   :  5, /* Snoop mode */ +			mem_lvl     : 14, /* Memory hierarchy level */ +			mem_op      :  5; /* Type of opcode */  	};  };  #else -#error "Unknown endianness" +# error "Unknown endianness"  #endif -/* type of opcode (load/store/prefetch,code) */ -#define PERF_MEM_OP_NA		0x01 /* not available */ -#define PERF_MEM_OP_LOAD	0x02 /* load instruction */ -#define PERF_MEM_OP_STORE	0x04 /* store instruction */ -#define PERF_MEM_OP_PFETCH	0x08 /* prefetch */ -#define PERF_MEM_OP_EXEC	0x10 /* code (execution) */ -#define PERF_MEM_OP_SHIFT	0 - -/* memory hierarchy (memory level, hit or miss) */ -#define PERF_MEM_LVL_NA		0x01  /* not available */ -#define PERF_MEM_LVL_HIT	0x02  /* hit level */ -#define PERF_MEM_LVL_MISS	0x04  /* miss level  */ -#define PERF_MEM_LVL_L1		0x08  /* L1 */ -#define PERF_MEM_LVL_LFB	0x10  /* Line Fill Buffer */ -#define PERF_MEM_LVL_L2		0x20  /* L2 */ -#define PERF_MEM_LVL_L3		0x40  /* L3 */ -#define PERF_MEM_LVL_LOC_RAM	0x80  /* Local DRAM */ -#define PERF_MEM_LVL_REM_RAM1	0x100 /* Remote DRAM (1 hop) */ -#define PERF_MEM_LVL_REM_RAM2	0x200 /* Remote DRAM (2 hops) */ -#define PERF_MEM_LVL_REM_CCE1	0x400 /* Remote Cache (1 hop) */ -#define PERF_MEM_LVL_REM_CCE2	0x800 /* Remote Cache (2 hops) */ -#define PERF_MEM_LVL_IO		0x1000 /* I/O memory */ -#define PERF_MEM_LVL_UNC	0x2000 /* Uncached memory */ -#define PERF_MEM_LVL_SHIFT	5 - -#define PERF_MEM_REMOTE_REMOTE	0x01  /* Remote */ -#define PERF_MEM_REMOTE_SHIFT	37 - -#define PERF_MEM_LVLNUM_L1	0x01 /* L1 */ -#define PERF_MEM_LVLNUM_L2	0x02 /* L2 */ -#define PERF_MEM_LVLNUM_L3	0x03 /* L3 */ -#define PERF_MEM_LVLNUM_L4	0x04 /* L4 */ -/* 5-0xa available */ -#define PERF_MEM_LVLNUM_ANY_CACHE 0x0b /* Any cache */ -#define PERF_MEM_LVLNUM_LFB	0x0c /* LFB */ -#define PERF_MEM_LVLNUM_RAM	0x0d /* RAM */ -#define PERF_MEM_LVLNUM_PMEM	0x0e /* PMEM */ -#define PERF_MEM_LVLNUM_NA	0x0f /* N/A */ - -#define PERF_MEM_LVLNUM_SHIFT	33 - -/* snoop mode */ -#define PERF_MEM_SNOOP_NA	0x01 /* not available */ -#define PERF_MEM_SNOOP_NONE	0x02 /* no snoop */ -#define PERF_MEM_SNOOP_HIT	0x04 /* snoop hit */ -#define PERF_MEM_SNOOP_MISS	0x08 /* snoop miss */ -#define PERF_MEM_SNOOP_HITM	0x10 /* snoop hit modified */ -#define PERF_MEM_SNOOP_SHIFT	19 - -#define PERF_MEM_SNOOPX_FWD	0x01 /* forward */ -/* 1 free */ -#define PERF_MEM_SNOOPX_SHIFT	37 - -/* locked instruction */ -#define PERF_MEM_LOCK_NA	0x01 /* not available */ -#define PERF_MEM_LOCK_LOCKED	0x02 /* locked transaction */ -#define PERF_MEM_LOCK_SHIFT	24 +/* Type of memory opcode: */ +#define PERF_MEM_OP_NA				0x0001 /* Not available */ +#define PERF_MEM_OP_LOAD			0x0002 /* Load instruction */ +#define PERF_MEM_OP_STORE			0x0004 /* Store instruction */ +#define PERF_MEM_OP_PFETCH			0x0008 /* Prefetch */ +#define PERF_MEM_OP_EXEC			0x0010 /* Code (execution) */ +#define PERF_MEM_OP_SHIFT			0 + +/* + * The PERF_MEM_LVL_* namespace is being deprecated to some extent in + * favour of newer composite PERF_MEM_{LVLNUM_,REMOTE_,SNOOPX_} fields. + * We support this namespace in order to not break defined ABIs. + * + * Memory hierarchy (memory level, hit or miss) + */ +#define PERF_MEM_LVL_NA				0x0001 /* Not available */ +#define PERF_MEM_LVL_HIT			0x0002 /* Hit level */ +#define PERF_MEM_LVL_MISS			0x0004 /* Miss level  */ +#define PERF_MEM_LVL_L1				0x0008 /* L1 */ +#define PERF_MEM_LVL_LFB			0x0010 /* Line Fill Buffer */ +#define PERF_MEM_LVL_L2				0x0020 /* L2 */ +#define PERF_MEM_LVL_L3				0x0040 /* L3 */ +#define PERF_MEM_LVL_LOC_RAM			0x0080 /* Local DRAM */ +#define PERF_MEM_LVL_REM_RAM1			0x0100 /* Remote DRAM (1 hop) */ +#define PERF_MEM_LVL_REM_RAM2			0x0200 /* Remote DRAM (2 hops) */ +#define PERF_MEM_LVL_REM_CCE1			0x0400 /* Remote Cache (1 hop) */ +#define PERF_MEM_LVL_REM_CCE2			0x0800 /* Remote Cache (2 hops) */ +#define PERF_MEM_LVL_IO				0x1000 /* I/O memory */ +#define PERF_MEM_LVL_UNC			0x2000 /* Uncached memory */ +#define PERF_MEM_LVL_SHIFT			5 + +#define PERF_MEM_REMOTE_REMOTE			0x0001 /* Remote */ +#define PERF_MEM_REMOTE_SHIFT			37 + +#define PERF_MEM_LVLNUM_L1			0x0001 /* L1 */ +#define PERF_MEM_LVLNUM_L2			0x0002 /* L2 */ +#define PERF_MEM_LVLNUM_L3			0x0003 /* L3 */ +#define PERF_MEM_LVLNUM_L4			0x0004 /* L4 */ +#define PERF_MEM_LVLNUM_L2_MHB			0x0005 /* L2 Miss Handling Buffer */ +#define PERF_MEM_LVLNUM_MSC			0x0006 /* Memory-side Cache */ +/* 0x007 available */ +#define PERF_MEM_LVLNUM_UNC			0x0008 /* Uncached */ +#define PERF_MEM_LVLNUM_CXL			0x0009 /* CXL */ +#define PERF_MEM_LVLNUM_IO			0x000a /* I/O */ +#define PERF_MEM_LVLNUM_ANY_CACHE		0x000b /* Any cache */ +#define PERF_MEM_LVLNUM_LFB			0x000c /* LFB / L1 Miss Handling Buffer */ +#define PERF_MEM_LVLNUM_RAM			0x000d /* RAM */ +#define PERF_MEM_LVLNUM_PMEM			0x000e /* PMEM */ +#define PERF_MEM_LVLNUM_NA			0x000f /* N/A */ + +#define PERF_MEM_LVLNUM_SHIFT			33 + +/* Snoop mode */ +#define PERF_MEM_SNOOP_NA			0x0001 /* Not available */ +#define PERF_MEM_SNOOP_NONE			0x0002 /* No snoop */ +#define PERF_MEM_SNOOP_HIT			0x0004 /* Snoop hit */ +#define PERF_MEM_SNOOP_MISS			0x0008 /* Snoop miss */ +#define PERF_MEM_SNOOP_HITM			0x0010 /* Snoop hit modified */ +#define PERF_MEM_SNOOP_SHIFT			19 + +#define PERF_MEM_SNOOPX_FWD			0x0001 /* Forward */ +#define PERF_MEM_SNOOPX_PEER			0x0002 /* Transfer from peer */ +#define PERF_MEM_SNOOPX_SHIFT			38 + +/* Locked instruction */ +#define PERF_MEM_LOCK_NA			0x0001 /* Not available */ +#define PERF_MEM_LOCK_LOCKED			0x0002 /* Locked transaction */ +#define PERF_MEM_LOCK_SHIFT			24  /* TLB access */ -#define PERF_MEM_TLB_NA		0x01 /* not available */ -#define PERF_MEM_TLB_HIT	0x02 /* hit level */ -#define PERF_MEM_TLB_MISS	0x04 /* miss level */ -#define PERF_MEM_TLB_L1		0x08 /* L1 */ -#define PERF_MEM_TLB_L2		0x10 /* L2 */ -#define PERF_MEM_TLB_WK		0x20 /* Hardware Walker*/ -#define PERF_MEM_TLB_OS		0x40 /* OS fault handler */ -#define PERF_MEM_TLB_SHIFT	26 +#define PERF_MEM_TLB_NA				0x0001 /* Not available */ +#define PERF_MEM_TLB_HIT			0x0002 /* Hit level */ +#define PERF_MEM_TLB_MISS			0x0004 /* Miss level */ +#define PERF_MEM_TLB_L1				0x0008 /* L1 */ +#define PERF_MEM_TLB_L2				0x0010 /* L2 */ +#define PERF_MEM_TLB_WK				0x0020 /* Hardware Walker*/ +#define PERF_MEM_TLB_OS				0x0040 /* OS fault handler */ +#define PERF_MEM_TLB_SHIFT			26 + +/* Access blocked */ +#define PERF_MEM_BLK_NA				0x0001 /* Not available */ +#define PERF_MEM_BLK_DATA			0x0002 /* Data could not be forwarded */ +#define PERF_MEM_BLK_ADDR			0x0004 /* Address conflict */ +#define PERF_MEM_BLK_SHIFT			40 + +/* Hop level */ +#define PERF_MEM_HOPS_0				0x0001 /* Remote core, same node */ +#define PERF_MEM_HOPS_1				0x0002 /* Remote node, same socket */ +#define PERF_MEM_HOPS_2				0x0003 /* Remote socket, same board */ +#define PERF_MEM_HOPS_3				0x0004 /* Remote board */ +/* 5-7 available */ +#define PERF_MEM_HOPS_SHIFT			43  #define PERF_MEM_S(a, s) \  	(((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT)  /* - * single taken branch record layout: + * Layout of single taken branch records:   *   *      from: source instruction (may not always be a branch insn)   *        to: branch target @@ -1231,17 +1444,43 @@ union perf_mem_data_src {   *     abort: aborting a hardware transaction   *    cycles: cycles from last branch (or 0 if not supported)   *      type: branch type + *      spec: branch speculation info (or 0 if not supported)   */  struct perf_branch_entry {  	__u64	from;  	__u64	to; -	__u64	mispred:1,  /* target mispredicted */ -		predicted:1,/* target predicted */ -		in_tx:1,    /* in transaction */ -		abort:1,    /* transaction abort */ -		cycles:16,  /* cycle count to last branch */ -		type:4,     /* branch type */ -		reserved:40; +	__u64	mispred   :  1, /* target mispredicted */ +		predicted :  1, /* target predicted */ +		in_tx     :  1, /* in transaction */ +		abort     :  1, /* transaction abort */ +		cycles    : 16, /* cycle count to last branch */ +		type      :  4, /* branch type */ +		spec      :  2, /* branch speculation info */ +		new_type  :  4, /* additional branch type */ +		priv      :  3, /* privilege level */ +		reserved  : 31; +}; + +/* Size of used info bits in struct perf_branch_entry */ +#define PERF_BRANCH_ENTRY_INFO_BITS_MAX		33 + +union perf_sample_weight { +	__u64	      full; +#if defined(__LITTLE_ENDIAN_BITFIELD) +	struct { +		__u32 var1_dw; +		__u16 var2_w; +		__u16 var3_w; +	}; +#elif defined(__BIG_ENDIAN_BITFIELD) +	struct { +		__u16 var3_w; +		__u16 var2_w; +		__u32 var1_dw; +	}; +#else +# error "Unknown endianness" +#endif  };  #endif /* _UAPI_LINUX_PERF_EVENT_H */ diff --git a/include/uapi/linux/pfkeyv2.h b/include/uapi/linux/pfkeyv2.h index d65b11785260..8abae1f6749c 100644 --- a/include/uapi/linux/pfkeyv2.h +++ b/include/uapi/linux/pfkeyv2.h @@ -309,6 +309,7 @@ struct sadb_x_filter {  #define SADB_X_AALG_SHA2_512HMAC	7  #define SADB_X_AALG_RIPEMD160HMAC	8  #define SADB_X_AALG_AES_XCBC_MAC	9 +#define SADB_X_AALG_SM3_256HMAC		10  #define SADB_X_AALG_NULL		251	/* kame */  #define SADB_AALG_MAX			251 @@ -329,6 +330,7 @@ struct sadb_x_filter {  #define SADB_X_EALG_AES_GCM_ICV16	20  #define SADB_X_EALG_CAMELLIACBC		22  #define SADB_X_EALG_NULL_AES_GMAC	23 +#define SADB_X_EALG_SM4CBC		24  #define SADB_EALG_MAX                   253 /* last EALG */  /* private allocations should use 249-255 (RFC2407) */  #define SADB_X_EALG_SERPENTCBC  252     /* draft-ietf-ipsec-ciph-aes-cbc-00 */ diff --git a/include/uapi/linux/pfrut.h b/include/uapi/linux/pfrut.h new file mode 100644 index 000000000000..b77d5c210c26 --- /dev/null +++ b/include/uapi/linux/pfrut.h @@ -0,0 +1,263 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Platform Firmware Runtime Update header + * + * Copyright(c) 2021 Intel Corporation. All rights reserved. + */ +#ifndef __PFRUT_H__ +#define __PFRUT_H__ + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define PFRUT_IOCTL_MAGIC 0xEE + +/** + * PFRU_IOC_SET_REV - _IOW(PFRUT_IOCTL_MAGIC, 0x01, unsigned int) + * + * Return: + * * 0			- success + * * -EFAULT		- fail to read the revision id + * * -EINVAL		- user provides an invalid revision id + * + * Set the Revision ID for Platform Firmware Runtime Update. + */ +#define PFRU_IOC_SET_REV _IOW(PFRUT_IOCTL_MAGIC, 0x01, unsigned int) + +/** + * PFRU_IOC_STAGE - _IOW(PFRUT_IOCTL_MAGIC, 0x02, unsigned int) + * + * Return: + * * 0			- success + * * -EINVAL		- stage phase returns invalid result + * + * Stage a capsule image from communication buffer and perform authentication. + */ +#define PFRU_IOC_STAGE _IOW(PFRUT_IOCTL_MAGIC, 0x02, unsigned int) + +/** + * PFRU_IOC_ACTIVATE - _IOW(PFRUT_IOCTL_MAGIC, 0x03, unsigned int) + * + * Return: + * * 0			- success + * * -EINVAL		- activate phase returns invalid result + * + * Activate a previously staged capsule image. + */ +#define PFRU_IOC_ACTIVATE _IOW(PFRUT_IOCTL_MAGIC, 0x03, unsigned int) + +/** + * PFRU_IOC_STAGE_ACTIVATE - _IOW(PFRUT_IOCTL_MAGIC, 0x04, unsigned int) + * + * Return: + * * 0			- success + * * -EINVAL		- stage/activate phase returns invalid result. + * + * Perform both stage and activation action. + */ +#define PFRU_IOC_STAGE_ACTIVATE _IOW(PFRUT_IOCTL_MAGIC, 0x04, unsigned int) + +/** + * PFRU_IOC_QUERY_CAP - _IOR(PFRUT_IOCTL_MAGIC, 0x05, + *			     struct pfru_update_cap_info) + * + * Return: + * * 0			- success + * * -EINVAL		- query phase returns invalid result + * * -EFAULT		- the result fails to be copied to userspace + * + * Retrieve information on the Platform Firmware Runtime Update capability. + * The information is a struct pfru_update_cap_info. + */ +#define PFRU_IOC_QUERY_CAP _IOR(PFRUT_IOCTL_MAGIC, 0x05, struct pfru_update_cap_info) + +/** + * struct pfru_payload_hdr - Capsule file payload header. + * + * @sig: Signature of this capsule file. + * @hdr_version: Revision of this header structure. + * @hdr_size: Size of this header, including the OemHeader bytes. + * @hw_ver: The supported firmware version. + * @rt_ver: Version of the code injection image. + * @platform_id: A platform specific GUID to specify the platform what + *               this capsule image support. + */ +struct pfru_payload_hdr { +	__u32 sig; +	__u32 hdr_version; +	__u32 hdr_size; +	__u32 hw_ver; +	__u32 rt_ver; +	__u8 platform_id[16]; +	__u32 svn_ver; +}; + +enum pfru_dsm_status { +	DSM_SUCCEED = 0, +	DSM_FUNC_NOT_SUPPORT = 1, +	DSM_INVAL_INPUT = 2, +	DSM_HARDWARE_ERR = 3, +	DSM_RETRY_SUGGESTED = 4, +	DSM_UNKNOWN = 5, +	DSM_FUNC_SPEC_ERR = 6, +}; + +/** + * struct pfru_update_cap_info - Runtime update capability information. + * + * @status: Indicator of whether this query succeed. + * @update_cap: Bitmap to indicate whether the feature is supported. + * @code_type: A buffer containing an image type GUID. + * @fw_version: Platform firmware version. + * @code_rt_version: Code injection runtime version for anti-rollback. + * @drv_type: A buffer containing an image type GUID. + * @drv_rt_version: The version of the driver update runtime code. + * @drv_svn: The secure version number(SVN) of the driver update runtime code. + * @platform_id: A buffer containing a platform ID GUID. + * @oem_id: A buffer containing an OEM ID GUID. + * @oem_info_len: Length of the buffer containing the vendor specific information. + */ +struct pfru_update_cap_info { +	__u32 status; +	__u32 update_cap; + +	__u8 code_type[16]; +	__u32 fw_version; +	__u32 code_rt_version; + +	__u8 drv_type[16]; +	__u32 drv_rt_version; +	__u32 drv_svn; + +	__u8 platform_id[16]; +	__u8 oem_id[16]; + +	__u32 oem_info_len; +}; + +/** + * struct pfru_com_buf_info - Communication buffer information. + * + * @status: Indicator of whether this query succeed. + * @ext_status: Implementation specific query result. + * @addr_lo: Low 32bit physical address of the communication buffer to hold + *           a runtime update package. + * @addr_hi: High 32bit physical address of the communication buffer to hold + *           a runtime update package. + * @buf_size: Maximum size in bytes of the communication buffer. + */ +struct pfru_com_buf_info { +	__u32 status; +	__u32 ext_status; +	__u64 addr_lo; +	__u64 addr_hi; +	__u32 buf_size; +}; + +/** + * struct pfru_updated_result - Platform firmware runtime update result information. + * @status: Indicator of whether this update succeed. + * @ext_status: Implementation specific update result. + * @low_auth_time: Low 32bit value of image authentication time in nanosecond. + * @high_auth_time: High 32bit value of image authentication time in nanosecond. + * @low_exec_time: Low 32bit value of image execution time in nanosecond. + * @high_exec_time: High 32bit value of image execution time in nanosecond. + */ +struct pfru_updated_result { +	__u32 status; +	__u32 ext_status; +	__u64 low_auth_time; +	__u64 high_auth_time; +	__u64 low_exec_time; +	__u64 high_exec_time; +}; + +/** + * struct pfrt_log_data_info - Log Data from telemetry service. + * @status: Indicator of whether this update succeed. + * @ext_status: Implementation specific update result. + * @chunk1_addr_lo: Low 32bit physical address of the telemetry data chunk1 + *                  starting address. + * @chunk1_addr_hi: High 32bit physical address of the telemetry data chunk1 + *                  starting address. + * @chunk2_addr_lo: Low 32bit physical address of the telemetry data chunk2 + *                  starting address. + * @chunk2_addr_hi: High 32bit physical address of the telemetry data chunk2 + *                  starting address. + * @max_data_size: Maximum supported size of data of all data chunks combined. + * @chunk1_size: Data size in bytes of the telemetry data chunk1 buffer. + * @chunk2_size: Data size in bytes of the telemetry data chunk2 buffer. + * @rollover_cnt: Number of times telemetry data buffer is overwritten + *                since telemetry buffer reset. + * @reset_cnt: Number of times telemetry services resets that results in + *             rollover count and data chunk buffers are reset. + */ +struct pfrt_log_data_info { +	__u32 status; +	__u32 ext_status; +	__u64 chunk1_addr_lo; +	__u64 chunk1_addr_hi; +	__u64 chunk2_addr_lo; +	__u64 chunk2_addr_hi; +	__u32 max_data_size; +	__u32 chunk1_size; +	__u32 chunk2_size; +	__u32 rollover_cnt; +	__u32 reset_cnt; +}; + +/** + * struct pfrt_log_info - Telemetry log information. + * @log_level: The telemetry log level. + * @log_type: The telemetry log type(history and execution). + * @log_revid: The telemetry log revision id. + */ +struct pfrt_log_info { +	__u32 log_level; +	__u32 log_type; +	__u32 log_revid; +}; + +/** + * PFRT_LOG_IOC_SET_INFO - _IOW(PFRUT_IOCTL_MAGIC, 0x06, + *				struct pfrt_log_info) + * + * Return: + * * 0			- success + * * -EFAULT		- fail to get the setting parameter + * * -EINVAL		- fail to set the log level + * + * Set the PFRT log level and log type. The input information is + * a struct pfrt_log_info. + */ +#define PFRT_LOG_IOC_SET_INFO _IOW(PFRUT_IOCTL_MAGIC, 0x06, struct pfrt_log_info) + +/** + * PFRT_LOG_IOC_GET_INFO - _IOR(PFRUT_IOCTL_MAGIC, 0x07, + *				struct pfrt_log_info) + * + * Return: + * * 0			- success + * * -EINVAL		- fail to get the log level + * * -EFAULT		- fail to copy the result back to userspace + * + * Retrieve log level and log type of the telemetry. The information is + * a struct pfrt_log_info. + */ +#define PFRT_LOG_IOC_GET_INFO _IOR(PFRUT_IOCTL_MAGIC, 0x07, struct pfrt_log_info) + +/** + * PFRT_LOG_IOC_GET_DATA_INFO - _IOR(PFRUT_IOCTL_MAGIC, 0x08, + *				     struct pfrt_log_data_info) + * + * Return: + * * 0			- success + * * -EINVAL		- fail to get the log buffer information + * * -EFAULT		- fail to copy the log buffer information to userspace + * + * Retrieve data information about the telemetry. The information + * is a struct pfrt_log_data_info. + */ +#define PFRT_LOG_IOC_GET_DATA_INFO _IOR(PFRUT_IOCTL_MAGIC, 0x08, struct pfrt_log_data_info) + +#endif /* __PFRUT_H__ */ diff --git a/include/uapi/linux/pidfd.h b/include/uapi/linux/pidfd.h new file mode 100644 index 000000000000..957db425d459 --- /dev/null +++ b/include/uapi/linux/pidfd.h @@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ + +#ifndef _UAPI_LINUX_PIDFD_H +#define _UAPI_LINUX_PIDFD_H + +#include <linux/types.h> +#include <linux/fcntl.h> +#include <linux/ioctl.h> + +/* Flags for pidfd_open().  */ +#define PIDFD_NONBLOCK	O_NONBLOCK +#define PIDFD_THREAD	O_EXCL +#ifdef __KERNEL__ +#include <linux/sched.h> +#define PIDFD_STALE CLONE_PIDFD +#endif + +/* Flags for pidfd_send_signal(). */ +#define PIDFD_SIGNAL_THREAD		(1UL << 0) +#define PIDFD_SIGNAL_THREAD_GROUP	(1UL << 1) +#define PIDFD_SIGNAL_PROCESS_GROUP	(1UL << 2) + +/* Flags for pidfd_info. */ +#define PIDFD_INFO_PID			(1UL << 0) /* Always returned, even if not requested */ +#define PIDFD_INFO_CREDS		(1UL << 1) /* Always returned, even if not requested */ +#define PIDFD_INFO_CGROUPID		(1UL << 2) /* Always returned if available, even if not requested */ +#define PIDFD_INFO_EXIT			(1UL << 3) /* Only returned if requested. */ +#define PIDFD_INFO_COREDUMP		(1UL << 4) /* Only returned if requested. */ + +#define PIDFD_INFO_SIZE_VER0		64 /* sizeof first published struct */ + +/* + * Values for @coredump_mask in pidfd_info. + * Only valid if PIDFD_INFO_COREDUMP is set in @mask. + * + * Note, the @PIDFD_COREDUMP_ROOT flag indicates that the generated + * coredump should be treated as sensitive and access should only be + * granted to privileged users. + */ +#define PIDFD_COREDUMPED	(1U << 0) /* Did crash and... */ +#define PIDFD_COREDUMP_SKIP	(1U << 1) /* coredumping generation was skipped. */ +#define PIDFD_COREDUMP_USER	(1U << 2) /* coredump was done as the user. */ +#define PIDFD_COREDUMP_ROOT	(1U << 3) /* coredump was done as root. */ + +/* + * ...and for userland we make life simpler - PIDFD_SELF refers to the current + * thread, PIDFD_SELF_PROCESS refers to the process thread group leader. + * + * For nearly all practical uses, a user will want to use PIDFD_SELF. + */ +#define PIDFD_SELF		PIDFD_SELF_THREAD +#define PIDFD_SELF_PROCESS	PIDFD_SELF_THREAD_GROUP + +struct pidfd_info { +	/* +	 * This mask is similar to the request_mask in statx(2). +	 * +	 * Userspace indicates what extensions or expensive-to-calculate fields +	 * they want by setting the corresponding bits in mask. The kernel +	 * will ignore bits that it does not know about. +	 * +	 * When filling the structure, the kernel will only set bits +	 * corresponding to the fields that were actually filled by the kernel. +	 * This also includes any future extensions that might be automatically +	 * filled. If the structure size is too small to contain a field +	 * (requested or not), to avoid confusion the mask will not +	 * contain a bit for that field. +	 * +	 * As such, userspace MUST verify that mask contains the +	 * corresponding flags after the ioctl(2) returns to ensure that it is +	 * using valid data. +	 */ +	__u64 mask; +	/* +	 * The information contained in the following fields might be stale at the +	 * time it is received, as the target process might have exited as soon as +	 * the IOCTL was processed, and there is no way to avoid that. However, it +	 * is guaranteed that if the call was successful, then the information was +	 * correct and referred to the intended process at the time the work was +	 * performed. */ +	__u64 cgroupid; +	__u32 pid; +	__u32 tgid; +	__u32 ppid; +	__u32 ruid; +	__u32 rgid; +	__u32 euid; +	__u32 egid; +	__u32 suid; +	__u32 sgid; +	__u32 fsuid; +	__u32 fsgid; +	__s32 exit_code; +	__u32 coredump_mask; +	__u32 __spare1; +}; + +#define PIDFS_IOCTL_MAGIC 0xFF + +#define PIDFD_GET_CGROUP_NAMESPACE            _IO(PIDFS_IOCTL_MAGIC, 1) +#define PIDFD_GET_IPC_NAMESPACE               _IO(PIDFS_IOCTL_MAGIC, 2) +#define PIDFD_GET_MNT_NAMESPACE               _IO(PIDFS_IOCTL_MAGIC, 3) +#define PIDFD_GET_NET_NAMESPACE               _IO(PIDFS_IOCTL_MAGIC, 4) +#define PIDFD_GET_PID_NAMESPACE               _IO(PIDFS_IOCTL_MAGIC, 5) +#define PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE  _IO(PIDFS_IOCTL_MAGIC, 6) +#define PIDFD_GET_TIME_NAMESPACE              _IO(PIDFS_IOCTL_MAGIC, 7) +#define PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 8) +#define PIDFD_GET_USER_NAMESPACE              _IO(PIDFS_IOCTL_MAGIC, 9) +#define PIDFD_GET_UTS_NAMESPACE               _IO(PIDFS_IOCTL_MAGIC, 10) +#define PIDFD_GET_INFO                        _IOWR(PIDFS_IOCTL_MAGIC, 11, struct pidfd_info) + +#endif /* _UAPI_LINUX_PIDFD_H */ diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h index ee95f42fb0ec..28d94b11d1aa 100644 --- a/include/uapi/linux/pkt_cls.h +++ b/include/uapi/linux/pkt_cls.h @@ -1,6 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_PKT_CLS_H -#define __LINUX_PKT_CLS_H +#ifndef _UAPI__LINUX_PKT_CLS_H +#define _UAPI__LINUX_PKT_CLS_H  #include <linux/types.h>  #include <linux/pkt_sched.h> @@ -19,12 +19,16 @@ enum {  	TCA_ACT_FLAGS,  	TCA_ACT_HW_STATS,  	TCA_ACT_USED_HW_STATS, +	TCA_ACT_IN_HW_COUNT,  	__TCA_ACT_MAX  }; -#define TCA_ACT_FLAGS_NO_PERCPU_STATS 1 /* Don't use percpu allocator for -					 * actions stats. -					 */ +/* See other TCA_ACT_FLAGS_ * flags in include/net/act_api.h. */ +#define TCA_ACT_FLAGS_NO_PERCPU_STATS (1 << 0) /* Don't use percpu allocator for +						* actions stats. +						*/ +#define TCA_ACT_FLAGS_SKIP_HW	(1 << 1) /* don't offload action to HW */ +#define TCA_ACT_FLAGS_SKIP_SW	(1 << 2) /* don't use action in SW */  /* tca HW stats type   * When user does not pass the attribute, he does not care. @@ -95,7 +99,7 @@ enum {   * versions.   */  #define TCA_ACT_GACT 5 -#define TCA_ACT_IPT 6 +#define TCA_ACT_IPT 6 /* obsoleted, can be reused */  #define TCA_ACT_PEDIT 7  #define TCA_ACT_MIRRED 8  #define TCA_ACT_NAT 9 @@ -116,7 +120,7 @@ enum tca_id {  	TCA_ID_UNSPEC = 0,  	TCA_ID_POLICE = 1,  	TCA_ID_GACT = TCA_ACT_GACT, -	TCA_ID_IPT = TCA_ACT_IPT, +	TCA_ID_IPT = TCA_ACT_IPT, /* Obsoleted, can be reused */  	TCA_ID_PEDIT = TCA_ACT_PEDIT,  	TCA_ID_MIRRED = TCA_ACT_MIRRED,  	TCA_ID_NAT = TCA_ACT_NAT, @@ -190,6 +194,8 @@ enum {  	TCA_POLICE_PAD,  	TCA_POLICE_RATE64,  	TCA_POLICE_PEAKRATE64, +	TCA_POLICE_PKTRATE64, +	TCA_POLICE_PKTBURST64,  	__TCA_POLICE_MAX  #define TCA_POLICE_RESULT TCA_POLICE_RESULT  }; @@ -240,17 +246,20 @@ struct tc_u32_key {  };  struct tc_u32_sel { -	unsigned char		flags; -	unsigned char		offshift; -	unsigned char		nkeys; +	/* New members MUST be added within the __struct_group() macro below. */ +	__struct_group(tc_u32_sel_hdr, hdr, /* no attrs */, +		unsigned char		flags; +		unsigned char		offshift; +		unsigned char		nkeys; -	__be16			offmask; -	__u16			off; -	short			offoff; +		__be16			offmask; +		__u16			off; +		short			offoff; -	short			hoff; -	__be32			hmask; -	struct tc_u32_key	keys[0]; +		short			hoff; +		__be32			hmask; +	); +	struct tc_u32_key	keys[];  };  struct tc_u32_mark { @@ -262,7 +271,7 @@ struct tc_u32_mark {  struct tc_u32_pcnt {  	__u64 rcnt;  	__u64 rhit; -	__u64 kcnts[0]; +	__u64 kcnts[];  };  /* Flags */ @@ -274,37 +283,6 @@ struct tc_u32_pcnt {  #define TC_U32_MAXDEPTH 8 - -/* RSVP filter */ - -enum { -	TCA_RSVP_UNSPEC, -	TCA_RSVP_CLASSID, -	TCA_RSVP_DST, -	TCA_RSVP_SRC, -	TCA_RSVP_PINFO, -	TCA_RSVP_POLICE, -	TCA_RSVP_ACT, -	__TCA_RSVP_MAX -}; - -#define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 ) - -struct tc_rsvp_gpi { -	__u32	key; -	__u32	mask; -	int	offset; -}; - -struct tc_rsvp_pinfo { -	struct tc_rsvp_gpi dpi; -	struct tc_rsvp_gpi spi; -	__u8	protocol; -	__u8	tunnelid; -	__u8	tunnelhdr; -	__u8	pad; -}; -  /* ROUTE filter */  enum { @@ -335,22 +313,6 @@ enum {  #define TCA_FW_MAX (__TCA_FW_MAX - 1) -/* TC index filter */ - -enum { -	TCA_TCINDEX_UNSPEC, -	TCA_TCINDEX_HASH, -	TCA_TCINDEX_MASK, -	TCA_TCINDEX_SHIFT, -	TCA_TCINDEX_FALL_THROUGH, -	TCA_TCINDEX_CLASSID, -	TCA_TCINDEX_POLICE, -	TCA_TCINDEX_ACT, -	__TCA_TCINDEX_MAX -}; - -#define TCA_TCINDEX_MAX     (__TCA_TCINDEX_MAX - 1) -  /* Flow filter */  enum { @@ -581,6 +543,23 @@ enum {  	TCA_FLOWER_KEY_HASH,		/* u32 */  	TCA_FLOWER_KEY_HASH_MASK,	/* u32 */ +	TCA_FLOWER_KEY_NUM_OF_VLANS,    /* u8 */ + +	TCA_FLOWER_KEY_PPPOE_SID,	/* be16 */ +	TCA_FLOWER_KEY_PPP_PROTO,	/* be16 */ + +	TCA_FLOWER_KEY_L2TPV3_SID,	/* be32 */ + +	TCA_FLOWER_L2_MISS,		/* u8 */ + +	TCA_FLOWER_KEY_CFM,		/* nested */ + +	TCA_FLOWER_KEY_SPI,		/* be32 */ +	TCA_FLOWER_KEY_SPI_MASK,	/* be32 */ + +	TCA_FLOWER_KEY_ENC_FLAGS,	/* be32 */ +	TCA_FLOWER_KEY_ENC_FLAGS_MASK,	/* be32 */ +  	__TCA_FLOWER_MAX,  }; @@ -591,6 +570,9 @@ enum {  	TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED = 1 << 1, /* Part of an existing connection. */  	TCA_FLOWER_KEY_CT_FLAGS_RELATED = 1 << 2, /* Related to an established connection. */  	TCA_FLOWER_KEY_CT_FLAGS_TRACKED = 1 << 3, /* Conntrack has occurred. */ +	TCA_FLOWER_KEY_CT_FLAGS_INVALID = 1 << 4, /* Conntrack is invalid. */ +	TCA_FLOWER_KEY_CT_FLAGS_REPLY = 1 << 5, /* Packet is in the reply direction. */ +	__TCA_FLOWER_KEY_CT_FLAGS_MAX,  };  enum { @@ -607,6 +589,14 @@ enum {  					 * TCA_FLOWER_KEY_ENC_OPT_ERSPAN_  					 * attributes  					 */ +	TCA_FLOWER_KEY_ENC_OPTS_GTP,	/* Nested +					 * TCA_FLOWER_KEY_ENC_OPT_GTP_ +					 * attributes +					 */ +	TCA_FLOWER_KEY_ENC_OPTS_PFCP,	/* Nested +					 * TCA_FLOWER_KEY_ENC_IPT_PFCP +					 * attributes +					 */  	__TCA_FLOWER_KEY_ENC_OPTS_MAX,  }; @@ -646,6 +636,27 @@ enum {  		(__TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX - 1)  enum { +	TCA_FLOWER_KEY_ENC_OPT_GTP_UNSPEC, +	TCA_FLOWER_KEY_ENC_OPT_GTP_PDU_TYPE,		/* u8 */ +	TCA_FLOWER_KEY_ENC_OPT_GTP_QFI,			/* u8 */ + +	__TCA_FLOWER_KEY_ENC_OPT_GTP_MAX, +}; + +#define TCA_FLOWER_KEY_ENC_OPT_GTP_MAX \ +		(__TCA_FLOWER_KEY_ENC_OPT_GTP_MAX - 1) + +enum { +	TCA_FLOWER_KEY_ENC_OPT_PFCP_UNSPEC, +	TCA_FLOWER_KEY_ENC_OPT_PFCP_TYPE,		/* u8 */ +	TCA_FLOWER_KEY_ENC_OPT_PFCP_SEID,		/* be64 */ +	__TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX, +}; + +#define TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX \ +		(__TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX - 1) + +enum {  	TCA_FLOWER_KEY_MPLS_OPTS_UNSPEC,  	TCA_FLOWER_KEY_MPLS_OPTS_LSE,  	__TCA_FLOWER_KEY_MPLS_OPTS_MAX, @@ -669,8 +680,25 @@ enum {  enum {  	TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),  	TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1), +	TCA_FLOWER_KEY_FLAGS_TUNNEL_CSUM = (1 << 2), +	TCA_FLOWER_KEY_FLAGS_TUNNEL_DONT_FRAGMENT = (1 << 3), +	TCA_FLOWER_KEY_FLAGS_TUNNEL_OAM = (1 << 4), +	TCA_FLOWER_KEY_FLAGS_TUNNEL_CRIT_OPT = (1 << 5), +	__TCA_FLOWER_KEY_FLAGS_MAX,  }; +#define TCA_FLOWER_KEY_FLAGS_MAX (__TCA_FLOWER_KEY_FLAGS_MAX - 1) + +enum { +	TCA_FLOWER_KEY_CFM_OPT_UNSPEC, +	TCA_FLOWER_KEY_CFM_MD_LEVEL, +	TCA_FLOWER_KEY_CFM_OPCODE, +	__TCA_FLOWER_KEY_CFM_OPT_MAX, +}; + +#define TCA_FLOWER_KEY_CFM_OPT_MAX (__TCA_FLOWER_KEY_CFM_OPT_MAX - 1) +#define TCA_FLOWER_KEY_CFM_MAX	   (__TCA_FLOWER_KEY_CFM_OPT_MAX - 1) +  #define TCA_FLOWER_MASK_FLAGS_RANGE	(1 << 0) /* Range-based match */  /* Match-all classifier */ diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h index 9e7c2c607845..c2da76e78bad 100644 --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h @@ -1,6 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_PKT_SCHED_H -#define __LINUX_PKT_SCHED_H +#ifndef _UAPI__LINUX_PKT_SCHED_H +#define _UAPI__LINUX_PKT_SCHED_H  #include <linux/const.h>  #include <linux/types.h> @@ -434,6 +434,7 @@ enum {  	TCA_HTB_RATE64,  	TCA_HTB_CEIL64,  	TCA_HTB_PAD, +	TCA_HTB_OFFLOAD,  	__TCA_HTB_MAX,  }; @@ -476,115 +477,6 @@ enum {  #define TCA_HFSC_MAX (__TCA_HFSC_MAX - 1) - -/* CBQ section */ - -#define TC_CBQ_MAXPRIO		8 -#define TC_CBQ_MAXLEVEL		8 -#define TC_CBQ_DEF_EWMA		5 - -struct tc_cbq_lssopt { -	unsigned char	change; -	unsigned char	flags; -#define TCF_CBQ_LSS_BOUNDED	1 -#define TCF_CBQ_LSS_ISOLATED	2 -	unsigned char  	ewma_log; -	unsigned char  	level; -#define TCF_CBQ_LSS_FLAGS	1 -#define TCF_CBQ_LSS_EWMA	2 -#define TCF_CBQ_LSS_MAXIDLE	4 -#define TCF_CBQ_LSS_MINIDLE	8 -#define TCF_CBQ_LSS_OFFTIME	0x10 -#define TCF_CBQ_LSS_AVPKT	0x20 -	__u32		maxidle; -	__u32		minidle; -	__u32		offtime; -	__u32		avpkt; -}; - -struct tc_cbq_wrropt { -	unsigned char	flags; -	unsigned char	priority; -	unsigned char	cpriority; -	unsigned char	__reserved; -	__u32		allot; -	__u32		weight; -}; - -struct tc_cbq_ovl { -	unsigned char	strategy; -#define	TC_CBQ_OVL_CLASSIC	0 -#define	TC_CBQ_OVL_DELAY	1 -#define	TC_CBQ_OVL_LOWPRIO	2 -#define	TC_CBQ_OVL_DROP		3 -#define	TC_CBQ_OVL_RCLASSIC	4 -	unsigned char	priority2; -	__u16		pad; -	__u32		penalty; -}; - -struct tc_cbq_police { -	unsigned char	police; -	unsigned char	__res1; -	unsigned short	__res2; -}; - -struct tc_cbq_fopt { -	__u32		split; -	__u32		defmap; -	__u32		defchange; -}; - -struct tc_cbq_xstats { -	__u32		borrows; -	__u32		overactions; -	__s32		avgidle; -	__s32		undertime; -}; - -enum { -	TCA_CBQ_UNSPEC, -	TCA_CBQ_LSSOPT, -	TCA_CBQ_WRROPT, -	TCA_CBQ_FOPT, -	TCA_CBQ_OVL_STRATEGY, -	TCA_CBQ_RATE, -	TCA_CBQ_RTAB, -	TCA_CBQ_POLICE, -	__TCA_CBQ_MAX, -}; - -#define TCA_CBQ_MAX	(__TCA_CBQ_MAX - 1) - -/* dsmark section */ - -enum { -	TCA_DSMARK_UNSPEC, -	TCA_DSMARK_INDICES, -	TCA_DSMARK_DEFAULT_INDEX, -	TCA_DSMARK_SET_TC_INDEX, -	TCA_DSMARK_MASK, -	TCA_DSMARK_VALUE, -	__TCA_DSMARK_MAX, -}; - -#define TCA_DSMARK_MAX (__TCA_DSMARK_MAX - 1) - -/* ATM  section */ - -enum { -	TCA_ATM_UNSPEC, -	TCA_ATM_FD,		/* file/socket descriptor */ -	TCA_ATM_PTR,		/* pointer to descriptor - later */ -	TCA_ATM_HDR,		/* LL header */ -	TCA_ATM_EXCESS,		/* excess traffic class (0 for CLP)  */ -	TCA_ATM_ADDR,		/* PVC address (for output only) */ -	TCA_ATM_STATE,		/* VC state (ATM_VS_*; for output only) */ -	__TCA_ATM_MAX, -}; - -#define TCA_ATM_MAX	(__TCA_ATM_MAX - 1) -  /* Network emulator */  enum { @@ -602,6 +494,7 @@ enum {  	TCA_NETEM_JITTER64,  	TCA_NETEM_SLOT,  	TCA_NETEM_SLOT_DIST, +	TCA_NETEM_PRNG_SEED,  	__TCA_NETEM_MAX,  }; @@ -718,6 +611,11 @@ enum {  #define __TC_MQPRIO_SHAPER_MAX (__TC_MQPRIO_SHAPER_MAX - 1) +enum { +	TC_FP_EXPRESS = 1, +	TC_FP_PREEMPTIBLE = 2, +}; +  struct tc_mqprio_qopt {  	__u8	num_tc;  	__u8	prio_tc_map[TC_QOPT_BITMASK + 1]; @@ -732,11 +630,22 @@ struct tc_mqprio_qopt {  #define TC_MQPRIO_F_MAX_RATE		0x8  enum { +	TCA_MQPRIO_TC_ENTRY_UNSPEC, +	TCA_MQPRIO_TC_ENTRY_INDEX,		/* u32 */ +	TCA_MQPRIO_TC_ENTRY_FP,			/* u32 */ + +	/* add new constants above here */ +	__TCA_MQPRIO_TC_ENTRY_CNT, +	TCA_MQPRIO_TC_ENTRY_MAX = (__TCA_MQPRIO_TC_ENTRY_CNT - 1) +}; + +enum {  	TCA_MQPRIO_UNSPEC,  	TCA_MQPRIO_MODE,  	TCA_MQPRIO_SHAPER,  	TCA_MQPRIO_MIN_RATE64,  	TCA_MQPRIO_MAX_RATE64, +	TCA_MQPRIO_TC_ENTRY,  	__TCA_MQPRIO_MAX,  }; @@ -826,6 +735,8 @@ struct tc_codel_xstats {  /* FQ_CODEL */ +#define FQ_CODEL_QUANTUM_MAX (1 << 20) +  enum {  	TCA_FQ_CODEL_UNSPEC,  	TCA_FQ_CODEL_TARGET, @@ -837,6 +748,8 @@ enum {  	TCA_FQ_CODEL_CE_THRESHOLD,  	TCA_FQ_CODEL_DROP_BATCH_SIZE,  	TCA_FQ_CODEL_MEMORY_LIMIT, +	TCA_FQ_CODEL_CE_THRESHOLD_SELECTOR, +	TCA_FQ_CODEL_CE_THRESHOLD_MASK,  	__TCA_FQ_CODEL_MAX  }; @@ -919,15 +832,24 @@ enum {  	TCA_FQ_HORIZON_DROP,	/* drop packets beyond horizon, or cap their EDT */ +	TCA_FQ_PRIOMAP,		/* prio2band */ + +	TCA_FQ_WEIGHTS,		/* Weights for each band */ + +	TCA_FQ_OFFLOAD_HORIZON, /* dequeue paced packets within this horizon immediately (us units) */ +  	__TCA_FQ_MAX  };  #define TCA_FQ_MAX	(__TCA_FQ_MAX - 1) +#define FQ_BANDS 3 +#define FQ_MIN_WEIGHT 16384 +  struct tc_fq_qd_stats {  	__u64	gc_flows; -	__u64	highprio_packets; -	__u64	tcp_retrans; +	__u64	highprio_packets;	/* obsolete */ +	__u64	tcp_retrans;		/* obsolete */  	__u64	throttled;  	__u64	flows_plimit;  	__u64	pkts_too_long; @@ -940,6 +862,10 @@ struct tc_fq_qd_stats {  	__u64	ce_mark;		/* packets above ce_threshold */  	__u64	horizon_drops;  	__u64	horizon_caps; +	__u64	fastpath_packets; +	__u64	band_drops[FQ_BANDS]; +	__u32	band_pkt_count[FQ_BANDS]; +	__u32	pad;  };  /* Heavy-Hitter Filter */ @@ -1228,6 +1154,27 @@ enum {  #define TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD	_BITUL(1)  enum { +	TCA_TAPRIO_TC_ENTRY_UNSPEC, +	TCA_TAPRIO_TC_ENTRY_INDEX,		/* u32 */ +	TCA_TAPRIO_TC_ENTRY_MAX_SDU,		/* u32 */ +	TCA_TAPRIO_TC_ENTRY_FP,			/* u32 */ + +	/* add new constants above here */ +	__TCA_TAPRIO_TC_ENTRY_CNT, +	TCA_TAPRIO_TC_ENTRY_MAX = (__TCA_TAPRIO_TC_ENTRY_CNT - 1) +}; + +enum { +	TCA_TAPRIO_OFFLOAD_STATS_PAD = 1,	/* u64 */ +	TCA_TAPRIO_OFFLOAD_STATS_WINDOW_DROPS,	/* u64 */ +	TCA_TAPRIO_OFFLOAD_STATS_TX_OVERRUNS,	/* u64 */ + +	/* add new constants above here */ +	__TCA_TAPRIO_OFFLOAD_STATS_CNT, +	TCA_TAPRIO_OFFLOAD_STATS_MAX = (__TCA_TAPRIO_OFFLOAD_STATS_CNT - 1) +}; + +enum {  	TCA_TAPRIO_ATTR_UNSPEC,  	TCA_TAPRIO_ATTR_PRIOMAP, /* struct tc_mqprio_qopt */  	TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST, /* nested of entry */ @@ -1235,11 +1182,13 @@ enum {  	TCA_TAPRIO_ATTR_SCHED_SINGLE_ENTRY, /* single entry */  	TCA_TAPRIO_ATTR_SCHED_CLOCKID, /* s32 */  	TCA_TAPRIO_PAD, +	TCA_TAPRIO_ATTR_PAD = TCA_TAPRIO_PAD,  	TCA_TAPRIO_ATTR_ADMIN_SCHED, /* The admin sched, only used in dump */  	TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME, /* s64 */  	TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION, /* s64 */  	TCA_TAPRIO_ATTR_FLAGS, /* u32 */  	TCA_TAPRIO_ATTR_TXTIME_DELAY, /* u32 */ +	TCA_TAPRIO_ATTR_TC_ENTRY, /* nest */  	__TCA_TAPRIO_ATTR_MAX,  }; @@ -1262,4 +1211,72 @@ enum {  #define TCA_ETS_MAX (__TCA_ETS_MAX - 1) +/* DUALPI2 */ +enum tc_dualpi2_drop_overload { +	TC_DUALPI2_DROP_OVERLOAD_OVERFLOW = 0, +	TC_DUALPI2_DROP_OVERLOAD_DROP = 1, +	__TCA_DUALPI2_DROP_OVERLOAD_MAX, +}; +#define TCA_DUALPI2_DROP_OVERLOAD_MAX (__TCA_DUALPI2_DROP_OVERLOAD_MAX - 1) + +enum tc_dualpi2_drop_early { +	TC_DUALPI2_DROP_EARLY_DROP_DEQUEUE = 0, +	TC_DUALPI2_DROP_EARLY_DROP_ENQUEUE = 1, +	__TCA_DUALPI2_DROP_EARLY_MAX, +}; +#define TCA_DUALPI2_DROP_EARLY_MAX (__TCA_DUALPI2_DROP_EARLY_MAX - 1) + +enum tc_dualpi2_ecn_mask { +	TC_DUALPI2_ECN_MASK_L4S_ECT = 1, +	TC_DUALPI2_ECN_MASK_CLA_ECT = 2, +	TC_DUALPI2_ECN_MASK_ANY_ECT = 3, +	__TCA_DUALPI2_ECN_MASK_MAX, +}; +#define TCA_DUALPI2_ECN_MASK_MAX (__TCA_DUALPI2_ECN_MASK_MAX - 1) + +enum tc_dualpi2_split_gso { +	TC_DUALPI2_SPLIT_GSO_NO_SPLIT_GSO = 0, +	TC_DUALPI2_SPLIT_GSO_SPLIT_GSO = 1, +	__TCA_DUALPI2_SPLIT_GSO_MAX, +}; +#define TCA_DUALPI2_SPLIT_GSO_MAX (__TCA_DUALPI2_SPLIT_GSO_MAX - 1) + +enum { +	TCA_DUALPI2_UNSPEC, +	TCA_DUALPI2_LIMIT,		/* Packets */ +	TCA_DUALPI2_MEMORY_LIMIT,	/* Bytes */ +	TCA_DUALPI2_TARGET,		/* us */ +	TCA_DUALPI2_TUPDATE,		/* us */ +	TCA_DUALPI2_ALPHA,		/* Hz scaled up by 256 */ +	TCA_DUALPI2_BETA,		/* Hz scaled up by 256 */ +	TCA_DUALPI2_STEP_THRESH_PKTS,	/* Step threshold in packets */ +	TCA_DUALPI2_STEP_THRESH_US,	/* Step threshold in microseconds */ +	TCA_DUALPI2_MIN_QLEN_STEP,	/* Minimum qlen to apply STEP_THRESH */ +	TCA_DUALPI2_COUPLING,		/* Coupling factor between queues */ +	TCA_DUALPI2_DROP_OVERLOAD,	/* Whether to drop on overload */ +	TCA_DUALPI2_DROP_EARLY,		/* Whether to drop on enqueue */ +	TCA_DUALPI2_C_PROTECTION,	/* Percentage */ +	TCA_DUALPI2_ECN_MASK,		/* L4S queue classification mask */ +	TCA_DUALPI2_SPLIT_GSO,		/* Split GSO packets at enqueue */ +	TCA_DUALPI2_PAD, +	__TCA_DUALPI2_MAX +}; + +#define TCA_DUALPI2_MAX   (__TCA_DUALPI2_MAX - 1) + +struct tc_dualpi2_xstats { +	__u32 prob;		/* current probability */ +	__u32 delay_c;		/* current delay in C queue */ +	__u32 delay_l;		/* current delay in L queue */ +	__u32 packets_in_c;	/* number of packets enqueued in C queue */ +	__u32 packets_in_l;	/* number of packets enqueued in L queue */ +	__u32 maxq;		/* maximum queue size */ +	__u32 ecn_mark;		/* packets marked with ecn*/ +	__u32 step_marks;	/* ECN marks due to the step AQM */ +	__s32 credit;		/* current c_protection credit */ +	__u32 memory_used;	/* Memory used by both queues */ +	__u32 max_memory_used;	/* Maximum used memory */ +	__u32 memory_limit;	/* Memory limit of both queues */ +}; +  #endif diff --git a/include/uapi/linux/pktcdvd.h b/include/uapi/linux/pktcdvd.h index 9cbb55d21c94..987a3022dc5f 100644 --- a/include/uapi/linux/pktcdvd.h +++ b/include/uapi/linux/pktcdvd.h @@ -16,6 +16,7 @@  #include <linux/types.h>  /* + * UNUSED:   * 1 for normal debug messages, 2 is very verbose. 0 to turn it off.   */  #define PACKET_DEBUG		1 @@ -30,17 +31,6 @@  #define PACKET_WAIT_TIME	(HZ * 5 / 1000)  /* - * use drive write caching -- we need deferred error handling to be - * able to successfully recover with this option (drive will return good - * status as soon as the cdb is validated). - */ -#if defined(CONFIG_CDROM_PKTCDVD_WCACHE) -#define USE_WCACHING		1 -#else -#define USE_WCACHING		0 -#endif - -/*   * No user-servicable parts beyond this point ->   */ diff --git a/include/uapi/linux/ppp-ioctl.h b/include/uapi/linux/ppp-ioctl.h index 7bd2a5a75348..1cc5ce0ae062 100644 --- a/include/uapi/linux/ppp-ioctl.h +++ b/include/uapi/linux/ppp-ioctl.h @@ -115,6 +115,8 @@ struct pppol2tp_ioc_stats {  #define PPPIOCATTCHAN	_IOW('t', 56, int)	/* attach to ppp channel */  #define PPPIOCGCHAN	_IOR('t', 55, int)	/* get ppp channel number */  #define PPPIOCGL2TPSTATS _IOR('t', 54, struct pppol2tp_ioc_stats) +#define PPPIOCBRIDGECHAN _IOW('t', 53, int)	/* bridge one channel to another */ +#define PPPIOCUNBRIDGECHAN _IO('t', 52)	/* unbridge channel */  #define SIOCGPPPSTATS   (SIOCDEVPRIVATE + 0)  #define SIOCGPPPVER     (SIOCDEVPRIVATE + 1)	/* NEVER change this!! */ diff --git a/include/uapi/linux/pps_gen.h b/include/uapi/linux/pps_gen.h new file mode 100644 index 000000000000..60a5d0fcfa68 --- /dev/null +++ b/include/uapi/linux/pps_gen.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * PPS generator API header + * + * Copyright (C) 2024 Rodolfo Giometti <giometti@enneenne.com> + */ + +#ifndef _PPS_GEN_H_ +#define _PPS_GEN_H_ + +#include <linux/types.h> +#include <linux/ioctl.h> + +/** + * struct pps_gen_event - the PPS generator events + * @event: the event type + * @sequence: the event sequence number + * + * Userspace can get the last PPS generator event by using the + * ioctl(pps_gen, PPS_GEN_FETCHEVENT, ...) syscall. + * The sequence field can be used to save the last event ID, while in the + * event field is stored the last event type. Currently known event is: + * + *     PPS_GEN_EVENT_MISSEDPULSE	: last pulse was not generated + */ +struct pps_gen_event { +	unsigned int event; +	unsigned int sequence; +}; + +#define PPS_GEN_EVENT_MISSEDPULSE	1 + +#define PPS_GEN_SETENABLE		_IOW('p', 0xb1, unsigned int *) +#define PPS_GEN_USESYSTEMCLOCK		_IOR('p', 0xb2, unsigned int *) +#define PPS_GEN_FETCHEVENT		_IOR('p', 0xb3, struct pps_gen_event *) + +#endif /* _PPS_GEN_H_ */ diff --git a/include/uapi/linux/pr.h b/include/uapi/linux/pr.h index ccc78cbf1221..d8126415966f 100644 --- a/include/uapi/linux/pr.h +++ b/include/uapi/linux/pr.h @@ -4,6 +4,23 @@  #include <linux/types.h> +enum pr_status { +	PR_STS_SUCCESS			= 0x0, +	/* +	 * The following error codes are based on SCSI, because the interface +	 * was originally created for it and has existing users. +	 */ +	/* Generic device failure. */ +	PR_STS_IOERR			= 0x2, +	PR_STS_RESERVATION_CONFLICT	= 0x18, +	/* Temporary path failure that can be retried. */ +	PR_STS_RETRY_PATH_FAILURE	= 0xe0000, +	/* The request was failed due to a fast failure timer. */ +	PR_STS_PATH_FAST_FAILED		= 0xf0000, +	/* The path cannot be reached and has been marked as failed. */ +	PR_STS_PATH_FAILED		= 0x10000, +}; +  enum pr_type {  	PR_WRITE_EXCLUSIVE		= 1,  	PR_EXCLUSIVE_ACCESS		= 2, diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index 07b4f8131e36..ed3aed264aeb 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -213,6 +213,7 @@ struct prctl_mm_map {  /* Speculation control variants */  # define PR_SPEC_STORE_BYPASS		0  # define PR_SPEC_INDIRECT_BRANCH	1 +# define PR_SPEC_L1D_FLUSH		2  /* Return and control values for PR_SET/GET_SPECULATION_CTRL */  # define PR_SPEC_NOT_AFFECTED		0  # define PR_SPEC_PRCTL			(1UL << 0) @@ -229,13 +230,150 @@ struct prctl_mm_map {  # define PR_PAC_APDBKEY			(1UL << 3)  # define PR_PAC_APGAKEY			(1UL << 4) -/* Tagged user address controls for arm64 */ +/* Tagged user address controls for arm64 and RISC-V */  #define PR_SET_TAGGED_ADDR_CTRL		55  #define PR_GET_TAGGED_ADDR_CTRL		56  # define PR_TAGGED_ADDR_ENABLE		(1UL << 0) +/* MTE tag check fault modes */ +# define PR_MTE_TCF_NONE		0UL +# define PR_MTE_TCF_SYNC		(1UL << 1) +# define PR_MTE_TCF_ASYNC		(1UL << 2) +# define PR_MTE_TCF_MASK		(PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC) +/* MTE tag inclusion mask */ +# define PR_MTE_TAG_SHIFT		3 +# define PR_MTE_TAG_MASK		(0xffffUL << PR_MTE_TAG_SHIFT) +/* Unused; kept only for source compatibility */ +# define PR_MTE_TCF_SHIFT		1 +/* MTE tag check store only */ +# define PR_MTE_STORE_ONLY		(1UL << 19) +/* RISC-V pointer masking tag length */ +# define PR_PMLEN_SHIFT			24 +# define PR_PMLEN_MASK			(0x7fUL << PR_PMLEN_SHIFT)  /* Control reclaim behavior when allocating memory */  #define PR_SET_IO_FLUSHER		57  #define PR_GET_IO_FLUSHER		58 +/* Dispatch syscalls to a userspace handler */ +#define PR_SET_SYSCALL_USER_DISPATCH	59 +# define PR_SYS_DISPATCH_OFF		0 +/* Enable dispatch except for the specified range */ +# define PR_SYS_DISPATCH_EXCLUSIVE_ON	1 +/* Enable dispatch for the specified range */ +# define PR_SYS_DISPATCH_INCLUSIVE_ON	2 +/* Legacy name for backwards compatibility */ +# define PR_SYS_DISPATCH_ON		PR_SYS_DISPATCH_EXCLUSIVE_ON +/* The control values for the user space selector when dispatch is enabled */ +# define SYSCALL_DISPATCH_FILTER_ALLOW	0 +# define SYSCALL_DISPATCH_FILTER_BLOCK	1 + +/* Set/get enabled arm64 pointer authentication keys */ +#define PR_PAC_SET_ENABLED_KEYS		60 +#define PR_PAC_GET_ENABLED_KEYS		61 + +/* Request the scheduler to share a core */ +#define PR_SCHED_CORE			62 +# define PR_SCHED_CORE_GET		0 +# define PR_SCHED_CORE_CREATE		1 /* create unique core_sched cookie */ +# define PR_SCHED_CORE_SHARE_TO		2 /* push core_sched cookie to pid */ +# define PR_SCHED_CORE_SHARE_FROM	3 /* pull core_sched cookie to pid */ +# define PR_SCHED_CORE_MAX		4 +# define PR_SCHED_CORE_SCOPE_THREAD		0 +# define PR_SCHED_CORE_SCOPE_THREAD_GROUP	1 +# define PR_SCHED_CORE_SCOPE_PROCESS_GROUP	2 + +/* arm64 Scalable Matrix Extension controls */ +/* Flag values must be in sync with SVE versions */ +#define PR_SME_SET_VL			63	/* set task vector length */ +# define PR_SME_SET_VL_ONEXEC		(1 << 18) /* defer effect until exec */ +#define PR_SME_GET_VL			64	/* get task vector length */ +/* Bits common to PR_SME_SET_VL and PR_SME_GET_VL */ +# define PR_SME_VL_LEN_MASK		0xffff +# define PR_SME_VL_INHERIT		(1 << 17) /* inherit across exec */ + +/* Memory deny write / execute */ +#define PR_SET_MDWE			65 +# define PR_MDWE_REFUSE_EXEC_GAIN	(1UL << 0) +# define PR_MDWE_NO_INHERIT		(1UL << 1) + +#define PR_GET_MDWE			66 + +#define PR_SET_VMA		0x53564d41 +# define PR_SET_VMA_ANON_NAME		0 + +#define PR_GET_AUXV			0x41555856 + +#define PR_SET_MEMORY_MERGE		67 +#define PR_GET_MEMORY_MERGE		68 + +#define PR_RISCV_V_SET_CONTROL		69 +#define PR_RISCV_V_GET_CONTROL		70 +# define PR_RISCV_V_VSTATE_CTRL_DEFAULT		0 +# define PR_RISCV_V_VSTATE_CTRL_OFF		1 +# define PR_RISCV_V_VSTATE_CTRL_ON		2 +# define PR_RISCV_V_VSTATE_CTRL_INHERIT		(1 << 4) +# define PR_RISCV_V_VSTATE_CTRL_CUR_MASK	0x3 +# define PR_RISCV_V_VSTATE_CTRL_NEXT_MASK	0xc +# define PR_RISCV_V_VSTATE_CTRL_MASK		0x1f + +#define PR_RISCV_SET_ICACHE_FLUSH_CTX	71 +# define PR_RISCV_CTX_SW_FENCEI_ON	0 +# define PR_RISCV_CTX_SW_FENCEI_OFF	1 +# define PR_RISCV_SCOPE_PER_PROCESS	0 +# define PR_RISCV_SCOPE_PER_THREAD	1 + +/* PowerPC Dynamic Execution Control Register (DEXCR) controls */ +#define PR_PPC_GET_DEXCR		72 +#define PR_PPC_SET_DEXCR		73 +/* DEXCR aspect to act on */ +# define PR_PPC_DEXCR_SBHE		0 /* Speculative branch hint enable */ +# define PR_PPC_DEXCR_IBRTPD		1 /* Indirect branch recurrent target prediction disable */ +# define PR_PPC_DEXCR_SRAPD		2 /* Subroutine return address prediction disable */ +# define PR_PPC_DEXCR_NPHIE		3 /* Non-privileged hash instruction enable */ +/* Action to apply / return */ +# define PR_PPC_DEXCR_CTRL_EDITABLE	 0x1 /* Aspect can be modified with PR_PPC_SET_DEXCR */ +# define PR_PPC_DEXCR_CTRL_SET		 0x2 /* Set the aspect for this process */ +# define PR_PPC_DEXCR_CTRL_CLEAR	 0x4 /* Clear the aspect for this process */ +# define PR_PPC_DEXCR_CTRL_SET_ONEXEC	 0x8 /* Set the aspect on exec */ +# define PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC	0x10 /* Clear the aspect on exec */ +# define PR_PPC_DEXCR_CTRL_MASK		0x1f + +/* + * Get the current shadow stack configuration for the current thread, + * this will be the value configured via PR_SET_SHADOW_STACK_STATUS. + */ +#define PR_GET_SHADOW_STACK_STATUS      74 + +/* + * Set the current shadow stack configuration.  Enabling the shadow + * stack will cause a shadow stack to be allocated for the thread. + */ +#define PR_SET_SHADOW_STACK_STATUS      75 +# define PR_SHADOW_STACK_ENABLE         (1UL << 0) +# define PR_SHADOW_STACK_WRITE		(1UL << 1) +# define PR_SHADOW_STACK_PUSH		(1UL << 2) + +/* + * Prevent further changes to the specified shadow stack + * configuration.  All bits may be locked via this call, including + * undefined bits. + */ +#define PR_LOCK_SHADOW_STACK_STATUS      76 + +/* + * Controls the mode of timer_create() for CRIU restore operations. + * Enabling this allows CRIU to restore timers with explicit IDs. + * + * Don't use for normal operations as the result might be undefined. + */ +#define PR_TIMER_CREATE_RESTORE_IDS		77 +# define PR_TIMER_CREATE_RESTORE_IDS_OFF	0 +# define PR_TIMER_CREATE_RESTORE_IDS_ON		1 +# define PR_TIMER_CREATE_RESTORE_IDS_GET	2 + +/* FUTEX hash management */ +#define PR_FUTEX_HASH			78 +# define PR_FUTEX_HASH_SET_SLOTS	1 +# define PR_FUTEX_HASH_GET_SLOTS	2 +  #endif /* _LINUX_PRCTL_H */ diff --git a/include/uapi/linux/psample.h b/include/uapi/linux/psample.h index aea26ab1431c..b765f0e81f20 100644 --- a/include/uapi/linux/psample.h +++ b/include/uapi/linux/psample.h @@ -3,18 +3,31 @@  #define __UAPI_PSAMPLE_H  enum { -	/* sampled packet metadata */  	PSAMPLE_ATTR_IIFINDEX,  	PSAMPLE_ATTR_OIFINDEX,  	PSAMPLE_ATTR_ORIGSIZE,  	PSAMPLE_ATTR_SAMPLE_GROUP,  	PSAMPLE_ATTR_GROUP_SEQ, -	PSAMPLE_ATTR_SAMPLE_RATE, +	PSAMPLE_ATTR_SAMPLE_RATE,	/* u32, ratio between observed and +					 * sampled packets or scaled probability +					 * if PSAMPLE_ATTR_SAMPLE_PROBABILITY +					 * is set. +					 */  	PSAMPLE_ATTR_DATA, +	PSAMPLE_ATTR_GROUP_REFCOUNT,  	PSAMPLE_ATTR_TUNNEL, -	/* commands attributes */ -	PSAMPLE_ATTR_GROUP_REFCOUNT, +	PSAMPLE_ATTR_PAD, +	PSAMPLE_ATTR_OUT_TC,		/* u16 */ +	PSAMPLE_ATTR_OUT_TC_OCC,	/* u64, bytes */ +	PSAMPLE_ATTR_LATENCY,		/* u64, nanoseconds */ +	PSAMPLE_ATTR_TIMESTAMP,		/* u64, nanoseconds */ +	PSAMPLE_ATTR_PROTO,		/* u16 */ +	PSAMPLE_ATTR_USER_COOKIE,	/* binary, user provided data */ +	PSAMPLE_ATTR_SAMPLE_PROBABILITY,/* no argument, interpret rate in +					 * PSAMPLE_ATTR_SAMPLE_RATE as a +					 * probability scaled 0 - U32_MAX. +					 */  	__PSAMPLE_ATTR_MAX  }; diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h index 2fcad1dd0b0e..81759ff385e6 100644 --- a/include/uapi/linux/psci.h +++ b/include/uapi/linux/psci.h @@ -48,12 +48,28 @@  #define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU	PSCI_0_2_FN64(7)  #define PSCI_1_0_FN_PSCI_FEATURES		PSCI_0_2_FN(10) +#define PSCI_1_0_FN_CPU_FREEZE			PSCI_0_2_FN(11) +#define PSCI_1_0_FN_CPU_DEFAULT_SUSPEND		PSCI_0_2_FN(12) +#define PSCI_1_0_FN_NODE_HW_STATE		PSCI_0_2_FN(13)  #define PSCI_1_0_FN_SYSTEM_SUSPEND		PSCI_0_2_FN(14)  #define PSCI_1_0_FN_SET_SUSPEND_MODE		PSCI_0_2_FN(15) +#define PSCI_1_0_FN_STAT_RESIDENCY		PSCI_0_2_FN(16) +#define PSCI_1_0_FN_STAT_COUNT			PSCI_0_2_FN(17) +  #define PSCI_1_1_FN_SYSTEM_RESET2		PSCI_0_2_FN(18) +#define PSCI_1_1_FN_MEM_PROTECT			PSCI_0_2_FN(19) +#define PSCI_1_1_FN_MEM_PROTECT_CHECK_RANGE	PSCI_0_2_FN(20) +#define PSCI_1_3_FN_SYSTEM_OFF2			PSCI_0_2_FN(21) +#define PSCI_1_0_FN64_CPU_DEFAULT_SUSPEND	PSCI_0_2_FN64(12) +#define PSCI_1_0_FN64_NODE_HW_STATE		PSCI_0_2_FN64(13)  #define PSCI_1_0_FN64_SYSTEM_SUSPEND		PSCI_0_2_FN64(14) +#define PSCI_1_0_FN64_STAT_RESIDENCY		PSCI_0_2_FN64(16) +#define PSCI_1_0_FN64_STAT_COUNT		PSCI_0_2_FN64(17) +  #define PSCI_1_1_FN64_SYSTEM_RESET2		PSCI_0_2_FN64(18) +#define PSCI_1_1_FN64_MEM_PROTECT_CHECK_RANGE	PSCI_0_2_FN64(20) +#define PSCI_1_3_FN64_SYSTEM_OFF2		PSCI_0_2_FN64(21)  /* PSCI v0.2 power state encoding for CPU_SUSPEND function */  #define PSCI_0_2_POWER_STATE_ID_MASK		0xffff @@ -82,6 +98,13 @@  #define PSCI_0_2_TOS_UP_NO_MIGRATE		1  #define PSCI_0_2_TOS_MP				2 +/* PSCI v1.1 reset type encoding for SYSTEM_RESET2 */ +#define PSCI_1_1_RESET_TYPE_SYSTEM_WARM_RESET	0 +#define PSCI_1_1_RESET_TYPE_VENDOR_START	0x80000000U + +/* PSCI v1.3 hibernate type for SYSTEM_OFF2 */ +#define PSCI_1_3_OFF_TYPE_HIBERNATE_OFF		BIT(0) +  /* PSCI version decoding (independent of PSCI version) */  #define PSCI_VERSION_MAJOR_SHIFT		16  #define PSCI_VERSION_MINOR_MASK			\ diff --git a/include/uapi/linux/psp-dbc.h b/include/uapi/linux/psp-dbc.h new file mode 100644 index 000000000000..b3845a9ff5fd --- /dev/null +++ b/include/uapi/linux/psp-dbc.h @@ -0,0 +1,147 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * Userspace interface for AMD Dynamic Boost Control (DBC) + * + * Copyright (C) 2023 Advanced Micro Devices, Inc. + * + * Author: Mario Limonciello <mario.limonciello@amd.com> + */ + +#ifndef __PSP_DBC_USER_H__ +#define __PSP_DBC_USER_H__ + +#include <linux/types.h> + +/** + * DOC: AMD Dynamic Boost Control (DBC) interface + */ + +#define DBC_NONCE_SIZE		16 +#define DBC_SIG_SIZE		32 +#define DBC_UID_SIZE		16 + +/** + * struct dbc_user_nonce - Nonce exchange structure (input/output). + * @auth_needed: Whether the PSP should authenticate this request (input). + *               0: no authentication, PSP will return single use nonce. + *               1: authentication: PSP will return multi-use nonce. + * @nonce:       8 byte value used for future authentication (output). + * @signature:   Optional 32 byte signature created by software using a + *               previous nonce (input). + */ +struct dbc_user_nonce { +	__u32	auth_needed; +	__u8	nonce[DBC_NONCE_SIZE]; +	__u8	signature[DBC_SIG_SIZE]; +} __packed; + +/** + * struct dbc_user_setuid - UID exchange structure (input). + * @uid:       16 byte value representing software identity + * @signature: 32 byte signature created by software using a previous nonce + */ +struct dbc_user_setuid { +	__u8	uid[DBC_UID_SIZE]; +	__u8	signature[DBC_SIG_SIZE]; +} __packed; + +/** + * struct dbc_user_param - Parameter exchange structure (input/output). + * @msg_index: Message indicating what parameter to set or get (input) + * @param:     4 byte parameter, units are message specific. (input/output) + * @signature: 32 byte signature. + *             - When sending a message this is to be created by software + *               using a previous nonce (input) + *             - For interpreting results, this signature is updated by the + *               PSP to allow software to validate the authenticity of the + *               results. + */ +struct dbc_user_param { +	__u32	msg_index; +	__u32	param; +	__u8	signature[DBC_SIG_SIZE]; +} __packed; + +/** + * Dynamic Boost Control (DBC) IOC + * + * possible return codes for all DBC IOCTLs: + *  0:          success + *  -EINVAL:    invalid input + *  -E2BIG:     excess data passed + *  -EFAULT:    failed to copy to/from userspace + *  -EBUSY:     mailbox in recovery or in use + *  -ENODEV:    driver not bound with PSP device + *  -EACCES:    request isn't authorized + *  -EINVAL:    invalid parameter + *  -ETIMEDOUT: request timed out + *  -EAGAIN:    invalid request for state machine + *  -ENOENT:    not implemented + *  -ENFILE:    overflow + *  -EPERM:     invalid signature + *  -EIO:       unknown error + */ +#define DBC_IOC_TYPE	'D' + +/** + * DBCIOCNONCE - Fetch a nonce from the PSP for authenticating commands. + *               If a nonce is fetched without authentication it can only + *               be utilized for one command. + *               If a nonce is fetched with authentication it can be used + *               for multiple requests. + */ +#define DBCIOCNONCE	_IOWR(DBC_IOC_TYPE, 0x1, struct dbc_user_nonce) + +/** + * DBCIOCUID - Set the user ID (UID) of a calling process. + *             The user ID is 8 bytes long. It must be programmed using a + *             32 byte signature built using the nonce fetched from + *             DBCIOCNONCE. + *             The UID can only be set once until the system is rebooted. + */ +#define DBCIOCUID	_IOW(DBC_IOC_TYPE, 0x2, struct dbc_user_setuid) + +/** + * DBCIOCPARAM - Set or get a parameter from the PSP. + *               This request will only work after DBCIOCUID has successfully + *               set the UID of the calling process. + *               Whether the parameter is set or get is controlled by the + *               message ID in the request. + *               This command must be sent using a 32 byte signature built + *               using the nonce fetched from DBCIOCNONCE. + *               When the command succeeds, the 32 byte signature will be + *               updated by the PSP for software to authenticate the results. + */ +#define DBCIOCPARAM	_IOWR(DBC_IOC_TYPE, 0x3, struct dbc_user_param) + +/** + * enum dbc_cmd_msg - Messages utilized by DBCIOCPARAM + * @PARAM_GET_FMAX_CAP:		Get frequency cap (MHz) + * @PARAM_SET_FMAX_CAP:		Set frequency cap (MHz) + * @PARAM_GET_PWR_CAP:		Get socket power cap (mW) + * @PARAM_SET_PWR_CAP:		Set socket power cap (mW) + * @PARAM_GET_GFX_MODE:		Get graphics mode (0/1) + * @PARAM_SET_GFX_MODE:		Set graphics mode (0/1) + * @PARAM_GET_CURR_TEMP:	Get current temperature (degrees C) + * @PARAM_GET_FMAX_MAX:		Get maximum allowed value for frequency (MHz) + * @PARAM_GET_FMAX_MIN:		Get minimum allowed value for frequency (MHz) + * @PARAM_GET_SOC_PWR_MAX:	Get maximum allowed value for SoC power (mw) + * @PARAM_GET_SOC_PWR_MIN:	Get minimum allowed value for SoC power (mw) + * @PARAM_GET_SOC_PWR_CUR:	Get current value for SoC Power (mW) + */ +enum dbc_cmd_msg { +	PARAM_GET_FMAX_CAP	= 0x3, +	PARAM_SET_FMAX_CAP	= 0x4, +	PARAM_GET_PWR_CAP	= 0x5, +	PARAM_SET_PWR_CAP	= 0x6, +	PARAM_GET_GFX_MODE	= 0x7, +	PARAM_SET_GFX_MODE	= 0x8, +	PARAM_GET_CURR_TEMP	= 0x9, +	PARAM_GET_FMAX_MAX	= 0xA, +	PARAM_GET_FMAX_MIN	= 0xB, +	PARAM_GET_SOC_PWR_MAX	= 0xC, +	PARAM_GET_SOC_PWR_MIN	= 0xD, +	PARAM_GET_SOC_PWR_CUR	= 0xE, +}; + +#endif /* __PSP_DBC_USER_H__ */ diff --git a/include/uapi/linux/psp-sev.h b/include/uapi/linux/psp-sev.h index 91b4c63d5cbf..eeb20dfb1fda 100644 --- a/include/uapi/linux/psp-sev.h +++ b/include/uapi/linux/psp-sev.h @@ -28,6 +28,10 @@ enum {  	SEV_PEK_CERT_IMPORT,  	SEV_GET_ID,	/* This command is deprecated, use SEV_GET_ID2 */  	SEV_GET_ID2, +	SNP_PLATFORM_STATUS, +	SNP_COMMIT, +	SNP_SET_CONFIG, +	SNP_VLEK_LOAD,  	SEV_MAX,  }; @@ -36,10 +40,18 @@ enum {   * SEV Firmware status code   */  typedef enum { +	/* +	 * This error code is not in the SEV spec. Its purpose is to convey that +	 * there was an error that prevented the SEV firmware from being called. +	 * The SEV API error codes are 16 bits, so the -1 value will not overlap +	 * with possible values from the specification. +	 */ +	SEV_RET_NO_FW_CALL = -1,  	SEV_RET_SUCCESS = 0,  	SEV_RET_INVALID_PLATFORM_STATE,  	SEV_RET_INVALID_GUEST_STATE,  	SEV_RET_INAVLID_CONFIG, +	SEV_RET_INVALID_CONFIG = SEV_RET_INAVLID_CONFIG,  	SEV_RET_INVALID_LEN,  	SEV_RET_ALREADY_OWNED,  	SEV_RET_INVALID_CERTIFICATE, @@ -61,6 +73,20 @@ typedef enum {  	SEV_RET_INVALID_PARAM,  	SEV_RET_RESOURCE_LIMIT,  	SEV_RET_SECURE_DATA_INVALID, +	SEV_RET_INVALID_PAGE_SIZE          = 0x0019, +	SEV_RET_INVALID_PAGE_STATE         = 0x001A, +	SEV_RET_INVALID_MDATA_ENTRY        = 0x001B, +	SEV_RET_INVALID_PAGE_OWNER         = 0x001C, +	SEV_RET_AEAD_OFLOW                 = 0x001D, +	SEV_RET_EXIT_RING_BUFFER           = 0x001F, +	SEV_RET_RMP_INIT_REQUIRED          = 0x0020, +	SEV_RET_BAD_SVN                    = 0x0021, +	SEV_RET_BAD_VERSION                = 0x0022, +	SEV_RET_SHUTDOWN_REQUIRED          = 0x0023, +	SEV_RET_UPDATE_FAILED              = 0x0024, +	SEV_RET_RESTORE_REQUIRED           = 0x0025, +	SEV_RET_RMP_INITIALIZATION_FAILED  = 0x0026, +	SEV_RET_INVALID_KEY                = 0x0027,  	SEV_RET_MAX,  } sev_ret_code; @@ -148,6 +174,82 @@ struct sev_user_data_get_id2 {  } __packed;  /** + * struct sev_user_data_snp_status - SNP status + * + * @api_major: API major version + * @api_minor: API minor version + * @state: current platform state + * @is_rmp_initialized: whether RMP is initialized or not + * @rsvd: reserved + * @build_id: firmware build id for the API version + * @mask_chip_id: whether chip id is present in attestation reports or not + * @mask_chip_key: whether attestation reports are signed or not + * @vlek_en: VLEK (Version Loaded Endorsement Key) hashstick is loaded + * @rsvd1: reserved + * @guest_count: the number of guest currently managed by the firmware + * @current_tcb_version: current TCB version + * @reported_tcb_version: reported TCB version + */ +struct sev_user_data_snp_status { +	__u8 api_major;			/* Out */ +	__u8 api_minor;			/* Out */ +	__u8 state;			/* Out */ +	__u8 is_rmp_initialized:1;	/* Out */ +	__u8 rsvd:7; +	__u32 build_id;			/* Out */ +	__u32 mask_chip_id:1;		/* Out */ +	__u32 mask_chip_key:1;		/* Out */ +	__u32 vlek_en:1;		/* Out */ +	__u32 rsvd1:29; +	__u32 guest_count;		/* Out */ +	__u64 current_tcb_version;	/* Out */ +	__u64 reported_tcb_version;	/* Out */ +} __packed; + +/** + * struct sev_user_data_snp_config - system wide configuration value for SNP. + * + * @reported_tcb: the TCB version to report in the guest attestation report. + * @mask_chip_id: whether chip id is present in attestation reports or not + * @mask_chip_key: whether attestation reports are signed or not + * @rsvd: reserved + * @rsvd1: reserved + */ +struct sev_user_data_snp_config { +	__u64 reported_tcb  ;   /* In */ +	__u32 mask_chip_id:1;   /* In */ +	__u32 mask_chip_key:1;  /* In */ +	__u32 rsvd:30;          /* In */ +	__u8 rsvd1[52]; +} __packed; + +/** + * struct sev_data_snp_vlek_load - SNP_VLEK_LOAD structure + * + * @len: length of the command buffer read by the PSP + * @vlek_wrapped_version: version of wrapped VLEK hashstick (Must be 0h) + * @rsvd: reserved + * @vlek_wrapped_address: address of a wrapped VLEK hashstick + *                        (struct sev_user_data_snp_wrapped_vlek_hashstick) + */ +struct sev_user_data_snp_vlek_load { +	__u32 len;				/* In */ +	__u8 vlek_wrapped_version;		/* In */ +	__u8 rsvd[3];				/* In */ +	__u64 vlek_wrapped_address;		/* In */ +} __packed; + +/** + * struct sev_user_data_snp_vlek_wrapped_vlek_hashstick - Wrapped VLEK data + * + * @data: Opaque data provided by AMD KDS (as described in SEV-SNP Firmware ABI + *        1.54, SNP_VLEK_LOAD) + */ +struct sev_user_data_snp_wrapped_vlek_hashstick { +	__u8 data[432];				/* In */ +} __packed; + +/**   * struct sev_issue_cmd - SEV ioctl parameters   *   * @cmd: SEV commands to execute diff --git a/include/uapi/linux/ptp_clock.h b/include/uapi/linux/ptp_clock.h index 1d108d597f66..18eefa6d93d6 100644 --- a/include/uapi/linux/ptp_clock.h +++ b/include/uapi/linux/ptp_clock.h @@ -32,6 +32,7 @@  #define PTP_RISING_EDGE    (1<<1)  #define PTP_FALLING_EDGE   (1<<2)  #define PTP_STRICT_FLAGS   (1<<3) +#define PTP_EXT_OFFSET     (1<<4)  #define PTP_EXTTS_EDGES    (PTP_RISING_EDGE | PTP_FALLING_EDGE)  /* @@ -40,7 +41,8 @@  #define PTP_EXTTS_VALID_FLAGS	(PTP_ENABLE_FEATURE |	\  				 PTP_RISING_EDGE |	\  				 PTP_FALLING_EDGE |	\ -				 PTP_STRICT_FLAGS) +				 PTP_STRICT_FLAGS |	\ +				 PTP_EXT_OFFSET)  /*   * flag fields valid for the original PTP_EXTTS_REQUEST ioctl. @@ -51,6 +53,11 @@  					 PTP_FALLING_EDGE)  /* + * flag fields valid for the ptp_extts_event report. + */ +#define PTP_EXTTS_EVENT_VALID	(PTP_ENABLE_FEATURE) + +/*   * Bits of the ptp_perout_request.flags field:   */  #define PTP_PEROUT_ONE_SHOT		(1<<0) @@ -95,7 +102,8 @@ struct ptp_clock_caps {  	int cross_timestamping;  	/* Whether the clock supports adjust phase */  	int adjust_phase; -	int rsv[12];   /* Reserved for future use. */ +	int max_phase_adj; /* Maximum phase adjustment in nanoseconds. */ +	int rsv[11];       /* Reserved for future use. */  };  struct ptp_extts_request { @@ -147,13 +155,25 @@ struct ptp_sys_offset {  	struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];  }; +/* + * ptp_sys_offset_extended - data structure for IOCTL operation + *			     PTP_SYS_OFFSET_EXTENDED + * + * @n_samples:	Desired number of measurements. + * @clockid:	clockid of a clock-base used for pre/post timestamps. + * @rsv:	Reserved for future use. + * @ts:		Array of samples in the form [pre-TS, PHC, post-TS]. The + *		kernel provides @n_samples. + * + * Starting from kernel 6.12 and onwards, the first word of the reserved-field + * is used for @clockid. That's backward compatible since previous kernel + * expect all three reserved words (@rsv[3]) to be 0 while the clockid (first + * word in the new structure) for CLOCK_REALTIME is '0'. + */  struct ptp_sys_offset_extended { -	unsigned int n_samples; /* Desired number of measurements. */ -	unsigned int rsv[3];    /* Reserved for future use. */ -	/* -	 * Array of [system, phc, system] time stamps. The kernel will provide -	 * 3*n_samples time stamps. -	 */ +	unsigned int n_samples; +	__kernel_clockid_t clockid; +	unsigned int rsv[2];  	struct ptp_clock_time ts[PTP_MAX_SAMPLES][3];  }; @@ -223,11 +243,13 @@ struct ptp_pin_desc {  	_IOWR(PTP_CLK_MAGIC, 17, struct ptp_sys_offset_precise)  #define PTP_SYS_OFFSET_EXTENDED2 \  	_IOWR(PTP_CLK_MAGIC, 18, struct ptp_sys_offset_extended) +#define PTP_MASK_CLEAR_ALL  _IO(PTP_CLK_MAGIC, 19) +#define PTP_MASK_EN_SINGLE  _IOW(PTP_CLK_MAGIC, 20, unsigned int)  struct ptp_extts_event { -	struct ptp_clock_time t; /* Time event occured. */ +	struct ptp_clock_time t; /* Time event occurred. */  	unsigned int index;      /* Which channel produced the event. */ -	unsigned int flags;      /* Reserved for future use. */ +	unsigned int flags;      /* Event type. */  	unsigned int rsv[2];     /* Reserved for future use. */  }; diff --git a/include/uapi/linux/ptrace.h b/include/uapi/linux/ptrace.h index a71b6e3b03eb..5f8ef6156752 100644 --- a/include/uapi/linux/ptrace.h +++ b/include/uapi/linux/ptrace.h @@ -74,6 +74,7 @@ struct seccomp_metadata {  };  #define PTRACE_GET_SYSCALL_INFO		0x420e +#define PTRACE_SET_SYSCALL_INFO		0x4212  #define PTRACE_SYSCALL_INFO_NONE	0  #define PTRACE_SYSCALL_INFO_ENTRY	1  #define PTRACE_SYSCALL_INFO_EXIT	2 @@ -81,7 +82,9 @@ struct seccomp_metadata {  struct ptrace_syscall_info {  	__u8 op;	/* PTRACE_SYSCALL_INFO_* */ -	__u32 arch __attribute__((__aligned__(sizeof(__u32)))); +	__u8 reserved; +	__u16 flags; +	__u32 arch;  	__u64 instruction_pointer;  	__u64 stack_pointer;  	union { @@ -97,13 +100,56 @@ struct ptrace_syscall_info {  			__u64 nr;  			__u64 args[6];  			__u32 ret_data; +			__u32 reserved2;  		} seccomp;  	};  }; +#define PTRACE_GET_RSEQ_CONFIGURATION	0x420f + +struct ptrace_rseq_configuration { +	__u64 rseq_abi_pointer; +	__u32 rseq_abi_size; +	__u32 signature; +	__u32 flags; +	__u32 pad; +}; + +#define PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG 0x4210 +#define PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG 0x4211 + +/* + * struct ptrace_sud_config - Per-task configuration for Syscall User Dispatch + * @mode:	One of PR_SYS_DISPATCH_ON or PR_SYS_DISPATCH_OFF + * @selector:	Tracees user virtual address of SUD selector + * @offset:	SUD exclusion area (virtual address) + * @len:	Length of SUD exclusion area + * + * Used to get/set the syscall user dispatch configuration for a tracee. + * Selector is optional (may be NULL), and if invalid will produce + * a SIGSEGV in the tracee upon first access. + * + * If mode is PR_SYS_DISPATCH_ON, syscall dispatch will be enabled. If + * PR_SYS_DISPATCH_OFF, syscall dispatch will be disabled and all other + * parameters must be 0.  The value in *selector (if not null), also determines + * whether syscall dispatch will occur. + * + * The Syscall User Dispatch Exclusion area described by offset/len is the + * virtual address space from which syscalls will not produce a user + * dispatch. + */ +struct ptrace_sud_config { +	__u64 mode; +	__u64 selector; +	__u64 offset; +	__u64 len; +}; + +/* 0x4212 is PTRACE_SET_SYSCALL_INFO */ +  /*   * These values are stored in task->ptrace_message - * by tracehook_report_syscall_* to describe the current syscall-stop. + * by ptrace_stop to describe the current syscall-stop.   */  #define PTRACE_EVENTMSG_SYSCALL_ENTRY	1  #define PTRACE_EVENTMSG_SYSCALL_EXIT	2 diff --git a/include/uapi/linux/pwm.h b/include/uapi/linux/pwm.h new file mode 100644 index 000000000000..182d59cc07ee --- /dev/null +++ b/include/uapi/linux/pwm.h @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ + +#ifndef _UAPI_PWM_H_ +#define _UAPI_PWM_H_ + +#include <linux/ioctl.h> +#include <linux/types.h> + +/** + * struct pwmchip_waveform - Describe a PWM waveform for a pwm_chip's PWM channel + * @hwpwm: per-chip relative index of the PWM device + * @__pad: padding, must be zero + * @period_length_ns: duration of the repeating period. + *    A value of 0 represents a disabled PWM. + * @duty_length_ns: duration of the active part in each period + * @duty_offset_ns: offset of the rising edge from a period's start + */ +struct pwmchip_waveform { +	__u32 hwpwm; +	__u32 __pad; +	__u64 period_length_ns; +	__u64 duty_length_ns; +	__u64 duty_offset_ns; +}; + +/* Reserves the passed hwpwm for exclusive control. */ +#define PWM_IOCTL_REQUEST	_IO(0x75, 1) + +/* counter part to PWM_IOCTL_REQUEST */ +#define PWM_IOCTL_FREE		_IO(0x75, 2) + +/* + * Modifies the passed wf according to hardware constraints. All parameters are + * rounded down to the next possible value, unless there is no such value, then + * values are rounded up. Note that zero isn't considered for rounding down + * period_length_ns. + */ +#define PWM_IOCTL_ROUNDWF	_IOWR(0x75, 3, struct pwmchip_waveform) + +/* Get the currently implemented waveform */ +#define PWM_IOCTL_GETWF		_IOWR(0x75, 4, struct pwmchip_waveform) + +/* Like PWM_IOCTL_ROUNDWF + PWM_IOCTL_SETEXACTWF in one go. */ +#define PWM_IOCTL_SETROUNDEDWF	_IOW(0x75, 5, struct pwmchip_waveform) + +/* + * Program the PWM to emit exactly the passed waveform, subject only to rounding + * down each value less than 1 ns. Returns 0 on success, -EDOM if the waveform + * cannot be implemented exactly, or other negative error codes. + */ +#define PWM_IOCTL_SETEXACTWF	_IOW(0x75, 6, struct pwmchip_waveform) + +#endif /* _UAPI_PWM_H_ */ diff --git a/include/uapi/linux/quota.h b/include/uapi/linux/quota.h index f17c9636a859..52090105b828 100644 --- a/include/uapi/linux/quota.h +++ b/include/uapi/linux/quota.h @@ -77,6 +77,7 @@  #define	QFMT_VFS_V0 2  #define QFMT_OCFS2 3  #define	QFMT_VFS_V1 4 +#define	QFMT_SHMEM 5  /* Size of block in which space limits are passed through the quota   * interface */ diff --git a/include/uapi/linux/raid/md_p.h b/include/uapi/linux/raid/md_p.h index e5a98a16f9b0..ac74133a4768 100644 --- a/include/uapi/linux/raid/md_p.h +++ b/include/uapi/linux/raid/md_p.h @@ -2,15 +2,11 @@  /*     md_p.h : physical layout of Linux RAID devices            Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman -	   +     This program is free software; you can redistribute it and/or modify     it under the terms of the GNU General Public License as published by     the Free Software Foundation; either version 2, or (at your option)     any later version. -    -   You should have received a copy of the GNU General Public License -   (for example /usr/src/linux/COPYING); if not, write to the Free -   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.    */  #ifndef _MD_P_H @@ -177,7 +173,7 @@ typedef struct mdp_superblock_s {  #else  #error unspecified endianness  #endif -	__u32 recovery_cp;	/* 11 recovery checkpoint sector count	      */ +	__u32 recovery_cp;	/* 11 resync checkpoint sector count	      */  	/* There are only valid for minor_version > 90 */  	__u64 reshape_position;	/* 12,13 next address in array-space for reshape */  	__u32 new_level;	/* 14 new level we are reshaping to	      */ @@ -237,7 +233,7 @@ struct mdp_superblock_1 {  	char	set_name[32];	/* set and interpreted by user-space */  	__le64	ctime;		/* lo 40 bits are seconds, top 24 are microseconds or 0*/ -	__le32	level;		/* -4 (multipath), -1 (linear), 0,1,4,5 */ +	__le32	level;		/* 0,1,4,5, -1 (linear) */  	__le32	layout;		/* only for raid5 and raid10 currently */  	__le64	size;		/* used size of component devices, in 512byte sectors */ @@ -303,7 +299,7 @@ struct mdp_superblock_1 {  	 * into the 'roles' value.  If a device is spare or faulty, then it doesn't  	 * have a meaningful role.  	 */ -	__le16	dev_roles[0];	/* role in array, or 0xffff for a spare, or 0xfffe for faulty */ +	__le16	dev_roles[];	/* role in array, or 0xffff for a spare, or 0xfffe for faulty */  };  /* feature_map bits */ diff --git a/include/uapi/linux/raid/md_u.h b/include/uapi/linux/raid/md_u.h index 105307244961..a893010735fb 100644 --- a/include/uapi/linux/raid/md_u.h +++ b/include/uapi/linux/raid/md_u.h @@ -2,15 +2,11 @@  /*     md_u.h : user <=> kernel API between Linux raidtools and RAID drivers            Copyright (C) 1998 Ingo Molnar -	   +     This program is free software; you can redistribute it and/or modify     it under the terms of the GNU General Public License as published by     the Free Software Foundation; either version 2, or (at your option)     any later version. -    -   You should have received a copy of the GNU General Public License -   (for example /usr/src/linux/COPYING); if not, write to the Free -   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.    */  #ifndef _UAPI_MD_U_H @@ -107,10 +103,7 @@ typedef struct mdu_array_info_s {  } mdu_array_info_t; -/* non-obvious values for 'level' */ -#define	LEVEL_MULTIPATH		(-4) -#define	LEVEL_LINEAR		(-1) -#define	LEVEL_FAULTY		(-5) +#define LEVEL_LINEAR		(-1)  /* we need a value for 'no level specified' and 0   * means 'raid0', so we need something else.  This is diff --git a/include/uapi/linux/random.h b/include/uapi/linux/random.h index dcc1b3e6106f..1dd047ec98a1 100644 --- a/include/uapi/linux/random.h +++ b/include/uapi/linux/random.h @@ -20,7 +20,7 @@  /* Add to (or subtract from) the entropy count.  (Superuser only.) */  #define RNDADDTOENTCNT	_IOW( 'R', 0x01, int ) -/* Get the contents of the entropy pool.  (Superuser only.) */ +/* Get the contents of the entropy pool.  (Superuser only.) (Removed in 2.6.9-rc2.) */  #define RNDGETPOOL	_IOR( 'R', 0x02, int [2] )  /*  @@ -41,7 +41,7 @@  struct rand_pool_info {  	int	entropy_count;  	int	buf_size; -	__u32	buf[0]; +	__u32	buf[];  };  /* @@ -55,4 +55,19 @@ struct rand_pool_info {  #define GRND_RANDOM	0x0002  #define GRND_INSECURE	0x0004 +/** + * struct vgetrandom_opaque_params - arguments for allocating memory for vgetrandom + * + * @size_per_opaque_state:	Size of each state that is to be passed to vgetrandom(). + * @mmap_prot:			Value of the prot argument in mmap(2). + * @mmap_flags:			Value of the flags argument in mmap(2). + * @reserved:			Reserved for future use. + */ +struct vgetrandom_opaque_params { +	__u32 size_of_opaque_state; +	__u32 mmap_prot; +	__u32 mmap_flags; +	__u32 reserved[13]; +}; +  #endif /* _UAPI_LINUX_RANDOM_H */ diff --git a/include/uapi/linux/raw.h b/include/uapi/linux/raw.h deleted file mode 100644 index 47874919d0b9..000000000000 --- a/include/uapi/linux/raw.h +++ /dev/null @@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_RAW_H -#define __LINUX_RAW_H - -#include <linux/types.h> - -#define RAW_SETBIND	_IO( 0xac, 0 ) -#define RAW_GETBIND	_IO( 0xac, 1 ) - -struct raw_config_request  -{ -	int	raw_minor; -	__u64	block_major; -	__u64	block_minor; -}; - -#endif /* __LINUX_RAW_H */ diff --git a/include/uapi/linux/reiserfs_fs.h b/include/uapi/linux/reiserfs_fs.h deleted file mode 100644 index 5bb921409f2b..000000000000 --- a/include/uapi/linux/reiserfs_fs.h +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * Copyright 1996, 1997, 1998 Hans Reiser, see reiserfs/README for licensing and copyright details - */ -#ifndef _LINUX_REISER_FS_H -#define _LINUX_REISER_FS_H - -#include <linux/types.h> -#include <linux/magic.h> - -/* - *  include/linux/reiser_fs.h - * - *  Reiser File System constants and structures - * - */ - -/* ioctl's command */ -#define REISERFS_IOC_UNPACK		_IOW(0xCD,1,long) -/* define following flags to be the same as in ext2, so that chattr(1), -   lsattr(1) will work with us. */ -#define REISERFS_IOC_GETFLAGS		FS_IOC_GETFLAGS -#define REISERFS_IOC_SETFLAGS		FS_IOC_SETFLAGS -#define REISERFS_IOC_GETVERSION		FS_IOC_GETVERSION -#define REISERFS_IOC_SETVERSION		FS_IOC_SETVERSION - -#endif				/* _LINUX_REISER_FS_H */ diff --git a/include/uapi/linux/reiserfs_xattr.h b/include/uapi/linux/reiserfs_xattr.h deleted file mode 100644 index 28f10842f047..000000000000 --- a/include/uapi/linux/reiserfs_xattr.h +++ /dev/null @@ -1,25 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* -  File: linux/reiserfs_xattr.h -*/ - -#ifndef _LINUX_REISERFS_XATTR_H -#define _LINUX_REISERFS_XATTR_H - -#include <linux/types.h> - -/* Magic value in header */ -#define REISERFS_XATTR_MAGIC 0x52465841	/* "RFXA" */ - -struct reiserfs_xattr_header { -	__le32 h_magic;		/* magic number for identification */ -	__le32 h_hash;		/* hash of the value */ -}; - -struct reiserfs_security_handle { -	const char *name; -	void *value; -	size_t length; -}; - -#endif  /*  _LINUX_REISERFS_XATTR_H  */ diff --git a/include/uapi/linux/resource.h b/include/uapi/linux/resource.h index 74ef57b38f9f..4fc22908bc09 100644 --- a/include/uapi/linux/resource.h +++ b/include/uapi/linux/resource.h @@ -2,7 +2,7 @@  #ifndef _UAPI_LINUX_RESOURCE_H  #define _UAPI_LINUX_RESOURCE_H -#include <linux/time.h> +#include <linux/time_types.h>  #include <linux/types.h>  /* @@ -66,10 +66,17 @@ struct rlimit64 {  #define _STK_LIM	(8*1024*1024)  /* - * GPG2 wants 64kB of mlocked memory, to make sure pass phrases - * and other sensitive information are never written to disk. + * Limit the amount of locked memory by some sane default: + * root can always increase this limit if needed. + * + * The main use-cases are (1) preventing sensitive memory + * from being swapped; (2) real-time operations; (3) via + * IOURING_REGISTER_BUFFERS. + * + * The first two don't need much. The latter will take as + * much as it can get. 8MB is a reasonably sane default.   */ -#define MLOCK_LIMIT	((PAGE_SIZE > 64*1024) ? PAGE_SIZE : 64*1024) +#define MLOCK_LIMIT	(8*1024*1024)  /*   * Due to binary compatibility, the actual resource numbers diff --git a/include/uapi/linux/rfkill.h b/include/uapi/linux/rfkill.h index 2e00dcebebd0..db6c8588c1d0 100644 --- a/include/uapi/linux/rfkill.h +++ b/include/uapi/linux/rfkill.h @@ -70,6 +70,16 @@ enum rfkill_operation {  };  /** + * enum rfkill_hard_block_reasons - hard block reasons + * @RFKILL_HARD_BLOCK_SIGNAL: the hardware rfkill signal is active + * @RFKILL_HARD_BLOCK_NOT_OWNER: the NIC is not owned by the host + */ +enum rfkill_hard_block_reasons { +	RFKILL_HARD_BLOCK_SIGNAL	= 1 << 0, +	RFKILL_HARD_BLOCK_NOT_OWNER	= 1 << 1, +}; + +/**   * struct rfkill_event - events for userspace on /dev/rfkill   * @idx: index of dev rfkill   * @type: type of the rfkill struct @@ -84,27 +94,97 @@ struct rfkill_event {  	__u32 idx;  	__u8  type;  	__u8  op; -	__u8  soft, hard; +	__u8  soft; +	__u8  hard;  } __attribute__((packed)); -/* - * We are planning to be backward and forward compatible with changes - * to the event struct, by adding new, optional, members at the end. - * When reading an event (whether the kernel from userspace or vice - * versa) we need to accept anything that's at least as large as the - * version 1 event size, but might be able to accept other sizes in - * the future. - * - * One exception is the kernel -- we already have two event sizes in - * that we've made the 'hard' member optional since our only option - * is to ignore it anyway. +/** + * struct rfkill_event_ext - events for userspace on /dev/rfkill + * @idx: index of dev rfkill + * @type: type of the rfkill struct + * @op: operation code + * @hard: hard state (0/1) + * @soft: soft state (0/1) + * @hard_block_reasons: valid if hard is set. One or several reasons from + *	&enum rfkill_hard_block_reasons. + * + * Structure used for userspace communication on /dev/rfkill, + * used for events from the kernel and control to the kernel. + * + * See the extensibility docs below. + */ +struct rfkill_event_ext { +	__u32 idx; +	__u8  type; +	__u8  op; +	__u8  soft; +	__u8  hard; + +	/* +	 * older kernels will accept/send only up to this point, +	 * and if extended further up to any chunk marked below +	 */ + +	__u8  hard_block_reasons; +} __attribute__((packed)); + +/** + * DOC: Extensibility + * + * Originally, we had planned to allow backward and forward compatible + * changes by just adding fields at the end of the structure that are + * then not reported on older kernels on read(), and not written to by + * older kernels on write(), with the kernel reporting the size it did + * accept as the result. + * + * This would have allowed userspace to detect on read() and write() + * which kernel structure version it was dealing with, and if was just + * recompiled it would have gotten the new fields, but obviously not + * accessed them, but things should've continued to work. + * + * Unfortunately, while actually exercising this mechanism to add the + * hard block reasons field, we found that userspace (notably systemd) + * did all kinds of fun things not in line with this scheme: + * + * 1. treat the (expected) short writes as an error; + * 2. ask to read sizeof(struct rfkill_event) but then compare the + *    actual return value to RFKILL_EVENT_SIZE_V1 and treat any + *    mismatch as an error. + * + * As a consequence, just recompiling with a new struct version caused + * things to no longer work correctly on old and new kernels. + * + * Hence, we've rolled back &struct rfkill_event to the original version + * and added &struct rfkill_event_ext. This effectively reverts to the + * old behaviour for all userspace, unless it explicitly opts in to the + * rules outlined here by using the new &struct rfkill_event_ext. + * + * Additionally, some other userspace (bluez, g-s-d) was reading with a + * large size but as streaming reads rather than message-based, or with + * too strict checks for the returned size. So eventually, we completely + * reverted this, and extended messages need to be opted in to by using + * an ioctl: + * + *  ioctl(fd, RFKILL_IOCTL_MAX_SIZE, sizeof(struct rfkill_event_ext)); + * + * Userspace using &struct rfkill_event_ext and the ioctl must adhere to + * the following rules: + * + * 1. accept short writes, optionally using them to detect that it's + *    running on an older kernel; + * 2. accept short reads, knowing that this means it's running on an + *    older kernel; + * 3. treat reads that are as long as requested as acceptable, not + *    checking against RFKILL_EVENT_SIZE_V1 or such.   */ -#define RFKILL_EVENT_SIZE_V1	8 +#define RFKILL_EVENT_SIZE_V1	sizeof(struct rfkill_event)  /* ioctl for turning off rfkill-input (if present) */  #define RFKILL_IOC_MAGIC	'R'  #define RFKILL_IOC_NOINPUT	1  #define RFKILL_IOCTL_NOINPUT	_IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT) +#define RFKILL_IOC_MAX_SIZE	2 +#define RFKILL_IOCTL_MAX_SIZE	_IOW(RFKILL_IOC_MAGIC, RFKILL_IOC_MAX_SIZE, __u32)  /* and that's all userspace gets */ diff --git a/include/uapi/linux/rkisp1-config.h b/include/uapi/linux/rkisp1-config.h new file mode 100644 index 000000000000..3b060ea6eed7 --- /dev/null +++ b/include/uapi/linux/rkisp1-config.h @@ -0,0 +1,1681 @@ +/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR MIT) */ +/* + * Rockchip ISP1 userspace API + * Copyright (C) 2017 Rockchip Electronics Co., Ltd. + */ + +#ifndef _UAPI_RKISP1_CONFIG_H +#define _UAPI_RKISP1_CONFIG_H + +#include <linux/types.h> + +/* Defect Pixel Cluster Detection */ +#define RKISP1_CIF_ISP_MODULE_DPCC		(1U << 0) +/* Black Level Subtraction */ +#define RKISP1_CIF_ISP_MODULE_BLS		(1U << 1) +/* Sensor De-gamma */ +#define RKISP1_CIF_ISP_MODULE_SDG		(1U << 2) +/* Histogram statistics configuration */ +#define RKISP1_CIF_ISP_MODULE_HST		(1U << 3) +/* Lens Shade Control */ +#define RKISP1_CIF_ISP_MODULE_LSC		(1U << 4) +/* Auto White Balance Gain */ +#define RKISP1_CIF_ISP_MODULE_AWB_GAIN		(1U << 5) +/* Filter */ +#define RKISP1_CIF_ISP_MODULE_FLT		(1U << 6) +/* Bayer Demosaic */ +#define RKISP1_CIF_ISP_MODULE_BDM		(1U << 7) +/* Cross Talk */ +#define RKISP1_CIF_ISP_MODULE_CTK		(1U << 8) +/* Gamma Out Curve */ +#define RKISP1_CIF_ISP_MODULE_GOC		(1U << 9) +/* Color Processing */ +#define RKISP1_CIF_ISP_MODULE_CPROC		(1U << 10) +/* Auto Focus Control statistics configuration */ +#define RKISP1_CIF_ISP_MODULE_AFC		(1U << 11) +/* Auto White Balancing statistics configuration */ +#define RKISP1_CIF_ISP_MODULE_AWB		(1U << 12) +/* Image Effect */ +#define RKISP1_CIF_ISP_MODULE_IE		(1U << 13) +/* Auto Exposure Control statistics configuration */ +#define RKISP1_CIF_ISP_MODULE_AEC		(1U << 14) +/* Wide Dynamic Range */ +#define RKISP1_CIF_ISP_MODULE_WDR		(1U << 15) +/* Denoise Pre-Filter */ +#define RKISP1_CIF_ISP_MODULE_DPF		(1U << 16) +/* Denoise Pre-Filter Strength */ +#define RKISP1_CIF_ISP_MODULE_DPF_STRENGTH	(1U << 17) + +#define RKISP1_CIF_ISP_CTK_COEFF_MAX            0x100 +#define RKISP1_CIF_ISP_CTK_OFFSET_MAX           0x800 + +#define RKISP1_CIF_ISP_AE_MEAN_MAX_V10		25 +#define RKISP1_CIF_ISP_AE_MEAN_MAX_V12		81 +#define RKISP1_CIF_ISP_AE_MEAN_MAX		RKISP1_CIF_ISP_AE_MEAN_MAX_V12 + +#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10	16 +#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12	32 +#define RKISP1_CIF_ISP_HIST_BIN_N_MAX		RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 + +#define RKISP1_CIF_ISP_AFM_MAX_WINDOWS          3 +#define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE       17 + +#define RKISP1_CIF_ISP_BDM_MAX_TH               0xff + +/* + * Black level compensation + */ +/* maximum value for horizontal start address */ +#define RKISP1_CIF_ISP_BLS_START_H_MAX             0x00000fff +/* maximum value for horizontal stop address */ +#define RKISP1_CIF_ISP_BLS_STOP_H_MAX              0x00000fff +/* maximum value for vertical start address */ +#define RKISP1_CIF_ISP_BLS_START_V_MAX             0x00000fff +/* maximum value for vertical stop address */ +#define RKISP1_CIF_ISP_BLS_STOP_V_MAX              0x00000fff +/* maximum is 2^18 = 262144*/ +#define RKISP1_CIF_ISP_BLS_SAMPLES_MAX             0x00000012 +/* maximum value for fixed black level */ +#define RKISP1_CIF_ISP_BLS_FIX_SUB_MAX             0x00000fff +/* minimum value for fixed black level */ +#define RKISP1_CIF_ISP_BLS_FIX_SUB_MIN             0xfffff000 +/* 13 bit range (signed)*/ +#define RKISP1_CIF_ISP_BLS_FIX_MASK                0x00001fff + +/* + * Automatic white balance measurements + */ +#define RKISP1_CIF_ISP_AWB_MAX_GRID                1 +#define RKISP1_CIF_ISP_AWB_MAX_FRAMES              7 + +/* + * Gamma out + */ +/* Maximum number of color samples supported */ +#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10   17 +#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12   34 +#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES       RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 + +/* + * Lens shade correction + */ +#define RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE        8 + +/* + * The following matches the tuning process, + * not the max capabilities of the chip. + */ +#define RKISP1_CIF_ISP_LSC_SAMPLES_MAX             17 + +/* + * Histogram calculation + */ +#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 25 +#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81 +#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE     RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 + +/* + * Defect Pixel Cluster Correction + */ +#define RKISP1_CIF_ISP_DPCC_METHODS_MAX				3 + +#define RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE			(1U << 2) + +#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER	(1U << 0) +#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_RB_CENTER	(1U << 1) +#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_G_3X3		(1U << 2) +#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_RB_3X3		(1U << 3) + +/* 0-2 for sets 1-3 */ +#define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_SET(n)		((n) << 0) +#define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_FIX_SET		(1U << 3) + +#define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_GREEN_ENABLE		(1U << 0) +#define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_GREEN_ENABLE		(1U << 1) +#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_GREEN_ENABLE		(1U << 2) +#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_GREEN_ENABLE	(1U << 3) +#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_GREEN_ENABLE		(1U << 4) +#define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_RED_BLUE_ENABLE	(1U << 8) +#define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_RED_BLUE_ENABLE	(1U << 9) +#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_RED_BLUE_ENABLE	(1U << 10) +#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_RED_BLUE_ENABLE	(1U << 11) +#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_RED_BLUE_ENABLE	(1U << 12) + +#define RKISP1_CIF_ISP_DPCC_LINE_THRESH_G(v)			((v) << 0) +#define RKISP1_CIF_ISP_DPCC_LINE_THRESH_RB(v)			((v) << 8) +#define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_G(v)			((v) << 0) +#define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_RB(v)			((v) << 8) +#define RKISP1_CIF_ISP_DPCC_PG_FAC_G(v)				((v) << 0) +#define RKISP1_CIF_ISP_DPCC_PG_FAC_RB(v)			((v) << 8) +#define RKISP1_CIF_ISP_DPCC_RND_THRESH_G(v)			((v) << 0) +#define RKISP1_CIF_ISP_DPCC_RND_THRESH_RB(v)			((v) << 8) +#define RKISP1_CIF_ISP_DPCC_RG_FAC_G(v)				((v) << 0) +#define RKISP1_CIF_ISP_DPCC_RG_FAC_RB(v)			((v) << 8) + +#define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_G(n, v)			((v) << ((n) * 4)) +#define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_RB(n, v)		((v) << ((n) * 4 + 2)) + +#define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_G(n, v)			((v) << ((n) * 4)) +#define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_RB(n, v)			((v) << ((n) * 4 + 2)) + +/* + * Denoising pre filter + */ +#define RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS      17 +#define RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS  6 + +/* + * Compand + */ +#define RKISP1_CIF_ISP_COMPAND_NUM_POINTS	64 + +/* + * Wide Dynamic Range + */ +#define RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV	32 +#define RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF	(RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV + 1) +#define RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS	4 + +/* + * Measurement types + */ +#define RKISP1_CIF_ISP_STAT_AWB           (1U << 0) +#define RKISP1_CIF_ISP_STAT_AUTOEXP       (1U << 1) +#define RKISP1_CIF_ISP_STAT_AFM           (1U << 2) +#define RKISP1_CIF_ISP_STAT_HIST          (1U << 3) + +/** + * enum rkisp1_cif_isp_version - ISP variants + * + * @RKISP1_V10: Used at least in RK3288 and RK3399. + * @RKISP1_V11: Declared in the original vendor code, but not used. Same number + *	of entries in grids and histogram as v10. + * @RKISP1_V12: Used at least in RK3326 and PX30. + * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and + *	histogram as v12. + * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids + *	and histogram as v10. + */ +enum rkisp1_cif_isp_version { +	RKISP1_V10 = 10, +	RKISP1_V11, +	RKISP1_V12, +	RKISP1_V13, +	RKISP1_V_IMX8MP, +}; + +enum rkisp1_cif_isp_histogram_mode { +	RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE, +	RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED, +	RKISP1_CIF_ISP_HISTOGRAM_MODE_R_HISTOGRAM, +	RKISP1_CIF_ISP_HISTOGRAM_MODE_G_HISTOGRAM, +	RKISP1_CIF_ISP_HISTOGRAM_MODE_B_HISTOGRAM, +	RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM +}; + +enum rkisp1_cif_isp_awb_mode_type { +	RKISP1_CIF_ISP_AWB_MODE_MANUAL, +	RKISP1_CIF_ISP_AWB_MODE_RGB, +	RKISP1_CIF_ISP_AWB_MODE_YCBCR +}; + +enum rkisp1_cif_isp_flt_mode { +	RKISP1_CIF_ISP_FLT_STATIC_MODE, +	RKISP1_CIF_ISP_FLT_DYNAMIC_MODE +}; + +/** + * enum rkisp1_cif_isp_exp_ctrl_autostop - stop modes + * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0: continuous measurement + * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame + */ +enum rkisp1_cif_isp_exp_ctrl_autostop { +	RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0 = 0, +	RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1 = 1, +}; + +/** + * enum rkisp1_cif_isp_exp_meas_mode - Exposure measure mode + * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B + * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256) + */ +enum rkisp1_cif_isp_exp_meas_mode { +	RKISP1_CIF_ISP_EXP_MEASURING_MODE_0, +	RKISP1_CIF_ISP_EXP_MEASURING_MODE_1, +}; + +/*---------- PART1: Input Parameters ------------*/ + +/** + * struct rkisp1_cif_isp_window -  measurement window. + * + * Measurements are calculated per window inside the frame. + * This struct represents a window for a measurement. + * + * @h_offs: the horizontal offset of the window from the left of the frame in pixels. + * @v_offs: the vertical offset of the window from the top of the frame in pixels. + * @h_size: the horizontal size of the window in pixels + * @v_size: the vertical size of the window in pixels. + */ +struct rkisp1_cif_isp_window { +	__u16 h_offs; +	__u16 v_offs; +	__u16 h_size; +	__u16 v_size; +}; + +/** + * struct rkisp1_cif_isp_bls_fixed_val - BLS fixed subtraction values + * + * The values will be subtracted from the sensor + * values. Therefore a negative value means addition instead of subtraction! + * + * @r: Fixed (signed!) subtraction value for Bayer pattern R + * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr + * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb + * @b: Fixed (signed!) subtraction value for Bayer pattern B + */ +struct rkisp1_cif_isp_bls_fixed_val { +	__s16 r; +	__s16 gr; +	__s16 gb; +	__s16 b; +}; + +/** + * struct rkisp1_cif_isp_bls_config - Configuration used by black level subtraction + * + * @enable_auto: Automatic mode activated means that the measured values + *		 are subtracted. Otherwise the fixed subtraction + *		 values will be subtracted. + * @en_windows: enabled window + * @bls_window1: Measurement window 1 size + * @bls_window2: Measurement window 2 size + * @bls_samples: Set amount of measured pixels for each Bayer position + *		 (A, B,C and D) to 2^bls_samples. + * @fixed_val: Fixed subtraction values + */ +struct rkisp1_cif_isp_bls_config { +	__u8 enable_auto; +	__u8 en_windows; +	struct rkisp1_cif_isp_window bls_window1; +	struct rkisp1_cif_isp_window bls_window2; +	__u8 bls_samples; +	struct rkisp1_cif_isp_bls_fixed_val fixed_val; +}; + +/** + * struct rkisp1_cif_isp_dpcc_methods_config - DPCC methods set configuration + * + * This structure stores the configuration of one set of methods for the DPCC + * algorithm. Multiple methods can be selected in each set (independently for + * the Green and Red/Blue components) through the @method field, the result is + * the logical AND of all enabled methods. The remaining fields set thresholds + * and factors for each method. + * + * @method: Method enable bits (RKISP1_CIF_ISP_DPCC_METHODS_SET_*) + * @line_thresh: Line threshold (RKISP1_CIF_ISP_DPCC_LINE_THRESH_*) + * @line_mad_fac: Line Mean Absolute Difference factor (RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_*) + * @pg_fac: Peak gradient factor (RKISP1_CIF_ISP_DPCC_PG_FAC_*) + * @rnd_thresh: Rank Neighbor Difference threshold (RKISP1_CIF_ISP_DPCC_RND_THRESH_*) + * @rg_fac: Rank gradient factor (RKISP1_CIF_ISP_DPCC_RG_FAC_*) + */ +struct rkisp1_cif_isp_dpcc_methods_config { +	__u32 method; +	__u32 line_thresh; +	__u32 line_mad_fac; +	__u32 pg_fac; +	__u32 rnd_thresh; +	__u32 rg_fac; +}; + +/** + * struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC + * + * Configuration used by Defect Pixel Cluster Correction. Three sets of methods + * can be configured and selected through the @set_use field. The result is the + * logical OR of all enabled sets. + * + * @mode: DPCC mode (RKISP1_CIF_ISP_DPCC_MODE_*) + * @output_mode: Interpolation output mode (RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_*) + * @set_use: Methods sets selection (RKISP1_CIF_ISP_DPCC_SET_USE_*) + * @methods: Methods sets configuration + * @ro_limits: Rank order limits (RKISP1_CIF_ISP_DPCC_RO_LIMITS_*) + * @rnd_offs: Differential rank offsets for rank neighbor difference (RKISP1_CIF_ISP_DPCC_RND_OFFS_*) + */ +struct rkisp1_cif_isp_dpcc_config { +	__u32 mode; +	__u32 output_mode; +	__u32 set_use; +	struct rkisp1_cif_isp_dpcc_methods_config methods[RKISP1_CIF_ISP_DPCC_METHODS_MAX]; +	__u32 ro_limits; +	__u32 rnd_offs; +}; + +/** + * struct rkisp1_cif_isp_gamma_corr_curve - gamma curve point definition y-axis (output). + * + * The reset values define a linear curve which has the same effect as bypass. Reset values are: + * gamma_y[0] = 0x0000, gamma_y[1] = 0x0100, ... gamma_y[15] = 0x0f00, gamma_y[16] = 0xfff + * + * @gamma_y: the values for the y-axis of gamma curve points. Each value is 12 bit. + */ +struct rkisp1_cif_isp_gamma_corr_curve { +	__u16 gamma_y[RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE]; +}; + +/** + * struct rkisp1_cif_isp_gamma_curve_x_axis_pnts - De-Gamma Curve definition x increments + *		(sampling points). gamma_dx0 is for the lower samples (1-8), gamma_dx1 is for the + *		higher samples (9-16). The reset values for both fields is 0x44444444. This means + *		that each sample is 4 units away from the previous one on the x-axis. + * + * @gamma_dx0: gamma curve sample points definitions. Bits 0:2 for sample 1. Bit 3 unused. + *		Bits 4:6 for sample 2. bit 7 unused ... Bits 28:30 for sample 8. Bit 31 unused + * @gamma_dx1: gamma curve sample points definitions. Bits 0:2 for sample 9. Bit 3 unused. + *		Bits 4:6 for sample 10. bit 7 unused ... Bits 28:30 for sample 16. Bit 31 unused + */ +struct rkisp1_cif_isp_gamma_curve_x_axis_pnts { +	__u32 gamma_dx0; +	__u32 gamma_dx1; +}; + +/** + * struct rkisp1_cif_isp_sdg_config - Configuration used by sensor degamma + * + * @curve_r: gamma curve point definition axis for red + * @curve_g: gamma curve point definition axis for green + * @curve_b: gamma curve point definition axis for blue + * @xa_pnts: x axis increments + */ +struct rkisp1_cif_isp_sdg_config { +	struct rkisp1_cif_isp_gamma_corr_curve curve_r; +	struct rkisp1_cif_isp_gamma_corr_curve curve_g; +	struct rkisp1_cif_isp_gamma_corr_curve curve_b; +	struct rkisp1_cif_isp_gamma_curve_x_axis_pnts xa_pnts; +}; + +/** + * struct rkisp1_cif_isp_lsc_config - Configuration used by Lens shading correction + * + * @r_data_tbl: sample table red + * @gr_data_tbl: sample table green (red) + * @gb_data_tbl: sample table green (blue) + * @b_data_tbl: sample table blue + * @x_grad_tbl: gradient table x + * @y_grad_tbl: gradient table y + * @x_size_tbl: size table x + * @y_size_tbl: size table y + * @config_width: not used at the moment + * @config_height: not used at the moment + */ +struct rkisp1_cif_isp_lsc_config { +	__u16 r_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX]; +	__u16 gr_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX]; +	__u16 gb_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX]; +	__u16 b_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX]; + +	__u16 x_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; +	__u16 y_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; + +	__u16 x_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; +	__u16 y_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE]; +	__u16 config_width; +	__u16 config_height; +}; + +/** + * struct rkisp1_cif_isp_ie_config - Configuration used by image effects + * + * @effect: values from 'enum v4l2_colorfx'. Possible values are: V4L2_COLORFX_SEPIA, + *		V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_AQUA, V4L2_COLORFX_EMBOSS, + *		V4L2_COLORFX_SKETCH,   V4L2_COLORFX_BW,   V4L2_COLORFX_NEGATIVE + * @color_sel: bits 0:2 - colors bitmask (001 - blue, 010 - green, 100 - red). + *		bits 8:15 - Threshold value of the RGB colors for the color selection effect. + * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1 + * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2 + * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1 + * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2 + * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3 + * @eff_tint: Chrominance increment values of tint (used for sepia effect) + */ +struct rkisp1_cif_isp_ie_config { +	__u16 effect; +	__u16 color_sel; +	__u16 eff_mat_1; +	__u16 eff_mat_2; +	__u16 eff_mat_3; +	__u16 eff_mat_4; +	__u16 eff_mat_5; +	__u16 eff_tint; +}; + +/** + * struct rkisp1_cif_isp_cproc_config - Configuration used by Color Processing + * + * @c_out_range: Chrominance pixel clipping range at output. + *		 (0 for limit, 1 for full) + * @y_in_range: Luminance pixel clipping range at output. + * @y_out_range: Luminance pixel clipping range at output. + * @contrast: 00~ff, 0.0~1.992 + * @brightness: 80~7F, -128~+127 + * @sat: saturation, 00~FF, 0.0~1.992 + * @hue: 80~7F, -90~+87.188 + */ +struct rkisp1_cif_isp_cproc_config { +	__u8 c_out_range; +	__u8 y_in_range; +	__u8 y_out_range; +	__u8 contrast; +	__u8 brightness; +	__u8 sat; +	__u8 hue; +}; + +/** + * struct rkisp1_cif_isp_awb_meas_config - Configuration for the AWB statistics + * + * @awb_mode: the awb meas mode. From enum rkisp1_cif_isp_awb_mode_type. + * @awb_wnd: white balance measurement window (in pixels) + * @max_y: only pixels values < max_y contribute to awb measurement, set to 0 + *	   to disable this feature + * @min_y: only pixels values > min_y contribute to awb measurement + * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr, + *	      smaller than threshold for awb measurements + * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr + *	   each greater than threshold value for awb measurements + * @frames: number of frames - 1 used for mean value calculation + *	    (ucFrames=0 means 1 Frame) + * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB + * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB + * @enable_ymax_cmp: enable Y_MAX compare (Not valid in RGB measurement mode.) + */ +struct rkisp1_cif_isp_awb_meas_config { +	/* +	 * Note: currently the h and v offsets are mapped to grid offsets +	 */ +	struct rkisp1_cif_isp_window awb_wnd; +	__u32 awb_mode; +	__u8 max_y; +	__u8 min_y; +	__u8 max_csum; +	__u8 min_c; +	__u8 frames; +	__u8 awb_ref_cr; +	__u8 awb_ref_cb; +	__u8 enable_ymax_cmp; +}; + +/** + * struct rkisp1_cif_isp_awb_gain_config - Configuration used by auto white balance gain + * + * All fields in this struct are 10 bit, where: + * 0x100h = 1, unsigned integer value, range 0 to 4 with 8 bit fractional part. + * + * out_data_x = ( AWB_GAIN_X * in_data + 128) >> 8 + * + * @gain_red: gain value for red component. + * @gain_green_r: gain value for green component in red line. + * @gain_blue: gain value for blue component. + * @gain_green_b: gain value for green component in blue line. + */ +struct rkisp1_cif_isp_awb_gain_config { +	__u16 gain_red; +	__u16 gain_green_r; +	__u16 gain_blue; +	__u16 gain_green_b; +}; + +/** + * struct rkisp1_cif_isp_flt_config - Configuration used by ISP filtering + * + * All 4 threshold fields (thresh_*) are 10 bits. + * All 6 factor fields (fac_*) are 6 bits. + * + * @mode: ISP_FILT_MODE register fields (from enum rkisp1_cif_isp_flt_mode) + * @grn_stage1: Green filter stage 1 select (range 0x0...0x8) + * @chr_h_mode: Chroma filter horizontal mode + * @chr_v_mode: Chroma filter vertical mode + * @thresh_bl0: If thresh_bl1 < sum_grad < thresh_bl0 then fac_bl0 is selected (blurring th) + * @thresh_bl1: If sum_grad < thresh_bl1 then fac_bl1 is selected (blurring th) + * @thresh_sh0: If thresh_sh0 < sum_grad < thresh_sh1 then thresh_sh0 is selected (sharpening th) + * @thresh_sh1: If thresh_sh1 < sum_grad then thresh_sh1 is selected (sharpening th) + * @lum_weight: Parameters for luminance weight function. + * @fac_sh1: filter factor for sharp1 level + * @fac_sh0: filter factor for sharp0 level + * @fac_mid: filter factor for mid level and for static filter mode + * @fac_bl0: filter factor for blur 0 level + * @fac_bl1: filter factor for blur 1 level (max blur) + */ +struct rkisp1_cif_isp_flt_config { +	__u32 mode; +	__u8 grn_stage1; +	__u8 chr_h_mode; +	__u8 chr_v_mode; +	__u32 thresh_bl0; +	__u32 thresh_bl1; +	__u32 thresh_sh0; +	__u32 thresh_sh1; +	__u32 lum_weight; +	__u32 fac_sh1; +	__u32 fac_sh0; +	__u32 fac_mid; +	__u32 fac_bl0; +	__u32 fac_bl1; +}; + +/** + * struct rkisp1_cif_isp_bdm_config - Configuration used by Bayer DeMosaic + * + * @demosaic_th: threshold for bayer demosaicing texture detection + */ +struct rkisp1_cif_isp_bdm_config { +	__u8 demosaic_th; +}; + +/** + * struct rkisp1_cif_isp_ctk_config - Configuration used by Cross Talk correction + * + * @coeff: color correction matrix. Values are 11-bit signed fixed-point numbers with 4 bit integer + *		and 7 bit fractional part, ranging from -8 (0x400) to +7.992 (0x3FF). 0 is + *		represented by 0x000 and a coefficient value of 1 as 0x080. + * @ct_offset: Red, Green, Blue offsets for the crosstalk correction matrix + */ +struct rkisp1_cif_isp_ctk_config { +	__u16 coeff[3][3]; +	__u16 ct_offset[3]; +}; + +enum rkisp1_cif_isp_goc_mode { +	RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC, +	RKISP1_CIF_ISP_GOC_MODE_EQUIDISTANT +}; + +/** + * struct rkisp1_cif_isp_goc_config - Configuration used by Gamma Out correction + * + * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode) + * @gamma_y: gamma out curve y-axis for all color components + * + * The number of entries of @gamma_y depends on the hardware revision + * as is reported by the hw_revision field of the struct media_device_info + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO. + * + * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries. + * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two. + */ +struct rkisp1_cif_isp_goc_config { +	__u32 mode; +	__u16 gamma_y[RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES]; +}; + +/** + * struct rkisp1_cif_isp_hst_config - Configuration for Histogram statistics + * + * @mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode) + * @histogram_predivider: process every stepsize pixel, all other pixels are + *			  skipped + * @meas_window: coordinates of the measure window + * @hist_weight: weighting factor for sub-windows + * + * The number of entries of @hist_weight depends on the hardware revision + * as is reported by the hw_revision field of the struct media_device_info + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO. + * + * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries. + * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the + * two. + */ +struct rkisp1_cif_isp_hst_config { +	__u32 mode; +	__u8 histogram_predivider; +	struct rkisp1_cif_isp_window meas_window; +	__u8 hist_weight[RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE]; +}; + +/** + * struct rkisp1_cif_isp_aec_config - Configuration for Auto Exposure statistics + * + * @mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode) + * @autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop) + * @meas_window: coordinates of the measure window + */ +struct rkisp1_cif_isp_aec_config { +	__u32 mode; +	__u32 autostop; +	struct rkisp1_cif_isp_window meas_window; +}; + +/** + * struct rkisp1_cif_isp_afc_config - Configuration for the Auto Focus statistics + * + * @num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWS + * @afm_win: coordinates of the meas window + * @thres: threshold used for minimizing the influence of noise + * @var_shift: the number of bits for the shift operation at the end of the + *	       calculation chain. + */ +struct rkisp1_cif_isp_afc_config { +	__u8 num_afm_win; +	struct rkisp1_cif_isp_window afm_win[RKISP1_CIF_ISP_AFM_MAX_WINDOWS]; +	__u32 thres; +	__u32 var_shift; +}; + +/** + * enum rkisp1_cif_isp_dpf_gain_usage - dpf gain usage + * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage + * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from + *				    registers DPF_NF_GAIN_R, ... + * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS:  use only the gains from LSC module + * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the + *					gains from LSC module + * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module + * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module + * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation) + */ +enum rkisp1_cif_isp_dpf_gain_usage { +	RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED, +	RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS, +	RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS, +	RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS, +	RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS, +	RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS, +	RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX +}; + +/** + * enum rkisp1_cif_isp_dpf_rb_filtersize - Red and blue filter sizes + * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9 + *				   (means 7x5 active pixel) + * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9 + *				   (means 5x5 active pixel) + */ +enum rkisp1_cif_isp_dpf_rb_filtersize { +	RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9, +	RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9, +}; + +/** + * enum rkisp1_cif_isp_dpf_nll_scale_mode - dpf noise level scale mode + * @RKISP1_CIF_ISP_NLL_SCALE_LINEAR: use a linear scaling + * @RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling + */ +enum rkisp1_cif_isp_dpf_nll_scale_mode { +	RKISP1_CIF_ISP_NLL_SCALE_LINEAR, +	RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC, +}; + +/** + * struct rkisp1_cif_isp_dpf_nll - Noise level lookup + * + * @coeff: Noise level Lookup coefficient + * @scale_mode: dpf noise level scale mode (from enum rkisp1_cif_isp_dpf_nll_scale_mode) + */ +struct rkisp1_cif_isp_dpf_nll { +	__u16 coeff[RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS]; +	__u32 scale_mode; +}; + +/** + * struct rkisp1_cif_isp_dpf_rb_flt - Red blue filter config + * + * @fltsize: The filter size for the red and blue pixels + *	     (from enum rkisp1_cif_isp_dpf_rb_filtersize) + * @spatial_coeff: Spatial weights + * @r_enable: enable filter processing for red pixels + * @b_enable: enable filter processing for blue pixels + */ +struct rkisp1_cif_isp_dpf_rb_flt { +	__u32 fltsize; +	__u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS]; +	__u8 r_enable; +	__u8 b_enable; +}; + +/** + * struct rkisp1_cif_isp_dpf_g_flt - Green filter Configuration + * + * @spatial_coeff: Spatial weights + * @gr_enable: enable filter processing for green pixels in green/red lines + * @gb_enable: enable filter processing for green pixels in green/blue lines + */ +struct rkisp1_cif_isp_dpf_g_flt { +	__u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS]; +	__u8 gr_enable; +	__u8 gb_enable; +}; + +/** + * struct rkisp1_cif_isp_dpf_gain - Noise function Configuration + * + * @mode: dpf gain usage  (from enum rkisp1_cif_isp_dpf_gain_usage) + * @nf_r_gain: Noise function Gain that replaces the AWB gain for red pixels + * @nf_b_gain: Noise function Gain that replaces the AWB gain for blue pixels + * @nf_gr_gain: Noise function Gain that replaces the AWB gain + *		for green pixels in a red line + * @nf_gb_gain: Noise function Gain that replaces the AWB gain + *		for green pixels in a blue line + */ +struct rkisp1_cif_isp_dpf_gain { +	__u32 mode; +	__u16 nf_r_gain; +	__u16 nf_b_gain; +	__u16 nf_gr_gain; +	__u16 nf_gb_gain; +}; + +/** + * struct rkisp1_cif_isp_dpf_config - Configuration used by De-noising pre-filter + * + * @gain: noise function gain + * @g_flt: green filter config + * @rb_flt: red blue filter config + * @nll: noise level lookup + */ +struct rkisp1_cif_isp_dpf_config { +	struct rkisp1_cif_isp_dpf_gain gain; +	struct rkisp1_cif_isp_dpf_g_flt g_flt; +	struct rkisp1_cif_isp_dpf_rb_flt rb_flt; +	struct rkisp1_cif_isp_dpf_nll nll; +}; + +/** + * struct rkisp1_cif_isp_dpf_strength_config - strength of the filter + * + * @r: filter strength of the RED filter + * @g: filter strength of the GREEN filter + * @b: filter strength of the BLUE filter + */ +struct rkisp1_cif_isp_dpf_strength_config { +	__u8 r; +	__u8 g; +	__u8 b; +}; + +/** + * struct rkisp1_cif_isp_isp_other_cfg - Parameters for some blocks in rockchip isp1 + * + * @dpcc_config: Defect Pixel Cluster Correction config + * @bls_config: Black Level Subtraction config + * @sdg_config: sensor degamma config + * @lsc_config: Lens Shade config + * @awb_gain_config: Auto White balance gain config + * @flt_config: filter config + * @bdm_config: demosaic config + * @ctk_config: cross talk config + * @goc_config: gamma out config + * @bls_config: black level subtraction config + * @dpf_config: De-noising pre-filter config + * @dpf_strength_config: dpf strength config + * @cproc_config: color process config + * @ie_config: image effects config + */ +struct rkisp1_cif_isp_isp_other_cfg { +	struct rkisp1_cif_isp_dpcc_config dpcc_config; +	struct rkisp1_cif_isp_bls_config bls_config; +	struct rkisp1_cif_isp_sdg_config sdg_config; +	struct rkisp1_cif_isp_lsc_config lsc_config; +	struct rkisp1_cif_isp_awb_gain_config awb_gain_config; +	struct rkisp1_cif_isp_flt_config flt_config; +	struct rkisp1_cif_isp_bdm_config bdm_config; +	struct rkisp1_cif_isp_ctk_config ctk_config; +	struct rkisp1_cif_isp_goc_config goc_config; +	struct rkisp1_cif_isp_dpf_config dpf_config; +	struct rkisp1_cif_isp_dpf_strength_config dpf_strength_config; +	struct rkisp1_cif_isp_cproc_config cproc_config; +	struct rkisp1_cif_isp_ie_config ie_config; +}; + +/** + * struct rkisp1_cif_isp_isp_meas_cfg - Rockchip ISP1 Measure Parameters + * + * @awb_meas_config: auto white balance config + * @hst_config: histogram config + * @aec_config: auto exposure config + * @afc_config: auto focus config + */ +struct rkisp1_cif_isp_isp_meas_cfg { +	struct rkisp1_cif_isp_awb_meas_config awb_meas_config; +	struct rkisp1_cif_isp_hst_config hst_config; +	struct rkisp1_cif_isp_aec_config aec_config; +	struct rkisp1_cif_isp_afc_config afc_config; +}; + +/** + * struct rkisp1_params_cfg - Rockchip ISP1 Input Parameters Meta Data + * + * @module_en_update: mask the enable bits of which module should be updated + * @module_ens: mask the enable value of each module, only update the module + *		which correspond bit was set in module_en_update + * @module_cfg_update: mask the config bits of which module should be updated + * @meas: measurement config + * @others: other config + */ +struct rkisp1_params_cfg { +	__u32 module_en_update; +	__u32 module_ens; +	__u32 module_cfg_update; + +	struct rkisp1_cif_isp_isp_meas_cfg meas; +	struct rkisp1_cif_isp_isp_other_cfg others; +}; + +/** + * struct rkisp1_cif_isp_compand_bls_config - Rockchip ISP1 Companding parameters (BLS) + * @r: Fixed subtraction value for Bayer pattern R + * @gr: Fixed subtraction value for Bayer pattern Gr + * @gb: Fixed subtraction value for Bayer pattern Gb + * @b: Fixed subtraction value for Bayer pattern B + * + * The values will be subtracted from the sensor values. Note that unlike the + * dedicated BLS block, the BLS values in the compander are 20-bit unsigned. + */ +struct rkisp1_cif_isp_compand_bls_config { +	__u32 r; +	__u32 gr; +	__u32 gb; +	__u32 b; +}; + +/** + * struct rkisp1_cif_isp_compand_curve_config - Rockchip ISP1 Companding + * parameters (expand and compression curves) + * @px: Compand curve x-values. Each value stores the distance from the + *      previous x-value, expressed as log2 of the distance on 5 bits. + * @x: Compand curve x-values. The functionality of these parameters are + *     unknown due to do a lack of hardware documentation, but these are left + *     here for future compatibility purposes. + * @y: Compand curve y-values + */ +struct rkisp1_cif_isp_compand_curve_config { +	__u8 px[RKISP1_CIF_ISP_COMPAND_NUM_POINTS]; +	__u32 x[RKISP1_CIF_ISP_COMPAND_NUM_POINTS]; +	__u32 y[RKISP1_CIF_ISP_COMPAND_NUM_POINTS]; +}; + +/** + * struct rkisp1_cif_isp_wdr_tone_curve - Tone mapping curve definition for WDR. + * + * @dY: the dYn increments for horizontal (input) axis of the tone curve. + *      each 3-bit dY value represents an increment of 2**(value+3). + *      dY[0] bits 0:2 is increment dY1, bit 3 unused + *      dY[0] bits 4:6 is increment dY2, bit 7 unused + *      ... + *      dY[0] bits 28:30 is increment dY8, bit 31 unused + *      ... and so on till dY[3] bits 28:30 is increment dY32, bit 31 unused. + * @ym: the Ym values for the vertical (output) axis of the tone curve. + *      each value is 13 bit. + */ +struct rkisp1_cif_isp_wdr_tone_curve { +	__u32 dY[RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS]; +	__u16 ym[RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF]; +}; + +/** + * struct rkisp1_cif_isp_wdr_iref_config - Illumination reference config for WDR. + * + * Use illumination reference value as described below, instead of only the + * luminance (Y) value for tone mapping and gain calculations: + * IRef = (rgb_factor * RGBMax_tr + (8 - rgb_factor) * Y)/8 + * + * @rgb_factor: defines how much influence the RGBmax approach has in + *              comparison to Y (valid values are 0..8). + * @use_y9_8: use Y*9/8 for maximum value calculation along with the + *            default of R, G, B for noise reduction. + * @use_rgb7_8: decrease RGBMax by 7/8 for noise reduction. + * @disable_transient: disable transient calculation between Y and RGBY_max. + */ +struct rkisp1_cif_isp_wdr_iref_config { +	__u8 rgb_factor; +	__u8 use_y9_8; +	__u8 use_rgb7_8; +	__u8 disable_transient; +}; + +/** + * struct rkisp1_cif_isp_wdr_config - Configuration for wide dynamic range. + * + * @tone_curve: tone mapping curve. + * @iref_config: illumination reference configuration. (when use_iref is true) + * @rgb_offset: RGB offset value for RGB operation mode. (12 bits) + * @luma_offset: luminance offset value for RGB operation mode. (12 bits) + * @dmin_thresh: lower threshold for deltaMin value. (12 bits) + * @dmin_strength: strength factor for deltaMin. (valid range is 0x00..0x10) + * @use_rgb_colorspace: use RGB instead of luminance/chrominance colorspace. + * @bypass_chroma_mapping: disable chrominance mapping (only valid if + *                         use_rgb_colorspace = 0) + * @use_iref: use illumination reference instead of Y for tone mapping + *            and gain calculations. + */ +struct rkisp1_cif_isp_wdr_config { +	struct rkisp1_cif_isp_wdr_tone_curve tone_curve; +	struct rkisp1_cif_isp_wdr_iref_config iref_config; +	__u16 rgb_offset; +	__u16 luma_offset; +	__u16 dmin_thresh; +	__u8 dmin_strength; +	__u8 use_rgb_colorspace; +	__u8 bypass_chroma_mapping; +	__u8 use_iref; +}; + +/*---------- PART2: Measurement Statistics ------------*/ + +/** + * struct rkisp1_cif_isp_awb_meas - AWB measured values + * + * @cnt: White pixel count, number of "white pixels" found during last + *	 measurement + * @mean_y_or_g: Mean value of Y within window and frames, + *		 Green if RGB is selected. + * @mean_cb_or_b: Mean value of Cb within window and frames, + *		  Blue if RGB is selected. + * @mean_cr_or_r: Mean value of Cr within window and frames, + *		  Red if RGB is selected. + */ +struct rkisp1_cif_isp_awb_meas { +	__u32 cnt; +	__u8 mean_y_or_g; +	__u8 mean_cb_or_b; +	__u8 mean_cr_or_r; +}; + +/** + * struct rkisp1_cif_isp_awb_stat - statistics automatic white balance data + * + * @awb_mean: Mean measured data + */ +struct rkisp1_cif_isp_awb_stat { +	struct rkisp1_cif_isp_awb_meas awb_mean[RKISP1_CIF_ISP_AWB_MAX_GRID]; +}; + +/** + * struct rkisp1_cif_isp_bls_meas_val - BLS measured values + * + * @meas_r: Mean measured value for Bayer pattern R + * @meas_gr: Mean measured value for Bayer pattern Gr + * @meas_gb: Mean measured value for Bayer pattern Gb + * @meas_b: Mean measured value for Bayer pattern B + */ +struct rkisp1_cif_isp_bls_meas_val { +	__u16 meas_r; +	__u16 meas_gr; +	__u16 meas_gb; +	__u16 meas_b; +}; + +/** + * struct rkisp1_cif_isp_ae_stat - statistics auto exposure data + * + * @exp_mean: Mean luminance value of block xx + * @bls_val:  BLS measured values + * + * The number of entries of @exp_mean depends on the hardware revision + * as is reported by the hw_revision field of the struct media_device_info + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO. + * + * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has + * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal + * to the maximum of the two. + * + * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12. + */ +struct rkisp1_cif_isp_ae_stat { +	__u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX]; +	struct rkisp1_cif_isp_bls_meas_val bls_val; +}; + +/** + * struct rkisp1_cif_isp_af_meas_val - AF measured values + * + * @sum: sharpness value + * @lum: luminance value + */ +struct rkisp1_cif_isp_af_meas_val { +	__u32 sum; +	__u32 lum; +}; + +/** + * struct rkisp1_cif_isp_af_stat - statistics auto focus data + * + * @window: AF measured value of window x + * + * The module measures the sharpness in 3 windows of selectable size via + * register settings(ISP_AFM_*_A/B/C) + */ +struct rkisp1_cif_isp_af_stat { +	struct rkisp1_cif_isp_af_meas_val window[RKISP1_CIF_ISP_AFM_MAX_WINDOWS]; +}; + +/** + * struct rkisp1_cif_isp_hist_stat - statistics histogram data + * + * @hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point + *	       type. Bits 0-4 are the fractional part and bits 5-19 are the + *	       integer part. + * + * The window of the measurements area is divided to 5x5 sub-windows for + * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each + * sub-window independently and the final result is a weighted average of the + * histogram measurements on all sub-windows. The window of the measurements + * area and the weight of each sub-window are configurable using + * struct @rkisp1_cif_isp_hst_config. + * + * The histogram contains 16 bins in V10 and 32 bins in V12. + * + * The number of entries of @hist_bins depends on the hardware revision + * as is reported by the hw_revision field of the struct media_device_info + * that is returned by ioctl MEDIA_IOC_DEVICE_INFO. + * + * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has + * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is + * equal to the maximum of the two. + */ +struct rkisp1_cif_isp_hist_stat { +	__u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX]; +}; + +/** + * struct rkisp1_cif_isp_stat - Rockchip ISP1 Statistics Data + * + * @awb: statistics data for automatic white balance + * @ae: statistics data for auto exposure + * @af: statistics data for auto focus + * @hist: statistics histogram data + */ +struct rkisp1_cif_isp_stat { +	struct rkisp1_cif_isp_awb_stat awb; +	struct rkisp1_cif_isp_ae_stat ae; +	struct rkisp1_cif_isp_af_stat af; +	struct rkisp1_cif_isp_hist_stat hist; +}; + +/** + * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data + * + * @meas_type: measurement types (RKISP1_CIF_ISP_STAT_* definitions) + * @frame_id: frame ID for sync + * @params: statistics data + */ +struct rkisp1_stat_buffer { +	__u32 meas_type; +	__u32 frame_id; +	struct rkisp1_cif_isp_stat params; +}; + +/*---------- PART3: Extensible Configuration Parameters  ------------*/ + +/** + * enum rkisp1_ext_params_block_type - RkISP1 extensible params block type + * + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS: Black level subtraction + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC: Defect pixel cluster correction + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG: Sensor de-gamma + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN: Auto white balance gains + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT: ISP filtering + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM: Bayer de-mosaic + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK: Cross-talk correction + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC: Gamma out correction + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF: De-noise pre-filter + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH: De-noise pre-filter strength + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC: Color processing + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_IE: Image effects + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC: Lens shading correction + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS: Auto white balance statistics + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS: Histogram statistics + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS: Auto exposure statistics + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS: Auto-focus statistics + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS: BLS in the compand block + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND: Companding expand curve + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS: Companding compress curve + * @RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR: Wide dynamic range + */ +enum rkisp1_ext_params_block_type { +	RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_IE, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS, +	RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR, +}; + +#define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE	(1U << 0) +#define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE	(1U << 1) + +/* A bitmask of parameters blocks supported on the current hardware. */ +#define RKISP1_CID_SUPPORTED_PARAMS_BLOCKS	(V4L2_CID_USER_RKISP1_BASE + 0x01) + +/** + * struct rkisp1_ext_params_block_header - RkISP1 extensible parameters block + *					   header + * + * This structure represents the common part of all the ISP configuration + * blocks. Each parameters block shall embed an instance of this structure type + * as its first member, followed by the block-specific configuration data. The + * driver inspects this common header to discern the block type and its size and + * properly handle the block content by casting it to the correct block-specific + * type. + * + * The @type field is one of the values enumerated by + * :c:type:`rkisp1_ext_params_block_type` and specifies how the data should be + * interpreted by the driver. The @size field specifies the size of the + * parameters block and is used by the driver for validation purposes. + * + * The @flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*. + * + * When userspace wants to configure and enable an ISP block it shall fully + * populate the block configuration and set the + * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE bit in the @flags field. + * + * When userspace simply wants to disable an ISP block the + * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bit should be set in @flags field. The + * driver ignores the rest of the block configuration structure in this case. + * + * If a new configuration of an ISP block has to be applied userspace shall + * fully populate the ISP block configuration and omit setting the + * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits + * in the @flags field. + * + * Setting both the RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and + * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits in the @flags field is not allowed + * and not accepted by the driver. + * + * Userspace is responsible for correctly populating the parameters block header + * fields (@type, @flags and @size) and the block-specific parameters. + * + * For example: + * + * .. code-block:: c + * + *	void populate_bls(struct rkisp1_ext_params_block_header *block) { + *		struct rkisp1_ext_params_bls_config *bls = + *			(struct rkisp1_ext_params_bls_config *)block; + * + *		bls->header.type = RKISP1_EXT_PARAMS_BLOCK_ID_BLS; + *		bls->header.flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; + *		bls->header.size = sizeof(*bls); + * + *		bls->config.enable_auto = 0; + *		bls->config.fixed_val.r = blackLevelRed_; + *		bls->config.fixed_val.gr = blackLevelGreenR_; + *		bls->config.fixed_val.gb = blackLevelGreenB_; + *		bls->config.fixed_val.b = blackLevelBlue_; + *	} + * + * @type: The parameters block type, see + *	  :c:type:`rkisp1_ext_params_block_type` + * @flags: A bitmask of block flags + * @size: Size (in bytes) of the parameters block, including this header + */ +struct rkisp1_ext_params_block_header { +	__u16 type; +	__u16 flags; +	__u32 size; +}; + +/** + * struct rkisp1_ext_params_bls_config - RkISP1 extensible params BLS config + * + * RkISP1 extensible parameters Black Level Subtraction configuration block. + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Black Level Subtraction configuration, see + *	    :c:type:`rkisp1_cif_isp_bls_config` + */ +struct rkisp1_ext_params_bls_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_bls_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_dpcc_config - RkISP1 extensible params DPCC config + * + * RkISP1 extensible parameters Defective Pixel Cluster Correction configuration + * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Defective Pixel Cluster Correction configuration, see + *	    :c:type:`rkisp1_cif_isp_dpcc_config` + */ +struct rkisp1_ext_params_dpcc_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_dpcc_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_sdg_config - RkISP1 extensible params SDG config + * + * RkISP1 extensible parameters Sensor Degamma configuration block. Identified + * by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Sensor Degamma configuration, see + *	    :c:type:`rkisp1_cif_isp_sdg_config` + */ +struct rkisp1_ext_params_sdg_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_sdg_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_lsc_config - RkISP1 extensible params LSC config + * + * RkISP1 extensible parameters Lens Shading Correction configuration block. + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Lens Shading Correction configuration, see + *	    :c:type:`rkisp1_cif_isp_lsc_config` + */ +struct rkisp1_ext_params_lsc_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_lsc_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_awb_gain_config - RkISP1 extensible params AWB + *					      gain config + * + * RkISP1 extensible parameters Auto-White Balance Gains configuration block. + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Auto-White Balance Gains configuration, see + *	    :c:type:`rkisp1_cif_isp_awb_gain_config` + */ +struct rkisp1_ext_params_awb_gain_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_awb_gain_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_flt_config - RkISP1 extensible params FLT config + * + * RkISP1 extensible parameters Filter configuration block. Identified by + * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Filter configuration, see :c:type:`rkisp1_cif_isp_flt_config` + */ +struct rkisp1_ext_params_flt_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_flt_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_bdm_config - RkISP1 extensible params BDM config + * + * RkISP1 extensible parameters Demosaicing configuration block. Identified by + * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Demosaicing configuration, see :c:type:`rkisp1_cif_isp_bdm_config` + */ +struct rkisp1_ext_params_bdm_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_bdm_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_ctk_config - RkISP1 extensible params CTK config + * + * RkISP1 extensible parameters Cross-Talk configuration block. Identified by + * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Cross-Talk configuration, see :c:type:`rkisp1_cif_isp_ctk_config` + */ +struct rkisp1_ext_params_ctk_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_ctk_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_goc_config - RkISP1 extensible params GOC config + * + * RkISP1 extensible parameters Gamma-Out configuration block. Identified by + * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Gamma-Out configuration, see :c:type:`rkisp1_cif_isp_goc_config` + */ +struct rkisp1_ext_params_goc_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_goc_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_dpf_config - RkISP1 extensible params DPF config + * + * RkISP1 extensible parameters De-noise Pre-Filter configuration block. + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: De-noise Pre-Filter configuration, see + *	    :c:type:`rkisp1_cif_isp_dpf_config` + */ +struct rkisp1_ext_params_dpf_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_dpf_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_dpf_strength_config - RkISP1 extensible params DPF + *						  strength config + * + * RkISP1 extensible parameters De-noise Pre-Filter strength configuration + * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: De-noise Pre-Filter strength configuration, see + *	    :c:type:`rkisp1_cif_isp_dpf_strength_config` + */ +struct rkisp1_ext_params_dpf_strength_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_dpf_strength_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_cproc_config - RkISP1 extensible params CPROC config + * + * RkISP1 extensible parameters Color Processing configuration block. + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Color processing configuration, see + *	    :c:type:`rkisp1_cif_isp_cproc_config` + */ +struct rkisp1_ext_params_cproc_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_cproc_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_ie_config - RkISP1 extensible params IE config + * + * RkISP1 extensible parameters Image Effect configuration block. Identified by + * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_IE`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Image Effect configuration, see :c:type:`rkisp1_cif_isp_ie_config` + */ +struct rkisp1_ext_params_ie_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_ie_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_awb_meas_config - RkISP1 extensible params AWB + *					      Meas config + * + * RkISP1 extensible parameters Auto-White Balance Measurement configuration + * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Auto-White Balance measure configuration, see + *	    :c:type:`rkisp1_cif_isp_awb_meas_config` + */ +struct rkisp1_ext_params_awb_meas_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_awb_meas_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_hst_config - RkISP1 extensible params Histogram config + * + * RkISP1 extensible parameters Histogram statistics configuration block. + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Histogram statistics configuration, see + *	    :c:type:`rkisp1_cif_isp_hst_config` + */ +struct rkisp1_ext_params_hst_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_hst_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_aec_config - RkISP1 extensible params AEC config + * + * RkISP1 extensible parameters Auto-Exposure statistics configuration block. + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Auto-Exposure statistics configuration, see + *	    :c:type:`rkisp1_cif_isp_aec_config` + */ +struct rkisp1_ext_params_aec_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_aec_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_afc_config - RkISP1 extensible params AFC config + * + * RkISP1 extensible parameters Auto-Focus statistics configuration block. + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Auto-Focus statistics configuration, see + *	    :c:type:`rkisp1_cif_isp_afc_config` + */ +struct rkisp1_ext_params_afc_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_afc_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_compand_bls_config - RkISP1 extensible params + * Compand BLS config + * + * RkISP1 extensible parameters Companding configuration block (black level + * subtraction). Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Companding BLS configuration, see + *	    :c:type:`rkisp1_cif_isp_compand_bls_config` + */ +struct rkisp1_ext_params_compand_bls_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_compand_bls_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_compand_curve_config - RkISP1 extensible params + * Compand curve config + * + * RkISP1 extensible parameters Companding configuration block (expand and + * compression curves). Identified by + * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND` or + * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS`. + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: Companding curve configuration, see + *	    :c:type:`rkisp1_cif_isp_compand_curve_config` + */ +struct rkisp1_ext_params_compand_curve_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_compand_curve_config config; +} __attribute__((aligned(8))); + +/** + * struct rkisp1_ext_params_wdr_config - RkISP1 extensible params + *                                       Wide dynamic range config + * + * RkISP1 extensible parameters WDR block. + * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR` + * + * @header: The RkISP1 extensible parameters header, see + *	    :c:type:`rkisp1_ext_params_block_header` + * @config: WDR configuration, see + *	    :c:type:`rkisp1_cif_isp_wdr_config` + */ +struct rkisp1_ext_params_wdr_config { +	struct rkisp1_ext_params_block_header header; +	struct rkisp1_cif_isp_wdr_config config; +} __attribute__((aligned(8))); + +/* + * The rkisp1_ext_params_compand_curve_config structure is counted twice as it + * is used for both the COMPAND_EXPAND and COMPAND_COMPRESS block types. + */ +#define RKISP1_EXT_PARAMS_MAX_SIZE					\ +	(sizeof(struct rkisp1_ext_params_bls_config)			+\ +	sizeof(struct rkisp1_ext_params_dpcc_config)			+\ +	sizeof(struct rkisp1_ext_params_sdg_config)			+\ +	sizeof(struct rkisp1_ext_params_lsc_config)			+\ +	sizeof(struct rkisp1_ext_params_awb_gain_config)		+\ +	sizeof(struct rkisp1_ext_params_flt_config)			+\ +	sizeof(struct rkisp1_ext_params_bdm_config)			+\ +	sizeof(struct rkisp1_ext_params_ctk_config)			+\ +	sizeof(struct rkisp1_ext_params_goc_config)			+\ +	sizeof(struct rkisp1_ext_params_dpf_config)			+\ +	sizeof(struct rkisp1_ext_params_dpf_strength_config)		+\ +	sizeof(struct rkisp1_ext_params_cproc_config)			+\ +	sizeof(struct rkisp1_ext_params_ie_config)			+\ +	sizeof(struct rkisp1_ext_params_awb_meas_config)		+\ +	sizeof(struct rkisp1_ext_params_hst_config)			+\ +	sizeof(struct rkisp1_ext_params_aec_config)			+\ +	sizeof(struct rkisp1_ext_params_afc_config)			+\ +	sizeof(struct rkisp1_ext_params_compand_bls_config)		+\ +	sizeof(struct rkisp1_ext_params_compand_curve_config)		+\ +	sizeof(struct rkisp1_ext_params_compand_curve_config)		+\ +	sizeof(struct rkisp1_ext_params_wdr_config)) + +/** + * enum rksip1_ext_param_buffer_version - RkISP1 extensible parameters version + * + * @RKISP1_EXT_PARAM_BUFFER_V1: First version of RkISP1 extensible parameters + */ +enum rksip1_ext_param_buffer_version { +	RKISP1_EXT_PARAM_BUFFER_V1 = 1, +}; + +/** + * struct rkisp1_ext_params_cfg - RkISP1 extensible parameters configuration + * + * This struct contains the configuration parameters of the RkISP1 ISP + * algorithms, serialized by userspace into a data buffer. Each configuration + * parameter block is represented by a block-specific structure which contains a + * :c:type:`rkisp1_ext_params_block_header` entry as first member. Userspace + * populates the @data buffer with configuration parameters for the blocks that + * it intends to configure. As a consequence, the data buffer effective size + * changes according to the number of ISP blocks that userspace intends to + * configure and is set by userspace in the @data_size field. + * + * The parameters buffer is versioned by the @version field to allow modifying + * and extending its definition. Userspace shall populate the @version field to + * inform the driver about the version it intends to use. The driver will parse + * and handle the @data buffer according to the data layout specific to the + * indicated version and return an error if the desired version is not + * supported. + * + * Currently the single RKISP1_EXT_PARAM_BUFFER_V1 version is supported. + * When a new format version will be added, a mechanism for userspace to query + * the supported format versions will be implemented in the form of a read-only + * V4L2 control. If such control is not available, userspace should assume only + * RKISP1_EXT_PARAM_BUFFER_V1 is supported by the driver. + * + * The read-only V4L2 control ``RKISP1_CID_SUPPORTED_PARAMS_BLOCKS`` can be used + * to query the blocks supported by the device. It contains a bitmask where each + * bit represents the availability of the corresponding entry from the + * :c:type:`rkisp1_ext_params_block_type` enum. The current and default values + * of the control represents the blocks supported by the device instance, while + * the maximum value represents the blocks supported by the kernel driver, + * independently of the device instance. + * + * For each ISP block that userspace wants to configure, a block-specific + * structure is appended to the @data buffer, one after the other without gaps + * in between nor overlaps. Userspace shall populate the @data_size field with + * the effective size, in bytes, of the @data buffer. + * + * The expected memory layout of the parameters buffer is:: + * + *	+-------------------- struct rkisp1_ext_params_cfg -------------------+ + *	| version = RKISP1_EXT_PARAM_BUFFER_V1;                               | + *	| data_size = sizeof(struct rkisp1_ext_params_bls_config)             | + *	|           + sizeof(struct rkisp1_ext_params_dpcc_config);           | + *	| +------------------------- data  ---------------------------------+ | + *	| | +------------- struct rkisp1_ext_params_bls_config -----------+ | | + *	| | | +-------- struct rkisp1_ext_params_block_header  ---------+ | | | + *	| | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS;                | | | | + *	| | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE;              | | | | + *	| | | | size = sizeof(struct rkisp1_ext_params_bls_config);     | | | | + *	| | | +---------------------------------------------------------+ | | | + *	| | | +---------- struct rkisp1_cif_isp_bls_config -------------+ | | | + *	| | | | enable_auto = 0;                                        | | | | + *	| | | | fixed_val.r = 256;                                      | | | | + *	| | | | fixed_val.gr = 256;                                     | | | | + *	| | | | fixed_val.gb = 256;                                     | | | | + *	| | | | fixed_val.b = 256;                                      | | | | + *	| | | +---------------------------------------------------------+ | | | + *	| | +------------ struct rkisp1_ext_params_dpcc_config -----------+ | | + *	| | | +-------- struct rkisp1_ext_params_block_header  ---------+ | | | + *	| | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC;               | | | | + *	| | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE;              | | | | + *	| | | | size = sizeof(struct rkisp1_ext_params_dpcc_config);    | | | | + *	| | | +---------------------------------------------------------+ | | | + *	| | | +---------- struct rkisp1_cif_isp_dpcc_config ------------+ | | | + *	| | | | mode = RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE;          | | | | + *	| | | | output_mode =                                           | | | | + *	| | | |   RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER; | | | | + *	| | | | set_use = ... ;                                         | | | | + *	| | | | ...  = ... ;                                            | | | | + *	| | | +---------------------------------------------------------+ | | | + *	| | +-------------------------------------------------------------+ | | + *	| +-----------------------------------------------------------------+ | + *	+---------------------------------------------------------------------+ + * + * @version: The RkISP1 extensible parameters buffer version, see + *	     :c:type:`rksip1_ext_param_buffer_version` + * @data_size: The RkISP1 configuration data effective size, excluding this + *	       header + * @data: The RkISP1 extensible configuration data blocks + */ +struct rkisp1_ext_params_cfg { +	__u32 version; +	__u32 data_size; +	__u8 data[RKISP1_EXT_PARAMS_MAX_SIZE]; +}; + +#endif /* _UAPI_RKISP1_CONFIG_H */ diff --git a/include/uapi/linux/romfs_fs.h b/include/uapi/linux/romfs_fs.h index a7f1585accef..6aa05e792454 100644 --- a/include/uapi/linux/romfs_fs.h +++ b/include/uapi/linux/romfs_fs.h @@ -27,7 +27,7 @@ struct romfs_super_block {  	__be32 word1;  	__be32 size;  	__be32 checksum; -	char name[0];		/* volume name */ +	char name[];		/* volume name */  };  /* On disk inode */ @@ -37,7 +37,7 @@ struct romfs_inode {  	__be32 spec;  	__be32 size;  	__be32 checksum; -	char name[0]; +	char name[];  };  #define ROMFH_TYPE 7 diff --git a/include/uapi/linux/rpl.h b/include/uapi/linux/rpl.h index 1dccb55cf8c6..7c8970e5b84b 100644 --- a/include/uapi/linux/rpl.h +++ b/include/uapi/linux/rpl.h @@ -28,17 +28,17 @@ struct ipv6_rpl_sr_hdr {  		pad:4,  		reserved1:16;  #elif defined(__BIG_ENDIAN_BITFIELD) -	__u32	reserved:20, +	__u32	cmpri:4, +		cmpre:4,  		pad:4, -		cmpri:4, -		cmpre:4; +		reserved:20;  #else  #error  "Please fix <asm/byteorder.h>"  #endif  	union { -		struct in6_addr addr[0]; -		__u8 data[0]; +		__DECLARE_FLEX_ARRAY(struct in6_addr, addr); +		__DECLARE_FLEX_ARRAY(__u8, data);  	} segments;  } __attribute__((packed)); diff --git a/include/uapi/linux/rpmsg.h b/include/uapi/linux/rpmsg.h index e14c6dab4223..f0c8da2b185b 100644 --- a/include/uapi/linux/rpmsg.h +++ b/include/uapi/linux/rpmsg.h @@ -9,11 +9,13 @@  #include <linux/ioctl.h>  #include <linux/types.h> +#define RPMSG_ADDR_ANY		0xFFFFFFFF +  /**   * struct rpmsg_endpoint_info - endpoint info representation   * @name: name of service - * @src: local address - * @dst: destination address + * @src: local address. To set to RPMSG_ADDR_ANY if not used. + * @dst: destination address. To set to RPMSG_ADDR_ANY if not used.   */  struct rpmsg_endpoint_info {  	char name[32]; @@ -21,7 +23,34 @@ struct rpmsg_endpoint_info {  	__u32 dst;  }; +/** + * Instantiate a new rmpsg char device endpoint. + */  #define RPMSG_CREATE_EPT_IOCTL	_IOW(0xb5, 0x1, struct rpmsg_endpoint_info) + +/** + * Destroy a rpmsg char device endpoint created by the RPMSG_CREATE_EPT_IOCTL. + */  #define RPMSG_DESTROY_EPT_IOCTL	_IO(0xb5, 0x2) +/** + * Instantiate a new local rpmsg service device. + */ +#define RPMSG_CREATE_DEV_IOCTL	_IOW(0xb5, 0x3, struct rpmsg_endpoint_info) + +/** + * Release a local rpmsg device. + */ +#define RPMSG_RELEASE_DEV_IOCTL	_IOW(0xb5, 0x4, struct rpmsg_endpoint_info) + +/** + * Get the flow control state of the remote rpmsg char device. + */ +#define RPMSG_GET_OUTGOING_FLOWCONTROL _IOR(0xb5, 0x5, int) + +/** + * Set the flow control state of the local rpmsg char device. + */ +#define RPMSG_SET_INCOMING_FLOWCONTROL _IOR(0xb5, 0x6, int) +  #endif diff --git a/include/uapi/linux/rpmsg_types.h b/include/uapi/linux/rpmsg_types.h new file mode 100644 index 000000000000..36e3b9404391 --- /dev/null +++ b/include/uapi/linux/rpmsg_types.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_RPMSG_TYPES_H +#define _UAPI_LINUX_RPMSG_TYPES_H + +#include <linux/types.h> + +typedef __u16 __bitwise __rpmsg16; +typedef __u32 __bitwise __rpmsg32; +typedef __u64 __bitwise __rpmsg64; + +#endif /* _UAPI_LINUX_RPMSG_TYPES_H */ diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h index 9a402fdb60e9..c233aae5eac9 100644 --- a/include/uapi/linux/rseq.h +++ b/include/uapi/linux/rseq.h @@ -105,23 +105,11 @@ struct rseq {  	 * Read and set by the kernel. Set by user-space with single-copy  	 * atomicity semantics. This field should only be updated by the  	 * thread which registered this data structure. Aligned on 64-bit. +	 * +	 * 32-bit architectures should update the low order bits of the +	 * rseq_cs field, leaving the high order bits initialized to 0.  	 */ -	union { -		__u64 ptr64; -#ifdef __LP64__ -		__u64 ptr; -#else -		struct { -#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined(__BIG_ENDIAN) -			__u32 padding;		/* Initialized to zero. */ -			__u32 ptr32; -#else /* LITTLE */ -			__u32 ptr32; -			__u32 padding;		/* Initialized to zero. */ -#endif /* ENDIAN */ -		} ptr; -#endif -	} rseq_cs; +	__u64 rseq_cs;  	/*  	 * Restartable sequences flags field. @@ -142,6 +130,28 @@ struct rseq {  	 *     this thread.  	 */  	__u32 flags; + +	/* +	 * Restartable sequences node_id field. Updated by the kernel. Read by +	 * user-space with single-copy atomicity semantics. This field should +	 * only be read by the thread which registered this data structure. +	 * Aligned on 32-bit. Contains the current NUMA node ID. +	 */ +	__u32 node_id; + +	/* +	 * Restartable sequences mm_cid field. Updated by the kernel. Read by +	 * user-space with single-copy atomicity semantics. This field should +	 * only be read by the thread which registered this data structure. +	 * Aligned on 32-bit. Contains the current thread's concurrency ID +	 * (allocated uniquely within a memory map). +	 */ +	__u32 mm_cid; + +	/* +	 * Flexible array member at end of structure, after last feature field. +	 */ +	char end[];  } __attribute__((aligned(4 * sizeof(__u64))));  #endif /* _UAPI_LINUX_RSEQ_H */ diff --git a/include/uapi/linux/rtc.h b/include/uapi/linux/rtc.h index fa9aff91cbf2..97aca4503a6a 100644 --- a/include/uapi/linux/rtc.h +++ b/include/uapi/linux/rtc.h @@ -14,6 +14,7 @@  #include <linux/const.h>  #include <linux/ioctl.h> +#include <linux/types.h>  /*   * The struct used to pass data via the following ioctl. Similar to the @@ -66,6 +67,17 @@ struct rtc_pll_info {  	long pll_clock;     /* base PLL frequency */  }; +struct rtc_param { +	__u64 param; +	union { +		__u64 uvalue; +		__s64 svalue; +		__u64 ptr; +	}; +	__u32 index; +	__u32 __pad; +}; +  /*   * ioctl calls that are permitted to the /dev/rtc interface, if   * any of the RTC drivers are enabled. @@ -95,6 +107,9 @@ struct rtc_pll_info {  #define RTC_PLL_GET	_IOR('p', 0x11, struct rtc_pll_info)  /* Get PLL correction */  #define RTC_PLL_SET	_IOW('p', 0x12, struct rtc_pll_info)  /* Set PLL correction */ +#define RTC_PARAM_GET	_IOW('p', 0x13, struct rtc_param)  /* Get parameter */ +#define RTC_PARAM_SET	_IOW('p', 0x14, struct rtc_param)  /* Set parameter */ +  #define RTC_VL_DATA_INVALID	_BITUL(0) /* Voltage too low, RTC data is invalid */  #define RTC_VL_BACKUP_LOW	_BITUL(1) /* Backup voltage is low */  #define RTC_VL_BACKUP_EMPTY	_BITUL(2) /* Backup empty or not present */ @@ -110,6 +125,26 @@ struct rtc_pll_info {  #define RTC_AF 0x20	/* Alarm interrupt */  #define RTC_UF 0x10	/* Update interrupt for 1Hz RTC */ +/* feature list */ +#define RTC_FEATURE_ALARM		0 +#define RTC_FEATURE_ALARM_RES_MINUTE	1 +#define RTC_FEATURE_NEED_WEEK_DAY	2 +#define RTC_FEATURE_ALARM_RES_2S	3 +#define RTC_FEATURE_UPDATE_INTERRUPT	4 +#define RTC_FEATURE_CORRECTION		5 +#define RTC_FEATURE_BACKUP_SWITCH_MODE	6 +#define RTC_FEATURE_ALARM_WAKEUP_ONLY	7 +#define RTC_FEATURE_CNT			8 + +/* parameter list */ +#define RTC_PARAM_FEATURES		0 +#define RTC_PARAM_CORRECTION		1 +#define RTC_PARAM_BACKUP_SWITCH_MODE	2 + +#define RTC_BSM_DISABLED	0 +#define RTC_BSM_DIRECT		1 +#define RTC_BSM_LEVEL		2 +#define RTC_BSM_STANDBY		3  #define RTC_MAX_FREQ	8192 diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h index 9b814c92de12..dab9493c791b 100644 --- a/include/uapi/linux/rtnetlink.h +++ b/include/uapi/linux/rtnetlink.h @@ -93,10 +93,18 @@ enum {  	RTM_NEWPREFIX	= 52,  #define RTM_NEWPREFIX	RTM_NEWPREFIX -	RTM_GETMULTICAST = 58, +	RTM_NEWMULTICAST = 56, +#define RTM_NEWMULTICAST RTM_NEWMULTICAST +	RTM_DELMULTICAST, +#define RTM_DELMULTICAST RTM_DELMULTICAST +	RTM_GETMULTICAST,  #define RTM_GETMULTICAST RTM_GETMULTICAST -	RTM_GETANYCAST	= 62, +	RTM_NEWANYCAST	= 60, +#define RTM_NEWANYCAST RTM_NEWANYCAST +	RTM_DELANYCAST, +#define RTM_DELANYCAST RTM_DELANYCAST +	RTM_GETANYCAST,  #define RTM_GETANYCAST	RTM_GETANYCAST  	RTM_NEWNEIGHTBL	= 64, @@ -146,6 +154,8 @@ enum {  #define RTM_NEWSTATS RTM_NEWSTATS  	RTM_GETSTATS = 94,  #define RTM_GETSTATS RTM_GETSTATS +	RTM_SETSTATS, +#define RTM_SETSTATS RTM_SETSTATS  	RTM_NEWCACHEREPORT = 96,  #define RTM_NEWCACHEREPORT RTM_NEWCACHEREPORT @@ -172,12 +182,26 @@ enum {  #define RTM_GETLINKPROP	RTM_GETLINKPROP  	RTM_NEWVLAN = 112, -#define RTM_NEWNVLAN	RTM_NEWVLAN +#define RTM_NEWVLAN	RTM_NEWVLAN  	RTM_DELVLAN,  #define RTM_DELVLAN	RTM_DELVLAN  	RTM_GETVLAN,  #define RTM_GETVLAN	RTM_GETVLAN +	RTM_NEWNEXTHOPBUCKET = 116, +#define RTM_NEWNEXTHOPBUCKET	RTM_NEWNEXTHOPBUCKET +	RTM_DELNEXTHOPBUCKET, +#define RTM_DELNEXTHOPBUCKET	RTM_DELNEXTHOPBUCKET +	RTM_GETNEXTHOPBUCKET, +#define RTM_GETNEXTHOPBUCKET	RTM_GETNEXTHOPBUCKET + +	RTM_NEWTUNNEL = 120, +#define RTM_NEWTUNNEL	RTM_NEWTUNNEL +	RTM_DELTUNNEL, +#define RTM_DELTUNNEL	RTM_DELTUNNEL +	RTM_GETTUNNEL, +#define RTM_GETTUNNEL	RTM_GETTUNNEL +  	__RTM_MAX,  #define RTM_MAX		(((__RTM_MAX + 3) & ~3) - 1)  }; @@ -283,6 +307,8 @@ enum {  #define RTPROT_MROUTED		17	/* Multicast daemon */  #define RTPROT_KEEPALIVED	18	/* Keepalived daemon */  #define RTPROT_BABEL		42	/* Babel daemon */ +#define RTPROT_OVN		84	/* OVN daemon */ +#define RTPROT_OPENR		99	/* Open Routing (Open/R) Routes */  #define RTPROT_BGP		186	/* BGP Routes */  #define RTPROT_ISIS		187	/* ISIS Routes */  #define RTPROT_OSPF		188	/* OSPF Routes */ @@ -319,6 +345,11 @@ enum rt_scope_t {  #define RTM_F_FIB_MATCH	        0x2000	/* return full fib lookup match */  #define RTM_F_OFFLOAD		0x4000	/* route is offloaded */  #define RTM_F_TRAP		0x8000	/* route is trapping packets */ +#define RTM_F_OFFLOAD_FAILED	0x20000000 /* route offload failed, this value +					    * is chosen to avoid conflicts with +					    * other flags defined in +					    * include/uapi/linux/ipv6_route.h +					    */  /* Reserved table identifiers */ @@ -367,6 +398,7 @@ enum rtattr_type_t {  	RTA_SPORT,  	RTA_DPORT,  	RTA_NH_ID, +	RTA_FLOWLABEL,  	__RTA_MAX  }; @@ -396,11 +428,13 @@ struct rtnexthop {  #define RTNH_F_DEAD		1	/* Nexthop is dead (used by multipath)	*/  #define RTNH_F_PERVASIVE	2	/* Do recursive gateway lookup	*/  #define RTNH_F_ONLINK		4	/* Gateway is forced on link	*/ -#define RTNH_F_OFFLOAD		8	/* offloaded route */ +#define RTNH_F_OFFLOAD		8	/* Nexthop is offloaded */  #define RTNH_F_LINKDOWN		16	/* carrier-down on nexthop */  #define RTNH_F_UNRESOLVED	32	/* The entry is unresolved (ipmr) */ +#define RTNH_F_TRAP		64	/* Nexthop is trapping packets */ -#define RTNH_COMPARE_MASK	(RTNH_F_DEAD | RTNH_F_LINKDOWN | RTNH_F_OFFLOAD) +#define RTNH_COMPARE_MASK	(RTNH_F_DEAD | RTNH_F_LINKDOWN | \ +				 RTNH_F_OFFLOAD | RTNH_F_TRAP)  /* Macros to handle hexthops */ @@ -416,7 +450,7 @@ struct rtnexthop {  /* RTA_VIA */  struct rtvia {  	__kernel_sa_family_t	rtvia_family; -	__u8			rtvia_addr[0]; +	__u8			rtvia_addr[];  };  /* RTM_CACHEINFO */ @@ -478,13 +512,17 @@ enum {  #define RTAX_MAX (__RTAX_MAX - 1) -#define RTAX_FEATURE_ECN	(1 << 0) -#define RTAX_FEATURE_SACK	(1 << 1) -#define RTAX_FEATURE_TIMESTAMP	(1 << 2) -#define RTAX_FEATURE_ALLFRAG	(1 << 3) +#define RTAX_FEATURE_ECN		(1 << 0) +#define RTAX_FEATURE_SACK		(1 << 1) /* unused */ +#define RTAX_FEATURE_TIMESTAMP		(1 << 2) /* unused */ +#define RTAX_FEATURE_ALLFRAG		(1 << 3) /* unused */ +#define RTAX_FEATURE_TCP_USEC_TS	(1 << 4) -#define RTAX_FEATURE_MASK	(RTAX_FEATURE_ECN | RTAX_FEATURE_SACK | \ -				 RTAX_FEATURE_TIMESTAMP | RTAX_FEATURE_ALLFRAG) +#define RTAX_FEATURE_MASK	(RTAX_FEATURE_ECN |		\ +				 RTAX_FEATURE_SACK |		\ +				 RTAX_FEATURE_TIMESTAMP |	\ +				 RTAX_FEATURE_ALLFRAG |		\ +				 RTAX_FEATURE_TCP_USEC_TS)  struct rta_session {  	__u8	proto; @@ -611,6 +649,7 @@ enum {  	TCA_INGRESS_BLOCK,  	TCA_EGRESS_BLOCK,  	TCA_DUMP_FLAGS, +	TCA_EXT_WARN_MSG,  	__TCA_MAX  }; @@ -739,6 +778,18 @@ enum rtnetlink_groups {  #define RTNLGRP_NEXTHOP		RTNLGRP_NEXTHOP  	RTNLGRP_BRVLAN,  #define RTNLGRP_BRVLAN		RTNLGRP_BRVLAN +	RTNLGRP_MCTP_IFADDR, +#define RTNLGRP_MCTP_IFADDR	RTNLGRP_MCTP_IFADDR +	RTNLGRP_TUNNEL, +#define RTNLGRP_TUNNEL		RTNLGRP_TUNNEL +	RTNLGRP_STATS, +#define RTNLGRP_STATS		RTNLGRP_STATS +	RTNLGRP_IPV4_MCADDR, +#define RTNLGRP_IPV4_MCADDR	RTNLGRP_IPV4_MCADDR +	RTNLGRP_IPV6_MCADDR, +#define RTNLGRP_IPV6_MCADDR	RTNLGRP_IPV6_MCADDR +	RTNLGRP_IPV6_ACADDR, +#define RTNLGRP_IPV6_ACADDR	RTNLGRP_IPV6_ACADDR  	__RTNLGRP_MAX  };  #define RTNLGRP_MAX	(__RTNLGRP_MAX - 1) @@ -758,6 +809,7 @@ enum {  	TCA_ROOT_FLAGS,  	TCA_ROOT_COUNT,  	TCA_ROOT_TIME_DELTA, /* in msecs */ +	TCA_ROOT_EXT_WARN_MSG,  	__TCA_ROOT_MAX,  #define	TCA_ROOT_MAX (__TCA_ROOT_MAX - 1)  }; @@ -766,12 +818,18 @@ enum {  #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))  /* tcamsg flags stored in attribute TCA_ROOT_FLAGS   * - * TCA_FLAG_LARGE_DUMP_ON user->kernel to request for larger than TCA_ACT_MAX_PRIO - * actions in a dump. All dump responses will contain the number of actions - * being dumped stored in for user app's consumption in TCA_ROOT_COUNT + * TCA_ACT_FLAG_LARGE_DUMP_ON user->kernel to request for larger than + * TCA_ACT_MAX_PRIO actions in a dump. All dump responses will contain the + * number of actions being dumped stored in for user app's consumption in + * TCA_ROOT_COUNT + * + * TCA_ACT_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only + * includes essential action info (kind, index, etc.)   *   */  #define TCA_FLAG_LARGE_DUMP_ON		(1 << 0) +#define TCA_ACT_FLAG_LARGE_DUMP_ON	TCA_FLAG_LARGE_DUMP_ON +#define TCA_ACT_FLAG_TERSE_DUMP		(1 << 1)  /* New extended info filters for IFLA_EXT_MASK */  #define RTEXT_FILTER_VF		(1 << 0) @@ -779,6 +837,9 @@ enum {  #define RTEXT_FILTER_BRVLAN_COMPRESSED	(1 << 2)  #define	RTEXT_FILTER_SKIP_STATS	(1 << 3)  #define RTEXT_FILTER_MRP	(1 << 4) +#define RTEXT_FILTER_CFM_CONFIG	(1 << 5) +#define RTEXT_FILTER_CFM_STATUS	(1 << 6) +#define RTEXT_FILTER_MST	(1 << 7)  /* End of information exported to user level */ diff --git a/include/uapi/linux/rxrpc.h b/include/uapi/linux/rxrpc.h index 4accfa7e266d..d9735abd4c79 100644 --- a/include/uapi/linux/rxrpc.h +++ b/include/uapi/linux/rxrpc.h @@ -36,26 +36,33 @@ struct sockaddr_rxrpc {  #define RXRPC_MIN_SECURITY_LEVEL	4	/* minimum security level */  #define RXRPC_UPGRADEABLE_SERVICE	5	/* Upgrade service[0] -> service[1] */  #define RXRPC_SUPPORTED_CMSG		6	/* Get highest supported control message type */ +#define RXRPC_MANAGE_RESPONSE		7	/* [clnt] Want to manage RESPONSE packets */  /*   * RxRPC control messages   * - If neither abort or accept are specified, the message is a data message.   * - terminal messages mean that a user call ID tag can be recycled + * - C/S/- indicate whether these are applicable to client, server or both   * - s/r/- indicate whether these are applicable to sendmsg() and/or recvmsg()   */  enum rxrpc_cmsg_type { -	RXRPC_USER_CALL_ID	= 1,	/* sr: user call ID specifier */ -	RXRPC_ABORT		= 2,	/* sr: abort request / notification [terminal] */ -	RXRPC_ACK		= 3,	/* -r: [Service] RPC op final ACK received [terminal] */ -	RXRPC_NET_ERROR		= 5,	/* -r: network error received [terminal] */ -	RXRPC_BUSY		= 6,	/* -r: server busy received [terminal] */ -	RXRPC_LOCAL_ERROR	= 7,	/* -r: local error generated [terminal] */ -	RXRPC_NEW_CALL		= 8,	/* -r: [Service] new incoming call notification */ -	RXRPC_ACCEPT		= 9,	/* s-: [Service] accept request */ -	RXRPC_EXCLUSIVE_CALL	= 10,	/* s-: Call should be on exclusive connection */ -	RXRPC_UPGRADE_SERVICE	= 11,	/* s-: Request service upgrade for client call */ -	RXRPC_TX_LENGTH		= 12,	/* s-: Total length of Tx data */ -	RXRPC_SET_CALL_TIMEOUT	= 13,	/* s-: Set one or more call timeouts */ +	RXRPC_USER_CALL_ID	= 1,	/* -sr: User call ID specifier */ +	RXRPC_ABORT		= 2,	/* -sr: Abort request / notification [terminal] */ +	RXRPC_ACK		= 3,	/* S-r: RPC op final ACK received [terminal] */ +	RXRPC_NET_ERROR		= 5,	/* --r: Network error received [terminal] */ +	RXRPC_BUSY		= 6,	/* C-r: Server busy received [terminal] */ +	RXRPC_LOCAL_ERROR	= 7,	/* --r: Local error generated [terminal] */ +	RXRPC_NEW_CALL		= 8,	/* S-r: New incoming call notification */ +	RXRPC_EXCLUSIVE_CALL	= 10,	/* Cs-: Call should be on exclusive connection */ +	RXRPC_UPGRADE_SERVICE	= 11,	/* Cs-: Request service upgrade for client call */ +	RXRPC_TX_LENGTH		= 12,	/* -s-: Total length of Tx data */ +	RXRPC_SET_CALL_TIMEOUT	= 13,	/* -s-: Set one or more call timeouts */ +	RXRPC_CHARGE_ACCEPT	= 14,	/* Ss-: Charge the accept pool with a user call ID */ +	RXRPC_OOB_ID		= 15,	/* -sr: OOB message ID */ +	RXRPC_CHALLENGED	= 16,	/* C-r: Info on a received CHALLENGE */ +	RXRPC_RESPOND		= 17,	/* Cs-: Respond to a challenge */ +	RXRPC_RESPONDED		= 18,	/* S-r: Data received in RESPONSE */ +	RXRPC_RESP_RXGK_APPDATA	= 19,	/* Cs-: RESPONSE: RxGK app data to include */  	RXRPC__SUPPORTED  }; @@ -73,6 +80,7 @@ enum rxrpc_cmsg_type {  #define RXRPC_SECURITY_RXKAD	2	/* kaserver or kerberos 4 */  #define RXRPC_SECURITY_RXGK	4	/* gssapi-based */  #define RXRPC_SECURITY_RXK5	5	/* kerberos 5 */ +#define RXRPC_SECURITY_YFS_RXGK	6	/* YFS gssapi-based */  /*   * RxRPC-level abort codes @@ -118,4 +126,49 @@ enum rxrpc_cmsg_type {  #define RXKADDATALEN		19270411	/* user data too long */  #define RXKADILLEGALLEVEL	19270412	/* caller not authorised to use encrypted conns */ +/* + * RxGK GSSAPI security abort codes. + */ +#if 0 /* Original standard abort codes (used by OpenAFS) */ +#define RXGK_INCONSISTENCY	1233242880	/* Security module structure inconsistent */ +#define RXGK_PACKETSHORT	1233242881	/* Packet too short for security challenge */ +#define RXGK_BADCHALLENGE	1233242882	/* Invalid security challenge */ +#define RXGK_BADETYPE		1233242883	/* Invalid or impermissible encryption type */ +#define RXGK_BADLEVEL		1233242884	/* Invalid or impermissible security level */ +#define RXGK_BADKEYNO		1233242885	/* Key version number not found */ +#define RXGK_EXPIRED		1233242886	/* Token has expired */ +#define RXGK_NOTAUTH		1233242887	/* Caller not authorized */ +#define RXGK_BAD_TOKEN		1233242888	/* Security object was passed a bad token */ +#define RXGK_SEALED_INCON	1233242889	/* Sealed data inconsistent */ +#define RXGK_DATA_LEN		1233242890	/* User data too long */ +#define RXGK_BAD_QOP		1233242891	/* Inadequate quality of protection available */ +#else /* Revised standard abort codes (used by YFS) */ +#define RXGK_INCONSISTENCY	1233242880	/* Security module structure inconsistent */ +#define RXGK_PACKETSHORT	1233242881	/* Packet too short for security challenge */ +#define RXGK_BADCHALLENGE	1233242882	/* Security challenge/response failed */ +#define RXGK_SEALEDINCON	1233242883	/* Sealed data is inconsistent */ +#define RXGK_NOTAUTH		1233242884	/* Caller not authorised */ +#define RXGK_EXPIRED		1233242885	/* Authentication expired */ +#define RXGK_BADLEVEL		1233242886	/* Unsupported or not permitted security level */ +#define RXGK_BADKEYNO		1233242887	/* Bad transport key number */ +#define RXGK_NOTRXGK		1233242888	/* Security layer is not rxgk */ +#define RXGK_UNSUPPORTED	1233242889	/* Endpoint does not support rxgk */ +#define RXGK_GSSERROR		1233242890	/* GSSAPI mechanism error */ +#endif + +/* + * Challenge information in the RXRPC_CHALLENGED control message. + */ +struct rxrpc_challenge { +	__u16		service_id;	/* The service ID of the connection (may be upgraded) */ +	__u8		security_index;	/* The security index of the connection */ +	__u8		pad;		/* Round out to a multiple of 4 bytes. */ +	/* ... The security class gets to append extra information ... */ +}; + +struct rxgk_challenge { +	struct rxrpc_challenge	base; +	__u32			enctype;	/* Krb5 encoding type */ +}; +  #endif /* _UAPI_LINUX_RXRPC_H */ diff --git a/include/uapi/linux/sched.h b/include/uapi/linux/sched.h index 3bac0a8ceab2..359a14cc76a4 100644 --- a/include/uapi/linux/sched.h +++ b/include/uapi/linux/sched.h @@ -118,6 +118,7 @@ struct clone_args {  /* SCHED_ISO: reserved but not implemented yet */  #define SCHED_IDLE		5  #define SCHED_DEADLINE		6 +#define SCHED_EXT		7  /* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */  #define SCHED_RESET_ON_FORK     0x40000000 diff --git a/include/uapi/linux/sched/types.h b/include/uapi/linux/sched/types.h index c852153ddb0d..bf6e9ae031c1 100644 --- a/include/uapi/linux/sched/types.h +++ b/include/uapi/linux/sched/types.h @@ -4,10 +4,6 @@  #include <linux/types.h> -struct sched_param { -	int sched_priority; -}; -  #define SCHED_ATTR_SIZE_VER0	48	/* sizeof first published struct */  #define SCHED_ATTR_SIZE_VER1	56	/* add: util_{min,max} */ @@ -62,9 +58,9 @@ struct sched_param {   *   * This is reflected by the following fields of the sched_attr structure:   * - *  @sched_deadline	representative of the task's deadline - *  @sched_runtime	representative of the task's runtime - *  @sched_period	representative of the task's period + *  @sched_deadline	representative of the task's deadline in nanoseconds + *  @sched_runtime	representative of the task's runtime in nanoseconds + *  @sched_period	representative of the task's period in nanoseconds   *   * Given this task model, there are a multiplicity of scheduling algorithms   * and policies, that can be used to ensure all the tasks will make their @@ -96,6 +92,8 @@ struct sched_param {   * on a CPU with a capacity big enough to fit the specified value.   * A task with a max utilization value smaller than 1024 is more likely   * scheduled on a CPU with no more capacity than the specified value. + * + * A task utilization boundary can be reset by setting the attribute to -1.   */  struct sched_attr {  	__u32 size; diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h index 28ad40d9acba..b7d91d4cf0db 100644 --- a/include/uapi/linux/sctp.h +++ b/include/uapi/linux/sctp.h @@ -140,6 +140,8 @@ typedef __s32 sctp_assoc_t;  #define SCTP_ECN_SUPPORTED	130  #define SCTP_EXPOSE_POTENTIALLY_FAILED_STATE	131  #define SCTP_EXPOSE_PF_STATE	SCTP_EXPOSE_POTENTIALLY_FAILED_STATE +#define SCTP_REMOTE_UDP_ENCAPS_PORT	132 +#define SCTP_PLPMTUD_PROBE_INTERVAL	133  /* PR-SCTP policies */  #define SCTP_PR_SCTP_NONE	0x0000 @@ -363,7 +365,7 @@ struct sctp_assoc_change {  	__u16 sac_outbound_streams;  	__u16 sac_inbound_streams;  	sctp_assoc_t sac_assoc_id; -	__u8 sac_info[0]; +	__u8 sac_info[];  };  /* @@ -434,7 +436,7 @@ struct sctp_remote_error {  	__u32 sre_length;  	__be16 sre_error;  	sctp_assoc_t sre_assoc_id; -	__u8 sre_data[0]; +	__u8 sre_data[];  }; @@ -451,7 +453,7 @@ struct sctp_send_failed {  	__u32 ssf_error;  	struct sctp_sndrcvinfo ssf_info;  	sctp_assoc_t ssf_assoc_id; -	__u8 ssf_data[0]; +	__u8 ssf_data[];  };  struct sctp_send_failed_event { @@ -461,7 +463,7 @@ struct sctp_send_failed_event {  	__u32 ssf_error;  	struct sctp_sndinfo ssfe_info;  	sctp_assoc_t ssf_assoc_id; -	__u8 ssf_data[0]; +	__u8 ssf_data[];  };  /* @@ -1027,7 +1029,7 @@ struct sctp_getaddrs_old {  struct sctp_getaddrs {  	sctp_assoc_t		assoc_id; /*input*/  	__u32			addr_num; /*output*/ -	__u8			addrs[0]; /*output, variable size*/ +	__u8			addrs[]; /*output, variable size*/  };  /* A socket user request obtained via SCTP_GET_ASSOC_STATS that retrieves @@ -1197,13 +1199,28 @@ struct sctp_event {  	uint8_t se_on;  }; +struct sctp_udpencaps { +	sctp_assoc_t sue_assoc_id; +	struct sockaddr_storage sue_address; +	uint16_t sue_port; +}; +  /* SCTP Stream schedulers */  enum sctp_sched_type {  	SCTP_SS_FCFS,  	SCTP_SS_DEFAULT = SCTP_SS_FCFS,  	SCTP_SS_PRIO,  	SCTP_SS_RR, -	SCTP_SS_MAX = SCTP_SS_RR +	SCTP_SS_FC, +	SCTP_SS_WFQ, +	SCTP_SS_MAX = SCTP_SS_WFQ +}; + +/* Probe Interval socket option */ +struct sctp_probeinterval { +	sctp_assoc_t spi_assoc_id; +	struct sockaddr_storage spi_address; +	__u32 spi_interval;  };  #endif /* _UAPI_SCTP_H */ diff --git a/include/uapi/linux/sdla.h b/include/uapi/linux/sdla.h deleted file mode 100644 index 1e3735be6511..000000000000 --- a/include/uapi/linux/sdla.h +++ /dev/null @@ -1,117 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ -/* - * INET		An implementation of the TCP/IP protocol suite for the LINUX - *		operating system.  INET is implemented using the  BSD Socket - *		interface as the means of communication with the user level. - * - *		Global definitions for the Frame relay interface. - * - * Version:	@(#)if_ifrad.h	0.20	13 Apr 96 - * - * Author:	Mike McLagan <mike.mclagan@linux.org> - * - * Changes: - *		0.15	Mike McLagan	Structure packing - * - *		0.20	Mike McLagan	New flags for S508 buffer handling - * - *		This program is free software; you can redistribute it and/or - *		modify it under the terms of the GNU General Public License - *		as published by the Free Software Foundation; either version - *		2 of the License, or (at your option) any later version. - */ - -#ifndef _UAPISDLA_H -#define _UAPISDLA_H - -/* adapter type */ -#define SDLA_TYPES -#define SDLA_S502A			5020 -#define SDLA_S502E			5021 -#define SDLA_S503			5030 -#define SDLA_S507			5070 -#define SDLA_S508			5080 -#define SDLA_S509			5090 -#define SDLA_UNKNOWN			-1 - -/* port selection flags for the S508 */ -#define SDLA_S508_PORT_V35		0x00 -#define SDLA_S508_PORT_RS232		0x02 - -/* Z80 CPU speeds */ -#define SDLA_CPU_3M			0x00 -#define SDLA_CPU_5M			0x01 -#define SDLA_CPU_7M			0x02 -#define SDLA_CPU_8M			0x03 -#define SDLA_CPU_10M			0x04 -#define SDLA_CPU_16M			0x05 -#define SDLA_CPU_12M			0x06 - -/* some private IOCTLs */ -#define SDLA_IDENTIFY			(FRAD_LAST_IOCTL + 1) -#define SDLA_CPUSPEED			(FRAD_LAST_IOCTL + 2) -#define SDLA_PROTOCOL			(FRAD_LAST_IOCTL + 3) - -#define SDLA_CLEARMEM			(FRAD_LAST_IOCTL + 4) -#define SDLA_WRITEMEM			(FRAD_LAST_IOCTL + 5) -#define SDLA_READMEM			(FRAD_LAST_IOCTL + 6) - -struct sdla_mem { -   int  addr; -   int  len; -   void __user *data; -}; - -#define SDLA_START			(FRAD_LAST_IOCTL + 7) -#define SDLA_STOP			(FRAD_LAST_IOCTL + 8) - -/* some offsets in the Z80's memory space */ -#define SDLA_NMIADDR			0x0000 -#define SDLA_CONF_ADDR			0x0010 -#define SDLA_S502A_NMIADDR		0x0066 -#define SDLA_CODE_BASEADDR		0x0100 -#define SDLA_WINDOW_SIZE		0x2000 -#define SDLA_ADDR_MASK			0x1FFF - -/* largest handleable block of data */ -#define SDLA_MAX_DATA			4080 -#define SDLA_MAX_MTU			4072	/* MAX_DATA - sizeof(fradhdr) */ -#define SDLA_MAX_DLCI			24 - -/* this should be the same as frad_conf */ -struct sdla_conf { -   short station; -   short config; -   short kbaud; -   short clocking; -   short max_frm; -   short T391; -   short T392; -   short N391; -   short N392; -   short N393; -   short CIR_fwd; -   short Bc_fwd; -   short Be_fwd; -   short CIR_bwd; -   short Bc_bwd; -   short Be_bwd; -}; - -/* this should be the same as dlci_conf */ -struct sdla_dlci_conf { -   short config; -   short CIR_fwd; -   short Bc_fwd; -   short Be_fwd; -   short CIR_bwd; -   short Bc_bwd; -   short Be_bwd;  -   short Tc_fwd; -   short Tc_bwd; -   short Tf_max; -   short Tb_max; -}; - - -#endif /* _UAPISDLA_H */ diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h index 6ba18b82a02e..dbfc9b37fcae 100644 --- a/include/uapi/linux/seccomp.h +++ b/include/uapi/linux/seccomp.h @@ -23,6 +23,8 @@  #define SECCOMP_FILTER_FLAG_SPEC_ALLOW		(1UL << 2)  #define SECCOMP_FILTER_FLAG_NEW_LISTENER	(1UL << 3)  #define SECCOMP_FILTER_FLAG_TSYNC_ESRCH		(1UL << 4) +/* Received notifications wait in killable state (only respond to fatal signals) */ +#define SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV	(1UL << 5)  /*   * All BPF programs must return a 32-bit value. @@ -113,8 +115,11 @@ struct seccomp_notif_resp {  	__u32 flags;  }; +#define SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP (1UL << 0) +  /* valid flags for seccomp_notif_addfd */  #define SECCOMP_ADDFD_FLAG_SETFD	(1UL << 0) /* Specify remote fd */ +#define SECCOMP_ADDFD_FLAG_SEND		(1UL << 1) /* Addfd and return it, atomically */  /**   * struct seccomp_notif_addfd @@ -147,4 +152,6 @@ struct seccomp_notif_addfd {  #define SECCOMP_IOCTL_NOTIF_ADDFD	SECCOMP_IOW(3, \  						struct seccomp_notif_addfd) +#define SECCOMP_IOCTL_NOTIF_SET_FLAGS	SECCOMP_IOW(4, __u64) +  #endif /* _UAPI_LINUX_SECCOMP_H */ diff --git a/include/uapi/linux/securebits.h b/include/uapi/linux/securebits.h index d6d98877ff1a..3fba30dbd68b 100644 --- a/include/uapi/linux/securebits.h +++ b/include/uapi/linux/securebits.h @@ -52,10 +52,32 @@  #define SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED \  			(issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED)) +/* See Documentation/userspace-api/check_exec.rst */ +#define SECURE_EXEC_RESTRICT_FILE		8 +#define SECURE_EXEC_RESTRICT_FILE_LOCKED	9  /* make bit-8 immutable */ + +#define SECBIT_EXEC_RESTRICT_FILE (issecure_mask(SECURE_EXEC_RESTRICT_FILE)) +#define SECBIT_EXEC_RESTRICT_FILE_LOCKED \ +			(issecure_mask(SECURE_EXEC_RESTRICT_FILE_LOCKED)) + +/* See Documentation/userspace-api/check_exec.rst */ +#define SECURE_EXEC_DENY_INTERACTIVE		10 +#define SECURE_EXEC_DENY_INTERACTIVE_LOCKED	11  /* make bit-10 immutable */ + +#define SECBIT_EXEC_DENY_INTERACTIVE \ +			(issecure_mask(SECURE_EXEC_DENY_INTERACTIVE)) +#define SECBIT_EXEC_DENY_INTERACTIVE_LOCKED \ +			(issecure_mask(SECURE_EXEC_DENY_INTERACTIVE_LOCKED)) +  #define SECURE_ALL_BITS		(issecure_mask(SECURE_NOROOT) | \  				 issecure_mask(SECURE_NO_SETUID_FIXUP) | \  				 issecure_mask(SECURE_KEEP_CAPS) | \ -				 issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE)) +				 issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE) | \ +				 issecure_mask(SECURE_EXEC_RESTRICT_FILE) | \ +				 issecure_mask(SECURE_EXEC_DENY_INTERACTIVE))  #define SECURE_ALL_LOCKS	(SECURE_ALL_BITS << 1) +#define SECURE_ALL_UNPRIVILEGED (issecure_mask(SECURE_EXEC_RESTRICT_FILE) | \ +				 issecure_mask(SECURE_EXEC_DENY_INTERACTIVE)) +  #endif /* _UAPI_LINUX_SECUREBITS_H */ diff --git a/include/uapi/linux/sed-opal.h b/include/uapi/linux/sed-opal.h index 6f5af1a84213..9025dd5a4f0f 100644 --- a/include/uapi/linux/sed-opal.h +++ b/include/uapi/linux/sed-opal.h @@ -44,13 +44,28 @@ enum opal_lock_state {  	OPAL_LK = 0x04, /* 0100 */  }; +enum opal_lock_flags { +	/* IOC_OPAL_SAVE will also store the provided key for locking */ +	OPAL_SAVE_FOR_LOCK = 0x01, +}; + +enum opal_key_type { +	OPAL_INCLUDED = 0,	/* key[] is the key */ +	OPAL_KEYRING,		/* key is in keyring */ +}; +  struct opal_key {  	__u8 lr;  	__u8 key_len; -	__u8 __align[6]; +	__u8 key_type; +	__u8 __align[5];  	__u8 key[OPAL_KEY_MAX];  }; +enum opal_revert_lsp_opts { +	OPAL_PRESERVE = 0x01, +}; +  struct opal_lr_act {  	struct opal_key key;  	__u32 sum; @@ -73,10 +88,21 @@ struct opal_user_lr_setup {  	struct opal_session_info session;  }; +struct opal_lr_status { +	struct opal_session_info session; +	__u64 range_start; +	__u64 range_length; +	__u32 RLE; /* Read Lock enabled */ +	__u32 WLE; /* Write Lock Enabled */ +	__u32 l_state; +	__u8  align[4]; +}; +  struct opal_lock_unlock {  	struct opal_session_info session;  	__u32 l_state; -	__u8 __align[4]; +	__u16 flags; +	__u8 __align[2];  };  struct opal_new_pw { @@ -132,6 +158,42 @@ struct opal_read_write_table {  	__u64 priv;  }; +#define OPAL_FL_SUPPORTED		0x00000001 +#define OPAL_FL_LOCKING_SUPPORTED	0x00000002 +#define OPAL_FL_LOCKING_ENABLED		0x00000004 +#define OPAL_FL_LOCKED			0x00000008 +#define OPAL_FL_MBR_ENABLED		0x00000010 +#define OPAL_FL_MBR_DONE		0x00000020 +#define OPAL_FL_SUM_SUPPORTED		0x00000040 + +struct opal_status { +	__u32 flags; +	__u32 reserved; +}; + +/* + * Geometry Reporting per TCG Storage OPAL SSC + * section 3.1.1.4 + */ +struct opal_geometry { +	__u8 align; +	__u32 logical_block_size; +	__u64 alignment_granularity; +	__u64 lowest_aligned_lba; +	__u8  __align[3]; +}; + +struct opal_discovery { +	__u64 data; +	__u64 size; +}; + +struct opal_revert_lsp { +	struct opal_key key; +	__u32 options; +	__u32 __pad; +}; +  #define IOC_OPAL_SAVE		    _IOW('p', 220, struct opal_lock_unlock)  #define IOC_OPAL_LOCK_UNLOCK	    _IOW('p', 221, struct opal_lock_unlock)  #define IOC_OPAL_TAKE_OWNERSHIP	    _IOW('p', 222, struct opal_key) @@ -148,5 +210,11 @@ struct opal_read_write_table {  #define IOC_OPAL_MBR_DONE           _IOW('p', 233, struct opal_mbr_done)  #define IOC_OPAL_WRITE_SHADOW_MBR   _IOW('p', 234, struct opal_shadow_mbr)  #define IOC_OPAL_GENERIC_TABLE_RW   _IOW('p', 235, struct opal_read_write_table) +#define IOC_OPAL_GET_STATUS         _IOR('p', 236, struct opal_status) +#define IOC_OPAL_GET_LR_STATUS      _IOW('p', 237, struct opal_lr_status) +#define IOC_OPAL_GET_GEOMETRY       _IOR('p', 238, struct opal_geometry) +#define IOC_OPAL_DISCOVERY          _IOW('p', 239, struct opal_discovery) +#define IOC_OPAL_REVERT_LSP         _IOW('p', 240, struct opal_revert_lsp) +#define IOC_OPAL_SET_SID_PW         _IOW('p', 241, struct opal_new_pw)  #endif /* _UAPI_SED_OPAL_H */ diff --git a/include/uapi/linux/seg6.h b/include/uapi/linux/seg6.h index 286e8d6a8e98..13bcbc8bba32 100644 --- a/include/uapi/linux/seg6.h +++ b/include/uapi/linux/seg6.h @@ -30,7 +30,7 @@ struct ipv6_sr_hdr {  	__u8	flags;  	__u16	tag; -	struct in6_addr segments[0]; +	struct in6_addr segments[];  };  #define SR6_FLAG1_PROTECTED	(1 << 6) diff --git a/include/uapi/linux/seg6_iptunnel.h b/include/uapi/linux/seg6_iptunnel.h index eb815e0d0ac3..ae78791372b8 100644 --- a/include/uapi/linux/seg6_iptunnel.h +++ b/include/uapi/linux/seg6_iptunnel.h @@ -26,7 +26,7 @@ enum {  struct seg6_iptunnel_encap {  	int mode; -	struct ipv6_sr_hdr srh[0]; +	struct ipv6_sr_hdr srh[];  };  #define SEG6_IPTUN_ENCAP_SIZE(x) ((sizeof(*x)) + (((x)->srh->hdrlen + 1) << 3)) @@ -35,6 +35,8 @@ enum {  	SEG6_IPTUN_MODE_INLINE,  	SEG6_IPTUN_MODE_ENCAP,  	SEG6_IPTUN_MODE_L2ENCAP, +	SEG6_IPTUN_MODE_ENCAP_RED, +	SEG6_IPTUN_MODE_L2ENCAP_RED,  };  #endif diff --git a/include/uapi/linux/seg6_local.h b/include/uapi/linux/seg6_local.h index edc138bdc56d..4fdc424c9cb3 100644 --- a/include/uapi/linux/seg6_local.h +++ b/include/uapi/linux/seg6_local.h @@ -26,6 +26,9 @@ enum {  	SEG6_LOCAL_IIF,  	SEG6_LOCAL_OIF,  	SEG6_LOCAL_BPF, +	SEG6_LOCAL_VRFTABLE, +	SEG6_LOCAL_COUNTERS, +	SEG6_LOCAL_FLAVORS,  	__SEG6_LOCAL_MAX,  };  #define SEG6_LOCAL_MAX (__SEG6_LOCAL_MAX - 1) @@ -62,6 +65,8 @@ enum {  	SEG6_LOCAL_ACTION_END_AM	= 14,  	/* custom BPF action */  	SEG6_LOCAL_ACTION_END_BPF	= 15, +	/* decap and lookup of DA in v4 or v6 table */ +	SEG6_LOCAL_ACTION_END_DT46	= 16,  	__SEG6_LOCAL_ACTION_MAX,  }; @@ -77,4 +82,56 @@ enum {  #define SEG6_LOCAL_BPF_PROG_MAX (__SEG6_LOCAL_BPF_PROG_MAX - 1) +/* SRv6 Behavior counters are encoded as netlink attributes guaranteeing the + * correct alignment. + * Each counter is identified by a different attribute type (i.e. + * SEG6_LOCAL_CNT_PACKETS). + * + * - SEG6_LOCAL_CNT_PACKETS: identifies a counter that counts the number of + *   packets that have been CORRECTLY processed by an SRv6 Behavior instance + *   (i.e., packets that generate errors or are dropped are NOT counted). + * + * - SEG6_LOCAL_CNT_BYTES: identifies a counter that counts the total amount + *   of traffic in bytes of all packets that have been CORRECTLY processed by + *   an SRv6 Behavior instance (i.e., packets that generate errors or are + *   dropped are NOT counted). + * + * - SEG6_LOCAL_CNT_ERRORS: identifies a counter that counts the number of + *   packets that have NOT been properly processed by an SRv6 Behavior instance + *   (i.e., packets that generate errors or are dropped). + */ +enum { +	SEG6_LOCAL_CNT_UNSPEC, +	SEG6_LOCAL_CNT_PAD,		/* pad for 64 bits values */ +	SEG6_LOCAL_CNT_PACKETS, +	SEG6_LOCAL_CNT_BYTES, +	SEG6_LOCAL_CNT_ERRORS, +	__SEG6_LOCAL_CNT_MAX, +}; + +#define SEG6_LOCAL_CNT_MAX (__SEG6_LOCAL_CNT_MAX - 1) + +/* SRv6 End* Flavor attributes */ +enum { +	SEG6_LOCAL_FLV_UNSPEC, +	SEG6_LOCAL_FLV_OPERATION, +	SEG6_LOCAL_FLV_LCBLOCK_BITS, +	SEG6_LOCAL_FLV_LCNODE_FN_BITS, +	__SEG6_LOCAL_FLV_MAX, +}; + +#define SEG6_LOCAL_FLV_MAX (__SEG6_LOCAL_FLV_MAX - 1) + +/* Designed flavor operations for SRv6 End* Behavior */ +enum { +	SEG6_LOCAL_FLV_OP_UNSPEC, +	SEG6_LOCAL_FLV_OP_PSP, +	SEG6_LOCAL_FLV_OP_USP, +	SEG6_LOCAL_FLV_OP_USD, +	SEG6_LOCAL_FLV_OP_NEXT_CSID, +	__SEG6_LOCAL_FLV_OP_MAX +}; + +#define SEG6_LOCAL_FLV_OP_MAX (__SEG6_LOCAL_FLV_OP_MAX - 1) +  #endif diff --git a/include/uapi/linux/serial.h b/include/uapi/linux/serial.h index 93eb3c496ff1..de9b4733607e 100644 --- a/include/uapi/linux/serial.h +++ b/include/uapi/linux/serial.h @@ -11,6 +11,7 @@  #ifndef _UAPI_LINUX_SERIAL_H  #define _UAPI_LINUX_SERIAL_H +#include <linux/const.h>  #include <linux/types.h>  #include <linux/tty_flags.h> @@ -52,11 +53,11 @@ struct serial_struct {  #define PORT_16450	2  #define PORT_16550	3  #define PORT_16550A	4 -#define PORT_CIRRUS     5	/* usurped by cyclades.c */ +#define PORT_CIRRUS     5  #define PORT_16650	6  #define PORT_16650V2	7  #define PORT_16750	8 -#define PORT_STARTECH	9	/* usurped by cyclades.c */ +#define PORT_STARTECH	9  #define PORT_16C950	10	/* Oxford Semiconductor */  #define PORT_16654	11  #define PORT_16850	12 @@ -107,29 +108,65 @@ struct serial_icounter_struct {  	int reserved[9];  }; -/* +/** + * struct serial_rs485 - serial interface for controlling RS485 settings. + * @flags:			RS485 feature flags. + * @delay_rts_before_send:	Delay before send (milliseconds). + * @delay_rts_after_send:	Delay after send (milliseconds). + * @addr_recv:			Receive filter for RS485 addressing mode + *				(used only when %SER_RS485_ADDR_RECV is set). + * @addr_dest:			Destination address for RS485 addressing mode + *				(used only when %SER_RS485_ADDR_DEST is set). + * @padding0:			Padding (set to zero). + * @padding1:			Padding (set to zero). + * @padding:			Deprecated, use @padding0 and @padding1 instead. + *				Do not use with @addr_recv and @addr_dest (due to + *				overlap). + *   * Serial interface for controlling RS485 settings on chips with suitable   * support. Set with TIOCSRS485 and get with TIOCGRS485 if supported by your   * platform. The set function returns the new state, with any unsupported bits   * reverted appropriately. + * + * The flag bits are: + * + * * %SER_RS485_ENABLED		- RS485 enabled. + * * %SER_RS485_RTS_ON_SEND	- Logical level for RTS pin when sending. + * * %SER_RS485_RTS_AFTER_SEND	- Logical level for RTS pin after sent. + * * %SER_RS485_RX_DURING_TX	- Full-duplex RS485 line. + * * %SER_RS485_TERMINATE_BUS	- Enable bus termination (if supported). + * * %SER_RS485_ADDRB		- Enable RS485 addressing mode. + * * %SER_RS485_ADDR_RECV - Receive address filter (enables @addr_recv). Requires %SER_RS485_ADDRB. + * * %SER_RS485_ADDR_DEST - Destination address (enables @addr_dest). Requires %SER_RS485_ADDRB. + * * %SER_RS485_MODE_RS422	- Enable RS422. Requires %SER_RS485_ENABLED.   */ -  struct serial_rs485 { -	__u32	flags;			/* RS485 feature flags */ -#define SER_RS485_ENABLED		(1 << 0)	/* If enabled */ -#define SER_RS485_RTS_ON_SEND		(1 << 1)	/* Logical level for -							   RTS pin when -							   sending */ -#define SER_RS485_RTS_AFTER_SEND	(1 << 2)	/* Logical level for -							   RTS pin after sent*/ -#define SER_RS485_RX_DURING_TX		(1 << 4) -#define SER_RS485_TERMINATE_BUS		(1 << 5)	/* Enable bus -							   termination -							   (if supported) */ -	__u32	delay_rts_before_send;	/* Delay before send (milliseconds) */ -	__u32	delay_rts_after_send;	/* Delay after send (milliseconds) */ -	__u32	padding[5];		/* Memory is cheap, new structs -					   are a royal PITA .. */ +	__u32	flags; +#define SER_RS485_ENABLED		_BITUL(0) +#define SER_RS485_RTS_ON_SEND		_BITUL(1) +#define SER_RS485_RTS_AFTER_SEND	_BITUL(2) +/* Placeholder for bit 3: SER_RS485_RTS_BEFORE_SEND, which isn't used anymore */ +#define SER_RS485_RX_DURING_TX		_BITUL(4) +#define SER_RS485_TERMINATE_BUS		_BITUL(5) +#define SER_RS485_ADDRB			_BITUL(6) +#define SER_RS485_ADDR_RECV		_BITUL(7) +#define SER_RS485_ADDR_DEST		_BITUL(8) +#define SER_RS485_MODE_RS422		_BITUL(9) + +	__u32	delay_rts_before_send; +	__u32	delay_rts_after_send; + +	/* The fields below are defined by flags */ +	union { +		__u32	padding[5];		/* Memory is cheap, new structs are a pain */ + +		struct { +			__u8	addr_recv; +			__u8	addr_dest; +			__u8	padding0[2]; +			__u32	padding1[4]; +		}; +	};  };  /* diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_core.h index 851b982f8c4b..9c007a106330 100644 --- a/include/uapi/linux/serial_core.h +++ b/include/uapi/linux/serial_core.h @@ -1,22 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */  /* - *  linux/drivers/char/serial_core.h - *   *  Copyright (C) 2000 Deep Blue Solutions Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   */  #ifndef _UAPILINUX_SERIAL_CORE_H  #define _UAPILINUX_SERIAL_CORE_H @@ -25,6 +9,10 @@  /*   * The type definitions.  These are from Ted Ts'o's serial.h + * By historical reasons the values from 0 to 13 are defined + * in the include/uapi/linux/serial.h, do not define them here. + * Values 0 to 19 are used by setserial from busybox and must never + * be modified.   */  #define PORT_NS16550A	14  #define PORT_XSCALE	15 @@ -68,6 +56,9 @@  /* NVIDIA Tegra Combined UART */  #define PORT_TEGRA_TCU	41 +/* ASPEED AST2x00 virtual UART */ +#define PORT_ASPEED_VUART	42 +  /* Intel EG20 */  #define PORT_PCH_8LINE	44  #define PORT_PCH_2LINE	45 @@ -91,15 +82,9 @@  #define PORT_SCIF	53  #define PORT_IRDA	54 -/* Samsung S3C2410 SoC and derivatives thereof */ -#define PORT_S3C2410    55 -  /* SGI IP22 aka Indy / Challenge S / Indigo 2 */  #define PORT_IP22ZILOG	56 -/* Sharp LH7a40x -- an ARM9 SoC series */ -#define PORT_LH7A40X	57 -  /* PPC CPM type number */  #define PORT_CPM        58 @@ -109,43 +94,23 @@  /* IBM icom */  #define PORT_ICOM	60 -/* Samsung S3C2440 SoC */ -#define PORT_S3C2440	61 -  /* Motorola i.MX SoC */  #define PORT_IMX	62 -/* Marvell MPSC (obsolete unused) */ -#define PORT_MPSC	63 -  /* TXX9 type number */  #define PORT_TXX9	64 -/* NEC VR4100 series SIU/DSIU */ -#define PORT_VR41XX_SIU		65 -#define PORT_VR41XX_DSIU	66 - -/* Samsung S3C2400 SoC */ -#define PORT_S3C2400	67 - -/* M32R SIO */ -#define PORT_M32R_SIO	68 -  /*Digi jsm */  #define PORT_JSM        69 -#define PORT_PNX8XXX	70 -  /* SUN4V Hypervisor Console */  #define PORT_SUNHV	72 -#define PORT_S3C2412	73 -  /* Xilinx uartlite */  #define PORT_UARTLITE	74 -/* Blackfin bf5xx */ -#define PORT_BFIN	75 +/* Broadcom BCM7271 UART */ +#define PORT_BCM7271	76  /* Broadcom SB1250, etc. SOC */  #define PORT_SB1250_DUART	77 @@ -153,13 +118,6 @@  /* Freescale ColdFire */  #define PORT_MCF	78 -/* Blackfin SPORT */ -#define PORT_BFIN_SPORT		79 - -/* MN10300 on-chip UART numbers */ -#define PORT_MN10300		80 -#define PORT_MN10300_CTS	81 -  #define PORT_SC26XX	82  /* SH-SCI */ @@ -167,9 +125,6 @@  #define PORT_S3C6400	84 -/* NWPSERIAL, now removed */ -#define PORT_NWPSERIAL	85 -  /* MAX3100 */  #define PORT_MAX3100    86 @@ -210,8 +165,8 @@  /* Atheros AR933X SoC */  #define PORT_AR933X	99 -/* Energy Micro efm32 SoC */ -#define PORT_EFMUART   100 +/* MCHP 16550A UART with 256 byte FIFOs */ +#define PORT_MCHP16550A	100  /* ARC (Synopsys) on-chip UART */  #define PORT_ARC       101 @@ -228,13 +183,10 @@  /* ST ASC type numbers */  #define PORT_ASC       105 -/* Tilera TILE-Gx UART */ -#define PORT_TILEGX	106 -  /* MEN 16z135 UART */  #define PORT_MEN_Z135	107 -/* SC16IS74xx */ +/* SC16IS7xx */  #define PORT_SC16IS7XX   108  /* MESON */ @@ -246,9 +198,6 @@  /* SPRD SERIAL  */  #define PORT_SPRD	111 -/* Cris v10 / v32 SoC */ -#define PORT_CRIS	112 -  /* STM32 USART */  #define PORT_STM32	113 @@ -279,4 +228,10 @@  /* Freescale LINFlexD UART */  #define PORT_LINFLEXUART	122 +/* Sunplus UART */ +#define PORT_SUNPLUS	123 + +/* Generic type identifier for ports which type is not important to userspace. */ +#define PORT_GENERIC	(-1) +  #endif /* _UAPILINUX_SERIAL_CORE_H */ diff --git a/include/uapi/linux/serial_reg.h b/include/uapi/linux/serial_reg.h index be07b5470f4b..9c987b04e2d0 100644 --- a/include/uapi/linux/serial_reg.h +++ b/include/uapi/linux/serial_reg.h @@ -44,6 +44,12 @@  #define UART_IIR_RX_TIMEOUT	0x0c /* OMAP RX Timeout interrupt */  #define UART_IIR_XOFF		0x10 /* OMAP XOFF/Special Character */  #define UART_IIR_CTS_RTS_DSR	0x20 /* OMAP CTS/RTS/DSR Change */ +#define UART_IIR_64BYTE_FIFO	0x20 /* 16750 64 bytes FIFO */ +#define UART_IIR_FIFO_ENABLED	0xc0 /* FIFOs enabled / port type identification */ +#define  UART_IIR_FIFO_ENABLED_8250	0x00	/* 8250: no FIFO */ +#define  UART_IIR_FIFO_ENABLED_16550	0x80	/* 16550: (broken/unusable) FIFO */ +#define  UART_IIR_FIFO_ENABLED_16550A	0xc0	/* 16550A: FIFO enabled */ +#define  UART_IIR_FIFO_ENABLED_16750	0xe0	/* 16750: 64 bytes FIFO enabled */  #define UART_FCR	2	/* Out: FIFO Control Register */  #define UART_FCR_ENABLE_FIFO	0x01 /* Enable the FIFO */ @@ -62,6 +68,7 @@   * ST16C654:	 8  16  56  60		 8  16  32  56	PORT_16654   * TI16C750:	 1  16  32  56		xx  xx  xx  xx	PORT_16750   * TI16C752:	 8  16  56  60		 8  16  32  56 + * OX16C950:	16  32 112 120		16  32  64 112	PORT_16C950   * Tegra:	 1   4   8  14		16   8   4   1	PORT_TEGRA   */  #define UART_FCR_R_TRIG_00	0x00 @@ -138,7 +145,7 @@  #define UART_LSR_PE		0x04 /* Parity error indicator */  #define UART_LSR_OE		0x02 /* Overrun error indicator */  #define UART_LSR_DR		0x01 /* Receiver data ready */ -#define UART_LSR_BRK_ERROR_BITS	0x1E /* BI, FE, PE, OE bits */ +#define UART_LSR_BRK_ERROR_BITS	(UART_LSR_BI|UART_LSR_FE|UART_LSR_PE|UART_LSR_OE)  #define UART_MSR	6	/* In:  Modem Status Register */  #define UART_MSR_DCD		0x80 /* Data Carrier Detect */ @@ -149,7 +156,7 @@  #define UART_MSR_TERI		0x04 /* Trailing edge ring indicator */  #define UART_MSR_DDSR		0x02 /* Delta DSR */  #define UART_MSR_DCTS		0x01 /* Delta CTS */ -#define UART_MSR_ANY_DELTA	0x0F /* Any of the delta bits! */ +#define UART_MSR_ANY_DELTA	(UART_MSR_DDCD|UART_MSR_TERI|UART_MSR_DDSR|UART_MSR_DCTS)  #define UART_SCR	7	/* I/O: Scratch Register */ diff --git a/include/uapi/linux/serio.h b/include/uapi/linux/serio.h index ed2a96f43ce4..5a2af0942c9f 100644 --- a/include/uapi/linux/serio.h +++ b/include/uapi/linux/serio.h @@ -83,5 +83,6 @@  #define SERIO_PULSE8_CEC	0x40  #define SERIO_RAINSHADOW_CEC	0x41  #define SERIO_FSIA6B	0x42 +#define SERIO_EXTRON_DA_HD_4K_PLUS	0x43  #endif /* _UAPI_SERIO_H */ diff --git a/include/uapi/linux/sev-guest.h b/include/uapi/linux/sev-guest.h new file mode 100644 index 000000000000..fcdfea767fca --- /dev/null +++ b/include/uapi/linux/sev-guest.h @@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * Userspace interface for AMD SEV and SNP guest driver. + * + * Copyright (C) 2021 Advanced Micro Devices, Inc. + * + * Author: Brijesh Singh <brijesh.singh@amd.com> + * + * SEV API specification is available at: https://developer.amd.com/sev/ + */ + +#ifndef __UAPI_LINUX_SEV_GUEST_H_ +#define __UAPI_LINUX_SEV_GUEST_H_ + +#include <linux/types.h> + +#define SNP_REPORT_USER_DATA_SIZE 64 + +struct snp_report_req { +	/* user data that should be included in the report */ +	__u8 user_data[SNP_REPORT_USER_DATA_SIZE]; + +	/* The vmpl level to be included in the report */ +	__u32 vmpl; + +	/* Must be zero filled */ +	__u8 rsvd[28]; +}; + +struct snp_report_resp { +	/* response data, see SEV-SNP spec for the format */ +	__u8 data[4000]; +}; + +struct snp_derived_key_req { +	__u32 root_key_select; +	__u32 rsvd; +	__u64 guest_field_select; +	__u32 vmpl; +	__u32 guest_svn; +	__u64 tcb_version; +}; + +struct snp_derived_key_resp { +	/* response data, see SEV-SNP spec for the format */ +	__u8 data[64]; +}; + +struct snp_guest_request_ioctl { +	/* message version number (must be non-zero) */ +	__u8 msg_version; + +	/* Request and response structure address */ +	__u64 req_data; +	__u64 resp_data; + +	/* bits[63:32]: VMM error code, bits[31:0] firmware error code (see psp-sev.h) */ +	union { +		__u64 exitinfo2; +		struct { +			__u32 fw_error; +			__u32 vmm_error; +		}; +	}; +}; + +struct snp_ext_report_req { +	struct snp_report_req data; + +	/* where to copy the certificate blob */ +	__u64 certs_address; + +	/* length of the certificate blob */ +	__u32 certs_len; +}; + +#define SNP_GUEST_REQ_IOC_TYPE	'S' + +/* Get SNP attestation report */ +#define SNP_GET_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x0, struct snp_guest_request_ioctl) + +/* Get a derived key from the root */ +#define SNP_GET_DERIVED_KEY _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x1, struct snp_guest_request_ioctl) + +/* Get SNP extended report as defined in the GHCB specification version 2. */ +#define SNP_GET_EXT_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x2, struct snp_guest_request_ioctl) + +/* Guest message request EXIT_INFO_2 constants */ +#define SNP_GUEST_FW_ERR_MASK		GENMASK_ULL(31, 0) +#define SNP_GUEST_VMM_ERR_SHIFT		32 +#define SNP_GUEST_VMM_ERR(x)		(((u64)x) << SNP_GUEST_VMM_ERR_SHIFT) +#define SNP_GUEST_FW_ERR(x)		((x) & SNP_GUEST_FW_ERR_MASK) +#define SNP_GUEST_ERR(vmm_err, fw_err)	(SNP_GUEST_VMM_ERR(vmm_err) | \ +					 SNP_GUEST_FW_ERR(fw_err)) + +#define SNP_GUEST_VMM_ERR_INVALID_LEN	1 +#define SNP_GUEST_VMM_ERR_BUSY		2 + +#endif /* __UAPI_LINUX_SEV_GUEST_H_ */ diff --git a/include/uapi/linux/smc.h b/include/uapi/linux/smc.h index 0e11ca421ca4..1f58cb0c266b 100644 --- a/include/uapi/linux/smc.h +++ b/include/uapi/linux/smc.h @@ -33,4 +33,281 @@ enum {				/* SMC PNET Table commands */  #define SMCR_GENL_FAMILY_NAME		"SMC_PNETID"  #define SMCR_GENL_FAMILY_VERSION	1 +/* gennetlink interface to access non-socket information from SMC module */ +#define SMC_GENL_FAMILY_NAME		"SMC_GEN_NETLINK" +#define SMC_GENL_FAMILY_VERSION		1 + +#define SMC_PCI_ID_STR_LEN		16 /* Max length of pci id string */ +#define SMC_MAX_HOSTNAME_LEN		32 /* Max length of the hostname */ +#define SMC_MAX_UEID			4  /* Max number of user EIDs */ +#define SMC_MAX_EID_LEN			32 /* Max length of an EID */ + +/* SMC_GENL_FAMILY commands */ +enum { +	SMC_NETLINK_GET_SYS_INFO = 1, +	SMC_NETLINK_GET_LGR_SMCR, +	SMC_NETLINK_GET_LINK_SMCR, +	SMC_NETLINK_GET_LGR_SMCD, +	SMC_NETLINK_GET_DEV_SMCD, +	SMC_NETLINK_GET_DEV_SMCR, +	SMC_NETLINK_GET_STATS, +	SMC_NETLINK_GET_FBACK_STATS, +	SMC_NETLINK_DUMP_UEID, +	SMC_NETLINK_ADD_UEID, +	SMC_NETLINK_REMOVE_UEID, +	SMC_NETLINK_FLUSH_UEID, +	SMC_NETLINK_DUMP_SEID, +	SMC_NETLINK_ENABLE_SEID, +	SMC_NETLINK_DISABLE_SEID, +	SMC_NETLINK_DUMP_HS_LIMITATION, +	SMC_NETLINK_ENABLE_HS_LIMITATION, +	SMC_NETLINK_DISABLE_HS_LIMITATION, +}; + +/* SMC_GENL_FAMILY top level attributes */ +enum { +	SMC_GEN_UNSPEC, +	SMC_GEN_SYS_INFO,		/* nest */ +	SMC_GEN_LGR_SMCR,		/* nest */ +	SMC_GEN_LINK_SMCR,		/* nest */ +	SMC_GEN_LGR_SMCD,		/* nest */ +	SMC_GEN_DEV_SMCD,		/* nest */ +	SMC_GEN_DEV_SMCR,		/* nest */ +	SMC_GEN_STATS,			/* nest */ +	SMC_GEN_FBACK_STATS,		/* nest */ +	__SMC_GEN_MAX, +	SMC_GEN_MAX = __SMC_GEN_MAX - 1 +}; + +/* SMC_GEN_SYS_INFO attributes */ +enum { +	SMC_NLA_SYS_UNSPEC, +	SMC_NLA_SYS_VER,		/* u8 */ +	SMC_NLA_SYS_REL,		/* u8 */ +	SMC_NLA_SYS_IS_ISM_V2,		/* u8 */ +	SMC_NLA_SYS_LOCAL_HOST,		/* string */ +	SMC_NLA_SYS_SEID,		/* string */ +	SMC_NLA_SYS_IS_SMCR_V2,		/* u8 */ +	__SMC_NLA_SYS_MAX, +	SMC_NLA_SYS_MAX = __SMC_NLA_SYS_MAX - 1 +}; + +/* SMC_NLA_LGR_D_V2_COMMON and SMC_NLA_LGR_R_V2_COMMON nested attributes */ +enum { +	SMC_NLA_LGR_V2_VER,		/* u8 */ +	SMC_NLA_LGR_V2_REL,		/* u8 */ +	SMC_NLA_LGR_V2_OS,		/* u8 */ +	SMC_NLA_LGR_V2_NEG_EID,		/* string */ +	SMC_NLA_LGR_V2_PEER_HOST,	/* string */ +	__SMC_NLA_LGR_V2_MAX, +	SMC_NLA_LGR_V2_MAX = __SMC_NLA_LGR_V2_MAX - 1 +}; + +/* SMC_NLA_LGR_R_V2 nested attributes */ +enum { +	SMC_NLA_LGR_R_V2_UNSPEC, +	SMC_NLA_LGR_R_V2_DIRECT,	/* u8 */ +	SMC_NLA_LGR_R_V2_MAX_CONNS,	/* u8 */ +	SMC_NLA_LGR_R_V2_MAX_LINKS,	/* u8 */ +	__SMC_NLA_LGR_R_V2_MAX, +	SMC_NLA_LGR_R_V2_MAX = __SMC_NLA_LGR_R_V2_MAX - 1 +}; + +/* SMC_GEN_LGR_SMCR attributes */ +enum { +	SMC_NLA_LGR_R_UNSPEC, +	SMC_NLA_LGR_R_ID,		/* u32 */ +	SMC_NLA_LGR_R_ROLE,		/* u8 */ +	SMC_NLA_LGR_R_TYPE,		/* u8 */ +	SMC_NLA_LGR_R_PNETID,		/* string */ +	SMC_NLA_LGR_R_VLAN_ID,		/* u8 */ +	SMC_NLA_LGR_R_CONNS_NUM,	/* u32 */ +	SMC_NLA_LGR_R_V2_COMMON,	/* nest */ +	SMC_NLA_LGR_R_V2,		/* nest */ +	SMC_NLA_LGR_R_NET_COOKIE,	/* u64 */ +	SMC_NLA_LGR_R_PAD,		/* flag */ +	SMC_NLA_LGR_R_BUF_TYPE,		/* u8 */ +	SMC_NLA_LGR_R_SNDBUF_ALLOC,	/* uint */ +	SMC_NLA_LGR_R_RMB_ALLOC,	/* uint */ +	__SMC_NLA_LGR_R_MAX, +	SMC_NLA_LGR_R_MAX = __SMC_NLA_LGR_R_MAX - 1 +}; + +/* SMC_GEN_LINK_SMCR attributes */ +enum { +	SMC_NLA_LINK_UNSPEC, +	SMC_NLA_LINK_ID,		/* u8 */ +	SMC_NLA_LINK_IB_DEV,		/* string */ +	SMC_NLA_LINK_IB_PORT,		/* u8 */ +	SMC_NLA_LINK_GID,		/* string */ +	SMC_NLA_LINK_PEER_GID,		/* string */ +	SMC_NLA_LINK_CONN_CNT,		/* u32 */ +	SMC_NLA_LINK_NET_DEV,		/* u32 */ +	SMC_NLA_LINK_UID,		/* u32 */ +	SMC_NLA_LINK_PEER_UID,		/* u32 */ +	SMC_NLA_LINK_STATE,		/* u32 */ +	__SMC_NLA_LINK_MAX, +	SMC_NLA_LINK_MAX = __SMC_NLA_LINK_MAX - 1 +}; + +/* SMC_GEN_LGR_SMCD attributes */ +enum { +	SMC_NLA_LGR_D_UNSPEC, +	SMC_NLA_LGR_D_ID,		/* u32 */ +	SMC_NLA_LGR_D_GID,		/* u64 */ +	SMC_NLA_LGR_D_PEER_GID,		/* u64 */ +	SMC_NLA_LGR_D_VLAN_ID,		/* u8 */ +	SMC_NLA_LGR_D_CONNS_NUM,	/* u32 */ +	SMC_NLA_LGR_D_PNETID,		/* string */ +	SMC_NLA_LGR_D_CHID,		/* u16 */ +	SMC_NLA_LGR_D_PAD,		/* flag */ +	SMC_NLA_LGR_D_V2_COMMON,	/* nest */ +	SMC_NLA_LGR_D_EXT_GID,		/* u64 */ +	SMC_NLA_LGR_D_PEER_EXT_GID,	/* u64 */ +	SMC_NLA_LGR_D_SNDBUF_ALLOC,	/* uint */ +	SMC_NLA_LGR_D_DMB_ALLOC,	/* uint */ +	__SMC_NLA_LGR_D_MAX, +	SMC_NLA_LGR_D_MAX = __SMC_NLA_LGR_D_MAX - 1 +}; + +/* SMC_NLA_DEV_PORT nested attributes */ +enum { +	SMC_NLA_DEV_PORT_UNSPEC, +	SMC_NLA_DEV_PORT_PNET_USR,	/* u8 */ +	SMC_NLA_DEV_PORT_PNETID,	/* string */ +	SMC_NLA_DEV_PORT_NETDEV,	/* u32 */ +	SMC_NLA_DEV_PORT_STATE,		/* u8 */ +	SMC_NLA_DEV_PORT_VALID,		/* u8 */ +	SMC_NLA_DEV_PORT_LNK_CNT,	/* u32 */ +	__SMC_NLA_DEV_PORT_MAX, +	SMC_NLA_DEV_PORT_MAX = __SMC_NLA_DEV_PORT_MAX - 1 +}; + +/* SMC_GEN_DEV_SMCD and SMC_GEN_DEV_SMCR attributes */ +enum { +	SMC_NLA_DEV_UNSPEC, +	SMC_NLA_DEV_USE_CNT,		/* u32 */ +	SMC_NLA_DEV_IS_CRIT,		/* u8 */ +	SMC_NLA_DEV_PCI_FID,		/* u32 */ +	SMC_NLA_DEV_PCI_CHID,		/* u16 */ +	SMC_NLA_DEV_PCI_VENDOR,		/* u16 */ +	SMC_NLA_DEV_PCI_DEVICE,		/* u16 */ +	SMC_NLA_DEV_PCI_ID,		/* string */ +	SMC_NLA_DEV_PORT,		/* nest */ +	SMC_NLA_DEV_PORT2,		/* nest */ +	SMC_NLA_DEV_IB_NAME,		/* string */ +	__SMC_NLA_DEV_MAX, +	SMC_NLA_DEV_MAX = __SMC_NLA_DEV_MAX - 1 +}; + +/* SMC_NLA_STATS_T_TX(RX)_RMB_SIZE nested attributes */ +/* SMC_NLA_STATS_TX(RX)PLOAD_SIZE nested attributes */ +enum { +	SMC_NLA_STATS_PLOAD_PAD, +	SMC_NLA_STATS_PLOAD_8K,		/* u64 */ +	SMC_NLA_STATS_PLOAD_16K,	/* u64 */ +	SMC_NLA_STATS_PLOAD_32K,	/* u64 */ +	SMC_NLA_STATS_PLOAD_64K,	/* u64 */ +	SMC_NLA_STATS_PLOAD_128K,	/* u64 */ +	SMC_NLA_STATS_PLOAD_256K,	/* u64 */ +	SMC_NLA_STATS_PLOAD_512K,	/* u64 */ +	SMC_NLA_STATS_PLOAD_1024K,	/* u64 */ +	SMC_NLA_STATS_PLOAD_G_1024K,	/* u64 */ +	__SMC_NLA_STATS_PLOAD_MAX, +	SMC_NLA_STATS_PLOAD_MAX = __SMC_NLA_STATS_PLOAD_MAX - 1 +}; + +/* SMC_NLA_STATS_T_TX(RX)_RMB_STATS nested attributes */ +enum { +	SMC_NLA_STATS_RMB_PAD, +	SMC_NLA_STATS_RMB_SIZE_SM_PEER_CNT,	/* u64 */ +	SMC_NLA_STATS_RMB_SIZE_SM_CNT,		/* u64 */ +	SMC_NLA_STATS_RMB_FULL_PEER_CNT,	/* u64 */ +	SMC_NLA_STATS_RMB_FULL_CNT,		/* u64 */ +	SMC_NLA_STATS_RMB_REUSE_CNT,		/* u64 */ +	SMC_NLA_STATS_RMB_ALLOC_CNT,		/* u64 */ +	SMC_NLA_STATS_RMB_DGRADE_CNT,		/* u64 */ +	__SMC_NLA_STATS_RMB_MAX, +	SMC_NLA_STATS_RMB_MAX = __SMC_NLA_STATS_RMB_MAX - 1 +}; + +/* SMC_NLA_STATS_SMCD_TECH and _SMCR_TECH nested attributes */ +enum { +	SMC_NLA_STATS_T_PAD, +	SMC_NLA_STATS_T_TX_RMB_SIZE,	/* nest */ +	SMC_NLA_STATS_T_RX_RMB_SIZE,	/* nest */ +	SMC_NLA_STATS_T_TXPLOAD_SIZE,	/* nest */ +	SMC_NLA_STATS_T_RXPLOAD_SIZE,	/* nest */ +	SMC_NLA_STATS_T_TX_RMB_STATS,	/* nest */ +	SMC_NLA_STATS_T_RX_RMB_STATS,	/* nest */ +	SMC_NLA_STATS_T_CLNT_V1_SUCC,	/* u64 */ +	SMC_NLA_STATS_T_CLNT_V2_SUCC,	/* u64 */ +	SMC_NLA_STATS_T_SRV_V1_SUCC,	/* u64 */ +	SMC_NLA_STATS_T_SRV_V2_SUCC,	/* u64 */ +	SMC_NLA_STATS_T_SENDPAGE_CNT,	/* u64 */ +	SMC_NLA_STATS_T_SPLICE_CNT,	/* u64 */ +	SMC_NLA_STATS_T_CORK_CNT,	/* u64 */ +	SMC_NLA_STATS_T_NDLY_CNT,	/* u64 */ +	SMC_NLA_STATS_T_URG_DATA_CNT,	/* u64 */ +	SMC_NLA_STATS_T_RX_BYTES,	/* u64 */ +	SMC_NLA_STATS_T_TX_BYTES,	/* u64 */ +	SMC_NLA_STATS_T_RX_CNT,		/* u64 */ +	SMC_NLA_STATS_T_TX_CNT,		/* u64 */ +	SMC_NLA_STATS_T_RX_RMB_USAGE,	/* uint */ +	SMC_NLA_STATS_T_TX_RMB_USAGE,	/* uint */ +	__SMC_NLA_STATS_T_MAX, +	SMC_NLA_STATS_T_MAX = __SMC_NLA_STATS_T_MAX - 1 +}; + +/* SMC_GEN_STATS attributes */ +enum { +	SMC_NLA_STATS_PAD, +	SMC_NLA_STATS_SMCD_TECH,	/* nest */ +	SMC_NLA_STATS_SMCR_TECH,	/* nest */ +	SMC_NLA_STATS_CLNT_HS_ERR_CNT,	/* u64 */ +	SMC_NLA_STATS_SRV_HS_ERR_CNT,	/* u64 */ +	__SMC_NLA_STATS_MAX, +	SMC_NLA_STATS_MAX = __SMC_NLA_STATS_MAX - 1 +}; + +/* SMC_GEN_FBACK_STATS attributes */ +enum { +	SMC_NLA_FBACK_STATS_PAD, +	SMC_NLA_FBACK_STATS_TYPE,	/* u8 */ +	SMC_NLA_FBACK_STATS_SRV_CNT,	/* u64 */ +	SMC_NLA_FBACK_STATS_CLNT_CNT,	/* u64 */ +	SMC_NLA_FBACK_STATS_RSN_CODE,	/* u32 */ +	SMC_NLA_FBACK_STATS_RSN_CNT,	/* u16 */ +	__SMC_NLA_FBACK_STATS_MAX, +	SMC_NLA_FBACK_STATS_MAX = __SMC_NLA_FBACK_STATS_MAX - 1 +}; + +/* SMC_NETLINK_UEID attributes */ +enum { +	SMC_NLA_EID_TABLE_UNSPEC, +	SMC_NLA_EID_TABLE_ENTRY,	/* string */ +	__SMC_NLA_EID_TABLE_MAX, +	SMC_NLA_EID_TABLE_MAX = __SMC_NLA_EID_TABLE_MAX - 1 +}; + +/* SMC_NETLINK_SEID attributes */ +enum { +	SMC_NLA_SEID_UNSPEC, +	SMC_NLA_SEID_ENTRY,	/* string */ +	SMC_NLA_SEID_ENABLED,	/* u8 */ +	__SMC_NLA_SEID_TABLE_MAX, +	SMC_NLA_SEID_TABLE_MAX = __SMC_NLA_SEID_TABLE_MAX - 1 +}; + +/* SMC_NETLINK_HS_LIMITATION attributes */ +enum { +	SMC_NLA_HS_LIMITATION_UNSPEC, +	SMC_NLA_HS_LIMITATION_ENABLED,	/* u8 */ +	__SMC_NLA_HS_LIMITATION_MAX, +	SMC_NLA_HS_LIMITATION_MAX = __SMC_NLA_HS_LIMITATION_MAX - 1 +}; + +/* SMC socket options */ +#define SMC_LIMIT_HS 1	/* constraint on smc handshake */ +  #endif /* _UAPI_LINUX_SMC_H */ diff --git a/include/uapi/linux/smc_diag.h b/include/uapi/linux/smc_diag.h index 8cb3a6fef553..58eceb7f5df2 100644 --- a/include/uapi/linux/smc_diag.h +++ b/include/uapi/linux/smc_diag.h @@ -107,6 +107,8 @@ struct smcd_diag_dmbinfo {		/* SMC-D Socket internals */  	__aligned_u64	my_gid;		/* My GID */  	__aligned_u64	token;		/* Token of DMB */  	__aligned_u64	peer_token;	/* Token of remote DMBE */ +	__aligned_u64	peer_gid_ext;	/* Peer GID (extended part) */ +	__aligned_u64	my_gid_ext;	/* My GID (extended part) */  };  #endif /* _UAPI_SMC_DIAG_H_ */ diff --git a/include/uapi/linux/snmp.h b/include/uapi/linux/snmp.h index cee9f8e6fce3..49f5640092a0 100644 --- a/include/uapi/linux/snmp.h +++ b/include/uapi/linux/snmp.h @@ -23,9 +23,14 @@ enum  	IPSTATS_MIB_INPKTS,			/* InReceives */  	IPSTATS_MIB_INOCTETS,			/* InOctets */  	IPSTATS_MIB_INDELIVERS,			/* InDelivers */ -	IPSTATS_MIB_OUTFORWDATAGRAMS,		/* OutForwDatagrams */ -	IPSTATS_MIB_OUTPKTS,			/* OutRequests */ +	IPSTATS_MIB_NOECTPKTS,			/* InNoECTPkts */ +	IPSTATS_MIB_ECT1PKTS,			/* InECT1Pkts */ +	IPSTATS_MIB_ECT0PKTS,			/* InECT0Pkts */ +	IPSTATS_MIB_CEPKTS,			/* InCEPkts */ +	IPSTATS_MIB_OUTREQUESTS,		/* OutRequests */ +	IPSTATS_MIB_OUTPKTS,			/* OutTransmits */  	IPSTATS_MIB_OUTOCTETS,			/* OutOctets */ +	IPSTATS_MIB_OUTFORWDATAGRAMS,		/* OutForwDatagrams */  /* other fields */  	IPSTATS_MIB_INHDRERRORS,		/* InHdrErrors */  	IPSTATS_MIB_INTOOBIGERRORS,		/* InTooBigErrors */ @@ -52,10 +57,6 @@ enum  	IPSTATS_MIB_INBCASTOCTETS,		/* InBcastOctets */  	IPSTATS_MIB_OUTBCASTOCTETS,		/* OutBcastOctets */  	IPSTATS_MIB_CSUMERRORS,			/* InCsumErrors */ -	IPSTATS_MIB_NOECTPKTS,			/* InNoECTPkts */ -	IPSTATS_MIB_ECT1PKTS,			/* InECT1Pkts */ -	IPSTATS_MIB_ECT0PKTS,			/* InECT0Pkts */ -	IPSTATS_MIB_CEPKTS,			/* InCEPkts */  	IPSTATS_MIB_REASM_OVERLAPS,		/* ReasmOverlaps */  	__IPSTATS_MIB_MAX  }; @@ -95,6 +96,8 @@ enum  	ICMP_MIB_OUTADDRMASKS,			/* OutAddrMasks */  	ICMP_MIB_OUTADDRMASKREPS,		/* OutAddrMaskReps */  	ICMP_MIB_CSUMERRORS,			/* InCsumErrors */ +	ICMP_MIB_RATELIMITGLOBAL,		/* OutRateLimitGlobal */ +	ICMP_MIB_RATELIMITHOST,			/* OutRateLimitHost */  	__ICMP_MIB_MAX  }; @@ -112,6 +115,7 @@ enum  	ICMP6_MIB_OUTMSGS,			/* OutMsgs */  	ICMP6_MIB_OUTERRORS,			/* OutErrors */  	ICMP6_MIB_CSUMERRORS,			/* InCsumErrors */ +	ICMP6_MIB_RATELIMITHOST,		/* OutRateLimitHost */  	__ICMP6_MIB_MAX  }; @@ -159,6 +163,7 @@ enum  	UDP_MIB_SNDBUFERRORS,			/* SndbufErrors */  	UDP_MIB_CSUMERRORS,			/* InCsumErrors */  	UDP_MIB_IGNOREDMULTI,			/* IgnoredMulti */ +	UDP_MIB_MEMERRORS,			/* MemErrors */  	__UDP_MIB_MAX  }; @@ -181,6 +186,10 @@ enum  	LINUX_MIB_TIMEWAITKILLED,		/* TimeWaitKilled */  	LINUX_MIB_PAWSACTIVEREJECTED,		/* PAWSActiveRejected */  	LINUX_MIB_PAWSESTABREJECTED,		/* PAWSEstabRejected */ +	LINUX_MIB_BEYOND_WINDOW,		/* BeyondWindow */ +	LINUX_MIB_TSECRREJECTED,		/* TSEcrRejected */ +	LINUX_MIB_PAWS_OLD_ACK,			/* PAWSOldAck */ +	LINUX_MIB_PAWS_TW_REJECTED,		/* PAWSTimewait */  	LINUX_MIB_DELAYEDACKS,			/* DelayedACKs */  	LINUX_MIB_DELAYEDACKLOCKED,		/* DelayedACKLocked */  	LINUX_MIB_DELAYEDACKLOST,		/* DelayedACKLost */ @@ -288,6 +297,15 @@ enum  	LINUX_MIB_TCPTIMEOUTREHASH,		/* TCPTimeoutRehash */  	LINUX_MIB_TCPDUPLICATEDATAREHASH,	/* TCPDuplicateDataRehash */  	LINUX_MIB_TCPDSACKRECVSEGS,		/* TCPDSACKRecvSegs */ +	LINUX_MIB_TCPDSACKIGNOREDDUBIOUS,	/* TCPDSACKIgnoredDubious */ +	LINUX_MIB_TCPMIGRATEREQSUCCESS,		/* TCPMigrateReqSuccess */ +	LINUX_MIB_TCPMIGRATEREQFAILURE,		/* TCPMigrateReqFailure */ +	LINUX_MIB_TCPPLBREHASH,			/* TCPPLBRehash */ +	LINUX_MIB_TCPAOREQUIRED,		/* TCPAORequired */ +	LINUX_MIB_TCPAOBAD,			/* TCPAOBad */ +	LINUX_MIB_TCPAOKEYNOTFOUND,		/* TCPAOKeyNotFound */ +	LINUX_MIB_TCPAOGOOD,			/* TCPAOGood */ +	LINUX_MIB_TCPAODROPPEDICMPS,		/* TCPAODroppedIcmps */  	__LINUX_MIB_MAX  }; @@ -323,6 +341,10 @@ enum  	LINUX_MIB_XFRMFWDHDRERROR,		/* XfrmFwdHdrError*/  	LINUX_MIB_XFRMOUTSTATEINVALID,		/* XfrmOutStateInvalid */  	LINUX_MIB_XFRMACQUIREERROR,		/* XfrmAcquireError */ +	LINUX_MIB_XFRMOUTSTATEDIRERROR,		/* XfrmOutStateDirError */ +	LINUX_MIB_XFRMINSTATEDIRERROR,		/* XfrmInStateDirError */ +	LINUX_MIB_XFRMINIPTFSERROR,		/* XfrmInIptfsError */ +	LINUX_MIB_XFRMOUTNOQSPACE,		/* XfrmOutNoQueueSpace */  	__LINUX_MIB_XFRMMAX  }; @@ -340,6 +362,13 @@ enum  	LINUX_MIB_TLSRXDEVICE,			/* TlsRxDevice */  	LINUX_MIB_TLSDECRYPTERROR,		/* TlsDecryptError */  	LINUX_MIB_TLSRXDEVICERESYNC,		/* TlsRxDeviceResync */ +	LINUX_MIB_TLSDECRYPTRETRY,		/* TlsDecryptRetry */ +	LINUX_MIB_TLSRXNOPADVIOL,		/* TlsRxNoPadViolation */ +	LINUX_MIB_TLSRXREKEYOK,			/* TlsRxRekeyOk */ +	LINUX_MIB_TLSRXREKEYERROR,		/* TlsRxRekeyError */ +	LINUX_MIB_TLSTXREKEYOK,			/* TlsTxRekeyOk */ +	LINUX_MIB_TLSTXREKEYERROR,		/* TlsTxRekeyError */ +	LINUX_MIB_TLSRXREKEYRECEIVED,		/* TlsRxRekeyReceived */  	__LINUX_MIB_TLSMAX  }; diff --git a/include/uapi/linux/socket.h b/include/uapi/linux/socket.h index c3409c8ec0dd..d3fcd3b5ec53 100644 --- a/include/uapi/linux/socket.h +++ b/include/uapi/linux/socket.h @@ -26,4 +26,13 @@ struct __kernel_sockaddr_storage {  	};  }; +#define SOCK_SNDBUF_LOCK	1 +#define SOCK_RCVBUF_LOCK	2 + +#define SOCK_BUF_LOCK_MASK (SOCK_SNDBUF_LOCK | SOCK_RCVBUF_LOCK) + +#define SOCK_TXREHASH_DEFAULT	255 +#define SOCK_TXREHASH_DISABLED	0 +#define SOCK_TXREHASH_ENABLED	1 +  #endif /* _UAPI_LINUX_SOCKET_H */ diff --git a/include/uapi/linux/soundcard.h b/include/uapi/linux/soundcard.h index f3b21f989872..ac1318793a86 100644 --- a/include/uapi/linux/soundcard.h +++ b/include/uapi/linux/soundcard.h @@ -1051,7 +1051,7 @@ typedef struct mixer_vol_table {   *	the GPL version of OSS-4.x and build against that version   *	of the header.   * - *	We redefine the extern keyword so that make headers_check + *	We redefine the extern keyword so that usr/include/headers_check.pl   *	does not complain about SEQ_USE_EXTBUF.   */  #define SEQ_DECLAREBUF()		SEQ_USE_EXTBUF() diff --git a/include/uapi/linux/spi/spi.h b/include/uapi/linux/spi/spi.h new file mode 100644 index 000000000000..ee4ac812b8f8 --- /dev/null +++ b/include/uapi/linux/spi/spi.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +#ifndef _UAPI_SPI_H +#define _UAPI_SPI_H + +#include <linux/const.h> + +#define	SPI_CPHA		_BITUL(0)	/* clock phase */ +#define	SPI_CPOL		_BITUL(1)	/* clock polarity */ + +#define	SPI_MODE_0		(0|0)		/* (original MicroWire) */ +#define	SPI_MODE_1		(0|SPI_CPHA) +#define	SPI_MODE_2		(SPI_CPOL|0) +#define	SPI_MODE_3		(SPI_CPOL|SPI_CPHA) +#define	SPI_MODE_X_MASK		(SPI_CPOL|SPI_CPHA) + +#define	SPI_CS_HIGH		_BITUL(2)	/* chipselect active high? */ +#define	SPI_LSB_FIRST		_BITUL(3)	/* per-word bits-on-wire */ +#define	SPI_3WIRE		_BITUL(4)	/* SI/SO signals shared */ +#define	SPI_LOOP		_BITUL(5)	/* loopback mode */ +#define	SPI_NO_CS		_BITUL(6)	/* 1 dev/bus, no chipselect */ +#define	SPI_READY		_BITUL(7)	/* slave pulls low to pause */ +#define	SPI_TX_DUAL		_BITUL(8)	/* transmit with 2 wires */ +#define	SPI_TX_QUAD		_BITUL(9)	/* transmit with 4 wires */ +#define	SPI_RX_DUAL		_BITUL(10)	/* receive with 2 wires */ +#define	SPI_RX_QUAD		_BITUL(11)	/* receive with 4 wires */ +#define	SPI_CS_WORD		_BITUL(12)	/* toggle cs after each word */ +#define	SPI_TX_OCTAL		_BITUL(13)	/* transmit with 8 wires */ +#define	SPI_RX_OCTAL		_BITUL(14)	/* receive with 8 wires */ +#define	SPI_3WIRE_HIZ		_BITUL(15)	/* high impedance turnaround */ +#define	SPI_RX_CPHA_FLIP	_BITUL(16)	/* flip CPHA on Rx only xfer */ +#define SPI_MOSI_IDLE_LOW	_BITUL(17)	/* leave MOSI line low when idle */ +#define SPI_MOSI_IDLE_HIGH	_BITUL(18)	/* leave MOSI line high when idle */ + +/* + * All the bits defined above should be covered by SPI_MODE_USER_MASK. + * The SPI_MODE_USER_MASK has the SPI_MODE_KERNEL_MASK counterpart in + * 'include/linux/spi/spi.h'. The bits defined here are from bit 0 upwards + * while in SPI_MODE_KERNEL_MASK they are from the other end downwards. + * These bits must not overlap. A static assert check should make sure of that. + * If adding extra bits, make sure to increase the bit index below as well. + */ +#define SPI_MODE_USER_MASK	(_BITUL(19) - 1) + +#endif /* _UAPI_SPI_H */ diff --git a/include/uapi/linux/spi/spidev.h b/include/uapi/linux/spi/spidev.h index d56427c0b3e0..0c3da08f2aff 100644 --- a/include/uapi/linux/spi/spidev.h +++ b/include/uapi/linux/spi/spidev.h @@ -25,35 +25,7 @@  #include <linux/types.h>  #include <linux/ioctl.h> - -/* User space versions of kernel symbols for SPI clocking modes, - * matching <linux/spi/spi.h> - */ - -#define SPI_CPHA		0x01 -#define SPI_CPOL		0x02 - -#define SPI_MODE_0		(0|0) -#define SPI_MODE_1		(0|SPI_CPHA) -#define SPI_MODE_2		(SPI_CPOL|0) -#define SPI_MODE_3		(SPI_CPOL|SPI_CPHA) - -#define SPI_CS_HIGH		0x04 -#define SPI_LSB_FIRST		0x08 -#define SPI_3WIRE		0x10 -#define SPI_LOOP		0x20 -#define SPI_NO_CS		0x40 -#define SPI_READY		0x80 -#define SPI_TX_DUAL		0x100 -#define SPI_TX_QUAD		0x200 -#define SPI_RX_DUAL		0x400 -#define SPI_RX_QUAD		0x800 -#define SPI_CS_WORD		0x1000 -#define SPI_TX_OCTAL		0x2000 -#define SPI_RX_OCTAL		0x4000 -#define SPI_3WIRE_HIZ		0x8000 - -/*---------------------------------------------------------------------------*/ +#include <linux/spi/spi.h>  /* IOCTL commands */ diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 82cc58fe9368..1686861aae20 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -98,35 +98,97 @@ struct statx_timestamp {   */  struct statx {  	/* 0x00 */ -	__u32	stx_mask;	/* What results were written [uncond] */ -	__u32	stx_blksize;	/* Preferred general I/O size [uncond] */ -	__u64	stx_attributes;	/* Flags conveying information about the file [uncond] */ +	/* What results were written [uncond] */ +	__u32	stx_mask; + +	/* Preferred general I/O size [uncond] */ +	__u32	stx_blksize; + +	/* Flags conveying information about the file [uncond] */ +	__u64	stx_attributes; +  	/* 0x10 */ -	__u32	stx_nlink;	/* Number of hard links */ -	__u32	stx_uid;	/* User ID of owner */ -	__u32	stx_gid;	/* Group ID of owner */ -	__u16	stx_mode;	/* File mode */ +	/* Number of hard links */ +	__u32	stx_nlink; + +	/* User ID of owner */ +	__u32	stx_uid; + +	/* Group ID of owner */ +	__u32	stx_gid; + +	/* File mode */ +	__u16	stx_mode;  	__u16	__spare0[1]; +  	/* 0x20 */ -	__u64	stx_ino;	/* Inode number */ -	__u64	stx_size;	/* File size */ -	__u64	stx_blocks;	/* Number of 512-byte blocks allocated */ -	__u64	stx_attributes_mask; /* Mask to show what's supported in stx_attributes */ +	/* Inode number */ +	__u64	stx_ino; + +	/* File size */ +	__u64	stx_size; + +	/* Number of 512-byte blocks allocated */ +	__u64	stx_blocks; + +	/* Mask to show what's supported in stx_attributes */ +	__u64	stx_attributes_mask; +  	/* 0x40 */ -	struct statx_timestamp	stx_atime;	/* Last access time */ -	struct statx_timestamp	stx_btime;	/* File creation time */ -	struct statx_timestamp	stx_ctime;	/* Last attribute change time */ -	struct statx_timestamp	stx_mtime;	/* Last data modification time */ +	/* Last access time */ +	struct statx_timestamp	stx_atime; + +	/* File creation time */ +	struct statx_timestamp	stx_btime; + +	/* Last attribute change time */ +	struct statx_timestamp	stx_ctime; + +	/* Last data modification time */ +	struct statx_timestamp	stx_mtime; +  	/* 0x80 */ -	__u32	stx_rdev_major;	/* Device ID of special file [if bdev/cdev] */ +	/* Device ID of special file [if bdev/cdev] */ +	__u32	stx_rdev_major;  	__u32	stx_rdev_minor; -	__u32	stx_dev_major;	/* ID of device containing file [uncond] */ + +	/* ID of device containing file [uncond] */ +	__u32	stx_dev_major;  	__u32	stx_dev_minor; +  	/* 0x90 */  	__u64	stx_mnt_id; -	__u64	__spare2; + +	/* Memory buffer alignment for direct I/O */ +	__u32	stx_dio_mem_align; + +	/* File offset alignment for direct I/O */ +	__u32	stx_dio_offset_align; +  	/* 0xa0 */ -	__u64	__spare3[12];	/* Spare space for future expansion */ +	/* Subvolume identifier */ +	__u64	stx_subvol; + +	/* Min atomic write unit in bytes */ +	__u32	stx_atomic_write_unit_min; + +	/* Max atomic write unit in bytes */ +	__u32	stx_atomic_write_unit_max; + +	/* 0xb0 */ +	/* Max atomic write segment count */ +	__u32   stx_atomic_write_segments_max; + +	/* File offset alignment for direct I/O reads */ +	__u32	stx_dio_read_offset_align; + +	/* Optimised max atomic write unit in bytes */ +	__u32	stx_atomic_write_unit_max_opt; +	__u32	__spare2[1]; + +	/* 0xc0 */ +	__u64	__spare3[8];	/* Spare space for future expansion */ +  	/* 0x100 */  }; @@ -152,6 +214,11 @@ struct statx {  #define STATX_BASIC_STATS	0x000007ffU	/* The stuff in the normal stat struct */  #define STATX_BTIME		0x00000800U	/* Want/got stx_btime */  #define STATX_MNT_ID		0x00001000U	/* Got stx_mnt_id */ +#define STATX_DIOALIGN		0x00002000U	/* Want/got direct I/O alignment info */ +#define STATX_MNT_ID_UNIQUE	0x00004000U	/* Want/got extended stx_mount_id */ +#define STATX_SUBVOL		0x00008000U	/* Want/got stx_subvol */ +#define STATX_WRITE_ATOMIC	0x00010000U	/* Want/got atomic_write_* fields */ +#define STATX_DIO_READ_ALIGN	0x00020000U	/* Want/got dio read alignment info */  #define STATX__RESERVED		0x80000000U	/* Reserved for future struct statx expansion */ @@ -171,9 +238,12 @@ struct statx {   * be of use to ordinary userspace programs such as GUIs or ls rather than   * specialised tools.   * - * Note that the flags marked [I] correspond to generic FS_IOC_FLAGS + * Note that the flags marked [I] correspond to the FS_IOC_SETFLAGS flags   * semantically.  Where possible, the numerical value is picked to correspond - * also. + * also.  Note that the DAX attribute indicates that the file is in the CPU + * direct access state.  It does not correspond to the per-inode flag that + * some filesystems support. + *   */  #define STATX_ATTR_COMPRESSED		0x00000004 /* [I] File is compressed by the fs */  #define STATX_ATTR_IMMUTABLE		0x00000010 /* [I] File is marked immutable */ @@ -183,7 +253,8 @@ struct statx {  #define STATX_ATTR_AUTOMOUNT		0x00001000 /* Dir: Automount trigger */  #define STATX_ATTR_MOUNT_ROOT		0x00002000 /* Root of a mount */  #define STATX_ATTR_VERITY		0x00100000 /* [I] Verity protected file */ -#define STATX_ATTR_DAX			0x00002000 /* [I] File is DAX */ +#define STATX_ATTR_DAX			0x00200000 /* File is currently in DAX state */ +#define STATX_ATTR_WRITE_ATOMIC		0x00400000 /* File supports atomic write operations */  #endif /* _UAPI_LINUX_STAT_H */ diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h index ee8220f8dcf5..b87df1b485c2 100644 --- a/include/uapi/linux/stddef.h +++ b/include/uapi/linux/stddef.h @@ -1,6 +1,79 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_STDDEF_H +#define _UAPI_LINUX_STDDEF_H +  #include <linux/compiler_types.h>  #ifndef __always_inline  #define __always_inline inline  #endif + +/* Not all C++ standards support type declarations inside an anonymous union */ +#ifndef __cplusplus +#define __struct_group_tag(TAG)		TAG +#else +#define __struct_group_tag(TAG) +#endif + +/** + * __struct_group() - Create a mirrored named and anonyomous struct + * + * @TAG: The tag name for the named sub-struct (usually empty) + * @NAME: The identifier name of the mirrored sub-struct + * @ATTRS: Any struct attributes (usually empty) + * @MEMBERS: The member declarations for the mirrored structs + * + * Used to create an anonymous union of two structs with identical layout + * and size: one anonymous and one named. The former's members can be used + * normally without sub-struct naming, and the latter can be used to + * reason about the start, end, and size of the group of struct members. + * The named struct can also be explicitly tagged for layer reuse (C only), + * as well as both having struct attributes appended. + */ +#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \ +	union { \ +		struct { MEMBERS } ATTRS; \ +		struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \ +	} ATTRS + +#ifdef __cplusplus +/* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */ +#define __DECLARE_FLEX_ARRAY(T, member)	\ +	T member[0] +#else +/** + * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union + * + * @TYPE: The type of each flexible array element + * @NAME: The name of the flexible array member + * + * In order to have a flexible array member in a union or alone in a + * struct, it needs to be wrapped in an anonymous struct with at least 1 + * named member, but that member can be empty. + */ +#define __DECLARE_FLEX_ARRAY(TYPE, NAME)	\ +	struct { \ +		struct { } __empty_ ## NAME; \ +		TYPE NAME[]; \ +	} +#endif + +#ifndef __counted_by +#define __counted_by(m) +#endif + +#ifndef __counted_by_le +#define __counted_by_le(m) +#endif + +#ifndef __counted_by_be +#define __counted_by_be(m) +#endif + +#ifdef __KERNEL__ +#define __kernel_nonstring	__nonstring +#else +#define __kernel_nonstring +#endif + +#endif /* _UAPI_LINUX_STDDEF_H */ diff --git a/include/uapi/linux/stm.h b/include/uapi/linux/stm.h index 7bac318b4440..de3579c2cff0 100644 --- a/include/uapi/linux/stm.h +++ b/include/uapi/linux/stm.h @@ -36,7 +36,7 @@ struct stp_policy_id {  	/* padding */  	__u16		__reserved_0;  	__u32		__reserved_1; -	char		id[0]; +	char		id[];  };  #define STP_POLICY_ID_SET	_IOWR('%', 0, struct stp_policy_id) diff --git a/include/uapi/linux/surface_aggregator/cdev.h b/include/uapi/linux/surface_aggregator/cdev.h new file mode 100644 index 000000000000..08f46b60b151 --- /dev/null +++ b/include/uapi/linux/surface_aggregator/cdev.h @@ -0,0 +1,147 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Surface System Aggregator Module (SSAM) user-space EC interface. + * + * Definitions, structs, and IOCTLs for the /dev/surface/aggregator misc + * device. This device provides direct user-space access to the SSAM EC. + * Intended for debugging and development. + * + * Copyright (C) 2020-2021 Maximilian Luz <luzmaximilian@gmail.com> + */ + +#ifndef _UAPI_LINUX_SURFACE_AGGREGATOR_CDEV_H +#define _UAPI_LINUX_SURFACE_AGGREGATOR_CDEV_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +/** + * enum ssam_cdev_request_flags - Request flags for SSAM cdev request IOCTL. + * + * @SSAM_CDEV_REQUEST_HAS_RESPONSE: + *	Specifies that the request expects a response. If not set, the request + *	will be directly completed after its underlying packet has been + *	transmitted. If set, the request transport system waits for a response + *	of the request. + * + * @SSAM_CDEV_REQUEST_UNSEQUENCED: + *	Specifies that the request should be transmitted via an unsequenced + *	packet. If set, the request must not have a response, meaning that this + *	flag and the %SSAM_CDEV_REQUEST_HAS_RESPONSE flag are mutually + *	exclusive. + */ +enum ssam_cdev_request_flags { +	SSAM_CDEV_REQUEST_HAS_RESPONSE = 0x01, +	SSAM_CDEV_REQUEST_UNSEQUENCED  = 0x02, +}; + +/** + * struct ssam_cdev_request - Controller request IOCTL argument. + * @target_category: Target category of the SAM request. + * @target_id:       Target ID of the SAM request. + * @command_id:      Command ID of the SAM request. + * @instance_id:     Instance ID of the SAM request. + * @flags:           Request flags (see &enum ssam_cdev_request_flags). + * @status:          Request status (output). + * @payload:         Request payload (input data). + * @payload.data:    Pointer to request payload data. + * @payload.length:  Length of request payload data (in bytes). + * @response:        Request response (output data). + * @response.data:   Pointer to response buffer. + * @response.length: On input: Capacity of response buffer (in bytes). + *                   On output: Length of request response (number of bytes + *                   in the buffer that are actually used). + */ +struct ssam_cdev_request { +	__u8 target_category; +	__u8 target_id; +	__u8 command_id; +	__u8 instance_id; +	__u16 flags; +	__s16 status; + +	struct { +		__u64 data; +		__u16 length; +		__u8 __pad[6]; +	} payload; + +	struct { +		__u64 data; +		__u16 length; +		__u8 __pad[6]; +	} response; +} __attribute__((__packed__)); + +/** + * struct ssam_cdev_notifier_desc - Notifier descriptor. + * @priority:        Priority value determining the order in which notifier + *                   callbacks will be called. A higher value means higher + *                   priority, i.e. the associated callback will be executed + *                   earlier than other (lower priority) callbacks. + * @target_category: The event target category for which this notifier should + *                   receive events. + * + * Specifies the notifier that should be registered or unregistered, + * specifically with which priority and for which target category of events. + */ +struct ssam_cdev_notifier_desc { +	__s32 priority; +	__u8 target_category; +} __attribute__((__packed__)); + +/** + * struct ssam_cdev_event_desc - Event descriptor. + * @reg:                 Registry via which the event will be enabled/disabled. + * @reg.target_category: Target category for the event registry requests. + * @reg.target_id:       Target ID for the event registry requests. + * @reg.cid_enable:      Command ID for the event-enable request. + * @reg.cid_disable:     Command ID for the event-disable request. + * @id:                  ID specifying the event. + * @id.target_category:  Target category of the event source. + * @id.instance:         Instance ID of the event source. + * @flags:               Flags used for enabling the event. + * + * Specifies which event should be enabled/disabled and how to do that. + */ +struct ssam_cdev_event_desc { +	struct { +		__u8 target_category; +		__u8 target_id; +		__u8 cid_enable; +		__u8 cid_disable; +	} reg; + +	struct { +		__u8 target_category; +		__u8 instance; +	} id; + +	__u8 flags; +} __attribute__((__packed__)); + +/** + * struct ssam_cdev_event - SSAM event sent by the EC. + * @target_category: Target category of the event source. See &enum ssam_ssh_tc. + * @target_id:       Target ID of the event source. + * @command_id:      Command ID of the event. + * @instance_id:     Instance ID of the event source. + * @length:          Length of the event payload in bytes. + * @data:            Event payload data. + */ +struct ssam_cdev_event { +	__u8 target_category; +	__u8 target_id; +	__u8 command_id; +	__u8 instance_id; +	__u16 length; +	__u8 data[]; +} __attribute__((__packed__)); + +#define SSAM_CDEV_REQUEST		_IOWR(0xA5, 1, struct ssam_cdev_request) +#define SSAM_CDEV_NOTIF_REGISTER	_IOW(0xA5, 2, struct ssam_cdev_notifier_desc) +#define SSAM_CDEV_NOTIF_UNREGISTER	_IOW(0xA5, 3, struct ssam_cdev_notifier_desc) +#define SSAM_CDEV_EVENT_ENABLE		_IOW(0xA5, 4, struct ssam_cdev_event_desc) +#define SSAM_CDEV_EVENT_DISABLE		_IOW(0xA5, 5, struct ssam_cdev_event_desc) + +#endif /* _UAPI_LINUX_SURFACE_AGGREGATOR_CDEV_H */ diff --git a/include/uapi/linux/surface_aggregator/dtx.h b/include/uapi/linux/surface_aggregator/dtx.h new file mode 100644 index 000000000000..0833aab0d819 --- /dev/null +++ b/include/uapi/linux/surface_aggregator/dtx.h @@ -0,0 +1,146 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Surface DTX (clipboard detachment system driver) user-space interface. + * + * Definitions, structs, and IOCTLs for the /dev/surface/dtx misc device. This + * device allows user-space to control the clipboard detachment process on + * Surface Book series devices. + * + * Copyright (C) 2020-2021 Maximilian Luz <luzmaximilian@gmail.com> + */ + +#ifndef _UAPI_LINUX_SURFACE_AGGREGATOR_DTX_H +#define _UAPI_LINUX_SURFACE_AGGREGATOR_DTX_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +/* Status/error categories */ +#define SDTX_CATEGORY_STATUS		0x0000 +#define SDTX_CATEGORY_RUNTIME_ERROR	0x1000 +#define SDTX_CATEGORY_HARDWARE_ERROR	0x2000 +#define SDTX_CATEGORY_UNKNOWN		0xf000 + +#define SDTX_CATEGORY_MASK		0xf000 +#define SDTX_CATEGORY(value)		((value) & SDTX_CATEGORY_MASK) + +#define SDTX_STATUS(code)		((code) | SDTX_CATEGORY_STATUS) +#define SDTX_ERR_RT(code)		((code) | SDTX_CATEGORY_RUNTIME_ERROR) +#define SDTX_ERR_HW(code)		((code) | SDTX_CATEGORY_HARDWARE_ERROR) +#define SDTX_UNKNOWN(code)		((code) | SDTX_CATEGORY_UNKNOWN) + +#define SDTX_SUCCESS(value)		(SDTX_CATEGORY(value) == SDTX_CATEGORY_STATUS) + +/* Latch status values */ +#define SDTX_LATCH_CLOSED		SDTX_STATUS(0x00) +#define SDTX_LATCH_OPENED		SDTX_STATUS(0x01) + +/* Base state values */ +#define SDTX_BASE_DETACHED		SDTX_STATUS(0x00) +#define SDTX_BASE_ATTACHED		SDTX_STATUS(0x01) + +/* Runtime errors (non-critical) */ +#define SDTX_DETACH_NOT_FEASIBLE	SDTX_ERR_RT(0x01) +#define SDTX_DETACH_TIMEDOUT		SDTX_ERR_RT(0x02) + +/* Hardware errors (critical) */ +#define SDTX_ERR_FAILED_TO_OPEN		SDTX_ERR_HW(0x01) +#define SDTX_ERR_FAILED_TO_REMAIN_OPEN	SDTX_ERR_HW(0x02) +#define SDTX_ERR_FAILED_TO_CLOSE	SDTX_ERR_HW(0x03) + +/* Base types */ +#define SDTX_DEVICE_TYPE_HID		0x0100 +#define SDTX_DEVICE_TYPE_SSH		0x0200 + +#define SDTX_DEVICE_TYPE_MASK		0x0f00 +#define SDTX_DEVICE_TYPE(value)		((value) & SDTX_DEVICE_TYPE_MASK) + +#define SDTX_BASE_TYPE_HID(id)		((id) | SDTX_DEVICE_TYPE_HID) +#define SDTX_BASE_TYPE_SSH(id)		((id) | SDTX_DEVICE_TYPE_SSH) + +/** + * enum sdtx_device_mode - Mode describing how (and if) the clipboard is + * attached to the base of the device. + * @SDTX_DEVICE_MODE_TABLET: The clipboard is detached from the base and the + *                           device operates as tablet. + * @SDTX_DEVICE_MODE_LAPTOP: The clipboard is attached normally to the base + *                           and the device operates as laptop. + * @SDTX_DEVICE_MODE_STUDIO: The clipboard is attached to the base in reverse. + *                           The device operates as tablet with keyboard and + *                           touchpad deactivated, however, the base battery + *                           and, if present in the specific device model, dGPU + *                           are available to the system. + */ +enum sdtx_device_mode { +	SDTX_DEVICE_MODE_TABLET		= 0x00, +	SDTX_DEVICE_MODE_LAPTOP		= 0x01, +	SDTX_DEVICE_MODE_STUDIO		= 0x02, +}; + +/** + * struct sdtx_event - Event provided by reading from the DTX device file. + * @length: Length of the event payload, in bytes. + * @code:   Event code, detailing what type of event this is. + * @data:   Payload of the event, containing @length bytes. + * + * See &enum sdtx_event_code for currently valid event codes. + */ +struct sdtx_event { +	__u16 length; +	__u16 code; +	__u8 data[]; +} __attribute__((__packed__)); + +/** + * enum sdtx_event_code - Code describing the type of an event. + * @SDTX_EVENT_REQUEST:         Detachment request event type. + * @SDTX_EVENT_CANCEL:          Cancel detachment process event type. + * @SDTX_EVENT_BASE_CONNECTION: Base/clipboard connection change event type. + * @SDTX_EVENT_LATCH_STATUS:    Latch status change event type. + * @SDTX_EVENT_DEVICE_MODE:     Device mode change event type. + * + * Used in &struct sdtx_event to describe the type of the event. Further event + * codes are reserved for future use. Any event parser should be able to + * gracefully handle unknown events, i.e. by simply skipping them. + * + * Consult the DTX user-space interface documentation for details regarding + * the individual event types. + */ +enum sdtx_event_code { +	SDTX_EVENT_REQUEST		= 1, +	SDTX_EVENT_CANCEL		= 2, +	SDTX_EVENT_BASE_CONNECTION	= 3, +	SDTX_EVENT_LATCH_STATUS		= 4, +	SDTX_EVENT_DEVICE_MODE		= 5, +}; + +/** + * struct sdtx_base_info - Describes if and what type of base is connected. + * @state:   The state of the connection. Valid values are %SDTX_BASE_DETACHED, + *           %SDTX_BASE_ATTACHED, and %SDTX_DETACH_NOT_FEASIBLE (in case a base + *           is attached but low clipboard battery prevents detachment). Other + *           values are currently reserved. + * @base_id: The type of base connected. Zero if no base is connected. + */ +struct sdtx_base_info { +	__u16 state; +	__u16 base_id; +} __attribute__((__packed__)); + +/* IOCTLs */ +#define SDTX_IOCTL_EVENTS_ENABLE	_IO(0xa5, 0x21) +#define SDTX_IOCTL_EVENTS_DISABLE	_IO(0xa5, 0x22) + +#define SDTX_IOCTL_LATCH_LOCK		_IO(0xa5, 0x23) +#define SDTX_IOCTL_LATCH_UNLOCK		_IO(0xa5, 0x24) + +#define SDTX_IOCTL_LATCH_REQUEST	_IO(0xa5, 0x25) +#define SDTX_IOCTL_LATCH_CONFIRM	_IO(0xa5, 0x26) +#define SDTX_IOCTL_LATCH_HEARTBEAT	_IO(0xa5, 0x27) +#define SDTX_IOCTL_LATCH_CANCEL		_IO(0xa5, 0x28) + +#define SDTX_IOCTL_GET_BASE_INFO	_IOR(0xa5, 0x29, struct sdtx_base_info) +#define SDTX_IOCTL_GET_DEVICE_MODE	_IOR(0xa5, 0x2a, __u16) +#define SDTX_IOCTL_GET_LATCH_STATUS	_IOR(0xa5, 0x2b, __u16) + +#endif /* _UAPI_LINUX_SURFACE_AGGREGATOR_DTX_H */ diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h index 7272f85d6d6a..01717181339e 100644 --- a/include/uapi/linux/swab.h +++ b/include/uapi/linux/swab.h @@ -3,7 +3,7 @@  #define _UAPI_LINUX_SWAB_H  #include <linux/types.h> -#include <linux/compiler.h> +#include <linux/stddef.h>  #include <asm/bitsperlong.h>  #include <asm/swab.h> @@ -102,7 +102,7 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val)  #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))  #else  #define __swab16(x)				\ -	(__builtin_constant_p((__u16)(x)) ?	\ +	(__u16)(__builtin_constant_p(x) ?	\  	___constant_swab16(x) :			\  	__fswab16(x))  #endif @@ -115,7 +115,7 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val)  #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))  #else  #define __swab32(x)				\ -	(__builtin_constant_p((__u32)(x)) ?	\ +	(__u32)(__builtin_constant_p(x) ?	\  	___constant_swab32(x) :			\  	__fswab32(x))  #endif @@ -128,7 +128,7 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val)  #define __swab64(x) (__u64)__builtin_bswap64((__u64)(x))  #else  #define __swab64(x)				\ -	(__builtin_constant_p((__u64)(x)) ?	\ +	(__u64)(__builtin_constant_p(x) ?	\  	___constant_swab64(x) :			\  	__fswab64(x))  #endif diff --git a/include/uapi/linux/sync_file.h b/include/uapi/linux/sync_file.h index ee2dcfb3d660..ff1f38889dcf 100644 --- a/include/uapi/linux/sync_file.h +++ b/include/uapi/linux/sync_file.h @@ -16,12 +16,16 @@  #include <linux/types.h>  /** - * struct sync_merge_data - data passed to merge ioctl + * struct sync_merge_data - SYNC_IOC_MERGE: merge two fences   * @name:	name of new fence   * @fd2:	file descriptor of second fence   * @fence:	returns the fd of the new fence to userspace   * @flags:	merge_data flags   * @pad:	padding for 64-bit alignment, should always be zero + * + * Creates a new fence containing copies of the sync_pts in both + * the calling fd and sync_merge_data.fd2.  Returns the new fence's + * fd in sync_merge_data.fence   */  struct sync_merge_data {  	char	name[32]; @@ -34,8 +38,8 @@ struct sync_merge_data {  /**   * struct sync_fence_info - detailed fence information   * @obj_name:		name of parent sync_timeline -* @driver_name:	name of driver implementing the parent -* @status:		status of the fence 0:active 1:signaled <0:error + * @driver_name:	name of driver implementing the parent + * @status:		status of the fence 0:active 1:signaled <0:error   * @flags:		fence_info flags   * @timestamp_ns:	timestamp of status change in nanoseconds   */ @@ -48,14 +52,19 @@ struct sync_fence_info {  };  /** - * struct sync_file_info - data returned from fence info ioctl + * struct sync_file_info - SYNC_IOC_FILE_INFO: get detailed information on a sync_file   * @name:	name of fence   * @status:	status of fence. 1: signaled 0:active <0:error   * @flags:	sync_file_info flags - * @num_fences	number of fences in the sync_file + * @num_fences:	number of fences in the sync_file   * @pad:	padding for 64-bit alignment, should always be zero - * @sync_fence_info: pointer to array of structs sync_fence_info with all + * @sync_fence_info: pointer to array of struct &sync_fence_info with all   *		 fences in the sync_file + * + * Takes a struct sync_file_info. If num_fences is 0, the field is updated + * with the actual number of fences. If num_fences is > 0, the system will + * use the pointer provided on sync_fence_info to return up to num_fences of + * struct sync_fence_info, with detailed fence information.   */  struct sync_file_info {  	char	name[32]; @@ -67,32 +76,38 @@ struct sync_file_info {  	__u64	sync_fence_info;  }; +/** + * struct sync_set_deadline - SYNC_IOC_SET_DEADLINE - set a deadline hint on a fence + * @deadline_ns: absolute time of the deadline + * @pad:	must be zero + * + * Allows userspace to set a deadline on a fence, see &dma_fence_set_deadline + * + * The timebase for the deadline is CLOCK_MONOTONIC (same as vblank).  For + * example + * + *     clock_gettime(CLOCK_MONOTONIC, &t); + *     deadline_ns = (t.tv_sec * 1000000000L) + t.tv_nsec + ns_until_deadline + */ +struct sync_set_deadline { +	__u64	deadline_ns; +	/* Not strictly needed for alignment but gives some possibility +	 * for future extension: +	 */ +	__u64	pad; +}; +  #define SYNC_IOC_MAGIC		'>' -/** +/*   * Opcodes  0, 1 and 2 were burned during a API change to avoid users of the   * old API to get weird errors when trying to handling sync_files. The API   * change happened during the de-stage of the Sync Framework when there was   * no upstream users available.   */ -/** - * DOC: SYNC_IOC_MERGE - merge two fences - * - * Takes a struct sync_merge_data.  Creates a new fence containing copies of - * the sync_pts in both the calling fd and sync_merge_data.fd2.  Returns the - * new fence's fd in sync_merge_data.fence - */  #define SYNC_IOC_MERGE		_IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data) - -/** - * DOC: SYNC_IOC_FILE_INFO - get detailed information on a sync_file - * - * Takes a struct sync_file_info. If num_fences is 0, the field is updated - * with the actual number of fences. If num_fences is > 0, the system will - * use the pointer provided on sync_fence_info to return up to num_fences of - * struct sync_fence_info, with detailed fence information. - */  #define SYNC_IOC_FILE_INFO	_IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info) +#define SYNC_IOC_SET_DEADLINE	_IOW(SYNC_IOC_MAGIC, 5, struct sync_set_deadline)  #endif /* _UAPI_LINUX_SYNC_H */ diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h index 27c1ed2822e6..63d1464cb71c 100644 --- a/include/uapi/linux/sysctl.h +++ b/include/uapi/linux/sysctl.h @@ -23,7 +23,7 @@  #ifndef _UAPI_LINUX_SYSCTL_H  #define _UAPI_LINUX_SYSCTL_H -#include <linux/kernel.h> +#include <linux/const.h>  #include <linux/types.h>  #include <linux/compiler.h> @@ -482,6 +482,7 @@ enum  	NET_IPV4_CONF_PROMOTE_SECONDARIES=20,  	NET_IPV4_CONF_ARP_ACCEPT=21,  	NET_IPV4_CONF_ARP_NOTIFY=22, +	NET_IPV4_CONF_ARP_EVICT_NOCARRIER=23,  };  /* /proc/sys/net/ipv4/netfilter */ @@ -571,6 +572,8 @@ enum {  	NET_IPV6_ACCEPT_SOURCE_ROUTE=25,  	NET_IPV6_ACCEPT_RA_FROM_LOCAL=26,  	NET_IPV6_ACCEPT_RA_RT_INFO_MIN_PLEN=27, +	NET_IPV6_RA_DEFRTR_METRIC=28, +	NET_IPV6_FORCE_FORWARDING=29,  	__NET_IPV6_MAX  }; @@ -582,24 +585,25 @@ enum {  /* /proc/sys/net/<protocol>/neigh/<dev> */  enum { -	NET_NEIGH_MCAST_SOLICIT=1, -	NET_NEIGH_UCAST_SOLICIT=2, -	NET_NEIGH_APP_SOLICIT=3, -	NET_NEIGH_RETRANS_TIME=4, -	NET_NEIGH_REACHABLE_TIME=5, -	NET_NEIGH_DELAY_PROBE_TIME=6, -	NET_NEIGH_GC_STALE_TIME=7, -	NET_NEIGH_UNRES_QLEN=8, -	NET_NEIGH_PROXY_QLEN=9, -	NET_NEIGH_ANYCAST_DELAY=10, -	NET_NEIGH_PROXY_DELAY=11, -	NET_NEIGH_LOCKTIME=12, -	NET_NEIGH_GC_INTERVAL=13, -	NET_NEIGH_GC_THRESH1=14, -	NET_NEIGH_GC_THRESH2=15, -	NET_NEIGH_GC_THRESH3=16, -	NET_NEIGH_RETRANS_TIME_MS=17, -	NET_NEIGH_REACHABLE_TIME_MS=18, +	NET_NEIGH_MCAST_SOLICIT = 1, +	NET_NEIGH_UCAST_SOLICIT = 2, +	NET_NEIGH_APP_SOLICIT = 3, +	NET_NEIGH_RETRANS_TIME = 4, +	NET_NEIGH_REACHABLE_TIME = 5, +	NET_NEIGH_DELAY_PROBE_TIME = 6, +	NET_NEIGH_GC_STALE_TIME = 7, +	NET_NEIGH_UNRES_QLEN = 8, +	NET_NEIGH_PROXY_QLEN = 9, +	NET_NEIGH_ANYCAST_DELAY = 10, +	NET_NEIGH_PROXY_DELAY = 11, +	NET_NEIGH_LOCKTIME = 12, +	NET_NEIGH_GC_INTERVAL = 13, +	NET_NEIGH_GC_THRESH1 = 14, +	NET_NEIGH_GC_THRESH2 = 15, +	NET_NEIGH_GC_THRESH3 = 16, +	NET_NEIGH_RETRANS_TIME_MS = 17, +	NET_NEIGH_REACHABLE_TIME_MS = 18, +	NET_NEIGH_INTERVAL_PROBE_TIME_MS = 19,  };  /* /proc/sys/net/dccp */ diff --git a/include/uapi/linux/target_core_user.h b/include/uapi/linux/target_core_user.h index 95b1597f16ae..f925a77f19ed 100644 --- a/include/uapi/linux/target_core_user.h +++ b/include/uapi/linux/target_core_user.h @@ -46,6 +46,7 @@  #define TCMU_MAILBOX_FLAG_CAP_OOOC (1 << 0) /* Out-of-order completions */  #define TCMU_MAILBOX_FLAG_CAP_READ_LEN (1 << 1) /* Read data length */  #define TCMU_MAILBOX_FLAG_CAP_TMR (1 << 2) /* TMR notifications */ +#define TCMU_MAILBOX_FLAG_CAP_KEEP_BUF (1<<3) /* Keep buf after cmd completion */  struct tcmu_mailbox {  	__u16 version; @@ -75,6 +76,7 @@ struct tcmu_cmd_entry_hdr {  	__u8 kflags;  #define TCMU_UFLAG_UNKNOWN_OP 0x1  #define TCMU_UFLAG_READ_LEN   0x2 +#define TCMU_UFLAG_KEEP_BUF   0x4  	__u8 uflags;  } __packed; @@ -117,7 +119,7 @@ struct tcmu_cmd_entry {  			__u64 cdb_off;  			__u64 __pad1;  			__u64 __pad2; -			struct iovec iov[0]; +			__DECLARE_FLEX_ARRAY(struct iovec, iov);  		} req;  		struct {  			__u8 scsi_status; @@ -150,7 +152,7 @@ struct tcmu_tmr_entry {  	__u32 cmd_cnt;  	__u64 __pad3;  	__u64 __pad4; -	__u16 cmd_ids[0]; +	__u16 cmd_ids[];  } __packed;  #define TCMU_OP_ALIGN_SIZE sizeof(__u64) diff --git a/include/uapi/linux/taskstats.h b/include/uapi/linux/taskstats.h index ccbd08709321..5929030d4e8b 100644 --- a/include/uapi/linux/taskstats.h +++ b/include/uapi/linux/taskstats.h @@ -34,7 +34,7 @@   */ -#define TASKSTATS_VERSION	10 +#define TASKSTATS_VERSION	16  #define TS_COMM_LEN		32	/* should be >= TASK_COMM_LEN  					 * in linux/sched.h */ @@ -48,7 +48,8 @@ struct taskstats {  	__u32	ac_exitcode;		/* Exit status */  	/* The accounting flags of a task as defined in <linux/acct.h> -	 * Defined values are AFORK, ASU, ACOMPAT, ACORE, and AXSIG. +	 * Defined values are AFORK, ASU, ACOMPAT, ACORE, AXSIG, and AGROUP. +	 * (AGROUP since version 12).  	 */  	__u8	ac_flag;		/* Record flags */  	__u8	ac_nice;		/* task_nice */ @@ -166,12 +167,69 @@ struct taskstats {  	__u64	freepages_count;  	__u64	freepages_delay_total; +  	/* Delay waiting for thrashing page */  	__u64	thrashing_count;  	__u64	thrashing_delay_total;  	/* v10: 64-bit btime to avoid overflow */  	__u64	ac_btime64;		/* 64-bit begin time */ + +	/* v11: Delay waiting for memory compact */ +	__u64	compact_count; +	__u64	compact_delay_total; + +	/* v12 begin */ +	__u32   ac_tgid;	/* thread group ID */ +	/* Thread group walltime up to now. This is total process walltime if +	 * AGROUP flag is set. +	 */ +	__u64	ac_tgetime __attribute__((aligned(8))); +	/* Lightweight information to identify process binary files. +	 * This leaves userspace to match this to a file system path, using +	 * MAJOR() and MINOR() macros to identify a device and mount point, +	 * the inode to identify the executable file. This is /proc/self/exe +	 * at the end, so matching the most recent exec(). Values are zero +	 * for kernel threads. +	 */ +	__u64   ac_exe_dev;     /* program binary device ID */ +	__u64   ac_exe_inode;   /* program binary inode number */ +	/* v12 end */ + +	/* v13: Delay waiting for write-protect copy */ +	__u64    wpcopy_count; +	__u64    wpcopy_delay_total; + +	/* v14: Delay waiting for IRQ/SOFTIRQ */ +	__u64    irq_count; +	__u64    irq_delay_total; + +	/* v15: add Delay max and Delay min */ + +	/* v16: move Delay max and Delay min to the end of taskstat */ +	__u64	cpu_delay_max; +	__u64	cpu_delay_min; + +	__u64	blkio_delay_max; +	__u64	blkio_delay_min; + +	__u64	swapin_delay_max; +	__u64	swapin_delay_min; + +	__u64	freepages_delay_max; +	__u64	freepages_delay_min; + +	__u64	thrashing_delay_max; +	__u64	thrashing_delay_min; + +	__u64	compact_delay_max; +	__u64	compact_delay_min; + +	__u64	wpcopy_delay_max; +	__u64	wpcopy_delay_min; + +	__u64	irq_delay_max; +	__u64	irq_delay_min;  }; diff --git a/include/uapi/linux/tc_act/tc_bpf.h b/include/uapi/linux/tc_act/tc_bpf.h index 653c4f94f76e..fe6c8f8f3e8c 100644 --- a/include/uapi/linux/tc_act/tc_bpf.h +++ b/include/uapi/linux/tc_act/tc_bpf.h @@ -1,11 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */  /*   * Copyright (c) 2015 Jiri Pirko <jiri@resnulli.us> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version.   */  #ifndef __LINUX_TC_BPF_H diff --git a/include/uapi/linux/tc_act/tc_ct.h b/include/uapi/linux/tc_act/tc_ct.h index 5fb1d7ac1027..6c5200f0ed38 100644 --- a/include/uapi/linux/tc_act/tc_ct.h +++ b/include/uapi/linux/tc_act/tc_ct.h @@ -22,6 +22,9 @@ enum {  	TCA_CT_NAT_PORT_MIN,	/* be16 */  	TCA_CT_NAT_PORT_MAX,	/* be16 */  	TCA_CT_PAD, +	TCA_CT_HELPER_NAME,	/* string */ +	TCA_CT_HELPER_FAMILY,	/* u8 */ +	TCA_CT_HELPER_PROTO,	/* u8 */  	__TCA_CT_MAX  }; diff --git a/include/uapi/linux/tc_act/tc_ipt.h b/include/uapi/linux/tc_act/tc_ipt.h deleted file mode 100644 index c48d7da6750d..000000000000 --- a/include/uapi/linux/tc_act/tc_ipt.h +++ /dev/null @@ -1,20 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef __LINUX_TC_IPT_H -#define __LINUX_TC_IPT_H - -#include <linux/pkt_cls.h> - -enum { -	TCA_IPT_UNSPEC, -	TCA_IPT_TABLE, -	TCA_IPT_HOOK, -	TCA_IPT_INDEX, -	TCA_IPT_CNT, -	TCA_IPT_TM, -	TCA_IPT_TARG, -	TCA_IPT_PAD, -	__TCA_IPT_MAX -}; -#define TCA_IPT_MAX (__TCA_IPT_MAX - 1) -                                                                                 -#endif diff --git a/include/uapi/linux/tc_act/tc_mirred.h b/include/uapi/linux/tc_act/tc_mirred.h index 2500a0005d05..c61e76f3c23b 100644 --- a/include/uapi/linux/tc_act/tc_mirred.h +++ b/include/uapi/linux/tc_act/tc_mirred.h @@ -21,6 +21,7 @@ enum {  	TCA_MIRRED_TM,  	TCA_MIRRED_PARMS,  	TCA_MIRRED_PAD, +	TCA_MIRRED_BLOCKID,  	__TCA_MIRRED_MAX  };  #define TCA_MIRRED_MAX (__TCA_MIRRED_MAX - 1) diff --git a/include/uapi/linux/tc_act/tc_mpls.h b/include/uapi/linux/tc_act/tc_mpls.h index 9360e95273c7..9e4e8f52a779 100644 --- a/include/uapi/linux/tc_act/tc_mpls.h +++ b/include/uapi/linux/tc_act/tc_mpls.h @@ -10,6 +10,7 @@  #define TCA_MPLS_ACT_PUSH	2  #define TCA_MPLS_ACT_MODIFY	3  #define TCA_MPLS_ACT_DEC_TTL	4 +#define TCA_MPLS_ACT_MAC_PUSH	5  struct tc_mpls {  	tc_gen;		/* generic TC action fields. */ diff --git a/include/uapi/linux/tc_act/tc_pedit.h b/include/uapi/linux/tc_act/tc_pedit.h index f3e61b04fa01..f5cab7fc96ab 100644 --- a/include/uapi/linux/tc_act/tc_pedit.h +++ b/include/uapi/linux/tc_act/tc_pedit.h @@ -62,7 +62,7 @@ struct tc_pedit_sel {  	tc_gen;  	unsigned char           nkeys;  	unsigned char           flags; -	struct tc_pedit_key     keys[0]; +	struct tc_pedit_key     keys[] __counted_by(nkeys);  };  #define tc_pedit tc_pedit_sel diff --git a/include/uapi/linux/tc_act/tc_skbedit.h b/include/uapi/linux/tc_act/tc_skbedit.h index 800e93377218..64032513cc4c 100644 --- a/include/uapi/linux/tc_act/tc_skbedit.h +++ b/include/uapi/linux/tc_act/tc_skbedit.h @@ -2,19 +2,6 @@  /*   * Copyright (c) 2008, Intel Corporation.   * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307 USA. - *   * Author: Alexander Duyck <alexander.h.duyck@intel.com>   */ @@ -29,6 +16,7 @@  #define SKBEDIT_F_PTYPE			0x8  #define SKBEDIT_F_MASK			0x10  #define SKBEDIT_F_INHERITDSFIELD	0x20 +#define SKBEDIT_F_TXQ_SKBHASH		0x40  struct tc_skbedit {  	tc_gen; @@ -45,6 +33,7 @@ enum {  	TCA_SKBEDIT_PTYPE,  	TCA_SKBEDIT_MASK,  	TCA_SKBEDIT_FLAGS, +	TCA_SKBEDIT_QUEUE_MAPPING_MAX,  	__TCA_SKBEDIT_MAX  };  #define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1) diff --git a/include/uapi/linux/tc_act/tc_skbmod.h b/include/uapi/linux/tc_act/tc_skbmod.h index c525b3503797..ac62c9a993ea 100644 --- a/include/uapi/linux/tc_act/tc_skbmod.h +++ b/include/uapi/linux/tc_act/tc_skbmod.h @@ -1,12 +1,7 @@  /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */  /*   * Copyright (c) 2016, Jamal Hadi Salim - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. -*/ + */  #ifndef __LINUX_TC_SKBMOD_H  #define __LINUX_TC_SKBMOD_H @@ -17,6 +12,7 @@  #define SKBMOD_F_SMAC	0x2  #define SKBMOD_F_ETYPE	0x4  #define SKBMOD_F_SWAPMAC 0x8 +#define SKBMOD_F_ECN	0x10  struct tc_skbmod {  	tc_gen; diff --git a/include/uapi/linux/tc_act/tc_tunnel_key.h b/include/uapi/linux/tc_act/tc_tunnel_key.h index 3f10dc4e7a4b..37c6f612f161 100644 --- a/include/uapi/linux/tc_act/tc_tunnel_key.h +++ b/include/uapi/linux/tc_act/tc_tunnel_key.h @@ -2,11 +2,6 @@  /*   * Copyright (c) 2016, Amir Vadai <amir@vadai.me>   * Copyright (c) 2016, Mellanox Technologies. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version.   */  #ifndef __LINUX_TC_TUNNEL_KEY_H @@ -39,6 +34,7 @@ enum {  					 */  	TCA_TUNNEL_KEY_ENC_TOS,		/* u8 */  	TCA_TUNNEL_KEY_ENC_TTL,		/* u8 */ +	TCA_TUNNEL_KEY_NO_FRAG,		/* flag */  	__TCA_TUNNEL_KEY_MAX,  }; diff --git a/include/uapi/linux/tc_act/tc_vlan.h b/include/uapi/linux/tc_act/tc_vlan.h index 168995b54a70..3e1f8e57cdd2 100644 --- a/include/uapi/linux/tc_act/tc_vlan.h +++ b/include/uapi/linux/tc_act/tc_vlan.h @@ -1,11 +1,6 @@  /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */  /*   * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version.   */  #ifndef __LINUX_TC_VLAN_H @@ -16,6 +11,8 @@  #define TCA_VLAN_ACT_POP	1  #define TCA_VLAN_ACT_PUSH	2  #define TCA_VLAN_ACT_MODIFY	3 +#define TCA_VLAN_ACT_POP_ETH	4 +#define TCA_VLAN_ACT_PUSH_ETH	5  struct tc_vlan {  	tc_gen; @@ -30,6 +27,8 @@ enum {  	TCA_VLAN_PUSH_VLAN_PROTOCOL,  	TCA_VLAN_PAD,  	TCA_VLAN_PUSH_VLAN_PRIORITY, +	TCA_VLAN_PUSH_ETH_DST, +	TCA_VLAN_PUSH_ETH_SRC,  	__TCA_VLAN_MAX,  };  #define TCA_VLAN_MAX (__TCA_VLAN_MAX - 1) diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index cfcb10b75483..bdac8c42fa82 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -28,7 +28,8 @@ struct tcphdr {  	__be32	seq;  	__be32	ack_seq;  #if defined(__LITTLE_ENDIAN_BITFIELD) -	__u16	res1:4, +	__u16	ae:1, +		res1:3,  		doff:4,  		fin:1,  		syn:1, @@ -40,7 +41,8 @@ struct tcphdr {  		cwr:1;  #elif defined(__BIG_ENDIAN_BITFIELD)  	__u16	doff:4, -		res1:4, +		res1:3, +		ae:1,  		cwr:1,  		ece:1,  		urg:1, @@ -51,7 +53,7 @@ struct tcphdr {  		fin:1;  #else  #error	"Adjust your <asm/byteorder.h> defines" -#endif	 +#endif  	__be16	window;  	__sum16	check;  	__be16	urg_ptr; @@ -62,14 +64,15 @@ struct tcphdr {   *  (union is compatible to any of its members)   *  This means this part of the code is -fstrict-aliasing safe now.   */ -union tcp_word_hdr {  +union tcp_word_hdr {  	struct tcphdr hdr; -	__be32 		  words[5]; -};  +	__be32        words[5]; +}; -#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])  +#define tcp_flag_word(tp) (((union tcp_word_hdr *)(tp))->words[3]) -enum {  +enum { +	TCP_FLAG_AE  = __constant_cpu_to_be32(0x01000000),  	TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000),  	TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000),  	TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000), @@ -78,9 +81,9 @@ enum {  	TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000),  	TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000),  	TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000), -	TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0F000000), +	TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0E000000),  	TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000) -};  +};  /*   * TCP general constants @@ -103,8 +106,8 @@ enum {  #define TCP_QUICKACK		12	/* Block/reenable quick acks */  #define TCP_CONGESTION		13	/* Congestion control algorithm */  #define TCP_MD5SIG		14	/* TCP MD5 Signature (RFC2385) */ -#define TCP_THIN_LINEAR_TIMEOUTS 16      /* Use linear timeouts for thin streams*/ -#define TCP_THIN_DUPACK         17      /* Fast retrans. after 1 dupack */ +#define TCP_THIN_LINEAR_TIMEOUTS 16	/* Use linear timeouts for thin streams*/ +#define TCP_THIN_DUPACK		17	/* Fast retrans. after 1 dupack */  #define TCP_USER_TIMEOUT	18	/* How long for loss retry before timeout */  #define TCP_REPAIR		19	/* TCP sock is under repair right now */  #define TCP_REPAIR_QUEUE	20 @@ -129,6 +132,16 @@ enum {  #define TCP_TX_DELAY		37	/* delay outgoing packets by XX usec */ +#define TCP_AO_ADD_KEY		38	/* Add/Set MKT */ +#define TCP_AO_DEL_KEY		39	/* Delete MKT */ +#define TCP_AO_INFO		40	/* Set/list TCP-AO per-socket options */ +#define TCP_AO_GET_KEYS		41	/* List MKT(s) */ +#define TCP_AO_REPAIR		42	/* Get/Set SNEs and ISNs */ + +#define TCP_IS_MPTCP		43	/* Is MPTCP being used? */ +#define TCP_RTO_MAX_MS		44	/* max rto time in ms */ +#define TCP_RTO_MIN_US		45	/* min rto time in us */ +#define TCP_DELACK_MAX_US	46	/* max delayed ack time in us */  #define TCP_REPAIR_ON		1  #define TCP_REPAIR_OFF		0 @@ -170,6 +183,8 @@ enum tcp_fastopen_client_fail {  #define TCPI_OPT_ECN		8 /* ECN was negociated at TCP session init */  #define TCPI_OPT_ECN_SEEN	16 /* we received at least one packet with ECT */  #define TCPI_OPT_SYN_DATA	32 /* SYN-ACK acked data in SYN sent or rcvd */ +#define TCPI_OPT_USEC_TS	64 /* usec timestamps */ +#define TCPI_OPT_TFO_CHILD	128 /* child from a Fast Open option on SYN */  /*   * Sender's congestion state indicating normal or abnormal situations @@ -284,6 +299,23 @@ struct tcp_info {  	__u32	tcpi_snd_wnd;	     /* peer's advertised receive window after  				      * scaling (bytes)  				      */ +	__u32	tcpi_rcv_wnd;	     /* local advertised receive window after +				      * scaling (bytes) +				      */ + +	__u32   tcpi_rehash;         /* PLB or timeout triggered rehash attempts */ + +	__u16	tcpi_total_rto;	/* Total number of RTO timeouts, including +				 * SYN/SYN-ACK and recurring timeouts. +				 */ +	__u16	tcpi_total_rto_recoveries;	/* Total number of RTO +						 * recoveries, including any +						 * unfinished recovery. +						 */ +	__u32	tcpi_total_rto_time;	/* Total time spent in RTO recoveries +					 * in milliseconds, including any +					 * unfinished recovery. +					 */  };  /* netlink attributes types for SCM_TIMESTAMPING_OPT_STATS */ @@ -314,6 +346,8 @@ enum {  	TCP_NLA_TIMEOUT_REHASH, /* Timeout-triggered rehash attempts */  	TCP_NLA_BYTES_NOTSENT,	/* Bytes in write queue not yet sent */  	TCP_NLA_EDT,		/* Earliest departure time (CLOCK_MONOTONIC) */ +	TCP_NLA_TTL,		/* TTL or hop limit of a packet received */ +	TCP_NLA_REHASH,         /* PLB and timeout triggered rehash attempts */  };  /* for TCP_MD5SIG socket option */ @@ -341,13 +375,121 @@ struct tcp_diag_md5sig {  	__u8	tcpm_key[TCP_MD5SIG_MAXKEYLEN];  }; +#define TCP_AO_MAXKEYLEN	80 + +#define TCP_AO_KEYF_IFINDEX	(1 << 0)	/* L3 ifindex for VRF */ +#define TCP_AO_KEYF_EXCLUDE_OPT	(1 << 1)	/* "Indicates whether TCP +						 *  options other than TCP-AO +						 *  are included in the MAC +						 *  calculation" +						 */ + +struct tcp_ao_add { /* setsockopt(TCP_AO_ADD_KEY) */ +	struct __kernel_sockaddr_storage addr;	/* peer's address for the key */ +	char	alg_name[64];		/* crypto hash algorithm to use */ +	__s32	ifindex;		/* L3 dev index for VRF */ +	__u32   set_current	:1,	/* set key as Current_key at once */ +		set_rnext	:1,	/* request it from peer with RNext_key */ +		reserved	:30;	/* must be 0 */ +	__u16	reserved2;		/* padding, must be 0 */ +	__u8	prefix;			/* peer's address prefix */ +	__u8	sndid;			/* SendID for outgoing segments */ +	__u8	rcvid;			/* RecvID to match for incoming seg */ +	__u8	maclen;			/* length of authentication code (hash) */ +	__u8	keyflags;		/* see TCP_AO_KEYF_ */ +	__u8	keylen;			/* length of ::key */ +	__u8	key[TCP_AO_MAXKEYLEN]; +} __attribute__((aligned(8))); + +struct tcp_ao_del { /* setsockopt(TCP_AO_DEL_KEY) */ +	struct __kernel_sockaddr_storage addr;	/* peer's address for the key */ +	__s32	ifindex;		/* L3 dev index for VRF */ +	__u32   set_current	:1,	/* corresponding ::current_key */ +		set_rnext	:1,	/* corresponding ::rnext */ +		del_async	:1,	/* only valid for listen sockets */ +		reserved	:29;	/* must be 0 */ +	__u16	reserved2;		/* padding, must be 0 */ +	__u8	prefix;			/* peer's address prefix */ +	__u8	sndid;			/* SendID for outgoing segments */ +	__u8	rcvid;			/* RecvID to match for incoming seg */ +	__u8	current_key;		/* KeyID to set as Current_key */ +	__u8	rnext;			/* KeyID to set as Rnext_key */ +	__u8	keyflags;		/* see TCP_AO_KEYF_ */ +} __attribute__((aligned(8))); + +struct tcp_ao_info_opt { /* setsockopt(TCP_AO_INFO), getsockopt(TCP_AO_INFO) */ +	/* Here 'in' is for setsockopt(), 'out' is for getsockopt() */ +	__u32   set_current	:1,	/* in/out: corresponding ::current_key */ +		set_rnext	:1,	/* in/out: corresponding ::rnext */ +		ao_required	:1,	/* in/out: don't accept non-AO connects */ +		set_counters	:1,	/* in: set/clear ::pkt_* counters */ +		accept_icmps	:1,	/* in/out: accept incoming ICMPs */ +		reserved	:27;	/* must be 0 */ +	__u16	reserved2;		/* padding, must be 0 */ +	__u8	current_key;		/* in/out: KeyID of Current_key */ +	__u8	rnext;			/* in/out: keyid of RNext_key */ +	__u64	pkt_good;		/* in/out: verified segments */ +	__u64	pkt_bad;		/* in/out: failed verification */ +	__u64	pkt_key_not_found;	/* in/out: could not find a key to verify */ +	__u64	pkt_ao_required;	/* in/out: segments missing TCP-AO sign */ +	__u64	pkt_dropped_icmp;	/* in/out: ICMPs that were ignored */ +} __attribute__((aligned(8))); + +struct tcp_ao_getsockopt { /* getsockopt(TCP_AO_GET_KEYS) */ +	struct __kernel_sockaddr_storage addr;	/* in/out: dump keys for peer +						 * with this address/prefix +						 */ +	char	alg_name[64];		/* out: crypto hash algorithm */ +	__u8	key[TCP_AO_MAXKEYLEN]; +	__u32	nkeys;			/* in: size of the userspace buffer +					 * @optval, measured in @optlen - the +					 * sizeof(struct tcp_ao_getsockopt) +					 * out: number of keys that matched +					 */ +	__u16   is_current	:1,	/* in: match and dump Current_key, +					 * out: the dumped key is Current_key +					 */ + +		is_rnext	:1,	/* in: match and dump RNext_key, +					 * out: the dumped key is RNext_key +					 */ +		get_all		:1,	/* in: dump all keys */ +		reserved	:13;	/* padding, must be 0 */ +	__u8	sndid;			/* in/out: dump keys with SendID */ +	__u8	rcvid;			/* in/out: dump keys with RecvID */ +	__u8	prefix;			/* in/out: dump keys with address/prefix */ +	__u8	maclen;			/* out: key's length of authentication +					 * code (hash) +					 */ +	__u8	keyflags;		/* in/out: see TCP_AO_KEYF_ */ +	__u8	keylen;			/* out: length of ::key */ +	__s32	ifindex;		/* in/out: L3 dev index for VRF */ +	__u64	pkt_good;		/* out: verified segments */ +	__u64	pkt_bad;		/* out: segments that failed verification */ +} __attribute__((aligned(8))); + +struct tcp_ao_repair { /* {s,g}etsockopt(TCP_AO_REPAIR) */ +	__be32			snt_isn; +	__be32			rcv_isn; +	__u32			snd_sne; +	__u32			rcv_sne; +} __attribute__((aligned(8))); +  /* setsockopt(fd, IPPROTO_TCP, TCP_ZEROCOPY_RECEIVE, ...) */ +#define TCP_RECEIVE_ZEROCOPY_FLAG_TLB_CLEAN_HINT 0x1  struct tcp_zerocopy_receive {  	__u64 address;		/* in: address of mapping */  	__u32 length;		/* in/out: number of bytes to map/mapped */  	__u32 recv_skip_hint;	/* out: amount of bytes to skip */  	__u32 inq; /* out: amount of bytes in read queue */  	__s32 err; /* out: socket error */ +	__u64 copybuf_address;	/* in: copybuf address (small reads) */ +	__s32 copybuf_len; /* in/out: copybuf bytes avail/used or error */ +	__u32 flags; /* in: flags */ +	__u64 msg_control; /* ancillary data */ +	__u64 msg_controllen; +	__u32 msg_flags; +	__u32 reserved; /* set to 0 for now */  };  #endif /* _UAPI_LINUX_TCP_H */ diff --git a/include/uapi/linux/tcp_metrics.h b/include/uapi/linux/tcp_metrics.h index 7cb4a172feed..927c735a5b0e 100644 --- a/include/uapi/linux/tcp_metrics.h +++ b/include/uapi/linux/tcp_metrics.h @@ -1,8 +1,8 @@  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */  /* tcp_metrics.h - TCP Metrics Interface */ -#ifndef _LINUX_TCP_METRICS_H -#define _LINUX_TCP_METRICS_H +#ifndef _UAPI_LINUX_TCP_METRICS_H +#define _UAPI_LINUX_TCP_METRICS_H  #include <linux/types.h> @@ -27,6 +27,22 @@ enum tcp_metric_index {  #define TCP_METRIC_MAX	(__TCP_METRIC_MAX - 1) +/* Re-define enum tcp_metric_index, again, using the values carried + * as netlink attribute types. + */ +enum { +	TCP_METRICS_A_METRICS_RTT = 1, +	TCP_METRICS_A_METRICS_RTTVAR, +	TCP_METRICS_A_METRICS_SSTHRESH, +	TCP_METRICS_A_METRICS_CWND, +	TCP_METRICS_A_METRICS_REODERING, +	TCP_METRICS_A_METRICS_RTT_US, +	TCP_METRICS_A_METRICS_RTTVAR_US, + +	__TCP_METRICS_A_METRICS_MAX +}; +#define TCP_METRICS_A_METRICS_MAX (__TCP_METRICS_A_METRICS_MAX - 1) +  enum {  	TCP_METRICS_ATTR_UNSPEC,  	TCP_METRICS_ATTR_ADDR_IPV4,		/* u32 */ @@ -58,4 +74,4 @@ enum {  #define TCP_METRICS_CMD_MAX	(__TCP_METRICS_CMD_MAX - 1) -#endif /* _LINUX_TCP_METRICS_H */ +#endif /* _UAPI_LINUX_TCP_METRICS_H */ diff --git a/include/uapi/linux/tdx-guest.h b/include/uapi/linux/tdx-guest.h new file mode 100644 index 000000000000..a6a2098c08ff --- /dev/null +++ b/include/uapi/linux/tdx-guest.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Userspace interface for TDX guest driver + * + * Copyright (C) 2022 Intel Corporation + */ + +#ifndef _UAPI_LINUX_TDX_GUEST_H_ +#define _UAPI_LINUX_TDX_GUEST_H_ + +#include <linux/ioctl.h> +#include <linux/types.h> + +/* Length of the REPORTDATA used in TDG.MR.REPORT TDCALL */ +#define TDX_REPORTDATA_LEN              64 + +/* Length of TDREPORT used in TDG.MR.REPORT TDCALL */ +#define TDX_REPORT_LEN                  1024 + +/** + * struct tdx_report_req - Request struct for TDX_CMD_GET_REPORT0 IOCTL. + * + * @reportdata: User buffer with REPORTDATA to be included into TDREPORT. + *              Typically it can be some nonce provided by attestation + *              service, so the generated TDREPORT can be uniquely verified. + * @tdreport: User buffer to store TDREPORT output from TDCALL[TDG.MR.REPORT]. + */ +struct tdx_report_req { +	__u8 reportdata[TDX_REPORTDATA_LEN]; +	__u8 tdreport[TDX_REPORT_LEN]; +}; + +/* + * TDX_CMD_GET_REPORT0 - Get TDREPORT0 (a.k.a. TDREPORT subtype 0) using + *                       TDCALL[TDG.MR.REPORT] + * + * Return 0 on success, -EIO on TDCALL execution failure, and + * standard errno on other general error cases. + */ +#define TDX_CMD_GET_REPORT0              _IOWR('T', 1, struct tdx_report_req) + +#endif /* _UAPI_LINUX_TDX_GUEST_H_ */ diff --git a/include/uapi/linux/tee.h b/include/uapi/linux/tee.h index b619f37ee03e..d0430bee8292 100644 --- a/include/uapi/linux/tee.h +++ b/include/uapi/linux/tee.h @@ -42,21 +42,21 @@  #define TEE_IOC_MAGIC	0xa4  #define TEE_IOC_BASE	0 -/* Flags relating to shared memory */ -#define TEE_IOCTL_SHM_MAPPED	0x1	/* memory mapped in normal world */ -#define TEE_IOCTL_SHM_DMA_BUF	0x2	/* dma-buf handle on shared memory */ -  #define TEE_MAX_ARG_SIZE	1024  #define TEE_GEN_CAP_GP		(1 << 0)/* GlobalPlatform compliant TEE */  #define TEE_GEN_CAP_PRIVILEGED	(1 << 1)/* Privileged device (for supplicant) */  #define TEE_GEN_CAP_REG_MEM	(1 << 2)/* Supports registering shared memory */ +#define TEE_GEN_CAP_MEMREF_NULL	(1 << 3)/* NULL MemRef support */ + +#define TEE_MEMREF_NULL		(__u64)(-1) /* NULL MemRef Buffer */  /*   * TEE Implementation ID   */  #define TEE_IMPL_ID_OPTEE	1  #define TEE_IMPL_ID_AMDTEE	2 +#define TEE_IMPL_ID_TSTEE	3  /*   * OP-TEE specific capabilities @@ -200,6 +200,16 @@ struct tee_ioctl_buf_data {   * a part of a shared memory by specifying an offset (@a) and size (@b) of   * the object. To supply the entire shared memory object set the offset   * (@a) to 0 and size (@b) to the previously returned size of the object. + * + * A client may need to present a NULL pointer in the argument + * passed to a trusted application in the TEE. + * This is also a requirement in GlobalPlatform Client API v1.0c + * (section 3.2.5 memory references), which can be found at + * http://www.globalplatform.org/specificationsdevice.asp + * + * If a NULL pointer is passed to a TA in the TEE, the (@c) + * IOCTL parameters value must be set to TEE_MEMREF_NULL indicating a NULL + * memory reference.   */  struct tee_ioctl_param {  	__u64 attr; @@ -342,7 +352,7 @@ struct tee_iocl_supp_send_arg {  };  /** - * TEE_IOC_SUPPL_SEND - Receive a request for a supplicant function + * TEE_IOC_SUPPL_SEND - Send a response to a received request   *   * Takes a struct tee_ioctl_buf_data which contains a struct   * tee_iocl_supp_send_arg followed by any array of struct tee_param diff --git a/include/uapi/linux/termios.h b/include/uapi/linux/termios.h index 33961d4e4de0..e6da9d4433d1 100644 --- a/include/uapi/linux/termios.h +++ b/include/uapi/linux/termios.h @@ -5,19 +5,4 @@  #include <linux/types.h>  #include <asm/termios.h> -#define NFF	5 - -struct termiox -{ -	__u16	x_hflag; -	__u16	x_cflag; -	__u16	x_rflag[NFF]; -	__u16	x_sflag; -}; - -#define	RTSXOFF		0x0001		/* RTS flow control on input */ -#define	CTSXON		0x0002		/* CTS flow control on output */ -#define	DTRXOFF		0x0004		/* DTR flow control on input */ -#define DSRXON		0x0008		/* DCD flow control on output */ -  #endif diff --git a/include/uapi/linux/thermal.h b/include/uapi/linux/thermal.h index c105054cbb57..46a2633d33aa 100644 --- a/include/uapi/linux/thermal.h +++ b/include/uapi/linux/thermal.h @@ -3,6 +3,8 @@  #define _UAPI_LINUX_THERMAL_H  #define THERMAL_NAME_LENGTH	20 +#define THERMAL_THRESHOLD_WAY_UP	0x1 +#define THERMAL_THRESHOLD_WAY_DOWN	0x2  enum thermal_device_mode {  	THERMAL_DEVICE_DISABLED = 0, @@ -18,7 +20,7 @@ enum thermal_trip_type {  /* Adding event notification support elements */  #define THERMAL_GENL_FAMILY_NAME		"thermal" -#define THERMAL_GENL_VERSION			0x01 +#define THERMAL_GENL_VERSION			0x02  #define THERMAL_GENL_SAMPLING_GROUP_NAME	"sampling"  #define THERMAL_GENL_EVENT_GROUP_NAME		"event" @@ -44,7 +46,14 @@ enum thermal_genl_attr {  	THERMAL_GENL_ATTR_CDEV_MAX_STATE,  	THERMAL_GENL_ATTR_CDEV_NAME,  	THERMAL_GENL_ATTR_GOV_NAME, - +	THERMAL_GENL_ATTR_CPU_CAPABILITY, +	THERMAL_GENL_ATTR_CPU_CAPABILITY_ID, +	THERMAL_GENL_ATTR_CPU_CAPABILITY_PERFORMANCE, +	THERMAL_GENL_ATTR_CPU_CAPABILITY_EFFICIENCY, +	THERMAL_GENL_ATTR_THRESHOLD, +	THERMAL_GENL_ATTR_THRESHOLD_TEMP, +	THERMAL_GENL_ATTR_THRESHOLD_DIRECTION, +	THERMAL_GENL_ATTR_TZ_PREV_TEMP,  	__THERMAL_GENL_ATTR_MAX,  };  #define THERMAL_GENL_ATTR_MAX (__THERMAL_GENL_ATTR_MAX - 1) @@ -60,7 +69,7 @@ enum thermal_genl_event {  	THERMAL_GENL_EVENT_UNSPEC,  	THERMAL_GENL_EVENT_TZ_CREATE,		/* Thermal zone creation */  	THERMAL_GENL_EVENT_TZ_DELETE,		/* Thermal zone deletion */ -	THERMAL_GENL_EVENT_TZ_DISABLE,		/* Thermal zone disabed */ +	THERMAL_GENL_EVENT_TZ_DISABLE,		/* Thermal zone disabled */  	THERMAL_GENL_EVENT_TZ_ENABLE,		/* Thermal zone enabled */  	THERMAL_GENL_EVENT_TZ_TRIP_UP,		/* Trip point crossed the way up */  	THERMAL_GENL_EVENT_TZ_TRIP_DOWN,	/* Trip point crossed the way down */ @@ -71,6 +80,12 @@ enum thermal_genl_event {  	THERMAL_GENL_EVENT_CDEV_DELETE,		/* Cdev unbound */  	THERMAL_GENL_EVENT_CDEV_STATE_UPDATE,	/* Cdev state updated */  	THERMAL_GENL_EVENT_TZ_GOV_CHANGE,	/* Governor policy changed  */ +	THERMAL_GENL_EVENT_CPU_CAPABILITY_CHANGE,	/* CPU capability changed */ +	THERMAL_GENL_EVENT_THRESHOLD_ADD,	/* A thresold has been added */ +	THERMAL_GENL_EVENT_THRESHOLD_DELETE,	/* A thresold has been deleted */ +	THERMAL_GENL_EVENT_THRESHOLD_FLUSH,	/* All thresolds have been deleted */ +	THERMAL_GENL_EVENT_THRESHOLD_UP,	/* A thresold has been crossed the way up */ +	THERMAL_GENL_EVENT_THRESHOLD_DOWN,	/* A thresold has been crossed the way down */  	__THERMAL_GENL_EVENT_MAX,  };  #define THERMAL_GENL_EVENT_MAX (__THERMAL_GENL_EVENT_MAX - 1) @@ -78,12 +93,16 @@ enum thermal_genl_event {  /* Commands supported by the thermal_genl_family */  enum thermal_genl_cmd {  	THERMAL_GENL_CMD_UNSPEC, -	THERMAL_GENL_CMD_TZ_GET_ID,	/* List of thermal zones id */ -	THERMAL_GENL_CMD_TZ_GET_TRIP,	/* List of thermal trips */ -	THERMAL_GENL_CMD_TZ_GET_TEMP,	/* Get the thermal zone temperature */ -	THERMAL_GENL_CMD_TZ_GET_GOV,	/* Get the thermal zone governor */ -	THERMAL_GENL_CMD_TZ_GET_MODE,	/* Get the thermal zone mode */ -	THERMAL_GENL_CMD_CDEV_GET,	/* List of cdev id */ +	THERMAL_GENL_CMD_TZ_GET_ID,		/* List of thermal zones id */ +	THERMAL_GENL_CMD_TZ_GET_TRIP,		/* List of thermal trips */ +	THERMAL_GENL_CMD_TZ_GET_TEMP,		/* Get the thermal zone temperature */ +	THERMAL_GENL_CMD_TZ_GET_GOV,		/* Get the thermal zone governor */ +	THERMAL_GENL_CMD_TZ_GET_MODE,		/* Get the thermal zone mode */ +	THERMAL_GENL_CMD_CDEV_GET,		/* List of cdev id */ +	THERMAL_GENL_CMD_THRESHOLD_GET,		/* List of thresholds */ +	THERMAL_GENL_CMD_THRESHOLD_ADD,		/* Add a threshold */ +	THERMAL_GENL_CMD_THRESHOLD_DELETE,	/* Delete a threshold */ +	THERMAL_GENL_CMD_THRESHOLD_FLUSH,	/* Flush all the thresholds */  	__THERMAL_GENL_CMD_MAX,  };  #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1) diff --git a/include/uapi/linux/thp7312.h b/include/uapi/linux/thp7312.h new file mode 100644 index 000000000000..2b629e05daf9 --- /dev/null +++ b/include/uapi/linux/thp7312.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * THine THP7312 user space header file. + * + * Copyright (C) 2021 THine Electronics, Inc. + * Copyright (C) 2023 Ideas on Board Oy + */ + +#ifndef __UAPI_THP7312_H_ +#define __UAPI_THP7312_H_ + +#include <linux/v4l2-controls.h> + +#define V4L2_CID_THP7312_LOW_LIGHT_COMPENSATION		(V4L2_CID_USER_THP7312_BASE + 0x01) +#define V4L2_CID_THP7312_AUTO_FOCUS_METHOD		(V4L2_CID_USER_THP7312_BASE + 0x02) +#define V4L2_CID_THP7312_NOISE_REDUCTION_AUTO		(V4L2_CID_USER_THP7312_BASE + 0x03) +#define V4L2_CID_THP7312_NOISE_REDUCTION_ABSOLUTE	(V4L2_CID_USER_THP7312_BASE + 0x04) + +#endif /* __UAPI_THP7312_H_ */ diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h index 4f4b6e48e01c..16ca1ac206fd 100644 --- a/include/uapi/linux/time.h +++ b/include/uapi/linux/time.h @@ -64,6 +64,17 @@ struct timezone {  #define CLOCK_TAI			11  #define MAX_CLOCKS			16 + +/* + * AUX clock support. AUXiliary clocks are dynamically configured by + * enabling a clock ID. These clock can be steered independently of the + * core timekeeper. The kernel can support up to 8 auxiliary clocks, but + * the actual limit depends on eventual architecture constraints vs. VDSO. + */ +#define CLOCK_AUX			MAX_CLOCKS +#define MAX_AUX_CLOCKS			8 +#define CLOCK_AUX_LAST			(CLOCK_AUX + MAX_AUX_CLOCKS - 1) +  #define CLOCKS_MASK			(CLOCK_REALTIME | CLOCK_MONOTONIC)  #define CLOCKS_MONO			CLOCK_MONOTONIC diff --git a/include/uapi/linux/tiocl.h b/include/uapi/linux/tiocl.h index b32acc229024..88faba506c3d 100644 --- a/include/uapi/linux/tiocl.h +++ b/include/uapi/linux/tiocl.h @@ -36,5 +36,6 @@ struct tiocl_selection {  #define TIOCL_BLANKSCREEN	14	/* keep screen blank even if a key is pressed */  #define TIOCL_BLANKEDSCREEN	15	/* return which vt was blanked */  #define TIOCL_GETKMSGREDIRECT	17	/* get the vt the kernel messages are restricted to */ +#define TIOCL_GETBRACKETEDPASTE	18	/* get whether paste may be bracketed */  #endif /* _LINUX_TIOCL_H */ diff --git a/include/uapi/linux/tipc.h b/include/uapi/linux/tipc.h index add01db1daef..80ea15e12113 100644 --- a/include/uapi/linux/tipc.h +++ b/include/uapi/linux/tipc.h @@ -254,6 +254,8 @@ static inline int tipc_aead_key_size(struct tipc_aead_key *key)  	return sizeof(*key) + key->keylen;  } +#define TIPC_REKEYING_NOW		(~0U) +  /* The macros and functions below are deprecated:   */ diff --git a/include/uapi/linux/tipc_config.h b/include/uapi/linux/tipc_config.h index 4dfc05651c98..c00adf2fe868 100644 --- a/include/uapi/linux/tipc_config.h +++ b/include/uapi/linux/tipc_config.h @@ -43,10 +43,6 @@  #include <linux/tipc.h>  #include <asm/byteorder.h> -#ifndef __KERNEL__ -#include <arpa/inet.h> /* for ntohs etc. */ -#endif -  /*   * Configuration   * @@ -269,33 +265,33 @@ static inline int TLV_OK(const void *tlv, __u16 space)  	 */  	return (space >= TLV_SPACE(0)) && -		(ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space); +		(__be16_to_cpu(((struct tlv_desc *)tlv)->tlv_len) <= space);  }  static inline int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type)  {  	return TLV_OK(tlv, space) && -		(ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type); +		(__be16_to_cpu(((struct tlv_desc *)tlv)->tlv_type) == exp_type);  }  static inline int TLV_GET_LEN(struct tlv_desc *tlv)  { -	return ntohs(tlv->tlv_len); +	return __be16_to_cpu(tlv->tlv_len);  }  static inline void TLV_SET_LEN(struct tlv_desc *tlv, __u16 len)  { -	tlv->tlv_len = htons(len); +	tlv->tlv_len = __cpu_to_be16(len);  }  static inline int TLV_CHECK_TYPE(struct tlv_desc *tlv,  __u16 type)  { -	return (ntohs(tlv->tlv_type) == type); +	return (__be16_to_cpu(tlv->tlv_type) == type);  }  static inline void TLV_SET_TYPE(struct tlv_desc *tlv, __u16 type)  { -	tlv->tlv_type = htons(type); +	tlv->tlv_type = __cpu_to_be16(type);  }  static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len) @@ -305,8 +301,8 @@ static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)  	tlv_len = TLV_LENGTH(len);  	tlv_ptr = (struct tlv_desc *)tlv; -	tlv_ptr->tlv_type = htons(type); -	tlv_ptr->tlv_len  = htons(tlv_len); +	tlv_ptr->tlv_type = __cpu_to_be16(type); +	tlv_ptr->tlv_len  = __cpu_to_be16(tlv_len);  	if (len && data) {  		memcpy(TLV_DATA(tlv_ptr), data, len);  		memset((char *)TLV_DATA(tlv_ptr) + len, 0, TLV_SPACE(len) - tlv_len); @@ -348,7 +344,7 @@ static inline void *TLV_LIST_DATA(struct tlv_list_desc *list)  static inline void TLV_LIST_STEP(struct tlv_list_desc *list)  { -	__u16 tlv_space = TLV_ALIGN(ntohs(list->tlv_ptr->tlv_len)); +	__u16 tlv_space = TLV_ALIGN(__be16_to_cpu(list->tlv_ptr->tlv_len));  	list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space);  	list->tlv_space -= tlv_space; @@ -404,9 +400,9 @@ static inline int TCM_SET(void *msg, __u16 cmd, __u16 flags,  	msg_len = TCM_LENGTH(data_len);  	tcm_hdr = (struct tipc_cfg_msg_hdr *)msg; -	tcm_hdr->tcm_len   = htonl(msg_len); -	tcm_hdr->tcm_type  = htons(cmd); -	tcm_hdr->tcm_flags = htons(flags); +	tcm_hdr->tcm_len   = __cpu_to_be32(msg_len); +	tcm_hdr->tcm_type  = __cpu_to_be16(cmd); +	tcm_hdr->tcm_flags = __cpu_to_be16(flags);  	if (data_len && data) {  		memcpy(TCM_DATA(msg), data, data_len);  		memset((char *)TCM_DATA(msg) + data_len, 0, TCM_SPACE(data_len) - msg_len); diff --git a/include/uapi/linux/tipc_netlink.h b/include/uapi/linux/tipc_netlink.h index dc0d23a50e69..d847dd671d79 100644 --- a/include/uapi/linux/tipc_netlink.h +++ b/include/uapi/linux/tipc_netlink.h @@ -165,6 +165,8 @@ enum {  	TIPC_NLA_NODE_UP,		/* flag */  	TIPC_NLA_NODE_ID,		/* data */  	TIPC_NLA_NODE_KEY,		/* data */ +	TIPC_NLA_NODE_KEY_MASTER,	/* flag */ +	TIPC_NLA_NODE_REKEYING,		/* u32 */  	__TIPC_NLA_NODE_MAX,  	TIPC_NLA_NODE_MAX = __TIPC_NLA_NODE_MAX - 1 diff --git a/include/uapi/linux/tls.h b/include/uapi/linux/tls.h index bcd2869ed472..b66a800389cc 100644 --- a/include/uapi/linux/tls.h +++ b/include/uapi/linux/tls.h @@ -39,6 +39,8 @@  /* TLS socket options */  #define TLS_TX			1	/* Set transmit parameters */  #define TLS_RX			2	/* Set receive parameters */ +#define TLS_TX_ZEROCOPY_RO	3	/* TX zerocopy (only sendfile now) */ +#define TLS_RX_EXPECT_NO_PAD	4	/* Attempt opportunistic zero-copy */  /* Supported versions */  #define TLS_VERSION_MINOR(ver)	((ver) & 0xFF) @@ -77,6 +79,41 @@  #define TLS_CIPHER_AES_CCM_128_TAG_SIZE		16  #define TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE		8 +#define TLS_CIPHER_CHACHA20_POLY1305			54 +#define TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE		12 +#define TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE	32 +#define TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE		0 +#define TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE	16 +#define TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE	8 + +#define TLS_CIPHER_SM4_GCM				55 +#define TLS_CIPHER_SM4_GCM_IV_SIZE			8 +#define TLS_CIPHER_SM4_GCM_KEY_SIZE		16 +#define TLS_CIPHER_SM4_GCM_SALT_SIZE		4 +#define TLS_CIPHER_SM4_GCM_TAG_SIZE		16 +#define TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE		8 + +#define TLS_CIPHER_SM4_CCM				56 +#define TLS_CIPHER_SM4_CCM_IV_SIZE			8 +#define TLS_CIPHER_SM4_CCM_KEY_SIZE		16 +#define TLS_CIPHER_SM4_CCM_SALT_SIZE		4 +#define TLS_CIPHER_SM4_CCM_TAG_SIZE		16 +#define TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE		8 + +#define TLS_CIPHER_ARIA_GCM_128				57 +#define TLS_CIPHER_ARIA_GCM_128_IV_SIZE			8 +#define TLS_CIPHER_ARIA_GCM_128_KEY_SIZE		16 +#define TLS_CIPHER_ARIA_GCM_128_SALT_SIZE		4 +#define TLS_CIPHER_ARIA_GCM_128_TAG_SIZE		16 +#define TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE		8 + +#define TLS_CIPHER_ARIA_GCM_256				58 +#define TLS_CIPHER_ARIA_GCM_256_IV_SIZE			8 +#define TLS_CIPHER_ARIA_GCM_256_KEY_SIZE		32 +#define TLS_CIPHER_ARIA_GCM_256_SALT_SIZE		4 +#define TLS_CIPHER_ARIA_GCM_256_TAG_SIZE		16 +#define TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE		8 +  #define TLS_SET_RECORD_TYPE	1  #define TLS_GET_RECORD_TYPE	2 @@ -109,12 +146,54 @@ struct tls12_crypto_info_aes_ccm_128 {  	unsigned char rec_seq[TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE];  }; +struct tls12_crypto_info_chacha20_poly1305 { +	struct tls_crypto_info info; +	unsigned char iv[TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE]; +	unsigned char key[TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE]; +	unsigned char salt[TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE]; +	unsigned char rec_seq[TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE]; +}; + +struct tls12_crypto_info_sm4_gcm { +	struct tls_crypto_info info; +	unsigned char iv[TLS_CIPHER_SM4_GCM_IV_SIZE]; +	unsigned char key[TLS_CIPHER_SM4_GCM_KEY_SIZE]; +	unsigned char salt[TLS_CIPHER_SM4_GCM_SALT_SIZE]; +	unsigned char rec_seq[TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE]; +}; + +struct tls12_crypto_info_sm4_ccm { +	struct tls_crypto_info info; +	unsigned char iv[TLS_CIPHER_SM4_CCM_IV_SIZE]; +	unsigned char key[TLS_CIPHER_SM4_CCM_KEY_SIZE]; +	unsigned char salt[TLS_CIPHER_SM4_CCM_SALT_SIZE]; +	unsigned char rec_seq[TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE]; +}; + +struct tls12_crypto_info_aria_gcm_128 { +	struct tls_crypto_info info; +	unsigned char iv[TLS_CIPHER_ARIA_GCM_128_IV_SIZE]; +	unsigned char key[TLS_CIPHER_ARIA_GCM_128_KEY_SIZE]; +	unsigned char salt[TLS_CIPHER_ARIA_GCM_128_SALT_SIZE]; +	unsigned char rec_seq[TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE]; +}; + +struct tls12_crypto_info_aria_gcm_256 { +	struct tls_crypto_info info; +	unsigned char iv[TLS_CIPHER_ARIA_GCM_256_IV_SIZE]; +	unsigned char key[TLS_CIPHER_ARIA_GCM_256_KEY_SIZE]; +	unsigned char salt[TLS_CIPHER_ARIA_GCM_256_SALT_SIZE]; +	unsigned char rec_seq[TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE]; +}; +  enum {  	TLS_INFO_UNSPEC,  	TLS_INFO_VERSION,  	TLS_INFO_CIPHER,  	TLS_INFO_TXCONF,  	TLS_INFO_RXCONF, +	TLS_INFO_ZC_RO_TX, +	TLS_INFO_RX_NO_PAD,  	__TLS_INFO_MAX,  };  #define TLS_INFO_MAX (__TLS_INFO_MAX - 1) diff --git a/include/uapi/linux/tps6594_pfsm.h b/include/uapi/linux/tps6594_pfsm.h new file mode 100644 index 000000000000..c69569e0a7a2 --- /dev/null +++ b/include/uapi/linux/tps6594_pfsm.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Userspace ABI for TPS6594 PMIC Pre-configurable Finite State Machine + * + * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/ + */ + +#ifndef __TPS6594_PFSM_H +#define __TPS6594_PFSM_H + +#include <linux/const.h> +#include <linux/ioctl.h> +#include <linux/types.h> + +/** + * struct pmic_state_opt - PMIC state options + * @gpio_retention: if enabled, power rails associated with GPIO retention remain active + * @ddr_retention: if enabled, power rails associated with DDR retention remain active + * @mcu_only_startup_dest: if enabled, startup destination state is MCU_ONLY + */ +struct pmic_state_opt { +	__u8 gpio_retention; +	__u8 ddr_retention; +	__u8 mcu_only_startup_dest; +}; + +/* Commands */ +#define PMIC_BASE			'P' + +#define PMIC_GOTO_STANDBY		_IO(PMIC_BASE, 0) +#define PMIC_GOTO_LP_STANDBY		_IO(PMIC_BASE, 1) +#define PMIC_UPDATE_PGM			_IO(PMIC_BASE, 2) +#define PMIC_SET_ACTIVE_STATE		_IO(PMIC_BASE, 3) +#define PMIC_SET_MCU_ONLY_STATE		_IOW(PMIC_BASE, 4, struct pmic_state_opt) +#define PMIC_SET_RETENTION_STATE	_IOW(PMIC_BASE, 5, struct pmic_state_opt) + +#endif /*  __TPS6594_PFSM_H */ diff --git a/include/uapi/linux/trace_mmap.h b/include/uapi/linux/trace_mmap.h new file mode 100644 index 000000000000..c102ef35d11e --- /dev/null +++ b/include/uapi/linux/trace_mmap.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _TRACE_MMAP_H_ +#define _TRACE_MMAP_H_ + +#include <linux/types.h> + +/** + * struct trace_buffer_meta - Ring-buffer Meta-page description + * @meta_page_size:	Size of this meta-page. + * @meta_struct_len:	Size of this structure. + * @subbuf_size:	Size of each sub-buffer. + * @nr_subbufs:		Number of subbfs in the ring-buffer, including the reader. + * @reader.lost_events:	Number of events lost at the time of the reader swap. + * @reader.id:		subbuf ID of the current reader. ID range [0 : @nr_subbufs - 1] + * @reader.read:	Number of bytes read on the reader subbuf. + * @flags:		Placeholder for now, 0 until new features are supported. + * @entries:		Number of entries in the ring-buffer. + * @overrun:		Number of entries lost in the ring-buffer. + * @read:		Number of entries that have been read. + * @Reserved1:		Internal use only. + * @Reserved2:		Internal use only. + */ +struct trace_buffer_meta { +	__u32		meta_page_size; +	__u32		meta_struct_len; + +	__u32		subbuf_size; +	__u32		nr_subbufs; + +	struct { +		__u64	lost_events; +		__u32	id; +		__u32	read; +	} reader; + +	__u64	flags; + +	__u64	entries; +	__u64	overrun; +	__u64	read; + +	__u64	Reserved1; +	__u64	Reserved2; +}; + +#define TRACE_MMAP_IOCTL_GET_READER		_IO('R', 0x20) + +#endif /* _TRACE_MMAP_H_ */ diff --git a/include/uapi/linux/tty.h b/include/uapi/linux/tty.h index 376cccf397be..68aeae2addec 100644 --- a/include/uapi/linux/tty.h +++ b/include/uapi/linux/tty.h @@ -6,8 +6,6 @@   * 'tty.h' defines some structures used by tty_io.c and some defines.   */ -#define NR_LDISCS		30 -  /* line disciplines */  #define N_TTY		0  #define N_SLIP		1 @@ -38,5 +36,11 @@  #define N_NCI		25	/* NFC NCI UART */  #define N_SPEAKUP	26	/* Speakup communication with synths */  #define N_NULL		27	/* Null ldisc used for error handling */ +#define N_MCTP		28	/* MCTP-over-serial */ +#define N_DEVELOPMENT	29	/* Manual out-of-tree testing */ +#define N_CAN327	30	/* ELM327 based OBD-II interfaces */ + +/* Always the newest line discipline + 1 */ +#define NR_LDISCS	31  #endif /* _UAPI_LINUX_TTY_H */ diff --git a/include/uapi/linux/tty_flags.h b/include/uapi/linux/tty_flags.h index 900a32e63424..cf25056d4b27 100644 --- a/include/uapi/linux/tty_flags.h +++ b/include/uapi/linux/tty_flags.h @@ -39,7 +39,7 @@   * WARNING: These flags are no longer used and have been superceded by the   *	    TTY_PORT_ flags in the iflags field (and not userspace-visible)   */ -#ifndef _KERNEL_ +#ifndef __KERNEL__  #define ASYNCB_INITIALIZED	31 /* Serial port was initialized */  #define ASYNCB_SUSPENDED	30 /* Serial port is suspended */  #define ASYNCB_NORMAL_ACTIVE	29 /* Normal device is active */ @@ -73,15 +73,15 @@  #define ASYNC_MAGIC_MULTIPLIER	(1U << ASYNCB_MAGIC_MULTIPLIER)  #define ASYNC_FLAGS		((1U << (ASYNCB_LAST_USER + 1)) - 1) -#define ASYNC_DEPRECATED	(ASYNC_SESSION_LOCKOUT | ASYNC_PGRP_LOCKOUT | \ -		ASYNC_CALLOUT_NOHUP | ASYNC_AUTOPROBE) +#define ASYNC_DEPRECATED	(ASYNC_SPLIT_TERMIOS | ASYNC_SESSION_LOCKOUT | \ +		ASYNC_PGRP_LOCKOUT | ASYNC_CALLOUT_NOHUP | ASYNC_AUTOPROBE)  #define ASYNC_USR_MASK		(ASYNC_SPD_MASK|ASYNC_CALLOUT_NOHUP| \  		ASYNC_LOW_LATENCY)  #define ASYNC_SPD_CUST		(ASYNC_SPD_HI|ASYNC_SPD_VHI)  #define ASYNC_SPD_WARP		(ASYNC_SPD_HI|ASYNC_SPD_SHI)  #define ASYNC_SPD_MASK		(ASYNC_SPD_HI|ASYNC_SPD_VHI|ASYNC_SPD_SHI) -#ifndef _KERNEL_ +#ifndef __KERNEL__  /* These flags are no longer used (and were always masked from userspace) */  #define ASYNC_INITIALIZED	(1U << ASYNCB_INITIALIZED)  #define ASYNC_NORMAL_ACTIVE	(1U << ASYNCB_NORMAL_ACTIVE) diff --git a/include/uapi/linux/types.h b/include/uapi/linux/types.h index f6d2f83cbe29..48b933938877 100644 --- a/include/uapi/linux/types.h +++ b/include/uapi/linux/types.h @@ -13,18 +13,25 @@  #include <linux/posix_types.h> +#ifdef __SIZEOF_INT128__ +typedef __signed__ __int128 __s128 __attribute__((aligned(16))); +typedef unsigned __int128 __u128 __attribute__((aligned(16))); +#endif  /*   * Below are truly Linux-specific types that should never collide with   * any application/library that wants linux/types.h.   */ +/* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */  #ifdef __CHECKER__ -#define __bitwise__ __attribute__((bitwise)) +#define __bitwise	__attribute__((bitwise))  #else -#define __bitwise__ +#define __bitwise  #endif -#define __bitwise __bitwise__ + +/* The kernel doesn't use this legacy form, but user space does */ +#define __bitwise__ __bitwise  typedef __u16 __bitwise __le16;  typedef __u16 __bitwise __be16; @@ -46,6 +53,7 @@ typedef __u32 __bitwise __wsum;   * No conversions are necessary between 32-bit user-space and a 64-bit kernel.   */  #define __aligned_u64 __u64 __attribute__((aligned(8))) +#define __aligned_s64 __s64 __attribute__((aligned(8)))  #define __aligned_be64 __be64 __attribute__((aligned(8)))  #define __aligned_le64 __le64 __attribute__((aligned(8))) diff --git a/include/uapi/linux/ublk_cmd.h b/include/uapi/linux/ublk_cmd.h new file mode 100644 index 000000000000..ec77dabba45b --- /dev/null +++ b/include/uapi/linux/ublk_cmd.h @@ -0,0 +1,627 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef USER_BLK_DRV_CMD_INC_H +#define USER_BLK_DRV_CMD_INC_H + +#include <linux/types.h> + +/* ublk server command definition */ + +/* + * Admin commands, issued by ublk server, and handled by ublk driver. + * + * Legacy command definition, don't use in new application, and don't + * add new such definition any more + */ +#define	UBLK_CMD_GET_QUEUE_AFFINITY	0x01 +#define	UBLK_CMD_GET_DEV_INFO	0x02 +#define	UBLK_CMD_ADD_DEV		0x04 +#define	UBLK_CMD_DEL_DEV		0x05 +#define	UBLK_CMD_START_DEV	0x06 +#define	UBLK_CMD_STOP_DEV	0x07 +#define	UBLK_CMD_SET_PARAMS	0x08 +#define	UBLK_CMD_GET_PARAMS	0x09 +#define	UBLK_CMD_START_USER_RECOVERY	0x10 +#define	UBLK_CMD_END_USER_RECOVERY	0x11 +#define	UBLK_CMD_GET_DEV_INFO2		0x12 + +/* Any new ctrl command should encode by __IO*() */ +#define UBLK_U_CMD_GET_QUEUE_AFFINITY	\ +	_IOR('u', UBLK_CMD_GET_QUEUE_AFFINITY, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_GET_DEV_INFO		\ +	_IOR('u', UBLK_CMD_GET_DEV_INFO, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_ADD_DEV		\ +	_IOWR('u', UBLK_CMD_ADD_DEV, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_DEL_DEV		\ +	_IOWR('u', UBLK_CMD_DEL_DEV, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_START_DEV		\ +	_IOWR('u', UBLK_CMD_START_DEV, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_STOP_DEV		\ +	_IOWR('u', UBLK_CMD_STOP_DEV, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_SET_PARAMS		\ +	_IOWR('u', UBLK_CMD_SET_PARAMS, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_GET_PARAMS		\ +	_IOR('u', UBLK_CMD_GET_PARAMS, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_START_USER_RECOVERY	\ +	_IOWR('u', UBLK_CMD_START_USER_RECOVERY, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_END_USER_RECOVERY	\ +	_IOWR('u', UBLK_CMD_END_USER_RECOVERY, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_GET_DEV_INFO2	\ +	_IOR('u', UBLK_CMD_GET_DEV_INFO2, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_GET_FEATURES	\ +	_IOR('u', 0x13, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_DEL_DEV_ASYNC	\ +	_IOR('u', 0x14, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_UPDATE_SIZE		\ +	_IOWR('u', 0x15, struct ublksrv_ctrl_cmd) +#define UBLK_U_CMD_QUIESCE_DEV		\ +	_IOWR('u', 0x16, struct ublksrv_ctrl_cmd) + +/* + * 64bits are enough now, and it should be easy to extend in case of + * running out of feature flags + */ +#define UBLK_FEATURES_LEN  8 + +/* + * IO commands, issued by ublk server, and handled by ublk driver. + * + * FETCH_REQ: issued via sqe(URING_CMD) beforehand for fetching IO request + *      from ublk driver, should be issued only when starting device. After + *      the associated cqe is returned, request's tag can be retrieved via + *      cqe->userdata. + * + * COMMIT_AND_FETCH_REQ: issued via sqe(URING_CMD) after ublkserver handled + *      this IO request, request's handling result is committed to ublk + *      driver, meantime FETCH_REQ is piggyback, and FETCH_REQ has to be + *      handled before completing io request. + * + * NEED_GET_DATA: only used for write requests to set io addr and copy data + *      When NEED_GET_DATA is set, ublksrv has to issue UBLK_IO_NEED_GET_DATA + *      command after ublk driver returns UBLK_IO_RES_NEED_GET_DATA. + * + *      It is only used if ublksrv set UBLK_F_NEED_GET_DATA flag + *      while starting a ublk device. + */ + +/* + * Legacy IO command definition, don't use in new application, and don't + * add new such definition any more + */ +#define	UBLK_IO_FETCH_REQ		0x20 +#define	UBLK_IO_COMMIT_AND_FETCH_REQ	0x21 +#define	UBLK_IO_NEED_GET_DATA	0x22 + +/* Any new IO command should encode by __IOWR() */ +#define	UBLK_U_IO_FETCH_REQ		\ +	_IOWR('u', UBLK_IO_FETCH_REQ, struct ublksrv_io_cmd) +#define	UBLK_U_IO_COMMIT_AND_FETCH_REQ	\ +	_IOWR('u', UBLK_IO_COMMIT_AND_FETCH_REQ, struct ublksrv_io_cmd) +#define	UBLK_U_IO_NEED_GET_DATA		\ +	_IOWR('u', UBLK_IO_NEED_GET_DATA, struct ublksrv_io_cmd) +#define	UBLK_U_IO_REGISTER_IO_BUF	\ +	_IOWR('u', 0x23, struct ublksrv_io_cmd) +#define	UBLK_U_IO_UNREGISTER_IO_BUF	\ +	_IOWR('u', 0x24, struct ublksrv_io_cmd) + +/* only ABORT means that no re-fetch */ +#define UBLK_IO_RES_OK			0 +#define UBLK_IO_RES_NEED_GET_DATA	1 +#define UBLK_IO_RES_ABORT		(-ENODEV) + +#define UBLKSRV_CMD_BUF_OFFSET	0 +#define UBLKSRV_IO_BUF_OFFSET	0x80000000 + +/* tag bit is 16bit, so far limit at most 4096 IOs for each queue */ +#define UBLK_MAX_QUEUE_DEPTH	4096 + +/* single IO buffer max size is 32MB */ +#define UBLK_IO_BUF_OFF		0 +#define UBLK_IO_BUF_BITS	25 +#define UBLK_IO_BUF_BITS_MASK	((1ULL << UBLK_IO_BUF_BITS) - 1) + +/* so at most 64K IOs for each queue */ +#define UBLK_TAG_OFF		UBLK_IO_BUF_BITS +#define UBLK_TAG_BITS		16 +#define UBLK_TAG_BITS_MASK	((1ULL << UBLK_TAG_BITS) - 1) + +/* max 4096 queues */ +#define UBLK_QID_OFF		(UBLK_TAG_OFF + UBLK_TAG_BITS) +#define UBLK_QID_BITS		12 +#define UBLK_QID_BITS_MASK	((1ULL << UBLK_QID_BITS) - 1) + +#define UBLK_MAX_NR_QUEUES	(1U << UBLK_QID_BITS) + +#define UBLKSRV_IO_BUF_TOTAL_BITS	(UBLK_QID_OFF + UBLK_QID_BITS) +#define UBLKSRV_IO_BUF_TOTAL_SIZE	(1ULL << UBLKSRV_IO_BUF_TOTAL_BITS) + +/* + * ublk server can register data buffers for incoming I/O requests with a sparse + * io_uring buffer table. The request buffer can then be used as the data buffer + * for io_uring operations via the fixed buffer index. + * Note that the ublk server can never directly access the request data memory. + * + * To use this feature, the ublk server must first register a sparse buffer + * table on an io_uring instance. + * When an incoming ublk request is received, the ublk server submits a + * UBLK_U_IO_REGISTER_IO_BUF command to that io_uring instance. The + * ublksrv_io_cmd's q_id and tag specify the request whose buffer to register + * and addr is the index in the io_uring's buffer table to install the buffer. + * SQEs can now be submitted to the io_uring to read/write the request's buffer + * by enabling fixed buffers (e.g. using IORING_OP_{READ,WRITE}_FIXED or + * IORING_URING_CMD_FIXED) and passing the registered buffer index in buf_index. + * Once the last io_uring operation using the request's buffer has completed, + * the ublk server submits a UBLK_U_IO_UNREGISTER_IO_BUF command with q_id, tag, + * and addr again specifying the request buffer to unregister. + * The ublk request is completed when its buffer is unregistered from all + * io_uring instances and the ublk server issues UBLK_U_IO_COMMIT_AND_FETCH_REQ. + * + * Not available for UBLK_F_UNPRIVILEGED_DEV, as a ublk server can leak + * uninitialized kernel memory by not reading into the full request buffer. + */ +#define UBLK_F_SUPPORT_ZERO_COPY	(1ULL << 0) + +/* + * Force to complete io cmd via io_uring_cmd_complete_in_task so that + * performance comparison is done easily with using task_work_add + */ +#define UBLK_F_URING_CMD_COMP_IN_TASK	(1ULL << 1) + +/* + * User should issue io cmd again for write requests to + * set io buffer address and copy data from bio vectors + * to the userspace io buffer. + * + * In this mode, task_work is not used. + */ +#define UBLK_F_NEED_GET_DATA (1UL << 2) + +/* + * - Block devices are recoverable if ublk server exits and restarts + * - Outstanding I/O when ublk server exits is met with errors + * - I/O issued while there is no ublk server queues + */ +#define UBLK_F_USER_RECOVERY	(1UL << 3) + +/* + * - Block devices are recoverable if ublk server exits and restarts + * - Outstanding I/O when ublk server exits is reissued + * - I/O issued while there is no ublk server queues + */ +#define UBLK_F_USER_RECOVERY_REISSUE	(1UL << 4) + +/* + * Unprivileged user can create /dev/ublkcN and /dev/ublkbN. + * + * /dev/ublk-control needs to be available for unprivileged user, and it + * can be done via udev rule to make all control commands available to + * unprivileged user. Except for the command of UBLK_CMD_ADD_DEV, all + * other commands are only allowed for the owner of the specified device. + * + * When userspace sends UBLK_CMD_ADD_DEV, the device pair's owner_uid and + * owner_gid are stored to ublksrv_ctrl_dev_info by kernel, so far only + * the current user's uid/gid is stored, that said owner of the created + * device is always the current user. + * + * We still need udev rule to apply OWNER/GROUP with the stored owner_uid + * and owner_gid. + * + * Then ublk server can be run as unprivileged user, and /dev/ublkbN can + * be accessed and managed by its owner represented by owner_uid/owner_gid. + */ +#define UBLK_F_UNPRIVILEGED_DEV	(1UL << 5) + +/* use ioctl encoding for uring command */ +#define UBLK_F_CMD_IOCTL_ENCODE	(1UL << 6) + +/* + *  Copy between request and user buffer by pread()/pwrite() + * + *  Not available for UBLK_F_UNPRIVILEGED_DEV, otherwise userspace may + *  deceive us by not filling request buffer, then kernel uninitialized + *  data may be leaked. + */ +#define UBLK_F_USER_COPY	(1UL << 7) + +/* + * User space sets this flag when setting up the device to request zoned storage support. Kernel may + * deny the request by returning an error. + */ +#define UBLK_F_ZONED (1ULL << 8) + +/* + * - Block devices are recoverable if ublk server exits and restarts + * - Outstanding I/O when ublk server exits is met with errors + * - I/O issued while there is no ublk server is met with errors + */ +#define UBLK_F_USER_RECOVERY_FAIL_IO (1ULL << 9) + +/* + * Resizing a block device is possible with UBLK_U_CMD_UPDATE_SIZE + * New size is passed in cmd->data[0] and is in units of sectors + */ +#define UBLK_F_UPDATE_SIZE		 (1ULL << 10) + +/* + * request buffer is registered automatically to uring_cmd's io_uring + * context before delivering this io command to ublk server, meantime + * it is un-registered automatically when completing this io command. + * + * For using this feature: + * + * - ublk server has to create sparse buffer table on the same `io_ring_ctx` + *   for issuing `UBLK_IO_FETCH_REQ` and `UBLK_IO_COMMIT_AND_FETCH_REQ`. + *   If uring_cmd isn't issued on same `io_ring_ctx`, it is ublk server's + *   responsibility to unregister the buffer by issuing `IO_UNREGISTER_IO_BUF` + *   manually, otherwise this ublk request won't complete. + * + * - ublk server passes auto buf register data via uring_cmd's sqe->addr, + *   `struct ublk_auto_buf_reg` is populated from sqe->addr, please see + *   the definition of ublk_sqe_addr_to_auto_buf_reg() + * + * - pass buffer index from `ublk_auto_buf_reg.index` + * + * - all reserved fields in `ublk_auto_buf_reg` need to be zeroed + * + * - pass flags from `ublk_auto_buf_reg.flags` if needed + * + * This way avoids extra cost from two uring_cmd, but also simplifies backend + * implementation, such as, the dependency on IO_REGISTER_IO_BUF and + * IO_UNREGISTER_IO_BUF becomes not necessary. + * + * If wrong data or flags are provided, both IO_FETCH_REQ and + * IO_COMMIT_AND_FETCH_REQ are failed, for the latter, the ublk IO request + * won't be completed until new IO_COMMIT_AND_FETCH_REQ command is issued + * successfully + */ +#define UBLK_F_AUTO_BUF_REG 	(1ULL << 11) + +/* + * Control command `UBLK_U_CMD_QUIESCE_DEV` is added for quiescing device, + * which state can be transitioned to `UBLK_S_DEV_QUIESCED` or + * `UBLK_S_DEV_FAIL_IO` finally, and it needs ublk server cooperation for + * handling `UBLK_IO_RES_ABORT` correctly. + * + * Typical use case is for supporting to upgrade ublk server application, + * meantime keep ublk block device persistent during the period. + * + * This feature is only available when UBLK_F_USER_RECOVERY is enabled. + * + * Note, this command returns -EBUSY in case that all IO commands are being + * handled by ublk server and not completed in specified time period which + * is passed from the control command parameter. + */ +#define UBLK_F_QUIESCE		(1ULL << 12) + +/* + * If this feature is set, ublk_drv supports each (qid,tag) pair having + * its own independent daemon task that is responsible for handling it. + * If it is not set, daemons are per-queue instead, so for two pairs + * (qid1,tag1) and (qid2,tag2), if qid1 == qid2, then the same task must + * be responsible for handling (qid1,tag1) and (qid2,tag2). + */ +#define UBLK_F_PER_IO_DAEMON (1ULL << 13) + +/* + * If this feature is set, UBLK_U_IO_REGISTER_IO_BUF/UBLK_U_IO_UNREGISTER_IO_BUF + * can be issued for an I/O on any task. q_id and tag are also ignored in + * UBLK_U_IO_UNREGISTER_IO_BUF's ublksrv_io_cmd. + * If it is unset, zero-copy buffers can only be registered and unregistered by + * the I/O's daemon task. The q_id and tag of the registered buffer are required + * in UBLK_U_IO_UNREGISTER_IO_BUF's ublksrv_io_cmd. + */ +#define UBLK_F_BUF_REG_OFF_DAEMON (1ULL << 14) + +/* device state */ +#define UBLK_S_DEV_DEAD	0 +#define UBLK_S_DEV_LIVE	1 +#define UBLK_S_DEV_QUIESCED	2 +#define UBLK_S_DEV_FAIL_IO 	3 + +/* shipped via sqe->cmd of io_uring command */ +struct ublksrv_ctrl_cmd { +	/* sent to which device, must be valid */ +	__u32	dev_id; + +	/* sent to which queue, must be -1 if the cmd isn't for queue */ +	__u16	queue_id; +	/* +	 * cmd specific buffer, can be IN or OUT. +	 */ +	__u16	len; +	__u64	addr; + +	/* inline data */ +	__u64	data[1]; + +	/* +	 * Used for UBLK_F_UNPRIVILEGED_DEV and UBLK_CMD_GET_DEV_INFO2 +	 * only, include null char +	 */ +	__u16	dev_path_len; +	__u16	pad; +	__u32	reserved; +}; + +struct ublksrv_ctrl_dev_info { +	__u16	nr_hw_queues; +	__u16	queue_depth; +	__u16	state; +	__u16	pad0; + +	__u32	max_io_buf_bytes; +	__u32	dev_id; + +	__s32	ublksrv_pid; +	__u32	pad1; + +	__u64	flags; + +	/* For ublksrv internal use, invisible to ublk driver */ +	__u64	ublksrv_flags; + +	__u32	owner_uid;	/* store by kernel */ +	__u32	owner_gid;	/* store by kernel */ +	__u64	reserved1; +	__u64   reserved2; +}; + +#define		UBLK_IO_OP_READ		0 +#define		UBLK_IO_OP_WRITE		1 +#define		UBLK_IO_OP_FLUSH		2 +#define		UBLK_IO_OP_DISCARD		3 +#define		UBLK_IO_OP_WRITE_SAME		4 +#define		UBLK_IO_OP_WRITE_ZEROES		5 +#define		UBLK_IO_OP_ZONE_OPEN		10 +#define		UBLK_IO_OP_ZONE_CLOSE		11 +#define		UBLK_IO_OP_ZONE_FINISH		12 +#define		UBLK_IO_OP_ZONE_APPEND		13 +#define		UBLK_IO_OP_ZONE_RESET_ALL	14 +#define		UBLK_IO_OP_ZONE_RESET		15 +/* + * Construct a zone report. The report request is carried in `struct + * ublksrv_io_desc`. The `start_sector` field must be the first sector of a zone + * and shall indicate the first zone of the report. The `nr_zones` shall + * indicate how many zones should be reported at most. The report shall be + * delivered as a `struct blk_zone` array. To report fewer zones than requested, + * zero the last entry of the returned array. + * + * Related definitions(blk_zone, blk_zone_cond, blk_zone_type, ...) in + * include/uapi/linux/blkzoned.h are part of ublk UAPI. + */ +#define		UBLK_IO_OP_REPORT_ZONES		18 + +#define		UBLK_IO_F_FAILFAST_DEV		(1U << 8) +#define		UBLK_IO_F_FAILFAST_TRANSPORT	(1U << 9) +#define		UBLK_IO_F_FAILFAST_DRIVER	(1U << 10) +#define		UBLK_IO_F_META			(1U << 11) +#define		UBLK_IO_F_FUA			(1U << 13) +#define		UBLK_IO_F_NOUNMAP		(1U << 15) +#define		UBLK_IO_F_SWAP			(1U << 16) +/* + * For UBLK_F_AUTO_BUF_REG & UBLK_AUTO_BUF_REG_FALLBACK only. + * + * This flag is set if auto buffer register is failed & ublk server passes + * UBLK_AUTO_BUF_REG_FALLBACK, and ublk server need to register buffer + * manually for handling the delivered IO command if this flag is observed + * + * ublk server has to check this flag if UBLK_AUTO_BUF_REG_FALLBACK is + * passed in. + */ +#define		UBLK_IO_F_NEED_REG_BUF		(1U << 17) + +/* + * io cmd is described by this structure, and stored in share memory, indexed + * by request tag. + * + * The data is stored by ublk driver, and read by ublksrv after one fetch command + * returns. + */ +struct ublksrv_io_desc { +	/* op: bit 0-7, flags: bit 8-31 */ +	__u32		op_flags; + +	union { +		__u32		nr_sectors; +		__u32		nr_zones; /* for UBLK_IO_OP_REPORT_ZONES */ +	}; + +	/* start sector for this io */ +	__u64		start_sector; + +	/* buffer address in ublksrv daemon vm space, from ublk driver */ +	__u64		addr; +}; + +static inline __u8 ublksrv_get_op(const struct ublksrv_io_desc *iod) +{ +	return iod->op_flags & 0xff; +} + +static inline __u32 ublksrv_get_flags(const struct ublksrv_io_desc *iod) +{ +	return iod->op_flags >> 8; +} + +/* + * If this flag is set, fallback by completing the uring_cmd and setting + * `UBLK_IO_F_NEED_REG_BUF` in case of auto-buf-register failure; + * otherwise the client ublk request is failed silently + * + * If ublk server passes this flag, it has to check if UBLK_IO_F_NEED_REG_BUF + * is set in `ublksrv_io_desc.op_flags`. If UBLK_IO_F_NEED_REG_BUF is set, + * ublk server needs to register io buffer manually for handling IO command. + */ +#define UBLK_AUTO_BUF_REG_FALLBACK 	(1 << 0) +#define UBLK_AUTO_BUF_REG_F_MASK 	UBLK_AUTO_BUF_REG_FALLBACK + +struct ublk_auto_buf_reg { +	/* index for registering the delivered request buffer */ +	__u16  index; +	__u8   flags; +	__u8   reserved0; + +	/* +	 * io_ring FD can be passed via the reserve field in future for +	 * supporting to register io buffer to external io_uring +	 */ +	__u32  reserved1; +}; + +/* + * For UBLK_F_AUTO_BUF_REG, auto buffer register data is carried via + * uring_cmd's sqe->addr: + * + * 	- bit0 ~ bit15: buffer index + * 	- bit16 ~ bit23: flags + * 	- bit24 ~ bit31: reserved0 + * 	- bit32 ~ bit63: reserved1 + */ +static inline struct ublk_auto_buf_reg ublk_sqe_addr_to_auto_buf_reg( +		__u64 sqe_addr) +{ +	struct ublk_auto_buf_reg reg = { +		.index = (__u16)sqe_addr, +		.flags = (__u8)(sqe_addr >> 16), +		.reserved0 = (__u8)(sqe_addr >> 24), +		.reserved1 = (__u32)(sqe_addr >> 32), +	}; + +	return reg; +} + +static inline __u64 +ublk_auto_buf_reg_to_sqe_addr(const struct ublk_auto_buf_reg *buf) +{ +	__u64 addr = buf->index | (__u64)buf->flags << 16 | (__u64)buf->reserved0 << 24 | +		(__u64)buf->reserved1 << 32; + +	return addr; +} + +/* issued to ublk driver via /dev/ublkcN */ +struct ublksrv_io_cmd { +	__u16	q_id; + +	/* for fetch/commit which result */ +	__u16	tag; + +	/* io result, it is valid for COMMIT* command only */ +	__s32	result; + +	union { +		/* +		 * userspace buffer address in ublksrv daemon process, valid for +		 * FETCH* command only +		 * +		 * `addr` should not be used when UBLK_F_USER_COPY is enabled, +		 * because userspace handles data copy by pread()/pwrite() over +		 * /dev/ublkcN. But in case of UBLK_F_ZONED, this union is +		 * re-used to pass back the allocated LBA for +		 * UBLK_IO_OP_ZONE_APPEND which actually depends on +		 * UBLK_F_USER_COPY +		 */ +		__u64	addr; +		__u64	zone_append_lba; +	}; +}; + +struct ublk_param_basic { +#define UBLK_ATTR_READ_ONLY            (1 << 0) +#define UBLK_ATTR_ROTATIONAL           (1 << 1) +#define UBLK_ATTR_VOLATILE_CACHE       (1 << 2) +#define UBLK_ATTR_FUA                  (1 << 3) +	__u32	attrs; +	__u8	logical_bs_shift; +	__u8	physical_bs_shift; +	__u8	io_opt_shift; +	__u8	io_min_shift; + +	__u32	max_sectors; +	__u32	chunk_sectors; + +	__u64   dev_sectors; +	__u64   virt_boundary_mask; +}; + +struct ublk_param_discard { +	__u32	discard_alignment; + +	__u32	discard_granularity; +	__u32	max_discard_sectors; + +	__u32	max_write_zeroes_sectors; +	__u16	max_discard_segments; +	__u16	reserved0; +}; + +/* + * read-only, can't set via UBLK_CMD_SET_PARAMS, disk_devt is available + * after device is started + */ +struct ublk_param_devt { +	__u32   char_major; +	__u32   char_minor; +	__u32   disk_major; +	__u32   disk_minor; +}; + +struct ublk_param_zoned { +	__u32	max_open_zones; +	__u32	max_active_zones; +	__u32	max_zone_append_sectors; +	__u8	reserved[20]; +}; + +struct ublk_param_dma_align { +	__u32	alignment; +	__u8	pad[4]; +}; + +#define UBLK_MIN_SEGMENT_SIZE   4096 +/* + * If any one of the three segment parameter is set as 0, the behavior is + * undefined. + */ +struct ublk_param_segment { +	/* +	 * seg_boundary_mask + 1 needs to be power_of_2(), and the sum has +	 * to be >= UBLK_MIN_SEGMENT_SIZE(4096) +	 */ +	__u64 	seg_boundary_mask; + +	/* +	 * max_segment_size could be override by virt_boundary_mask, so be +	 * careful when setting both. +	 * +	 * max_segment_size has to be >= UBLK_MIN_SEGMENT_SIZE(4096) +	 */ +	__u32 	max_segment_size; +	__u16 	max_segments; +	__u8	pad[2]; +}; + +struct ublk_params { +	/* +	 * Total length of parameters, userspace has to set 'len' for both +	 * SET_PARAMS and GET_PARAMS command, and driver may update len +	 * if two sides use different version of 'ublk_params', same with +	 * 'types' fields. +	 */ +	__u32	len; +#define UBLK_PARAM_TYPE_BASIC           (1 << 0) +#define UBLK_PARAM_TYPE_DISCARD         (1 << 1) +#define UBLK_PARAM_TYPE_DEVT            (1 << 2) +#define UBLK_PARAM_TYPE_ZONED           (1 << 3) +#define UBLK_PARAM_TYPE_DMA_ALIGN       (1 << 4) +#define UBLK_PARAM_TYPE_SEGMENT         (1 << 5) +	__u32	types;			/* types of parameter included */ + +	struct ublk_param_basic		basic; +	struct ublk_param_discard	discard; +	struct ublk_param_devt		devt; +	struct ublk_param_zoned	zoned; +	struct ublk_param_dma_align	dma; +	struct ublk_param_segment	seg; +}; + +#endif diff --git a/include/uapi/linux/udp.h b/include/uapi/linux/udp.h index 4828794efcf8..edca3e430305 100644 --- a/include/uapi/linux/udp.h +++ b/include/uapi/linux/udp.h @@ -31,17 +31,18 @@ struct udphdr {  #define UDP_CORK	1	/* Never send partially complete segments */  #define UDP_ENCAP	100	/* Set the socket to accept encapsulated packets */  #define UDP_NO_CHECK6_TX 101	/* Disable sending checksum for UDP6X */ -#define UDP_NO_CHECK6_RX 102	/* Disable accpeting checksum for UDP6 */ +#define UDP_NO_CHECK6_RX 102	/* Disable accepting checksum for UDP6 */  #define UDP_SEGMENT	103	/* Set GSO segmentation size */  #define UDP_GRO		104	/* This socket can receive UDP GRO packets */  /* UDP encapsulation types */ -#define UDP_ENCAP_ESPINUDP_NON_IKE	1 /* draft-ietf-ipsec-nat-t-ike-00/01 */ +#define UDP_ENCAP_ESPINUDP_NON_IKE	1 /* unused  draft-ietf-ipsec-nat-t-ike-00/01 */  #define UDP_ENCAP_ESPINUDP	2 /* draft-ietf-ipsec-udp-encaps-06 */  #define UDP_ENCAP_L2TPINUDP	3 /* rfc2661 */  #define UDP_ENCAP_GTP0		4 /* GSM TS 09.60 */  #define UDP_ENCAP_GTP1U		5 /* 3GPP TS 29.060 */  #define UDP_ENCAP_RXRPC		6  #define TCP_ENCAP_ESPINTCP	7 /* Yikes, this is really xfrm encap types. */ +#define UDP_ENCAP_OVPNINUDP	8 /* OpenVPN traffic */  #endif /* _UAPI_LINUX_UDP_H */ diff --git a/include/uapi/linux/uio.h b/include/uapi/linux/uio.h index 059b1a9147f4..649739e0c404 100644 --- a/include/uapi/linux/uio.h +++ b/include/uapi/linux/uio.h @@ -20,6 +20,24 @@ struct iovec  	__kernel_size_t iov_len; /* Must be size_t (1003.1g) */  }; +struct dmabuf_cmsg { +	__u64 frag_offset;	/* offset into the dmabuf where the frag starts. +				 */ +	__u32 frag_size;	/* size of the frag. */ +	__u32 frag_token;	/* token representing this frag for +				 * DEVMEM_DONTNEED. +				 */ +	__u32  dmabuf_id;	/* dmabuf id this frag belongs to. */ +	__u32 flags;		/* Currently unused. Reserved for future +				 * uses. +				 */ +}; + +struct dmabuf_token { +	__u32 token_start; +	__u32 token_count; +}; +  /*   *	UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1)   */ diff --git a/include/uapi/linux/um_timetravel.h b/include/uapi/linux/um_timetravel.h index ca3238222b6d..546a690b0346 100644 --- a/include/uapi/linux/um_timetravel.h +++ b/include/uapi/linux/um_timetravel.h @@ -1,17 +1,6 @@ +/* SPDX-License-Identifier: BSD-3-Clause */  /* - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Copyright (C) 2019 Intel Corporation + * Copyright (C) 2019 - 2023 Intel Corporation   */  #ifndef _UAPI_LINUX_UM_TIMETRAVEL_H  #define _UAPI_LINUX_UM_TIMETRAVEL_H @@ -50,6 +39,36 @@ struct um_timetravel_msg {  	__u64 time;  }; +/* max number of file descriptors that can be sent/received in a message */ +#define UM_TIMETRAVEL_MAX_FDS 2 + +/** + * enum um_timetravel_shared_mem_fds - fds sent in ACK message for START message + */ +enum um_timetravel_shared_mem_fds { +	/** +	 * @UM_TIMETRAVEL_SHARED_MEMFD: Index of the shared memory file +	 *	descriptor in the control message +	 */ +	UM_TIMETRAVEL_SHARED_MEMFD, +	/** +	 * @UM_TIMETRAVEL_SHARED_LOGFD: Index of the logging file descriptor +	 *	in the control message +	 */ +	UM_TIMETRAVEL_SHARED_LOGFD, +	UM_TIMETRAVEL_SHARED_MAX_FDS, +}; + +/** + * enum um_timetravel_start_ack - ack-time mask for start message + */ +enum um_timetravel_start_ack { +	/** +	 * @UM_TIMETRAVEL_START_ACK_ID: client ID that controller allocated. +	 */ +	UM_TIMETRAVEL_START_ACK_ID = 0xffff, +}; +  /**   * enum um_timetravel_ops - Operation codes   */ @@ -57,7 +76,9 @@ enum um_timetravel_ops {  	/**  	 * @UM_TIMETRAVEL_ACK: response (ACK) to any previous message,  	 *	this usually doesn't carry any data in the 'time' field -	 *	unless otherwise specified below +	 *	unless otherwise specified below, note: while using shared +	 *	memory no ACK for WAIT and RUN messages, for more info see +	 *	&struct um_timetravel_schedshm.  	 */  	UM_TIMETRAVEL_ACK		= 0, @@ -123,6 +144,147 @@ enum um_timetravel_ops {  	 *	the simulation.  	 */  	UM_TIMETRAVEL_GET_TOD		= 8, + +	/** +	 * @UM_TIMETRAVEL_BROADCAST: Send/Receive a broadcast message. +	 *	This message can be used to sync all components in the system +	 *	with a single message, if the calender gets the message, the +	 *	calender broadcast the message to all components, and if a +	 *	component receives it it should act based on it e.g print a +	 *	message to it's log system. +	 *	(calendar <-> host) +	 */ +	UM_TIMETRAVEL_BROADCAST		= 9, +}; + +/* version of struct um_timetravel_schedshm */ +#define UM_TIMETRAVEL_SCHEDSHM_VERSION 2 + +/** + * enum um_timetravel_schedshm_cap - time travel capabilities of every client + * + * These flags must be set immediately after processing the ACK to + * the START message, before sending any message to the controller. + */ +enum um_timetravel_schedshm_cap { +	/** +	 * @UM_TIMETRAVEL_SCHEDSHM_CAP_TIME_SHARE: client can read current time +	 *	update internal time request to shared memory and read +	 *	free until and send no Ack on RUN and doesn't expect ACK on +	 *	WAIT. +	 */ +	UM_TIMETRAVEL_SCHEDSHM_CAP_TIME_SHARE = 0x1, +}; + +/** + * enum um_timetravel_schedshm_flags - time travel flags of every client + */ +enum um_timetravel_schedshm_flags { +	/** +	 * @UM_TIMETRAVEL_SCHEDSHM_FLAGS_REQ_RUN: client has a request to run. +	 *	It's set by client when it has a request to run, if (and only +	 *	if) the @running_id points to a client that is able to use +	 *	shared memory, i.e. has %UM_TIMETRAVEL_SCHEDSHM_CAP_TIME_SHARE +	 *	(this includes the client itself). Otherwise, a message must +	 *	be used. +	 */ +	UM_TIMETRAVEL_SCHEDSHM_FLAGS_REQ_RUN = 0x1, +}; + +/** + * DOC: Time travel shared memory overview + * + * The main purpose of the shared memory is to avoid all time travel message + * that don't need any action, for example current time can be held in shared + * memory without the need of any client to send a message UM_TIMETRAVEL_GET + * in order to know what's the time. + * + * Since this is shared memory with all clients and controller and controller + * creates the shared memory space, all time values are absolute to controller + * time. So first time client connects to shared memory mode it should take the + * current_time value in shared memory and keep it internally as a diff to + * shared memory times, and once shared memory is initialized, any interaction + * with the controller must happen in the controller time domain, including any + * messages (for clients that are not using shared memory, the controller will + * handle an offset and make the clients think they start at time zero.) + * + * Along with the shared memory file descriptor is sent to the client a logging + * file descriptor, to have all logs related to shared memory, + * logged into one place. note: to have all logs synced into log file at write, + * file should be flushed (fflush) after writing to it. + * + * To avoid memory corruption, we define below for each field who can write to + * it at what time, defined in the structure fields. + * + * To avoid having to pack this struct, all fields in it must be naturally aligned + * (i.e. aligned to their size). + */ + +/** + * union um_timetravel_schedshm_client - UM time travel client struct + * + * Every entity using the shared memory including the controller has a place in + * the um_timetravel_schedshm clients array, that holds info related to the client + * using the shared memory, and can be set only by the client after it gets the + * fd memory. + * + * @capa: bit fields with client capabilities see + *	&enum um_timetravel_schedshm_cap, set by client once after getting the + *	shared memory file descriptor. + * @flags: bit fields for flags see &enum um_timetravel_schedshm_flags for doc. + * @req_time: request time to run, set by client on every request it needs. + * @name: unique id sent to the controller by client with START message. + */ +union um_timetravel_schedshm_client { +	struct { +		__u32 capa; +		__u32 flags; +		__u64 req_time; +		__u64 name; +	}; +	char reserve[128]; /* reserved for future usage */  }; +/** + * struct um_timetravel_schedshm - UM time travel shared memory struct + * + * @hdr: header fields: + * @version: Current version struct UM_TIMETRAVEL_SCHEDSHM_VERSION, + *	set by controller once at init, clients must check this after mapping + *	and work without shared memory if they cannot handle the indicated + *	version. + * @len: Length of all the memory including header (@hdr), clients should once + *	per connection first mmap the header and take the length (@len) to remap the entire size. + *	This is done in order to support dynamic struct size letting number of + *	clients be dynamic based on controller support. + * @free_until: Stores the next request to run by any client, in order for the + *	current client to know how long it can still run. A client needs to (at + *	least) reload this value immediately after communicating with any other + *	client, since the controller will update this field when a new request + *	is made by any client. Clients also must update this value when they + *	insert/update an own request into the shared memory while not running + *	themselves, and the new request is before than the current value. + * current_time: Current time, can only be set by the client in running state + *	(indicated by @running_id), though that client may only run until @free_until, + *	so it must remain smaller than @free_until. + * @running_id: The current client in state running, set before a client is + *	notified that it's now running. + * @max_clients: size of @clients array, set once at init by the controller. + * @clients: clients array see &union um_timetravel_schedshm_client for doc, + *	set only by client. + */ +struct um_timetravel_schedshm { +	union { +		struct { +			__u32 version; +			__u32 len; +			__u64 free_until; +			__u64 current_time; +			__u16 running_id; +			__u16 max_clients; +		}; +		char hdr[4096]; /* align to 4K page size */ +	}; +	union um_timetravel_schedshm_client clients[]; +};  #endif /* _UAPI_LINUX_UM_TIMETRAVEL_H */ diff --git a/include/uapi/linux/usb/audio.h b/include/uapi/linux/usb/audio.h index 76b7c3f6cd0d..c917c53070d5 100644 --- a/include/uapi/linux/usb/audio.h +++ b/include/uapi/linux/usb/audio.h @@ -341,7 +341,7 @@ struct uac_feature_unit_descriptor {  	__u8 bUnitID;  	__u8 bSourceID;  	__u8 bControlSize; -	__u8 bmaControls[0]; /* variable length */ +	__u8 bmaControls[]; /* variable length */  } __attribute__((packed));  static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc) diff --git a/include/uapi/linux/usb/cdc.h b/include/uapi/linux/usb/cdc.h index 6d61550959ef..1924cf665448 100644 --- a/include/uapi/linux/usb/cdc.h +++ b/include/uapi/linux/usb/cdc.h @@ -171,7 +171,7 @@ struct usb_cdc_mdlm_detail_desc {  	/* type is associated with mdlm_desc.bGUID */  	__u8	bGuidDescriptorType; -	__u8	bDetailData[0]; +	__u8	bDetailData[];  } __attribute__ ((packed));  /* "OBEX Control Model Functional Descriptor" */ @@ -271,6 +271,10 @@ struct usb_cdc_line_coding {  	__u8	bDataBits;  } __attribute__ ((packed)); +/* Control Signal Bitmap Values from 6.2.14 SetControlLineState */ +#define USB_CDC_CTRL_DTR			(1 << 0) +#define USB_CDC_CTRL_RTS			(1 << 1) +  /* table 62; bits in multicast filter */  #define	USB_CDC_PACKET_TYPE_PROMISCUOUS		(1 << 0)  #define	USB_CDC_PACKET_TYPE_ALL_MULTICAST	(1 << 1) /* no filter */ @@ -302,6 +306,15 @@ struct usb_cdc_notification {  	__le16	wLength;  } __attribute__ ((packed)); +/* UART State Bitmap Values from 6.3.5 SerialState */ +#define USB_CDC_SERIAL_STATE_DCD		(1 << 0) +#define USB_CDC_SERIAL_STATE_DSR		(1 << 1) +#define USB_CDC_SERIAL_STATE_BREAK		(1 << 2) +#define USB_CDC_SERIAL_STATE_RING_SIGNAL	(1 << 3) +#define USB_CDC_SERIAL_STATE_FRAMING		(1 << 4) +#define USB_CDC_SERIAL_STATE_PARITY		(1 << 5) +#define USB_CDC_SERIAL_STATE_OVERRUN		(1 << 6) +  struct usb_cdc_speed_change {  	__le32	DLBitRRate;	/* contains the downlink bit rate (IN pipe) */  	__le32	ULBitRate;	/* contains the uplink bit rate (OUT pipe) */ @@ -379,7 +392,7 @@ struct usb_cdc_ncm_ndp16 {  	__le32	dwSignature;  	__le16	wLength;  	__le16	wNextNdpIndex; -	struct	usb_cdc_ncm_dpe16 dpe16[0]; +	struct	usb_cdc_ncm_dpe16 dpe16[];  } __attribute__ ((packed));  /* 32-bit NCM Datagram Pointer Entry */ @@ -395,7 +408,7 @@ struct usb_cdc_ncm_ndp32 {  	__le16	wReserved6;  	__le32	dwNextNdpIndex;  	__le32	dwReserved12; -	struct	usb_cdc_ncm_dpe32 dpe32[0]; +	struct	usb_cdc_ncm_dpe32 dpe32[];  } __attribute__ ((packed));  /* CDC NCM subclass 3.2.1 and 3.2.2 */ diff --git a/include/uapi/linux/usb/ch11.h b/include/uapi/linux/usb/ch11.h index fb0cd24c392c..ce4c83f2e66a 100644 --- a/include/uapi/linux/usb/ch11.h +++ b/include/uapi/linux/usb/ch11.h @@ -15,10 +15,8 @@  /* This is arbitrary.   * From USB 2.0 spec Table 11-13, offset 7, a hub can   * have up to 255 ports. The most yet reported is 10. - * - * Current Wireless USB host hardware (Intel i1480 for example) allows - * up to 22 devices to connect. Upcoming hardware might raise that - * limit. Because the arrays need to add a bit for hub status data, we + * Upcoming hardware might raise that limit. + * Because the arrays need to add a bit for hub status data, we   * use 31, so plus one evens out to four bytes.   */  #define USB_MAXCHILDREN		31 diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index 0f865ae4ba89..8003243a4937 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -3,7 +3,7 @@   * This file holds USB constants and structures that are needed for   * USB device APIs.  These are used by the USB device model, which is   * defined in chapter 9 of the USB 2.0 specification and in the - * Wireless USB 1.0 (spread around).  Linux has several APIs in C that + * Wireless USB 1.0 spec (now defunct).  Linux has several APIs in C that   * need these:   *   * - the master/host side Linux-USB kernel driver API; @@ -14,9 +14,6 @@   * act either as a USB master/host or as a USB slave/device.  That means   * the master and slave side APIs benefit from working well together.   * - * There's also "Wireless USB", using low power short range radios for - * peripheral interconnection but otherwise building on the USB framework. - *   * Note all descriptors are declared '__attribute__((packed))' so that:   *   * [a] they never get padded, either internally (USB spec writers @@ -256,7 +253,13 @@ struct usb_ctrlrequest {  #define USB_DT_BOS			0x0f  #define USB_DT_DEVICE_CAPABILITY	0x10  #define USB_DT_WIRELESS_ENDPOINT_COMP	0x11 +/* From the eUSB2 spec */ +#define USB_DT_EUSB2_ISOC_ENDPOINT_COMP	0x12 +/* From Wireless USB spec */  #define USB_DT_WIRE_ADAPTER		0x21 +/* From USB Device Firmware Upgrade Specification, Revision 1.1 */ +#define USB_DT_DFU_FUNCTIONAL		0x21 +/* these are from the Wireless USB spec */  #define USB_DT_RPIPE			0x22  #define USB_DT_CS_RADIO_CONTROL		0x23  /* From the T10 UAS specification */ @@ -330,11 +333,13 @@ struct usb_device_descriptor {  #define USB_CLASS_AUDIO_VIDEO		0x10  #define USB_CLASS_BILLBOARD		0x11  #define USB_CLASS_USB_TYPE_C_BRIDGE	0x12 +#define USB_CLASS_MCTP			0x14  #define USB_CLASS_MISC			0xef  #define USB_CLASS_APP_SPEC		0xfe -#define USB_CLASS_VENDOR_SPEC		0xff +#define USB_SUBCLASS_DFU			0x01 -#define USB_SUBCLASS_VENDOR_SPEC	0xff +#define USB_CLASS_VENDOR_SPEC		0xff +#define USB_SUBCLASS_VENDOR_SPEC		0xff  /*-------------------------------------------------------------------------*/ @@ -376,7 +381,10 @@ struct usb_string_descriptor {  	__u8  bLength;  	__u8  bDescriptorType; -	__le16 wData[1];		/* UTF-16LE encoded */ +	union { +		__le16 legacy_padding; +		__DECLARE_FLEX_ARRAY(__le16, wData);	/* UTF-16LE encoded */ +	};  } __attribute__ ((packed));  /* note that "string" zero is special, it holds language codes that @@ -671,6 +679,18 @@ static inline int usb_endpoint_interrupt_type(  /*-------------------------------------------------------------------------*/ +/* USB_DT_EUSB2_ISOC_ENDPOINT_COMP: eUSB2 Isoch Endpoint Companion descriptor */ +struct usb_eusb2_isoc_ep_comp_descriptor { +	__u8	bLength; +	__u8	bDescriptorType; +	__le16	wMaxPacketSize; +	__le32	dwBytesPerInterval; +} __attribute__ ((packed)); + +#define USB_DT_EUSB2_ISOC_EP_COMP_SIZE	8 + +/*-------------------------------------------------------------------------*/ +  /* USB_DT_SSP_ISOC_ENDPOINT_COMP: SuperSpeedPlus Isochronous Endpoint Companion   * descriptor   */ @@ -763,6 +783,8 @@ struct usb_otg20_descriptor {  #define USB_OTG_SRP		(1 << 0)  #define USB_OTG_HNP		(1 << 1)	/* swap host/device roles */  #define USB_OTG_ADP		(1 << 2)	/* support ADP */ +/* OTG 3.0 */ +#define USB_OTG_RSP		(1 << 3)	/* support RSP */  #define OTG_STS_SELECTOR	0xF000		/* OTG status selector */  /*-------------------------------------------------------------------------*/ @@ -818,7 +840,7 @@ struct usb_key_descriptor {  	__u8  tTKID[3];  	__u8  bReserved; -	__u8  bKeyData[0]; +	__u8  bKeyData[];  } __attribute__((packed));  /*-------------------------------------------------------------------------*/ @@ -948,6 +970,22 @@ struct usb_ss_container_id_descriptor {  #define USB_DT_USB_SS_CONTN_ID_SIZE	20  /* + * Platform Device Capability descriptor: Defines platform specific device + * capabilities + */ +#define	USB_PLAT_DEV_CAP_TYPE	5 +struct usb_plat_dev_cap_descriptor { +	__u8  bLength; +	__u8  bDescriptorType; +	__u8  bDevCapabilityType; +	__u8  bReserved; +	__u8  UUID[16]; +	__u8  CapabilityData[]; +} __attribute__((packed)); + +#define USB_DT_USB_PLAT_DEV_CAP_SIZE(capability_data_size)	(20 + capability_data_size) + +/*   * SuperSpeed Plus USB Capability descriptor: Defines the set of   * SuperSpeed Plus USB specific device level capabilities   */ @@ -965,12 +1003,29 @@ struct usb_ssp_cap_descriptor {  #define USB_SSP_MIN_RX_LANE_COUNT		(0xf << 8)  #define USB_SSP_MIN_TX_LANE_COUNT		(0xf << 12)  	__le16 wReserved; -	__le32 bmSublinkSpeedAttr[1]; /* list of sublink speed attrib entries */ +	union { +		__le32 legacy_padding; +		/* list of sublink speed attrib entries */ +		__DECLARE_FLEX_ARRAY(__le32, bmSublinkSpeedAttr); +	};  #define USB_SSP_SUBLINK_SPEED_SSID	(0xf)		/* sublink speed ID */  #define USB_SSP_SUBLINK_SPEED_LSE	(0x3 << 4)	/* Lanespeed exponent */ +#define USB_SSP_SUBLINK_SPEED_LSE_BPS		0 +#define USB_SSP_SUBLINK_SPEED_LSE_KBPS		1 +#define USB_SSP_SUBLINK_SPEED_LSE_MBPS		2 +#define USB_SSP_SUBLINK_SPEED_LSE_GBPS		3 +  #define USB_SSP_SUBLINK_SPEED_ST	(0x3 << 6)	/* Sublink type */ +#define USB_SSP_SUBLINK_SPEED_ST_SYM_RX		0 +#define USB_SSP_SUBLINK_SPEED_ST_ASYM_RX	1 +#define USB_SSP_SUBLINK_SPEED_ST_SYM_TX		2 +#define USB_SSP_SUBLINK_SPEED_ST_ASYM_TX	3 +  #define USB_SSP_SUBLINK_SPEED_RSVD	(0x3f << 8)	/* Reserved */  #define USB_SSP_SUBLINK_SPEED_LP	(0x3 << 14)	/* Link protocol */ +#define USB_SSP_SUBLINK_SPEED_LP_SS		0 +#define USB_SSP_SUBLINK_SPEED_LP_SSP		1 +  #define USB_SSP_SUBLINK_SPEED_LSM	(0xff << 16)	/* Lanespeed mantissa */  } __attribute__((packed)); diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h index d77ee6b65328..beef1752e36e 100644 --- a/include/uapi/linux/usb/functionfs.h +++ b/include/uapi/linux/usb/functionfs.h @@ -3,6 +3,7 @@  #define _UAPI__LINUX_FUNCTIONFS_H__ +#include <linux/const.h>  #include <linux/types.h>  #include <linux/ioctl.h> @@ -37,6 +38,31 @@ struct usb_endpoint_descriptor_no_audio {  	__u8  bInterval;  } __attribute__((packed)); +/** + * struct usb_dfu_functional_descriptor - DFU Functional descriptor + * @bLength:		Size of the descriptor (bytes) + * @bDescriptorType:	USB_DT_DFU_FUNCTIONAL + * @bmAttributes:	DFU attributes + * @wDetachTimeOut:	Maximum time to wait after DFU_DETACH (ms, le16) + * @wTransferSize:	Maximum number of bytes per control-write (le16) + * @bcdDFUVersion:	DFU Spec version (BCD, le16) + */ +struct usb_dfu_functional_descriptor { +	__u8  bLength; +	__u8  bDescriptorType; +	__u8  bmAttributes; +	__le16 wDetachTimeOut; +	__le16 wTransferSize; +	__le16 bcdDFUVersion; +} __attribute__ ((packed)); + +/* from DFU functional descriptor bmAttributes */ +#define DFU_FUNC_ATT_CAN_DOWNLOAD	_BITUL(0) +#define DFU_FUNC_ATT_CAN_UPLOAD		_BITUL(1) +#define DFU_FUNC_ATT_MANIFEST_TOLERANT	_BITUL(2) +#define DFU_FUNC_ATT_WILL_DETACH	_BITUL(3) + +  struct usb_functionfs_descs_head_v2 {  	__le32 magic;  	__le32 length; @@ -73,8 +99,10 @@ struct usb_os_desc_header {  struct usb_ext_compat_desc {  	__u8	bFirstInterfaceNumber;  	__u8	Reserved1; -	__u8	CompatibleID[8]; -	__u8	SubCompatibleID[8]; +	__struct_group(/* no tag */, IDs, /* no attrs */, +		__u8	CompatibleID[8]; +		__u8	SubCompatibleID[8]; +	);  	__u8	Reserved2[6];  }; @@ -84,25 +112,56 @@ struct usb_ext_prop_desc {  	__le16	wPropertyNameLength;  } __attribute__((packed)); +/* Flags for usb_ffs_dmabuf_transfer_req->flags (none for now) */ +#define USB_FFS_DMABUF_TRANSFER_MASK	0x0 + +/** + * struct usb_ffs_dmabuf_transfer_req - Transfer request for a DMABUF object + * @fd:		file descriptor of the DMABUF object + * @flags:	one or more USB_FFS_DMABUF_TRANSFER_* flags + * @length:	number of bytes used in this DMABUF for the data transfer. + *		Should generally be set to the DMABUF's size. + */ +struct usb_ffs_dmabuf_transfer_req { +	int fd; +	__u32 flags; +	__u64 length; +} __attribute__((packed)); +  #ifndef __KERNEL__ -/* +/** + * DOC: descriptors + *   * Descriptors format:   * + * +-----+-----------+--------------+--------------------------------------+   * | off | name      | type         | description                          | - * |-----+-----------+--------------+--------------------------------------| + * +-----+-----------+--------------+--------------------------------------+   * |   0 | magic     | LE32         | FUNCTIONFS_DESCRIPTORS_MAGIC_V2      | + * +-----+-----------+--------------+--------------------------------------+   * |   4 | length    | LE32         | length of the whole data chunk       | + * +-----+-----------+--------------+--------------------------------------+   * |   8 | flags     | LE32         | combination of functionfs_flags      | + * +-----+-----------+--------------+--------------------------------------+   * |     | eventfd   | LE32         | eventfd file descriptor              | + * +-----+-----------+--------------+--------------------------------------+   * |     | fs_count  | LE32         | number of full-speed descriptors     | + * +-----+-----------+--------------+--------------------------------------+   * |     | hs_count  | LE32         | number of high-speed descriptors     | + * +-----+-----------+--------------+--------------------------------------+   * |     | ss_count  | LE32         | number of super-speed descriptors    | + * +-----+-----------+--------------+--------------------------------------+   * |     | os_count  | LE32         | number of MS OS descriptors          | + * +-----+-----------+--------------+--------------------------------------+   * |     | fs_descrs | Descriptor[] | list of full-speed descriptors       | + * +-----+-----------+--------------+--------------------------------------+   * |     | hs_descrs | Descriptor[] | list of high-speed descriptors       | + * +-----+-----------+--------------+--------------------------------------+   * |     | ss_descrs | Descriptor[] | list of super-speed descriptors      | + * +-----+-----------+--------------+--------------------------------------+   * |     | os_descrs | OSDesc[]     | list of MS OS descriptors            | + * +-----+-----------+--------------+--------------------------------------+   *   * Depending on which flags are set, various fields may be missing in the   * structure.  Any flags that are not recognised cause the whole block to be @@ -110,71 +169,111 @@ struct usb_ext_prop_desc {   *   * Legacy descriptors format (deprecated as of 3.14):   * + * +-----+-----------+--------------+--------------------------------------+   * | off | name      | type         | description                          | - * |-----+-----------+--------------+--------------------------------------| + * +-----+-----------+--------------+--------------------------------------+   * |   0 | magic     | LE32         | FUNCTIONFS_DESCRIPTORS_MAGIC         | + * +-----+-----------+--------------+--------------------------------------+   * |   4 | length    | LE32         | length of the whole data chunk       | + * +-----+-----------+--------------+--------------------------------------+   * |   8 | fs_count  | LE32         | number of full-speed descriptors     | + * +-----+-----------+--------------+--------------------------------------+   * |  12 | hs_count  | LE32         | number of high-speed descriptors     | + * +-----+-----------+--------------+--------------------------------------+   * |  16 | fs_descrs | Descriptor[] | list of full-speed descriptors       | + * +-----+-----------+--------------+--------------------------------------+   * |     | hs_descrs | Descriptor[] | list of high-speed descriptors       | + * +-----+-----------+--------------+--------------------------------------+   *   * All numbers must be in little endian order.   *   * Descriptor[] is an array of valid USB descriptors which have the following   * format:   * + * +-----+-----------------+------+--------------------------+   * | off | name            | type | description              | - * |-----+-----------------+------+--------------------------| + * +-----+-----------------+------+--------------------------+   * |   0 | bLength         | U8   | length of the descriptor | + * +-----+-----------------+------+--------------------------+   * |   1 | bDescriptorType | U8   | descriptor type          | + * +-----+-----------------+------+--------------------------+   * |   2 | payload         |      | descriptor's payload     | + * +-----+-----------------+------+--------------------------+   *   * OSDesc[] is an array of valid MS OS Feature Descriptors which have one of   * the following formats:   * + * +-----+-----------------+------+--------------------------+   * | off | name            | type | description              | - * |-----+-----------------+------+--------------------------| - * |   0 | inteface        | U8   | related interface number | + * +-----+-----------------+------+--------------------------+ + * |   0 | interface       | U8   | related interface number | + * +-----+-----------------+------+--------------------------+   * |   1 | dwLength        | U32  | length of the descriptor | + * +-----+-----------------+------+--------------------------+   * |   5 | bcdVersion      | U16  | currently supported: 1   | + * +-----+-----------------+------+--------------------------+   * |   7 | wIndex          | U16  | currently supported: 4   | + * +-----+-----------------+------+--------------------------+   * |   9 | bCount          | U8   | number of ext. compat.   | + * +-----+-----------------+------+--------------------------+   * |  10 | Reserved        | U8   | 0                        | + * +-----+-----------------+------+--------------------------+   * |  11 | ExtCompat[]     |      | list of ext. compat. d.  | + * +-----+-----------------+------+--------------------------+   * + * +-----+-----------------+------+--------------------------+   * | off | name            | type | description              | - * |-----+-----------------+------+--------------------------| - * |   0 | inteface        | U8   | related interface number | + * +-----+-----------------+------+--------------------------+ + * |   0 | interface       | U8   | related interface number | + * +-----+-----------------+------+--------------------------+   * |   1 | dwLength        | U32  | length of the descriptor | + * +-----+-----------------+------+--------------------------+   * |   5 | bcdVersion      | U16  | currently supported: 1   | + * +-----+-----------------+------+--------------------------+   * |   7 | wIndex          | U16  | currently supported: 5   | + * +-----+-----------------+------+--------------------------+   * |   9 | wCount          | U16  | number of ext. compat.   | + * +-----+-----------------+------+--------------------------+   * |  11 | ExtProp[]       |      | list of ext. prop. d.    | + * +-----+-----------------+------+--------------------------+   * - * ExtCompat[] is an array of valid Extended Compatiblity descriptors + * ExtCompat[] is an array of valid Extended Compatibility descriptors   * which have the following format:   * + * +-----+-----------------------+------+-------------------------------------+   * | off | name                  | type | description                         | - * |-----+-----------------------+------+-------------------------------------| + * +-----+-----------------------+------+-------------------------------------+   * |   0 | bFirstInterfaceNumber | U8   | index of the interface or of the 1st| + * +-----+-----------------------+------+-------------------------------------+   * |     |                       |      | interface in an IAD group           | + * +-----+-----------------------+------+-------------------------------------+   * |   1 | Reserved              | U8   | 1                                   | + * +-----+-----------------------+------+-------------------------------------+   * |   2 | CompatibleID          | U8[8]| compatible ID string                | + * +-----+-----------------------+------+-------------------------------------+   * |  10 | SubCompatibleID       | U8[8]| subcompatible ID string             | + * +-----+-----------------------+------+-------------------------------------+   * |  18 | Reserved              | U8[6]| 0                                   | + * +-----+-----------------------+------+-------------------------------------+   *   * ExtProp[] is an array of valid Extended Properties descriptors   * which have the following format:   * + * +-----+-----------------------+------+-------------------------------------+   * | off | name                  | type | description                         | - * |-----+-----------------------+------+-------------------------------------| + * +-----+-----------------------+------+-------------------------------------+   * |   0 | dwSize                | U32  | length of the descriptor            | + * +-----+-----------------------+------+-------------------------------------+   * |   4 | dwPropertyDataType    | U32  | 1..7                                | + * +-----+-----------------------+------+-------------------------------------+   * |   8 | wPropertyNameLength   | U16  | bPropertyName length (NL)           | + * +-----+-----------------------+------+-------------------------------------+   * |  10 | bPropertyName         |U8[NL]| name of this property               | + * +-----+-----------------------+------+-------------------------------------+   * |10+NL| dwPropertyDataLength  | U32  | bPropertyData length (DL)           | + * +-----+-----------------------+------+-------------------------------------+   * |14+NL| bProperty             |U8[DL]| payload of this property            | + * +-----+-----------------------+------+-------------------------------------+   */  struct usb_functionfs_strings_head { @@ -196,7 +295,7 @@ struct usb_functionfs_strings_head {   * |  16 | stringtab  | StringTab[lang_count] | table of strings per lang  |   *   * For each language there is one stringtab entry (ie. there are lang_count - * stringtab entires).  Each StringTab has following format: + * stringtab entries).  Each StringTab has following format:   *   * | off | name    | type              | description                        |   * |-----+---------+-------------------+------------------------------------| @@ -288,6 +387,31 @@ struct usb_functionfs_event {  #define	FUNCTIONFS_ENDPOINT_DESC	_IOR('g', 130, \  					     struct usb_endpoint_descriptor) +/* + * Attach the DMABUF object, identified by its file descriptor, to the + * data endpoint. Returns zero on success, and a negative errno value + * on error. + */ +#define FUNCTIONFS_DMABUF_ATTACH	_IOW('g', 131, int) + +/* + * Detach the given DMABUF object, identified by its file descriptor, + * from the data endpoint. Returns zero on success, and a negative + * errno value on error. Note that closing the endpoint's file + * descriptor will automatically detach all attached DMABUFs. + */ +#define FUNCTIONFS_DMABUF_DETACH	_IOW('g', 132, int) + +/* + * Enqueue the previously attached DMABUF to the transfer queue. + * The argument is a structure that packs the DMABUF's file descriptor, + * the size in bytes to transfer (which should generally correspond to + * the size of the DMABUF), and a 'flags' field which is unused + * for now. Returns zero on success, and a negative errno value on + * error. + */ +#define FUNCTIONFS_DMABUF_TRANSFER	_IOW('g', 133, \ +					     struct usb_ffs_dmabuf_transfer_req)  #endif /* _UAPI__LINUX_FUNCTIONFS_H__ */ diff --git a/include/uapi/linux/usb/g_hid.h b/include/uapi/linux/usb/g_hid.h new file mode 100644 index 000000000000..b965092db476 --- /dev/null +++ b/include/uapi/linux/usb/g_hid.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ + +#ifndef __UAPI_LINUX_USB_G_HID_H +#define __UAPI_LINUX_USB_G_HID_H + +#include <linux/types.h> + +/* Maximum HID report length for High-Speed USB (i.e. USB 2.0) */ +#define MAX_REPORT_LENGTH 64 + +/** + * struct usb_hidg_report - response to GET_REPORT + * @report_id: report ID that this is a response for + * @userspace_req: + *    !0 this report is used for any pending GET_REPORT request + *       but wait on userspace to issue a new report on future requests + *    0  this report is to be used for any future GET_REPORT requests + * @length: length of the report response + * @data: report response + * @padding: padding for 32/64 bit compatibility + * + * Structure used by GADGET_HID_WRITE_GET_REPORT ioctl on /dev/hidg*. + */ +struct usb_hidg_report { +	__u8 report_id; +	__u8 userspace_req; +	__u16 length; +	__u8 data[MAX_REPORT_LENGTH]; +	__u8 padding[4]; +}; + +/* The 'g' code is used by gadgetfs and hid gadget ioctl requests. + * Don't add any colliding codes to either driver, and keep + * them in unique ranges. + */ + +#define GADGET_HID_READ_GET_REPORT_ID   _IOR('g', 0x41, __u8) +#define GADGET_HID_WRITE_GET_REPORT     _IOW('g', 0x42, struct usb_hidg_report) + +#endif /* __UAPI_LINUX_USB_G_HID_H */ diff --git a/include/uapi/linux/usb/g_uvc.h b/include/uapi/linux/usb/g_uvc.h index 652f169a019e..8d7824dde1b2 100644 --- a/include/uapi/linux/usb/g_uvc.h +++ b/include/uapi/linux/usb/g_uvc.h @@ -21,6 +21,9 @@  #define UVC_EVENT_DATA			(V4L2_EVENT_PRIVATE_START + 5)  #define UVC_EVENT_LAST			(V4L2_EVENT_PRIVATE_START + 5) +#define UVC_STRING_CONTROL_IDX			0 +#define UVC_STRING_STREAMING_IDX		1 +  struct uvc_request_data {  	__s32 length;  	__u8 data[60]; diff --git a/include/uapi/linux/usb/gadgetfs.h b/include/uapi/linux/usb/gadgetfs.h index 835473910a49..9754822b2a40 100644 --- a/include/uapi/linux/usb/gadgetfs.h +++ b/include/uapi/linux/usb/gadgetfs.h @@ -62,7 +62,7 @@ struct usb_gadgetfs_event {  }; -/* The 'g' code is also used by printer gadget ioctl requests. +/* The 'g' code is also used by printer and hid gadget ioctl requests.   * Don't add any colliding codes to either driver, and keep   * them in unique ranges (size 0x20 for now).   */ diff --git a/include/uapi/linux/usb/raw_gadget.h b/include/uapi/linux/usb/raw_gadget.h index 0be685272eb1..f0224a8dc858 100644 --- a/include/uapi/linux/usb/raw_gadget.h +++ b/include/uapi/linux/usb/raw_gadget.h @@ -44,6 +44,16 @@ enum usb_raw_event_type {  	/* This event is queued when a new control request arrived to ep0. */  	USB_RAW_EVENT_CONTROL = 2, +	/* +	 * These events are queued when the gadget driver is suspended, +	 * resumed, reset, or disconnected. Note that some UDCs (e.g. dwc2) +	 * report a disconnect event instead of a reset. +	 */ +	USB_RAW_EVENT_SUSPEND = 3, +	USB_RAW_EVENT_RESUME = 4, +	USB_RAW_EVENT_RESET = 5, +	USB_RAW_EVENT_DISCONNECT = 6, +  	/* The list might grow in the future. */  }; @@ -54,13 +64,13 @@ enum usb_raw_event_type {   *     actual length of the fetched event data.   * @data: A buffer to store the fetched event data.   * - * Currently the fetched data buffer is empty for USB_RAW_EVENT_CONNECT, - * and contains struct usb_ctrlrequest for USB_RAW_EVENT_CONTROL. + * The fetched event data buffer contains struct usb_ctrlrequest for + * USB_RAW_EVENT_CONTROL and is empty for other events.   */  struct usb_raw_event {  	__u32		type;  	__u32		length; -	__u8		data[0]; +	__u8		data[];  };  #define USB_RAW_IO_FLAGS_ZERO	0x0001 @@ -90,7 +100,7 @@ struct usb_raw_ep_io {  	__u16		ep;  	__u16		flags;  	__u32		length; -	__u8		data[0]; +	__u8		data[];  };  /* Maximum number of non-control endpoints in struct usb_raw_eps_info. */ diff --git a/include/uapi/linux/usb/tmc.h b/include/uapi/linux/usb/tmc.h index fdd4d88a7b95..d791cc58a7f0 100644 --- a/include/uapi/linux/usb/tmc.h +++ b/include/uapi/linux/usb/tmc.h @@ -102,6 +102,9 @@ struct usbtmc_message {  #define USBTMC_IOCTL_MSG_IN_ATTR	_IOR(USBTMC_IOC_NR, 24, __u8)  #define USBTMC_IOCTL_AUTO_ABORT		_IOW(USBTMC_IOC_NR, 25, __u8) +#define USBTMC_IOCTL_GET_STB            _IOR(USBTMC_IOC_NR, 26, __u8) +#define USBTMC_IOCTL_GET_SRQ_STB        _IOR(USBTMC_IOC_NR, 27, __u8) +  /* Cancel and cleanup asynchronous calls */  #define USBTMC_IOCTL_CANCEL_IO		_IO(USBTMC_IOC_NR, 35)  #define USBTMC_IOCTL_CLEANUP_IO		_IO(USBTMC_IOC_NR, 36) diff --git a/include/uapi/linux/usb/video.h b/include/uapi/linux/usb/video.h index d854cb19c42c..e1d9f5773187 100644 --- a/include/uapi/linux/usb/video.h +++ b/include/uapi/linux/usb/video.h @@ -104,6 +104,7 @@  #define UVC_CT_ROLL_ABSOLUTE_CONTROL			0x0f  #define UVC_CT_ROLL_RELATIVE_CONTROL			0x10  #define UVC_CT_PRIVACY_CONTROL				0x11 +#define UVC_CT_REGION_OF_INTEREST_CONTROL		0x14  /* A.9.5. Processing Unit Control Selectors */  #define UVC_PU_CONTROL_UNDEFINED			0x00 @@ -179,6 +180,36 @@  #define UVC_CONTROL_CAP_AUTOUPDATE			(1 << 3)  #define UVC_CONTROL_CAP_ASYNCHRONOUS			(1 << 4) +/* 3.9.2.6 Color Matching Descriptor Values */ +enum uvc_color_primaries_values { +	UVC_COLOR_PRIMARIES_UNSPECIFIED, +	UVC_COLOR_PRIMARIES_BT_709_SRGB, +	UVC_COLOR_PRIMARIES_BT_470_2_M, +	UVC_COLOR_PRIMARIES_BT_470_2_B_G, +	UVC_COLOR_PRIMARIES_SMPTE_170M, +	UVC_COLOR_PRIMARIES_SMPTE_240M, +}; + +enum uvc_transfer_characteristics_values { +	UVC_TRANSFER_CHARACTERISTICS_UNSPECIFIED, +	UVC_TRANSFER_CHARACTERISTICS_BT_709, +	UVC_TRANSFER_CHARACTERISTICS_BT_470_2_M, +	UVC_TRANSFER_CHARACTERISTICS_BT_470_2_B_G, +	UVC_TRANSFER_CHARACTERISTICS_SMPTE_170M, +	UVC_TRANSFER_CHARACTERISTICS_SMPTE_240M, +	UVC_TRANSFER_CHARACTERISTICS_LINEAR, +	UVC_TRANSFER_CHARACTERISTICS_SRGB, +}; + +enum uvc_matrix_coefficients { +	UVC_MATRIX_COEFFICIENTS_UNSPECIFIED, +	UVC_MATRIX_COEFFICIENTS_BT_709, +	UVC_MATRIX_COEFFICIENTS_FCC, +	UVC_MATRIX_COEFFICIENTS_BT_470_2_B_G, +	UVC_MATRIX_COEFFICIENTS_SMPTE_170M, +	UVC_MATRIX_COEFFICIENTS_SMPTE_240M, +}; +  /* ------------------------------------------------------------------------   * UVC structures   */ @@ -302,9 +333,10 @@ struct uvc_processing_unit_descriptor {  	__u8   bControlSize;  	__u8   bmControls[2];  	__u8   iProcessing; +	__u8   bmVideoStandards;  } __attribute__((__packed__)); -#define UVC_DT_PROCESSING_UNIT_SIZE(n)			(9+(n)) +#define UVC_DT_PROCESSING_UNIT_SIZE(n)			(10+(n))  /* 3.7.2.6. Extension Unit Descriptor */  struct uvc_extension_unit_descriptor { @@ -465,7 +497,7 @@ struct uvc_format_uncompressed {  	__u8  bDefaultFrameIndex;  	__u8  bAspectRatioX;  	__u8  bAspectRatioY; -	__u8  bmInterfaceFlags; +	__u8  bmInterlaceFlags;  	__u8  bCopyProtect;  } __attribute__((__packed__)); @@ -521,7 +553,7 @@ struct uvc_format_mjpeg {  	__u8  bDefaultFrameIndex;  	__u8  bAspectRatioX;  	__u8  bAspectRatioY; -	__u8  bmInterfaceFlags; +	__u8  bmInterlaceFlags;  	__u8  bCopyProtect;  } __attribute__((__packed__)); @@ -566,5 +598,63 @@ struct UVC_FRAME_MJPEG(n) {				\  	__le32 dwFrameInterval[n];			\  } __attribute__ ((packed)) +/* Frame Based Payload - 3.1.1. Frame Based Video Format Descriptor */ +struct uvc_format_framebased { +	__u8  bLength; +	__u8  bDescriptorType; +	__u8  bDescriptorSubType; +	__u8  bFormatIndex; +	__u8  bNumFrameDescriptors; +	__u8  guidFormat[16]; +	__u8  bBitsPerPixel; +	__u8  bDefaultFrameIndex; +	__u8  bAspectRatioX; +	__u8  bAspectRatioY; +	__u8  bmInterfaceFlags; +	__u8  bCopyProtect; +	__u8  bVariableSize; +} __attribute__((__packed__)); + +#define UVC_DT_FORMAT_FRAMEBASED_SIZE                  28 + +/* Frame Based Payload - 3.1.2. Frame Based Video Frame Descriptor */ +struct uvc_frame_framebased { +	__u8  bLength; +	__u8  bDescriptorType; +	__u8  bDescriptorSubType; +	__u8  bFrameIndex; +	__u8  bmCapabilities; +	__u16 wWidth; +	__u16 wHeight; +	__u32 dwMinBitRate; +	__u32 dwMaxBitRate; +	__u32 dwDefaultFrameInterval; +	__u8  bFrameIntervalType; +	__u32 dwBytesPerLine; +	__u32 dwFrameInterval[]; +} __attribute__((__packed__)); + +#define UVC_DT_FRAME_FRAMEBASED_SIZE(n)                        (26+4*(n)) + +#define UVC_FRAME_FRAMEBASED(n) \ +	uvc_frame_framebased_##n + +#define DECLARE_UVC_FRAME_FRAMEBASED(n)			\ +struct UVC_FRAME_FRAMEBASED(n) {			\ +	__u8  bLength;					\ +	__u8  bDescriptorType;				\ +	__u8  bDescriptorSubType;                       \ +	__u8  bFrameIndex;                              \ +	__u8  bmCapabilities;                           \ +	__u16 wWidth;                                   \ +	__u16 wHeight;                                  \ +	__u32 dwMinBitRate;                             \ +	__u32 dwMaxBitRate;                             \ +	__u32 dwDefaultFrameInterval;                   \ +	__u8  bFrameIntervalType;                       \ +	__u32 dwBytesPerLine;                           \ +	__u32 dwFrameInterval[n];                       \ +} __attribute__ ((packed)) +  #endif /* __LINUX_USB_VIDEO_H */ diff --git a/include/uapi/linux/usbdevice_fs.h b/include/uapi/linux/usbdevice_fs.h index cf525cddeb94..74a84e02422a 100644 --- a/include/uapi/linux/usbdevice_fs.h +++ b/include/uapi/linux/usbdevice_fs.h @@ -131,7 +131,7 @@ struct usbdevfs_urb {  	unsigned int signr;	/* signal to be sent on completion,  				  or 0 if none should be sent. */  	void __user *usercontext; -	struct usbdevfs_iso_packet_desc iso_frame_desc[0]; +	struct usbdevfs_iso_packet_desc iso_frame_desc[];  };  /* ioctls for talking directly to drivers */ @@ -176,7 +176,7 @@ struct usbdevfs_disconnect_claim {  struct usbdevfs_streams {  	unsigned int num_streams; /* Not used by USBDEVFS_FREE_STREAMS */  	unsigned int num_eps; -	unsigned char eps[0]; +	unsigned char eps[];  };  /* diff --git a/include/uapi/linux/usbip.h b/include/uapi/linux/usbip.h index fd393d908d8a..e4421ad55b2e 100644 --- a/include/uapi/linux/usbip.h +++ b/include/uapi/linux/usbip.h @@ -24,4 +24,30 @@ enum usbip_device_status {  	VDEV_ST_USED,  	VDEV_ST_ERROR  }; + +/* USB URB Transfer flags: + * + * USBIP server and client (vchi) pack URBs in TCP packets. The following + * are the transfer type defines used in USBIP protocol. + */ + +#define USBIP_URB_SHORT_NOT_OK		0x0001 +#define USBIP_URB_ISO_ASAP		0x0002 +#define USBIP_URB_NO_TRANSFER_DMA_MAP	0x0004 +#define USBIP_URB_ZERO_PACKET		0x0040 +#define USBIP_URB_NO_INTERRUPT		0x0080 +#define USBIP_URB_FREE_BUFFER		0x0100 +#define USBIP_URB_DIR_IN		0x0200 +#define USBIP_URB_DIR_OUT		0 +#define USBIP_URB_DIR_MASK		USBIP_URB_DIR_IN + +#define USBIP_URB_DMA_MAP_SINGLE	0x00010000 +#define USBIP_URB_DMA_MAP_PAGE		0x00020000 +#define USBIP_URB_DMA_MAP_SG		0x00040000 +#define USBIP_URB_MAP_LOCAL		0x00080000 +#define USBIP_URB_SETUP_MAP_SINGLE	0x00100000 +#define USBIP_URB_SETUP_MAP_LOCAL	0x00200000 +#define USBIP_URB_DMA_SG_COMBINED	0x00400000 +#define USBIP_URB_ALIGNED_TEMP_BUFFER	0x00800000 +  #endif /* _UAPI_LINUX_USBIP_H */ diff --git a/include/uapi/linux/user_events.h b/include/uapi/linux/user_events.h new file mode 100644 index 000000000000..a03de03dccbc --- /dev/null +++ b/include/uapi/linux/user_events.h @@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Copyright (c) 2021-2022, Microsoft Corporation. + * + * Authors: + *   Beau Belgrave <beaub@linux.microsoft.com> + */ +#ifndef _UAPI_LINUX_USER_EVENTS_H +#define _UAPI_LINUX_USER_EVENTS_H + +#include <linux/types.h> +#include <linux/ioctl.h> + +#define USER_EVENTS_SYSTEM "user_events" +#define USER_EVENTS_MULTI_SYSTEM "user_events_multi" +#define USER_EVENTS_PREFIX "u:" + +/* Create dynamic location entry within a 32-bit value */ +#define DYN_LOC(offset, size) ((size) << 16 | (offset)) + +/* List of supported registration flags */ +enum user_reg_flag { +	/* Event will not delete upon last reference closing */ +	USER_EVENT_REG_PERSIST		= 1U << 0, + +	/* Event will be allowed to have multiple formats */ +	USER_EVENT_REG_MULTI_FORMAT	= 1U << 1, + +	/* This value or above is currently non-ABI */ +	USER_EVENT_REG_MAX		= 1U << 2, +}; + +/* + * Describes an event registration and stores the results of the registration. + * This structure is passed to the DIAG_IOCSREG ioctl, callers at a minimum + * must set the size and name_args before invocation. + */ +struct user_reg { + +	/* Input: Size of the user_reg structure being used */ +	__u32	size; + +	/* Input: Bit in enable address to use */ +	__u8	enable_bit; + +	/* Input: Enable size in bytes at address */ +	__u8	enable_size; + +	/* Input: Flags to use, if any */ +	__u16	flags; + +	/* Input: Address to update when enabled */ +	__u64	enable_addr; + +	/* Input: Pointer to string with event name, description and flags */ +	__u64	name_args; + +	/* Output: Index of the event to use when writing data */ +	__u32	write_index; +} __attribute__((__packed__)); + +/* + * Describes an event unregister, callers must set the size, address and bit. + * This structure is passed to the DIAG_IOCSUNREG ioctl to disable bit updates. + */ +struct user_unreg { +	/* Input: Size of the user_unreg structure being used */ +	__u32	size; + +	/* Input: Bit to unregister */ +	__u8	disable_bit; + +	/* Input: Reserved, set to 0 */ +	__u8	__reserved; + +	/* Input: Reserved, set to 0 */ +	__u16	__reserved2; + +	/* Input: Address to unregister */ +	__u64	disable_addr; +} __attribute__((__packed__)); + +#define DIAG_IOC_MAGIC '*' + +/* Request to register a user_event */ +#define DIAG_IOCSREG _IOWR(DIAG_IOC_MAGIC, 0, struct user_reg *) + +/* Request to delete a user_event */ +#define DIAG_IOCSDEL _IOW(DIAG_IOC_MAGIC, 1, char *) + +/* Requests to unregister a user_event */ +#define DIAG_IOCSUNREG _IOW(DIAG_IOC_MAGIC, 2, struct user_unreg*) + +#endif /* _UAPI_LINUX_USER_EVENTS_H */ diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/userfaultfd.h index e7e98bde221f..2841e4ea8f2c 100644 --- a/include/uapi/linux/userfaultfd.h +++ b/include/uapi/linux/userfaultfd.h @@ -12,6 +12,10 @@  #include <linux/types.h> +/* ioctls for /dev/userfaultfd */ +#define USERFAULTFD_IOC 0xAA +#define USERFAULTFD_IOC_NEW _IO(USERFAULTFD_IOC, 0x00) +  /*   * If the UFFDIO_API is upgraded someday, the UFFDIO_UNREGISTER and   * UFFDIO_WAKE ioctls should be defined as _IOW and not as _IOR.  In @@ -19,15 +23,26 @@   * means the userland is reading).   */  #define UFFD_API ((__u64)0xAA) +#define UFFD_API_REGISTER_MODES (UFFDIO_REGISTER_MODE_MISSING |	\ +				 UFFDIO_REGISTER_MODE_WP |	\ +				 UFFDIO_REGISTER_MODE_MINOR)  #define UFFD_API_FEATURES (UFFD_FEATURE_PAGEFAULT_FLAG_WP |	\  			   UFFD_FEATURE_EVENT_FORK |		\  			   UFFD_FEATURE_EVENT_REMAP |		\ -			   UFFD_FEATURE_EVENT_REMOVE |	\ +			   UFFD_FEATURE_EVENT_REMOVE |		\  			   UFFD_FEATURE_EVENT_UNMAP |		\  			   UFFD_FEATURE_MISSING_HUGETLBFS |	\  			   UFFD_FEATURE_MISSING_SHMEM |		\  			   UFFD_FEATURE_SIGBUS |		\ -			   UFFD_FEATURE_THREAD_ID) +			   UFFD_FEATURE_THREAD_ID |		\ +			   UFFD_FEATURE_MINOR_HUGETLBFS |	\ +			   UFFD_FEATURE_MINOR_SHMEM |		\ +			   UFFD_FEATURE_EXACT_ADDRESS |		\ +			   UFFD_FEATURE_WP_HUGETLBFS_SHMEM |	\ +			   UFFD_FEATURE_WP_UNPOPULATED |	\ +			   UFFD_FEATURE_POISON |		\ +			   UFFD_FEATURE_WP_ASYNC |		\ +			   UFFD_FEATURE_MOVE)  #define UFFD_API_IOCTLS				\  	((__u64)1 << _UFFDIO_REGISTER |		\  	 (__u64)1 << _UFFDIO_UNREGISTER |	\ @@ -36,10 +51,16 @@  	((__u64)1 << _UFFDIO_WAKE |		\  	 (__u64)1 << _UFFDIO_COPY |		\  	 (__u64)1 << _UFFDIO_ZEROPAGE |		\ -	 (__u64)1 << _UFFDIO_WRITEPROTECT) +	 (__u64)1 << _UFFDIO_MOVE |		\ +	 (__u64)1 << _UFFDIO_WRITEPROTECT |	\ +	 (__u64)1 << _UFFDIO_CONTINUE |		\ +	 (__u64)1 << _UFFDIO_POISON)  #define UFFD_API_RANGE_IOCTLS_BASIC		\  	((__u64)1 << _UFFDIO_WAKE |		\ -	 (__u64)1 << _UFFDIO_COPY) +	 (__u64)1 << _UFFDIO_COPY |		\ +	 (__u64)1 << _UFFDIO_WRITEPROTECT |	\ +	 (__u64)1 << _UFFDIO_CONTINUE |		\ +	 (__u64)1 << _UFFDIO_POISON)  /*   * Valid ioctl command number range with this API is from 0x00 to @@ -54,7 +75,10 @@  #define _UFFDIO_WAKE			(0x02)  #define _UFFDIO_COPY			(0x03)  #define _UFFDIO_ZEROPAGE		(0x04) +#define _UFFDIO_MOVE			(0x05)  #define _UFFDIO_WRITEPROTECT		(0x06) +#define _UFFDIO_CONTINUE		(0x07) +#define _UFFDIO_POISON			(0x08)  #define _UFFDIO_API			(0x3F)  /* userfaultfd ioctl ids */ @@ -71,8 +95,14 @@  				      struct uffdio_copy)  #define UFFDIO_ZEROPAGE		_IOWR(UFFDIO, _UFFDIO_ZEROPAGE,	\  				      struct uffdio_zeropage) +#define UFFDIO_MOVE		_IOWR(UFFDIO, _UFFDIO_MOVE,	\ +				      struct uffdio_move)  #define UFFDIO_WRITEPROTECT	_IOWR(UFFDIO, _UFFDIO_WRITEPROTECT, \  				      struct uffdio_writeprotect) +#define UFFDIO_CONTINUE		_IOWR(UFFDIO, _UFFDIO_CONTINUE,	\ +				      struct uffdio_continue) +#define UFFDIO_POISON		_IOWR(UFFDIO, _UFFDIO_POISON, \ +				      struct uffdio_poison)  /* read() structure */  struct uffd_msg { @@ -127,6 +157,7 @@ struct uffd_msg {  /* flags for UFFD_EVENT_PAGEFAULT */  #define UFFD_PAGEFAULT_FLAG_WRITE	(1<<0)	/* If this was a write fault */  #define UFFD_PAGEFAULT_FLAG_WP		(1<<1)	/* If reason is VM_UFFD_WP */ +#define UFFD_PAGEFAULT_FLAG_MINOR	(1<<2)	/* If reason is VM_UFFD_MINOR */  struct uffdio_api {  	/* userland asks for an API number and the features to enable */ @@ -171,6 +202,34 @@ struct uffdio_api {  	 *  	 * UFFD_FEATURE_THREAD_ID pid of the page faulted task_struct will  	 * be returned, if feature is not requested 0 will be returned. +	 * +	 * UFFD_FEATURE_MINOR_HUGETLBFS indicates that minor faults +	 * can be intercepted (via REGISTER_MODE_MINOR) for +	 * hugetlbfs-backed pages. +	 * +	 * UFFD_FEATURE_MINOR_SHMEM indicates the same support as +	 * UFFD_FEATURE_MINOR_HUGETLBFS, but for shmem-backed pages instead. +	 * +	 * UFFD_FEATURE_EXACT_ADDRESS indicates that the exact address of page +	 * faults would be provided and the offset within the page would not be +	 * masked. +	 * +	 * UFFD_FEATURE_WP_HUGETLBFS_SHMEM indicates that userfaultfd +	 * write-protection mode is supported on both shmem and hugetlbfs. +	 * +	 * UFFD_FEATURE_WP_UNPOPULATED indicates that userfaultfd +	 * write-protection mode will always apply to unpopulated pages +	 * (i.e. empty ptes).  This will be the default behavior for shmem +	 * & hugetlbfs, so this flag only affects anonymous memory behavior +	 * when userfault write-protection mode is registered. +	 * +	 * UFFD_FEATURE_WP_ASYNC indicates that userfaultfd write-protection +	 * asynchronous mode is supported in which the write fault is +	 * automatically resolved and write-protection is un-set. +	 * It implies UFFD_FEATURE_WP_UNPOPULATED. +	 * +	 * UFFD_FEATURE_MOVE indicates that the kernel supports moving an +	 * existing page contents from userspace.  	 */  #define UFFD_FEATURE_PAGEFAULT_FLAG_WP		(1<<0)  #define UFFD_FEATURE_EVENT_FORK			(1<<1) @@ -181,6 +240,14 @@ struct uffdio_api {  #define UFFD_FEATURE_EVENT_UNMAP		(1<<6)  #define UFFD_FEATURE_SIGBUS			(1<<7)  #define UFFD_FEATURE_THREAD_ID			(1<<8) +#define UFFD_FEATURE_MINOR_HUGETLBFS		(1<<9) +#define UFFD_FEATURE_MINOR_SHMEM		(1<<10) +#define UFFD_FEATURE_EXACT_ADDRESS		(1<<11) +#define UFFD_FEATURE_WP_HUGETLBFS_SHMEM		(1<<12) +#define UFFD_FEATURE_WP_UNPOPULATED		(1<<13) +#define UFFD_FEATURE_POISON			(1<<14) +#define UFFD_FEATURE_WP_ASYNC			(1<<15) +#define UFFD_FEATURE_MOVE			(1<<16)  	__u64 features;  	__u64 ioctls; @@ -195,6 +262,7 @@ struct uffdio_register {  	struct uffdio_range range;  #define UFFDIO_REGISTER_MODE_MISSING	((__u64)1<<0)  #define UFFDIO_REGISTER_MODE_WP		((__u64)1<<1) +#define UFFDIO_REGISTER_MODE_MINOR	((__u64)1<<2)  	__u64 mode;  	/* @@ -257,4 +325,62 @@ struct uffdio_writeprotect {  	__u64 mode;  }; +struct uffdio_continue { +	struct uffdio_range range; +#define UFFDIO_CONTINUE_MODE_DONTWAKE		((__u64)1<<0) +	/* +	 * UFFDIO_CONTINUE_MODE_WP will map the page write protected on +	 * the fly.  UFFDIO_CONTINUE_MODE_WP is available only if the +	 * write protected ioctl is implemented for the range +	 * according to the uffdio_register.ioctls. +	 */ +#define UFFDIO_CONTINUE_MODE_WP			((__u64)1<<1) +	__u64 mode; + +	/* +	 * Fields below here are written by the ioctl and must be at the end: +	 * the copy_from_user will not read past here. +	 */ +	__s64 mapped; +}; + +struct uffdio_poison { +	struct uffdio_range range; +#define UFFDIO_POISON_MODE_DONTWAKE		((__u64)1<<0) +	__u64 mode; + +	/* +	 * Fields below here are written by the ioctl and must be at the end: +	 * the copy_from_user will not read past here. +	 */ +	__s64 updated; +}; + +struct uffdio_move { +	__u64 dst; +	__u64 src; +	__u64 len; +	/* +	 * Especially if used to atomically remove memory from the +	 * address space the wake on the dst range is not needed. +	 */ +#define UFFDIO_MOVE_MODE_DONTWAKE		((__u64)1<<0) +#define UFFDIO_MOVE_MODE_ALLOW_SRC_HOLES	((__u64)1<<1) +	__u64 mode; +	/* +	 * "move" is written by the ioctl and must be at the end: the +	 * copy_from_user will not read the last 8 bytes. +	 */ +	__s64 move; +}; + +/* + * Flags for the userfaultfd(2) system call itself. + */ + +/* + * Create a userfaultfd that can handle page faults only in user mode. + */ +#define UFFD_USER_MODE_ONLY 1 +  #endif /* _LINUX_USERFAULTFD_H */ diff --git a/include/uapi/linux/uuid.h b/include/uapi/linux/uuid.h index e5a7eecef7c3..8443738f4bb2 100644 --- a/include/uapi/linux/uuid.h +++ b/include/uapi/linux/uuid.h @@ -1,42 +1 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * UUID/GUID definition - * - * Copyright (C) 2010, Intel Corp. - *	Huang Ying <ying.huang@intel.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - */ - -#ifndef _UAPI_LINUX_UUID_H_ -#define _UAPI_LINUX_UUID_H_ - -#include <linux/types.h> - -typedef struct { -	__u8 b[16]; -} guid_t; - -#define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)			\ -((guid_t)								\ -{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ -   (b) & 0xff, ((b) >> 8) & 0xff,					\ -   (c) & 0xff, ((c) >> 8) & 0xff,					\ -   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) - -/* backwards compatibility, don't use in new code */ -typedef guid_t uuid_le; -#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\ -	GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) -#define NULL_UUID_LE							\ -	UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\ -	     0x00, 0x00, 0x00, 0x00) - -#endif /* _UAPI_LINUX_UUID_H_ */ +#include <linux/mei_uuid.h> diff --git a/include/uapi/linux/uvcvideo.h b/include/uapi/linux/uvcvideo.h index f80f05b3c423..cbe15bca9569 100644 --- a/include/uapi/linux/uvcvideo.h +++ b/include/uapi/linux/uvcvideo.h @@ -16,6 +16,7 @@  #define UVC_CTRL_DATA_TYPE_BOOLEAN	3  #define UVC_CTRL_DATA_TYPE_ENUM		4  #define UVC_CTRL_DATA_TYPE_BITMASK	5 +#define UVC_CTRL_DATA_TYPE_RECT		6  /* Control flags */  #define UVC_CTRL_FLAG_SET_CUR		(1 << 0) @@ -36,9 +37,23 @@  	 UVC_CTRL_FLAG_GET_MAX | UVC_CTRL_FLAG_GET_RES | \  	 UVC_CTRL_FLAG_GET_DEF) +#define UVC_MENU_NAME_LEN 32 + +/* V4L2 driver-specific controls */ +#define V4L2_CID_UVC_REGION_OF_INTEREST_RECT	(V4L2_CID_USER_UVC_BASE + 1) +#define V4L2_CID_UVC_REGION_OF_INTEREST_AUTO	(V4L2_CID_USER_UVC_BASE + 2) +#define V4L2_UVC_REGION_OF_INTEREST_AUTO_EXPOSURE		(1 << 0) +#define V4L2_UVC_REGION_OF_INTEREST_AUTO_IRIS			(1 << 1) +#define V4L2_UVC_REGION_OF_INTEREST_AUTO_WHITE_BALANCE		(1 << 2) +#define V4L2_UVC_REGION_OF_INTEREST_AUTO_FOCUS			(1 << 3) +#define V4L2_UVC_REGION_OF_INTEREST_AUTO_FACE_DETECT		(1 << 4) +#define V4L2_UVC_REGION_OF_INTEREST_AUTO_DETECT_AND_TRACK	(1 << 5) +#define V4L2_UVC_REGION_OF_INTEREST_AUTO_IMAGE_STABILIZATION	(1 << 6) +#define V4L2_UVC_REGION_OF_INTEREST_AUTO_HIGHER_QUALITY		(1 << 7) +  struct uvc_menu_info {  	__u32 value; -	__u8 name[32]; +	__u8 name[UVC_MENU_NAME_LEN];  };  struct uvc_xu_control_mapping { @@ -76,17 +91,17 @@ struct uvc_xu_control_query {  /**   * struct uvc_meta_buf - metadata buffer building block - * @ns		- system timestamp of the payload in nanoseconds - * @sof		- USB Frame Number - * @length	- length of the payload header - * @flags	- payload header flags - * @buf		- optional device-specific header data + * @ns: system timestamp of the payload in nanoseconds + * @sof: USB Frame Number + * @length: length of the payload header + * @flags: payload header flags + * @buf: optional device-specific header data   *   * UVC metadata nodes fill buffers with possibly multiple instances of this   * struct. The first two fields are added by the driver, they can be used for   * clock synchronisation. The rest is an exact copy of a UVC payload header.   * Only complete objects with complete buffers are included. Therefore it's - * always sizeof(meta->ts) + sizeof(meta->sof) + meta->length bytes large. + * always sizeof(meta->ns) + sizeof(meta->sof) + meta->length bytes large.   */  struct uvc_meta_buf {  	__u64 ns; diff --git a/include/uapi/linux/v4l2-common.h b/include/uapi/linux/v4l2-common.h index 7d21c1634b4d..5a23a15d78ac 100644 --- a/include/uapi/linux/v4l2-common.h +++ b/include/uapi/linux/v4l2-common.h @@ -10,45 +10,6 @@   *   * Copyright (C) 2012 Nokia Corporation   * Contact: Sakari Ailus <sakari.ailus@iki.fi> - * - *  This program is free software; you can redistribute it and/or modify - *  it under the terms of the GNU General Public License as published by - *  the Free Software Foundation; either version 2 of the License, or - *  (at your option) any later version. - * - *  This program is distributed in the hope that it will be useful, - *  but WITHOUT ANY WARRANTY; without even the implied warranty of - *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - *  GNU General Public License for more details. - * - *  Alternatively you can redistribute this file under the terms of the - *  BSD license as stated below: - * - *  Redistribution and use in source and binary forms, with or without - *  modification, are permitted provided that the following conditions - *  are met: - *  1. Redistributions of source code must retain the above copyright - *     notice, this list of conditions and the following disclaimer. - *  2. Redistributions in binary form must reproduce the above copyright - *     notice, this list of conditions and the following disclaimer in - *     the documentation and/or other materials provided with the - *     distribution. - *  3. The names of its contributors may not be used to endorse or promote - *     products derived from this software without specific prior written - *     permission. - * - *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - *  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *   */  #ifndef __V4L2_COMMON__ diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 62271418c1be..f836512e9deb 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -4,44 +4,6 @@   *   *  Copyright (C) 1999-2012 the contributors   * - *  This program is free software; you can redistribute it and/or modify - *  it under the terms of the GNU General Public License as published by - *  the Free Software Foundation; either version 2 of the License, or - *  (at your option) any later version. - * - *  This program is distributed in the hope that it will be useful, - *  but WITHOUT ANY WARRANTY; without even the implied warranty of - *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - *  GNU General Public License for more details. - * - *  Alternatively you can redistribute this file under the terms of the - *  BSD license as stated below: - * - *  Redistribution and use in source and binary forms, with or without - *  modification, are permitted provided that the following conditions - *  are met: - *  1. Redistributions of source code must retain the above copyright - *     notice, this list of conditions and the following disclaimer. - *  2. Redistributions in binary form must reproduce the above copyright - *     notice, this list of conditions and the following disclaimer in - *     the documentation and/or other materials provided with the - *     distribution. - *  3. The names of its contributors may not be used to endorse or promote - *     products derived from this software without specific prior written - *     permission. - * - *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - *  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *   *  The contents of this header was split off from videodev2.h. All control   *  definitions should be added to this header, which is included by   *  videodev2.h. @@ -50,11 +12,12 @@  #ifndef __LINUX_V4L2_CONTROLS_H  #define __LINUX_V4L2_CONTROLS_H +#include <linux/const.h>  #include <linux/types.h>  /* Control classes */  #define V4L2_CTRL_CLASS_USER		0x00980000	/* Old-style 'user' controls */ -#define V4L2_CTRL_CLASS_MPEG		0x00990000	/* MPEG-compression controls */ +#define V4L2_CTRL_CLASS_CODEC		0x00990000	/* Stateful codec controls */  #define V4L2_CTRL_CLASS_CAMERA		0x009a0000	/* Camera class controls */  #define V4L2_CTRL_CLASS_FM_TX		0x009b0000	/* FM Modulator controls */  #define V4L2_CTRL_CLASS_FLASH		0x009c0000	/* Camera flash controls */ @@ -65,6 +28,8 @@  #define V4L2_CTRL_CLASS_FM_RX		0x00a10000	/* FM Receiver controls */  #define V4L2_CTRL_CLASS_RF_TUNER	0x00a20000	/* RF tuner controls */  #define V4L2_CTRL_CLASS_DETECT		0x00a30000	/* Detection controls */ +#define V4L2_CTRL_CLASS_CODEC_STATELESS 0x00a40000	/* Stateless codecs controls */ +#define V4L2_CTRL_CLASS_COLORIMETRY	0x00a50000	/* Colorimetry controls */  /* User-class control IDs */ @@ -125,6 +90,7 @@ enum v4l2_colorfx {  	V4L2_COLORFX_SOLARIZATION		= 13,  	V4L2_COLORFX_ANTIQUE			= 14,  	V4L2_COLORFX_SET_CBCR			= 15, +	V4L2_COLORFX_SET_RGB			= 16,  };  #define V4L2_CID_AUTOBRIGHTNESS			(V4L2_CID_BASE+32)  #define V4L2_CID_BAND_STOP_FILTER		(V4L2_CID_BASE+33) @@ -142,15 +108,20 @@ enum v4l2_colorfx {  #define V4L2_CID_ALPHA_COMPONENT		(V4L2_CID_BASE+41)  #define V4L2_CID_COLORFX_CBCR			(V4L2_CID_BASE+42) +#define V4L2_CID_COLORFX_RGB			(V4L2_CID_BASE+43)  /* last CID + 1 */ -#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+43) +#define V4L2_CID_LASTP1                         (V4L2_CID_BASE+44)  /* USER-class private control IDs */ -/* The base for the meye driver controls. See linux/meye.h for the list - * of controls. We reserve 16 controls for this driver. */ +#ifndef __KERNEL__ +/* + * The base for the meye driver controls. This driver was removed, but + * we keep this define in case any software still uses it. + */  #define V4L2_CID_USER_MEYE_BASE			(V4L2_CID_USER_BASE + 0x1000) +#endif  /* The base for the bttv driver controls.   * We reserve 32 controls for this driver. */ @@ -198,15 +169,74 @@ enum v4l2_colorfx {   */  #define V4L2_CID_USER_ATMEL_ISC_BASE		(V4L2_CID_USER_BASE + 0x10c0) +/* + * The base for the CODA driver controls. + * We reserve 16 controls for this driver. + */ +#define V4L2_CID_USER_CODA_BASE			(V4L2_CID_USER_BASE + 0x10e0) +/* + * The base for MIPI CCS driver controls. + * We reserve 128 controls for this driver. + */ +#define V4L2_CID_USER_CCS_BASE			(V4L2_CID_USER_BASE + 0x10f0) +/* + * The base for Allegro driver controls. + * We reserve 16 controls for this driver. + */ +#define V4L2_CID_USER_ALLEGRO_BASE		(V4L2_CID_USER_BASE + 0x1170) + +/* + * The base for the isl7998x driver controls. + * We reserve 16 controls for this driver. + */ +#define V4L2_CID_USER_ISL7998X_BASE		(V4L2_CID_USER_BASE + 0x1180) + +/* + * The base for DW100 driver controls. + * We reserve 16 controls for this driver. + */ +#define V4L2_CID_USER_DW100_BASE		(V4L2_CID_USER_BASE + 0x1190) + +/* + * The base for Aspeed driver controls. + * We reserve 16 controls for this driver. + */ +#define V4L2_CID_USER_ASPEED_BASE		(V4L2_CID_USER_BASE + 0x11a0) + +/* + * The base for Nuvoton NPCM driver controls. + * We reserve 16 controls for this driver. + */ +#define V4L2_CID_USER_NPCM_BASE			(V4L2_CID_USER_BASE + 0x11b0) + +/* + * The base for THine THP7312 driver controls. + * We reserve 32 controls for this driver. + */ +#define V4L2_CID_USER_THP7312_BASE		(V4L2_CID_USER_BASE + 0x11c0) + +/* + * The base for the uvc driver controls. + * See linux/uvcvideo.h for the list of controls. + * We reserve 64 controls for this driver. + */ +#define V4L2_CID_USER_UVC_BASE			(V4L2_CID_USER_BASE + 0x11e0) + +/* + * The base for Rockchip ISP1 driver controls. + * We reserve 16 controls for this driver. + */ +#define V4L2_CID_USER_RKISP1_BASE		(V4L2_CID_USER_BASE + 0x1220) +  /* MPEG-class control IDs */  /* The MPEG controls are applicable to all codec controls   * and the 'MPEG' part of the define is historical */ -#define V4L2_CID_MPEG_BASE			(V4L2_CTRL_CLASS_MPEG | 0x900) -#define V4L2_CID_MPEG_CLASS			(V4L2_CTRL_CLASS_MPEG | 1) +#define V4L2_CID_CODEC_BASE			(V4L2_CTRL_CLASS_CODEC | 0x900) +#define V4L2_CID_CODEC_CLASS			(V4L2_CTRL_CLASS_CODEC | 1)  /*  MPEG streams, specific to multiplexed streams */ -#define V4L2_CID_MPEG_STREAM_TYPE		(V4L2_CID_MPEG_BASE+0) +#define V4L2_CID_MPEG_STREAM_TYPE		(V4L2_CID_CODEC_BASE+0)  enum v4l2_mpeg_stream_type {  	V4L2_MPEG_STREAM_TYPE_MPEG2_PS   = 0, /* MPEG-2 program stream */  	V4L2_MPEG_STREAM_TYPE_MPEG2_TS   = 1, /* MPEG-2 transport stream */ @@ -215,26 +245,26 @@ enum v4l2_mpeg_stream_type {  	V4L2_MPEG_STREAM_TYPE_MPEG1_VCD  = 4, /* MPEG-1 VCD-compatible stream */  	V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */  }; -#define V4L2_CID_MPEG_STREAM_PID_PMT		(V4L2_CID_MPEG_BASE+1) -#define V4L2_CID_MPEG_STREAM_PID_AUDIO		(V4L2_CID_MPEG_BASE+2) -#define V4L2_CID_MPEG_STREAM_PID_VIDEO		(V4L2_CID_MPEG_BASE+3) -#define V4L2_CID_MPEG_STREAM_PID_PCR		(V4L2_CID_MPEG_BASE+4) -#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO	(V4L2_CID_MPEG_BASE+5) -#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO	(V4L2_CID_MPEG_BASE+6) -#define V4L2_CID_MPEG_STREAM_VBI_FMT		(V4L2_CID_MPEG_BASE+7) +#define V4L2_CID_MPEG_STREAM_PID_PMT		(V4L2_CID_CODEC_BASE+1) +#define V4L2_CID_MPEG_STREAM_PID_AUDIO		(V4L2_CID_CODEC_BASE+2) +#define V4L2_CID_MPEG_STREAM_PID_VIDEO		(V4L2_CID_CODEC_BASE+3) +#define V4L2_CID_MPEG_STREAM_PID_PCR		(V4L2_CID_CODEC_BASE+4) +#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO	(V4L2_CID_CODEC_BASE+5) +#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO	(V4L2_CID_CODEC_BASE+6) +#define V4L2_CID_MPEG_STREAM_VBI_FMT		(V4L2_CID_CODEC_BASE+7)  enum v4l2_mpeg_stream_vbi_fmt {  	V4L2_MPEG_STREAM_VBI_FMT_NONE = 0,  /* No VBI in the MPEG stream */  	V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1,  /* VBI in private packets, IVTV format */  };  /*  MPEG audio controls specific to multiplexed streams  */ -#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ	(V4L2_CID_MPEG_BASE+100) +#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ	(V4L2_CID_CODEC_BASE+100)  enum v4l2_mpeg_audio_sampling_freq {  	V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0,  	V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1,  	V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2,  }; -#define V4L2_CID_MPEG_AUDIO_ENCODING		(V4L2_CID_MPEG_BASE+101) +#define V4L2_CID_MPEG_AUDIO_ENCODING		(V4L2_CID_CODEC_BASE+101)  enum v4l2_mpeg_audio_encoding {  	V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0,  	V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1, @@ -242,7 +272,7 @@ enum v4l2_mpeg_audio_encoding {  	V4L2_MPEG_AUDIO_ENCODING_AAC     = 3,  	V4L2_MPEG_AUDIO_ENCODING_AC3     = 4,  }; -#define V4L2_CID_MPEG_AUDIO_L1_BITRATE		(V4L2_CID_MPEG_BASE+102) +#define V4L2_CID_MPEG_AUDIO_L1_BITRATE		(V4L2_CID_CODEC_BASE+102)  enum v4l2_mpeg_audio_l1_bitrate {  	V4L2_MPEG_AUDIO_L1_BITRATE_32K  = 0,  	V4L2_MPEG_AUDIO_L1_BITRATE_64K  = 1, @@ -259,7 +289,7 @@ enum v4l2_mpeg_audio_l1_bitrate {  	V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12,  	V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13,  }; -#define V4L2_CID_MPEG_AUDIO_L2_BITRATE		(V4L2_CID_MPEG_BASE+103) +#define V4L2_CID_MPEG_AUDIO_L2_BITRATE		(V4L2_CID_CODEC_BASE+103)  enum v4l2_mpeg_audio_l2_bitrate {  	V4L2_MPEG_AUDIO_L2_BITRATE_32K  = 0,  	V4L2_MPEG_AUDIO_L2_BITRATE_48K  = 1, @@ -276,7 +306,7 @@ enum v4l2_mpeg_audio_l2_bitrate {  	V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12,  	V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13,  }; -#define V4L2_CID_MPEG_AUDIO_L3_BITRATE		(V4L2_CID_MPEG_BASE+104) +#define V4L2_CID_MPEG_AUDIO_L3_BITRATE		(V4L2_CID_CODEC_BASE+104)  enum v4l2_mpeg_audio_l3_bitrate {  	V4L2_MPEG_AUDIO_L3_BITRATE_32K  = 0,  	V4L2_MPEG_AUDIO_L3_BITRATE_40K  = 1, @@ -293,34 +323,34 @@ enum v4l2_mpeg_audio_l3_bitrate {  	V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12,  	V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13,  }; -#define V4L2_CID_MPEG_AUDIO_MODE		(V4L2_CID_MPEG_BASE+105) +#define V4L2_CID_MPEG_AUDIO_MODE		(V4L2_CID_CODEC_BASE+105)  enum v4l2_mpeg_audio_mode {  	V4L2_MPEG_AUDIO_MODE_STEREO       = 0,  	V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1,  	V4L2_MPEG_AUDIO_MODE_DUAL         = 2,  	V4L2_MPEG_AUDIO_MODE_MONO         = 3,  }; -#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION	(V4L2_CID_MPEG_BASE+106) +#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION	(V4L2_CID_CODEC_BASE+106)  enum v4l2_mpeg_audio_mode_extension {  	V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4  = 0,  	V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8  = 1,  	V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2,  	V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3,  }; -#define V4L2_CID_MPEG_AUDIO_EMPHASIS		(V4L2_CID_MPEG_BASE+107) +#define V4L2_CID_MPEG_AUDIO_EMPHASIS		(V4L2_CID_CODEC_BASE+107)  enum v4l2_mpeg_audio_emphasis {  	V4L2_MPEG_AUDIO_EMPHASIS_NONE         = 0,  	V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1,  	V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17    = 2,  }; -#define V4L2_CID_MPEG_AUDIO_CRC			(V4L2_CID_MPEG_BASE+108) +#define V4L2_CID_MPEG_AUDIO_CRC			(V4L2_CID_CODEC_BASE+108)  enum v4l2_mpeg_audio_crc {  	V4L2_MPEG_AUDIO_CRC_NONE  = 0,  	V4L2_MPEG_AUDIO_CRC_CRC16 = 1,  }; -#define V4L2_CID_MPEG_AUDIO_MUTE		(V4L2_CID_MPEG_BASE+109) -#define V4L2_CID_MPEG_AUDIO_AAC_BITRATE		(V4L2_CID_MPEG_BASE+110) -#define V4L2_CID_MPEG_AUDIO_AC3_BITRATE		(V4L2_CID_MPEG_BASE+111) +#define V4L2_CID_MPEG_AUDIO_MUTE		(V4L2_CID_CODEC_BASE+109) +#define V4L2_CID_MPEG_AUDIO_AAC_BITRATE		(V4L2_CID_CODEC_BASE+110) +#define V4L2_CID_MPEG_AUDIO_AC3_BITRATE		(V4L2_CID_CODEC_BASE+111)  enum v4l2_mpeg_audio_ac3_bitrate {  	V4L2_MPEG_AUDIO_AC3_BITRATE_32K  = 0,  	V4L2_MPEG_AUDIO_AC3_BITRATE_40K  = 1, @@ -342,7 +372,7 @@ enum v4l2_mpeg_audio_ac3_bitrate {  	V4L2_MPEG_AUDIO_AC3_BITRATE_576K = 17,  	V4L2_MPEG_AUDIO_AC3_BITRATE_640K = 18,  }; -#define V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK	(V4L2_CID_MPEG_BASE+112) +#define V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK	(V4L2_CID_CODEC_BASE+112)  enum v4l2_mpeg_audio_dec_playback {  	V4L2_MPEG_AUDIO_DEC_PLAYBACK_AUTO	    = 0,  	V4L2_MPEG_AUDIO_DEC_PLAYBACK_STEREO	    = 1, @@ -351,51 +381,52 @@ enum v4l2_mpeg_audio_dec_playback {  	V4L2_MPEG_AUDIO_DEC_PLAYBACK_MONO	    = 4,  	V4L2_MPEG_AUDIO_DEC_PLAYBACK_SWAPPED_STEREO = 5,  }; -#define V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK (V4L2_CID_MPEG_BASE+113) +#define V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK (V4L2_CID_CODEC_BASE+113)  /*  MPEG video controls specific to multiplexed streams */ -#define V4L2_CID_MPEG_VIDEO_ENCODING		(V4L2_CID_MPEG_BASE+200) +#define V4L2_CID_MPEG_VIDEO_ENCODING		(V4L2_CID_CODEC_BASE+200)  enum v4l2_mpeg_video_encoding {  	V4L2_MPEG_VIDEO_ENCODING_MPEG_1     = 0,  	V4L2_MPEG_VIDEO_ENCODING_MPEG_2     = 1,  	V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC = 2,  }; -#define V4L2_CID_MPEG_VIDEO_ASPECT		(V4L2_CID_MPEG_BASE+201) +#define V4L2_CID_MPEG_VIDEO_ASPECT		(V4L2_CID_CODEC_BASE+201)  enum v4l2_mpeg_video_aspect {  	V4L2_MPEG_VIDEO_ASPECT_1x1     = 0,  	V4L2_MPEG_VIDEO_ASPECT_4x3     = 1,  	V4L2_MPEG_VIDEO_ASPECT_16x9    = 2,  	V4L2_MPEG_VIDEO_ASPECT_221x100 = 3,  }; -#define V4L2_CID_MPEG_VIDEO_B_FRAMES		(V4L2_CID_MPEG_BASE+202) -#define V4L2_CID_MPEG_VIDEO_GOP_SIZE		(V4L2_CID_MPEG_BASE+203) -#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE		(V4L2_CID_MPEG_BASE+204) -#define V4L2_CID_MPEG_VIDEO_PULLDOWN		(V4L2_CID_MPEG_BASE+205) -#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE	(V4L2_CID_MPEG_BASE+206) +#define V4L2_CID_MPEG_VIDEO_B_FRAMES		(V4L2_CID_CODEC_BASE+202) +#define V4L2_CID_MPEG_VIDEO_GOP_SIZE		(V4L2_CID_CODEC_BASE+203) +#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE		(V4L2_CID_CODEC_BASE+204) +#define V4L2_CID_MPEG_VIDEO_PULLDOWN		(V4L2_CID_CODEC_BASE+205) +#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE	(V4L2_CID_CODEC_BASE+206)  enum v4l2_mpeg_video_bitrate_mode {  	V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0,  	V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1, -}; -#define V4L2_CID_MPEG_VIDEO_BITRATE		(V4L2_CID_MPEG_BASE+207) -#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK	(V4L2_CID_MPEG_BASE+208) -#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209) -#define V4L2_CID_MPEG_VIDEO_MUTE		(V4L2_CID_MPEG_BASE+210) -#define V4L2_CID_MPEG_VIDEO_MUTE_YUV		(V4L2_CID_MPEG_BASE+211) -#define V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE		(V4L2_CID_MPEG_BASE+212) -#define V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER	(V4L2_CID_MPEG_BASE+213) -#define V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB		(V4L2_CID_MPEG_BASE+214) -#define V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE			(V4L2_CID_MPEG_BASE+215) -#define V4L2_CID_MPEG_VIDEO_HEADER_MODE				(V4L2_CID_MPEG_BASE+216) +	V4L2_MPEG_VIDEO_BITRATE_MODE_CQ  = 2, +}; +#define V4L2_CID_MPEG_VIDEO_BITRATE		(V4L2_CID_CODEC_BASE+207) +#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK	(V4L2_CID_CODEC_BASE+208) +#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_CODEC_BASE+209) +#define V4L2_CID_MPEG_VIDEO_MUTE		(V4L2_CID_CODEC_BASE+210) +#define V4L2_CID_MPEG_VIDEO_MUTE_YUV		(V4L2_CID_CODEC_BASE+211) +#define V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE		(V4L2_CID_CODEC_BASE+212) +#define V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER	(V4L2_CID_CODEC_BASE+213) +#define V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB		(V4L2_CID_CODEC_BASE+214) +#define V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE			(V4L2_CID_CODEC_BASE+215) +#define V4L2_CID_MPEG_VIDEO_HEADER_MODE				(V4L2_CID_CODEC_BASE+216)  enum v4l2_mpeg_video_header_mode {  	V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE			= 0,  	V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME	= 1,  }; -#define V4L2_CID_MPEG_VIDEO_MAX_REF_PIC			(V4L2_CID_MPEG_BASE+217) -#define V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE		(V4L2_CID_MPEG_BASE+218) -#define V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES	(V4L2_CID_MPEG_BASE+219) -#define V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB		(V4L2_CID_MPEG_BASE+220) -#define V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE		(V4L2_CID_MPEG_BASE+221) +#define V4L2_CID_MPEG_VIDEO_MAX_REF_PIC			(V4L2_CID_CODEC_BASE+217) +#define V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE		(V4L2_CID_CODEC_BASE+218) +#define V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES	(V4L2_CID_CODEC_BASE+219) +#define V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB		(V4L2_CID_CODEC_BASE+220) +#define V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE		(V4L2_CID_CODEC_BASE+221)  enum v4l2_mpeg_video_multi_slice_mode {  	V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE		= 0,  	V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_MB		= 1, @@ -406,24 +437,36 @@ enum v4l2_mpeg_video_multi_slice_mode {  	V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES	= 2,  #endif  }; -#define V4L2_CID_MPEG_VIDEO_VBV_SIZE			(V4L2_CID_MPEG_BASE+222) -#define V4L2_CID_MPEG_VIDEO_DEC_PTS			(V4L2_CID_MPEG_BASE+223) -#define V4L2_CID_MPEG_VIDEO_DEC_FRAME			(V4L2_CID_MPEG_BASE+224) -#define V4L2_CID_MPEG_VIDEO_VBV_DELAY			(V4L2_CID_MPEG_BASE+225) -#define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER		(V4L2_CID_MPEG_BASE+226) -#define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE		(V4L2_CID_MPEG_BASE+227) -#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE		(V4L2_CID_MPEG_BASE+228) -#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME		(V4L2_CID_MPEG_BASE+229) +#define V4L2_CID_MPEG_VIDEO_VBV_SIZE			(V4L2_CID_CODEC_BASE+222) +#define V4L2_CID_MPEG_VIDEO_DEC_PTS			(V4L2_CID_CODEC_BASE+223) +#define V4L2_CID_MPEG_VIDEO_DEC_FRAME			(V4L2_CID_CODEC_BASE+224) +#define V4L2_CID_MPEG_VIDEO_VBV_DELAY			(V4L2_CID_CODEC_BASE+225) +#define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER		(V4L2_CID_CODEC_BASE+226) +#define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE		(V4L2_CID_CODEC_BASE+227) +#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE		(V4L2_CID_CODEC_BASE+228) +#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME		(V4L2_CID_CODEC_BASE+229) +#define V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID	(V4L2_CID_CODEC_BASE+230) +#define V4L2_CID_MPEG_VIDEO_AU_DELIMITER		(V4L2_CID_CODEC_BASE+231) +#define V4L2_CID_MPEG_VIDEO_LTR_COUNT			(V4L2_CID_CODEC_BASE+232) +#define V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX		(V4L2_CID_CODEC_BASE+233) +#define V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES		(V4L2_CID_CODEC_BASE+234) +#define V4L2_CID_MPEG_VIDEO_DEC_CONCEAL_COLOR		(V4L2_CID_CODEC_BASE+235) +#define V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD	(V4L2_CID_CODEC_BASE+236) +#define V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE	(V4L2_CID_CODEC_BASE+237) +enum v4l2_mpeg_video_intra_refresh_period_type { +	V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_RANDOM	= 0, +	V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_CYCLIC	= 1, +};  /* CIDs for the MPEG-2 Part 2 (H.262) codec */ -#define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL			(V4L2_CID_MPEG_BASE+270) +#define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL			(V4L2_CID_CODEC_BASE+270)  enum v4l2_mpeg_video_mpeg2_level {  	V4L2_MPEG_VIDEO_MPEG2_LEVEL_LOW		= 0,  	V4L2_MPEG_VIDEO_MPEG2_LEVEL_MAIN	= 1,  	V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH_1440	= 2,  	V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH	= 3,  }; -#define V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE		(V4L2_CID_MPEG_BASE+271) +#define V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE		(V4L2_CID_CODEC_BASE+271)  enum v4l2_mpeg_video_mpeg2_profile {  	V4L2_MPEG_VIDEO_MPEG2_PROFILE_SIMPLE				= 0,  	V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN				= 1, @@ -434,28 +477,28 @@ enum v4l2_mpeg_video_mpeg2_profile {  };  /* CIDs for the FWHT codec as used by the vicodec driver. */ -#define V4L2_CID_FWHT_I_FRAME_QP             (V4L2_CID_MPEG_BASE + 290) -#define V4L2_CID_FWHT_P_FRAME_QP             (V4L2_CID_MPEG_BASE + 291) - -#define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP		(V4L2_CID_MPEG_BASE+300) -#define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP		(V4L2_CID_MPEG_BASE+301) -#define V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP		(V4L2_CID_MPEG_BASE+302) -#define V4L2_CID_MPEG_VIDEO_H263_MIN_QP			(V4L2_CID_MPEG_BASE+303) -#define V4L2_CID_MPEG_VIDEO_H263_MAX_QP			(V4L2_CID_MPEG_BASE+304) -#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP		(V4L2_CID_MPEG_BASE+350) -#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP		(V4L2_CID_MPEG_BASE+351) -#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP		(V4L2_CID_MPEG_BASE+352) -#define V4L2_CID_MPEG_VIDEO_H264_MIN_QP			(V4L2_CID_MPEG_BASE+353) -#define V4L2_CID_MPEG_VIDEO_H264_MAX_QP			(V4L2_CID_MPEG_BASE+354) -#define V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM		(V4L2_CID_MPEG_BASE+355) -#define V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE		(V4L2_CID_MPEG_BASE+356) -#define V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE		(V4L2_CID_MPEG_BASE+357) +#define V4L2_CID_FWHT_I_FRAME_QP             (V4L2_CID_CODEC_BASE + 290) +#define V4L2_CID_FWHT_P_FRAME_QP             (V4L2_CID_CODEC_BASE + 291) + +#define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP		(V4L2_CID_CODEC_BASE+300) +#define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP		(V4L2_CID_CODEC_BASE+301) +#define V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP		(V4L2_CID_CODEC_BASE+302) +#define V4L2_CID_MPEG_VIDEO_H263_MIN_QP			(V4L2_CID_CODEC_BASE+303) +#define V4L2_CID_MPEG_VIDEO_H263_MAX_QP			(V4L2_CID_CODEC_BASE+304) +#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP		(V4L2_CID_CODEC_BASE+350) +#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP		(V4L2_CID_CODEC_BASE+351) +#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP		(V4L2_CID_CODEC_BASE+352) +#define V4L2_CID_MPEG_VIDEO_H264_MIN_QP			(V4L2_CID_CODEC_BASE+353) +#define V4L2_CID_MPEG_VIDEO_H264_MAX_QP			(V4L2_CID_CODEC_BASE+354) +#define V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM		(V4L2_CID_CODEC_BASE+355) +#define V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE		(V4L2_CID_CODEC_BASE+356) +#define V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE		(V4L2_CID_CODEC_BASE+357)  enum v4l2_mpeg_video_h264_entropy_mode {  	V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC	= 0,  	V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC	= 1,  }; -#define V4L2_CID_MPEG_VIDEO_H264_I_PERIOD		(V4L2_CID_MPEG_BASE+358) -#define V4L2_CID_MPEG_VIDEO_H264_LEVEL			(V4L2_CID_MPEG_BASE+359) +#define V4L2_CID_MPEG_VIDEO_H264_I_PERIOD		(V4L2_CID_CODEC_BASE+358) +#define V4L2_CID_MPEG_VIDEO_H264_LEVEL			(V4L2_CID_CODEC_BASE+359)  enum v4l2_mpeg_video_h264_level {  	V4L2_MPEG_VIDEO_H264_LEVEL_1_0	= 0,  	V4L2_MPEG_VIDEO_H264_LEVEL_1B	= 1, @@ -478,15 +521,15 @@ enum v4l2_mpeg_video_h264_level {  	V4L2_MPEG_VIDEO_H264_LEVEL_6_1	= 18,  	V4L2_MPEG_VIDEO_H264_LEVEL_6_2	= 19,  }; -#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA	(V4L2_CID_MPEG_BASE+360) -#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA	(V4L2_CID_MPEG_BASE+361) -#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE	(V4L2_CID_MPEG_BASE+362) +#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA	(V4L2_CID_CODEC_BASE+360) +#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA	(V4L2_CID_CODEC_BASE+361) +#define V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE	(V4L2_CID_CODEC_BASE+362)  enum v4l2_mpeg_video_h264_loop_filter_mode {  	V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED				= 0,  	V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED				= 1,  	V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY	= 2,  }; -#define V4L2_CID_MPEG_VIDEO_H264_PROFILE		(V4L2_CID_MPEG_BASE+363) +#define V4L2_CID_MPEG_VIDEO_H264_PROFILE		(V4L2_CID_CODEC_BASE+363)  enum v4l2_mpeg_video_h264_profile {  	V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE			= 0,  	V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE	= 1, @@ -507,10 +550,10 @@ enum v4l2_mpeg_video_h264_profile {  	V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH		= 16,  	V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH		= 17,  }; -#define V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_HEIGHT	(V4L2_CID_MPEG_BASE+364) -#define V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_WIDTH	(V4L2_CID_MPEG_BASE+365) -#define V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE		(V4L2_CID_MPEG_BASE+366) -#define V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC		(V4L2_CID_MPEG_BASE+367) +#define V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_HEIGHT	(V4L2_CID_CODEC_BASE+364) +#define V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_WIDTH	(V4L2_CID_CODEC_BASE+365) +#define V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE		(V4L2_CID_CODEC_BASE+366) +#define V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC		(V4L2_CID_CODEC_BASE+367)  enum v4l2_mpeg_video_h264_vui_sar_idc {  	V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_UNSPECIFIED	= 0,  	V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_1x1		= 1, @@ -531,9 +574,9 @@ enum v4l2_mpeg_video_h264_vui_sar_idc {  	V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_2x1		= 16,  	V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_EXTENDED	= 17,  }; -#define V4L2_CID_MPEG_VIDEO_H264_SEI_FRAME_PACKING		(V4L2_CID_MPEG_BASE+368) -#define V4L2_CID_MPEG_VIDEO_H264_SEI_FP_CURRENT_FRAME_0		(V4L2_CID_MPEG_BASE+369) -#define V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE	(V4L2_CID_MPEG_BASE+370) +#define V4L2_CID_MPEG_VIDEO_H264_SEI_FRAME_PACKING		(V4L2_CID_CODEC_BASE+368) +#define V4L2_CID_MPEG_VIDEO_H264_SEI_FP_CURRENT_FRAME_0		(V4L2_CID_CODEC_BASE+369) +#define V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE	(V4L2_CID_CODEC_BASE+370)  enum v4l2_mpeg_video_h264_sei_fp_arrangement_type {  	V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_CHECKERBOARD	= 0,  	V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_COLUMN		= 1, @@ -542,8 +585,8 @@ enum v4l2_mpeg_video_h264_sei_fp_arrangement_type {  	V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_TOP_BOTTOM		= 4,  	V4L2_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE_TEMPORAL		= 5,  }; -#define V4L2_CID_MPEG_VIDEO_H264_FMO			(V4L2_CID_MPEG_BASE+371) -#define V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE		(V4L2_CID_MPEG_BASE+372) +#define V4L2_CID_MPEG_VIDEO_H264_FMO			(V4L2_CID_CODEC_BASE+371) +#define V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE		(V4L2_CID_CODEC_BASE+372)  enum v4l2_mpeg_video_h264_fmo_map_type {  	V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_INTERLEAVED_SLICES		= 0,  	V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_SCATTERED_SLICES		= 1, @@ -553,36 +596,45 @@ enum v4l2_mpeg_video_h264_fmo_map_type {  	V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_WIPE_SCAN			= 5,  	V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_EXPLICIT			= 6,  }; -#define V4L2_CID_MPEG_VIDEO_H264_FMO_SLICE_GROUP	(V4L2_CID_MPEG_BASE+373) -#define V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_DIRECTION	(V4L2_CID_MPEG_BASE+374) +#define V4L2_CID_MPEG_VIDEO_H264_FMO_SLICE_GROUP	(V4L2_CID_CODEC_BASE+373) +#define V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_DIRECTION	(V4L2_CID_CODEC_BASE+374)  enum v4l2_mpeg_video_h264_fmo_change_dir {  	V4L2_MPEG_VIDEO_H264_FMO_CHANGE_DIR_RIGHT	= 0,  	V4L2_MPEG_VIDEO_H264_FMO_CHANGE_DIR_LEFT	= 1,  }; -#define V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_RATE	(V4L2_CID_MPEG_BASE+375) -#define V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH		(V4L2_CID_MPEG_BASE+376) -#define V4L2_CID_MPEG_VIDEO_H264_ASO			(V4L2_CID_MPEG_BASE+377) -#define V4L2_CID_MPEG_VIDEO_H264_ASO_SLICE_ORDER	(V4L2_CID_MPEG_BASE+378) -#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING		(V4L2_CID_MPEG_BASE+379) -#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE	(V4L2_CID_MPEG_BASE+380) +#define V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_RATE	(V4L2_CID_CODEC_BASE+375) +#define V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH		(V4L2_CID_CODEC_BASE+376) +#define V4L2_CID_MPEG_VIDEO_H264_ASO			(V4L2_CID_CODEC_BASE+377) +#define V4L2_CID_MPEG_VIDEO_H264_ASO_SLICE_ORDER	(V4L2_CID_CODEC_BASE+378) +#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING		(V4L2_CID_CODEC_BASE+379) +#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE	(V4L2_CID_CODEC_BASE+380)  enum v4l2_mpeg_video_h264_hierarchical_coding_type {  	V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_B	= 0,  	V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P	= 1,  }; -#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER	(V4L2_CID_MPEG_BASE+381) -#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP	(V4L2_CID_MPEG_BASE+382) -#define V4L2_CID_MPEG_VIDEO_H264_CONSTRAINED_INTRA_PREDICTION	(V4L2_CID_MPEG_BASE+383) -#define V4L2_CID_MPEG_VIDEO_H264_CHROMA_QP_INDEX_OFFSET		(V4L2_CID_MPEG_BASE+384) -#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP	(V4L2_CID_MPEG_BASE+385) -#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP	(V4L2_CID_MPEG_BASE+386) -#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP	(V4L2_CID_MPEG_BASE+387) -#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP	(V4L2_CID_MPEG_BASE+388) -#define V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP	(V4L2_CID_MPEG_BASE+400) -#define V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP	(V4L2_CID_MPEG_BASE+401) -#define V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP	(V4L2_CID_MPEG_BASE+402) -#define V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP	(V4L2_CID_MPEG_BASE+403) -#define V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP	(V4L2_CID_MPEG_BASE+404) -#define V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL		(V4L2_CID_MPEG_BASE+405) +#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER	(V4L2_CID_CODEC_BASE+381) +#define V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP	(V4L2_CID_CODEC_BASE+382) +#define V4L2_CID_MPEG_VIDEO_H264_CONSTRAINED_INTRA_PREDICTION	(V4L2_CID_CODEC_BASE+383) +#define V4L2_CID_MPEG_VIDEO_H264_CHROMA_QP_INDEX_OFFSET		(V4L2_CID_CODEC_BASE+384) +#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP	(V4L2_CID_CODEC_BASE+385) +#define V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP	(V4L2_CID_CODEC_BASE+386) +#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP	(V4L2_CID_CODEC_BASE+387) +#define V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP	(V4L2_CID_CODEC_BASE+388) +#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP	(V4L2_CID_CODEC_BASE+389) +#define V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP	(V4L2_CID_CODEC_BASE+390) +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR	(V4L2_CID_CODEC_BASE+391) +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR	(V4L2_CID_CODEC_BASE+392) +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR	(V4L2_CID_CODEC_BASE+393) +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR	(V4L2_CID_CODEC_BASE+394) +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR	(V4L2_CID_CODEC_BASE+395) +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR	(V4L2_CID_CODEC_BASE+396) +#define V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L6_BR	(V4L2_CID_CODEC_BASE+397) +#define V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP	(V4L2_CID_CODEC_BASE+400) +#define V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP	(V4L2_CID_CODEC_BASE+401) +#define V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP	(V4L2_CID_CODEC_BASE+402) +#define V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP	(V4L2_CID_CODEC_BASE+403) +#define V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP	(V4L2_CID_CODEC_BASE+404) +#define V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL		(V4L2_CID_CODEC_BASE+405)  enum v4l2_mpeg_video_mpeg4_level {  	V4L2_MPEG_VIDEO_MPEG4_LEVEL_0	= 0,  	V4L2_MPEG_VIDEO_MPEG4_LEVEL_0B	= 1, @@ -593,7 +645,7 @@ enum v4l2_mpeg_video_mpeg4_level {  	V4L2_MPEG_VIDEO_MPEG4_LEVEL_4	= 6,  	V4L2_MPEG_VIDEO_MPEG4_LEVEL_5	= 7,  }; -#define V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE	(V4L2_CID_MPEG_BASE+406) +#define V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE	(V4L2_CID_CODEC_BASE+406)  enum v4l2_mpeg_video_mpeg4_profile {  	V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE				= 0,  	V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE			= 1, @@ -601,40 +653,40 @@ enum v4l2_mpeg_video_mpeg4_profile {  	V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE_SCALABLE			= 3,  	V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_CODING_EFFICIENCY	= 4,  }; -#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL		(V4L2_CID_MPEG_BASE+407) +#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL		(V4L2_CID_CODEC_BASE+407)  /*  Control IDs for VP8 streams   *  Although VP8 is not part of MPEG we add these controls to the MPEG class   *  as that class is already handling other video compression standards   */ -#define V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS		(V4L2_CID_MPEG_BASE+500) +#define V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS		(V4L2_CID_CODEC_BASE+500)  enum v4l2_vp8_num_partitions {  	V4L2_CID_MPEG_VIDEO_VPX_1_PARTITION	= 0,  	V4L2_CID_MPEG_VIDEO_VPX_2_PARTITIONS	= 1,  	V4L2_CID_MPEG_VIDEO_VPX_4_PARTITIONS	= 2,  	V4L2_CID_MPEG_VIDEO_VPX_8_PARTITIONS	= 3,  }; -#define V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4		(V4L2_CID_MPEG_BASE+501) -#define V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES		(V4L2_CID_MPEG_BASE+502) +#define V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4		(V4L2_CID_CODEC_BASE+501) +#define V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES		(V4L2_CID_CODEC_BASE+502)  enum v4l2_vp8_num_ref_frames {  	V4L2_CID_MPEG_VIDEO_VPX_1_REF_FRAME	= 0,  	V4L2_CID_MPEG_VIDEO_VPX_2_REF_FRAME	= 1,  	V4L2_CID_MPEG_VIDEO_VPX_3_REF_FRAME	= 2,  }; -#define V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL		(V4L2_CID_MPEG_BASE+503) -#define V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS	(V4L2_CID_MPEG_BASE+504) -#define V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD	(V4L2_CID_MPEG_BASE+505) -#define V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL	(V4L2_CID_MPEG_BASE+506) +#define V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL		(V4L2_CID_CODEC_BASE+503) +#define V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS	(V4L2_CID_CODEC_BASE+504) +#define V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD	(V4L2_CID_CODEC_BASE+505) +#define V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL	(V4L2_CID_CODEC_BASE+506)  enum v4l2_vp8_golden_frame_sel {  	V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_PREV		= 0,  	V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_REF_PERIOD	= 1,  }; -#define V4L2_CID_MPEG_VIDEO_VPX_MIN_QP			(V4L2_CID_MPEG_BASE+507) -#define V4L2_CID_MPEG_VIDEO_VPX_MAX_QP			(V4L2_CID_MPEG_BASE+508) -#define V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP		(V4L2_CID_MPEG_BASE+509) -#define V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP		(V4L2_CID_MPEG_BASE+510) +#define V4L2_CID_MPEG_VIDEO_VPX_MIN_QP			(V4L2_CID_CODEC_BASE+507) +#define V4L2_CID_MPEG_VIDEO_VPX_MAX_QP			(V4L2_CID_CODEC_BASE+508) +#define V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP		(V4L2_CID_CODEC_BASE+509) +#define V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP		(V4L2_CID_CODEC_BASE+510) -#define V4L2_CID_MPEG_VIDEO_VP8_PROFILE			(V4L2_CID_MPEG_BASE+511) +#define V4L2_CID_MPEG_VIDEO_VP8_PROFILE			(V4L2_CID_CODEC_BASE+511)  enum v4l2_mpeg_video_vp8_profile {  	V4L2_MPEG_VIDEO_VP8_PROFILE_0				= 0,  	V4L2_MPEG_VIDEO_VP8_PROFILE_1				= 1, @@ -643,42 +695,59 @@ enum v4l2_mpeg_video_vp8_profile {  };  /* Deprecated alias for compatibility reasons. */  #define V4L2_CID_MPEG_VIDEO_VPX_PROFILE	V4L2_CID_MPEG_VIDEO_VP8_PROFILE -#define V4L2_CID_MPEG_VIDEO_VP9_PROFILE			(V4L2_CID_MPEG_BASE+512) +#define V4L2_CID_MPEG_VIDEO_VP9_PROFILE			(V4L2_CID_CODEC_BASE+512)  enum v4l2_mpeg_video_vp9_profile {  	V4L2_MPEG_VIDEO_VP9_PROFILE_0				= 0,  	V4L2_MPEG_VIDEO_VP9_PROFILE_1				= 1,  	V4L2_MPEG_VIDEO_VP9_PROFILE_2				= 2,  	V4L2_MPEG_VIDEO_VP9_PROFILE_3				= 3,  }; +#define V4L2_CID_MPEG_VIDEO_VP9_LEVEL			(V4L2_CID_CODEC_BASE+513) +enum v4l2_mpeg_video_vp9_level { +	V4L2_MPEG_VIDEO_VP9_LEVEL_1_0	= 0, +	V4L2_MPEG_VIDEO_VP9_LEVEL_1_1	= 1, +	V4L2_MPEG_VIDEO_VP9_LEVEL_2_0	= 2, +	V4L2_MPEG_VIDEO_VP9_LEVEL_2_1	= 3, +	V4L2_MPEG_VIDEO_VP9_LEVEL_3_0	= 4, +	V4L2_MPEG_VIDEO_VP9_LEVEL_3_1	= 5, +	V4L2_MPEG_VIDEO_VP9_LEVEL_4_0	= 6, +	V4L2_MPEG_VIDEO_VP9_LEVEL_4_1	= 7, +	V4L2_MPEG_VIDEO_VP9_LEVEL_5_0	= 8, +	V4L2_MPEG_VIDEO_VP9_LEVEL_5_1	= 9, +	V4L2_MPEG_VIDEO_VP9_LEVEL_5_2	= 10, +	V4L2_MPEG_VIDEO_VP9_LEVEL_6_0	= 11, +	V4L2_MPEG_VIDEO_VP9_LEVEL_6_1	= 12, +	V4L2_MPEG_VIDEO_VP9_LEVEL_6_2	= 13, +};  /* CIDs for HEVC encoding. */ -#define V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP		(V4L2_CID_MPEG_BASE + 600) -#define V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP		(V4L2_CID_MPEG_BASE + 601) -#define V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP	(V4L2_CID_MPEG_BASE + 602) -#define V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP	(V4L2_CID_MPEG_BASE + 603) -#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP	(V4L2_CID_MPEG_BASE + 604) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_QP	(V4L2_CID_MPEG_BASE + 605) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_TYPE (V4L2_CID_MPEG_BASE + 606) +#define V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP		(V4L2_CID_CODEC_BASE + 600) +#define V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP		(V4L2_CID_CODEC_BASE + 601) +#define V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP	(V4L2_CID_CODEC_BASE + 602) +#define V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP	(V4L2_CID_CODEC_BASE + 603) +#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP	(V4L2_CID_CODEC_BASE + 604) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_QP	(V4L2_CID_CODEC_BASE + 605) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_TYPE (V4L2_CID_CODEC_BASE + 606)  enum v4l2_mpeg_video_hevc_hier_coding_type {  	V4L2_MPEG_VIDEO_HEVC_HIERARCHICAL_CODING_B	= 0,  	V4L2_MPEG_VIDEO_HEVC_HIERARCHICAL_CODING_P	= 1,  }; -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER	(V4L2_CID_MPEG_BASE + 607) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L0_QP	(V4L2_CID_MPEG_BASE + 608) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L1_QP	(V4L2_CID_MPEG_BASE + 609) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L2_QP	(V4L2_CID_MPEG_BASE + 610) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L3_QP	(V4L2_CID_MPEG_BASE + 611) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_QP	(V4L2_CID_MPEG_BASE + 612) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_QP	(V4L2_CID_MPEG_BASE + 613) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L6_QP	(V4L2_CID_MPEG_BASE + 614) -#define V4L2_CID_MPEG_VIDEO_HEVC_PROFILE	(V4L2_CID_MPEG_BASE + 615) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER	(V4L2_CID_CODEC_BASE + 607) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L0_QP	(V4L2_CID_CODEC_BASE + 608) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L1_QP	(V4L2_CID_CODEC_BASE + 609) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L2_QP	(V4L2_CID_CODEC_BASE + 610) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L3_QP	(V4L2_CID_CODEC_BASE + 611) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_QP	(V4L2_CID_CODEC_BASE + 612) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_QP	(V4L2_CID_CODEC_BASE + 613) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L6_QP	(V4L2_CID_CODEC_BASE + 614) +#define V4L2_CID_MPEG_VIDEO_HEVC_PROFILE	(V4L2_CID_CODEC_BASE + 615)  enum v4l2_mpeg_video_hevc_profile {  	V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN = 0,  	V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE = 1,  	V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10 = 2,  }; -#define V4L2_CID_MPEG_VIDEO_HEVC_LEVEL		(V4L2_CID_MPEG_BASE + 616) +#define V4L2_CID_MPEG_VIDEO_HEVC_LEVEL		(V4L2_CID_CODEC_BASE + 616)  enum v4l2_mpeg_video_hevc_level {  	V4L2_MPEG_VIDEO_HEVC_LEVEL_1	= 0,  	V4L2_MPEG_VIDEO_HEVC_LEVEL_2	= 1, @@ -694,64 +763,165 @@ enum v4l2_mpeg_video_hevc_level {  	V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1	= 11,  	V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2	= 12,  }; -#define V4L2_CID_MPEG_VIDEO_HEVC_FRAME_RATE_RESOLUTION	(V4L2_CID_MPEG_BASE + 617) -#define V4L2_CID_MPEG_VIDEO_HEVC_TIER			(V4L2_CID_MPEG_BASE + 618) +#define V4L2_CID_MPEG_VIDEO_HEVC_FRAME_RATE_RESOLUTION	(V4L2_CID_CODEC_BASE + 617) +#define V4L2_CID_MPEG_VIDEO_HEVC_TIER			(V4L2_CID_CODEC_BASE + 618)  enum v4l2_mpeg_video_hevc_tier {  	V4L2_MPEG_VIDEO_HEVC_TIER_MAIN = 0,  	V4L2_MPEG_VIDEO_HEVC_TIER_HIGH = 1,  }; -#define V4L2_CID_MPEG_VIDEO_HEVC_MAX_PARTITION_DEPTH	(V4L2_CID_MPEG_BASE + 619) -#define V4L2_CID_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE	(V4L2_CID_MPEG_BASE + 620) +#define V4L2_CID_MPEG_VIDEO_HEVC_MAX_PARTITION_DEPTH	(V4L2_CID_CODEC_BASE + 619) +#define V4L2_CID_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE	(V4L2_CID_CODEC_BASE + 620)  enum v4l2_cid_mpeg_video_hevc_loop_filter_mode {  	V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED			 = 0,  	V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_ENABLED			 = 1,  	V4L2_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY = 2,  }; -#define V4L2_CID_MPEG_VIDEO_HEVC_LF_BETA_OFFSET_DIV2	(V4L2_CID_MPEG_BASE + 621) -#define V4L2_CID_MPEG_VIDEO_HEVC_LF_TC_OFFSET_DIV2	(V4L2_CID_MPEG_BASE + 622) -#define V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_TYPE		(V4L2_CID_MPEG_BASE + 623) +#define V4L2_CID_MPEG_VIDEO_HEVC_LF_BETA_OFFSET_DIV2	(V4L2_CID_CODEC_BASE + 621) +#define V4L2_CID_MPEG_VIDEO_HEVC_LF_TC_OFFSET_DIV2	(V4L2_CID_CODEC_BASE + 622) +#define V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_TYPE		(V4L2_CID_CODEC_BASE + 623)  enum v4l2_cid_mpeg_video_hevc_refresh_type {  	V4L2_MPEG_VIDEO_HEVC_REFRESH_NONE		= 0,  	V4L2_MPEG_VIDEO_HEVC_REFRESH_CRA		= 1,  	V4L2_MPEG_VIDEO_HEVC_REFRESH_IDR		= 2,  }; -#define V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_PERIOD		(V4L2_CID_MPEG_BASE + 624) -#define V4L2_CID_MPEG_VIDEO_HEVC_LOSSLESS_CU		(V4L2_CID_MPEG_BASE + 625) -#define V4L2_CID_MPEG_VIDEO_HEVC_CONST_INTRA_PRED	(V4L2_CID_MPEG_BASE + 626) -#define V4L2_CID_MPEG_VIDEO_HEVC_WAVEFRONT		(V4L2_CID_MPEG_BASE + 627) -#define V4L2_CID_MPEG_VIDEO_HEVC_GENERAL_PB		(V4L2_CID_MPEG_BASE + 628) -#define V4L2_CID_MPEG_VIDEO_HEVC_TEMPORAL_ID		(V4L2_CID_MPEG_BASE + 629) -#define V4L2_CID_MPEG_VIDEO_HEVC_STRONG_SMOOTHING	(V4L2_CID_MPEG_BASE + 630) -#define V4L2_CID_MPEG_VIDEO_HEVC_MAX_NUM_MERGE_MV_MINUS1	(V4L2_CID_MPEG_BASE + 631) -#define V4L2_CID_MPEG_VIDEO_HEVC_INTRA_PU_SPLIT		(V4L2_CID_MPEG_BASE + 632) -#define V4L2_CID_MPEG_VIDEO_HEVC_TMV_PREDICTION		(V4L2_CID_MPEG_BASE + 633) -#define V4L2_CID_MPEG_VIDEO_HEVC_WITHOUT_STARTCODE	(V4L2_CID_MPEG_BASE + 634) -#define V4L2_CID_MPEG_VIDEO_HEVC_SIZE_OF_LENGTH_FIELD	(V4L2_CID_MPEG_BASE + 635) +#define V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_PERIOD		(V4L2_CID_CODEC_BASE + 624) +#define V4L2_CID_MPEG_VIDEO_HEVC_LOSSLESS_CU		(V4L2_CID_CODEC_BASE + 625) +#define V4L2_CID_MPEG_VIDEO_HEVC_CONST_INTRA_PRED	(V4L2_CID_CODEC_BASE + 626) +#define V4L2_CID_MPEG_VIDEO_HEVC_WAVEFRONT		(V4L2_CID_CODEC_BASE + 627) +#define V4L2_CID_MPEG_VIDEO_HEVC_GENERAL_PB		(V4L2_CID_CODEC_BASE + 628) +#define V4L2_CID_MPEG_VIDEO_HEVC_TEMPORAL_ID		(V4L2_CID_CODEC_BASE + 629) +#define V4L2_CID_MPEG_VIDEO_HEVC_STRONG_SMOOTHING	(V4L2_CID_CODEC_BASE + 630) +#define V4L2_CID_MPEG_VIDEO_HEVC_MAX_NUM_MERGE_MV_MINUS1	(V4L2_CID_CODEC_BASE + 631) +#define V4L2_CID_MPEG_VIDEO_HEVC_INTRA_PU_SPLIT		(V4L2_CID_CODEC_BASE + 632) +#define V4L2_CID_MPEG_VIDEO_HEVC_TMV_PREDICTION		(V4L2_CID_CODEC_BASE + 633) +#define V4L2_CID_MPEG_VIDEO_HEVC_WITHOUT_STARTCODE	(V4L2_CID_CODEC_BASE + 634) +#define V4L2_CID_MPEG_VIDEO_HEVC_SIZE_OF_LENGTH_FIELD	(V4L2_CID_CODEC_BASE + 635)  enum v4l2_cid_mpeg_video_hevc_size_of_length_field {  	V4L2_MPEG_VIDEO_HEVC_SIZE_0		= 0,  	V4L2_MPEG_VIDEO_HEVC_SIZE_1		= 1,  	V4L2_MPEG_VIDEO_HEVC_SIZE_2		= 2,  	V4L2_MPEG_VIDEO_HEVC_SIZE_4		= 3,  }; -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L0_BR	(V4L2_CID_MPEG_BASE + 636) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L1_BR	(V4L2_CID_MPEG_BASE + 637) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L2_BR	(V4L2_CID_MPEG_BASE + 638) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L3_BR	(V4L2_CID_MPEG_BASE + 639) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_BR	(V4L2_CID_MPEG_BASE + 640) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_BR	(V4L2_CID_MPEG_BASE + 641) -#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L6_BR	(V4L2_CID_MPEG_BASE + 642) -#define V4L2_CID_MPEG_VIDEO_REF_NUMBER_FOR_PFRAMES	(V4L2_CID_MPEG_BASE + 643) -#define V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR	(V4L2_CID_MPEG_BASE + 644) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L0_BR	(V4L2_CID_CODEC_BASE + 636) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L1_BR	(V4L2_CID_CODEC_BASE + 637) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L2_BR	(V4L2_CID_CODEC_BASE + 638) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L3_BR	(V4L2_CID_CODEC_BASE + 639) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_BR	(V4L2_CID_CODEC_BASE + 640) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_BR	(V4L2_CID_CODEC_BASE + 641) +#define V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L6_BR	(V4L2_CID_CODEC_BASE + 642) +#define V4L2_CID_MPEG_VIDEO_REF_NUMBER_FOR_PFRAMES	(V4L2_CID_CODEC_BASE + 643) +#define V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR	(V4L2_CID_CODEC_BASE + 644) +#define V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY		(V4L2_CID_CODEC_BASE + 645) +#define V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE		(V4L2_CID_CODEC_BASE + 646) +enum v4l2_mpeg_video_frame_skip_mode { +	V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED	= 0, +	V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT	= 1, +	V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT	= 2, +}; + +#define V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP        (V4L2_CID_CODEC_BASE + 647) +#define V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP        (V4L2_CID_CODEC_BASE + 648) +#define V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP        (V4L2_CID_CODEC_BASE + 649) +#define V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP        (V4L2_CID_CODEC_BASE + 650) +#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP        (V4L2_CID_CODEC_BASE + 651) +#define V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP        (V4L2_CID_CODEC_BASE + 652) + +#define V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY		(V4L2_CID_CODEC_BASE + 653) +#define V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE	(V4L2_CID_CODEC_BASE + 654) + +#define V4L2_CID_MPEG_VIDEO_AV1_PROFILE (V4L2_CID_CODEC_BASE + 655) +/** + * enum v4l2_mpeg_video_av1_profile - AV1 profiles + * + * @V4L2_MPEG_VIDEO_AV1_PROFILE_MAIN: compliant decoders must be able to decode + * streams with seq_profile equal to 0. + * @V4L2_MPEG_VIDEO_AV1_PROFILE_HIGH: compliant decoders must be able to decode + * streams with seq_profile equal less than or equal to 1. + * @V4L2_MPEG_VIDEO_AV1_PROFILE_PROFESSIONAL: compliant decoders must be able to + * decode streams with seq_profile less than or equal to 2. + * + * Conveys the highest profile a decoder can work with. + */ +enum v4l2_mpeg_video_av1_profile { +	V4L2_MPEG_VIDEO_AV1_PROFILE_MAIN = 0, +	V4L2_MPEG_VIDEO_AV1_PROFILE_HIGH = 1, +	V4L2_MPEG_VIDEO_AV1_PROFILE_PROFESSIONAL = 2, +}; + +#define V4L2_CID_MPEG_VIDEO_AV1_LEVEL (V4L2_CID_CODEC_BASE + 656) +/** + * enum v4l2_mpeg_video_av1_level - AV1 levels + * + * @V4L2_MPEG_VIDEO_AV1_LEVEL_2_0: Level 2.0. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_2_1: Level 2.1. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_2_2: Level 2.2. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_2_3: Level 2.3. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_3_0: Level 3.0. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_3_1: Level 3.1. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_3_2: Level 3.2. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_3_3: Level 3.3. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_4_0: Level 4.0. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_4_1: Level 4.1. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_4_2: Level 4.2. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_4_3: Level 4.3. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_5_0: Level 5.0. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_5_1: Level 5.1. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_5_2: Level 5.2. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_5_3: Level 5.3. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_6_0: Level 6.0. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_6_1: Level 6.1. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_6_2: Level 6.2. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_6_3: Level 6.3. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_7_0: Level 7.0. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_7_1: Level 7.1. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_7_2: Level 7.2. + * @V4L2_MPEG_VIDEO_AV1_LEVEL_7_3: Level 7.3. + * + * Conveys the highest level a decoder can work with. + */ +enum v4l2_mpeg_video_av1_level { +	V4L2_MPEG_VIDEO_AV1_LEVEL_2_0 = 0, +	V4L2_MPEG_VIDEO_AV1_LEVEL_2_1 = 1, +	V4L2_MPEG_VIDEO_AV1_LEVEL_2_2 = 2, +	V4L2_MPEG_VIDEO_AV1_LEVEL_2_3 = 3, + +	V4L2_MPEG_VIDEO_AV1_LEVEL_3_0 = 4, +	V4L2_MPEG_VIDEO_AV1_LEVEL_3_1 = 5, +	V4L2_MPEG_VIDEO_AV1_LEVEL_3_2 = 6, +	V4L2_MPEG_VIDEO_AV1_LEVEL_3_3 = 7, + +	V4L2_MPEG_VIDEO_AV1_LEVEL_4_0 = 8, +	V4L2_MPEG_VIDEO_AV1_LEVEL_4_1 = 9, +	V4L2_MPEG_VIDEO_AV1_LEVEL_4_2 = 10, +	V4L2_MPEG_VIDEO_AV1_LEVEL_4_3 = 11, + +	V4L2_MPEG_VIDEO_AV1_LEVEL_5_0 = 12, +	V4L2_MPEG_VIDEO_AV1_LEVEL_5_1 = 13, +	V4L2_MPEG_VIDEO_AV1_LEVEL_5_2 = 14, +	V4L2_MPEG_VIDEO_AV1_LEVEL_5_3 = 15, + +	V4L2_MPEG_VIDEO_AV1_LEVEL_6_0 = 16, +	V4L2_MPEG_VIDEO_AV1_LEVEL_6_1 = 17, +	V4L2_MPEG_VIDEO_AV1_LEVEL_6_2 = 18, +	V4L2_MPEG_VIDEO_AV1_LEVEL_6_3 = 19, + +	V4L2_MPEG_VIDEO_AV1_LEVEL_7_0 = 20, +	V4L2_MPEG_VIDEO_AV1_LEVEL_7_1 = 21, +	V4L2_MPEG_VIDEO_AV1_LEVEL_7_2 = 22, +	V4L2_MPEG_VIDEO_AV1_LEVEL_7_3 = 23 +}; + +#define V4L2_CID_MPEG_VIDEO_AVERAGE_QP  (V4L2_CID_CODEC_BASE + 657)  /*  MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ -#define V4L2_CID_MPEG_CX2341X_BASE				(V4L2_CTRL_CLASS_MPEG | 0x1000) -#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE		(V4L2_CID_MPEG_CX2341X_BASE+0) +#define V4L2_CID_CODEC_CX2341X_BASE				(V4L2_CTRL_CLASS_CODEC | 0x1000) +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE		(V4L2_CID_CODEC_CX2341X_BASE+0)  enum v4l2_mpeg_cx2341x_video_spatial_filter_mode {  	V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0,  	V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO   = 1,  }; -#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER		(V4L2_CID_MPEG_CX2341X_BASE+1) -#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE	(V4L2_CID_MPEG_CX2341X_BASE+2) +#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER		(V4L2_CID_CODEC_CX2341X_BASE+1) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE	(V4L2_CID_CODEC_CX2341X_BASE+2)  enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type {  	V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF                  = 0,  	V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR               = 1, @@ -759,18 +929,18 @@ enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type {  	V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE      = 3,  	V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4,  }; -#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE	(V4L2_CID_MPEG_CX2341X_BASE+3) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE	(V4L2_CID_CODEC_CX2341X_BASE+3)  enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type {  	V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF    = 0,  	V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,  }; -#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE	(V4L2_CID_MPEG_CX2341X_BASE+4) +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE	(V4L2_CID_CODEC_CX2341X_BASE+4)  enum v4l2_mpeg_cx2341x_video_temporal_filter_mode {  	V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0,  	V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO   = 1,  }; -#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER		(V4L2_CID_MPEG_CX2341X_BASE+5) -#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE		(V4L2_CID_MPEG_CX2341X_BASE+6) +#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER		(V4L2_CID_CODEC_CX2341X_BASE+5) +#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE		(V4L2_CID_CODEC_CX2341X_BASE+6)  enum v4l2_mpeg_cx2341x_video_median_filter_type {  	V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF      = 0,  	V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR      = 1, @@ -778,38 +948,38 @@ enum v4l2_mpeg_cx2341x_video_median_filter_type {  	V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3,  	V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG     = 4,  }; -#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM	(V4L2_CID_MPEG_CX2341X_BASE+7) -#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP	(V4L2_CID_MPEG_CX2341X_BASE+8) -#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM	(V4L2_CID_MPEG_CX2341X_BASE+9) -#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP	(V4L2_CID_MPEG_CX2341X_BASE+10) -#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS		(V4L2_CID_MPEG_CX2341X_BASE+11) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM	(V4L2_CID_CODEC_CX2341X_BASE+7) +#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP	(V4L2_CID_CODEC_CX2341X_BASE+8) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM	(V4L2_CID_CODEC_CX2341X_BASE+9) +#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP	(V4L2_CID_CODEC_CX2341X_BASE+10) +#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS		(V4L2_CID_CODEC_CX2341X_BASE+11)  /*  MPEG-class control IDs specific to the Samsung MFC 5.1 driver as defined by V4L2 */ -#define V4L2_CID_MPEG_MFC51_BASE				(V4L2_CTRL_CLASS_MPEG | 0x1100) +#define V4L2_CID_CODEC_MFC51_BASE				(V4L2_CTRL_CLASS_CODEC | 0x1100) -#define V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY		(V4L2_CID_MPEG_MFC51_BASE+0) -#define V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY_ENABLE	(V4L2_CID_MPEG_MFC51_BASE+1) -#define V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE			(V4L2_CID_MPEG_MFC51_BASE+2) +#define V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY		(V4L2_CID_CODEC_MFC51_BASE+0) +#define V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY_ENABLE	(V4L2_CID_CODEC_MFC51_BASE+1) +#define V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE			(V4L2_CID_CODEC_MFC51_BASE+2)  enum v4l2_mpeg_mfc51_video_frame_skip_mode {  	V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_DISABLED		= 0,  	V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT	= 1,  	V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT		= 2,  }; -#define V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE			(V4L2_CID_MPEG_MFC51_BASE+3) +#define V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE			(V4L2_CID_CODEC_MFC51_BASE+3)  enum v4l2_mpeg_mfc51_video_force_frame_type {  	V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_DISABLED		= 0,  	V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_I_FRAME		= 1,  	V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_NOT_CODED	= 2,  }; -#define V4L2_CID_MPEG_MFC51_VIDEO_PADDING				(V4L2_CID_MPEG_MFC51_BASE+4) -#define V4L2_CID_MPEG_MFC51_VIDEO_PADDING_YUV				(V4L2_CID_MPEG_MFC51_BASE+5) -#define V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT			(V4L2_CID_MPEG_MFC51_BASE+6) -#define V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF			(V4L2_CID_MPEG_MFC51_BASE+7) -#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_ACTIVITY		(V4L2_CID_MPEG_MFC51_BASE+50) -#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_DARK			(V4L2_CID_MPEG_MFC51_BASE+51) -#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_SMOOTH		(V4L2_CID_MPEG_MFC51_BASE+52) -#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_STATIC		(V4L2_CID_MPEG_MFC51_BASE+53) -#define V4L2_CID_MPEG_MFC51_VIDEO_H264_NUM_REF_PIC_FOR_P		(V4L2_CID_MPEG_MFC51_BASE+54) +#define V4L2_CID_MPEG_MFC51_VIDEO_PADDING				(V4L2_CID_CODEC_MFC51_BASE+4) +#define V4L2_CID_MPEG_MFC51_VIDEO_PADDING_YUV				(V4L2_CID_CODEC_MFC51_BASE+5) +#define V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT			(V4L2_CID_CODEC_MFC51_BASE+6) +#define V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF			(V4L2_CID_CODEC_MFC51_BASE+7) +#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_ACTIVITY		(V4L2_CID_CODEC_MFC51_BASE+50) +#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_DARK			(V4L2_CID_CODEC_MFC51_BASE+51) +#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_SMOOTH		(V4L2_CID_CODEC_MFC51_BASE+52) +#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_STATIC		(V4L2_CID_CODEC_MFC51_BASE+53) +#define V4L2_CID_MPEG_MFC51_VIDEO_H264_NUM_REF_PIC_FOR_P		(V4L2_CID_CODEC_MFC51_BASE+54)  /*  Camera class control IDs */ @@ -930,6 +1100,8 @@ enum v4l2_auto_focus_range {  #define V4L2_CID_CAMERA_SENSOR_ROTATION		(V4L2_CID_CAMERA_CLASS_BASE+35) +#define V4L2_CID_HDR_SENSOR_MODE		(V4L2_CID_CAMERA_CLASS_BASE+36) +  /* FM Modulator class control IDs */  #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900) @@ -1053,6 +1225,7 @@ enum v4l2_jpeg_chroma_subsampling {  #define V4L2_CID_TEST_PATTERN_BLUE		(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 6)  #define V4L2_CID_TEST_PATTERN_GREENB		(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 7)  #define V4L2_CID_UNIT_CELL_SIZE			(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 8) +#define V4L2_CID_NOTIFY_GAINS			(V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 9)  /* Image processing controls */ @@ -1146,4 +1319,2200 @@ enum v4l2_detect_md_mode {  #define V4L2_CID_DETECT_MD_THRESHOLD_GRID	(V4L2_CID_DETECT_CLASS_BASE + 3)  #define V4L2_CID_DETECT_MD_REGION_GRID		(V4L2_CID_DETECT_CLASS_BASE + 4) + +/*  Stateless CODECs controls */ +#define V4L2_CID_CODEC_STATELESS_BASE          (V4L2_CTRL_CLASS_CODEC_STATELESS | 0x900) +#define V4L2_CID_CODEC_STATELESS_CLASS         (V4L2_CTRL_CLASS_CODEC_STATELESS | 1) + +#define V4L2_CID_STATELESS_H264_DECODE_MODE	(V4L2_CID_CODEC_STATELESS_BASE + 0) +/** + * enum v4l2_stateless_h264_decode_mode - Decoding mode + * + * @V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED: indicates that decoding + * is performed one slice at a time. In this mode, + * V4L2_CID_STATELESS_H264_SLICE_PARAMS must contain the parsed slice + * parameters and the OUTPUT buffer must contain a single slice. + * V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF feature is used + * in order to support multislice frames. + * @V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED: indicates that + * decoding is performed per frame. The OUTPUT buffer must contain + * all slices and also both fields. This mode is typically supported + * by device drivers that are able to parse the slice(s) header(s) + * in hardware. When this mode is selected, + * V4L2_CID_STATELESS_H264_SLICE_PARAMS is not used. + */ +enum v4l2_stateless_h264_decode_mode { +	V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED, +	V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED, +}; + +#define V4L2_CID_STATELESS_H264_START_CODE	(V4L2_CID_CODEC_STATELESS_BASE + 1) +/** + * enum v4l2_stateless_h264_start_code - Start code + * + * @V4L2_STATELESS_H264_START_CODE_NONE: slices are passed + * to the driver without any start code. + * @V4L2_STATELESS_H264_START_CODE_ANNEX_B: slices are passed + * to the driver with an Annex B start code prefix + * (legal start codes can be 3-bytes 0x000001 or 4-bytes 0x00000001). + * This mode is typically supported by device drivers that parse + * the start code in hardware. + */ +enum v4l2_stateless_h264_start_code { +	V4L2_STATELESS_H264_START_CODE_NONE, +	V4L2_STATELESS_H264_START_CODE_ANNEX_B, +}; + +#define V4L2_H264_SPS_CONSTRAINT_SET0_FLAG			0x01 +#define V4L2_H264_SPS_CONSTRAINT_SET1_FLAG			0x02 +#define V4L2_H264_SPS_CONSTRAINT_SET2_FLAG			0x04 +#define V4L2_H264_SPS_CONSTRAINT_SET3_FLAG			0x08 +#define V4L2_H264_SPS_CONSTRAINT_SET4_FLAG			0x10 +#define V4L2_H264_SPS_CONSTRAINT_SET5_FLAG			0x20 + +#define V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE		0x01 +#define V4L2_H264_SPS_FLAG_QPPRIME_Y_ZERO_TRANSFORM_BYPASS	0x02 +#define V4L2_H264_SPS_FLAG_DELTA_PIC_ORDER_ALWAYS_ZERO		0x04 +#define V4L2_H264_SPS_FLAG_GAPS_IN_FRAME_NUM_VALUE_ALLOWED	0x08 +#define V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY			0x10 +#define V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD		0x20 +#define V4L2_H264_SPS_FLAG_DIRECT_8X8_INFERENCE			0x40 + +#define V4L2_H264_SPS_HAS_CHROMA_FORMAT(sps) \ +	((sps)->profile_idc == 100 || (sps)->profile_idc == 110 || \ +	 (sps)->profile_idc == 122 || (sps)->profile_idc == 244 || \ +	 (sps)->profile_idc == 44  || (sps)->profile_idc == 83  || \ +	 (sps)->profile_idc == 86  || (sps)->profile_idc == 118 || \ +	 (sps)->profile_idc == 128 || (sps)->profile_idc == 138 || \ +	 (sps)->profile_idc == 139 || (sps)->profile_idc == 134 || \ +	 (sps)->profile_idc == 135) + +#define V4L2_CID_STATELESS_H264_SPS		(V4L2_CID_CODEC_STATELESS_BASE + 2) +/** + * struct v4l2_ctrl_h264_sps - H264 sequence parameter set + * + * All the members on this sequence parameter set structure match the + * sequence parameter set syntax as specified by the H264 specification. + * + * @profile_idc: see H264 specification. + * @constraint_set_flags: see H264 specification. + * @level_idc: see H264 specification. + * @seq_parameter_set_id: see H264 specification. + * @chroma_format_idc: see H264 specification. + * @bit_depth_luma_minus8: see H264 specification. + * @bit_depth_chroma_minus8: see H264 specification. + * @log2_max_frame_num_minus4: see H264 specification. + * @pic_order_cnt_type: see H264 specification. + * @log2_max_pic_order_cnt_lsb_minus4: see H264 specification. + * @max_num_ref_frames: see H264 specification. + * @num_ref_frames_in_pic_order_cnt_cycle: see H264 specification. + * @offset_for_ref_frame: see H264 specification. + * @offset_for_non_ref_pic: see H264 specification. + * @offset_for_top_to_bottom_field: see H264 specification. + * @pic_width_in_mbs_minus1: see H264 specification. + * @pic_height_in_map_units_minus1: see H264 specification. + * @flags: see V4L2_H264_SPS_FLAG_{}. + */ +struct v4l2_ctrl_h264_sps { +	__u8 profile_idc; +	__u8 constraint_set_flags; +	__u8 level_idc; +	__u8 seq_parameter_set_id; +	__u8 chroma_format_idc; +	__u8 bit_depth_luma_minus8; +	__u8 bit_depth_chroma_minus8; +	__u8 log2_max_frame_num_minus4; +	__u8 pic_order_cnt_type; +	__u8 log2_max_pic_order_cnt_lsb_minus4; +	__u8 max_num_ref_frames; +	__u8 num_ref_frames_in_pic_order_cnt_cycle; +	__s32 offset_for_ref_frame[255]; +	__s32 offset_for_non_ref_pic; +	__s32 offset_for_top_to_bottom_field; +	__u16 pic_width_in_mbs_minus1; +	__u16 pic_height_in_map_units_minus1; +	__u32 flags; +}; + +#define V4L2_H264_PPS_FLAG_ENTROPY_CODING_MODE				0x0001 +#define V4L2_H264_PPS_FLAG_BOTTOM_FIELD_PIC_ORDER_IN_FRAME_PRESENT	0x0002 +#define V4L2_H264_PPS_FLAG_WEIGHTED_PRED				0x0004 +#define V4L2_H264_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT		0x0008 +#define V4L2_H264_PPS_FLAG_CONSTRAINED_INTRA_PRED			0x0010 +#define V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT			0x0020 +#define V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE				0x0040 +#define V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT			0x0080 + +#define V4L2_CID_STATELESS_H264_PPS		(V4L2_CID_CODEC_STATELESS_BASE + 3) +/** + * struct v4l2_ctrl_h264_pps - H264 picture parameter set + * + * Except where noted, all the members on this picture parameter set + * structure match the picture parameter set syntax as specified + * by the H264 specification. + * + * In particular, V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT flag + * has a specific meaning. This flag should be set if a non-flat + * scaling matrix applies to the picture. In this case, applications + * are expected to use V4L2_CID_STATELESS_H264_SCALING_MATRIX, + * to pass the values of the non-flat matrices. + * + * @pic_parameter_set_id: see H264 specification. + * @seq_parameter_set_id: see H264 specification. + * @num_slice_groups_minus1: see H264 specification. + * @num_ref_idx_l0_default_active_minus1: see H264 specification. + * @num_ref_idx_l1_default_active_minus1: see H264 specification. + * @weighted_bipred_idc: see H264 specification. + * @pic_init_qp_minus26: see H264 specification. + * @pic_init_qs_minus26: see H264 specification. + * @chroma_qp_index_offset: see H264 specification. + * @second_chroma_qp_index_offset: see H264 specification. + * @flags: see V4L2_H264_PPS_FLAG_{}. + */ +struct v4l2_ctrl_h264_pps { +	__u8 pic_parameter_set_id; +	__u8 seq_parameter_set_id; +	__u8 num_slice_groups_minus1; +	__u8 num_ref_idx_l0_default_active_minus1; +	__u8 num_ref_idx_l1_default_active_minus1; +	__u8 weighted_bipred_idc; +	__s8 pic_init_qp_minus26; +	__s8 pic_init_qs_minus26; +	__s8 chroma_qp_index_offset; +	__s8 second_chroma_qp_index_offset; +	__u16 flags; +}; + +#define V4L2_CID_STATELESS_H264_SCALING_MATRIX	(V4L2_CID_CODEC_STATELESS_BASE + 4) +/** + * struct v4l2_ctrl_h264_scaling_matrix - H264 scaling matrices + * + * @scaling_list_4x4: scaling matrix after applying the inverse + * scanning process. Expected list order is Intra Y, Intra Cb, + * Intra Cr, Inter Y, Inter Cb, Inter Cr. The values on each + * scaling list are expected in raster scan order. + * @scaling_list_8x8: scaling matrix after applying the inverse + * scanning process. Expected list order is Intra Y, Inter Y, + * Intra Cb, Inter Cb, Intra Cr, Inter Cr. The values on each + * scaling list are expected in raster scan order. + * + * Note that the list order is different for the 4x4 and 8x8 + * matrices as per the H264 specification, see table 7-2 "Assignment + * of mnemonic names to scaling list indices and specification of + * fall-back rule". + */ +struct v4l2_ctrl_h264_scaling_matrix { +	__u8 scaling_list_4x4[6][16]; +	__u8 scaling_list_8x8[6][64]; +}; + +struct v4l2_h264_weight_factors { +	__s16 luma_weight[32]; +	__s16 luma_offset[32]; +	__s16 chroma_weight[32][2]; +	__s16 chroma_offset[32][2]; +}; + +#define V4L2_H264_CTRL_PRED_WEIGHTS_REQUIRED(pps, slice) \ +	((((pps)->flags & V4L2_H264_PPS_FLAG_WEIGHTED_PRED) && \ +	 ((slice)->slice_type == V4L2_H264_SLICE_TYPE_P || \ +	  (slice)->slice_type == V4L2_H264_SLICE_TYPE_SP)) || \ +	 ((pps)->weighted_bipred_idc == 1 && \ +	  (slice)->slice_type == V4L2_H264_SLICE_TYPE_B)) + +#define V4L2_CID_STATELESS_H264_PRED_WEIGHTS	(V4L2_CID_CODEC_STATELESS_BASE + 5) +/** + * struct v4l2_ctrl_h264_pred_weights - Prediction weight table + * + * Prediction weight table, which matches the syntax specified + * by the H264 specification. + * + * @luma_log2_weight_denom: see H264 specification. + * @chroma_log2_weight_denom: see H264 specification. + * @weight_factors: luma and chroma weight factors. + */ +struct v4l2_ctrl_h264_pred_weights { +	__u16 luma_log2_weight_denom; +	__u16 chroma_log2_weight_denom; +	struct v4l2_h264_weight_factors weight_factors[2]; +}; + +#define V4L2_H264_SLICE_TYPE_P				0 +#define V4L2_H264_SLICE_TYPE_B				1 +#define V4L2_H264_SLICE_TYPE_I				2 +#define V4L2_H264_SLICE_TYPE_SP				3 +#define V4L2_H264_SLICE_TYPE_SI				4 + +#define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED	0x01 +#define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH		0x02 + +#define V4L2_H264_TOP_FIELD_REF				0x1 +#define V4L2_H264_BOTTOM_FIELD_REF			0x2 +#define V4L2_H264_FRAME_REF				0x3 + +/** + * struct v4l2_h264_reference - H264 picture reference + * + * @fields: indicates how the picture is referenced. + * Valid values are V4L2_H264_{}_REF. + * @index: index into v4l2_ctrl_h264_decode_params.dpb[]. + */ +struct v4l2_h264_reference { +	__u8 fields; +	__u8 index; +}; + +/* + * Maximum DPB size, as specified by section 'A.3.1 Level limits + * common to the Baseline, Main, and Extended profiles'. + */ +#define V4L2_H264_NUM_DPB_ENTRIES 16 +#define V4L2_H264_REF_LIST_LEN (2 * V4L2_H264_NUM_DPB_ENTRIES) + +#define V4L2_CID_STATELESS_H264_SLICE_PARAMS	(V4L2_CID_CODEC_STATELESS_BASE + 6) +/** + * struct v4l2_ctrl_h264_slice_params - H264 slice parameters + * + * This structure holds the H264 syntax elements that are specified + * as non-invariant for the slices in a given frame. + * + * Slice invariant syntax elements are contained in struct + * v4l2_ctrl_h264_decode_params. This is done to reduce the API surface + * on frame-based decoders, where slice header parsing is done by the + * hardware. + * + * Slice invariant syntax elements are specified in specification section + * "7.4.3 Slice header semantics". + * + * Except where noted, the members on this struct match the slice header syntax. + * + * @header_bit_size: offset in bits to slice_data() from the beginning of this slice. + * @first_mb_in_slice: see H264 specification. + * @slice_type: see H264 specification. + * @colour_plane_id: see H264 specification. + * @redundant_pic_cnt: see H264 specification. + * @cabac_init_idc: see H264 specification. + * @slice_qp_delta: see H264 specification. + * @slice_qs_delta: see H264 specification. + * @disable_deblocking_filter_idc: see H264 specification. + * @slice_alpha_c0_offset_div2: see H264 specification. + * @slice_beta_offset_div2: see H264 specification. + * @num_ref_idx_l0_active_minus1: see H264 specification. + * @num_ref_idx_l1_active_minus1: see H264 specification. + * @reserved: padding field. Should be zeroed by applications. + * @ref_pic_list0: reference picture list 0 after applying the per-slice modifications. + * @ref_pic_list1: reference picture list 1 after applying the per-slice modifications. + * @flags: see V4L2_H264_SLICE_FLAG_{}. + */ +struct v4l2_ctrl_h264_slice_params { +	__u32 header_bit_size; +	__u32 first_mb_in_slice; +	__u8 slice_type; +	__u8 colour_plane_id; +	__u8 redundant_pic_cnt; +	__u8 cabac_init_idc; +	__s8 slice_qp_delta; +	__s8 slice_qs_delta; +	__u8 disable_deblocking_filter_idc; +	__s8 slice_alpha_c0_offset_div2; +	__s8 slice_beta_offset_div2; +	__u8 num_ref_idx_l0_active_minus1; +	__u8 num_ref_idx_l1_active_minus1; + +	__u8 reserved; + +	struct v4l2_h264_reference ref_pic_list0[V4L2_H264_REF_LIST_LEN]; +	struct v4l2_h264_reference ref_pic_list1[V4L2_H264_REF_LIST_LEN]; + +	__u32 flags; +}; + +#define V4L2_H264_DPB_ENTRY_FLAG_VALID		0x01 +#define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE		0x02 +#define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM	0x04 +#define V4L2_H264_DPB_ENTRY_FLAG_FIELD		0x08 + +/** + * struct v4l2_h264_dpb_entry - H264 decoded picture buffer entry + * + * @reference_ts: timestamp of the V4L2 capture buffer to use as reference. + * The timestamp refers to the timestamp field in struct v4l2_buffer. + * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64. + * @pic_num: matches PicNum variable assigned during the reference + * picture lists construction process. + * @frame_num: frame identifier which matches frame_num syntax element. + * @fields: indicates how the DPB entry is referenced. Valid values are + * V4L2_H264_{}_REF. + * @reserved: padding field. Should be zeroed by applications. + * @top_field_order_cnt: matches TopFieldOrderCnt picture value. + * @bottom_field_order_cnt: matches BottomFieldOrderCnt picture value. + * Note that picture field is indicated by v4l2_buffer.field. + * @flags: see V4L2_H264_DPB_ENTRY_FLAG_{}. + */ +struct v4l2_h264_dpb_entry { +	__u64 reference_ts; +	__u32 pic_num; +	__u16 frame_num; +	__u8 fields; +	__u8 reserved[5]; +	__s32 top_field_order_cnt; +	__s32 bottom_field_order_cnt; +	__u32 flags; +}; + +#define V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC		0x01 +#define V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC		0x02 +#define V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD	0x04 +#define V4L2_H264_DECODE_PARAM_FLAG_PFRAME		0x08 +#define V4L2_H264_DECODE_PARAM_FLAG_BFRAME		0x10 + +#define V4L2_CID_STATELESS_H264_DECODE_PARAMS	(V4L2_CID_CODEC_STATELESS_BASE + 7) +/** + * struct v4l2_ctrl_h264_decode_params - H264 decoding parameters + * + * @dpb: decoded picture buffer. + * @nal_ref_idc: slice header syntax element. + * @frame_num: slice header syntax element. + * @top_field_order_cnt: matches TopFieldOrderCnt picture value. + * @bottom_field_order_cnt: matches BottomFieldOrderCnt picture value. + * Note that picture field is indicated by v4l2_buffer.field. + * @idr_pic_id: slice header syntax element. + * @pic_order_cnt_lsb: slice header syntax element. + * @delta_pic_order_cnt_bottom: slice header syntax element. + * @delta_pic_order_cnt0: slice header syntax element. + * @delta_pic_order_cnt1: slice header syntax element. + * @dec_ref_pic_marking_bit_size: size in bits of dec_ref_pic_marking() + * syntax element. + * @pic_order_cnt_bit_size: size in bits of pic order count syntax. + * @slice_group_change_cycle: slice header syntax element. + * @reserved: padding field. Should be zeroed by applications. + * @flags: see V4L2_H264_DECODE_PARAM_FLAG_{}. + */ +struct v4l2_ctrl_h264_decode_params { +	struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]; +	__u16 nal_ref_idc; +	__u16 frame_num; +	__s32 top_field_order_cnt; +	__s32 bottom_field_order_cnt; +	__u16 idr_pic_id; +	__u16 pic_order_cnt_lsb; +	__s32 delta_pic_order_cnt_bottom; +	__s32 delta_pic_order_cnt0; +	__s32 delta_pic_order_cnt1; +	__u32 dec_ref_pic_marking_bit_size; +	__u32 pic_order_cnt_bit_size; +	__u32 slice_group_change_cycle; + +	__u32 reserved; +	__u32 flags; +}; + + +/* Stateless FWHT control, used by the vicodec driver */ + +/* Current FWHT version */ +#define V4L2_FWHT_VERSION			3 + +/* Set if this is an interlaced format */ +#define V4L2_FWHT_FL_IS_INTERLACED		_BITUL(0) +/* Set if this is a bottom-first (NTSC) interlaced format */ +#define V4L2_FWHT_FL_IS_BOTTOM_FIRST		_BITUL(1) +/* Set if each 'frame' contains just one field */ +#define V4L2_FWHT_FL_IS_ALTERNATE		_BITUL(2) +/* + * If V4L2_FWHT_FL_IS_ALTERNATE was set, then this is set if this + * 'frame' is the bottom field, else it is the top field. + */ +#define V4L2_FWHT_FL_IS_BOTTOM_FIELD		_BITUL(3) +/* Set if the Y' plane is uncompressed */ +#define V4L2_FWHT_FL_LUMA_IS_UNCOMPRESSED	_BITUL(4) +/* Set if the Cb plane is uncompressed */ +#define V4L2_FWHT_FL_CB_IS_UNCOMPRESSED		_BITUL(5) +/* Set if the Cr plane is uncompressed */ +#define V4L2_FWHT_FL_CR_IS_UNCOMPRESSED		_BITUL(6) +/* Set if the chroma plane is full height, if cleared it is half height */ +#define V4L2_FWHT_FL_CHROMA_FULL_HEIGHT		_BITUL(7) +/* Set if the chroma plane is full width, if cleared it is half width */ +#define V4L2_FWHT_FL_CHROMA_FULL_WIDTH		_BITUL(8) +/* Set if the alpha plane is uncompressed */ +#define V4L2_FWHT_FL_ALPHA_IS_UNCOMPRESSED	_BITUL(9) +/* Set if this is an I Frame */ +#define V4L2_FWHT_FL_I_FRAME			_BITUL(10) + +/* A 4-values flag - the number of components - 1 */ +#define V4L2_FWHT_FL_COMPONENTS_NUM_MSK		GENMASK(18, 16) +#define V4L2_FWHT_FL_COMPONENTS_NUM_OFFSET	16 + +/* A 4-values flag - the pixel encoding type */ +#define V4L2_FWHT_FL_PIXENC_MSK			GENMASK(20, 19) +#define V4L2_FWHT_FL_PIXENC_OFFSET		19 +#define V4L2_FWHT_FL_PIXENC_YUV			(1 << V4L2_FWHT_FL_PIXENC_OFFSET) +#define V4L2_FWHT_FL_PIXENC_RGB			(2 << V4L2_FWHT_FL_PIXENC_OFFSET) +#define V4L2_FWHT_FL_PIXENC_HSV			(3 << V4L2_FWHT_FL_PIXENC_OFFSET) + +#define V4L2_CID_STATELESS_FWHT_PARAMS		(V4L2_CID_CODEC_STATELESS_BASE + 100) +/** + * struct v4l2_ctrl_fwht_params - FWHT parameters + * + * @backward_ref_ts: timestamp of the V4L2 capture buffer to use as reference. + * The timestamp refers to the timestamp field in struct v4l2_buffer. + * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64. + * @version: must be V4L2_FWHT_VERSION. + * @width: width of frame. + * @height: height of frame. + * @flags: FWHT flags (see V4L2_FWHT_FL_*). + * @colorspace: the colorspace (enum v4l2_colorspace). + * @xfer_func: the transfer function (enum v4l2_xfer_func). + * @ycbcr_enc: the Y'CbCr encoding (enum v4l2_ycbcr_encoding). + * @quantization: the quantization (enum v4l2_quantization). + */ +struct v4l2_ctrl_fwht_params { +	__u64 backward_ref_ts; +	__u32 version; +	__u32 width; +	__u32 height; +	__u32 flags; +	__u32 colorspace; +	__u32 xfer_func; +	__u32 ycbcr_enc; +	__u32 quantization; +}; + +/* Stateless VP8 control */ + +#define V4L2_VP8_SEGMENT_FLAG_ENABLED              0x01 +#define V4L2_VP8_SEGMENT_FLAG_UPDATE_MAP           0x02 +#define V4L2_VP8_SEGMENT_FLAG_UPDATE_FEATURE_DATA  0x04 +#define V4L2_VP8_SEGMENT_FLAG_DELTA_VALUE_MODE     0x08 + +/** + * struct v4l2_vp8_segment - VP8 segment-based adjustments parameters + * + * @quant_update: update values for the segment quantizer. + * @lf_update: update values for the loop filter level. + * @segment_probs: branch probabilities of the segment_id decoding tree. + * @padding: padding field. Should be zeroed by applications. + * @flags: see V4L2_VP8_SEGMENT_FLAG_{}. + * + * This structure contains segment-based adjustments related parameters. + * See the 'update_segmentation()' part of the frame header syntax, + * and section '9.3. Segment-Based Adjustments' of the VP8 specification + * for more details. + */ +struct v4l2_vp8_segment { +	__s8 quant_update[4]; +	__s8 lf_update[4]; +	__u8 segment_probs[3]; +	__u8 padding; +	__u32 flags; +}; + +#define V4L2_VP8_LF_ADJ_ENABLE	0x01 +#define V4L2_VP8_LF_DELTA_UPDATE	0x02 +#define V4L2_VP8_LF_FILTER_TYPE_SIMPLE	0x04 + +/** + * struct v4l2_vp8_loop_filter - VP8 loop filter parameters + * + * @ref_frm_delta: Reference frame signed delta values. + * @mb_mode_delta: MB prediction mode signed delta values. + * @sharpness_level: matches sharpness_level syntax element. + * @level: matches loop_filter_level syntax element. + * @padding: padding field. Should be zeroed by applications. + * @flags: see V4L2_VP8_LF_{}. + * + * This structure contains loop filter related parameters. + * See the 'mb_lf_adjustments()' part of the frame header syntax, + * and section '9.4. Loop Filter Type and Levels' of the VP8 specification + * for more details. + */ +struct v4l2_vp8_loop_filter { +	__s8 ref_frm_delta[4]; +	__s8 mb_mode_delta[4]; +	__u8 sharpness_level; +	__u8 level; +	__u16 padding; +	__u32 flags; +}; + +/** + * struct v4l2_vp8_quantization - VP8 quantizattion indices + * + * @y_ac_qi: luma AC coefficient table index. + * @y_dc_delta: luma DC delta vaue. + * @y2_dc_delta: y2 block DC delta value. + * @y2_ac_delta: y2 block AC delta value. + * @uv_dc_delta: chroma DC delta value. + * @uv_ac_delta: chroma AC delta value. + * @padding: padding field. Should be zeroed by applications. + * + * This structure contains the quantization indices present + * in 'quant_indices()' part of the frame header syntax. + * See section '9.6. Dequantization Indices' of the VP8 specification + * for more details. + */ +struct v4l2_vp8_quantization { +	__u8 y_ac_qi; +	__s8 y_dc_delta; +	__s8 y2_dc_delta; +	__s8 y2_ac_delta; +	__s8 uv_dc_delta; +	__s8 uv_ac_delta; +	__u16 padding; +}; + +#define V4L2_VP8_COEFF_PROB_CNT 11 +#define V4L2_VP8_MV_PROB_CNT 19 + +/** + * struct v4l2_vp8_entropy - VP8 update probabilities + * + * @coeff_probs: coefficient probability update values. + * @y_mode_probs: luma intra-prediction probabilities. + * @uv_mode_probs: chroma intra-prediction probabilities. + * @mv_probs: mv decoding probability. + * @padding: padding field. Should be zeroed by applications. + * + * This structure contains the update probabilities present in + * 'token_prob_update()' and 'mv_prob_update()' part of the frame header. + * See section '17.2. Probability Updates' of the VP8 specification + * for more details. + */ +struct v4l2_vp8_entropy { +	__u8 coeff_probs[4][8][3][V4L2_VP8_COEFF_PROB_CNT]; +	__u8 y_mode_probs[4]; +	__u8 uv_mode_probs[3]; +	__u8 mv_probs[2][V4L2_VP8_MV_PROB_CNT]; +	__u8 padding[3]; +}; + +/** + * struct v4l2_vp8_entropy_coder_state - VP8 boolean coder state + * + * @range: coder state value for "Range" + * @value: coder state value for "Value" + * @bit_count: number of bits left in range "Value". + * @padding: padding field. Should be zeroed by applications. + * + * This structure contains the state for the boolean coder, as + * explained in section '7. Boolean Entropy Decoder' of the VP8 specification. + */ +struct v4l2_vp8_entropy_coder_state { +	__u8 range; +	__u8 value; +	__u8 bit_count; +	__u8 padding; +}; + +#define V4L2_VP8_FRAME_FLAG_KEY_FRAME		0x01 +#define V4L2_VP8_FRAME_FLAG_EXPERIMENTAL		0x02 +#define V4L2_VP8_FRAME_FLAG_SHOW_FRAME		0x04 +#define V4L2_VP8_FRAME_FLAG_MB_NO_SKIP_COEFF	0x08 +#define V4L2_VP8_FRAME_FLAG_SIGN_BIAS_GOLDEN	0x10 +#define V4L2_VP8_FRAME_FLAG_SIGN_BIAS_ALT	0x20 + +#define V4L2_VP8_FRAME_IS_KEY_FRAME(hdr) \ +	(!!((hdr)->flags & V4L2_VP8_FRAME_FLAG_KEY_FRAME)) + +#define V4L2_CID_STATELESS_VP8_FRAME (V4L2_CID_CODEC_STATELESS_BASE + 200) +/** + * struct v4l2_ctrl_vp8_frame - VP8 frame parameters + * + * @segment: segmentation parameters. See &v4l2_vp8_segment for more details + * @lf: loop filter parameters. See &v4l2_vp8_loop_filter for more details + * @quant: quantization parameters. See &v4l2_vp8_quantization for more details + * @entropy: update probabilities. See &v4l2_vp8_entropy for more details + * @coder_state: boolean coder state. See &v4l2_vp8_entropy_coder_state for more details + * @width: frame width. + * @height: frame height. + * @horizontal_scale: horizontal scaling factor. + * @vertical_scale: vertical scaling factor. + * @version: bitstream version. + * @prob_skip_false: frame header syntax element. + * @prob_intra: frame header syntax element. + * @prob_last: frame header syntax element. + * @prob_gf: frame header syntax element. + * @num_dct_parts: number of DCT coefficients partitions. + * @first_part_size: size of the first partition, i.e. the control partition. + * @first_part_header_bits: size in bits of the first partition header portion. + * @dct_part_sizes: DCT coefficients sizes. + * @last_frame_ts: "last" reference buffer timestamp. + * The timestamp refers to the timestamp field in struct v4l2_buffer. + * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64. + * @golden_frame_ts: "golden" reference buffer timestamp. + * @alt_frame_ts: "alt" reference buffer timestamp. + * @flags: see V4L2_VP8_FRAME_FLAG_{}. + */ +struct v4l2_ctrl_vp8_frame { +	struct v4l2_vp8_segment segment; +	struct v4l2_vp8_loop_filter lf; +	struct v4l2_vp8_quantization quant; +	struct v4l2_vp8_entropy entropy; +	struct v4l2_vp8_entropy_coder_state coder_state; + +	__u16 width; +	__u16 height; + +	__u8 horizontal_scale; +	__u8 vertical_scale; + +	__u8 version; +	__u8 prob_skip_false; +	__u8 prob_intra; +	__u8 prob_last; +	__u8 prob_gf; +	__u8 num_dct_parts; + +	__u32 first_part_size; +	__u32 first_part_header_bits; +	__u32 dct_part_sizes[8]; + +	__u64 last_frame_ts; +	__u64 golden_frame_ts; +	__u64 alt_frame_ts; + +	__u64 flags; +}; + +/* Stateless MPEG-2 controls */ + +#define V4L2_MPEG2_SEQ_FLAG_PROGRESSIVE	0x01 + +#define V4L2_CID_STATELESS_MPEG2_SEQUENCE (V4L2_CID_CODEC_STATELESS_BASE+220) +/** + * struct v4l2_ctrl_mpeg2_sequence - MPEG-2 sequence header + * + * All the members on this structure match the sequence header and sequence + * extension syntaxes as specified by the MPEG-2 specification. + * + * Fields horizontal_size, vertical_size and vbv_buffer_size are a + * combination of respective _value and extension syntax elements, + * as described in section 6.3.3 "Sequence header". + * + * @horizontal_size: combination of elements horizontal_size_value and + * horizontal_size_extension. + * @vertical_size: combination of elements vertical_size_value and + * vertical_size_extension. + * @vbv_buffer_size: combination of elements vbv_buffer_size_value and + * vbv_buffer_size_extension. + * @profile_and_level_indication: see MPEG-2 specification. + * @chroma_format: see MPEG-2 specification. + * @flags: see V4L2_MPEG2_SEQ_FLAG_{}. + */ +struct v4l2_ctrl_mpeg2_sequence { +	__u16	horizontal_size; +	__u16	vertical_size; +	__u32	vbv_buffer_size; +	__u16	profile_and_level_indication; +	__u8	chroma_format; +	__u8	flags; +}; + +#define V4L2_MPEG2_PIC_CODING_TYPE_I			1 +#define V4L2_MPEG2_PIC_CODING_TYPE_P			2 +#define V4L2_MPEG2_PIC_CODING_TYPE_B			3 +#define V4L2_MPEG2_PIC_CODING_TYPE_D			4 + +#define V4L2_MPEG2_PIC_TOP_FIELD			0x1 +#define V4L2_MPEG2_PIC_BOTTOM_FIELD			0x2 +#define V4L2_MPEG2_PIC_FRAME				0x3 + +#define V4L2_MPEG2_PIC_FLAG_TOP_FIELD_FIRST		0x0001 +#define V4L2_MPEG2_PIC_FLAG_FRAME_PRED_DCT		0x0002 +#define V4L2_MPEG2_PIC_FLAG_CONCEALMENT_MV		0x0004 +#define V4L2_MPEG2_PIC_FLAG_Q_SCALE_TYPE		0x0008 +#define V4L2_MPEG2_PIC_FLAG_INTRA_VLC			0x0010 +#define V4L2_MPEG2_PIC_FLAG_ALT_SCAN			0x0020 +#define V4L2_MPEG2_PIC_FLAG_REPEAT_FIRST		0x0040 +#define V4L2_MPEG2_PIC_FLAG_PROGRESSIVE			0x0080 + +#define V4L2_CID_STATELESS_MPEG2_PICTURE (V4L2_CID_CODEC_STATELESS_BASE+221) +/** + * struct v4l2_ctrl_mpeg2_picture - MPEG-2 picture header + * + * All the members on this structure match the picture header and picture + * coding extension syntaxes as specified by the MPEG-2 specification. + * + * @backward_ref_ts: timestamp of the V4L2 capture buffer to use as + * reference for backward prediction. + * @forward_ref_ts: timestamp of the V4L2 capture buffer to use as + * reference for forward prediction. These timestamp refers to the + * timestamp field in struct v4l2_buffer. Use v4l2_timeval_to_ns() + * to convert the struct timeval to a __u64. + * @flags: see V4L2_MPEG2_PIC_FLAG_{}. + * @f_code: see MPEG-2 specification. + * @picture_coding_type: see MPEG-2 specification. + * @picture_structure: see V4L2_MPEG2_PIC_{}_FIELD. + * @intra_dc_precision: see MPEG-2 specification. + * @reserved: padding field. Should be zeroed by applications. + */ +struct v4l2_ctrl_mpeg2_picture { +	__u64	backward_ref_ts; +	__u64	forward_ref_ts; +	__u32	flags; +	__u8	f_code[2][2]; +	__u8	picture_coding_type; +	__u8	picture_structure; +	__u8	intra_dc_precision; +	__u8	reserved[5]; +}; + +#define V4L2_CID_STATELESS_MPEG2_QUANTISATION (V4L2_CID_CODEC_STATELESS_BASE+222) +/** + * struct v4l2_ctrl_mpeg2_quantisation - MPEG-2 quantisation + * + * Quantisation matrices as specified by section 6.3.7 + * "Quant matrix extension". + * + * @intra_quantiser_matrix: The quantisation matrix coefficients + * for intra-coded frames, in zigzag scanning order. It is relevant + * for both luma and chroma components, although it can be superseded + * by the chroma-specific matrix for non-4:2:0 YUV formats. + * @non_intra_quantiser_matrix: The quantisation matrix coefficients + * for non-intra-coded frames, in zigzag scanning order. It is relevant + * for both luma and chroma components, although it can be superseded + * by the chroma-specific matrix for non-4:2:0 YUV formats. + * @chroma_intra_quantiser_matrix: The quantisation matrix coefficients + * for the chominance component of intra-coded frames, in zigzag scanning + * order. Only relevant for 4:2:2 and 4:4:4 YUV formats. + * @chroma_non_intra_quantiser_matrix: The quantisation matrix coefficients + * for the chrominance component of non-intra-coded frames, in zigzag scanning + * order. Only relevant for 4:2:2 and 4:4:4 YUV formats. + */ +struct v4l2_ctrl_mpeg2_quantisation { +	__u8	intra_quantiser_matrix[64]; +	__u8	non_intra_quantiser_matrix[64]; +	__u8	chroma_intra_quantiser_matrix[64]; +	__u8	chroma_non_intra_quantiser_matrix[64]; +}; + +#define V4L2_CID_STATELESS_HEVC_SPS		(V4L2_CID_CODEC_STATELESS_BASE + 400) +#define V4L2_CID_STATELESS_HEVC_PPS		(V4L2_CID_CODEC_STATELESS_BASE + 401) +#define V4L2_CID_STATELESS_HEVC_SLICE_PARAMS	(V4L2_CID_CODEC_STATELESS_BASE + 402) +#define V4L2_CID_STATELESS_HEVC_SCALING_MATRIX	(V4L2_CID_CODEC_STATELESS_BASE + 403) +#define V4L2_CID_STATELESS_HEVC_DECODE_PARAMS	(V4L2_CID_CODEC_STATELESS_BASE + 404) +#define V4L2_CID_STATELESS_HEVC_DECODE_MODE	(V4L2_CID_CODEC_STATELESS_BASE + 405) +#define V4L2_CID_STATELESS_HEVC_START_CODE	(V4L2_CID_CODEC_STATELESS_BASE + 406) +#define V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS (V4L2_CID_CODEC_STATELESS_BASE + 407) + +enum v4l2_stateless_hevc_decode_mode { +	V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED, +	V4L2_STATELESS_HEVC_DECODE_MODE_FRAME_BASED, +}; + +enum v4l2_stateless_hevc_start_code { +	V4L2_STATELESS_HEVC_START_CODE_NONE, +	V4L2_STATELESS_HEVC_START_CODE_ANNEX_B, +}; + +#define V4L2_HEVC_SLICE_TYPE_B	0 +#define V4L2_HEVC_SLICE_TYPE_P	1 +#define V4L2_HEVC_SLICE_TYPE_I	2 + +#define V4L2_HEVC_SPS_FLAG_SEPARATE_COLOUR_PLANE		(1ULL << 0) +#define V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED			(1ULL << 1) +#define V4L2_HEVC_SPS_FLAG_AMP_ENABLED				(1ULL << 2) +#define V4L2_HEVC_SPS_FLAG_SAMPLE_ADAPTIVE_OFFSET		(1ULL << 3) +#define V4L2_HEVC_SPS_FLAG_PCM_ENABLED				(1ULL << 4) +#define V4L2_HEVC_SPS_FLAG_PCM_LOOP_FILTER_DISABLED		(1ULL << 5) +#define V4L2_HEVC_SPS_FLAG_LONG_TERM_REF_PICS_PRESENT		(1ULL << 6) +#define V4L2_HEVC_SPS_FLAG_SPS_TEMPORAL_MVP_ENABLED		(1ULL << 7) +#define V4L2_HEVC_SPS_FLAG_STRONG_INTRA_SMOOTHING_ENABLED	(1ULL << 8) + +/** + * struct v4l2_ctrl_hevc_sps - ITU-T Rec. H.265: Sequence parameter set + * + * @video_parameter_set_id: specifies the value of the + *			vps_video_parameter_set_id of the active VPS + * @seq_parameter_set_id: provides an identifier for the SPS for + *			  reference by other syntax elements + * @pic_width_in_luma_samples:	specifies the width of each decoded picture + *				in units of luma samples + * @pic_height_in_luma_samples: specifies the height of each decoded picture + *				in units of luma samples + * @bit_depth_luma_minus8: this value plus 8specifies the bit depth of the + *                         samples of the luma array + * @bit_depth_chroma_minus8: this value plus 8 specifies the bit depth of the + *                           samples of the chroma arrays + * @log2_max_pic_order_cnt_lsb_minus4: this value plus 4 specifies the value of + *                                     the variable MaxPicOrderCntLsb + * @sps_max_dec_pic_buffering_minus1: this value plus 1 specifies the maximum + *                                    required size of the decoded picture + *                                    buffer for the codec video sequence + * @sps_max_num_reorder_pics: indicates the maximum allowed number of pictures + * @sps_max_latency_increase_plus1: not equal to 0 is used to compute the + *				    value of SpsMaxLatencyPictures array + * @log2_min_luma_coding_block_size_minus3: plus 3 specifies the minimum + *					    luma coding block size + * @log2_diff_max_min_luma_coding_block_size: specifies the difference between + *					      the maximum and minimum luma + *					      coding block size + * @log2_min_luma_transform_block_size_minus2: plus 2 specifies the minimum luma + *					       transform block size + * @log2_diff_max_min_luma_transform_block_size: specifies the difference between + *						 the maximum and minimum luma + *						 transform block size + * @max_transform_hierarchy_depth_inter: specifies the maximum hierarchy + *					 depth for transform units of + *					 coding units coded in inter + *					 prediction mode + * @max_transform_hierarchy_depth_intra: specifies the maximum hierarchy + *					 depth for transform units of + *					 coding units coded in intra + *					 prediction mode + * @pcm_sample_bit_depth_luma_minus1: this value plus 1 specifies the number of + *                                    bits used to represent each of PCM sample + *                                    values of the luma component + * @pcm_sample_bit_depth_chroma_minus1: this value plus 1 specifies the number + *                                      of bits used to represent each of PCM + *                                      sample values of the chroma components + * @log2_min_pcm_luma_coding_block_size_minus3: this value plus 3 specifies the + *                                              minimum size of coding blocks + * @log2_diff_max_min_pcm_luma_coding_block_size: specifies the difference between + *						  the maximum and minimum size of + *						  coding blocks + * @num_short_term_ref_pic_sets: specifies the number of st_ref_pic_set() + *				 syntax structures included in the SPS + * @num_long_term_ref_pics_sps: specifies the number of candidate long-term + *				reference pictures that are specified in the SPS + * @chroma_format_idc: specifies the chroma sampling + * @sps_max_sub_layers_minus1: this value plus 1 specifies the maximum number + *                             of temporal sub-layers + * @reserved: padding field. Should be zeroed by applications. + * @flags: see V4L2_HEVC_SPS_FLAG_{} + */ +struct v4l2_ctrl_hevc_sps { +	__u8	video_parameter_set_id; +	__u8	seq_parameter_set_id; +	__u16	pic_width_in_luma_samples; +	__u16	pic_height_in_luma_samples; +	__u8	bit_depth_luma_minus8; +	__u8	bit_depth_chroma_minus8; +	__u8	log2_max_pic_order_cnt_lsb_minus4; +	__u8	sps_max_dec_pic_buffering_minus1; +	__u8	sps_max_num_reorder_pics; +	__u8	sps_max_latency_increase_plus1; +	__u8	log2_min_luma_coding_block_size_minus3; +	__u8	log2_diff_max_min_luma_coding_block_size; +	__u8	log2_min_luma_transform_block_size_minus2; +	__u8	log2_diff_max_min_luma_transform_block_size; +	__u8	max_transform_hierarchy_depth_inter; +	__u8	max_transform_hierarchy_depth_intra; +	__u8	pcm_sample_bit_depth_luma_minus1; +	__u8	pcm_sample_bit_depth_chroma_minus1; +	__u8	log2_min_pcm_luma_coding_block_size_minus3; +	__u8	log2_diff_max_min_pcm_luma_coding_block_size; +	__u8	num_short_term_ref_pic_sets; +	__u8	num_long_term_ref_pics_sps; +	__u8	chroma_format_idc; +	__u8	sps_max_sub_layers_minus1; + +	__u8	reserved[6]; +	__u64	flags; +}; + +#define V4L2_HEVC_PPS_FLAG_DEPENDENT_SLICE_SEGMENT_ENABLED	(1ULL << 0) +#define V4L2_HEVC_PPS_FLAG_OUTPUT_FLAG_PRESENT			(1ULL << 1) +#define V4L2_HEVC_PPS_FLAG_SIGN_DATA_HIDING_ENABLED		(1ULL << 2) +#define V4L2_HEVC_PPS_FLAG_CABAC_INIT_PRESENT			(1ULL << 3) +#define V4L2_HEVC_PPS_FLAG_CONSTRAINED_INTRA_PRED		(1ULL << 4) +#define V4L2_HEVC_PPS_FLAG_TRANSFORM_SKIP_ENABLED		(1ULL << 5) +#define V4L2_HEVC_PPS_FLAG_CU_QP_DELTA_ENABLED			(1ULL << 6) +#define V4L2_HEVC_PPS_FLAG_PPS_SLICE_CHROMA_QP_OFFSETS_PRESENT	(1ULL << 7) +#define V4L2_HEVC_PPS_FLAG_WEIGHTED_PRED			(1ULL << 8) +#define V4L2_HEVC_PPS_FLAG_WEIGHTED_BIPRED			(1ULL << 9) +#define V4L2_HEVC_PPS_FLAG_TRANSQUANT_BYPASS_ENABLED		(1ULL << 10) +#define V4L2_HEVC_PPS_FLAG_TILES_ENABLED			(1ULL << 11) +#define V4L2_HEVC_PPS_FLAG_ENTROPY_CODING_SYNC_ENABLED		(1ULL << 12) +#define V4L2_HEVC_PPS_FLAG_LOOP_FILTER_ACROSS_TILES_ENABLED	(1ULL << 13) +#define V4L2_HEVC_PPS_FLAG_PPS_LOOP_FILTER_ACROSS_SLICES_ENABLED (1ULL << 14) +#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_OVERRIDE_ENABLED	(1ULL << 15) +#define V4L2_HEVC_PPS_FLAG_PPS_DISABLE_DEBLOCKING_FILTER	(1ULL << 16) +#define V4L2_HEVC_PPS_FLAG_LISTS_MODIFICATION_PRESENT		(1ULL << 17) +#define V4L2_HEVC_PPS_FLAG_SLICE_SEGMENT_HEADER_EXTENSION_PRESENT (1ULL << 18) +#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT	(1ULL << 19) +#define V4L2_HEVC_PPS_FLAG_UNIFORM_SPACING			(1ULL << 20) + +/** + * struct v4l2_ctrl_hevc_pps - ITU-T Rec. H.265: Picture parameter set + * + * @pic_parameter_set_id: identifies the PPS for reference by other + *			  syntax elements + * @num_extra_slice_header_bits: specifies the number of extra slice header + *				 bits that are present in the slice header RBSP + *				 for coded pictures referring to the PPS. + * @num_ref_idx_l0_default_active_minus1: this value plus 1 specifies the + *                                        inferred value of num_ref_idx_l0_active_minus1 + * @num_ref_idx_l1_default_active_minus1: this value plus 1 specifies the + *                                        inferred value of num_ref_idx_l1_active_minus1 + * @init_qp_minus26: this value plus 26 specifies the initial value of SliceQp Y for + *		     each slice referring to the PPS + * @diff_cu_qp_delta_depth: specifies the difference between the luma coding + *			    tree block size and the minimum luma coding block + *			    size of coding units that convey cu_qp_delta_abs + *			    and cu_qp_delta_sign_flag + * @pps_cb_qp_offset: specify the offsets to the luma quantization parameter Cb + * @pps_cr_qp_offset: specify the offsets to the luma quantization parameter Cr + * @num_tile_columns_minus1: this value plus 1 specifies the number of tile columns + *			     partitioning the picture + * @num_tile_rows_minus1: this value plus 1 specifies the number of tile rows partitioning + *			  the picture + * @column_width_minus1: this value plus 1 specifies the width of the each tile column in + *			 units of coding tree blocks + * @row_height_minus1: this value plus 1 specifies the height of the each tile row in + *		       units of coding tree blocks + * @pps_beta_offset_div2: specify the default deblocking parameter offsets for + *			  beta divided by 2 + * @pps_tc_offset_div2: specify the default deblocking parameter offsets for tC + *			divided by 2 + * @log2_parallel_merge_level_minus2: this value plus 2 specifies the value of + *                                    the variable Log2ParMrgLevel + * @reserved: padding field. Should be zeroed by applications. + * @flags: see V4L2_HEVC_PPS_FLAG_{} + */ +struct v4l2_ctrl_hevc_pps { +	__u8	pic_parameter_set_id; +	__u8	num_extra_slice_header_bits; +	__u8	num_ref_idx_l0_default_active_minus1; +	__u8	num_ref_idx_l1_default_active_minus1; +	__s8	init_qp_minus26; +	__u8	diff_cu_qp_delta_depth; +	__s8	pps_cb_qp_offset; +	__s8	pps_cr_qp_offset; +	__u8	num_tile_columns_minus1; +	__u8	num_tile_rows_minus1; +	__u8	column_width_minus1[20]; +	__u8	row_height_minus1[22]; +	__s8	pps_beta_offset_div2; +	__s8	pps_tc_offset_div2; +	__u8	log2_parallel_merge_level_minus2; +	__u8	reserved; +	__u64	flags; +}; + +#define V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE	0x01 + +#define V4L2_HEVC_SEI_PIC_STRUCT_FRAME				0 +#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_FIELD			1 +#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_FIELD			2 +#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_BOTTOM			3 +#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_TOP			4 +#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_BOTTOM_TOP			5 +#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM		6 +#define V4L2_HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING			7 +#define V4L2_HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING			8 +#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_PAIRED_PREVIOUS_BOTTOM	9 +#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_PAIRED_PREVIOUS_TOP	10 +#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_PAIRED_NEXT_BOTTOM		11 +#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_PAIRED_NEXT_TOP		12 + +#define V4L2_HEVC_DPB_ENTRIES_NUM_MAX		16 + +/** + * struct v4l2_hevc_dpb_entry - HEVC decoded picture buffer entry + * + * @timestamp: timestamp of the V4L2 capture buffer to use as reference. + * @flags: long term flag for the reference frame + * @field_pic: whether the reference is a field picture or a frame. + * @reserved: padding field. Should be zeroed by applications. + * @pic_order_cnt_val: the picture order count of the current picture. + */ +struct v4l2_hevc_dpb_entry { +	__u64	timestamp; +	__u8	flags; +	__u8	field_pic; +	__u16	reserved; +	__s32	pic_order_cnt_val; +}; + +/** + * struct v4l2_hevc_pred_weight_table - HEVC weighted prediction parameters + * + * @delta_luma_weight_l0: the difference of the weighting factor applied + *			  to the luma prediction value for list 0 + * @luma_offset_l0: the additive offset applied to the luma prediction value + *		    for list 0 + * @delta_chroma_weight_l0: the difference of the weighting factor applied + *			    to the chroma prediction values for list 0 + * @chroma_offset_l0: the difference of the additive offset applied to + *		      the chroma prediction values for list 0 + * @delta_luma_weight_l1: the difference of the weighting factor applied + *			  to the luma prediction value for list 1 + * @luma_offset_l1: the additive offset applied to the luma prediction value + *		    for list 1 + * @delta_chroma_weight_l1: the difference of the weighting factor applied + *			    to the chroma prediction values for list 1 + * @chroma_offset_l1: the difference of the additive offset applied to + *		      the chroma prediction values for list 1 + * @luma_log2_weight_denom: the base 2 logarithm of the denominator for + *			    all luma weighting factors + * @delta_chroma_log2_weight_denom: the difference of the base 2 logarithm + *				    of the denominator for all chroma + *				    weighting factors + */ +struct v4l2_hevc_pred_weight_table { +	__s8	delta_luma_weight_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; +	__s8	luma_offset_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; +	__s8	delta_chroma_weight_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2]; +	__s8	chroma_offset_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2]; + +	__s8	delta_luma_weight_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; +	__s8	luma_offset_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; +	__s8	delta_chroma_weight_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2]; +	__s8	chroma_offset_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2]; + +	__u8	luma_log2_weight_denom; +	__s8	delta_chroma_log2_weight_denom; +}; + +#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_SAO_LUMA		(1ULL << 0) +#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_SAO_CHROMA		(1ULL << 1) +#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_TEMPORAL_MVP_ENABLED	(1ULL << 2) +#define V4L2_HEVC_SLICE_PARAMS_FLAG_MVD_L1_ZERO			(1ULL << 3) +#define V4L2_HEVC_SLICE_PARAMS_FLAG_CABAC_INIT			(1ULL << 4) +#define V4L2_HEVC_SLICE_PARAMS_FLAG_COLLOCATED_FROM_L0		(1ULL << 5) +#define V4L2_HEVC_SLICE_PARAMS_FLAG_USE_INTEGER_MV		(1ULL << 6) +#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_DEBLOCKING_FILTER_DISABLED (1ULL << 7) +#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED (1ULL << 8) +#define V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT	(1ULL << 9) + +/** + * struct v4l2_ctrl_hevc_slice_params - HEVC slice parameters + * + * This control is a dynamically sized 1-dimensional array, + * V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it. + * + * @bit_size: size (in bits) of the current slice data + * @data_byte_offset: offset (in bytes) to the video data in the current slice data + * @num_entry_point_offsets: specifies the number of entry point offset syntax + *			     elements in the slice header. + * @nal_unit_type: specifies the coding type of the slice (B, P or I) + * @nuh_temporal_id_plus1: minus 1 specifies a temporal identifier for the NAL unit + * @slice_type: see V4L2_HEVC_SLICE_TYPE_{} + * @colour_plane_id: specifies the colour plane associated with the current slice + * @slice_pic_order_cnt: specifies the picture order count + * @num_ref_idx_l0_active_minus1: this value plus 1 specifies the maximum + *                                reference index for reference picture list 0 + *                                that may be used to decode the slice + * @num_ref_idx_l1_active_minus1: this value plus 1 specifies the maximum + *                                reference index for reference picture list 1 + *                                that may be used to decode the slice + * @collocated_ref_idx: specifies the reference index of the collocated picture used + *			for temporal motion vector prediction + * @five_minus_max_num_merge_cand: specifies the maximum number of merging + *				   motion vector prediction candidates supported in + *				   the slice subtracted from 5 + * @slice_qp_delta: specifies the initial value of QpY to be used for the coding + *		    blocks in the slice + * @slice_cb_qp_offset: specifies a difference to be added to the value of pps_cb_qp_offset + * @slice_cr_qp_offset: specifies a difference to be added to the value of pps_cr_qp_offset + * @slice_act_y_qp_offset: screen content extension parameters + * @slice_act_cb_qp_offset: screen content extension parameters + * @slice_act_cr_qp_offset: screen content extension parameters + * @slice_beta_offset_div2: specify the deblocking parameter offsets for beta divided by 2 + * @slice_tc_offset_div2: specify the deblocking parameter offsets for tC divided by 2 + * @pic_struct: indicates whether a picture should be displayed as a frame or as one or + *		more fields + * @reserved0: padding field. Should be zeroed by applications. + * @slice_segment_addr: specifies the address of the first coding tree block in + *			the slice segment + * @ref_idx_l0: the list of L0 reference elements as indices in the DPB + * @ref_idx_l1: the list of L1 reference elements as indices in the DPB + * @short_term_ref_pic_set_size: specifies the size of short-term reference + *				 pictures set included in the SPS + * @long_term_ref_pic_set_size: specifies the size of long-term reference + *				pictures set include in the SPS + * @pred_weight_table: the prediction weight coefficients for inter-picture + *		       prediction + * @reserved1: padding field. Should be zeroed by applications. + * @flags: see V4L2_HEVC_SLICE_PARAMS_FLAG_{} + */ +struct v4l2_ctrl_hevc_slice_params { +	__u32	bit_size; +	__u32	data_byte_offset; +	__u32	num_entry_point_offsets; + +	/* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */ +	__u8	nal_unit_type; +	__u8	nuh_temporal_id_plus1; + +	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */ +	__u8	slice_type; +	__u8	colour_plane_id; +	__s32	slice_pic_order_cnt; +	__u8	num_ref_idx_l0_active_minus1; +	__u8	num_ref_idx_l1_active_minus1; +	__u8	collocated_ref_idx; +	__u8	five_minus_max_num_merge_cand; +	__s8	slice_qp_delta; +	__s8	slice_cb_qp_offset; +	__s8	slice_cr_qp_offset; +	__s8	slice_act_y_qp_offset; +	__s8	slice_act_cb_qp_offset; +	__s8	slice_act_cr_qp_offset; +	__s8	slice_beta_offset_div2; +	__s8	slice_tc_offset_div2; + +	/* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture timing SEI message */ +	__u8	pic_struct; + +	__u8	reserved0[3]; +	/* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */ +	__u32	slice_segment_addr; +	__u8	ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; +	__u8	ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; +	__u16	short_term_ref_pic_set_size; +	__u16	long_term_ref_pic_set_size; + +	/* ISO/IEC 23008-2, ITU-T Rec. H.265: Weighted prediction parameter */ +	struct v4l2_hevc_pred_weight_table pred_weight_table; + +	__u8	reserved1[2]; +	__u64	flags; +}; + +#define V4L2_HEVC_DECODE_PARAM_FLAG_IRAP_PIC		0x1 +#define V4L2_HEVC_DECODE_PARAM_FLAG_IDR_PIC		0x2 +#define V4L2_HEVC_DECODE_PARAM_FLAG_NO_OUTPUT_OF_PRIOR  0x4 + +/** + * struct v4l2_ctrl_hevc_decode_params - HEVC decode parameters + * + * @pic_order_cnt_val: picture order count + * @short_term_ref_pic_set_size: specifies the size of short-term reference + *				 pictures set included in the SPS of the first slice + * @long_term_ref_pic_set_size: specifies the size of long-term reference + *				pictures set include in the SPS of the first slice + * @num_active_dpb_entries: the number of entries in dpb + * @num_poc_st_curr_before: the number of reference pictures in the short-term + *			    set that come before the current frame + * @num_poc_st_curr_after: the number of reference pictures in the short-term + *			   set that come after the current frame + * @num_poc_lt_curr: the number of reference pictures in the long-term set + * @poc_st_curr_before: provides the index of the short term before references + *			in DPB array + * @poc_st_curr_after: provides the index of the short term after references + *		       in DPB array + * @poc_lt_curr: provides the index of the long term references in DPB array + * @num_delta_pocs_of_ref_rps_idx: same as the derived value NumDeltaPocs[RefRpsIdx], + *				   can be used to parse the RPS data in slice headers + *				   instead of skipping it with @short_term_ref_pic_set_size. + * @reserved: padding field. Should be zeroed by applications. + * @dpb: the decoded picture buffer, for meta-data about reference frames + * @flags: see V4L2_HEVC_DECODE_PARAM_FLAG_{} + */ +struct v4l2_ctrl_hevc_decode_params { +	__s32	pic_order_cnt_val; +	__u16	short_term_ref_pic_set_size; +	__u16	long_term_ref_pic_set_size; +	__u8	num_active_dpb_entries; +	__u8	num_poc_st_curr_before; +	__u8	num_poc_st_curr_after; +	__u8	num_poc_lt_curr; +	__u8	poc_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; +	__u8	poc_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; +	__u8	poc_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; +	__u8	num_delta_pocs_of_ref_rps_idx; +	__u8	reserved[3]; +	struct	v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; +	__u64	flags; +}; + +/** + * struct v4l2_ctrl_hevc_scaling_matrix - HEVC scaling lists parameters + * + * @scaling_list_4x4: scaling list is used for the scaling process for + *		      transform coefficients. The values on each scaling + *		      list are expected in raster scan order + * @scaling_list_8x8: scaling list is used for the scaling process for + *		      transform coefficients. The values on each scaling + *		      list are expected in raster scan order + * @scaling_list_16x16:	scaling list is used for the scaling process for + *			transform coefficients. The values on each scaling + *			list are expected in raster scan order + * @scaling_list_32x32:	scaling list is used for the scaling process for + *			transform coefficients. The values on each scaling + *			list are expected in raster scan order + * @scaling_list_dc_coef_16x16:	scaling list is used for the scaling process + *				for transform coefficients. The values on each + *				scaling list are expected in raster scan order. + * @scaling_list_dc_coef_32x32:	scaling list is used for the scaling process + *				for transform coefficients. The values on each + *				scaling list are expected in raster scan order. + */ +struct v4l2_ctrl_hevc_scaling_matrix { +	__u8	scaling_list_4x4[6][16]; +	__u8	scaling_list_8x8[6][64]; +	__u8	scaling_list_16x16[6][64]; +	__u8	scaling_list_32x32[2][64]; +	__u8	scaling_list_dc_coef_16x16[6]; +	__u8	scaling_list_dc_coef_32x32[2]; +}; + +#define V4L2_CID_COLORIMETRY_CLASS_BASE	(V4L2_CTRL_CLASS_COLORIMETRY | 0x900) +#define V4L2_CID_COLORIMETRY_CLASS	(V4L2_CTRL_CLASS_COLORIMETRY | 1) + +#define V4L2_CID_COLORIMETRY_HDR10_CLL_INFO	(V4L2_CID_COLORIMETRY_CLASS_BASE + 0) + +struct v4l2_ctrl_hdr10_cll_info { +	__u16 max_content_light_level; +	__u16 max_pic_average_light_level; +}; + +#define V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY	(V4L2_CID_COLORIMETRY_CLASS_BASE + 1) + +#define V4L2_HDR10_MASTERING_PRIMARIES_X_LOW	5 +#define V4L2_HDR10_MASTERING_PRIMARIES_X_HIGH	37000 +#define V4L2_HDR10_MASTERING_PRIMARIES_Y_LOW	5 +#define V4L2_HDR10_MASTERING_PRIMARIES_Y_HIGH	42000 +#define V4L2_HDR10_MASTERING_WHITE_POINT_X_LOW	5 +#define V4L2_HDR10_MASTERING_WHITE_POINT_X_HIGH	37000 +#define V4L2_HDR10_MASTERING_WHITE_POINT_Y_LOW	5 +#define V4L2_HDR10_MASTERING_WHITE_POINT_Y_HIGH	42000 +#define V4L2_HDR10_MASTERING_MAX_LUMA_LOW	50000 +#define V4L2_HDR10_MASTERING_MAX_LUMA_HIGH	100000000 +#define V4L2_HDR10_MASTERING_MIN_LUMA_LOW	1 +#define V4L2_HDR10_MASTERING_MIN_LUMA_HIGH	50000 + +struct v4l2_ctrl_hdr10_mastering_display { +	__u16 display_primaries_x[3]; +	__u16 display_primaries_y[3]; +	__u16 white_point_x; +	__u16 white_point_y; +	__u32 max_display_mastering_luminance; +	__u32 min_display_mastering_luminance; +}; + +/* Stateless VP9 controls */ + +#define V4L2_VP9_LOOP_FILTER_FLAG_DELTA_ENABLED	0x1 +#define	V4L2_VP9_LOOP_FILTER_FLAG_DELTA_UPDATE	0x2 + +/** + * struct v4l2_vp9_loop_filter - VP9 loop filter parameters + * + * @ref_deltas: contains the adjustment needed for the filter level based on the + * chosen reference frame. If this syntax element is not present in the bitstream, + * users should pass its last value. + * @mode_deltas: contains the adjustment needed for the filter level based on the + * chosen mode.	If this syntax element is not present in the bitstream, users should + * pass its last value. + * @level: indicates the loop filter strength. + * @sharpness: indicates the sharpness level. + * @flags: combination of V4L2_VP9_LOOP_FILTER_FLAG_{} flags. + * @reserved: padding field. Should be zeroed by applications. + * + * This structure contains all loop filter related parameters. See sections + * '7.2.8 Loop filter semantics' of the VP9 specification for more details. + */ +struct v4l2_vp9_loop_filter { +	__s8 ref_deltas[4]; +	__s8 mode_deltas[2]; +	__u8 level; +	__u8 sharpness; +	__u8 flags; +	__u8 reserved[7]; +}; + +/** + * struct v4l2_vp9_quantization - VP9 quantization parameters + * + * @base_q_idx: indicates the base frame qindex. + * @delta_q_y_dc: indicates the Y DC quantizer relative to base_q_idx. + * @delta_q_uv_dc: indicates the UV DC quantizer relative to base_q_idx. + * @delta_q_uv_ac: indicates the UV AC quantizer relative to base_q_idx. + * @reserved: padding field. Should be zeroed by applications. + * + * Encodes the quantization parameters. See section '7.2.9 Quantization params + * syntax' of the VP9 specification for more details. + */ +struct v4l2_vp9_quantization { +	__u8 base_q_idx; +	__s8 delta_q_y_dc; +	__s8 delta_q_uv_dc; +	__s8 delta_q_uv_ac; +	__u8 reserved[4]; +}; + +#define V4L2_VP9_SEGMENTATION_FLAG_ENABLED		0x01 +#define V4L2_VP9_SEGMENTATION_FLAG_UPDATE_MAP		0x02 +#define V4L2_VP9_SEGMENTATION_FLAG_TEMPORAL_UPDATE	0x04 +#define V4L2_VP9_SEGMENTATION_FLAG_UPDATE_DATA		0x08 +#define V4L2_VP9_SEGMENTATION_FLAG_ABS_OR_DELTA_UPDATE	0x10 + +#define V4L2_VP9_SEG_LVL_ALT_Q				0 +#define V4L2_VP9_SEG_LVL_ALT_L				1 +#define V4L2_VP9_SEG_LVL_REF_FRAME			2 +#define V4L2_VP9_SEG_LVL_SKIP				3 +#define V4L2_VP9_SEG_LVL_MAX				4 + +#define V4L2_VP9_SEGMENT_FEATURE_ENABLED(id)	(1 << (id)) +#define V4L2_VP9_SEGMENT_FEATURE_ENABLED_MASK	0xf + +/** + * struct v4l2_vp9_segmentation - VP9 segmentation parameters + * + * @feature_data: data attached to each feature. Data entry is only valid if + * the feature is enabled. The array shall be indexed with segment number as + * the first dimension (0..7) and one of V4L2_VP9_SEG_{} as the second dimension. + * @feature_enabled: bitmask defining which features are enabled in each segment. + * The value for each segment is a combination of V4L2_VP9_SEGMENT_FEATURE_ENABLED(id) + * values where id is one of V4L2_VP9_SEG_LVL_{}. + * @tree_probs: specifies the probability values to be used when decoding a + * Segment-ID. See '5.15. Segmentation map' section of the VP9 specification + * for more details. + * @pred_probs: specifies the probability values to be used when decoding a + * Predicted-Segment-ID. See '6.4.14. Get segment id syntax' section of :ref:`vp9` + * for more details. + * @flags: combination of V4L2_VP9_SEGMENTATION_FLAG_{} flags. + * @reserved: padding field. Should be zeroed by applications. + * + * Encodes the quantization parameters. See section '7.2.10 Segmentation params syntax' of + * the VP9 specification for more details. + */ +struct v4l2_vp9_segmentation { +	__s16 feature_data[8][4]; +	__u8 feature_enabled[8]; +	__u8 tree_probs[7]; +	__u8 pred_probs[3]; +	__u8 flags; +	__u8 reserved[5]; +}; + +#define V4L2_VP9_FRAME_FLAG_KEY_FRAME			0x001 +#define V4L2_VP9_FRAME_FLAG_SHOW_FRAME			0x002 +#define V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT		0x004 +#define V4L2_VP9_FRAME_FLAG_INTRA_ONLY			0x008 +#define V4L2_VP9_FRAME_FLAG_ALLOW_HIGH_PREC_MV		0x010 +#define V4L2_VP9_FRAME_FLAG_REFRESH_FRAME_CTX		0x020 +#define V4L2_VP9_FRAME_FLAG_PARALLEL_DEC_MODE		0x040 +#define V4L2_VP9_FRAME_FLAG_X_SUBSAMPLING		0x080 +#define V4L2_VP9_FRAME_FLAG_Y_SUBSAMPLING		0x100 +#define V4L2_VP9_FRAME_FLAG_COLOR_RANGE_FULL_SWING	0x200 + +#define V4L2_VP9_SIGN_BIAS_LAST				0x1 +#define V4L2_VP9_SIGN_BIAS_GOLDEN			0x2 +#define V4L2_VP9_SIGN_BIAS_ALT				0x4 + +#define V4L2_VP9_RESET_FRAME_CTX_NONE			0 +#define V4L2_VP9_RESET_FRAME_CTX_SPEC			1 +#define V4L2_VP9_RESET_FRAME_CTX_ALL			2 + +#define V4L2_VP9_INTERP_FILTER_EIGHTTAP			0 +#define V4L2_VP9_INTERP_FILTER_EIGHTTAP_SMOOTH		1 +#define V4L2_VP9_INTERP_FILTER_EIGHTTAP_SHARP		2 +#define V4L2_VP9_INTERP_FILTER_BILINEAR			3 +#define V4L2_VP9_INTERP_FILTER_SWITCHABLE		4 + +#define V4L2_VP9_REFERENCE_MODE_SINGLE_REFERENCE	0 +#define V4L2_VP9_REFERENCE_MODE_COMPOUND_REFERENCE	1 +#define V4L2_VP9_REFERENCE_MODE_SELECT			2 + +#define V4L2_VP9_PROFILE_MAX				3 + +#define V4L2_CID_STATELESS_VP9_FRAME	(V4L2_CID_CODEC_STATELESS_BASE + 300) +/** + * struct v4l2_ctrl_vp9_frame - VP9 frame decoding control + * + * @lf: loop filter parameters. See &v4l2_vp9_loop_filter for more details. + * @quant: quantization parameters. See &v4l2_vp9_quantization for more details. + * @seg: segmentation parameters. See &v4l2_vp9_segmentation for more details. + * @flags: combination of V4L2_VP9_FRAME_FLAG_{} flags. + * @compressed_header_size: compressed header size in bytes. + * @uncompressed_header_size: uncompressed header size in bytes. + * @frame_width_minus_1: add 1 to it and you'll get the frame width expressed in pixels. + * @frame_height_minus_1: add 1 to it and you'll get the frame height expressed in pixels. + * @render_width_minus_1: add 1 to it and you'll get the expected render width expressed in + * pixels. This is not used during the decoding process but might be used by HW scalers + * to prepare a frame that's ready for scanout. + * @render_height_minus_1: add 1 to it and you'll get the expected render height expressed in + * pixels. This is not used during the decoding process but might be used by HW scalers + * to prepare a frame that's ready for scanout. + * @last_frame_ts: "last" reference buffer timestamp. + * The timestamp refers to the timestamp field in struct v4l2_buffer. + * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64. + * @golden_frame_ts: "golden" reference buffer timestamp. + * The timestamp refers to the timestamp field in struct v4l2_buffer. + * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64. + * @alt_frame_ts: "alt" reference buffer timestamp. + * The timestamp refers to the timestamp field in struct v4l2_buffer. + * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64. + * @ref_frame_sign_bias: a bitfield specifying whether the sign bias is set for a given + * reference frame. Either of V4L2_VP9_SIGN_BIAS_{}. + * @reset_frame_context: specifies whether the frame context should be reset to default values. + * Either of V4L2_VP9_RESET_FRAME_CTX_{}. + * @frame_context_idx: frame context that should be used/updated. + * @profile: VP9 profile. Can be 0, 1, 2 or 3. + * @bit_depth: bits per components. Can be 8, 10 or 12. Note that not all profiles support + * 10 and/or 12 bits depths. + * @interpolation_filter: specifies the filter selection used for performing inter prediction. + * Set to one of V4L2_VP9_INTERP_FILTER_{}. + * @tile_cols_log2: specifies the base 2 logarithm of the width of each tile (where the width + * is measured in units of 8x8 blocks). Shall be less than or equal to 6. + * @tile_rows_log2: specifies the base 2 logarithm of the height of each tile (where the height + * is measured in units of 8x8 blocks). + * @reference_mode: specifies the type of inter prediction to be used. + * Set to one of V4L2_VP9_REFERENCE_MODE_{}. + * @reserved: padding field. Should be zeroed by applications. + */ +struct v4l2_ctrl_vp9_frame { +	struct v4l2_vp9_loop_filter lf; +	struct v4l2_vp9_quantization quant; +	struct v4l2_vp9_segmentation seg; +	__u32 flags; +	__u16 compressed_header_size; +	__u16 uncompressed_header_size; +	__u16 frame_width_minus_1; +	__u16 frame_height_minus_1; +	__u16 render_width_minus_1; +	__u16 render_height_minus_1; +	__u64 last_frame_ts; +	__u64 golden_frame_ts; +	__u64 alt_frame_ts; +	__u8 ref_frame_sign_bias; +	__u8 reset_frame_context; +	__u8 frame_context_idx; +	__u8 profile; +	__u8 bit_depth; +	__u8 interpolation_filter; +	__u8 tile_cols_log2; +	__u8 tile_rows_log2; +	__u8 reference_mode; +	__u8 reserved[7]; +}; + +#define V4L2_VP9_NUM_FRAME_CTX	4 + +/** + * struct v4l2_vp9_mv_probs - VP9 Motion vector probability updates + * @joint: motion vector joint probability updates. + * @sign: motion vector sign probability updates. + * @classes: motion vector class probability updates. + * @class0_bit: motion vector class0 bit probability updates. + * @bits: motion vector bits probability updates. + * @class0_fr: motion vector class0 fractional bit probability updates. + * @fr: motion vector fractional bit probability updates. + * @class0_hp: motion vector class0 high precision fractional bit probability updates. + * @hp: motion vector high precision fractional bit probability updates. + * + * This structure contains new values of motion vector probabilities. + * A value of zero in an array element means there is no update of the relevant probability. + * See `struct v4l2_vp9_prob_updates` for details. + */ +struct v4l2_vp9_mv_probs { +	__u8 joint[3]; +	__u8 sign[2]; +	__u8 classes[2][10]; +	__u8 class0_bit[2]; +	__u8 bits[2][10]; +	__u8 class0_fr[2][2][3]; +	__u8 fr[2][3]; +	__u8 class0_hp[2]; +	__u8 hp[2]; +}; + +#define V4L2_CID_STATELESS_VP9_COMPRESSED_HDR	(V4L2_CID_CODEC_STATELESS_BASE + 301) + +#define V4L2_VP9_TX_MODE_ONLY_4X4			0 +#define V4L2_VP9_TX_MODE_ALLOW_8X8			1 +#define V4L2_VP9_TX_MODE_ALLOW_16X16			2 +#define V4L2_VP9_TX_MODE_ALLOW_32X32			3 +#define V4L2_VP9_TX_MODE_SELECT				4 + +/** + * struct v4l2_ctrl_vp9_compressed_hdr - VP9 probability updates control + * @tx_mode: specifies the TX mode. Set to one of V4L2_VP9_TX_MODE_{}. + * @tx8: TX 8x8 probability updates. + * @tx16: TX 16x16 probability updates. + * @tx32: TX 32x32 probability updates. + * @coef: coefficient probability updates. + * @skip: skip probability updates. + * @inter_mode: inter mode probability updates. + * @interp_filter: interpolation filter probability updates. + * @is_inter: is inter-block probability updates. + * @comp_mode: compound prediction mode probability updates. + * @single_ref: single ref probability updates. + * @comp_ref: compound ref probability updates. + * @y_mode: Y prediction mode probability updates. + * @uv_mode: UV prediction mode probability updates. + * @partition: partition probability updates. + * @mv: motion vector probability updates. + * + * This structure holds the probabilities update as parsed in the compressed + * header (Spec 6.3). These values represent the value of probability update after + * being translated with inv_map_table[] (see 6.3.5). A value of zero in an array element + * means that there is no update of the relevant probability. + * + * This control is optional and needs to be used when dealing with the hardware which is + * not capable of parsing the compressed header itself. Only drivers which need it will + * implement it. + */ +struct v4l2_ctrl_vp9_compressed_hdr { +	__u8 tx_mode; +	__u8 tx8[2][1]; +	__u8 tx16[2][2]; +	__u8 tx32[2][3]; +	__u8 coef[4][2][2][6][6][3]; +	__u8 skip[3]; +	__u8 inter_mode[7][3]; +	__u8 interp_filter[4][2]; +	__u8 is_inter[4]; +	__u8 comp_mode[5]; +	__u8 single_ref[5][2]; +	__u8 comp_ref[5]; +	__u8 y_mode[4][9]; +	__u8 uv_mode[10][9]; +	__u8 partition[16][3]; + +	struct v4l2_vp9_mv_probs mv; +}; + +/* Stateless AV1 controls */ + +#define V4L2_AV1_TOTAL_REFS_PER_FRAME	8 +#define V4L2_AV1_CDEF_MAX		8 +#define V4L2_AV1_NUM_PLANES_MAX		3 /* 1 if monochrome, 3 otherwise */ +#define V4L2_AV1_MAX_SEGMENTS		8 +#define V4L2_AV1_MAX_OPERATING_POINTS	(1 << 5) /* 5 bits to encode */ +#define V4L2_AV1_REFS_PER_FRAME		7 +#define V4L2_AV1_MAX_NUM_Y_POINTS	(1 << 4) /* 4 bits to encode */ +#define V4L2_AV1_MAX_NUM_CB_POINTS	(1 << 4) /* 4 bits to encode */ +#define V4L2_AV1_MAX_NUM_CR_POINTS	(1 << 4) /* 4 bits to encode */ +#define V4L2_AV1_AR_COEFFS_SIZE		25 /* (2 * 3 * (3 + 1)) + 1 */ +#define V4L2_AV1_MAX_NUM_PLANES		3 +#define V4L2_AV1_MAX_TILE_COLS		64 +#define V4L2_AV1_MAX_TILE_ROWS		64 +#define V4L2_AV1_MAX_TILE_COUNT		512 + +#define V4L2_AV1_SEQUENCE_FLAG_STILL_PICTURE		  0x00000001 +#define V4L2_AV1_SEQUENCE_FLAG_USE_128X128_SUPERBLOCK	  0x00000002 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_FILTER_INTRA	  0x00000004 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_INTRA_EDGE_FILTER   0x00000008 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_INTERINTRA_COMPOUND 0x00000010 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_MASKED_COMPOUND	  0x00000020 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_WARPED_MOTION	  0x00000040 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_DUAL_FILTER	  0x00000080 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_ORDER_HINT	  0x00000100 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_JNT_COMP		  0x00000200 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_REF_FRAME_MVS	  0x00000400 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_SUPERRES		  0x00000800 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_CDEF		  0x00001000 +#define V4L2_AV1_SEQUENCE_FLAG_ENABLE_RESTORATION	  0x00002000 +#define V4L2_AV1_SEQUENCE_FLAG_MONO_CHROME		  0x00004000 +#define V4L2_AV1_SEQUENCE_FLAG_COLOR_RANGE		  0x00008000 +#define V4L2_AV1_SEQUENCE_FLAG_SUBSAMPLING_X		  0x00010000 +#define V4L2_AV1_SEQUENCE_FLAG_SUBSAMPLING_Y		  0x00020000 +#define V4L2_AV1_SEQUENCE_FLAG_FILM_GRAIN_PARAMS_PRESENT  0x00040000 +#define V4L2_AV1_SEQUENCE_FLAG_SEPARATE_UV_DELTA_Q	  0x00080000 + +#define V4L2_CID_STATELESS_AV1_SEQUENCE (V4L2_CID_CODEC_STATELESS_BASE + 500) +/** + * struct v4l2_ctrl_av1_sequence - AV1 Sequence + * + * Represents an AV1 Sequence OBU. See section 5.5 "Sequence header OBU syntax" + * for more details. + * + * @flags: See V4L2_AV1_SEQUENCE_FLAG_{}. + * @seq_profile: specifies the features that can be used in the coded video + * sequence. + * @order_hint_bits: specifies the number of bits used for the order_hint field + * at each frame. + * @bit_depth: the bitdepth to use for the sequence as described in section + * 5.5.2 "Color config syntax". + * @reserved: padding field. Should be zeroed by applications. + * @max_frame_width_minus_1: specifies the maximum frame width minus 1 for the + * frames represented by this sequence header. + * @max_frame_height_minus_1: specifies the maximum frame height minus 1 for the + * frames represented by this sequence header. + */ +struct v4l2_ctrl_av1_sequence { +	__u32 flags; +	__u8 seq_profile; +	__u8 order_hint_bits; +	__u8 bit_depth; +	__u8 reserved; +	__u16 max_frame_width_minus_1; +	__u16 max_frame_height_minus_1; +}; + +#define V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY (V4L2_CID_CODEC_STATELESS_BASE + 501) +/** + * struct v4l2_ctrl_av1_tile_group_entry - AV1 Tile Group entry + * + * Represents a single AV1 tile inside an AV1 Tile Group. Note that MiRowStart, + * MiRowEnd, MiColStart and MiColEnd can be retrieved from struct + * v4l2_av1_tile_info in struct v4l2_ctrl_av1_frame using tile_row and + * tile_col. See section 6.10.1 "General tile group OBU semantics" for more + * details. + * + * @tile_offset: offset from the OBU data, i.e. where the coded tile data + * actually starts. + * @tile_size: specifies the size in bytes of the coded tile. Equivalent to + * "TileSize" in the AV1 Specification. + * @tile_row: specifies the row of the current tile. Equivalent to "TileRow" in + * the AV1 Specification. + * @tile_col: specifies the col of the current tile. Equivalent to "TileCol" in + * the AV1 Specification. + */ +struct v4l2_ctrl_av1_tile_group_entry { +	__u32 tile_offset; +	__u32 tile_size; +	__u32 tile_row; +	__u32 tile_col; +}; + +/** + * enum v4l2_av1_warp_model - AV1 Warp Model as described in section 3 + * "Symbols and abbreviated terms" of the AV1 Specification. + * + * @V4L2_AV1_WARP_MODEL_IDENTITY: Warp model is just an identity transform. + * @V4L2_AV1_WARP_MODEL_TRANSLATION: Warp model is a pure translation. + * @V4L2_AV1_WARP_MODEL_ROTZOOM: Warp model is a rotation + symmetric zoom + + * translation. + * @V4L2_AV1_WARP_MODEL_AFFINE: Warp model is a general affine transform. + */ +enum v4l2_av1_warp_model { +	V4L2_AV1_WARP_MODEL_IDENTITY = 0, +	V4L2_AV1_WARP_MODEL_TRANSLATION = 1, +	V4L2_AV1_WARP_MODEL_ROTZOOM = 2, +	V4L2_AV1_WARP_MODEL_AFFINE = 3, +}; + +/** + * enum v4l2_av1_reference_frame - AV1 reference frames + * + * @V4L2_AV1_REF_INTRA_FRAME: Intra Frame Reference + * @V4L2_AV1_REF_LAST_FRAME: Last Reference Frame + * @V4L2_AV1_REF_LAST2_FRAME: Last2 Reference Frame + * @V4L2_AV1_REF_LAST3_FRAME: Last3 Reference Frame + * @V4L2_AV1_REF_GOLDEN_FRAME: Golden Reference Frame + * @V4L2_AV1_REF_BWDREF_FRAME: BWD Reference Frame + * @V4L2_AV1_REF_ALTREF2_FRAME: Alternative2 Reference Frame + * @V4L2_AV1_REF_ALTREF_FRAME: Alternative Reference Frame + */ +enum v4l2_av1_reference_frame { +	V4L2_AV1_REF_INTRA_FRAME = 0, +	V4L2_AV1_REF_LAST_FRAME = 1, +	V4L2_AV1_REF_LAST2_FRAME = 2, +	V4L2_AV1_REF_LAST3_FRAME = 3, +	V4L2_AV1_REF_GOLDEN_FRAME = 4, +	V4L2_AV1_REF_BWDREF_FRAME = 5, +	V4L2_AV1_REF_ALTREF2_FRAME = 6, +	V4L2_AV1_REF_ALTREF_FRAME = 7, +}; + +#define V4L2_AV1_GLOBAL_MOTION_IS_INVALID(ref) (1 << (ref)) + +#define V4L2_AV1_GLOBAL_MOTION_FLAG_IS_GLOBAL	   0x1 +#define V4L2_AV1_GLOBAL_MOTION_FLAG_IS_ROT_ZOOM	   0x2 +#define V4L2_AV1_GLOBAL_MOTION_FLAG_IS_TRANSLATION 0x4 +/** + * struct v4l2_av1_global_motion - AV1 Global Motion parameters as described in + * section 6.8.17 "Global motion params semantics" of the AV1 specification. + * + * @flags: A bitfield containing the flags per reference frame. See + * V4L2_AV1_GLOBAL_MOTION_FLAG_{} + * @type: The type of global motion transform used. + * @params: this field has the same meaning as "gm_params" in the AV1 + * specification. + * @invalid: bitfield indicating whether the global motion params are invalid + * for a given reference frame. See section 7.11.3.6 Setup shear process and + * the variable "warpValid". Use V4L2_AV1_GLOBAL_MOTION_IS_INVALID(ref) to + * create a suitable mask. + * @reserved: padding field. Should be zeroed by applications. + */ + +struct v4l2_av1_global_motion { +	__u8 flags[V4L2_AV1_TOTAL_REFS_PER_FRAME]; +	enum v4l2_av1_warp_model type[V4L2_AV1_TOTAL_REFS_PER_FRAME]; +	__s32 params[V4L2_AV1_TOTAL_REFS_PER_FRAME][6]; +	__u8 invalid; +	__u8 reserved[3]; +}; + +/** + * enum v4l2_av1_frame_restoration_type - AV1 Frame Restoration Type + * @V4L2_AV1_FRAME_RESTORE_NONE: no filtering is applied. + * @V4L2_AV1_FRAME_RESTORE_WIENER: Wiener filter process is invoked. + * @V4L2_AV1_FRAME_RESTORE_SGRPROJ: self guided filter process is invoked. + * @V4L2_AV1_FRAME_RESTORE_SWITCHABLE: restoration filter is swichtable. + */ +enum v4l2_av1_frame_restoration_type { +	V4L2_AV1_FRAME_RESTORE_NONE = 0, +	V4L2_AV1_FRAME_RESTORE_WIENER = 1, +	V4L2_AV1_FRAME_RESTORE_SGRPROJ = 2, +	V4L2_AV1_FRAME_RESTORE_SWITCHABLE = 3, +}; + +#define V4L2_AV1_LOOP_RESTORATION_FLAG_USES_LR		0x1 +#define V4L2_AV1_LOOP_RESTORATION_FLAG_USES_CHROMA_LR	0x2 + +/** + * struct v4l2_av1_loop_restoration - AV1 Loop Restauration as described in + * section 6.10.15 "Loop restoration params semantics" of the AV1 specification. + * + * @flags: See V4L2_AV1_LOOP_RESTORATION_FLAG_{}. + * @lr_unit_shift: specifies if the luma restoration size should be halved. + * @lr_uv_shift: specifies if the chroma size should be half the luma size. + * @reserved: padding field. Should be zeroed by applications. + * @frame_restoration_type: specifies the type of restoration used for each + * plane. See enum v4l2_av1_frame_restoration_type. + * @loop_restoration_size: specifies the size of loop restoration units in units + * of samples in the current plane. + */ +struct v4l2_av1_loop_restoration { +	__u8 flags; +	__u8 lr_unit_shift; +	__u8 lr_uv_shift; +	__u8 reserved; +	enum v4l2_av1_frame_restoration_type frame_restoration_type[V4L2_AV1_NUM_PLANES_MAX]; +	__u32 loop_restoration_size[V4L2_AV1_MAX_NUM_PLANES]; +}; + +/** + * struct v4l2_av1_cdef - AV1 CDEF params semantics as described in section + * 6.10.14 "CDEF params semantics" of the AV1 specification + * + * @damping_minus_3: controls the amount of damping in the deringing filter. + * @bits: specifies the number of bits needed to specify which CDEF filter to + * apply. + * @y_pri_strength: specifies the strength of the primary filter. + * @y_sec_strength: specifies the strength of the secondary filter. + * @uv_pri_strength: specifies the strength of the primary filter. + * @uv_sec_strength: specifies the strength of the secondary filter. + */ +struct v4l2_av1_cdef { +	__u8 damping_minus_3; +	__u8 bits; +	__u8 y_pri_strength[V4L2_AV1_CDEF_MAX]; +	__u8 y_sec_strength[V4L2_AV1_CDEF_MAX]; +	__u8 uv_pri_strength[V4L2_AV1_CDEF_MAX]; +	__u8 uv_sec_strength[V4L2_AV1_CDEF_MAX]; +}; + +#define V4L2_AV1_SEGMENTATION_FLAG_ENABLED	   0x1 +#define V4L2_AV1_SEGMENTATION_FLAG_UPDATE_MAP	   0x2 +#define V4L2_AV1_SEGMENTATION_FLAG_TEMPORAL_UPDATE 0x4 +#define V4L2_AV1_SEGMENTATION_FLAG_UPDATE_DATA	   0x8 +#define V4L2_AV1_SEGMENTATION_FLAG_SEG_ID_PRE_SKIP 0x10 + +/** + * enum v4l2_av1_segment_feature - AV1 segment features as described in section + * 3 "Symbols and abbreviated terms" of the AV1 specification. + * + * @V4L2_AV1_SEG_LVL_ALT_Q: Index for quantizer segment feature. + * @V4L2_AV1_SEG_LVL_ALT_LF_Y_V: Index for vertical luma loop filter segment + * feature. + * @V4L2_AV1_SEG_LVL_REF_FRAME: Index for reference frame segment feature. + * @V4L2_AV1_SEG_LVL_REF_SKIP: Index for skip segment feature. + * @V4L2_AV1_SEG_LVL_REF_GLOBALMV: Index for global mv feature. + * @V4L2_AV1_SEG_LVL_MAX: Number of segment features. + */ +enum v4l2_av1_segment_feature { +	V4L2_AV1_SEG_LVL_ALT_Q = 0, +	V4L2_AV1_SEG_LVL_ALT_LF_Y_V = 1, +	V4L2_AV1_SEG_LVL_REF_FRAME = 5, +	V4L2_AV1_SEG_LVL_REF_SKIP = 6, +	V4L2_AV1_SEG_LVL_REF_GLOBALMV = 7, +	V4L2_AV1_SEG_LVL_MAX = 8 +}; + +#define V4L2_AV1_SEGMENT_FEATURE_ENABLED(id)	(1 << (id)) + +/** + * struct v4l2_av1_segmentation - AV1 Segmentation params as defined in section + * 6.8.13 "Segmentation params semantics" of the AV1 specification. + * + * @flags: see V4L2_AV1_SEGMENTATION_FLAG_{}. + * @last_active_seg_id: indicates the highest numbered segment id that has some + * enabled feature. This is used when decoding the segment id to only decode + * choices corresponding to used segments. + * @feature_enabled: bitmask defining which features are enabled in each + * segment. Use V4L2_AV1_SEGMENT_FEATURE_ENABLED to build a suitable mask. + * @feature_data: data attached to each feature. Data entry is only valid if the + * feature is enabled + */ +struct v4l2_av1_segmentation { +	__u8 flags; +	__u8 last_active_seg_id; +	__u8 feature_enabled[V4L2_AV1_MAX_SEGMENTS]; +	__s16 feature_data[V4L2_AV1_MAX_SEGMENTS][V4L2_AV1_SEG_LVL_MAX]; +}; + +#define V4L2_AV1_LOOP_FILTER_FLAG_DELTA_ENABLED    0x1 +#define V4L2_AV1_LOOP_FILTER_FLAG_DELTA_UPDATE     0x2 +#define V4L2_AV1_LOOP_FILTER_FLAG_DELTA_LF_PRESENT 0x4 +#define V4L2_AV1_LOOP_FILTER_FLAG_DELTA_LF_MULTI   0x8 + +/** + * struct v4l2_av1_loop_filter - AV1 Loop filter params as defined in section + * 6.8.10 "Loop filter semantics" and 6.8.16 "Loop filter delta parameters + * semantics" of the AV1 specification. + * + * @flags: see V4L2_AV1_LOOP_FILTER_FLAG_{} + * @level: an array containing loop filter strength values. Different loop + * filter strength values from the array are used depending on the image plane + * being filtered, and the edge direction (vertical or horizontal) being + * filtered. + * @sharpness: indicates the sharpness level. The loop_filter_level and + * loop_filter_sharpness together determine when a block edge is filtered, and + * by how much the filtering can change the sample values. The loop filter + * process is described in section 7.14 of the AV1 specification. + * @ref_deltas: contains the adjustment needed for the filter level based on the + * chosen reference frame. If this syntax element is not present, it maintains + * its previous value. + * @mode_deltas: contains the adjustment needed for the filter level based on + * the chosen mode. If this syntax element is not present, it maintains its + * previous value. + * @delta_lf_res: specifies the left shift which should be applied to decoded + * loop filter delta values. + */ +struct v4l2_av1_loop_filter { +	__u8 flags; +	__u8 level[4]; +	__u8 sharpness; +	__s8 ref_deltas[V4L2_AV1_TOTAL_REFS_PER_FRAME]; +	__s8 mode_deltas[2]; +	__u8 delta_lf_res; +}; + +#define V4L2_AV1_QUANTIZATION_FLAG_DIFF_UV_DELTA   0x1 +#define V4L2_AV1_QUANTIZATION_FLAG_USING_QMATRIX   0x2 +#define V4L2_AV1_QUANTIZATION_FLAG_DELTA_Q_PRESENT 0x4 + +/** + * struct v4l2_av1_quantization - AV1 Quantization params as defined in section + * 6.8.11 "Quantization params semantics" of the AV1 specification. + * + * @flags: see V4L2_AV1_QUANTIZATION_FLAG_{} + * @base_q_idx: indicates the base frame qindex. This is used for Y AC + * coefficients and as the base value for the other quantizers. + * @delta_q_y_dc: indicates the Y DC quantizer relative to base_q_idx. + * @delta_q_u_dc: indicates the U DC quantizer relative to base_q_idx. + * @delta_q_u_ac: indicates the U AC quantizer relative to base_q_idx. + * @delta_q_v_dc: indicates the V DC quantizer relative to base_q_idx. + * @delta_q_v_ac: indicates the V AC quantizer relative to base_q_idx. + * @qm_y: specifies the level in the quantizer matrix that should be used for + * luma plane decoding. + * @qm_u: specifies the level in the quantizer matrix that should be used for + * chroma U plane decoding. + * @qm_v: specifies the level in the quantizer matrix that should be used for + * chroma V plane decoding. + * @delta_q_res: specifies the left shift which should be applied to decoded + * quantizer index delta values. + */ +struct v4l2_av1_quantization { +	__u8 flags; +	__u8 base_q_idx; +	__s8 delta_q_y_dc; +	__s8 delta_q_u_dc; +	__s8 delta_q_u_ac; +	__s8 delta_q_v_dc; +	__s8 delta_q_v_ac; +	__u8 qm_y; +	__u8 qm_u; +	__u8 qm_v; +	__u8 delta_q_res; +}; + +#define V4L2_AV1_TILE_INFO_FLAG_UNIFORM_TILE_SPACING	0x1 + +/** + * struct v4l2_av1_tile_info - AV1 Tile info as defined in section 6.8.14 "Tile + * info semantics" of the AV1 specification. + * + * @flags: see V4L2_AV1_TILE_INFO_FLAG_{} + * @context_update_tile_id: specifies which tile to use for the CDF update. + * @tile_rows: specifies the number of tiles down the frame. + * @tile_cols: specifies the number of tiles across the frame. + * @mi_col_starts: an array specifying the start column (in units of 4x4 luma + * samples) for each tile across the image. + * @mi_row_starts: an array specifying the start row (in units of 4x4 luma + * samples) for each tile down the image. + * @width_in_sbs_minus_1: specifies the width of a tile minus 1 in units of + * superblocks. + * @height_in_sbs_minus_1:  specifies the height of a tile minus 1 in units of + * superblocks. + * @tile_size_bytes: specifies the number of bytes needed to code each tile + * size. + * @reserved: padding field. Should be zeroed by applications. + */ +struct v4l2_av1_tile_info { +	__u8 flags; +	__u8 context_update_tile_id; +	__u8 tile_cols; +	__u8 tile_rows; +	__u32 mi_col_starts[V4L2_AV1_MAX_TILE_COLS + 1]; +	__u32 mi_row_starts[V4L2_AV1_MAX_TILE_ROWS + 1]; +	__u32 width_in_sbs_minus_1[V4L2_AV1_MAX_TILE_COLS]; +	__u32 height_in_sbs_minus_1[V4L2_AV1_MAX_TILE_ROWS]; +	__u8 tile_size_bytes; +	__u8 reserved[3]; +}; + +/** + * enum v4l2_av1_frame_type - AV1 Frame Type + * + * @V4L2_AV1_KEY_FRAME: Key frame + * @V4L2_AV1_INTER_FRAME: Inter frame + * @V4L2_AV1_INTRA_ONLY_FRAME: Intra-only frame + * @V4L2_AV1_SWITCH_FRAME: Switch frame + */ +enum v4l2_av1_frame_type { +	V4L2_AV1_KEY_FRAME = 0, +	V4L2_AV1_INTER_FRAME = 1, +	V4L2_AV1_INTRA_ONLY_FRAME = 2, +	V4L2_AV1_SWITCH_FRAME = 3 +}; + +/** + * enum v4l2_av1_interpolation_filter - AV1 interpolation filter types + * + * @V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP: eight tap filter + * @V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP_SMOOTH: eight tap smooth filter + * @V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP_SHARP: eight tap sharp filter + * @V4L2_AV1_INTERPOLATION_FILTER_BILINEAR: bilinear filter + * @V4L2_AV1_INTERPOLATION_FILTER_SWITCHABLE: filter selection is signaled at + * the block level + * + * See section 6.8.9 "Interpolation filter semantics" of the AV1 specification + * for more details. + */ +enum v4l2_av1_interpolation_filter { +	V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP = 0, +	V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP_SMOOTH = 1, +	V4L2_AV1_INTERPOLATION_FILTER_EIGHTTAP_SHARP = 2, +	V4L2_AV1_INTERPOLATION_FILTER_BILINEAR = 3, +	V4L2_AV1_INTERPOLATION_FILTER_SWITCHABLE = 4, +}; + +/** + * enum v4l2_av1_tx_mode - AV1 Tx mode as described in section 6.8.21 "TX mode + * semantics" of the AV1 specification. + * @V4L2_AV1_TX_MODE_ONLY_4X4: the inverse transform will use only 4x4 + * transforms + * @V4L2_AV1_TX_MODE_LARGEST: the inverse transform will use the largest + * transform size that fits inside the block + * @V4L2_AV1_TX_MODE_SELECT: the choice of transform size is specified + * explicitly for each block. + */ +enum v4l2_av1_tx_mode { +	V4L2_AV1_TX_MODE_ONLY_4X4 = 0, +	V4L2_AV1_TX_MODE_LARGEST = 1, +	V4L2_AV1_TX_MODE_SELECT = 2 +}; + +#define V4L2_AV1_FRAME_FLAG_SHOW_FRAME			 0x00000001 +#define V4L2_AV1_FRAME_FLAG_SHOWABLE_FRAME		 0x00000002 +#define V4L2_AV1_FRAME_FLAG_ERROR_RESILIENT_MODE	 0x00000004 +#define V4L2_AV1_FRAME_FLAG_DISABLE_CDF_UPDATE		 0x00000008 +#define V4L2_AV1_FRAME_FLAG_ALLOW_SCREEN_CONTENT_TOOLS	 0x00000010 +#define V4L2_AV1_FRAME_FLAG_FORCE_INTEGER_MV		 0x00000020 +#define V4L2_AV1_FRAME_FLAG_ALLOW_INTRABC		 0x00000040 +#define V4L2_AV1_FRAME_FLAG_USE_SUPERRES		 0x00000080 +#define V4L2_AV1_FRAME_FLAG_ALLOW_HIGH_PRECISION_MV	 0x00000100 +#define V4L2_AV1_FRAME_FLAG_IS_MOTION_MODE_SWITCHABLE	 0x00000200 +#define V4L2_AV1_FRAME_FLAG_USE_REF_FRAME_MVS		 0x00000400 +#define V4L2_AV1_FRAME_FLAG_DISABLE_FRAME_END_UPDATE_CDF 0x00000800 +#define V4L2_AV1_FRAME_FLAG_ALLOW_WARPED_MOTION		 0x00001000 +#define V4L2_AV1_FRAME_FLAG_REFERENCE_SELECT		 0x00002000 +#define V4L2_AV1_FRAME_FLAG_REDUCED_TX_SET		 0x00004000 +#define V4L2_AV1_FRAME_FLAG_SKIP_MODE_ALLOWED		 0x00008000 +#define V4L2_AV1_FRAME_FLAG_SKIP_MODE_PRESENT		 0x00010000 +#define V4L2_AV1_FRAME_FLAG_FRAME_SIZE_OVERRIDE		 0x00020000 +#define V4L2_AV1_FRAME_FLAG_BUFFER_REMOVAL_TIME_PRESENT	 0x00040000 +#define V4L2_AV1_FRAME_FLAG_FRAME_REFS_SHORT_SIGNALING	 0x00080000 + +#define V4L2_CID_STATELESS_AV1_FRAME (V4L2_CID_CODEC_STATELESS_BASE + 502) +/** + * struct v4l2_ctrl_av1_frame - Represents an AV1 Frame Header OBU. + * + * @tile_info: tile info + * @quantization: quantization params + * @segmentation: segmentation params + * @superres_denom: the denominator for the upscaling ratio. + * @loop_filter: loop filter params + * @cdef: cdef params + * @skip_mode_frame: specifies the frames to use for compound prediction when + * skip_mode is equal to 1. + * @primary_ref_frame: specifies which reference frame contains the CDF values + * and other state that should be loaded at the start of the frame. + * @loop_restoration: loop restoration params + * @global_motion: global motion params + * @flags: see V4L2_AV1_FRAME_FLAG_{} + * @frame_type: specifies the AV1 frame type + * @order_hint: specifies OrderHintBits least significant bits of the expected + * output order for this frame. + * @upscaled_width: the upscaled width. + * @interpolation_filter: specifies the filter selection used for performing + * inter prediction. + * @tx_mode: specifies how the transform size is determined. + * @frame_width_minus_1: add 1 to get the frame's width. + * @frame_height_minus_1: add 1 to get the frame's height + * @render_width_minus_1: add 1 to get the render width of the frame in luma + * samples. + * @render_height_minus_1: add 1 to get the render height of the frame in luma + * samples. + * @current_frame_id: specifies the frame id number for the current frame. Frame + * id numbers are additional information that do not affect the decoding + * process, but provide decoders with a way of detecting missing reference + * frames so that appropriate action can be taken. + * @buffer_removal_time: specifies the frame removal time in units of DecCT clock + * ticks counted from the removal time of the last random access point for + * operating point opNum. + * @reserved: padding field. Should be zeroed by applications. + * @order_hints: specifies the expected output order hint for each reference + * frame. This field corresponds to the OrderHints variable from the + * specification (section 5.9.2 "Uncompressed header syntax"). As such, this is + * only used for non-intra frames and ignored otherwise. order_hints[0] is + * always ignored. + * @reference_frame_ts: the V4L2 timestamp of the reference frame slots. + * @ref_frame_idx: used to index into @reference_frame_ts when decoding + * inter-frames. The meaning of this array is the same as in the specification. + * The timestamp refers to the timestamp field in struct v4l2_buffer. Use + * v4l2_timeval_to_ns() to convert the struct timeval to a __u64. + * @refresh_frame_flags: contains a bitmask that specifies which reference frame + * slots will be updated with the current frame after it is decoded. + */ +struct v4l2_ctrl_av1_frame { +	struct v4l2_av1_tile_info tile_info; +	struct v4l2_av1_quantization quantization; +	__u8 superres_denom; +	struct v4l2_av1_segmentation segmentation; +	struct v4l2_av1_loop_filter loop_filter; +	struct v4l2_av1_cdef cdef; +	__u8 skip_mode_frame[2]; +	__u8 primary_ref_frame; +	struct v4l2_av1_loop_restoration loop_restoration; +	struct v4l2_av1_global_motion global_motion; +	__u32 flags; +	enum v4l2_av1_frame_type frame_type; +	__u32 order_hint; +	__u32 upscaled_width; +	enum v4l2_av1_interpolation_filter interpolation_filter; +	enum v4l2_av1_tx_mode tx_mode; +	__u32 frame_width_minus_1; +	__u32 frame_height_minus_1; +	__u16 render_width_minus_1; +	__u16 render_height_minus_1; + +	__u32 current_frame_id; +	__u32 buffer_removal_time[V4L2_AV1_MAX_OPERATING_POINTS]; +	__u8 reserved[4]; +	__u32 order_hints[V4L2_AV1_TOTAL_REFS_PER_FRAME]; +	__u64 reference_frame_ts[V4L2_AV1_TOTAL_REFS_PER_FRAME]; +	__s8 ref_frame_idx[V4L2_AV1_REFS_PER_FRAME]; +	__u8 refresh_frame_flags; +}; + +#define V4L2_AV1_FILM_GRAIN_FLAG_APPLY_GRAIN 0x1 +#define V4L2_AV1_FILM_GRAIN_FLAG_UPDATE_GRAIN 0x2 +#define V4L2_AV1_FILM_GRAIN_FLAG_CHROMA_SCALING_FROM_LUMA 0x4 +#define V4L2_AV1_FILM_GRAIN_FLAG_OVERLAP 0x8 +#define V4L2_AV1_FILM_GRAIN_FLAG_CLIP_TO_RESTRICTED_RANGE 0x10 + +#define V4L2_CID_STATELESS_AV1_FILM_GRAIN (V4L2_CID_CODEC_STATELESS_BASE + 505) +/** + * struct v4l2_ctrl_av1_film_grain - AV1 Film Grain parameters. + * + * Film grain parameters as specified by section 6.8.20 of the AV1 Specification. + * + * @flags: see V4L2_AV1_FILM_GRAIN_{}. + * @cr_mult: represents a multiplier for the cr component used in derivation of + * the input index to the cr component scaling function. + * @grain_seed: specifies the starting value for the pseudo-random numbers used + * during film grain synthesis. + * @film_grain_params_ref_idx: indicates which reference frame contains the + * film grain parameters to be used for this frame. + * @num_y_points: specifies the number of points for the piece-wise linear + * scaling function of the luma component. + * @point_y_value: represents the x (luma value) coordinate for the i-th point + * of the piecewise linear scaling function for luma component. The values are + * signaled on the scale of 0..255. In case of 10 bit video, these values + * correspond to luma values divided by 4. In case of 12 bit video, these values + * correspond to luma values divided by 16. + * @point_y_scaling:  represents the scaling (output) value for the i-th point + * of the piecewise linear scaling function for luma component. + * @num_cb_points: specifies the number of points for the piece-wise linear + * scaling function of the cb component. + * @point_cb_value: represents the x coordinate for the i-th point of the + * piece-wise linear scaling function for cb component. The values are signaled + * on the scale of 0..255. + * @point_cb_scaling: represents the scaling (output) value for the i-th point + * of the piecewise linear scaling function for cb component. + * @num_cr_points: specifies represents the number of points for the piece-wise + * linear scaling function of the cr component. + * @point_cr_value:  represents the x coordinate for the i-th point of the + * piece-wise linear scaling function for cr component. The values are signaled + * on the scale of 0..255. + * @point_cr_scaling:  represents the scaling (output) value for the i-th point + * of the piecewise linear scaling function for cr component. + * @grain_scaling_minus_8: represents the shift – 8 applied to the values of the + * chroma component. The grain_scaling_minus_8 can take values of 0..3 and + * determines the range and quantization step of the standard deviation of film + * grain. + * @ar_coeff_lag: specifies the number of auto-regressive coefficients for luma + * and chroma. + * @ar_coeffs_y_plus_128: specifies auto-regressive coefficients used for the Y + * plane. + * @ar_coeffs_cb_plus_128: specifies auto-regressive coefficients used for the U + * plane. + * @ar_coeffs_cr_plus_128: specifies auto-regressive coefficients used for the V + * plane. + * @ar_coeff_shift_minus_6: specifies the range of the auto-regressive + * coefficients. Values of 0, 1, 2, and 3 correspond to the ranges for + * auto-regressive coefficients of [-2, 2), [-1, 1), [-0.5, 0.5) and [-0.25, + * 0.25) respectively. + * @grain_scale_shift: specifies how much the Gaussian random numbers should be + * scaled down during the grain synthesis process. + * @cb_mult: represents a multiplier for the cb component used in derivation of + * the input index to the cb component scaling function. + * @cb_luma_mult: represents a multiplier for the average luma component used in + * derivation of the input index to the cb component scaling function. + * @cr_luma_mult: represents a multiplier for the average luma component used in + * derivation of the input index to the cr component scaling function. + * @cb_offset: represents an offset used in derivation of the input index to the + * cb component scaling function. + * @cr_offset: represents an offset used in derivation of the input index to the + * cr component scaling function. + * @reserved: padding field. Should be zeroed by applications. + */ +struct v4l2_ctrl_av1_film_grain { +	__u8 flags; +	__u8 cr_mult; +	__u16 grain_seed; +	__u8 film_grain_params_ref_idx; +	__u8 num_y_points; +	__u8 point_y_value[V4L2_AV1_MAX_NUM_Y_POINTS]; +	__u8 point_y_scaling[V4L2_AV1_MAX_NUM_Y_POINTS]; +	__u8 num_cb_points; +	__u8 point_cb_value[V4L2_AV1_MAX_NUM_CB_POINTS]; +	__u8 point_cb_scaling[V4L2_AV1_MAX_NUM_CB_POINTS]; +	__u8 num_cr_points; +	__u8 point_cr_value[V4L2_AV1_MAX_NUM_CR_POINTS]; +	__u8 point_cr_scaling[V4L2_AV1_MAX_NUM_CR_POINTS]; +	__u8 grain_scaling_minus_8; +	__u8 ar_coeff_lag; +	__u8 ar_coeffs_y_plus_128[V4L2_AV1_AR_COEFFS_SIZE]; +	__u8 ar_coeffs_cb_plus_128[V4L2_AV1_AR_COEFFS_SIZE]; +	__u8 ar_coeffs_cr_plus_128[V4L2_AV1_AR_COEFFS_SIZE]; +	__u8 ar_coeff_shift_minus_6; +	__u8 grain_scale_shift; +	__u8 cb_mult; +	__u8 cb_luma_mult; +	__u8 cr_luma_mult; +	__u16 cb_offset; +	__u16 cr_offset; +	__u8 reserved[4]; +}; + +/* MPEG-compression definitions kept for backwards compatibility */ +#ifndef __KERNEL__ +#define V4L2_CTRL_CLASS_MPEG            V4L2_CTRL_CLASS_CODEC +#define V4L2_CID_MPEG_CLASS             V4L2_CID_CODEC_CLASS +#define V4L2_CID_MPEG_BASE              V4L2_CID_CODEC_BASE +#define V4L2_CID_MPEG_CX2341X_BASE      V4L2_CID_CODEC_CX2341X_BASE +#define V4L2_CID_MPEG_MFC51_BASE        V4L2_CID_CODEC_MFC51_BASE +#endif +  #endif diff --git a/include/uapi/linux/v4l2-dv-timings.h b/include/uapi/linux/v4l2-dv-timings.h index b52b67c62562..44a16e0e5a12 100644 --- a/include/uapi/linux/v4l2-dv-timings.h +++ b/include/uapi/linux/v4l2-dv-timings.h @@ -2,16 +2,7 @@  /*   * V4L2 DV timings header.   * - * Copyright (C) 2012-2016  Hans Verkuil <hans.verkuil@cisco.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU - * General Public License for more details. + * Copyright (C) 2012-2016  Hans Verkuil <hansverk@cisco.com>   */  #ifndef _V4L2_DV_TIMINGS_H diff --git a/include/uapi/linux/v4l2-mediabus.h b/include/uapi/linux/v4l2-mediabus.h index 123a231001a8..946520bc49f1 100644 --- a/include/uapi/linux/v4l2-mediabus.h +++ b/include/uapi/linux/v4l2-mediabus.h @@ -3,10 +3,6 @@   * Media Bus API header   *   * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation.   */  #ifndef __LINUX_V4L2_MEDIABUS_H @@ -16,16 +12,27 @@  #include <linux/types.h>  #include <linux/videodev2.h> +#define V4L2_MBUS_FRAMEFMT_SET_CSC	0x0001 +  /**   * struct v4l2_mbus_framefmt - frame format on the media bus   * @width:	image width   * @height:	image height   * @code:	data format code (from enum v4l2_mbus_pixelcode) - * @field:	used interlacing type (from enum v4l2_field) - * @colorspace:	colorspace of the data (from enum v4l2_colorspace) - * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding) - * @quantization: quantization of the data (from enum v4l2_quantization) - * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func) + * @field:	used interlacing type (from enum v4l2_field), zero for metadata + *		mbus codes + * @colorspace:	colorspace of the data (from enum v4l2_colorspace), zero on + *		metadata mbus codes + * @ycbcr_enc:	YCbCr encoding of the data (from enum v4l2_ycbcr_encoding), zero + *		for metadata mbus codes + * @hsv_enc:	HSV encoding of the data (from enum v4l2_hsv_encoding), zero for + *		metadata mbus codes + * @quantization: quantization of the data (from enum v4l2_quantization), zero + *		for metadata mbus codes + * @xfer_func:  transfer function of the data (from enum v4l2_xfer_func), zero + *		for metadata mbus codes + * @flags:	flags (V4L2_MBUS_FRAMEFMT_*) + * @reserved:  reserved bytes that can be later used   */  struct v4l2_mbus_framefmt {  	__u32			width; @@ -33,10 +40,16 @@ struct v4l2_mbus_framefmt {  	__u32			code;  	__u32			field;  	__u32			colorspace; -	__u16			ycbcr_enc; +	union { +		/* enum v4l2_ycbcr_encoding */ +		__u16			ycbcr_enc; +		/* enum v4l2_hsv_encoding */ +		__u16			hsv_enc; +	};  	__u16			quantization;  	__u16			xfer_func; -	__u16			reserved[11]; +	__u16			flags; +	__u16			reserved[10];  };  #ifndef __KERNEL__ diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h index 5d2a1dab7911..2347e266cf75 100644 --- a/include/uapi/linux/v4l2-subdev.h +++ b/include/uapi/linux/v4l2-subdev.h @@ -6,24 +6,12 @@   *   * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>   *	     Sakari Ailus <sakari.ailus@iki.fi> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   */  #ifndef __LINUX_V4L2_SUBDEV_H  #define __LINUX_V4L2_SUBDEV_H +#include <linux/const.h>  #include <linux/ioctl.h>  #include <linux/types.h>  #include <linux/v4l2-common.h> @@ -44,12 +32,15 @@ enum v4l2_subdev_format_whence {   * @which: format type (from enum v4l2_subdev_format_whence)   * @pad: pad number, as reported by the media API   * @format: media bus format (format code and frame size) + * @stream: stream number, defined in subdev routing + * @reserved: drivers and applications must zero this array   */  struct v4l2_subdev_format {  	__u32 which;  	__u32 pad;  	struct v4l2_mbus_framefmt format; -	__u32 reserved[8]; +	__u32 stream; +	__u32 reserved[7];  };  /** @@ -57,35 +48,59 @@ struct v4l2_subdev_format {   * @which: format type (from enum v4l2_subdev_format_whence)   * @pad: pad number, as reported by the media API   * @rect: pad crop rectangle boundaries + * @stream: stream number, defined in subdev routing + * @reserved: drivers and applications must zero this array + * + * The subdev crop API is an obsolete interface and may be removed in the + * future. It is superseded by the selection API. No new extensions to this + * structure will be accepted.   */  struct v4l2_subdev_crop {  	__u32 which;  	__u32 pad;  	struct v4l2_rect rect; -	__u32 reserved[8]; +	__u32 stream; +	__u32 reserved[7];  }; +#define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE	0x00000001 +#define V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC	0x00000002 +#define V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC	0x00000004 +#define V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC	V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC +#define V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION	0x00000008 +  /**   * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration   * @pad: pad number, as reported by the media API   * @index: format index during enumeration   * @code: format code (MEDIA_BUS_FMT_ definitions)   * @which: format type (from enum v4l2_subdev_format_whence) + * @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*) + * @stream: stream number, defined in subdev routing + * @reserved: drivers and applications must zero this array   */  struct v4l2_subdev_mbus_code_enum {  	__u32 pad;  	__u32 index;  	__u32 code;  	__u32 which; -	__u32 reserved[8]; +	__u32 flags; +	__u32 stream; +	__u32 reserved[6];  };  /**   * struct v4l2_subdev_frame_size_enum - Media bus format enumeration - * @pad: pad number, as reported by the media API   * @index: format index during enumeration + * @pad: pad number, as reported by the media API   * @code: format code (MEDIA_BUS_FMT_ definitions) + * @min_width: minimum frame width, in pixels + * @max_width: maximum frame width, in pixels + * @min_height: minimum frame height, in pixels + * @max_height: maximum frame height, in pixels   * @which: format type (from enum v4l2_subdev_format_whence) + * @stream: stream number, defined in subdev routing + * @reserved: drivers and applications must zero this array   */  struct v4l2_subdev_frame_size_enum {  	__u32 index; @@ -96,18 +111,24 @@ struct v4l2_subdev_frame_size_enum {  	__u32 min_height;  	__u32 max_height;  	__u32 which; -	__u32 reserved[8]; +	__u32 stream; +	__u32 reserved[7];  };  /**   * struct v4l2_subdev_frame_interval - Pad-level frame rate   * @pad: pad number, as reported by the media API   * @interval: frame interval in seconds + * @stream: stream number, defined in subdev routing + * @which: interval type (from enum v4l2_subdev_format_whence) + * @reserved: drivers and applications must zero this array   */  struct v4l2_subdev_frame_interval {  	__u32 pad;  	struct v4l2_fract interval; -	__u32 reserved[9]; +	__u32 stream; +	__u32 which; +	__u32 reserved[7];  };  /** @@ -118,7 +139,9 @@ struct v4l2_subdev_frame_interval {   * @width: frame width in pixels   * @height: frame height in pixels   * @interval: frame interval in seconds - * @which: format type (from enum v4l2_subdev_format_whence) + * @which: interval type (from enum v4l2_subdev_format_whence) + * @stream: stream number, defined in subdev routing + * @reserved: drivers and applications must zero this array   */  struct v4l2_subdev_frame_interval_enum {  	__u32 index; @@ -128,7 +151,8 @@ struct v4l2_subdev_frame_interval_enum {  	__u32 height;  	struct v4l2_fract interval;  	__u32 which; -	__u32 reserved[8]; +	__u32 stream; +	__u32 reserved[7];  };  /** @@ -140,6 +164,7 @@ struct v4l2_subdev_frame_interval_enum {   *	    defined in v4l2-common.h; V4L2_SEL_TGT_* .   * @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.   * @r: coordinates of the selection window + * @stream: stream number, defined in subdev routing   * @reserved: for future use, set to zero for now   *   * Hardware may use multiple helper windows to process a video stream. @@ -152,7 +177,8 @@ struct v4l2_subdev_selection {  	__u32 target;  	__u32 flags;  	struct v4l2_rect r; -	__u32 reserved[8]; +	__u32 stream; +	__u32 reserved[7];  };  /** @@ -168,7 +194,79 @@ struct v4l2_subdev_capability {  };  /* The v4l2 sub-device video device node is registered in read-only mode. */ -#define V4L2_SUBDEV_CAP_RO_SUBDEV		BIT(0) +#define V4L2_SUBDEV_CAP_RO_SUBDEV		0x00000001 + +/* The v4l2 sub-device supports routing and multiplexed streams. */ +#define V4L2_SUBDEV_CAP_STREAMS			0x00000002 + +/* + * Is the route active? An active route will start when streaming is enabled + * on a video node. + */ +#define V4L2_SUBDEV_ROUTE_FL_ACTIVE		(1U << 0) + +/** + * struct v4l2_subdev_route - A route inside a subdev + * + * @sink_pad: the sink pad index + * @sink_stream: the sink stream identifier + * @source_pad: the source pad index + * @source_stream: the source stream identifier + * @flags: route flags V4L2_SUBDEV_ROUTE_FL_* + * @reserved: drivers and applications must zero this array + */ +struct v4l2_subdev_route { +	__u32 sink_pad; +	__u32 sink_stream; +	__u32 source_pad; +	__u32 source_stream; +	__u32 flags; +	__u32 reserved[5]; +}; + +/** + * struct v4l2_subdev_routing - Subdev routing information + * + * @which: configuration type (from enum v4l2_subdev_format_whence) + * @len_routes: the length of the routes array, in routes; set by the user, not + *		modified by the kernel + * @routes: pointer to the routes array + * @num_routes: the total number of routes, possibly more than fits in the + *		routes array + * @reserved: drivers and applications must zero this array + */ +struct v4l2_subdev_routing { +	__u32 which; +	__u32 len_routes; +	__u64 routes; +	__u32 num_routes; +	__u32 reserved[11]; +}; + +/* + * The client is aware of streams. Setting this flag enables the use of 'stream' + * fields (referring to the stream number) with various ioctls. If this is not + * set (which is the default), the 'stream' fields will be forced to 0 by the + * kernel. + */ +#define V4L2_SUBDEV_CLIENT_CAP_STREAMS			(1ULL << 0) + +/* + * The client is aware of the struct v4l2_subdev_frame_interval which field. If + * this is not set (which is the default), the which field is forced to + * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel. + */ +#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH	(1ULL << 1) + +/** + * struct v4l2_subdev_client_capability - Capabilities of the client accessing + *					  the subdev + * + * @capabilities: A bitmask of V4L2_SUBDEV_CLIENT_CAP_* flags. + */ +struct v4l2_subdev_client_capability { +	__u64 capabilities; +};  /* Backwards compatibility define --- to be removed */  #define v4l2_subdev_edid v4l2_edid @@ -185,6 +283,11 @@ struct v4l2_subdev_capability {  #define VIDIOC_SUBDEV_S_CROP			_IOWR('V', 60, struct v4l2_subdev_crop)  #define VIDIOC_SUBDEV_G_SELECTION		_IOWR('V', 61, struct v4l2_subdev_selection)  #define VIDIOC_SUBDEV_S_SELECTION		_IOWR('V', 62, struct v4l2_subdev_selection) +#define VIDIOC_SUBDEV_G_ROUTING			_IOWR('V', 38, struct v4l2_subdev_routing) +#define VIDIOC_SUBDEV_S_ROUTING			_IOWR('V', 39, struct v4l2_subdev_routing) +#define VIDIOC_SUBDEV_G_CLIENT_CAP		_IOR('V',  101, struct v4l2_subdev_client_capability) +#define VIDIOC_SUBDEV_S_CLIENT_CAP		_IOWR('V',  102, struct v4l2_subdev_client_capability) +  /* The following ioctls are identical to the ioctls in videodev2.h */  #define VIDIOC_SUBDEV_G_STD			_IOR('V', 23, v4l2_std_id)  #define VIDIOC_SUBDEV_S_STD			_IOW('V', 24, v4l2_std_id) diff --git a/include/uapi/linux/vbox_vmmdev_types.h b/include/uapi/linux/vbox_vmmdev_types.h index f8a8d6b3c521..6073858d52a2 100644 --- a/include/uapi/linux/vbox_vmmdev_types.h +++ b/include/uapi/linux/vbox_vmmdev_types.h @@ -282,7 +282,10 @@ struct vmmdev_hgcm_pagelist {  	__u32 flags;             /** VMMDEV_HGCM_F_PARM_*. */  	__u16 offset_first_page; /** Data offset in the first page. */  	__u16 page_count;        /** Number of pages. */ -	__u64 pages[1];          /** Page addresses. */ +	union { +		__u64 unused;	/** Deprecated place-holder for first "pages" entry. */ +		__DECLARE_FLEX_ARRAY(__u64, pages); /** Page addresses. */ +	};  };  VMMDEV_ASSERT_SIZE(vmmdev_hgcm_pagelist, 4 + 2 + 2 + 8); diff --git a/include/uapi/linux/vdpa.h b/include/uapi/linux/vdpa.h new file mode 100644 index 000000000000..71edf2c70cc3 --- /dev/null +++ b/include/uapi/linux/vdpa.h @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * vdpa device management interface + * Copyright (c) 2020 Mellanox Technologies Ltd. All rights reserved. + */ + +#ifndef _UAPI_LINUX_VDPA_H_ +#define _UAPI_LINUX_VDPA_H_ + +#define VDPA_GENL_NAME "vdpa" +#define VDPA_GENL_VERSION 0x1 + +enum vdpa_command { +	VDPA_CMD_UNSPEC, +	VDPA_CMD_MGMTDEV_NEW, +	VDPA_CMD_MGMTDEV_GET,		/* can dump */ +	VDPA_CMD_DEV_NEW, +	VDPA_CMD_DEV_DEL, +	VDPA_CMD_DEV_GET,		/* can dump */ +	VDPA_CMD_DEV_CONFIG_GET,	/* can dump */ +	VDPA_CMD_DEV_VSTATS_GET, +	VDPA_CMD_DEV_ATTR_SET, +}; + +enum vdpa_attr { +	VDPA_ATTR_UNSPEC, + +	/* Pad attribute for 64b alignment */ +	VDPA_ATTR_PAD = VDPA_ATTR_UNSPEC, + +	/* bus name (optional) + dev name together make the parent device handle */ +	VDPA_ATTR_MGMTDEV_BUS_NAME,		/* string */ +	VDPA_ATTR_MGMTDEV_DEV_NAME,		/* string */ +	VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES,	/* u64 */ + +	VDPA_ATTR_DEV_NAME,			/* string */ +	VDPA_ATTR_DEV_ID,			/* u32 */ +	VDPA_ATTR_DEV_VENDOR_ID,		/* u32 */ +	VDPA_ATTR_DEV_MAX_VQS,			/* u32 */ +	VDPA_ATTR_DEV_MAX_VQ_SIZE,		/* u16 */ +	VDPA_ATTR_DEV_MIN_VQ_SIZE,		/* u16 */ + +	VDPA_ATTR_DEV_NET_CFG_MACADDR,		/* binary */ +	VDPA_ATTR_DEV_NET_STATUS,		/* u8 */ +	VDPA_ATTR_DEV_NET_CFG_MAX_VQP,		/* u16 */ +	VDPA_ATTR_DEV_NET_CFG_MTU,		/* u16 */ + +	VDPA_ATTR_DEV_NEGOTIATED_FEATURES,	/* u64 */ +	VDPA_ATTR_DEV_MGMTDEV_MAX_VQS,		/* u32 */ +	/* virtio features that are supported by the vDPA management device */ +	VDPA_ATTR_DEV_SUPPORTED_FEATURES,	/* u64 */ + +	VDPA_ATTR_DEV_QUEUE_INDEX,              /* u32 */ +	VDPA_ATTR_DEV_VENDOR_ATTR_NAME,		/* string */ +	VDPA_ATTR_DEV_VENDOR_ATTR_VALUE,        /* u64 */ + +	/* virtio features that are provisioned to the vDPA device */ +	VDPA_ATTR_DEV_FEATURES,                 /* u64 */ + +	VDPA_ATTR_DEV_BLK_CFG_CAPACITY,		/* u64 */ +	VDPA_ATTR_DEV_BLK_CFG_SIZE_MAX,		/* u32 */ +	VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE,		/* u32 */ +	VDPA_ATTR_DEV_BLK_CFG_SEG_MAX,		/* u32 */ +	VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES,	/* u16 */ +	VDPA_ATTR_DEV_BLK_CFG_PHY_BLK_EXP,	/* u8 */ +	VDPA_ATTR_DEV_BLK_CFG_ALIGN_OFFSET,	/* u8 */ +	VDPA_ATTR_DEV_BLK_CFG_MIN_IO_SIZE,	/* u16 */ +	VDPA_ATTR_DEV_BLK_CFG_OPT_IO_SIZE,	/* u32 */ +	VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEC,	/* u32 */ +	VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEG,	/* u32 */ +	VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN,/* u32 */ +	VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC,	/* u32 */ +	VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG,	/* u32 */ +	VDPA_ATTR_DEV_BLK_READ_ONLY,		/* u8 */ +	VDPA_ATTR_DEV_BLK_FLUSH,		/* u8 */ + +	/* new attributes must be added above here */ +	VDPA_ATTR_MAX, +}; + +#endif diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h new file mode 100644 index 000000000000..68a627d04afa --- /dev/null +++ b/include/uapi/linux/vduse.h @@ -0,0 +1,353 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +#ifndef _UAPI_VDUSE_H_ +#define _UAPI_VDUSE_H_ + +#include <linux/types.h> + +#define VDUSE_BASE	0x81 + +/* The ioctls for control device (/dev/vduse/control) */ + +#define VDUSE_API_VERSION	0 + +/* + * Get the version of VDUSE API that kernel supported (VDUSE_API_VERSION). + * This is used for future extension. + */ +#define VDUSE_GET_API_VERSION	_IOR(VDUSE_BASE, 0x00, __u64) + +/* Set the version of VDUSE API that userspace supported. */ +#define VDUSE_SET_API_VERSION	_IOW(VDUSE_BASE, 0x01, __u64) + +/** + * struct vduse_dev_config - basic configuration of a VDUSE device + * @name: VDUSE device name, needs to be NUL terminated + * @vendor_id: virtio vendor id + * @device_id: virtio device id + * @features: virtio features + * @vq_num: the number of virtqueues + * @vq_align: the allocation alignment of virtqueue's metadata + * @reserved: for future use, needs to be initialized to zero + * @config_size: the size of the configuration space + * @config: the buffer of the configuration space + * + * Structure used by VDUSE_CREATE_DEV ioctl to create VDUSE device. + */ +struct vduse_dev_config { +#define VDUSE_NAME_MAX	256 +	char name[VDUSE_NAME_MAX]; +	__u32 vendor_id; +	__u32 device_id; +	__u64 features; +	__u32 vq_num; +	__u32 vq_align; +	__u32 reserved[13]; +	__u32 config_size; +	__u8 config[]; +}; + +/* Create a VDUSE device which is represented by a char device (/dev/vduse/$NAME) */ +#define VDUSE_CREATE_DEV	_IOW(VDUSE_BASE, 0x02, struct vduse_dev_config) + +/* + * Destroy a VDUSE device. Make sure there are no more references + * to the char device (/dev/vduse/$NAME). + */ +#define VDUSE_DESTROY_DEV	_IOW(VDUSE_BASE, 0x03, char[VDUSE_NAME_MAX]) + +/* The ioctls for VDUSE device (/dev/vduse/$NAME) */ + +/** + * struct vduse_iotlb_entry - entry of IOTLB to describe one IOVA region [start, last] + * @offset: the mmap offset on returned file descriptor + * @start: start of the IOVA region + * @last: last of the IOVA region + * @perm: access permission of the IOVA region + * + * Structure used by VDUSE_IOTLB_GET_FD ioctl to find an overlapped IOVA region. + */ +struct vduse_iotlb_entry { +	__u64 offset; +	__u64 start; +	__u64 last; +#define VDUSE_ACCESS_RO 0x1 +#define VDUSE_ACCESS_WO 0x2 +#define VDUSE_ACCESS_RW 0x3 +	__u8 perm; +}; + +/* + * Find the first IOVA region that overlaps with the range [start, last] + * and return the corresponding file descriptor. Return -EINVAL means the + * IOVA region doesn't exist. Caller should set start and last fields. + */ +#define VDUSE_IOTLB_GET_FD	_IOWR(VDUSE_BASE, 0x10, struct vduse_iotlb_entry) + +/* + * Get the negotiated virtio features. It's a subset of the features in + * struct vduse_dev_config which can be accepted by virtio driver. It's + * only valid after FEATURES_OK status bit is set. + */ +#define VDUSE_DEV_GET_FEATURES	_IOR(VDUSE_BASE, 0x11, __u64) + +/** + * struct vduse_config_data - data used to update configuration space + * @offset: the offset from the beginning of configuration space + * @length: the length to write to configuration space + * @buffer: the buffer used to write from + * + * Structure used by VDUSE_DEV_SET_CONFIG ioctl to update device + * configuration space. + */ +struct vduse_config_data { +	__u32 offset; +	__u32 length; +	__u8 buffer[]; +}; + +/* Set device configuration space */ +#define VDUSE_DEV_SET_CONFIG	_IOW(VDUSE_BASE, 0x12, struct vduse_config_data) + +/* + * Inject a config interrupt. It's usually used to notify virtio driver + * that device configuration space has changed. + */ +#define VDUSE_DEV_INJECT_CONFIG_IRQ	_IO(VDUSE_BASE, 0x13) + +/** + * struct vduse_vq_config - basic configuration of a virtqueue + * @index: virtqueue index + * @max_size: the max size of virtqueue + * @reserved: for future use, needs to be initialized to zero + * + * Structure used by VDUSE_VQ_SETUP ioctl to setup a virtqueue. + */ +struct vduse_vq_config { +	__u32 index; +	__u16 max_size; +	__u16 reserved[13]; +}; + +/* + * Setup the specified virtqueue. Make sure all virtqueues have been + * configured before the device is attached to vDPA bus. + */ +#define VDUSE_VQ_SETUP		_IOW(VDUSE_BASE, 0x14, struct vduse_vq_config) + +/** + * struct vduse_vq_state_split - split virtqueue state + * @avail_index: available index + */ +struct vduse_vq_state_split { +	__u16 avail_index; +}; + +/** + * struct vduse_vq_state_packed - packed virtqueue state + * @last_avail_counter: last driver ring wrap counter observed by device + * @last_avail_idx: device available index + * @last_used_counter: device ring wrap counter + * @last_used_idx: used index + */ +struct vduse_vq_state_packed { +	__u16 last_avail_counter; +	__u16 last_avail_idx; +	__u16 last_used_counter; +	__u16 last_used_idx; +}; + +/** + * struct vduse_vq_info - information of a virtqueue + * @index: virtqueue index + * @num: the size of virtqueue + * @desc_addr: address of desc area + * @driver_addr: address of driver area + * @device_addr: address of device area + * @split: split virtqueue state + * @packed: packed virtqueue state + * @ready: ready status of virtqueue + * + * Structure used by VDUSE_VQ_GET_INFO ioctl to get virtqueue's information. + */ +struct vduse_vq_info { +	__u32 index; +	__u32 num; +	__u64 desc_addr; +	__u64 driver_addr; +	__u64 device_addr; +	union { +		struct vduse_vq_state_split split; +		struct vduse_vq_state_packed packed; +	}; +	__u8 ready; +}; + +/* Get the specified virtqueue's information. Caller should set index field. */ +#define VDUSE_VQ_GET_INFO	_IOWR(VDUSE_BASE, 0x15, struct vduse_vq_info) + +/** + * struct vduse_vq_eventfd - eventfd configuration for a virtqueue + * @index: virtqueue index + * @fd: eventfd, -1 means de-assigning the eventfd + * + * Structure used by VDUSE_VQ_SETUP_KICKFD ioctl to setup kick eventfd. + */ +struct vduse_vq_eventfd { +	__u32 index; +#define VDUSE_EVENTFD_DEASSIGN -1 +	int fd; +}; + +/* + * Setup kick eventfd for specified virtqueue. The kick eventfd is used + * by VDUSE kernel module to notify userspace to consume the avail vring. + */ +#define VDUSE_VQ_SETUP_KICKFD	_IOW(VDUSE_BASE, 0x16, struct vduse_vq_eventfd) + +/* + * Inject an interrupt for specific virtqueue. It's used to notify virtio driver + * to consume the used vring. + */ +#define VDUSE_VQ_INJECT_IRQ	_IOW(VDUSE_BASE, 0x17, __u32) + +/** + * struct vduse_iova_umem - userspace memory configuration for one IOVA region + * @uaddr: start address of userspace memory, it must be aligned to page size + * @iova: start of the IOVA region + * @size: size of the IOVA region + * @reserved: for future use, needs to be initialized to zero + * + * Structure used by VDUSE_IOTLB_REG_UMEM and VDUSE_IOTLB_DEREG_UMEM + * ioctls to register/de-register userspace memory for IOVA regions + */ +struct vduse_iova_umem { +	__u64 uaddr; +	__u64 iova; +	__u64 size; +	__u64 reserved[3]; +}; + +/* Register userspace memory for IOVA regions */ +#define VDUSE_IOTLB_REG_UMEM	_IOW(VDUSE_BASE, 0x18, struct vduse_iova_umem) + +/* De-register the userspace memory. Caller should set iova and size field. */ +#define VDUSE_IOTLB_DEREG_UMEM	_IOW(VDUSE_BASE, 0x19, struct vduse_iova_umem) + +/** + * struct vduse_iova_info - information of one IOVA region + * @start: start of the IOVA region + * @last: last of the IOVA region + * @capability: capability of the IOVA regsion + * @reserved: for future use, needs to be initialized to zero + * + * Structure used by VDUSE_IOTLB_GET_INFO ioctl to get information of + * one IOVA region. + */ +struct vduse_iova_info { +	__u64 start; +	__u64 last; +#define VDUSE_IOVA_CAP_UMEM (1 << 0) +	__u64 capability; +	__u64 reserved[3]; +}; + +/* + * Find the first IOVA region that overlaps with the range [start, last] + * and return some information on it. Caller should set start and last fields. + */ +#define VDUSE_IOTLB_GET_INFO	_IOWR(VDUSE_BASE, 0x1a, struct vduse_iova_info) + +/* The control messages definition for read(2)/write(2) on /dev/vduse/$NAME */ + +/** + * enum vduse_req_type - request type + * @VDUSE_GET_VQ_STATE: get the state for specified virtqueue from userspace + * @VDUSE_SET_STATUS: set the device status + * @VDUSE_UPDATE_IOTLB: Notify userspace to update the memory mapping for + *                      specified IOVA range via VDUSE_IOTLB_GET_FD ioctl + */ +enum vduse_req_type { +	VDUSE_GET_VQ_STATE, +	VDUSE_SET_STATUS, +	VDUSE_UPDATE_IOTLB, +}; + +/** + * struct vduse_vq_state - virtqueue state + * @index: virtqueue index + * @split: split virtqueue state + * @packed: packed virtqueue state + */ +struct vduse_vq_state { +	__u32 index; +	union { +		struct vduse_vq_state_split split; +		struct vduse_vq_state_packed packed; +	}; +}; + +/** + * struct vduse_dev_status - device status + * @status: device status + */ +struct vduse_dev_status { +	__u8 status; +}; + +/** + * struct vduse_iova_range - IOVA range [start, last] + * @start: start of the IOVA range + * @last: last of the IOVA range + */ +struct vduse_iova_range { +	__u64 start; +	__u64 last; +}; + +/** + * struct vduse_dev_request - control request + * @type: request type + * @request_id: request id + * @reserved: for future use + * @vq_state: virtqueue state, only index field is available + * @s: device status + * @iova: IOVA range for updating + * @padding: padding + * + * Structure used by read(2) on /dev/vduse/$NAME. + */ +struct vduse_dev_request { +	__u32 type; +	__u32 request_id; +	__u32 reserved[4]; +	union { +		struct vduse_vq_state vq_state; +		struct vduse_dev_status s; +		struct vduse_iova_range iova; +		__u32 padding[32]; +	}; +}; + +/** + * struct vduse_dev_response - response to control request + * @request_id: corresponding request id + * @result: the result of request + * @reserved: for future use, needs to be initialized to zero + * @vq_state: virtqueue state + * @padding: padding + * + * Structure used by write(2) on /dev/vduse/$NAME. + */ +struct vduse_dev_response { +	__u32 request_id; +#define VDUSE_REQ_RESULT_OK	0x00 +#define VDUSE_REQ_RESULT_FAILED	0x01 +	__u32 result; +	__u32 reserved[4]; +	union { +		struct vduse_vq_state vq_state; +		__u32 padding[32]; +	}; +}; + +#endif /* _UAPI_VDUSE_H_ */ diff --git a/include/uapi/linux/vesa.h b/include/uapi/linux/vesa.h new file mode 100644 index 000000000000..81947f5088cd --- /dev/null +++ b/include/uapi/linux/vesa.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_VESA_H +#define _UAPI_LINUX_VESA_H + +/* VESA Blanking Levels */ +enum vesa_blank_mode { +	VESA_NO_BLANKING	= 0, +#define VESA_NO_BLANKING	VESA_NO_BLANKING +	VESA_VSYNC_SUSPEND	= 1, +#define VESA_VSYNC_SUSPEND	VESA_VSYNC_SUSPEND +	VESA_HSYNC_SUSPEND	= 2, +#define VESA_HSYNC_SUSPEND	VESA_HSYNC_SUSPEND +	VESA_POWERDOWN		= VESA_VSYNC_SUSPEND | VESA_HSYNC_SUSPEND, +#define VESA_POWERDOWN		VESA_POWERDOWN +	VESA_BLANK_MAX		= VESA_POWERDOWN, +}; + +#endif diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index 920470502329..75100bf009ba 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -35,7 +35,7 @@  #define VFIO_EEH			5  /* Two-stage IOMMU */ -#define VFIO_TYPE1_NESTING_IOMMU	6	/* Implies v2 */ +#define __VFIO_RESERVED_TYPE1_NESTING_IOMMU	6	/* Implies v2 */  #define VFIO_SPAPR_TCE_v2_IOMMU		7 @@ -46,6 +46,16 @@   */  #define VFIO_NOIOMMU_IOMMU		8 +/* Supports VFIO_DMA_UNMAP_FLAG_ALL */ +#define VFIO_UNMAP_ALL			9 + +/* + * Supports the vaddr flag for DMA map and unmap.  Not supported for mediated + * devices, so this capability is subject to change as groups are added or + * removed. + */ +#define VFIO_UPDATE_VADDR		10 +  /*   * The IOCTL interface is designed for extensibility by embedding the   * structure length (argsz) and flags into structures passed between @@ -201,8 +211,13 @@ struct vfio_device_info {  #define VFIO_DEVICE_FLAGS_AMBA  (1 << 3)	/* vfio-amba device */  #define VFIO_DEVICE_FLAGS_CCW	(1 << 4)	/* vfio-ccw device */  #define VFIO_DEVICE_FLAGS_AP	(1 << 5)	/* vfio-ap device */ +#define VFIO_DEVICE_FLAGS_FSL_MC (1 << 6)	/* vfio-fsl-mc device */ +#define VFIO_DEVICE_FLAGS_CAPS	(1 << 7)	/* Info supports caps */ +#define VFIO_DEVICE_FLAGS_CDX	(1 << 8)	/* vfio-cdx device */  	__u32	num_regions;	/* Max region index + 1 */  	__u32	num_irqs;	/* Max IRQ index + 1 */ +	__u32   cap_offset;	/* Offset within info struct of first cap */ +	__u32   pad;  };  #define VFIO_DEVICE_GET_INFO		_IO(VFIO_TYPE, VFIO_BASE + 7) @@ -218,6 +233,29 @@ struct vfio_device_info {  #define VFIO_DEVICE_API_CCW_STRING		"vfio-ccw"  #define VFIO_DEVICE_API_AP_STRING		"vfio-ap" +/* + * The following capabilities are unique to s390 zPCI devices.  Their contents + * are further-defined in vfio_zdev.h + */ +#define VFIO_DEVICE_INFO_CAP_ZPCI_BASE		1 +#define VFIO_DEVICE_INFO_CAP_ZPCI_GROUP		2 +#define VFIO_DEVICE_INFO_CAP_ZPCI_UTIL		3 +#define VFIO_DEVICE_INFO_CAP_ZPCI_PFIP		4 + +/* + * The following VFIO_DEVICE_INFO capability reports support for PCIe AtomicOp + * completion to the root bus with supported widths provided via flags. + */ +#define VFIO_DEVICE_INFO_CAP_PCI_ATOMIC_COMP	5 +struct vfio_device_info_cap_pci_atomic_comp { +	struct vfio_info_cap_header header; +	__u32 flags; +#define VFIO_PCI_ATOMIC_COMP32	(1 << 0) +#define VFIO_PCI_ATOMIC_COMP64	(1 << 1) +#define VFIO_PCI_ATOMIC_COMP128	(1 << 2) +	__u32 reserved; +}; +  /**   * VFIO_DEVICE_GET_REGION_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 8,   *				       struct vfio_region_info) @@ -239,8 +277,8 @@ struct vfio_region_info {  #define VFIO_REGION_INFO_FLAG_CAPS	(1 << 3) /* Info supports caps */  	__u32	index;		/* Region index */  	__u32	cap_offset;	/* Offset within info struct of first cap */ -	__u64	size;		/* Region size (bytes) */ -	__u64	offset;		/* Region offset from start of device fd */ +	__aligned_u64	size;	/* Region size (bytes) */ +	__aligned_u64	offset;	/* Region offset from start of device fd */  };  #define VFIO_DEVICE_GET_REGION_INFO	_IO(VFIO_TYPE, VFIO_BASE + 8) @@ -256,8 +294,8 @@ struct vfio_region_info {  #define VFIO_REGION_INFO_CAP_SPARSE_MMAP	1  struct vfio_region_sparse_mmap_area { -	__u64	offset;	/* Offset of mmap'able area within region */ -	__u64	size;	/* Size of mmap'able area */ +	__aligned_u64	offset;	/* Offset of mmap'able area within region */ +	__aligned_u64	size;	/* Size of mmap'able area */  };  struct vfio_region_info_cap_sparse_mmap { @@ -305,7 +343,7 @@ struct vfio_region_info_cap_type {  #define VFIO_REGION_TYPE_PCI_VENDOR_MASK	(0xffff)  #define VFIO_REGION_TYPE_GFX                    (1)  #define VFIO_REGION_TYPE_CCW			(2) -#define VFIO_REGION_TYPE_MIGRATION              (3) +#define VFIO_REGION_TYPE_MIGRATION_DEPRECATED   (3)  /* sub-types for VFIO_REGION_TYPE_PCI_* */ @@ -317,6 +355,8 @@ struct vfio_region_info_cap_type {  /* 10de vendor PCI sub-types */  /*   * NVIDIA GPU NVlink2 RAM is coherent RAM mapped onto the host address space. + * + * Deprecated, region no longer provided   */  #define VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM	(1) @@ -324,6 +364,8 @@ struct vfio_region_info_cap_type {  /*   * IBM NPU NVlink2 ATSD (Address Translation Shootdown) register of NPU   * to do TLB invalidation on a GPU. + * + * Deprecated, region no longer provided   */  #define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD	(1) @@ -383,230 +425,34 @@ struct vfio_region_gfx_edid {  #define VFIO_REGION_SUBTYPE_CCW_CRW		(3)  /* sub-types for VFIO_REGION_TYPE_MIGRATION */ -#define VFIO_REGION_SUBTYPE_MIGRATION           (1) - -/* - * The structure vfio_device_migration_info is placed at the 0th offset of - * the VFIO_REGION_SUBTYPE_MIGRATION region to get and set VFIO device related - * migration information. Field accesses from this structure are only supported - * at their native width and alignment. Otherwise, the result is undefined and - * vendor drivers should return an error. - * - * device_state: (read/write) - *      - The user application writes to this field to inform the vendor driver - *        about the device state to be transitioned to. - *      - The vendor driver should take the necessary actions to change the - *        device state. After successful transition to a given state, the - *        vendor driver should return success on write(device_state, state) - *        system call. If the device state transition fails, the vendor driver - *        should return an appropriate -errno for the fault condition. - *      - On the user application side, if the device state transition fails, - *	  that is, if write(device_state, state) returns an error, read - *	  device_state again to determine the current state of the device from - *	  the vendor driver. - *      - The vendor driver should return previous state of the device unless - *        the vendor driver has encountered an internal error, in which case - *        the vendor driver may report the device_state VFIO_DEVICE_STATE_ERROR. - *      - The user application must use the device reset ioctl to recover the - *        device from VFIO_DEVICE_STATE_ERROR state. If the device is - *        indicated to be in a valid device state by reading device_state, the - *        user application may attempt to transition the device to any valid - *        state reachable from the current state or terminate itself. - * - *      device_state consists of 3 bits: - *      - If bit 0 is set, it indicates the _RUNNING state. If bit 0 is clear, - *        it indicates the _STOP state. When the device state is changed to - *        _STOP, driver should stop the device before write() returns. - *      - If bit 1 is set, it indicates the _SAVING state, which means that the - *        driver should start gathering device state information that will be - *        provided to the VFIO user application to save the device's state. - *      - If bit 2 is set, it indicates the _RESUMING state, which means that - *        the driver should prepare to resume the device. Data provided through - *        the migration region should be used to resume the device. - *      Bits 3 - 31 are reserved for future use. To preserve them, the user - *      application should perform a read-modify-write operation on this - *      field when modifying the specified bits. - * - *  +------- _RESUMING - *  |+------ _SAVING - *  ||+----- _RUNNING - *  ||| - *  000b => Device Stopped, not saving or resuming - *  001b => Device running, which is the default state - *  010b => Stop the device & save the device state, stop-and-copy state - *  011b => Device running and save the device state, pre-copy state - *  100b => Device stopped and the device state is resuming - *  101b => Invalid state - *  110b => Error state - *  111b => Invalid state - * - * State transitions: - * - *              _RESUMING  _RUNNING    Pre-copy    Stop-and-copy   _STOP - *                (100b)     (001b)     (011b)        (010b)       (000b) - * 0. Running or default state - *                             | - * - * 1. Normal Shutdown (optional) - *                             |------------------------------------->| - * - * 2. Save the state or suspend - *                             |------------------------->|---------->| - * - * 3. Save the state during live migration - *                             |----------->|------------>|---------->| - * - * 4. Resuming - *                  |<---------| - * - * 5. Resumed - *                  |--------->| - * - * 0. Default state of VFIO device is _RUNNNG when the user application starts. - * 1. During normal shutdown of the user application, the user application may - *    optionally change the VFIO device state from _RUNNING to _STOP. This - *    transition is optional. The vendor driver must support this transition but - *    must not require it. - * 2. When the user application saves state or suspends the application, the - *    device state transitions from _RUNNING to stop-and-copy and then to _STOP. - *    On state transition from _RUNNING to stop-and-copy, driver must stop the - *    device, save the device state and send it to the application through the - *    migration region. The sequence to be followed for such transition is given - *    below. - * 3. In live migration of user application, the state transitions from _RUNNING - *    to pre-copy, to stop-and-copy, and to _STOP. - *    On state transition from _RUNNING to pre-copy, the driver should start - *    gathering the device state while the application is still running and send - *    the device state data to application through the migration region. - *    On state transition from pre-copy to stop-and-copy, the driver must stop - *    the device, save the device state and send it to the user application - *    through the migration region. - *    Vendor drivers must support the pre-copy state even for implementations - *    where no data is provided to the user before the stop-and-copy state. The - *    user must not be required to consume all migration data before the device - *    transitions to a new state, including the stop-and-copy state. - *    The sequence to be followed for above two transitions is given below. - * 4. To start the resuming phase, the device state should be transitioned from - *    the _RUNNING to the _RESUMING state. - *    In the _RESUMING state, the driver should use the device state data - *    received through the migration region to resume the device. - * 5. After providing saved device data to the driver, the application should - *    change the state from _RESUMING to _RUNNING. - * - * reserved: - *      Reads on this field return zero and writes are ignored. - * - * pending_bytes: (read only) - *      The number of pending bytes still to be migrated from the vendor driver. - * - * data_offset: (read only) - *      The user application should read data_offset field from the migration - *      region. The user application should read the device data from this - *      offset within the migration region during the _SAVING state or write - *      the device data during the _RESUMING state. See below for details of - *      sequence to be followed. - * - * data_size: (read/write) - *      The user application should read data_size to get the size in bytes of - *      the data copied in the migration region during the _SAVING state and - *      write the size in bytes of the data copied in the migration region - *      during the _RESUMING state. - * - * The format of the migration region is as follows: - *  ------------------------------------------------------------------ - * |vfio_device_migration_info|    data section                      | - * |                          |     ///////////////////////////////  | - * ------------------------------------------------------------------ - *   ^                              ^ - *  offset 0-trapped part        data_offset - * - * The structure vfio_device_migration_info is always followed by the data - * section in the region, so data_offset will always be nonzero. The offset - * from where the data is copied is decided by the kernel driver. The data - * section can be trapped, mmapped, or partitioned, depending on how the kernel - * driver defines the data section. The data section partition can be defined - * as mapped by the sparse mmap capability. If mmapped, data_offset must be - * page aligned, whereas initial section which contains the - * vfio_device_migration_info structure, might not end at the offset, which is - * page aligned. The user is not required to access through mmap regardless - * of the capabilities of the region mmap. - * The vendor driver should determine whether and how to partition the data - * section. The vendor driver should return data_offset accordingly. - * - * The sequence to be followed while in pre-copy state and stop-and-copy state - * is as follows: - * a. Read pending_bytes, indicating the start of a new iteration to get device - *    data. Repeated read on pending_bytes at this stage should have no side - *    effects. - *    If pending_bytes == 0, the user application should not iterate to get data - *    for that device. - *    If pending_bytes > 0, perform the following steps. - * b. Read data_offset, indicating that the vendor driver should make data - *    available through the data section. The vendor driver should return this - *    read operation only after data is available from (region + data_offset) - *    to (region + data_offset + data_size). - * c. Read data_size, which is the amount of data in bytes available through - *    the migration region. - *    Read on data_offset and data_size should return the offset and size of - *    the current buffer if the user application reads data_offset and - *    data_size more than once here. - * d. Read data_size bytes of data from (region + data_offset) from the - *    migration region. - * e. Process the data. - * f. Read pending_bytes, which indicates that the data from the previous - *    iteration has been read. If pending_bytes > 0, go to step b. - * - * The user application can transition from the _SAVING|_RUNNING - * (pre-copy state) to the _SAVING (stop-and-copy) state regardless of the - * number of pending bytes. The user application should iterate in _SAVING - * (stop-and-copy) until pending_bytes is 0. - * - * The sequence to be followed while _RESUMING device state is as follows: - * While data for this device is available, repeat the following steps: - * a. Read data_offset from where the user application should write data. - * b. Write migration data starting at the migration region + data_offset for - *    the length determined by data_size from the migration source. - * c. Write data_size, which indicates to the vendor driver that data is - *    written in the migration region. Vendor driver must return this write - *    operations on consuming data. Vendor driver should apply the - *    user-provided migration region data to the device resume state. - * - * If an error occurs during the above sequences, the vendor driver can return - * an error code for next read() or write() operation, which will terminate the - * loop. The user application should then take the next necessary action, for - * example, failing migration or terminating the user application. - * - * For the user application, data is opaque. The user application should write - * data in the same order as the data is received and the data should be of - * same transaction size at the source. - */ +#define VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED (1)  struct vfio_device_migration_info {  	__u32 device_state;         /* VFIO device state */ -#define VFIO_DEVICE_STATE_STOP      (0) -#define VFIO_DEVICE_STATE_RUNNING   (1 << 0) -#define VFIO_DEVICE_STATE_SAVING    (1 << 1) -#define VFIO_DEVICE_STATE_RESUMING  (1 << 2) -#define VFIO_DEVICE_STATE_MASK      (VFIO_DEVICE_STATE_RUNNING | \ -				     VFIO_DEVICE_STATE_SAVING |  \ -				     VFIO_DEVICE_STATE_RESUMING) +#define VFIO_DEVICE_STATE_V1_STOP      (0) +#define VFIO_DEVICE_STATE_V1_RUNNING   (1 << 0) +#define VFIO_DEVICE_STATE_V1_SAVING    (1 << 1) +#define VFIO_DEVICE_STATE_V1_RESUMING  (1 << 2) +#define VFIO_DEVICE_STATE_MASK      (VFIO_DEVICE_STATE_V1_RUNNING | \ +				     VFIO_DEVICE_STATE_V1_SAVING |  \ +				     VFIO_DEVICE_STATE_V1_RESUMING)  #define VFIO_DEVICE_STATE_VALID(state) \ -	(state & VFIO_DEVICE_STATE_RESUMING ? \ -	(state & VFIO_DEVICE_STATE_MASK) == VFIO_DEVICE_STATE_RESUMING : 1) +	(state & VFIO_DEVICE_STATE_V1_RESUMING ? \ +	(state & VFIO_DEVICE_STATE_MASK) == VFIO_DEVICE_STATE_V1_RESUMING : 1)  #define VFIO_DEVICE_STATE_IS_ERROR(state) \ -	((state & VFIO_DEVICE_STATE_MASK) == (VFIO_DEVICE_STATE_SAVING | \ -					      VFIO_DEVICE_STATE_RESUMING)) +	((state & VFIO_DEVICE_STATE_MASK) == (VFIO_DEVICE_STATE_V1_SAVING | \ +					      VFIO_DEVICE_STATE_V1_RESUMING))  #define VFIO_DEVICE_STATE_SET_ERROR(state) \ -	((state & ~VFIO_DEVICE_STATE_MASK) | VFIO_DEVICE_SATE_SAVING | \ -					     VFIO_DEVICE_STATE_RESUMING) +	((state & ~VFIO_DEVICE_STATE_MASK) | VFIO_DEVICE_STATE_V1_SAVING | \ +					     VFIO_DEVICE_STATE_V1_RESUMING)  	__u32 reserved; -	__u64 pending_bytes; -	__u64 data_offset; -	__u64 data_size; +	__aligned_u64 pending_bytes; +	__aligned_u64 data_offset; +	__aligned_u64 data_size;  };  /* @@ -623,12 +469,14 @@ struct vfio_device_migration_info {   * Capability with compressed real address (aka SSA - small system address)   * where GPU RAM is mapped on a system bus. Used by a GPU for DMA routing   * and by the userspace to associate a NVLink bridge with a GPU. + * + * Deprecated, capability no longer provided   */  #define VFIO_REGION_INFO_CAP_NVLINK2_SSATGT	4  struct vfio_region_info_cap_nvlink2_ssatgt {  	struct vfio_info_cap_header header; -	__u64 tgt; +	__aligned_u64 tgt;  };  /* @@ -637,6 +485,8 @@ struct vfio_region_info_cap_nvlink2_ssatgt {   * property in the device tree. The value is fixed in the hardware   * and failing to provide the correct value results in the link   * not working with no indication from the driver why. + * + * Deprecated, capability no longer provided   */  #define VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD	5 @@ -677,6 +527,9 @@ struct vfio_region_info_cap_nvlink2_lnkspd {   * then add and unmask vectors, it's up to userspace to make the decision   * whether to allocate the maximum supported number of vectors or tear   * down setup and incrementally increase the vectors as each is enabled. + * Absence of the NORESIZE flag indicates that vectors can be enabled + * and disabled dynamically without impacting other vectors within the + * index.   */  struct vfio_irq_info {  	__u32	argsz; @@ -808,18 +661,78 @@ enum {  enum {  	VFIO_CCW_IO_IRQ_INDEX,  	VFIO_CCW_CRW_IRQ_INDEX, +	VFIO_CCW_REQ_IRQ_INDEX,  	VFIO_CCW_NUM_IRQS  }; +/* + * The vfio-ap bus driver makes use of the following IRQ index mapping. + * Unimplemented IRQ types return a count of zero. + */ +enum { +	VFIO_AP_REQ_IRQ_INDEX, +	VFIO_AP_CFG_CHG_IRQ_INDEX, +	VFIO_AP_NUM_IRQS +}; +  /** - * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IORW(VFIO_TYPE, VFIO_BASE + 12, + * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 12,   *					      struct vfio_pci_hot_reset_info)   * + * This command is used to query the affected devices in the hot reset for + * a given device. + * + * This command always reports the segment, bus, and devfn information for + * each affected device, and selectively reports the group_id or devid per + * the way how the calling device is opened. + * + *	- If the calling device is opened via the traditional group/container + *	  API, group_id is reported.  User should check if it has owned all + *	  the affected devices and provides a set of group fds to prove the + *	  ownership in VFIO_DEVICE_PCI_HOT_RESET ioctl. + * + *	- If the calling device is opened as a cdev, devid is reported. + *	  Flag VFIO_PCI_HOT_RESET_FLAG_DEV_ID is set to indicate this + *	  data type.  All the affected devices should be represented in + *	  the dev_set, ex. bound to a vfio driver, and also be owned by + *	  this interface which is determined by the following conditions: + *	  1) Has a valid devid within the iommufd_ctx of the calling device. + *	     Ownership cannot be determined across separate iommufd_ctx and + *	     the cdev calling conventions do not support a proof-of-ownership + *	     model as provided in the legacy group interface.  In this case + *	     valid devid with value greater than zero is provided in the return + *	     structure. + *	  2) Does not have a valid devid within the iommufd_ctx of the calling + *	     device, but belongs to the same IOMMU group as the calling device + *	     or another opened device that has a valid devid within the + *	     iommufd_ctx of the calling device.  This provides implicit ownership + *	     for devices within the same DMA isolation context.  In this case + *	     the devid value of VFIO_PCI_DEVID_OWNED is provided in the return + *	     structure. + * + *	  A devid value of VFIO_PCI_DEVID_NOT_OWNED is provided in the return + *	  structure for affected devices where device is NOT represented in the + *	  dev_set or ownership is not available.  Such devices prevent the use + *	  of VFIO_DEVICE_PCI_HOT_RESET ioctl outside of the proof-of-ownership + *	  calling conventions (ie. via legacy group accessed devices).  Flag + *	  VFIO_PCI_HOT_RESET_FLAG_DEV_ID_OWNED would be set when all the + *	  affected devices are represented in the dev_set and also owned by + *	  the user.  This flag is available only when + *	  flag VFIO_PCI_HOT_RESET_FLAG_DEV_ID is set, otherwise reserved. + *	  When set, user could invoke VFIO_DEVICE_PCI_HOT_RESET with a zero + *	  length fd array on the calling device as the ownership is validated + *	  by iommufd_ctx. + *   * Return: 0 on success, -errno on failure:   *	-enospc = insufficient buffer, -enodev = unsupported for device.   */  struct vfio_pci_dependent_device { -	__u32	group_id; +	union { +		__u32   group_id; +		__u32	devid; +#define VFIO_PCI_DEVID_OWNED		0 +#define VFIO_PCI_DEVID_NOT_OWNED	-1 +	};  	__u16	segment;  	__u8	bus;  	__u8	devfn; /* Use PCI_SLOT/PCI_FUNC */ @@ -828,6 +741,8 @@ struct vfio_pci_dependent_device {  struct vfio_pci_hot_reset_info {  	__u32	argsz;  	__u32	flags; +#define VFIO_PCI_HOT_RESET_FLAG_DEV_ID		(1 << 0) +#define VFIO_PCI_HOT_RESET_FLAG_DEV_ID_OWNED	(1 << 1)  	__u32	count;  	struct vfio_pci_dependent_device	devices[];  }; @@ -838,6 +753,24 @@ struct vfio_pci_hot_reset_info {   * VFIO_DEVICE_PCI_HOT_RESET - _IOW(VFIO_TYPE, VFIO_BASE + 13,   *				    struct vfio_pci_hot_reset)   * + * A PCI hot reset results in either a bus or slot reset which may affect + * other devices sharing the bus/slot.  The calling user must have + * ownership of the full set of affected devices as determined by the + * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO ioctl. + * + * When called on a device file descriptor acquired through the vfio + * group interface, the user is required to provide proof of ownership + * of those affected devices via the group_fds array in struct + * vfio_pci_hot_reset. + * + * When called on a direct cdev opened vfio device, the flags field of + * struct vfio_pci_hot_reset_info reports the ownership status of the + * affected devices and this ioctl must be called with an empty group_fds + * array.  See above INFO ioctl definition for ownership requirements. + * + * Mixed usage of legacy groups and cdevs across the set of affected + * devices is not supported. + *   * Return: 0 on success, -errno on failure.   */  struct vfio_pci_hot_reset { @@ -884,7 +817,7 @@ struct vfio_device_gfx_plane_info {  	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_* */  	/* out */  	__u32 drm_format;	/* drm format of plane */ -	__u64 drm_format_mod;   /* tiled mode */ +	__aligned_u64 drm_format_mod;   /* tiled mode */  	__u32 width;	/* width of plane */  	__u32 height;	/* height of plane */  	__u32 stride;	/* stride of plane */ @@ -897,6 +830,7 @@ struct vfio_device_gfx_plane_info {  		__u32 region_index;	/* region index */  		__u32 dmabuf_id;	/* dma-buf id */  	}; +	__u32 reserved;  };  #define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14) @@ -931,15 +865,16 @@ struct vfio_device_ioeventfd {  #define VFIO_DEVICE_IOEVENTFD_32	(1 << 2) /* 4-byte write */  #define VFIO_DEVICE_IOEVENTFD_64	(1 << 3) /* 8-byte write */  #define VFIO_DEVICE_IOEVENTFD_SIZE_MASK	(0xf) -	__u64	offset;			/* device fd offset of write */ -	__u64	data;			/* data to be written */ +	__aligned_u64	offset;		/* device fd offset of write */ +	__aligned_u64	data;		/* data to be written */  	__s32	fd;			/* -1 for de-assignment */ +	__u32	reserved;  };  #define VFIO_DEVICE_IOEVENTFD		_IO(VFIO_TYPE, VFIO_BASE + 16)  /** - * VFIO_DEVICE_FEATURE - _IORW(VFIO_TYPE, VFIO_BASE + 17, + * VFIO_DEVICE_FEATURE - _IOWR(VFIO_TYPE, VFIO_BASE + 17,   *			       struct vfio_device_feature)   *   * Get, set, or probe feature data of the device.  The feature is selected @@ -967,6 +902,102 @@ struct vfio_device_feature {  #define VFIO_DEVICE_FEATURE		_IO(VFIO_TYPE, VFIO_BASE + 17)  /* + * VFIO_DEVICE_BIND_IOMMUFD - _IOR(VFIO_TYPE, VFIO_BASE + 18, + *				   struct vfio_device_bind_iommufd) + * @argsz:	 User filled size of this data. + * @flags:	 Must be 0 or a bit flags of VFIO_DEVICE_BIND_* + * @iommufd:	 iommufd to bind. + * @out_devid:	 The device id generated by this bind. devid is a handle for + *		 this device/iommufd bond and can be used in IOMMUFD commands. + * @token_uuid_ptr: Valid if VFIO_DEVICE_BIND_FLAG_TOKEN. Points to a 16 byte + *                  UUID in the same format as VFIO_DEVICE_FEATURE_PCI_VF_TOKEN. + * + * Bind a vfio_device to the specified iommufd. + * + * User is restricted from accessing the device before the binding operation + * is completed.  Only allowed on cdev fds. + * + * Unbind is automatically conducted when device fd is closed. + * + * A token is sometimes required to open the device, unless this is known to be + * needed VFIO_DEVICE_BIND_FLAG_TOKEN should not be set and token_uuid_ptr is + * ignored. The only case today is a PF/VF relationship where the VF bind must + * be provided the same token as VFIO_DEVICE_FEATURE_PCI_VF_TOKEN provided to + * the PF. + * + * Return: 0 on success, -errno on failure. + */ +struct vfio_device_bind_iommufd { +	__u32		argsz; +	__u32		flags; +#define VFIO_DEVICE_BIND_FLAG_TOKEN (1 << 0) +	__s32		iommufd; +	__u32		out_devid; +	__aligned_u64	token_uuid_ptr; +}; + +#define VFIO_DEVICE_BIND_IOMMUFD	_IO(VFIO_TYPE, VFIO_BASE + 18) + +/* + * VFIO_DEVICE_ATTACH_IOMMUFD_PT - _IOW(VFIO_TYPE, VFIO_BASE + 19, + *					struct vfio_device_attach_iommufd_pt) + * @argsz:	User filled size of this data. + * @flags:	Flags for attach. + * @pt_id:	Input the target id which can represent an ioas or a hwpt + *		allocated via iommufd subsystem. + *		Output the input ioas id or the attached hwpt id which could + *		be the specified hwpt itself or a hwpt automatically created + *		for the specified ioas by kernel during the attachment. + * @pasid:	The pasid to be attached, only meaningful when + *		VFIO_DEVICE_ATTACH_PASID is set in @flags + * + * Associate the device with an address space within the bound iommufd. + * Undo by VFIO_DEVICE_DETACH_IOMMUFD_PT or device fd close.  This is only + * allowed on cdev fds. + * + * If a vfio device or a pasid of this device is currently attached to a valid + * hw_pagetable (hwpt), without doing a VFIO_DEVICE_DETACH_IOMMUFD_PT, a second + * VFIO_DEVICE_ATTACH_IOMMUFD_PT ioctl passing in another hwpt id is allowed. + * This action, also known as a hw_pagetable replacement, will replace the + * currently attached hwpt of the device or the pasid of this device with a new + * hwpt corresponding to the given pt_id. + * + * Return: 0 on success, -errno on failure. + */ +struct vfio_device_attach_iommufd_pt { +	__u32	argsz; +	__u32	flags; +#define VFIO_DEVICE_ATTACH_PASID	(1 << 0) +	__u32	pt_id; +	__u32	pasid; +}; + +#define VFIO_DEVICE_ATTACH_IOMMUFD_PT		_IO(VFIO_TYPE, VFIO_BASE + 19) + +/* + * VFIO_DEVICE_DETACH_IOMMUFD_PT - _IOW(VFIO_TYPE, VFIO_BASE + 20, + *					struct vfio_device_detach_iommufd_pt) + * @argsz:	User filled size of this data. + * @flags:	Flags for detach. + * @pasid:	The pasid to be detached, only meaningful when + *		VFIO_DEVICE_DETACH_PASID is set in @flags + * + * Remove the association of the device or a pasid of the device and its current + * associated address space.  After it, the device or the pasid should be in a + * blocking DMA state.  This is only allowed on cdev fds. + * + * Return: 0 on success, -errno on failure. + */ +struct vfio_device_detach_iommufd_pt { +	__u32	argsz; +	__u32	flags; +#define VFIO_DEVICE_DETACH_PASID	(1 << 0) +	__u32	pasid; +}; + +#define VFIO_DEVICE_DETACH_IOMMUFD_PT		_IO(VFIO_TYPE, VFIO_BASE + 20) + +/*   * Provide support for setting a PCI VF Token, which is used as a shared   * secret between PF and VF drivers.  This feature may only be set on a   * PCI SR-IOV PF when SR-IOV is enabled on the PF and there are no existing @@ -975,6 +1006,478 @@ struct vfio_device_feature {   */  #define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN	(0) +/* + * Indicates the device can support the migration API through + * VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE. If this GET succeeds, the RUNNING and + * ERROR states are always supported. Support for additional states is + * indicated via the flags field; at least VFIO_MIGRATION_STOP_COPY must be + * set. + * + * VFIO_MIGRATION_STOP_COPY means that STOP, STOP_COPY and + * RESUMING are supported. + * + * VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P means that RUNNING_P2P + * is supported in addition to the STOP_COPY states. + * + * VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_PRE_COPY means that + * PRE_COPY is supported in addition to the STOP_COPY states. + * + * VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P | VFIO_MIGRATION_PRE_COPY + * means that RUNNING_P2P, PRE_COPY and PRE_COPY_P2P are supported + * in addition to the STOP_COPY states. + * + * Other combinations of flags have behavior to be defined in the future. + */ +struct vfio_device_feature_migration { +	__aligned_u64 flags; +#define VFIO_MIGRATION_STOP_COPY	(1 << 0) +#define VFIO_MIGRATION_P2P		(1 << 1) +#define VFIO_MIGRATION_PRE_COPY		(1 << 2) +}; +#define VFIO_DEVICE_FEATURE_MIGRATION 1 + +/* + * Upon VFIO_DEVICE_FEATURE_SET, execute a migration state change on the VFIO + * device. The new state is supplied in device_state, see enum + * vfio_device_mig_state for details + * + * The kernel migration driver must fully transition the device to the new state + * value before the operation returns to the user. + * + * The kernel migration driver must not generate asynchronous device state + * transitions outside of manipulation by the user or the VFIO_DEVICE_RESET + * ioctl as described above. + * + * If this function fails then current device_state may be the original + * operating state or some other state along the combination transition path. + * The user can then decide if it should execute a VFIO_DEVICE_RESET, attempt + * to return to the original state, or attempt to return to some other state + * such as RUNNING or STOP. + * + * If the new_state starts a new data transfer session then the FD associated + * with that session is returned in data_fd. The user is responsible to close + * this FD when it is finished. The user must consider the migration data stream + * carried over the FD to be opaque and must preserve the byte order of the + * stream. The user is not required to preserve buffer segmentation when writing + * the data stream during the RESUMING operation. + * + * Upon VFIO_DEVICE_FEATURE_GET, get the current migration state of the VFIO + * device, data_fd will be -1. + */ +struct vfio_device_feature_mig_state { +	__u32 device_state; /* From enum vfio_device_mig_state */ +	__s32 data_fd; +}; +#define VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE 2 + +/* + * The device migration Finite State Machine is described by the enum + * vfio_device_mig_state. Some of the FSM arcs will create a migration data + * transfer session by returning a FD, in this case the migration data will + * flow over the FD using read() and write() as discussed below. + * + * There are 5 states to support VFIO_MIGRATION_STOP_COPY: + *  RUNNING - The device is running normally + *  STOP - The device does not change the internal or external state + *  STOP_COPY - The device internal state can be read out + *  RESUMING - The device is stopped and is loading a new internal state + *  ERROR - The device has failed and must be reset + * + * And optional states to support VFIO_MIGRATION_P2P: + *  RUNNING_P2P - RUNNING, except the device cannot do peer to peer DMA + * And VFIO_MIGRATION_PRE_COPY: + *  PRE_COPY - The device is running normally but tracking internal state + *             changes + * And VFIO_MIGRATION_P2P | VFIO_MIGRATION_PRE_COPY: + *  PRE_COPY_P2P - PRE_COPY, except the device cannot do peer to peer DMA + * + * The FSM takes actions on the arcs between FSM states. The driver implements + * the following behavior for the FSM arcs: + * + * RUNNING_P2P -> STOP + * STOP_COPY -> STOP + *   While in STOP the device must stop the operation of the device. The device + *   must not generate interrupts, DMA, or any other change to external state. + *   It must not change its internal state. When stopped the device and kernel + *   migration driver must accept and respond to interaction to support external + *   subsystems in the STOP state, for example PCI MSI-X and PCI config space. + *   Failure by the user to restrict device access while in STOP must not result + *   in error conditions outside the user context (ex. host system faults). + * + *   The STOP_COPY arc will terminate a data transfer session. + * + * RESUMING -> STOP + *   Leaving RESUMING terminates a data transfer session and indicates the + *   device should complete processing of the data delivered by write(). The + *   kernel migration driver should complete the incorporation of data written + *   to the data transfer FD into the device internal state and perform + *   final validity and consistency checking of the new device state. If the + *   user provided data is found to be incomplete, inconsistent, or otherwise + *   invalid, the migration driver must fail the SET_STATE ioctl and + *   optionally go to the ERROR state as described below. + * + *   While in STOP the device has the same behavior as other STOP states + *   described above. + * + *   To abort a RESUMING session the device must be reset. + * + * PRE_COPY -> RUNNING + * RUNNING_P2P -> RUNNING + *   While in RUNNING the device is fully operational, the device may generate + *   interrupts, DMA, respond to MMIO, all vfio device regions are functional, + *   and the device may advance its internal state. + * + *   The PRE_COPY arc will terminate a data transfer session. + * + * PRE_COPY_P2P -> RUNNING_P2P + * RUNNING -> RUNNING_P2P + * STOP -> RUNNING_P2P + *   While in RUNNING_P2P the device is partially running in the P2P quiescent + *   state defined below. + * + *   The PRE_COPY_P2P arc will terminate a data transfer session. + * + * RUNNING -> PRE_COPY + * RUNNING_P2P -> PRE_COPY_P2P + * STOP -> STOP_COPY + *   PRE_COPY, PRE_COPY_P2P and STOP_COPY form the "saving group" of states + *   which share a data transfer session. Moving between these states alters + *   what is streamed in session, but does not terminate or otherwise affect + *   the associated fd. + * + *   These arcs begin the process of saving the device state and will return a + *   new data_fd. The migration driver may perform actions such as enabling + *   dirty logging of device state when entering PRE_COPY or PER_COPY_P2P. + * + *   Each arc does not change the device operation, the device remains + *   RUNNING, P2P quiesced or in STOP. The STOP_COPY state is described below + *   in PRE_COPY_P2P -> STOP_COPY. + * + * PRE_COPY -> PRE_COPY_P2P + *   Entering PRE_COPY_P2P continues all the behaviors of PRE_COPY above. + *   However, while in the PRE_COPY_P2P state, the device is partially running + *   in the P2P quiescent state defined below, like RUNNING_P2P. + * + * PRE_COPY_P2P -> PRE_COPY + *   This arc allows returning the device to a full RUNNING behavior while + *   continuing all the behaviors of PRE_COPY. + * + * PRE_COPY_P2P -> STOP_COPY + *   While in the STOP_COPY state the device has the same behavior as STOP + *   with the addition that the data transfers session continues to stream the + *   migration state. End of stream on the FD indicates the entire device + *   state has been transferred. + * + *   The user should take steps to restrict access to vfio device regions while + *   the device is in STOP_COPY or risk corruption of the device migration data + *   stream. + * + * STOP -> RESUMING + *   Entering the RESUMING state starts a process of restoring the device state + *   and will return a new data_fd. The data stream fed into the data_fd should + *   be taken from the data transfer output of a single FD during saving from + *   a compatible device. The migration driver may alter/reset the internal + *   device state for this arc if required to prepare the device to receive the + *   migration data. + * + * STOP_COPY -> PRE_COPY + * STOP_COPY -> PRE_COPY_P2P + *   These arcs are not permitted and return error if requested. Future + *   revisions of this API may define behaviors for these arcs, in this case + *   support will be discoverable by a new flag in + *   VFIO_DEVICE_FEATURE_MIGRATION. + * + * any -> ERROR + *   ERROR cannot be specified as a device state, however any transition request + *   can be failed with an errno return and may then move the device_state into + *   ERROR. In this case the device was unable to execute the requested arc and + *   was also unable to restore the device to any valid device_state. + *   To recover from ERROR VFIO_DEVICE_RESET must be used to return the + *   device_state back to RUNNING. + * + * The optional peer to peer (P2P) quiescent state is intended to be a quiescent + * state for the device for the purposes of managing multiple devices within a + * user context where peer-to-peer DMA between devices may be active. The + * RUNNING_P2P and PRE_COPY_P2P states must prevent the device from initiating + * any new P2P DMA transactions. If the device can identify P2P transactions + * then it can stop only P2P DMA, otherwise it must stop all DMA. The migration + * driver must complete any such outstanding operations prior to completing the + * FSM arc into a P2P state. For the purpose of specification the states + * behave as though the device was fully running if not supported. Like while in + * STOP or STOP_COPY the user must not touch the device, otherwise the state + * can be exited. + * + * The remaining possible transitions are interpreted as combinations of the + * above FSM arcs. As there are multiple paths through the FSM arcs the path + * should be selected based on the following rules: + *   - Select the shortest path. + *   - The path cannot have saving group states as interior arcs, only + *     starting/end states. + * Refer to vfio_mig_get_next_state() for the result of the algorithm. + * + * The automatic transit through the FSM arcs that make up the combination + * transition is invisible to the user. When working with combination arcs the + * user may see any step along the path in the device_state if SET_STATE + * fails. When handling these types of errors users should anticipate future + * revisions of this protocol using new states and those states becoming + * visible in this case. + * + * The optional states cannot be used with SET_STATE if the device does not + * support them. The user can discover if these states are supported by using + * VFIO_DEVICE_FEATURE_MIGRATION. By using combination transitions the user can + * avoid knowing about these optional states if the kernel driver supports them. + * + * Arcs touching PRE_COPY and PRE_COPY_P2P are removed if support for PRE_COPY + * is not present. + */ +enum vfio_device_mig_state { +	VFIO_DEVICE_STATE_ERROR = 0, +	VFIO_DEVICE_STATE_STOP = 1, +	VFIO_DEVICE_STATE_RUNNING = 2, +	VFIO_DEVICE_STATE_STOP_COPY = 3, +	VFIO_DEVICE_STATE_RESUMING = 4, +	VFIO_DEVICE_STATE_RUNNING_P2P = 5, +	VFIO_DEVICE_STATE_PRE_COPY = 6, +	VFIO_DEVICE_STATE_PRE_COPY_P2P = 7, +	VFIO_DEVICE_STATE_NR, +}; + +/** + * VFIO_MIG_GET_PRECOPY_INFO - _IO(VFIO_TYPE, VFIO_BASE + 21) + * + * This ioctl is used on the migration data FD in the precopy phase of the + * migration data transfer. It returns an estimate of the current data sizes + * remaining to be transferred. It allows the user to judge when it is + * appropriate to leave PRE_COPY for STOP_COPY. + * + * This ioctl is valid only in PRE_COPY states and kernel driver should + * return -EINVAL from any other migration state. + * + * The vfio_precopy_info data structure returned by this ioctl provides + * estimates of data available from the device during the PRE_COPY states. + * This estimate is split into two categories, initial_bytes and + * dirty_bytes. + * + * The initial_bytes field indicates the amount of initial precopy + * data available from the device. This field should have a non-zero initial + * value and decrease as migration data is read from the device. + * It is recommended to leave PRE_COPY for STOP_COPY only after this field + * reaches zero. Leaving PRE_COPY earlier might make things slower. + * + * The dirty_bytes field tracks device state changes relative to data + * previously retrieved.  This field starts at zero and may increase as + * the internal device state is modified or decrease as that modified + * state is read from the device. + * + * Userspace may use the combination of these fields to estimate the + * potential data size available during the PRE_COPY phases, as well as + * trends relative to the rate the device is dirtying its internal + * state, but these fields are not required to have any bearing relative + * to the data size available during the STOP_COPY phase. + * + * Drivers have a lot of flexibility in when and what they transfer during the + * PRE_COPY phase, and how they report this from VFIO_MIG_GET_PRECOPY_INFO. + * + * During pre-copy the migration data FD has a temporary "end of stream" that is + * reached when both initial_bytes and dirty_byte are zero. For instance, this + * may indicate that the device is idle and not currently dirtying any internal + * state. When read() is done on this temporary end of stream the kernel driver + * should return ENOMSG from read(). Userspace can wait for more data (which may + * never come) by using poll. + * + * Once in STOP_COPY the migration data FD has a permanent end of stream + * signaled in the usual way by read() always returning 0 and poll always + * returning readable. ENOMSG may not be returned in STOP_COPY. + * Support for this ioctl is mandatory if a driver claims to support + * VFIO_MIGRATION_PRE_COPY. + * + * Return: 0 on success, -1 and errno set on failure. + */ +struct vfio_precopy_info { +	__u32 argsz; +	__u32 flags; +	__aligned_u64 initial_bytes; +	__aligned_u64 dirty_bytes; +}; + +#define VFIO_MIG_GET_PRECOPY_INFO _IO(VFIO_TYPE, VFIO_BASE + 21) + +/* + * Upon VFIO_DEVICE_FEATURE_SET, allow the device to be moved into a low power + * state with the platform-based power management.  Device use of lower power + * states depends on factors managed by the runtime power management core, + * including system level support and coordinating support among dependent + * devices.  Enabling device low power entry does not guarantee lower power + * usage by the device, nor is a mechanism provided through this feature to + * know the current power state of the device.  If any device access happens + * (either from the host or through the vfio uAPI) when the device is in the + * low power state, then the host will move the device out of the low power + * state as necessary prior to the access.  Once the access is completed, the + * device may re-enter the low power state.  For single shot low power support + * with wake-up notification, see + * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP below.  Access to mmap'd + * device regions is disabled on LOW_POWER_ENTRY and may only be resumed after + * calling LOW_POWER_EXIT. + */ +#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY 3 + +/* + * This device feature has the same behavior as + * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY with the exception that the user + * provides an eventfd for wake-up notification.  When the device moves out of + * the low power state for the wake-up, the host will not allow the device to + * re-enter a low power state without a subsequent user call to one of the low + * power entry device feature IOCTLs.  Access to mmap'd device regions is + * disabled on LOW_POWER_ENTRY_WITH_WAKEUP and may only be resumed after the + * low power exit.  The low power exit can happen either through LOW_POWER_EXIT + * or through any other access (where the wake-up notification has been + * generated).  The access to mmap'd device regions will not trigger low power + * exit. + * + * The notification through the provided eventfd will be generated only when + * the device has entered and is resumed from a low power state after + * calling this device feature IOCTL.  A device that has not entered low power + * state, as managed through the runtime power management core, will not + * generate a notification through the provided eventfd on access.  Calling the + * LOW_POWER_EXIT feature is optional in the case where notification has been + * signaled on the provided eventfd that a resume from low power has occurred. + */ +struct vfio_device_low_power_entry_with_wakeup { +	__s32 wakeup_eventfd; +	__u32 reserved; +}; + +#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP 4 + +/* + * Upon VFIO_DEVICE_FEATURE_SET, disallow use of device low power states as + * previously enabled via VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY or + * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP device features. + * This device feature IOCTL may itself generate a wakeup eventfd notification + * in the latter case if the device had previously entered a low power state. + */ +#define VFIO_DEVICE_FEATURE_LOW_POWER_EXIT 5 + +/* + * Upon VFIO_DEVICE_FEATURE_SET start/stop device DMA logging. + * VFIO_DEVICE_FEATURE_PROBE can be used to detect if the device supports + * DMA logging. + * + * DMA logging allows a device to internally record what DMAs the device is + * initiating and report them back to userspace. It is part of the VFIO + * migration infrastructure that allows implementing dirty page tracking + * during the pre copy phase of live migration. Only DMA WRITEs are logged, + * and this API is not connected to VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE. + * + * When DMA logging is started a range of IOVAs to monitor is provided and the + * device can optimize its logging to cover only the IOVA range given. Each + * DMA that the device initiates inside the range will be logged by the device + * for later retrieval. + * + * page_size is an input that hints what tracking granularity the device + * should try to achieve. If the device cannot do the hinted page size then + * it's the driver choice which page size to pick based on its support. + * On output the device will return the page size it selected. + * + * ranges is a pointer to an array of + * struct vfio_device_feature_dma_logging_range. + * + * The core kernel code guarantees to support by minimum num_ranges that fit + * into a single kernel page. User space can try higher values but should give + * up if the above can't be achieved as of some driver limitations. + * + * A single call to start device DMA logging can be issued and a matching stop + * should follow at the end. Another start is not allowed in the meantime. + */ +struct vfio_device_feature_dma_logging_control { +	__aligned_u64 page_size; +	__u32 num_ranges; +	__u32 __reserved; +	__aligned_u64 ranges; +}; + +struct vfio_device_feature_dma_logging_range { +	__aligned_u64 iova; +	__aligned_u64 length; +}; + +#define VFIO_DEVICE_FEATURE_DMA_LOGGING_START 6 + +/* + * Upon VFIO_DEVICE_FEATURE_SET stop device DMA logging that was started + * by VFIO_DEVICE_FEATURE_DMA_LOGGING_START + */ +#define VFIO_DEVICE_FEATURE_DMA_LOGGING_STOP 7 + +/* + * Upon VFIO_DEVICE_FEATURE_GET read back and clear the device DMA log + * + * Query the device's DMA log for written pages within the given IOVA range. + * During querying the log is cleared for the IOVA range. + * + * bitmap is a pointer to an array of u64s that will hold the output bitmap + * with 1 bit reporting a page_size unit of IOVA. The mapping of IOVA to bits + * is given by: + *  bitmap[(addr - iova)/page_size] & (1ULL << (addr % 64)) + * + * The input page_size can be any power of two value and does not have to + * match the value given to VFIO_DEVICE_FEATURE_DMA_LOGGING_START. The driver + * will format its internal logging to match the reporting page size, possibly + * by replicating bits if the internal page size is lower than requested. + * + * The LOGGING_REPORT will only set bits in the bitmap and never clear or + * perform any initialization of the user provided bitmap. + * + * If any error is returned userspace should assume that the dirty log is + * corrupted. Error recovery is to consider all memory dirty and try to + * restart the dirty tracking, or to abort/restart the whole migration. + * + * If DMA logging is not enabled, an error will be returned. + * + */ +struct vfio_device_feature_dma_logging_report { +	__aligned_u64 iova; +	__aligned_u64 length; +	__aligned_u64 page_size; +	__aligned_u64 bitmap; +}; + +#define VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT 8 + +/* + * Upon VFIO_DEVICE_FEATURE_GET read back the estimated data length that will + * be required to complete stop copy. + * + * Note: Can be called on each device state. + */ + +struct vfio_device_feature_mig_data_size { +	__aligned_u64 stop_copy_length; +}; + +#define VFIO_DEVICE_FEATURE_MIG_DATA_SIZE 9 + +/** + * Upon VFIO_DEVICE_FEATURE_SET, set or clear the BUS mastering for the device + * based on the operation specified in op flag. + * + * The functionality is incorporated for devices that needs bus master control, + * but the in-band device interface lacks the support. Consequently, it is not + * applicable to PCI devices, as bus master control for PCI devices is managed + * in-band through the configuration space. At present, this feature is supported + * only for CDX devices. + * When the device's BUS MASTER setting is configured as CLEAR, it will result in + * blocking all incoming DMA requests from the device. On the other hand, configuring + * the device's BUS MASTER setting as SET (enable) will grant the device the + * capability to perform DMA to the host memory. + */ +struct vfio_device_feature_bus_master { +	__u32 op; +#define		VFIO_DEVICE_FEATURE_CLEAR_MASTER	0	/* Clear Bus Master */ +#define		VFIO_DEVICE_FEATURE_SET_MASTER		1	/* Set Bus Master */ +}; +#define VFIO_DEVICE_FEATURE_BUS_MASTER 10 +  /* -------- API for Type1 VFIO IOMMU -------- */  /** @@ -990,8 +1493,9 @@ struct vfio_iommu_type1_info {  	__u32	flags;  #define VFIO_IOMMU_INFO_PGSIZES (1 << 0)	/* supported page sizes info */  #define VFIO_IOMMU_INFO_CAPS	(1 << 1)	/* Info supports caps */ -	__u64	iova_pgsizes;	/* Bitmap of supported page sizes */ +	__aligned_u64	iova_pgsizes;		/* Bitmap of supported page sizes */  	__u32   cap_offset;	/* Offset within info struct of first cap */ +	__u32   pad;  };  /* @@ -1039,6 +1543,21 @@ struct vfio_iommu_type1_info_cap_migration {  	__u64	max_dirty_bitmap_size;		/* in bytes */  }; +/* + * The DMA available capability allows to report the current number of + * simultaneously outstanding DMA mappings that are allowed. + * + * The structure below defines version 1 of this capability. + * + * avail: specifies the current number of outstanding DMA mappings allowed. + */ +#define VFIO_IOMMU_TYPE1_INFO_DMA_AVAIL 3 + +struct vfio_iommu_type1_info_dma_avail { +	struct	vfio_info_cap_header header; +	__u32	avail; +}; +  #define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)  /** @@ -1046,12 +1565,21 @@ struct vfio_iommu_type1_info_cap_migration {   *   * Map process virtual addresses to IO virtual addresses using the   * provided struct vfio_dma_map. Caller sets argsz. READ &/ WRITE required. + * + * If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova. The vaddr + * must have previously been invalidated with VFIO_DMA_UNMAP_FLAG_VADDR.  To + * maintain memory consistency within the user application, the updated vaddr + * must address the same memory object as originally mapped.  Failure to do so + * will result in user memory corruption and/or device misbehavior.  iova and + * size must match those in the original MAP_DMA call.  Protection is not + * changed, and the READ & WRITE flags must be 0.   */  struct vfio_iommu_type1_dma_map {  	__u32	argsz;  	__u32	flags;  #define VFIO_DMA_MAP_FLAG_READ (1 << 0)		/* readable from device */  #define VFIO_DMA_MAP_FLAG_WRITE (1 << 1)	/* writable from device */ +#define VFIO_DMA_MAP_FLAG_VADDR (1 << 2)  	__u64	vaddr;				/* Process virtual address */  	__u64	iova;				/* IO virtual address */  	__u64	size;				/* Size of mapping (bytes) */ @@ -1074,6 +1602,7 @@ struct vfio_bitmap {   * field.  No guarantee is made to the user that arbitrary unmaps of iova   * or size different from those used in the original mapping call will   * succeed. + *   * VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP should be set to get the dirty bitmap   * before unmapping IO virtual addresses. When this flag is set, the user must   * provide a struct vfio_bitmap in data[]. User must provide zero-allocated @@ -1083,11 +1612,21 @@ struct vfio_bitmap {   * indicates that the page at that offset from iova is dirty. A Bitmap of the   * pages in the range of unmapped size is returned in the user-provided   * vfio_bitmap.data. + * + * If flags & VFIO_DMA_UNMAP_FLAG_ALL, unmap all addresses.  iova and size + * must be 0.  This cannot be combined with the get-dirty-bitmap flag. + * + * If flags & VFIO_DMA_UNMAP_FLAG_VADDR, do not unmap, but invalidate host + * virtual addresses in the iova range.  DMA to already-mapped pages continues. + * Groups may not be added to the container while any addresses are invalid. + * This cannot be combined with the get-dirty-bitmap flag.   */  struct vfio_iommu_type1_dma_unmap {  	__u32	argsz;  	__u32	flags;  #define VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP (1 << 0) +#define VFIO_DMA_UNMAP_FLAG_ALL		     (1 << 1) +#define VFIO_DMA_UNMAP_FLAG_VADDR	     (1 << 2)  	__u64	iova;				/* IO virtual address */  	__u64	size;				/* Size of mapping (bytes) */  	__u8    data[]; diff --git a/include/uapi/linux/vfio_zdev.h b/include/uapi/linux/vfio_zdev.h new file mode 100644 index 000000000000..77f2aff1f27e --- /dev/null +++ b/include/uapi/linux/vfio_zdev.h @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * VFIO Region definitions for ZPCI devices + * + * Copyright IBM Corp. 2020 + * + * Author(s): Pierre Morel <pmorel@linux.ibm.com> + *            Matthew Rosato <mjrosato@linux.ibm.com> + */ + +#ifndef _VFIO_ZDEV_H_ +#define _VFIO_ZDEV_H_ + +#include <linux/types.h> +#include <linux/vfio.h> + +/** + * VFIO_DEVICE_INFO_CAP_ZPCI_BASE - Base PCI Function information + * + * This capability provides a set of descriptive information about the + * associated PCI function. + */ +struct vfio_device_info_cap_zpci_base { +	struct vfio_info_cap_header header; +	__u64 start_dma;	/* Start of available DMA addresses */ +	__u64 end_dma;		/* End of available DMA addresses */ +	__u16 pchid;		/* Physical Channel ID */ +	__u16 vfn;		/* Virtual function number */ +	__u16 fmb_length;	/* Measurement Block Length (in bytes) */ +	__u8 pft;		/* PCI Function Type */ +	__u8 gid;		/* PCI function group ID */ +	/* End of version 1 */ +	__u32 fh;		/* PCI function handle */ +	/* End of version 2 */ +}; + +/** + * VFIO_DEVICE_INFO_CAP_ZPCI_GROUP - Base PCI Function Group information + * + * This capability provides a set of descriptive information about the group of + * PCI functions that the associated device belongs to. + */ +struct vfio_device_info_cap_zpci_group { +	struct vfio_info_cap_header header; +	__u64 dasm;		/* DMA Address space mask */ +	__u64 msi_addr;		/* MSI address */ +	__u64 flags; +#define VFIO_DEVICE_INFO_ZPCI_FLAG_REFRESH 1 /* Program-specified TLB refresh */ +	__u16 mui;		/* Measurement Block Update Interval */ +	__u16 noi;		/* Maximum number of MSIs */ +	__u16 maxstbl;		/* Maximum Store Block Length */ +	__u8 version;		/* Supported PCI Version */ +	/* End of version 1 */ +	__u8 reserved; +	__u16 imaxstbl;		/* Maximum Interpreted Store Block Length */ +	/* End of version 2 */ +}; + +/** + * VFIO_DEVICE_INFO_CAP_ZPCI_UTIL - Utility String + * + * This capability provides the utility string for the associated device, which + * is a device identifier string made up of EBCDID characters.  'size' specifies + * the length of 'util_str'. + */ +struct vfio_device_info_cap_zpci_util { +	struct vfio_info_cap_header header; +	__u32 size; +	__u8 util_str[]; +}; + +/** + * VFIO_DEVICE_INFO_CAP_ZPCI_PFIP - PCI Function Path + * + * This capability provides the PCI function path string, which is an identifier + * that describes the internal hardware path of the device. 'size' specifies + * the length of 'pfip'. + */ +struct vfio_device_info_cap_zpci_pfip { +	struct vfio_info_cap_header header; +	__u32 size; +	__u8 pfip[]; +}; + +#endif diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index 75232185324a..c57674a6aa0d 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -28,10 +28,10 @@  /* Set current process as the (exclusive) owner of this file descriptor.  This   * must be called before any other vhost command.  Further calls to - * VHOST_OWNER_SET fail until VHOST_OWNER_RESET is called. */ + * VHOST_SET_OWNER fail until VHOST_RESET_OWNER is called. */  #define VHOST_SET_OWNER _IO(VHOST_VIRTIO, 0x01)  /* Give up ownership, and reset the device to default values. - * Allows subsequent call to VHOST_OWNER_SET to succeed. */ + * Allows subsequent call to VHOST_SET_OWNER to succeed. */  #define VHOST_RESET_OWNER _IO(VHOST_VIRTIO, 0x02)  /* Set up/modify memory layout */ @@ -45,6 +45,25 @@  #define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64)  /* Specify an eventfd file descriptor to signal on log write. */  #define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int) +/* By default, a device gets one vhost_worker that its virtqueues share. This + * command allows the owner of the device to create an additional vhost_worker + * for the device. It can later be bound to 1 or more of its virtqueues using + * the VHOST_ATTACH_VRING_WORKER command. + * + * This must be called after VHOST_SET_OWNER and the caller must be the owner + * of the device. The new thread will inherit caller's cgroups and namespaces, + * and will share the caller's memory space. The new thread will also be + * counted against the caller's RLIMIT_NPROC value. + * + * The worker's ID used in other commands will be returned in + * vhost_worker_state. + */ +#define VHOST_NEW_WORKER _IOR(VHOST_VIRTIO, 0x8, struct vhost_worker_state) +/* Free a worker created with VHOST_NEW_WORKER if it's not attached to any + * virtqueue. If userspace is not able to call this for workers its created, + * the kernel will free all the device's workers when the device is closed. + */ +#define VHOST_FREE_WORKER _IOW(VHOST_VIRTIO, 0x9, struct vhost_worker_state)  /* Ring setup. */  /* Set number of descriptors in ring. This parameter can not @@ -70,6 +89,18 @@  #define VHOST_VRING_BIG_ENDIAN 1  #define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state)  #define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state) +/* Attach a vhost_worker created with VHOST_NEW_WORKER to one of the device's + * virtqueues. + * + * This will replace the virtqueue's existing worker. If the replaced worker + * is no longer attached to any virtqueues, it can be freed with + * VHOST_FREE_WORKER. + */ +#define VHOST_ATTACH_VRING_WORKER _IOW(VHOST_VIRTIO, 0x15,		\ +				       struct vhost_vring_worker) +/* Return the vring worker's ID */ +#define VHOST_GET_VRING_WORKER _IOWR(VHOST_VIRTIO, 0x16,		\ +				     struct vhost_vring_worker)  /* The following ioctls use eventfd file descriptors to signal and poll   * for events. */ @@ -89,11 +120,6 @@  /* Set or get vhost backend capability */ -/* Use message type V2 */ -#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 -/* IOTLB can accept batching hints */ -#define VHOST_BACKEND_F_IOTLB_BATCH  0x2 -  #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)  #define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) @@ -146,4 +172,102 @@  /* Set event fd for config interrupt*/  #define VHOST_VDPA_SET_CONFIG_CALL	_IOW(VHOST_VIRTIO, 0x77, int) + +/* Get the valid iova range */ +#define VHOST_VDPA_GET_IOVA_RANGE	_IOR(VHOST_VIRTIO, 0x78, \ +					     struct vhost_vdpa_iova_range) +/* Get the config size */ +#define VHOST_VDPA_GET_CONFIG_SIZE	_IOR(VHOST_VIRTIO, 0x79, __u32) + +/* Get the number of address spaces. */ +#define VHOST_VDPA_GET_AS_NUM		_IOR(VHOST_VIRTIO, 0x7A, unsigned int) + +/* Get the group for a virtqueue: read index, write group in num, + * The virtqueue index is stored in the index field of + * vhost_vring_state. The group for this specific virtqueue is + * returned via num field of vhost_vring_state. + */ +#define VHOST_VDPA_GET_VRING_GROUP	_IOWR(VHOST_VIRTIO, 0x7B,	\ +					      struct vhost_vring_state) +/* Set the ASID for a virtqueue group. The group index is stored in + * the index field of vhost_vring_state, the ASID associated with this + * group is stored at num field of vhost_vring_state. + */ +#define VHOST_VDPA_SET_GROUP_ASID	_IOW(VHOST_VIRTIO, 0x7C, \ +					     struct vhost_vring_state) + +/* Suspend a device so it does not process virtqueue requests anymore + * + * After the return of ioctl the device must preserve all the necessary state + * (the virtqueue vring base plus the possible device specific states) that is + * required for restoring in the future. The device must not change its + * configuration after that point. + */ +#define VHOST_VDPA_SUSPEND		_IO(VHOST_VIRTIO, 0x7D) + +/* Resume a device so it can resume processing virtqueue requests + * + * After the return of this ioctl the device will have restored all the + * necessary states and it is fully operational to continue processing the + * virtqueue descriptors. + */ +#define VHOST_VDPA_RESUME		_IO(VHOST_VIRTIO, 0x7E) + +/* Get the group for the descriptor table including driver & device areas + * of a virtqueue: read index, write group in num. + * The virtqueue index is stored in the index field of vhost_vring_state. + * The group ID of the descriptor table for this specific virtqueue + * is returned via num field of vhost_vring_state. + */ +#define VHOST_VDPA_GET_VRING_DESC_GROUP	_IOWR(VHOST_VIRTIO, 0x7F,	\ +					      struct vhost_vring_state) + + +/* Get the count of all virtqueues */ +#define VHOST_VDPA_GET_VQS_COUNT	_IOR(VHOST_VIRTIO, 0x80, __u32) + +/* Get the number of virtqueue groups. */ +#define VHOST_VDPA_GET_GROUP_NUM	_IOR(VHOST_VIRTIO, 0x81, __u32) + +/* Get the queue size of a specific virtqueue. + * userspace set the vring index in vhost_vring_state.index + * kernel set the queue size in vhost_vring_state.num + */ +#define VHOST_VDPA_GET_VRING_SIZE	_IOWR(VHOST_VIRTIO, 0x82,	\ +					      struct vhost_vring_state) + +/* Extended features manipulation */ +#define VHOST_GET_FEATURES_ARRAY _IOR(VHOST_VIRTIO, 0x83, \ +				       struct vhost_features_array) +#define VHOST_SET_FEATURES_ARRAY _IOW(VHOST_VIRTIO, 0x83, \ +				       struct vhost_features_array) + +/* fork_owner values for vhost */ +#define VHOST_FORK_OWNER_KTHREAD 0 +#define VHOST_FORK_OWNER_TASK 1 + +/** + * VHOST_SET_FORK_FROM_OWNER - Set the fork_owner flag for the vhost device, + * This ioctl must called before VHOST_SET_OWNER. + * Only available when CONFIG_VHOST_ENABLE_FORK_OWNER_CONTROL=y + * + * @param fork_owner: An 8-bit value that determines the vhost thread mode + * + * When fork_owner is set to VHOST_FORK_OWNER_TASK(default value): + *   - Vhost will create vhost worker as tasks forked from the owner, + *     inheriting all of the owner's attributes. + * + * When fork_owner is set to VHOST_FORK_OWNER_KTHREAD: + *   - Vhost will create vhost workers as kernel threads. + */ +#define VHOST_SET_FORK_FROM_OWNER _IOW(VHOST_VIRTIO, 0x84, __u8) + +/** + * VHOST_GET_FORK_OWNER - Get the current fork_owner flag for the vhost device. + * Only available when CONFIG_VHOST_ENABLE_FORK_OWNER_CONTROL=y + * + * @return: An 8-bit value indicating the current thread mode. + */ +#define VHOST_GET_FORK_FROM_OWNER _IOR(VHOST_VIRTIO, 0x85, __u8) +  #endif diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h index 9a269a88a6ff..1c39cc5f5a31 100644 --- a/include/uapi/linux/vhost_types.h +++ b/include/uapi/linux/vhost_types.h @@ -47,6 +47,22 @@ struct vhost_vring_addr {  	__u64 log_guest_addr;  }; +struct vhost_worker_state { +	/* +	 * For VHOST_NEW_WORKER the kernel will return the new vhost_worker id. +	 * For VHOST_FREE_WORKER this must be set to the id of the vhost_worker +	 * to free. +	 */ +	unsigned int worker_id; +}; + +struct vhost_vring_worker { +	/* vring index */ +	unsigned int index; +	/* The id of the vhost_worker returned from VHOST_NEW_WORKER */ +	unsigned int worker_id; +}; +  /* no alignment requirement */  struct vhost_iotlb_msg {  	__u64 iova; @@ -87,13 +103,18 @@ struct vhost_msg {  struct vhost_msg_v2 {  	__u32 type; -	__u32 reserved; +	__u32 asid;  	union {  		struct vhost_iotlb_msg iotlb;  		__u8 padding[64];  	};  }; +struct vhost_features_array { +	__u64 count; /* number of entries present in features array */ +	__u64 features[] __counted_by(count); +}; +  struct vhost_memory_region {  	__u64 guest_phys_addr;  	__u64 memory_size; /* bytes */ @@ -107,7 +128,7 @@ struct vhost_memory_region {  struct vhost_memory {  	__u32 nregions;  	__u32 padding; -	struct vhost_memory_region regions[0]; +	struct vhost_memory_region regions[];  };  /* VHOST_SCSI specific definitions */ @@ -135,7 +156,16 @@ struct vhost_scsi_target {  struct vhost_vdpa_config {  	__u32 off;  	__u32 len; -	__u8 buf[0]; +	__u8 buf[]; +}; + +/* vhost vdpa IOVA range + * @first: First address that can be mapped by vhost-vDPA + * @last: Last address that can be mapped by vhost-vDPA + */ +struct vhost_vdpa_iova_range { +	__u64 first; +	__u64 last;  };  /* Feature bits */ @@ -144,4 +174,28 @@ struct vhost_vdpa_config {  /* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */  #define VHOST_NET_F_VIRTIO_NET_HDR 27 +/* Use message type V2 */ +#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 +/* IOTLB can accept batching hints */ +#define VHOST_BACKEND_F_IOTLB_BATCH  0x2 +/* IOTLB can accept address space identifier through V2 type of IOTLB + * message + */ +#define VHOST_BACKEND_F_IOTLB_ASID  0x3 +/* Device can be suspended */ +#define VHOST_BACKEND_F_SUSPEND  0x4 +/* Device can be resumed */ +#define VHOST_BACKEND_F_RESUME  0x5 +/* Device supports the driver enabling virtqueues both before and after + * DRIVER_OK + */ +#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK  0x6 +/* Device may expose the virtqueue's descriptor area, driver area and + * device area to a different group for ASID binding than where its + * buffers may reside. Requires VHOST_BACKEND_F_IOTLB_ASID. + */ +#define VHOST_BACKEND_F_DESC_ASID    0x7 +/* IOTLB don't flush memory mapping across device reset */ +#define VHOST_BACKEND_F_IOTLB_PERSIST  0x8 +  #endif diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index c7b70ff53bc1..3dd9fa45dde1 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -153,10 +153,18 @@ enum v4l2_buf_type {  	V4L2_BUF_TYPE_SDR_OUTPUT           = 12,  	V4L2_BUF_TYPE_META_CAPTURE         = 13,  	V4L2_BUF_TYPE_META_OUTPUT	   = 14, +	/* +	 * Note: V4L2_TYPE_IS_VALID and V4L2_TYPE_IS_OUTPUT must +	 * be updated if a new type is added. +	 */  	/* Deprecated, do not use */  	V4L2_BUF_TYPE_PRIVATE              = 0x80,  }; +#define V4L2_TYPE_IS_VALID(type)		 \ +	((type) >= V4L2_BUF_TYPE_VIDEO_CAPTURE &&\ +	 (type) <= V4L2_BUF_TYPE_META_OUTPUT) +  #define V4L2_TYPE_IS_MULTIPLANAR(type)			\  	((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE	\  	 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) @@ -164,14 +172,14 @@ enum v4l2_buf_type {  #define V4L2_TYPE_IS_OUTPUT(type)				\  	((type) == V4L2_BUF_TYPE_VIDEO_OUTPUT			\  	 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE		\ -	 || (type) == V4L2_BUF_TYPE_VIDEO_OVERLAY		\  	 || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY	\  	 || (type) == V4L2_BUF_TYPE_VBI_OUTPUT			\  	 || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT		\  	 || (type) == V4L2_BUF_TYPE_SDR_OUTPUT			\  	 || (type) == V4L2_BUF_TYPE_META_OUTPUT) -#define V4L2_TYPE_IS_CAPTURE(type) (!V4L2_TYPE_IS_OUTPUT(type)) +#define V4L2_TYPE_IS_CAPTURE(type)	\ +	(V4L2_TYPE_IS_VALID(type) && !V4L2_TYPE_IS_OUTPUT(type))  enum v4l2_tuner_type {  	V4L2_TUNER_RADIO	     = 1, @@ -191,8 +199,6 @@ enum v4l2_memory {  	V4L2_MEMORY_DMABUF           = 4,  }; -#define V4L2_FLAG_MEMORY_NON_CONSISTENT		(1 << 0) -  /* see also http://vektor.theorem.ca/graphics/ycbcr/ */  enum v4l2_colorspace {  	/* @@ -223,9 +229,7 @@ enum v4l2_colorspace {  	V4L2_COLORSPACE_470_SYSTEM_M  = 5,  	/* -	 * EBU Tech 3213 PAL/SECAM colorspace. This only makes sense when -	 * dealing with really old PAL/SECAM recordings. Superseded by -	 * SMPTE 170M. +	 * EBU Tech 3213 PAL/SECAM colorspace.  	 */  	V4L2_COLORSPACE_470_SYSTEM_BG = 6, @@ -249,6 +253,14 @@ enum v4l2_colorspace {  	/* DCI-P3 colorspace, used by cinema projectors */  	V4L2_COLORSPACE_DCI_P3        = 12, + +#ifdef __KERNEL__ +	/* +	 * Largest supported colorspace value, assigned by the compiler, used +	 * by the framework to check for invalid values. +	 */ +	V4L2_COLORSPACE_LAST, +#endif  };  /* @@ -287,6 +299,13 @@ enum v4l2_xfer_func {  	V4L2_XFER_FUNC_NONE        = 5,  	V4L2_XFER_FUNC_DCI_P3      = 6,  	V4L2_XFER_FUNC_SMPTE2084   = 7, +#ifdef __KERNEL__ +	/* +	 * Largest supported transfer function value, assigned by the compiler, +	 * used by the framework to check for invalid values. +	 */ +	V4L2_XFER_FUNC_LAST, +#endif  };  /* @@ -347,6 +366,13 @@ enum v4l2_ycbcr_encoding {  	/* SMPTE 240M -- Obsolete HDTV */  	V4L2_YCBCR_ENC_SMPTE240M      = 8, +#ifdef __KERNEL__ +	/* +	 * Largest supported encoding value, assigned by the compiler, used by +	 * the framework to check for invalid values. +	 */ +	V4L2_YCBCR_ENC_LAST, +#endif  };  /* @@ -375,9 +401,9 @@ enum v4l2_hsv_encoding {  enum v4l2_quantization {  	/* -	 * The default for R'G'B' quantization is always full range, except -	 * for the BT2020 colorspace. For Y'CbCr the quantization is always -	 * limited range, except for COLORSPACE_JPEG: this is full range. +	 * The default for R'G'B' quantization is always full range. +	 * For Y'CbCr the quantization is always limited range, except +	 * for COLORSPACE_JPEG: this is full range.  	 */  	V4L2_QUANTIZATION_DEFAULT     = 0,  	V4L2_QUANTIZATION_FULL_RANGE  = 1, @@ -386,14 +412,13 @@ enum v4l2_quantization {  /*   * Determine how QUANTIZATION_DEFAULT should map to a proper quantization. - * This depends on whether the image is RGB or not, the colorspace and the - * Y'CbCr encoding. + * This depends on whether the image is RGB or not, the colorspace. + * The Y'CbCr encoding is not used anymore, but is still there for backwards + * compatibility.   */  #define V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb_or_hsv, colsp, ycbcr_enc) \ -	(((is_rgb_or_hsv) && (colsp) == V4L2_COLORSPACE_BT2020) ? \ -	 V4L2_QUANTIZATION_LIM_RANGE : \ -	 (((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \ -	 V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)) +	(((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \ +	 V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)  /*   * Deprecated names for opRGB colorspace (IEC 61966-2-5) @@ -485,7 +510,7 @@ struct v4l2_capability {  #define V4L2_CAP_META_CAPTURE		0x00800000  /* Is a metadata capture device */  #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */ -#define V4L2_CAP_ASYNCIO                0x02000000  /* async I/O */ +#define V4L2_CAP_EDID			0x02000000  /* Is an EDID-only device */  #define V4L2_CAP_STREAMING              0x04000000  /* streaming I/O ioctls */  #define V4L2_CAP_META_OUTPUT		0x08000000  /* Is a metadata output device */ @@ -520,7 +545,7 @@ struct v4l2_pix_format {  /*      Pixel format         FOURCC                          depth  Description  */ -/* RGB formats */ +/* RGB formats (1 or 2 bytes per pixel) */  #define V4L2_PIX_FMT_RGB332  v4l2_fourcc('R', 'G', 'B', '1') /*  8  RGB-3-3-2     */  #define V4L2_PIX_FMT_RGB444  v4l2_fourcc('R', '4', '4', '4') /* 16  xxxxrrrr ggggbbbb */  #define V4L2_PIX_FMT_ARGB444 v4l2_fourcc('A', 'R', '1', '2') /* 16  aaaarrrr ggggbbbb */ @@ -529,12 +554,6 @@ struct v4l2_pix_format {  #define V4L2_PIX_FMT_RGBX444 v4l2_fourcc('R', 'X', '1', '2') /* 16  rrrrgggg bbbbxxxx */  #define V4L2_PIX_FMT_ABGR444 v4l2_fourcc('A', 'B', '1', '2') /* 16  aaaabbbb ggggrrrr */  #define V4L2_PIX_FMT_XBGR444 v4l2_fourcc('X', 'B', '1', '2') /* 16  xxxxbbbb ggggrrrr */ - -/* - * Originally this had 'BA12' as fourcc, but this clashed with the older - * V4L2_PIX_FMT_SGRBG12 which inexplicably used that same fourcc. - * So use 'GA12' instead for V4L2_PIX_FMT_BGRA444. - */  #define V4L2_PIX_FMT_BGRA444 v4l2_fourcc('G', 'A', '1', '2') /* 16  bbbbgggg rrrraaaa */  #define V4L2_PIX_FMT_BGRX444 v4l2_fourcc('B', 'X', '1', '2') /* 16  bbbbgggg rrrrxxxx */  #define V4L2_PIX_FMT_RGB555  v4l2_fourcc('R', 'G', 'B', 'O') /* 16  RGB-5-5-5     */ @@ -551,6 +570,8 @@ struct v4l2_pix_format {  #define V4L2_PIX_FMT_ARGB555X v4l2_fourcc_be('A', 'R', '1', '5') /* 16  ARGB-5-5-5 BE */  #define V4L2_PIX_FMT_XRGB555X v4l2_fourcc_be('X', 'R', '1', '5') /* 16  XRGB-5-5-5 BE */  #define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16  RGB-5-6-5 BE  */ + +/* RGB formats (3 or 4 bytes per pixel) */  #define V4L2_PIX_FMT_BGR666  v4l2_fourcc('B', 'G', 'R', 'H') /* 18  BGR-6-6-6	  */  #define V4L2_PIX_FMT_BGR24   v4l2_fourcc('B', 'G', 'R', '3') /* 24  BGR-8-8-8     */  #define V4L2_PIX_FMT_RGB24   v4l2_fourcc('R', 'G', 'B', '3') /* 24  RGB-8-8-8     */ @@ -564,6 +585,15 @@ struct v4l2_pix_format {  #define V4L2_PIX_FMT_RGBX32  v4l2_fourcc('X', 'B', '2', '4') /* 32  RGBX-8-8-8-8  */  #define V4L2_PIX_FMT_ARGB32  v4l2_fourcc('B', 'A', '2', '4') /* 32  ARGB-8-8-8-8  */  #define V4L2_PIX_FMT_XRGB32  v4l2_fourcc('B', 'X', '2', '4') /* 32  XRGB-8-8-8-8  */ +#define V4L2_PIX_FMT_RGBX1010102 v4l2_fourcc('R', 'X', '3', '0') /* 32  RGBX-10-10-10-2 */ +#define V4L2_PIX_FMT_RGBA1010102 v4l2_fourcc('R', 'A', '3', '0') /* 32  RGBA-10-10-10-2 */ +#define V4L2_PIX_FMT_ARGB2101010 v4l2_fourcc('A', 'R', '3', '0') /* 32  ARGB-2-10-10-10 */ + +/* RGB formats (6 or 8 bytes per pixel) */ +#define V4L2_PIX_FMT_BGR48_12    v4l2_fourcc('B', '3', '1', '2') /* 48  BGR 12-bit per component */ +#define V4L2_PIX_FMT_BGR48       v4l2_fourcc('B', 'G', 'R', '6') /* 48  BGR 16-bit per component */ +#define V4L2_PIX_FMT_RGB48       v4l2_fourcc('R', 'G', 'B', '6') /* 48  RGB 16-bit per component */ +#define V4L2_PIX_FMT_ABGR64_12   v4l2_fourcc('B', '4', '1', '2') /* 64  BGRA 12-bit per component */  /* Grey formats */  #define V4L2_PIX_FMT_GREY    v4l2_fourcc('G', 'R', 'E', 'Y') /*  8  Greyscale     */ @@ -571,6 +601,7 @@ struct v4l2_pix_format {  #define V4L2_PIX_FMT_Y6      v4l2_fourcc('Y', '0', '6', ' ') /*  6  Greyscale     */  #define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10  Greyscale     */  #define V4L2_PIX_FMT_Y12     v4l2_fourcc('Y', '1', '2', ' ') /* 12  Greyscale     */ +#define V4L2_PIX_FMT_Y012    v4l2_fourcc('Y', '0', '1', '2') /* 12  Greyscale     */  #define V4L2_PIX_FMT_Y14     v4l2_fourcc('Y', '1', '4', ' ') /* 14  Greyscale     */  #define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16  Greyscale     */  #define V4L2_PIX_FMT_Y16_BE  v4l2_fourcc_be('Y', '1', '6', ' ') /* 16  Greyscale BE  */ @@ -578,6 +609,9 @@ struct v4l2_pix_format {  /* Grey bit-packed formats */  #define V4L2_PIX_FMT_Y10BPACK    v4l2_fourcc('Y', '1', '0', 'B') /* 10  Greyscale bit-packed */  #define V4L2_PIX_FMT_Y10P    v4l2_fourcc('Y', '1', '0', 'P') /* 10  Greyscale, MIPI RAW10 packed */ +#define V4L2_PIX_FMT_IPU3_Y10		v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */ +#define V4L2_PIX_FMT_Y12P    v4l2_fourcc('Y', '1', '2', 'P') /* 12  Greyscale, MIPI RAW12 packed */ +#define V4L2_PIX_FMT_Y14P    v4l2_fourcc('Y', '1', '4', 'P') /* 14  Greyscale, MIPI RAW14 packed */  /* Palette formats */  #define V4L2_PIX_FMT_PAL8    v4l2_fourcc('P', 'A', 'L', '8') /*  8  8-bit palette */ @@ -595,30 +629,43 @@ struct v4l2_pix_format {  #define V4L2_PIX_FMT_YUV444  v4l2_fourcc('Y', '4', '4', '4') /* 16  xxxxyyyy uuuuvvvv */  #define V4L2_PIX_FMT_YUV555  v4l2_fourcc('Y', 'U', 'V', 'O') /* 16  YUV-5-5-5     */  #define V4L2_PIX_FMT_YUV565  v4l2_fourcc('Y', 'U', 'V', 'P') /* 16  YUV-5-6-5     */ +#define V4L2_PIX_FMT_YUV24   v4l2_fourcc('Y', 'U', 'V', '3') /* 24  YUV-8-8-8     */  #define V4L2_PIX_FMT_YUV32   v4l2_fourcc('Y', 'U', 'V', '4') /* 32  YUV-8-8-8-8   */  #define V4L2_PIX_FMT_AYUV32  v4l2_fourcc('A', 'Y', 'U', 'V') /* 32  AYUV-8-8-8-8  */  #define V4L2_PIX_FMT_XYUV32  v4l2_fourcc('X', 'Y', 'U', 'V') /* 32  XYUV-8-8-8-8  */  #define V4L2_PIX_FMT_VUYA32  v4l2_fourcc('V', 'U', 'Y', 'A') /* 32  VUYA-8-8-8-8  */  #define V4L2_PIX_FMT_VUYX32  v4l2_fourcc('V', 'U', 'Y', 'X') /* 32  VUYX-8-8-8-8  */ -#define V4L2_PIX_FMT_HI240   v4l2_fourcc('H', 'I', '2', '4') /*  8  8-bit color   */ -#define V4L2_PIX_FMT_HM12    v4l2_fourcc('H', 'M', '1', '2') /*  8  YUV 4:2:0 16x16 macroblocks */ +#define V4L2_PIX_FMT_YUVA32  v4l2_fourcc('Y', 'U', 'V', 'A') /* 32  YUVA-8-8-8-8  */ +#define V4L2_PIX_FMT_YUVX32  v4l2_fourcc('Y', 'U', 'V', 'X') /* 32  YUVX-8-8-8-8  */  #define V4L2_PIX_FMT_M420    v4l2_fourcc('M', '4', '2', '0') /* 12  YUV 4:2:0 2 lines y, 1 line uv interleaved */ +#define V4L2_PIX_FMT_YUV48_12    v4l2_fourcc('Y', '3', '1', '2') /* 48  YUV 4:4:4 12-bit per component */ + +/* + * YCbCr packed format. For each Y2xx format, xx bits of valid data occupy the MSBs + * of the 16 bit components, and 16-xx bits of zero padding occupy the LSBs. + */ +#define V4L2_PIX_FMT_Y210    v4l2_fourcc('Y', '2', '1', '0') /* 32  YUYV 4:2:2 */ +#define V4L2_PIX_FMT_Y212    v4l2_fourcc('Y', '2', '1', '2') /* 32  YUYV 4:2:2 */ +#define V4L2_PIX_FMT_Y216    v4l2_fourcc('Y', '2', '1', '6') /* 32  YUYV 4:2:2 */  /* two planes -- one Y, one Cr + Cb interleaved  */  #define V4L2_PIX_FMT_NV12    v4l2_fourcc('N', 'V', '1', '2') /* 12  Y/CbCr 4:2:0  */  #define V4L2_PIX_FMT_NV21    v4l2_fourcc('N', 'V', '2', '1') /* 12  Y/CrCb 4:2:0  */ +#define V4L2_PIX_FMT_NV15    v4l2_fourcc('N', 'V', '1', '5') /* 15  Y/CbCr 4:2:0 10-bit packed */  #define V4L2_PIX_FMT_NV16    v4l2_fourcc('N', 'V', '1', '6') /* 16  Y/CbCr 4:2:2  */  #define V4L2_PIX_FMT_NV61    v4l2_fourcc('N', 'V', '6', '1') /* 16  Y/CrCb 4:2:2  */ +#define V4L2_PIX_FMT_NV20    v4l2_fourcc('N', 'V', '2', '0') /* 20  Y/CbCr 4:2:2 10-bit packed */  #define V4L2_PIX_FMT_NV24    v4l2_fourcc('N', 'V', '2', '4') /* 24  Y/CbCr 4:4:4  */  #define V4L2_PIX_FMT_NV42    v4l2_fourcc('N', 'V', '4', '2') /* 24  Y/CrCb 4:4:4  */ +#define V4L2_PIX_FMT_P010    v4l2_fourcc('P', '0', '1', '0') /* 24  Y/CbCr 4:2:0 10-bit per component */ +#define V4L2_PIX_FMT_P012    v4l2_fourcc('P', '0', '1', '2') /* 24  Y/CbCr 4:2:0 12-bit per component */  /* two non contiguous planes - one Y, one Cr + Cb interleaved  */  #define V4L2_PIX_FMT_NV12M   v4l2_fourcc('N', 'M', '1', '2') /* 12  Y/CbCr 4:2:0  */  #define V4L2_PIX_FMT_NV21M   v4l2_fourcc('N', 'M', '2', '1') /* 21  Y/CrCb 4:2:0  */  #define V4L2_PIX_FMT_NV16M   v4l2_fourcc('N', 'M', '1', '6') /* 16  Y/CbCr 4:2:2  */  #define V4L2_PIX_FMT_NV61M   v4l2_fourcc('N', 'M', '6', '1') /* 16  Y/CrCb 4:2:2  */ -#define V4L2_PIX_FMT_NV12MT  v4l2_fourcc('T', 'M', '1', '2') /* 12  Y/CbCr 4:2:0 64x32 macroblocks */ -#define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12  Y/CbCr 4:2:0 16x16 macroblocks */ +#define V4L2_PIX_FMT_P012M   v4l2_fourcc('P', 'M', '1', '2') /* 24  Y/CbCr 4:2:0 12-bit per component */  /* three planes - Y Cb, Cr */  #define V4L2_PIX_FMT_YUV410  v4l2_fourcc('Y', 'U', 'V', '9') /*  9  YUV 4:1:0     */ @@ -636,6 +683,21 @@ struct v4l2_pix_format {  #define V4L2_PIX_FMT_YUV444M v4l2_fourcc('Y', 'M', '2', '4') /* 24  YUV444 planar */  #define V4L2_PIX_FMT_YVU444M v4l2_fourcc('Y', 'M', '4', '2') /* 24  YVU444 planar */ +/* Tiled YUV formats */ +#define V4L2_PIX_FMT_NV12_4L4 v4l2_fourcc('V', 'T', '1', '2')   /* 12  Y/CbCr 4:2:0  4x4 tiles */ +#define V4L2_PIX_FMT_NV12_16L16 v4l2_fourcc('H', 'M', '1', '2') /* 12  Y/CbCr 4:2:0 16x16 tiles */ +#define V4L2_PIX_FMT_NV12_32L32 v4l2_fourcc('S', 'T', '1', '2') /* 12  Y/CbCr 4:2:0 32x32 tiles */ +#define V4L2_PIX_FMT_NV15_4L4 v4l2_fourcc('V', 'T', '1', '5') /* 15 Y/CbCr 4:2:0 10-bit 4x4 tiles */ +#define V4L2_PIX_FMT_P010_4L4 v4l2_fourcc('T', '0', '1', '0') /* 12  Y/CbCr 4:2:0 10-bit 4x4 macroblocks */ +#define V4L2_PIX_FMT_NV12_8L128       v4l2_fourcc('A', 'T', '1', '2') /* Y/CbCr 4:2:0 8x128 tiles */ +#define V4L2_PIX_FMT_NV12_10BE_8L128  v4l2_fourcc_be('A', 'X', '1', '2') /* Y/CbCr 4:2:0 10-bit 8x128 tiles */ + +/* Tiled YUV formats, non contiguous planes */ +#define V4L2_PIX_FMT_NV12MT  v4l2_fourcc('T', 'M', '1', '2') /* 12  Y/CbCr 4:2:0 64x32 tiles */ +#define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12  Y/CbCr 4:2:0 16x16 tiles */ +#define V4L2_PIX_FMT_NV12M_8L128      v4l2_fourcc('N', 'A', '1', '2') /* Y/CbCr 4:2:0 8x128 tiles */ +#define V4L2_PIX_FMT_NV12M_10BE_8L128 v4l2_fourcc_be('N', 'T', '1', '2') /* Y/CbCr 4:2:0 10-bit 8x128 tiles */ +  /* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */  #define V4L2_PIX_FMT_SBGGR8  v4l2_fourcc('B', 'A', '8', '1') /*  8  BGBG.. GRGR.. */  #define V4L2_PIX_FMT_SGBRG8  v4l2_fourcc('G', 'B', 'R', 'G') /*  8  GBGB.. RGRG.. */ @@ -664,7 +726,7 @@ struct v4l2_pix_format {  #define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2') /* 12  GBGB.. RGRG.. */  #define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12  GRGR.. BGBG.. */  #define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12  RGRG.. GBGB.. */ -	/* 12bit raw bayer packed, 6 bytes for every 4 pixels */ +	/* 12bit raw bayer packed, 3 bytes for every 2 pixels */  #define V4L2_PIX_FMT_SBGGR12P v4l2_fourcc('p', 'B', 'C', 'C')  #define V4L2_PIX_FMT_SGBRG12P v4l2_fourcc('p', 'G', 'C', 'C')  #define V4L2_PIX_FMT_SGRBG12P v4l2_fourcc('p', 'g', 'C', 'C') @@ -704,10 +766,18 @@ struct v4l2_pix_format {  #define V4L2_PIX_FMT_VC1_ANNEX_G v4l2_fourcc('V', 'C', '1', 'G') /* SMPTE 421M Annex G compliant stream */  #define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L') /* SMPTE 421M Annex L compliant stream */  #define V4L2_PIX_FMT_VP8      v4l2_fourcc('V', 'P', '8', '0') /* VP8 */ +#define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F') /* VP8 parsed frame */  #define V4L2_PIX_FMT_VP9      v4l2_fourcc('V', 'P', '9', '0') /* VP9 */ +#define V4L2_PIX_FMT_VP9_FRAME v4l2_fourcc('V', 'P', '9', 'F') /* VP9 parsed frame */  #define V4L2_PIX_FMT_HEVC     v4l2_fourcc('H', 'E', 'V', 'C') /* HEVC aka H.265 */  #define V4L2_PIX_FMT_FWHT     v4l2_fourcc('F', 'W', 'H', 'T') /* Fast Walsh Hadamard Transform (vicodec) */  #define V4L2_PIX_FMT_FWHT_STATELESS     v4l2_fourcc('S', 'F', 'W', 'H') /* Stateless FWHT (vicodec) */ +#define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */ +#define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5') /* HEVC parsed slices */ +#define V4L2_PIX_FMT_AV1_FRAME v4l2_fourcc('A', 'V', '1', 'F') /* AV1 parsed frame */ +#define V4L2_PIX_FMT_SPK      v4l2_fourcc('S', 'P', 'K', '0') /* Sorenson Spark */ +#define V4L2_PIX_FMT_RV30     v4l2_fourcc('R', 'V', '3', '0') /* RealVideo 8 */ +#define V4L2_PIX_FMT_RV40     v4l2_fourcc('R', 'V', '4', '0') /* RealVideo 9 & 10 */  /*  Vendor-specific formats   */  #define V4L2_PIX_FMT_CPIA1    v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */ @@ -738,18 +808,44 @@ struct v4l2_pix_format {  #define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I') /* S5C73M3 interleaved UYVY/JPEG */  #define V4L2_PIX_FMT_Y8I      v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 8-bit L/R interleaved */  #define V4L2_PIX_FMT_Y12I     v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 12-bit L/R interleaved */ +#define V4L2_PIX_FMT_Y16I     v4l2_fourcc('Y', '1', '6', 'I') /* Greyscale 16-bit L/R interleaved */  #define V4L2_PIX_FMT_Z16      v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 16-bit */  #define V4L2_PIX_FMT_MT21C    v4l2_fourcc('M', 'T', '2', '1') /* Mediatek compressed block mode  */ +#define V4L2_PIX_FMT_MM21     v4l2_fourcc('M', 'M', '2', '1') /* Mediatek 8-bit block mode, two non-contiguous planes */ +#define V4L2_PIX_FMT_MT2110T  v4l2_fourcc('M', 'T', '2', 'T') /* Mediatek 10-bit block tile mode */ +#define V4L2_PIX_FMT_MT2110R  v4l2_fourcc('M', 'T', '2', 'R') /* Mediatek 10-bit block raster mode */  #define V4L2_PIX_FMT_INZI     v4l2_fourcc('I', 'N', 'Z', 'I') /* Intel Planar Greyscale 10-bit and Depth 16-bit */ -#define V4L2_PIX_FMT_SUNXI_TILED_NV12 v4l2_fourcc('S', 'T', '1', '2') /* Sunxi Tiled NV12 Format */  #define V4L2_PIX_FMT_CNF4     v4l2_fourcc('C', 'N', 'F', '4') /* Intel 4-bit packed depth confidence information */ +#define V4L2_PIX_FMT_HI240    v4l2_fourcc('H', 'I', '2', '4') /* BTTV 8-bit dithered RGB */ +#define V4L2_PIX_FMT_QC08C    v4l2_fourcc('Q', '0', '8', 'C') /* Qualcomm 8-bit compressed */ +#define V4L2_PIX_FMT_QC10C    v4l2_fourcc('Q', '1', '0', 'C') /* Qualcomm 10-bit compressed */ +#define V4L2_PIX_FMT_AJPG     v4l2_fourcc('A', 'J', 'P', 'G') /* Aspeed JPEG */ +#define V4L2_PIX_FMT_HEXTILE  v4l2_fourcc('H', 'X', 'T', 'L') /* Hextile compressed */ -/* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */ +/* 10bit raw packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */  #define V4L2_PIX_FMT_IPU3_SBGGR10	v4l2_fourcc('i', 'p', '3', 'b') /* IPU3 packed 10-bit BGGR bayer */  #define V4L2_PIX_FMT_IPU3_SGBRG10	v4l2_fourcc('i', 'p', '3', 'g') /* IPU3 packed 10-bit GBRG bayer */  #define V4L2_PIX_FMT_IPU3_SGRBG10	v4l2_fourcc('i', 'p', '3', 'G') /* IPU3 packed 10-bit GRBG bayer */  #define V4L2_PIX_FMT_IPU3_SRGGB10	v4l2_fourcc('i', 'p', '3', 'r') /* IPU3 packed 10-bit RGGB bayer */ +/* Raspberry Pi PiSP compressed formats. */ +#define V4L2_PIX_FMT_PISP_COMP1_RGGB	v4l2_fourcc('P', 'C', '1', 'R') /* PiSP 8-bit mode 1 compressed RGGB bayer */ +#define V4L2_PIX_FMT_PISP_COMP1_GRBG	v4l2_fourcc('P', 'C', '1', 'G') /* PiSP 8-bit mode 1 compressed GRBG bayer */ +#define V4L2_PIX_FMT_PISP_COMP1_GBRG	v4l2_fourcc('P', 'C', '1', 'g') /* PiSP 8-bit mode 1 compressed GBRG bayer */ +#define V4L2_PIX_FMT_PISP_COMP1_BGGR	v4l2_fourcc('P', 'C', '1', 'B') /* PiSP 8-bit mode 1 compressed BGGR bayer */ +#define V4L2_PIX_FMT_PISP_COMP1_MONO	v4l2_fourcc('P', 'C', '1', 'M') /* PiSP 8-bit mode 1 compressed monochrome */ +#define V4L2_PIX_FMT_PISP_COMP2_RGGB	v4l2_fourcc('P', 'C', '2', 'R') /* PiSP 8-bit mode 2 compressed RGGB bayer */ +#define V4L2_PIX_FMT_PISP_COMP2_GRBG	v4l2_fourcc('P', 'C', '2', 'G') /* PiSP 8-bit mode 2 compressed GRBG bayer */ +#define V4L2_PIX_FMT_PISP_COMP2_GBRG	v4l2_fourcc('P', 'C', '2', 'g') /* PiSP 8-bit mode 2 compressed GBRG bayer */ +#define V4L2_PIX_FMT_PISP_COMP2_BGGR	v4l2_fourcc('P', 'C', '2', 'B') /* PiSP 8-bit mode 2 compressed BGGR bayer */ +#define V4L2_PIX_FMT_PISP_COMP2_MONO	v4l2_fourcc('P', 'C', '2', 'M') /* PiSP 8-bit mode 2 compressed monochrome */ + +/* Renesas RZ/V2H CRU packed formats. 64-bit units with contiguous pixels */ +#define V4L2_PIX_FMT_RAW_CRU10	v4l2_fourcc('C', 'R', '1', '0') +#define V4L2_PIX_FMT_RAW_CRU12	v4l2_fourcc('C', 'R', '1', '2') +#define V4L2_PIX_FMT_RAW_CRU14	v4l2_fourcc('C', 'R', '1', '4') +#define V4L2_PIX_FMT_RAW_CRU20	v4l2_fourcc('C', 'R', '2', '0') +  /* SDR formats - used only for Software Defined Radio devices */  #define V4L2_SDR_FMT_CU8          v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */  #define V4L2_SDR_FMT_CU16LE       v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */ @@ -771,13 +867,43 @@ struct v4l2_pix_format {  #define V4L2_META_FMT_VSP1_HGT    v4l2_fourcc('V', 'S', 'P', 'T') /* R-Car VSP1 2-D Histogram */  #define V4L2_META_FMT_UVC         v4l2_fourcc('U', 'V', 'C', 'H') /* UVC Payload Header metadata */  #define V4L2_META_FMT_D4XX        v4l2_fourcc('D', '4', 'X', 'X') /* D4XX Payload Header metadata */ +#define V4L2_META_FMT_UVC_MSXU_1_5  v4l2_fourcc('U', 'V', 'C', 'M') /* UVC MSXU metadata */  #define V4L2_META_FMT_VIVID	  v4l2_fourcc('V', 'I', 'V', 'D') /* Vivid Metadata */ +/* Vendor specific - used for RK_ISP1 camera sub-system */ +#define V4L2_META_FMT_RK_ISP1_PARAMS	v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */ +#define V4L2_META_FMT_RK_ISP1_STAT_3A	v4l2_fourcc('R', 'K', '1', 'S') /* Rockchip ISP1 3A Statistics */ +#define V4L2_META_FMT_RK_ISP1_EXT_PARAMS	v4l2_fourcc('R', 'K', '1', 'E') /* Rockchip ISP1 3a Extensible Parameters */ + +/* Vendor specific - used for C3_ISP */ +#define V4L2_META_FMT_C3ISP_PARAMS	v4l2_fourcc('C', '3', 'P', 'M') /* Amlogic C3 ISP Parameters */ +#define V4L2_META_FMT_C3ISP_STATS	v4l2_fourcc('C', '3', 'S', 'T') /* Amlogic C3 ISP Statistics */ + +/* Vendor specific - used for RaspberryPi PiSP */ +#define V4L2_META_FMT_RPI_BE_CFG	v4l2_fourcc('R', 'P', 'B', 'C') /* PiSP BE configuration */ +#define V4L2_META_FMT_RPI_FE_CFG	v4l2_fourcc('R', 'P', 'F', 'C') /* PiSP FE configuration */ +#define V4L2_META_FMT_RPI_FE_STATS	v4l2_fourcc('R', 'P', 'F', 'S') /* PiSP FE stats */ + +#ifdef __KERNEL__ +/* + * Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when + * adding new ones! + */ +#define V4L2_META_FMT_GENERIC_8		v4l2_fourcc('M', 'E', 'T', '8') /* Generic 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_10	v4l2_fourcc('M', 'C', '1', 'A') /* 10-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_12	v4l2_fourcc('M', 'C', '1', 'C') /* 12-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_14	v4l2_fourcc('M', 'C', '1', 'E') /* 14-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_16	v4l2_fourcc('M', 'C', '1', 'G') /* 16-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_20	v4l2_fourcc('M', 'C', '1', 'K') /* 20-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_24	v4l2_fourcc('M', 'C', '1', 'O') /* 24-bit CSI-2 packed 8-bit metadata */ +#endif +  /* priv field value to indicates that subsequent fields are valid. */  #define V4L2_PIX_FMT_PRIV_MAGIC		0xfeedcafe  /* Flags */  #define V4L2_PIX_FMT_FLAG_PREMUL_ALPHA	0x00000001 +#define V4L2_PIX_FMT_FLAG_SET_CSC	0x00000002  /*   *	F O R M A T   E N U M E R A T I O N @@ -797,6 +923,15 @@ struct v4l2_fmtdesc {  #define V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM	0x0004  #define V4L2_FMT_FLAG_DYN_RESOLUTION		0x0008  #define V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL	0x0010 +#define V4L2_FMT_FLAG_CSC_COLORSPACE		0x0020 +#define V4L2_FMT_FLAG_CSC_XFER_FUNC		0x0040 +#define V4L2_FMT_FLAG_CSC_YCBCR_ENC		0x0080 +#define V4L2_FMT_FLAG_CSC_HSV_ENC		V4L2_FMT_FLAG_CSC_YCBCR_ENC +#define V4L2_FMT_FLAG_CSC_QUANTIZATION		0x0100 +#define V4L2_FMT_FLAG_META_LINE_BASED		0x0200 + +/*  Format description flag, to be ORed with the index */ +#define V4L2_FMTDESC_FLAG_ENUM_ALL		0x80000000  	/* Frame Size and frame rate enumeration */  /* @@ -949,12 +1084,12 @@ struct v4l2_requestbuffers {  	__u32			type;		/* enum v4l2_buf_type */  	__u32			memory;		/* enum v4l2_memory */  	__u32			capabilities; -	union { -		__u32		flags; -		__u32		reserved[1]; -	}; +	__u8			flags; +	__u8			reserved[3];  }; +#define V4L2_MEMORY_FLAG_NON_COHERENT			(1 << 0) +  /* capabilities for struct v4l2_requestbuffers and v4l2_create_buffers */  #define V4L2_BUF_CAP_SUPPORTS_MMAP			(1 << 0)  #define V4L2_BUF_CAP_SUPPORTS_USERPTR			(1 << 1) @@ -963,21 +1098,25 @@ struct v4l2_requestbuffers {  #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS		(1 << 4)  #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF	(1 << 5)  #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS		(1 << 6) +#define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS		(1 << 7) +#define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS		(1 << 8)  /**   * struct v4l2_plane - plane info for multi-planar buffers   * @bytesused:		number of bytes occupied by data in the plane (payload)   * @length:		size of this plane (NOT the payload) in bytes - * @mem_offset:		when memory in the associated struct v4l2_buffer is + * @m.mem_offset:	when memory in the associated struct v4l2_buffer is   *			V4L2_MEMORY_MMAP, equals the offset from the start of   *			the device memory for this plane (or is a "cookie" that   *			should be passed to mmap() called on the video node) - * @userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer + * @m.userptr:		when memory is V4L2_MEMORY_USERPTR, a userspace pointer   *			pointing to this plane - * @fd:			when memory is V4L2_MEMORY_DMABUF, a userspace file + * @m.fd:		when memory is V4L2_MEMORY_DMABUF, a userspace file   *			descriptor associated with this plane + * @m:			union of @mem_offset, @userptr and @fd   * @data_offset:	offset in the plane to the start of data; usually 0,   *			unless there is a header in front of the data + * @reserved:		drivers and applications must zero this array   *   * Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer   * with two planes can have one plane for Y, and another for interleaved CbCr @@ -1010,19 +1149,23 @@ struct v4l2_plane {   * @sequence:	sequence count of this frame   * @memory:	enum v4l2_memory; the method, in which the actual video data is   *		passed - * @offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP; + * @m.offset:	for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;   *		offset from the start of the device memory for this plane,   *		(or a "cookie" that should be passed to mmap() as offset) - * @userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR; + * @m.userptr:	for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;   *		a userspace pointer pointing to this buffer - * @fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF; + * @m.fd:		for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;   *		a userspace file descriptor associated with this buffer - * @planes:	for multiplanar buffers; userspace pointer to the array of plane + * @m.planes:	for multiplanar buffers; userspace pointer to the array of plane   *		info structs for this buffer + * @m:		union of @offset, @userptr, @planes and @fd   * @length:	size in bytes of the buffer (NOT its payload) for single-plane   *		buffers (when type != *_MPLANE); number of elements in the   *		planes array for multi-plane buffers + * @reserved2:	drivers and applications must zero this field   * @request_fd: fd of the request that this buffer should use + * @reserved:	for backwards compatibility with applications that do not know + *		about @request_fd   *   * Contains data exchanged by application and driver using one of the Streaming   * I/O methods. @@ -1060,7 +1203,7 @@ struct v4l2_buffer {  #ifndef __KERNEL__  /**   * v4l2_timeval_to_ns - Convert timeval to nanoseconds - * @ts:		pointer to the timeval variable to be converted + * @tv:		pointer to the timeval variable to be converted   *   * Returns the scalar nanosecond representation of the timeval   * parameter. @@ -1121,6 +1264,7 @@ static inline __u64 v4l2_timeval_to_ns(const struct timeval *tv)   * @flags:	flags for newly created file, currently only O_CLOEXEC is   *		supported, refer to manual of open syscall for more details   * @fd:		file descriptor associated with DMABUF (set by driver) + * @reserved:	drivers and applications must zero this array   *   * Contains data used for exporting a video buffer as DMABUF file descriptor.   * The buffer is identified by a 'cookie' returned by VIDIOC_QUERYBUF @@ -1161,8 +1305,10 @@ struct v4l2_framebuffer {  /*  Flags for the 'capability' field. Read only */  #define V4L2_FBUF_CAP_EXTERNOVERLAY	0x0001  #define V4L2_FBUF_CAP_CHROMAKEY		0x0002 +#ifndef __KERNEL__  #define V4L2_FBUF_CAP_LIST_CLIPPING     0x0004  #define V4L2_FBUF_CAP_BITMAP_CLIPPING	0x0008 +#endif  #define V4L2_FBUF_CAP_LOCAL_ALPHA	0x0010  #define V4L2_FBUF_CAP_GLOBAL_ALPHA	0x0020  #define V4L2_FBUF_CAP_LOCAL_INV_ALPHA	0x0040 @@ -1185,7 +1331,7 @@ struct v4l2_window {  	struct v4l2_rect        w;  	__u32			field;	 /* enum v4l2_field */  	__u32			chromakey; -	struct v4l2_clip	__user *clips; +	struct v4l2_clip	*clips;  	__u32			clipcount;  	void			__user *bitmap;  	__u8                    global_alpha; @@ -1552,7 +1698,8 @@ struct v4l2_bt_timings {  	((bt)->width + V4L2_DV_BT_BLANKING_WIDTH(bt))  #define V4L2_DV_BT_BLANKING_HEIGHT(bt) \  	((bt)->vfrontporch + (bt)->vsync + (bt)->vbackporch + \ -	 (bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch) +	 ((bt)->interlaced ? \ +	  ((bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch) : 0))  #define V4L2_DV_BT_FRAME_HEIGHT(bt) \  	((bt)->height + V4L2_DV_BT_BLANKING_HEIGHT(bt)) @@ -1643,7 +1790,7 @@ struct v4l2_input {  	__u8	     name[32];		/*  Label */  	__u32	     type;		/*  Type of input */  	__u32	     audioset;		/*  Associated audios (bitfield) */ -	__u32        tuner;             /*  enum v4l2_tuner_type */ +	__u32        tuner;             /*  Tuner index */  	v4l2_std_id  std;  	__u32	     status;  	__u32	     capabilities; @@ -1730,9 +1877,36 @@ struct v4l2_ext_control {  		__u8 __user *p_u8;  		__u16 __user *p_u16;  		__u32 __user *p_u32; +		__s32 __user *p_s32; +		__s64 __user *p_s64;  		struct v4l2_area __user *p_area; +		struct v4l2_rect __user *p_rect; +		struct v4l2_ctrl_h264_sps __user *p_h264_sps; +		struct v4l2_ctrl_h264_pps __user *p_h264_pps; +		struct v4l2_ctrl_h264_scaling_matrix __user *p_h264_scaling_matrix; +		struct v4l2_ctrl_h264_pred_weights __user *p_h264_pred_weights; +		struct v4l2_ctrl_h264_slice_params __user *p_h264_slice_params; +		struct v4l2_ctrl_h264_decode_params __user *p_h264_decode_params; +		struct v4l2_ctrl_fwht_params __user *p_fwht_params; +		struct v4l2_ctrl_vp8_frame __user *p_vp8_frame; +		struct v4l2_ctrl_mpeg2_sequence __user *p_mpeg2_sequence; +		struct v4l2_ctrl_mpeg2_picture __user *p_mpeg2_picture; +		struct v4l2_ctrl_mpeg2_quantisation __user *p_mpeg2_quantisation; +		struct v4l2_ctrl_vp9_compressed_hdr __user *p_vp9_compressed_hdr_probs; +		struct v4l2_ctrl_vp9_frame __user *p_vp9_frame; +		struct v4l2_ctrl_hevc_sps __user *p_hevc_sps; +		struct v4l2_ctrl_hevc_pps __user *p_hevc_pps; +		struct v4l2_ctrl_hevc_slice_params __user *p_hevc_slice_params; +		struct v4l2_ctrl_hevc_scaling_matrix __user *p_hevc_scaling_matrix; +		struct v4l2_ctrl_hevc_decode_params __user *p_hevc_decode_params; +		struct v4l2_ctrl_av1_sequence __user *p_av1_sequence; +		struct v4l2_ctrl_av1_tile_group_entry __user *p_av1_tile_group_entry; +		struct v4l2_ctrl_av1_frame __user *p_av1_frame; +		struct v4l2_ctrl_av1_film_grain __user *p_av1_film_grain; +		struct v4l2_ctrl_hdr10_cll_info __user *p_hdr10_cll_info; +		struct v4l2_ctrl_hdr10_mastering_display __user *p_hdr10_mastering_display;  		void __user *ptr; -	}; +	} __attribute__ ((packed));  } __attribute__ ((packed));  struct v4l2_ext_controls { @@ -1759,6 +1933,8 @@ struct v4l2_ext_controls {  #define V4L2_CTRL_WHICH_CUR_VAL   0  #define V4L2_CTRL_WHICH_DEF_VAL   0x0f000000  #define V4L2_CTRL_WHICH_REQUEST_VAL 0x0f010000 +#define V4L2_CTRL_WHICH_MIN_VAL   0x0f020000 +#define V4L2_CTRL_WHICH_MAX_VAL   0x0f030000  enum v4l2_ctrl_type {  	V4L2_CTRL_TYPE_INTEGER	     = 1, @@ -1777,6 +1953,39 @@ enum v4l2_ctrl_type {  	V4L2_CTRL_TYPE_U16	     = 0x0101,  	V4L2_CTRL_TYPE_U32	     = 0x0102,  	V4L2_CTRL_TYPE_AREA          = 0x0106, +	V4L2_CTRL_TYPE_RECT	     = 0x0107, + +	V4L2_CTRL_TYPE_HDR10_CLL_INFO		= 0x0110, +	V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY	= 0x0111, + +	V4L2_CTRL_TYPE_H264_SPS             = 0x0200, +	V4L2_CTRL_TYPE_H264_PPS		    = 0x0201, +	V4L2_CTRL_TYPE_H264_SCALING_MATRIX  = 0x0202, +	V4L2_CTRL_TYPE_H264_SLICE_PARAMS    = 0x0203, +	V4L2_CTRL_TYPE_H264_DECODE_PARAMS   = 0x0204, +	V4L2_CTRL_TYPE_H264_PRED_WEIGHTS    = 0x0205, + +	V4L2_CTRL_TYPE_FWHT_PARAMS	    = 0x0220, + +	V4L2_CTRL_TYPE_VP8_FRAME            = 0x0240, + +	V4L2_CTRL_TYPE_MPEG2_QUANTISATION   = 0x0250, +	V4L2_CTRL_TYPE_MPEG2_SEQUENCE       = 0x0251, +	V4L2_CTRL_TYPE_MPEG2_PICTURE        = 0x0252, + +	V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR	= 0x0260, +	V4L2_CTRL_TYPE_VP9_FRAME		= 0x0261, + +	V4L2_CTRL_TYPE_HEVC_SPS			= 0x0270, +	V4L2_CTRL_TYPE_HEVC_PPS			= 0x0271, +	V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS	= 0x0272, +	V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX	= 0x0273, +	V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS	= 0x0274, + +	V4L2_CTRL_TYPE_AV1_SEQUENCE	    = 0x280, +	V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281, +	V4L2_CTRL_TYPE_AV1_FRAME	    = 0x282, +	V4L2_CTRL_TYPE_AV1_FILM_GRAIN	    = 0x283,  };  /*  Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ @@ -1832,6 +2041,8 @@ struct v4l2_querymenu {  #define V4L2_CTRL_FLAG_HAS_PAYLOAD	0x0100  #define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE	0x0200  #define V4L2_CTRL_FLAG_MODIFY_LAYOUT	0x0400 +#define V4L2_CTRL_FLAG_DYNAMIC_ARRAY	0x0800 +#define V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX 0x1000  /*  Query flags, to be ORed with the control ID */  #define V4L2_CTRL_FLAG_NEXT_CTRL	0x80000000 @@ -2214,6 +2425,7 @@ struct v4l2_mpeg_vbi_fmt_ivtv {   *			this plane will be used   * @bytesperline:	distance in bytes between the leftmost pixels in two   *			adjacent lines + * @reserved:		drivers and applications must zero this array   */  struct v4l2_plane_pix_format {  	__u32		sizeimage; @@ -2232,8 +2444,10 @@ struct v4l2_plane_pix_format {   * @num_planes:		number of planes for this format   * @flags:		format flags (V4L2_PIX_FMT_FLAG_*)   * @ycbcr_enc:		enum v4l2_ycbcr_encoding, Y'CbCr encoding + * @hsv_enc:		enum v4l2_hsv_encoding, HSV encoding   * @quantization:	enum v4l2_quantization, colorspace quantization   * @xfer_func:		enum v4l2_xfer_func, colorspace transfer function + * @reserved:		drivers and applications must zero this array   */  struct v4l2_pix_format_mplane {  	__u32				width; @@ -2258,6 +2472,7 @@ struct v4l2_pix_format_mplane {   * struct v4l2_sdr_format - SDR format definition   * @pixelformat:	little endian four character code (fourcc)   * @buffersize:		maximum size in bytes required for data + * @reserved:		drivers and applications must zero this array   */  struct v4l2_sdr_format {  	__u32				pixelformat; @@ -2269,21 +2484,32 @@ struct v4l2_sdr_format {   * struct v4l2_meta_format - metadata format definition   * @dataformat:		little endian four character code (fourcc)   * @buffersize:		maximum size in bytes required for data + * @width:		number of data units of data per line (valid for line + *			based formats only, see format documentation) + * @height:		number of lines of data per buffer (valid for line based + *			formats only) + * @bytesperline:	offset between the beginnings of two adjacent lines in + *			bytes (valid for line based formats only)   */  struct v4l2_meta_format {  	__u32				dataformat;  	__u32				buffersize; +	__u32				width; +	__u32				height; +	__u32				bytesperline;  } __attribute__ ((packed));  /**   * struct v4l2_format - stream data format - * @type:	enum v4l2_buf_type; type of the data stream - * @pix:	definition of an image format - * @pix_mp:	definition of a multiplanar image format - * @win:	definition of an overlaid image - * @vbi:	raw VBI capture or output parameters - * @sliced:	sliced VBI capture or output parameters - * @raw_data:	placeholder for future extensions and custom formats + * @type:		enum v4l2_buf_type; type of the data stream + * @fmt.pix:		definition of an image format + * @fmt.pix_mp:		definition of a multiplanar image format + * @fmt.win:		definition of an overlaid image + * @fmt.vbi:		raw VBI capture or output parameters + * @fmt.sliced:		sliced VBI capture or output parameters + * @fmt.raw_data:	placeholder for future extensions and custom formats + * @fmt:		union of @pix, @pix_mp, @win, @vbi, @sliced, @sdr, + *			@meta and @raw_data   */  struct v4l2_format {  	__u32	 type; @@ -2333,6 +2559,7 @@ struct v4l2_event_vsync {  #define V4L2_EVENT_CTRL_CH_VALUE		(1 << 0)  #define V4L2_EVENT_CTRL_CH_FLAGS		(1 << 1)  #define V4L2_EVENT_CTRL_CH_RANGE		(1 << 2) +#define V4L2_EVENT_CTRL_CH_DIMENSIONS		(1 << 3)  struct v4l2_event_ctrl {  	__u32 changes; @@ -2459,6 +2686,9 @@ struct v4l2_dbg_chip_info {   * @flags:	additional buffer management attributes (ignored unless the   *		queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability   *		and configured for MMAP streaming I/O). + * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set + *		this field indicate the maximum possible number of buffers + *		for this queue.   * @reserved:	future extensions   */  struct v4l2_create_buffers { @@ -2468,7 +2698,22 @@ struct v4l2_create_buffers {  	struct v4l2_format	format;  	__u32			capabilities;  	__u32			flags; -	__u32			reserved[6]; +	__u32			max_num_buffers; +	__u32			reserved[5]; +}; + +/** + * struct v4l2_remove_buffers - VIDIOC_REMOVE_BUFS argument + * @index:	the first buffer to be removed + * @count:	number of buffers to removed + * @type:	enum v4l2_buf_type + * @reserved:	future extensions + */ +struct v4l2_remove_buffers { +	__u32			index; +	__u32			count; +	__u32			type; +	__u32			reserved[13];  };  /* @@ -2570,10 +2815,23 @@ struct v4l2_create_buffers {  #define VIDIOC_DBG_G_CHIP_INFO  _IOWR('V', 102, struct v4l2_dbg_chip_info)  #define VIDIOC_QUERY_EXT_CTRL	_IOWR('V', 103, struct v4l2_query_ext_ctrl) +#define VIDIOC_REMOVE_BUFS	_IOWR('V', 104, struct v4l2_remove_buffers) +  /* Reminder: when adding new ioctls please add support for them to     drivers/media/v4l2-core/v4l2-compat-ioctl32.c as well! */  #define BASE_VIDIOC_PRIVATE	192		/* 192-255 are private */ +/* Deprecated definitions kept for backwards compatibility */ +#ifndef __KERNEL__ +#define V4L2_PIX_FMT_HM12 V4L2_PIX_FMT_NV12_16L16 +#define V4L2_PIX_FMT_SUNXI_TILED_NV12 V4L2_PIX_FMT_NV12_32L32 +/* + * This capability was never implemented, anyone using this cap should drop it + * from their code. + */ +#define V4L2_CAP_ASYNCIO 0x02000000 +#endif +  #endif /* _UAPI__LINUX_VIDEODEV2_H */ diff --git a/include/uapi/linux/virtio_9p.h b/include/uapi/linux/virtio_9p.h index 441047432258..374b68f8ac6e 100644 --- a/include/uapi/linux/virtio_9p.h +++ b/include/uapi/linux/virtio_9p.h @@ -38,7 +38,7 @@ struct virtio_9p_config {  	/* length of the tag name */  	__virtio16 tag_len;  	/* non-NULL terminated tag name */ -	__u8 tag[0]; +	__u8 tag[];  } __attribute__((packed));  #endif /* _LINUX_VIRTIO_9P_H */ diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h index ddaa45e723c4..ee35a372805d 100644 --- a/include/uapi/linux/virtio_balloon.h +++ b/include/uapi/linux/virtio_balloon.h @@ -71,7 +71,13 @@ struct virtio_balloon_config {  #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */  #define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */  #define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */ -#define VIRTIO_BALLOON_S_NR       10 +#define VIRTIO_BALLOON_S_OOM_KILL      10 /* OOM killer invocations */ +#define VIRTIO_BALLOON_S_ALLOC_STALL   11 /* Stall count of memory allocatoin */ +#define VIRTIO_BALLOON_S_ASYNC_SCAN    12 /* Amount of memory scanned asynchronously */ +#define VIRTIO_BALLOON_S_DIRECT_SCAN   13 /* Amount of memory scanned directly */ +#define VIRTIO_BALLOON_S_ASYNC_RECLAIM 14 /* Amount of memory reclaimed asynchronously */ +#define VIRTIO_BALLOON_S_DIRECT_RECLAIM 15 /* Amount of memory reclaimed directly */ +#define VIRTIO_BALLOON_S_NR       16  #define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \  	VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \ @@ -83,7 +89,13 @@ struct virtio_balloon_config {  	VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \  	VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \  	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \ -	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures" \ +	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures", \ +	VIRTIO_BALLOON_S_NAMES_prefix "oom-kills", \ +	VIRTIO_BALLOON_S_NAMES_prefix "alloc-stalls", \ +	VIRTIO_BALLOON_S_NAMES_prefix "async-scans", \ +	VIRTIO_BALLOON_S_NAMES_prefix "direct-scans", \ +	VIRTIO_BALLOON_S_NAMES_prefix "async-reclaims", \ +	VIRTIO_BALLOON_S_NAMES_prefix "direct-reclaims" \  }  #define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("") diff --git a/include/uapi/linux/virtio_blk.h b/include/uapi/linux/virtio_blk.h index d888f013d9ff..3744e4da1b2a 100644 --- a/include/uapi/linux/virtio_blk.h +++ b/include/uapi/linux/virtio_blk.h @@ -40,6 +40,8 @@  #define VIRTIO_BLK_F_MQ		12	/* support more than one vq */  #define VIRTIO_BLK_F_DISCARD	13	/* DISCARD is supported */  #define VIRTIO_BLK_F_WRITE_ZEROES	14	/* WRITE ZEROES is supported */ +#define VIRTIO_BLK_F_SECURE_ERASE	16 /* Secure Erase is supported */ +#define VIRTIO_BLK_F_ZONED		17	/* Zoned block device */  /* Legacy feature bits */  #ifndef VIRTIO_BLK_NO_LEGACY @@ -121,6 +123,31 @@ struct virtio_blk_config {  	__u8 write_zeroes_may_unmap;  	__u8 unused1[3]; + +	/* the next 3 entries are guarded by VIRTIO_BLK_F_SECURE_ERASE */ +	/* +	 * The maximum secure erase sectors (in 512-byte sectors) for +	 * one segment. +	 */ +	__virtio32 max_secure_erase_sectors; +	/* +	 * The maximum number of secure erase segments in a +	 * secure erase command. +	 */ +	__virtio32 max_secure_erase_seg; +	/* Secure erase commands must be aligned to this number of sectors. */ +	__virtio32 secure_erase_sector_alignment; + +	/* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */ +	struct virtio_blk_zoned_characteristics { +		__virtio32 zone_sectors; +		__virtio32 max_open_zones; +		__virtio32 max_active_zones; +		__virtio32 max_append_sectors; +		__virtio32 write_granularity; +		__u8 model; +		__u8 unused2[3]; +	} zoned;  } __attribute__((packed));  /* @@ -155,6 +182,30 @@ struct virtio_blk_config {  /* Write zeroes command */  #define VIRTIO_BLK_T_WRITE_ZEROES	13 +/* Secure erase command */ +#define VIRTIO_BLK_T_SECURE_ERASE	14 + +/* Zone append command */ +#define VIRTIO_BLK_T_ZONE_APPEND    15 + +/* Report zones command */ +#define VIRTIO_BLK_T_ZONE_REPORT    16 + +/* Open zone command */ +#define VIRTIO_BLK_T_ZONE_OPEN      18 + +/* Close zone command */ +#define VIRTIO_BLK_T_ZONE_CLOSE     20 + +/* Finish zone command */ +#define VIRTIO_BLK_T_ZONE_FINISH    22 + +/* Reset zone command */ +#define VIRTIO_BLK_T_ZONE_RESET     24 + +/* Reset All zones command */ +#define VIRTIO_BLK_T_ZONE_RESET_ALL 26 +  #ifndef VIRTIO_BLK_NO_LEGACY  /* Barrier before this op. */  #define VIRTIO_BLK_T_BARRIER	0x80000000 @@ -174,6 +225,72 @@ struct virtio_blk_outhdr {  	__virtio64 sector;  }; +/* + * Supported zoned device models. + */ + +/* Regular block device */ +#define VIRTIO_BLK_Z_NONE      0 +/* Host-managed zoned device */ +#define VIRTIO_BLK_Z_HM        1 +/* Host-aware zoned device */ +#define VIRTIO_BLK_Z_HA        2 + +/* + * Zone descriptor. A part of VIRTIO_BLK_T_ZONE_REPORT command reply. + */ +struct virtio_blk_zone_descriptor { +	/* Zone capacity */ +	__virtio64 z_cap; +	/* The starting sector of the zone */ +	__virtio64 z_start; +	/* Zone write pointer position in sectors */ +	__virtio64 z_wp; +	/* Zone type */ +	__u8 z_type; +	/* Zone state */ +	__u8 z_state; +	__u8 reserved[38]; +}; + +struct virtio_blk_zone_report { +	__virtio64 nr_zones; +	__u8 reserved[56]; +	struct virtio_blk_zone_descriptor zones[]; +}; + +/* + * Supported zone types. + */ + +/* Conventional zone */ +#define VIRTIO_BLK_ZT_CONV         1 +/* Sequential Write Required zone */ +#define VIRTIO_BLK_ZT_SWR          2 +/* Sequential Write Preferred zone */ +#define VIRTIO_BLK_ZT_SWP          3 + +/* + * Zone states that are available for zones of all types. + */ + +/* Not a write pointer (conventional zones only) */ +#define VIRTIO_BLK_ZS_NOT_WP       0 +/* Empty */ +#define VIRTIO_BLK_ZS_EMPTY        1 +/* Implicitly Open */ +#define VIRTIO_BLK_ZS_IOPEN        2 +/* Explicitly Open */ +#define VIRTIO_BLK_ZS_EOPEN        3 +/* Closed */ +#define VIRTIO_BLK_ZS_CLOSED       4 +/* Read-Only */ +#define VIRTIO_BLK_ZS_RDONLY       13 +/* Full */ +#define VIRTIO_BLK_ZS_FULL         14 +/* Offline */ +#define VIRTIO_BLK_ZS_OFFLINE      15 +  /* Unmap this range (only valid for write zeroes command) */  #define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP	0x00000001 @@ -200,4 +317,11 @@ struct virtio_scsi_inhdr {  #define VIRTIO_BLK_S_OK		0  #define VIRTIO_BLK_S_IOERR	1  #define VIRTIO_BLK_S_UNSUPP	2 + +/* Error codes that are specific to zoned block devices */ +#define VIRTIO_BLK_S_ZONE_INVALID_CMD     3 +#define VIRTIO_BLK_S_ZONE_UNALIGNED_WP    4 +#define VIRTIO_BLK_S_ZONE_OPEN_RESOURCE   5 +#define VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE 6 +  #endif /* _LINUX_VIRTIO_BLK_H */ diff --git a/include/uapi/linux/virtio_bt.h b/include/uapi/linux/virtio_bt.h new file mode 100644 index 000000000000..3cc7d633456b --- /dev/null +++ b/include/uapi/linux/virtio_bt.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _UAPI_LINUX_VIRTIO_BT_H +#define _UAPI_LINUX_VIRTIO_BT_H + +#include <linux/virtio_types.h> + +/* Feature bits */ +#define VIRTIO_BT_F_VND_HCI	0	/* Indicates vendor command support */ +#define VIRTIO_BT_F_MSFT_EXT	1	/* Indicates MSFT vendor support */ +#define VIRTIO_BT_F_AOSP_EXT	2	/* Indicates AOSP vendor support */ +#define VIRTIO_BT_F_CONFIG_V2	3	/* Use second version configuration */ + +enum virtio_bt_config_type { +	VIRTIO_BT_CONFIG_TYPE_PRIMARY	= 0, +}; + +enum virtio_bt_config_vendor { +	VIRTIO_BT_CONFIG_VENDOR_NONE	= 0, +	VIRTIO_BT_CONFIG_VENDOR_ZEPHYR	= 1, +	VIRTIO_BT_CONFIG_VENDOR_INTEL	= 2, +	VIRTIO_BT_CONFIG_VENDOR_REALTEK	= 3, +}; + +struct virtio_bt_config { +	__u8  type; +	__u16 vendor; +	__u16 msft_opcode; +} __attribute__((packed)); + +struct virtio_bt_config_v2 { +	__u8  type; +	__u8  alignment; +	__u16 vendor; +	__u16 msft_opcode; +}; + +#endif /* _UAPI_LINUX_VIRTIO_BT_H */ diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h index b5eda06f0d57..2445f365bce7 100644 --- a/include/uapi/linux/virtio_config.h +++ b/include/uapi/linux/virtio_config.h @@ -52,7 +52,7 @@   * rest are per-device feature bits.   */  #define VIRTIO_TRANSPORT_F_START	28 -#define VIRTIO_TRANSPORT_F_END		38 +#define VIRTIO_TRANSPORT_F_END		42  #ifndef VIRTIO_CONFIG_NO_LEGACY  /* Do we get callbacks when the ring is completely used, even if we've @@ -83,6 +83,12 @@  #define VIRTIO_F_RING_PACKED		34  /* + * Inorder feature indicates that all buffers are used by the device + * in the same order in which they have been made available. + */ +#define VIRTIO_F_IN_ORDER		35 + +/*   * This feature indicates that memory accesses by the driver and the   * device are ordered in a way described by the platform.   */ @@ -92,4 +98,26 @@   * Does the device support Single Root I/O Virtualization?   */  #define VIRTIO_F_SR_IOV			37 + +/* + * This feature indicates that the driver passes extra data (besides + * identifying the virtqueue) in its device notifications. + */ +#define VIRTIO_F_NOTIFICATION_DATA	38 + +/* This feature indicates that the driver uses the data provided by the device + * as a virtqueue identifier in available buffer notifications. + */ +#define VIRTIO_F_NOTIF_CONFIG_DATA	39 + +/* + * This feature indicates that the driver can reset a queue individually. + */ +#define VIRTIO_F_RING_RESET		40 + +/* + * This feature indicates that the device support administration virtqueues. + */ +#define VIRTIO_F_ADMIN_VQ		41 +  #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ diff --git a/include/uapi/linux/virtio_crypto.h b/include/uapi/linux/virtio_crypto.h index a03932f10565..2fccb64c9d6b 100644 --- a/include/uapi/linux/virtio_crypto.h +++ b/include/uapi/linux/virtio_crypto.h @@ -37,6 +37,7 @@  #define VIRTIO_CRYPTO_SERVICE_HASH   1  #define VIRTIO_CRYPTO_SERVICE_MAC    2  #define VIRTIO_CRYPTO_SERVICE_AEAD   3 +#define VIRTIO_CRYPTO_SERVICE_AKCIPHER 4  #define VIRTIO_CRYPTO_OPCODE(service, op)   (((service) << 8) | (op)) @@ -57,6 +58,10 @@ struct virtio_crypto_ctrl_header {  	   VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x02)  #define VIRTIO_CRYPTO_AEAD_DESTROY_SESSION \  	   VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x03) +#define VIRTIO_CRYPTO_AKCIPHER_CREATE_SESSION \ +	   VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x04) +#define VIRTIO_CRYPTO_AKCIPHER_DESTROY_SESSION \ +	   VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x05)  	__le32 opcode;  	__le32 algo;  	__le32 flag; @@ -180,6 +185,58 @@ struct virtio_crypto_aead_create_session_req {  	__u8 padding[32];  }; +struct virtio_crypto_rsa_session_para { +#define VIRTIO_CRYPTO_RSA_RAW_PADDING   0 +#define VIRTIO_CRYPTO_RSA_PKCS1_PADDING 1 +	__le32 padding_algo; + +#define VIRTIO_CRYPTO_RSA_NO_HASH   0 +#define VIRTIO_CRYPTO_RSA_MD2       1 +#define VIRTIO_CRYPTO_RSA_MD3       2 +#define VIRTIO_CRYPTO_RSA_MD4       3 +#define VIRTIO_CRYPTO_RSA_MD5       4 +#define VIRTIO_CRYPTO_RSA_SHA1      5 +#define VIRTIO_CRYPTO_RSA_SHA256    6 +#define VIRTIO_CRYPTO_RSA_SHA384    7 +#define VIRTIO_CRYPTO_RSA_SHA512    8 +#define VIRTIO_CRYPTO_RSA_SHA224    9 +	__le32 hash_algo; +}; + +struct virtio_crypto_ecdsa_session_para { +#define VIRTIO_CRYPTO_CURVE_UNKNOWN   0 +#define VIRTIO_CRYPTO_CURVE_NIST_P192 1 +#define VIRTIO_CRYPTO_CURVE_NIST_P224 2 +#define VIRTIO_CRYPTO_CURVE_NIST_P256 3 +#define VIRTIO_CRYPTO_CURVE_NIST_P384 4 +#define VIRTIO_CRYPTO_CURVE_NIST_P521 5 +	__le32 curve_id; +	__le32 padding; +}; + +struct virtio_crypto_akcipher_session_para { +#define VIRTIO_CRYPTO_NO_AKCIPHER    0 +#define VIRTIO_CRYPTO_AKCIPHER_RSA   1 +#define VIRTIO_CRYPTO_AKCIPHER_DSA   2 +#define VIRTIO_CRYPTO_AKCIPHER_ECDSA 3 +	__le32 algo; + +#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC  1 +#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE 2 +	__le32 keytype; +	__le32 keylen; + +	union { +		struct virtio_crypto_rsa_session_para rsa; +		struct virtio_crypto_ecdsa_session_para ecdsa; +	} u; +}; + +struct virtio_crypto_akcipher_create_session_req { +	struct virtio_crypto_akcipher_session_para para; +	__u8 padding[36]; +}; +  struct virtio_crypto_alg_chain_session_para {  #define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER  1  #define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH  2 @@ -247,6 +304,8 @@ struct virtio_crypto_op_ctrl_req {  			mac_create_session;  		struct virtio_crypto_aead_create_session_req  			aead_create_session; +		struct virtio_crypto_akcipher_create_session_req +			akcipher_create_session;  		struct virtio_crypto_destroy_session_req  			destroy_session;  		__u8 padding[56]; @@ -266,6 +325,15 @@ struct virtio_crypto_op_header {  	VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x00)  #define VIRTIO_CRYPTO_AEAD_DECRYPT \  	VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x01) +#define VIRTIO_CRYPTO_AKCIPHER_ENCRYPT \ +	VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x00) +#define VIRTIO_CRYPTO_AKCIPHER_DECRYPT \ +	VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x01) +	/* akcipher sign/verify opcodes are deprecated */ +#define VIRTIO_CRYPTO_AKCIPHER_SIGN \ +	VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x02) +#define VIRTIO_CRYPTO_AKCIPHER_VERIFY \ +	VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x03)  	__le32 opcode;  	/* algo should be service-specific algorithms */  	__le32 algo; @@ -390,6 +458,16 @@ struct virtio_crypto_aead_data_req {  	__u8 padding[32];  }; +struct virtio_crypto_akcipher_para { +	__le32 src_data_len; +	__le32 dst_data_len; +}; + +struct virtio_crypto_akcipher_data_req { +	struct virtio_crypto_akcipher_para para; +	__u8 padding[40]; +}; +  /* The request of the data virtqueue's packet */  struct virtio_crypto_op_data_req {  	struct virtio_crypto_op_header header; @@ -399,6 +477,7 @@ struct virtio_crypto_op_data_req {  		struct virtio_crypto_hash_data_req hash_req;  		struct virtio_crypto_mac_data_req mac_req;  		struct virtio_crypto_aead_data_req aead_req; +		struct virtio_crypto_akcipher_data_req akcipher_req;  		__u8 padding[48];  	} u;  }; @@ -408,6 +487,8 @@ struct virtio_crypto_op_data_req {  #define VIRTIO_CRYPTO_BADMSG    2  #define VIRTIO_CRYPTO_NOTSUPP   3  #define VIRTIO_CRYPTO_INVSESS   4 /* Invalid session id */ +#define VIRTIO_CRYPTO_NOSPC     5 /* no free session ID */ +#define VIRTIO_CRYPTO_KEY_REJECTED 6 /* Signature verification failed */  /* The accelerator hardware is ready */  #define VIRTIO_CRYPTO_S_HW_READY  (1 << 0) @@ -438,7 +519,7 @@ struct virtio_crypto_config {  	__le32 max_cipher_key_len;  	/* Maximum length of authenticated key */  	__le32 max_auth_key_len; -	__le32 reserve; +	__le32 akcipher_algo;  	/* Maximum size of each crypto request's content */  	__le64 max_size;  }; diff --git a/include/uapi/linux/virtio_fs.h b/include/uapi/linux/virtio_fs.h index 3056b6e9f8ce..bea38291421b 100644 --- a/include/uapi/linux/virtio_fs.h +++ b/include/uapi/linux/virtio_fs.h @@ -16,4 +16,7 @@ struct virtio_fs_config {  	__le32 num_request_queues;  } __attribute__((packed)); +/* For the id field in virtio_pci_shm_cap */ +#define VIRTIO_FS_SHMCAP_ID_CACHE 0 +  #endif /* _UAPI_LINUX_VIRTIO_FS_H */ diff --git a/include/uapi/linux/virtio_gpio.h b/include/uapi/linux/virtio_gpio.h new file mode 100644 index 000000000000..d4b29d9a39dd --- /dev/null +++ b/include/uapi/linux/virtio_gpio.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ + +#ifndef _LINUX_VIRTIO_GPIO_H +#define _LINUX_VIRTIO_GPIO_H + +#include <linux/types.h> + +/* Virtio GPIO Feature bits */ +#define VIRTIO_GPIO_F_IRQ			0 + +/* Virtio GPIO request types */ +#define VIRTIO_GPIO_MSG_GET_NAMES		0x0001 +#define VIRTIO_GPIO_MSG_GET_DIRECTION		0x0002 +#define VIRTIO_GPIO_MSG_SET_DIRECTION		0x0003 +#define VIRTIO_GPIO_MSG_GET_VALUE		0x0004 +#define VIRTIO_GPIO_MSG_SET_VALUE		0x0005 +#define VIRTIO_GPIO_MSG_IRQ_TYPE		0x0006 + +/* Possible values of the status field */ +#define VIRTIO_GPIO_STATUS_OK			0x0 +#define VIRTIO_GPIO_STATUS_ERR			0x1 + +/* Direction types */ +#define VIRTIO_GPIO_DIRECTION_NONE		0x00 +#define VIRTIO_GPIO_DIRECTION_OUT		0x01 +#define VIRTIO_GPIO_DIRECTION_IN		0x02 + +/* Virtio GPIO IRQ types */ +#define VIRTIO_GPIO_IRQ_TYPE_NONE		0x00 +#define VIRTIO_GPIO_IRQ_TYPE_EDGE_RISING	0x01 +#define VIRTIO_GPIO_IRQ_TYPE_EDGE_FALLING	0x02 +#define VIRTIO_GPIO_IRQ_TYPE_EDGE_BOTH		0x03 +#define VIRTIO_GPIO_IRQ_TYPE_LEVEL_HIGH		0x04 +#define VIRTIO_GPIO_IRQ_TYPE_LEVEL_LOW		0x08 + +struct virtio_gpio_config { +	__le16 ngpio; +	__u8 padding[2]; +	__le32 gpio_names_size; +}; + +/* Virtio GPIO Request / Response */ +struct virtio_gpio_request { +	__le16 type; +	__le16 gpio; +	__le32 value; +}; + +struct virtio_gpio_response { +	__u8 status; +	__u8 value; +}; + +struct virtio_gpio_response_get_names { +	__u8 status; +	__u8 value[]; +}; + +/* Virtio GPIO IRQ Request / Response */ +struct virtio_gpio_irq_request { +	__le16 gpio; +}; + +struct virtio_gpio_irq_response { +	__u8 status; +}; + +/* Possible values of the interrupt status field */ +#define VIRTIO_GPIO_IRQ_STATUS_INVALID		0x0 +#define VIRTIO_GPIO_IRQ_STATUS_VALID		0x1 + +#endif /* _LINUX_VIRTIO_GPIO_H */ diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h index ccbd174ef321..be109777d10d 100644 --- a/include/uapi/linux/virtio_gpu.h +++ b/include/uapi/linux/virtio_gpu.h @@ -50,6 +50,20 @@   * VIRTIO_GPU_CMD_GET_EDID   */  #define VIRTIO_GPU_F_EDID                1 +/* + * VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID + */ +#define VIRTIO_GPU_F_RESOURCE_UUID       2 + +/* + * VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB + */ +#define VIRTIO_GPU_F_RESOURCE_BLOB       3 +/* + * VIRTIO_GPU_CMD_CREATE_CONTEXT with + * context_init and multiple timelines + */ +#define VIRTIO_GPU_F_CONTEXT_INIT        4  enum virtio_gpu_ctrl_type {  	VIRTIO_GPU_UNDEFINED = 0, @@ -66,6 +80,9 @@ enum virtio_gpu_ctrl_type {  	VIRTIO_GPU_CMD_GET_CAPSET_INFO,  	VIRTIO_GPU_CMD_GET_CAPSET,  	VIRTIO_GPU_CMD_GET_EDID, +	VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID, +	VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB, +	VIRTIO_GPU_CMD_SET_SCANOUT_BLOB,  	/* 3d commands */  	VIRTIO_GPU_CMD_CTX_CREATE = 0x0200, @@ -76,6 +93,8 @@ enum virtio_gpu_ctrl_type {  	VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D,  	VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D,  	VIRTIO_GPU_CMD_SUBMIT_3D, +	VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB, +	VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB,  	/* cursor commands */  	VIRTIO_GPU_CMD_UPDATE_CURSOR = 0x0300, @@ -87,6 +106,8 @@ enum virtio_gpu_ctrl_type {  	VIRTIO_GPU_RESP_OK_CAPSET_INFO,  	VIRTIO_GPU_RESP_OK_CAPSET,  	VIRTIO_GPU_RESP_OK_EDID, +	VIRTIO_GPU_RESP_OK_RESOURCE_UUID, +	VIRTIO_GPU_RESP_OK_MAP_INFO,  	/* error responses */  	VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200, @@ -97,14 +118,29 @@ enum virtio_gpu_ctrl_type {  	VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER,  }; -#define VIRTIO_GPU_FLAG_FENCE (1 << 0) +enum virtio_gpu_shm_id { +	VIRTIO_GPU_SHM_ID_UNDEFINED = 0, +	/* +	 * VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB +	 * VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB +	 */ +	VIRTIO_GPU_SHM_ID_HOST_VISIBLE = 1 +}; + +#define VIRTIO_GPU_FLAG_FENCE         (1 << 0) +/* + * If the following flag is set, then ring_idx contains the index + * of the command ring that needs to used when creating the fence + */ +#define VIRTIO_GPU_FLAG_INFO_RING_IDX (1 << 1)  struct virtio_gpu_ctrl_hdr {  	__le32 type;  	__le32 flags;  	__le64 fence_id;  	__le32 ctx_id; -	__le32 padding; +	__u8 ring_idx; +	__u8 padding[3];  };  /* data passed in the cursor vq */ @@ -244,10 +280,11 @@ struct virtio_gpu_resource_create_3d {  };  /* VIRTIO_GPU_CMD_CTX_CREATE */ +#define VIRTIO_GPU_CONTEXT_INIT_CAPSET_ID_MASK 0x000000ff  struct virtio_gpu_ctx_create {  	struct virtio_gpu_ctrl_hdr hdr;  	__le32 nlen; -	__le32 padding; +	__le32 context_init;  	char debug_name[64];  }; @@ -272,6 +309,10 @@ struct virtio_gpu_cmd_submit {  #define VIRTIO_GPU_CAPSET_VIRGL 1  #define VIRTIO_GPU_CAPSET_VIRGL2 2 +#define VIRTIO_GPU_CAPSET_GFXSTREAM_VULKAN 3 +#define VIRTIO_GPU_CAPSET_VENUS 4 +#define VIRTIO_GPU_CAPSET_CROSS_DOMAIN 5 +#define VIRTIO_GPU_CAPSET_DRM 6  /* VIRTIO_GPU_CMD_GET_CAPSET_INFO */  struct virtio_gpu_get_capset_info { @@ -340,4 +381,80 @@ enum virtio_gpu_formats {  	VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM  = 134,  }; +/* VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID */ +struct virtio_gpu_resource_assign_uuid { +	struct virtio_gpu_ctrl_hdr hdr; +	__le32 resource_id; +	__le32 padding; +}; + +/* VIRTIO_GPU_RESP_OK_RESOURCE_UUID */ +struct virtio_gpu_resp_resource_uuid { +	struct virtio_gpu_ctrl_hdr hdr; +	__u8 uuid[16]; +}; + +/* VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB */ +struct virtio_gpu_resource_create_blob { +	struct virtio_gpu_ctrl_hdr hdr; +	__le32 resource_id; +#define VIRTIO_GPU_BLOB_MEM_GUEST             0x0001 +#define VIRTIO_GPU_BLOB_MEM_HOST3D            0x0002 +#define VIRTIO_GPU_BLOB_MEM_HOST3D_GUEST      0x0003 + +#define VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE     0x0001 +#define VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE    0x0002 +#define VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004 +	/* zero is invalid blob mem */ +	__le32 blob_mem; +	__le32 blob_flags; +	__le32 nr_entries; +	__le64 blob_id; +	__le64 size; +	/* +	 * sizeof(nr_entries * virtio_gpu_mem_entry) bytes follow +	 */ +}; + +/* VIRTIO_GPU_CMD_SET_SCANOUT_BLOB */ +struct virtio_gpu_set_scanout_blob { +	struct virtio_gpu_ctrl_hdr hdr; +	struct virtio_gpu_rect r; +	__le32 scanout_id; +	__le32 resource_id; +	__le32 width; +	__le32 height; +	__le32 format; +	__le32 padding; +	__le32 strides[4]; +	__le32 offsets[4]; +}; + +/* VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB */ +struct virtio_gpu_resource_map_blob { +	struct virtio_gpu_ctrl_hdr hdr; +	__le32 resource_id; +	__le32 padding; +	__le64 offset; +}; + +/* VIRTIO_GPU_RESP_OK_MAP_INFO */ +#define VIRTIO_GPU_MAP_CACHE_MASK     0x0f +#define VIRTIO_GPU_MAP_CACHE_NONE     0x00 +#define VIRTIO_GPU_MAP_CACHE_CACHED   0x01 +#define VIRTIO_GPU_MAP_CACHE_UNCACHED 0x02 +#define VIRTIO_GPU_MAP_CACHE_WC       0x03 +struct virtio_gpu_resp_map_info { +	struct virtio_gpu_ctrl_hdr hdr; +	__u32 map_info; +	__u32 padding; +}; + +/* VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB */ +struct virtio_gpu_resource_unmap_blob { +	struct virtio_gpu_ctrl_hdr hdr; +	__le32 resource_id; +	__le32 padding; +}; +  #endif diff --git a/include/uapi/linux/virtio_i2c.h b/include/uapi/linux/virtio_i2c.h new file mode 100644 index 000000000000..acf3b6069136 --- /dev/null +++ b/include/uapi/linux/virtio_i2c.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */ +/* + * Definitions for virtio I2C Adpter + * + * Copyright (c) 2021 Intel Corporation. All rights reserved. + */ + +#ifndef _UAPI_LINUX_VIRTIO_I2C_H +#define _UAPI_LINUX_VIRTIO_I2C_H + +#include <linux/const.h> +#include <linux/types.h> + +/* Virtio I2C Feature bits */ +#define VIRTIO_I2C_F_ZERO_LENGTH_REQUEST	0 + +/* The bit 0 of the @virtio_i2c_out_hdr.@flags, used to group the requests */ +#define VIRTIO_I2C_FLAGS_FAIL_NEXT	_BITUL(0) + +/* The bit 1 of the @virtio_i2c_out_hdr.@flags, used to mark a buffer as read */ +#define VIRTIO_I2C_FLAGS_M_RD		_BITUL(1) + +/** + * struct virtio_i2c_out_hdr - the virtio I2C message OUT header + * @addr: the controlled device address + * @padding: used to pad to full dword + * @flags: used for feature extensibility + */ +struct virtio_i2c_out_hdr { +	__le16 addr; +	__le16 padding; +	__le32 flags; +}; + +/** + * struct virtio_i2c_in_hdr - the virtio I2C message IN header + * @status: the processing result from the backend + */ +struct virtio_i2c_in_hdr { +	__u8 status; +}; + +/* The final status written by the device */ +#define VIRTIO_I2C_MSG_OK	0 +#define VIRTIO_I2C_MSG_ERR	1 + +#endif /* _UAPI_LINUX_VIRTIO_I2C_H */ diff --git a/include/uapi/linux/virtio_ids.h b/include/uapi/linux/virtio_ids.h index b052355ac7a3..7aa2eb766205 100644 --- a/include/uapi/linux/virtio_ids.h +++ b/include/uapi/linux/virtio_ids.h @@ -29,24 +29,56 @@   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF   * SUCH DAMAGE. */ -#define VIRTIO_ID_NET		1 /* virtio net */ -#define VIRTIO_ID_BLOCK		2 /* virtio block */ -#define VIRTIO_ID_CONSOLE	3 /* virtio console */ -#define VIRTIO_ID_RNG		4 /* virtio rng */ -#define VIRTIO_ID_BALLOON	5 /* virtio balloon */ -#define VIRTIO_ID_RPMSG		7 /* virtio remote processor messaging */ -#define VIRTIO_ID_SCSI		8 /* virtio scsi */ -#define VIRTIO_ID_9P		9 /* 9p virtio console */ -#define VIRTIO_ID_RPROC_SERIAL 11 /* virtio remoteproc serial link */ -#define VIRTIO_ID_CAIF	       12 /* Virtio caif */ -#define VIRTIO_ID_GPU          16 /* virtio GPU */ -#define VIRTIO_ID_INPUT        18 /* virtio input */ -#define VIRTIO_ID_VSOCK        19 /* virtio vsock transport */ -#define VIRTIO_ID_CRYPTO       20 /* virtio crypto */ -#define VIRTIO_ID_IOMMU        23 /* virtio IOMMU */ -#define VIRTIO_ID_MEM          24 /* virtio mem */ -#define VIRTIO_ID_FS           26 /* virtio filesystem */ -#define VIRTIO_ID_PMEM         27 /* virtio pmem */ -#define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */ +#define VIRTIO_ID_NET			1 /* virtio net */ +#define VIRTIO_ID_BLOCK			2 /* virtio block */ +#define VIRTIO_ID_CONSOLE		3 /* virtio console */ +#define VIRTIO_ID_RNG			4 /* virtio rng */ +#define VIRTIO_ID_BALLOON		5 /* virtio balloon */ +#define VIRTIO_ID_IOMEM			6 /* virtio ioMemory */ +#define VIRTIO_ID_RPMSG			7 /* virtio remote processor messaging */ +#define VIRTIO_ID_SCSI			8 /* virtio scsi */ +#define VIRTIO_ID_9P			9 /* 9p virtio console */ +#define VIRTIO_ID_MAC80211_WLAN		10 /* virtio WLAN MAC */ +#define VIRTIO_ID_RPROC_SERIAL		11 /* virtio remoteproc serial link */ +#define VIRTIO_ID_CAIF			12 /* Virtio caif */ +#define VIRTIO_ID_MEMORY_BALLOON	13 /* virtio memory balloon */ +#define VIRTIO_ID_GPU			16 /* virtio GPU */ +#define VIRTIO_ID_CLOCK			17 /* virtio clock/timer */ +#define VIRTIO_ID_INPUT			18 /* virtio input */ +#define VIRTIO_ID_VSOCK			19 /* virtio vsock transport */ +#define VIRTIO_ID_CRYPTO		20 /* virtio crypto */ +#define VIRTIO_ID_SIGNAL_DIST		21 /* virtio signal distribution device */ +#define VIRTIO_ID_PSTORE		22 /* virtio pstore device */ +#define VIRTIO_ID_IOMMU			23 /* virtio IOMMU */ +#define VIRTIO_ID_MEM			24 /* virtio mem */ +#define VIRTIO_ID_SOUND			25 /* virtio sound */ +#define VIRTIO_ID_FS			26 /* virtio filesystem */ +#define VIRTIO_ID_PMEM			27 /* virtio pmem */ +#define VIRTIO_ID_RPMB			28 /* virtio rpmb */ +#define VIRTIO_ID_MAC80211_HWSIM	29 /* virtio mac80211-hwsim */ +#define VIRTIO_ID_VIDEO_ENCODER		30 /* virtio video encoder */ +#define VIRTIO_ID_VIDEO_DECODER		31 /* virtio video decoder */ +#define VIRTIO_ID_SCMI			32 /* virtio SCMI */ +#define VIRTIO_ID_NITRO_SEC_MOD		33 /* virtio nitro secure module*/ +#define VIRTIO_ID_I2C_ADAPTER		34 /* virtio i2c adapter */ +#define VIRTIO_ID_WATCHDOG		35 /* virtio watchdog */ +#define VIRTIO_ID_CAN			36 /* virtio can */ +#define VIRTIO_ID_DMABUF		37 /* virtio dmabuf */ +#define VIRTIO_ID_PARAM_SERV		38 /* virtio parameter server */ +#define VIRTIO_ID_AUDIO_POLICY		39 /* virtio audio policy */ +#define VIRTIO_ID_BT			40 /* virtio bluetooth */ +#define VIRTIO_ID_GPIO			41 /* virtio gpio */ + +/* + * Virtio Transitional IDs + */ + +#define VIRTIO_TRANS_ID_NET		0x1000 /* transitional virtio net */ +#define VIRTIO_TRANS_ID_BLOCK		0x1001 /* transitional virtio block */ +#define VIRTIO_TRANS_ID_BALLOON		0x1002 /* transitional virtio balloon */ +#define VIRTIO_TRANS_ID_CONSOLE		0x1003 /* transitional virtio console */ +#define VIRTIO_TRANS_ID_SCSI		0x1004 /* transitional virtio SCSI */ +#define VIRTIO_TRANS_ID_RNG		0x1005 /* transitional virtio rng */ +#define VIRTIO_TRANS_ID_9P		0x1009 /* transitional virtio 9p console */  #endif /* _LINUX_VIRTIO_IDS_H */ diff --git a/include/uapi/linux/virtio_iommu.h b/include/uapi/linux/virtio_iommu.h index 237e36a280cb..1ff357f0d72e 100644 --- a/include/uapi/linux/virtio_iommu.h +++ b/include/uapi/linux/virtio_iommu.h @@ -16,6 +16,7 @@  #define VIRTIO_IOMMU_F_BYPASS			3  #define VIRTIO_IOMMU_F_PROBE			4  #define VIRTIO_IOMMU_F_MMIO			5 +#define VIRTIO_IOMMU_F_BYPASS_CONFIG		6  struct virtio_iommu_range_64 {  	__le64					start; @@ -36,6 +37,8 @@ struct virtio_iommu_config {  	struct virtio_iommu_range_32		domain_range;  	/* Probe buffer size */  	__le32					probe_size; +	__u8					bypass; +	__u8					reserved[3];  };  /* Request types */ @@ -66,11 +69,14 @@ struct virtio_iommu_req_tail {  	__u8					reserved[3];  }; +#define VIRTIO_IOMMU_ATTACH_F_BYPASS		(1 << 0) +  struct virtio_iommu_req_attach {  	struct virtio_iommu_req_head		head;  	__le32					domain;  	__le32					endpoint; -	__u8					reserved[8]; +	__le32					flags; +	__u8					reserved[4];  	struct virtio_iommu_req_tail		tail;  }; diff --git a/include/uapi/linux/virtio_mem.h b/include/uapi/linux/virtio_mem.h index 70e01c687d5e..6e4b2cf6b7f1 100644 --- a/include/uapi/linux/virtio_mem.h +++ b/include/uapi/linux/virtio_mem.h @@ -68,9 +68,10 @@   * explicitly triggered (VIRTIO_MEM_REQ_UNPLUG).   *   * There are no guarantees what will happen if unplugged memory is - * read/written. Such memory should, in general, not be touched. E.g., - * even writing might succeed, but the values will simply be discarded at - * random points in time. + * read/written. In general, unplugged memory should not be touched, because + * the resulting action is undefined. There is one exception: without + * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, unplugged memory inside the usable + * region can be read, to simplify creation of memory dumps.   *   * It can happen that the device cannot process a request, because it is   * busy. The device driver has to retry later. @@ -87,6 +88,10 @@  /* node_id is an ACPI PXM and is valid */  #define VIRTIO_MEM_F_ACPI_PXM		0 +/* unplugged memory must not be accessed */ +#define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE	1 +/* plugged memory will remain plugged when suspending+resuming */ +#define VIRTIO_MEM_F_PERSISTENT_SUSPEND		2  /* --- virtio-mem: guest -> host requests --- */ diff --git a/include/uapi/linux/virtio_mmio.h b/include/uapi/linux/virtio_mmio.h index c4b09689ab64..0650f91bea6c 100644 --- a/include/uapi/linux/virtio_mmio.h +++ b/include/uapi/linux/virtio_mmio.h @@ -122,6 +122,17 @@  #define VIRTIO_MMIO_QUEUE_USED_LOW	0x0a0  #define VIRTIO_MMIO_QUEUE_USED_HIGH	0x0a4 +/* Shared memory region id */ +#define VIRTIO_MMIO_SHM_SEL             0x0ac + +/* Shared memory region length, 64 bits in two halves */ +#define VIRTIO_MMIO_SHM_LEN_LOW         0x0b0 +#define VIRTIO_MMIO_SHM_LEN_HIGH        0x0b4 + +/* Shared memory region base address, 64 bits in two halves */ +#define VIRTIO_MMIO_SHM_BASE_LOW        0x0b8 +#define VIRTIO_MMIO_SHM_BASE_HIGH       0x0bc +  /* Configuration atomicity value */  #define VIRTIO_MMIO_CONFIG_GENERATION	0x0fc diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h index 3f55a4215f11..8bf27ab8bcb4 100644 --- a/include/uapi/linux/virtio_net.h +++ b/include/uapi/linux/virtio_net.h @@ -56,14 +56,42 @@  #define VIRTIO_NET_F_MQ	22	/* Device supports Receive Flow  					 * Steering */  #define VIRTIO_NET_F_CTRL_MAC_ADDR 23	/* Set MAC address */ - +#define VIRTIO_NET_F_DEVICE_STATS 50	/* Device can provide device-level statistics. */ +#define VIRTIO_NET_F_VQ_NOTF_COAL 52	/* Device supports virtqueue notification coalescing */ +#define VIRTIO_NET_F_NOTF_COAL	53	/* Device supports notifications coalescing */ +#define VIRTIO_NET_F_GUEST_USO4	54	/* Guest can handle USOv4 in. */ +#define VIRTIO_NET_F_GUEST_USO6	55	/* Guest can handle USOv6 in. */ +#define VIRTIO_NET_F_HOST_USO	56	/* Host can handle USO in. */  #define VIRTIO_NET_F_HASH_REPORT  57	/* Supports hash report */ +#define VIRTIO_NET_F_GUEST_HDRLEN  59	/* Guest provides the exact hdr_len value. */  #define VIRTIO_NET_F_RSS	  60	/* Supports RSS RX steering */  #define VIRTIO_NET_F_RSC_EXT	  61	/* extended coalescing info */  #define VIRTIO_NET_F_STANDBY	  62	/* Act as standby for another device  					 * with the same MAC.  					 */  #define VIRTIO_NET_F_SPEED_DUPLEX 63	/* Device set linkspeed and duplex */ +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO 65 /* Driver can receive +					      * GSO-over-UDP-tunnel packets +					      */ +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM 66 /* Driver handles +						   * GSO-over-UDP-tunnel +						   * packets with partial csum +						   * for the outer header +						   */ +#define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO 67 /* Device can receive +					     * GSO-over-UDP-tunnel packets +					     */ +#define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM 68 /* Device handles +						  * GSO-over-UDP-tunnel +						  * packets with partial csum +						  * for the outer header +						  */ + +/* Offloads bits corresponding to VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO{,_CSUM} + * features + */ +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_MAPPED	46 +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM_MAPPED	47  #ifndef VIRTIO_NET_NO_LEGACY  #define VIRTIO_NET_F_GSO	6	/* Host handles pkts w/ any GSO type */ @@ -125,11 +153,17 @@ struct virtio_net_hdr_v1 {  #define VIRTIO_NET_HDR_F_NEEDS_CSUM	1	/* Use csum_start, csum_offset */  #define VIRTIO_NET_HDR_F_DATA_VALID	2	/* Csum is valid */  #define VIRTIO_NET_HDR_F_RSC_INFO	4	/* rsc info in csum_ fields */ +#define VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM 8	/* UDP tunnel csum offload */  	__u8 flags;  #define VIRTIO_NET_HDR_GSO_NONE		0	/* Not a GSO frame */  #define VIRTIO_NET_HDR_GSO_TCPV4	1	/* GSO frame, IPv4 TCP (TSO) */  #define VIRTIO_NET_HDR_GSO_UDP		3	/* GSO frame, IPv4 UDP (UFO) */  #define VIRTIO_NET_HDR_GSO_TCPV6	4	/* GSO frame, IPv6 TCP */ +#define VIRTIO_NET_HDR_GSO_UDP_L4	5	/* GSO frame, IPv4& IPv6 UDP (USO) */ +#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 0x20 /* UDPv4 tunnel present */ +#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 0x40 /* UDPv6 tunnel present */ +#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL (VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 | \ +				       VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6)  #define VIRTIO_NET_HDR_GSO_ECN		0x80	/* TCP has ECN set */  	__u8 gso_type;  	__virtio16 hdr_len;	/* Ethernet + IP + tcp/udp hdrs */ @@ -174,6 +208,12 @@ struct virtio_net_hdr_v1_hash {  	__le16 padding;  }; +struct virtio_net_hdr_v1_hash_tunnel { +	struct virtio_net_hdr_v1_hash hash_hdr; +	__le16 outer_th_offset; +	__le16 inner_nh_offset; +}; +  #ifndef VIRTIO_NET_NO_LEGACY  /* This header comes first in the scatter-gather list.   * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must @@ -320,6 +360,19 @@ struct virtio_net_rss_config {  	__u8 hash_key_data[/* hash_key_length */];  }; +struct virtio_net_rss_config_hdr { +	__le32 hash_types; +	__le16 indirection_table_mask; +	__le16 unclassified_queue; +	__le16 indirection_table[/* 1 + indirection_table_mask */]; +}; + +struct virtio_net_rss_config_trailer { +	__le16 max_tx_vq; +	__u8 hash_key_length; +	__u8 hash_key_data[/* hash_key_length */]; +}; +   #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG          1  /* @@ -355,4 +408,191 @@ struct virtio_net_hash_config {  #define VIRTIO_NET_CTRL_GUEST_OFFLOADS   5  #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET        0 +/* + * Control notifications coalescing. + * + * Request the device to change the notifications coalescing parameters. + * + * Available with the VIRTIO_NET_F_NOTF_COAL feature bit. + */ +#define VIRTIO_NET_CTRL_NOTF_COAL		6 +/* + * Set the tx-usecs/tx-max-packets parameters. + */ +struct virtio_net_ctrl_coal_tx { +	/* Maximum number of packets to send before a TX notification */ +	__le32 tx_max_packets; +	/* Maximum number of usecs to delay a TX notification */ +	__le32 tx_usecs; +}; + +#define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET		0 + +/* + * Set the rx-usecs/rx-max-packets parameters. + */ +struct virtio_net_ctrl_coal_rx { +	/* Maximum number of packets to receive before a RX notification */ +	__le32 rx_max_packets; +	/* Maximum number of usecs to delay a RX notification */ +	__le32 rx_usecs; +}; + +#define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET		1 +#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET		2 +#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET		3 + +struct virtio_net_ctrl_coal { +	__le32 max_packets; +	__le32 max_usecs; +}; + +struct  virtio_net_ctrl_coal_vq { +	__le16 vqn; +	__le16 reserved; +	struct virtio_net_ctrl_coal coal; +}; + +/* + * Device Statistics + */ +#define VIRTIO_NET_CTRL_STATS         8 +#define VIRTIO_NET_CTRL_STATS_QUERY   0 +#define VIRTIO_NET_CTRL_STATS_GET     1 + +struct virtio_net_stats_capabilities { + +#define VIRTIO_NET_STATS_TYPE_CVQ       (1ULL << 32) + +#define VIRTIO_NET_STATS_TYPE_RX_BASIC  (1ULL << 0) +#define VIRTIO_NET_STATS_TYPE_RX_CSUM   (1ULL << 1) +#define VIRTIO_NET_STATS_TYPE_RX_GSO    (1ULL << 2) +#define VIRTIO_NET_STATS_TYPE_RX_SPEED  (1ULL << 3) + +#define VIRTIO_NET_STATS_TYPE_TX_BASIC  (1ULL << 16) +#define VIRTIO_NET_STATS_TYPE_TX_CSUM   (1ULL << 17) +#define VIRTIO_NET_STATS_TYPE_TX_GSO    (1ULL << 18) +#define VIRTIO_NET_STATS_TYPE_TX_SPEED  (1ULL << 19) + +	__le64 supported_stats_types[1]; +}; + +struct virtio_net_ctrl_queue_stats { +	struct { +		__le16 vq_index; +		__le16 reserved[3]; +		__le64 types_bitmap[1]; +	} stats[1]; +}; + +struct virtio_net_stats_reply_hdr { +#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ       32 + +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC  0 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM   1 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO    2 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED  3 + +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC  16 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM   17 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO    18 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED  19 +	__u8 type; +	__u8 reserved; +	__le16 vq_index; +	__le16 reserved1; +	__le16 size; +}; + +struct virtio_net_stats_cvq { +	struct virtio_net_stats_reply_hdr hdr; + +	__le64 command_num; +	__le64 ok_num; +}; + +struct virtio_net_stats_rx_basic { +	struct virtio_net_stats_reply_hdr hdr; + +	__le64 rx_notifications; + +	__le64 rx_packets; +	__le64 rx_bytes; + +	__le64 rx_interrupts; + +	__le64 rx_drops; +	__le64 rx_drop_overruns; +}; + +struct virtio_net_stats_tx_basic { +	struct virtio_net_stats_reply_hdr hdr; + +	__le64 tx_notifications; + +	__le64 tx_packets; +	__le64 tx_bytes; + +	__le64 tx_interrupts; + +	__le64 tx_drops; +	__le64 tx_drop_malformed; +}; + +struct virtio_net_stats_rx_csum { +	struct virtio_net_stats_reply_hdr hdr; + +	__le64 rx_csum_valid; +	__le64 rx_needs_csum; +	__le64 rx_csum_none; +	__le64 rx_csum_bad; +}; + +struct virtio_net_stats_tx_csum { +	struct virtio_net_stats_reply_hdr hdr; + +	__le64 tx_csum_none; +	__le64 tx_needs_csum; +}; + +struct virtio_net_stats_rx_gso { +	struct virtio_net_stats_reply_hdr hdr; + +	__le64 rx_gso_packets; +	__le64 rx_gso_bytes; +	__le64 rx_gso_packets_coalesced; +	__le64 rx_gso_bytes_coalesced; +}; + +struct virtio_net_stats_tx_gso { +	struct virtio_net_stats_reply_hdr hdr; + +	__le64 tx_gso_packets; +	__le64 tx_gso_bytes; +	__le64 tx_gso_segments; +	__le64 tx_gso_segments_bytes; +	__le64 tx_gso_packets_noseg; +	__le64 tx_gso_bytes_noseg; +}; + +struct virtio_net_stats_rx_speed { +	struct virtio_net_stats_reply_hdr hdr; + +	/* rx_{packets,bytes}_allowance_exceeded are too long. So rename to +	 * short name. +	 */ +	__le64 rx_ratelimit_packets; +	__le64 rx_ratelimit_bytes; +}; + +struct virtio_net_stats_tx_speed { +	struct virtio_net_stats_reply_hdr hdr; + +	/* tx_{packets,bytes}_allowance_exceeded are too long. So rename to +	 * short name. +	 */ +	__le64 tx_ratelimit_packets; +	__le64 tx_ratelimit_bytes; +}; +  #endif /* _UAPI_LINUX_VIRTIO_NET_H */ diff --git a/include/uapi/linux/virtio_pci.h b/include/uapi/linux/virtio_pci.h index 90007a1abcab..c691ac210ce2 100644 --- a/include/uapi/linux/virtio_pci.h +++ b/include/uapi/linux/virtio_pci.h @@ -40,6 +40,7 @@  #define _LINUX_VIRTIO_PCI_H  #include <linux/types.h> +#include <linux/kernel.h>  #ifndef VIRTIO_PCI_NO_LEGACY @@ -113,6 +114,10 @@  #define VIRTIO_PCI_CAP_DEVICE_CFG	4  /* PCI configuration access */  #define VIRTIO_PCI_CAP_PCI_CFG		5 +/* Additional shared memory capability */ +#define VIRTIO_PCI_CAP_SHARED_MEMORY_CFG 8 +/* PCI vendor data configuration */ +#define VIRTIO_PCI_CAP_VENDOR_CFG	9  /* This is the PCI capability header: */  struct virtio_pci_cap { @@ -121,11 +126,30 @@ struct virtio_pci_cap {  	__u8 cap_len;		/* Generic PCI field: capability length */  	__u8 cfg_type;		/* Identifies the structure. */  	__u8 bar;		/* Where to find it. */ -	__u8 padding[3];	/* Pad to full dword. */ +	__u8 id;		/* Multiple capabilities of the same type */ +	__u8 padding[2];	/* Pad to full dword. */  	__le32 offset;		/* Offset within bar. */  	__le32 length;		/* Length of the structure, in bytes. */  }; +/* This is the PCI vendor data capability header: */ +struct virtio_pci_vndr_data { +	__u8 cap_vndr;		/* Generic PCI field: PCI_CAP_ID_VNDR */ +	__u8 cap_next;		/* Generic PCI field: next ptr. */ +	__u8 cap_len;		/* Generic PCI field: capability length */ +	__u8 cfg_type;		/* Identifies the structure. */ +	__u16 vendor_id;	/* Identifies the vendor-specific format. */ +	/* For Vendor Definition */ +	/* Pads structure to a multiple of 4 bytes */ +	/* Reads must not have side effects */ +}; + +struct virtio_pci_cap64 { +	struct virtio_pci_cap cap; +	__le32 offset_hi;             /* Most sig 32 bits of offset */ +	__le32 length_hi;             /* Most sig 32 bits of length */ +}; +  struct virtio_pci_notify_cap {  	struct virtio_pci_cap cap;  	__le32 notify_off_multiplier;	/* Multiplier for queue_notify_off. */ @@ -157,6 +181,20 @@ struct virtio_pci_common_cfg {  	__le32 queue_used_hi;		/* read-write */  }; +/* + * Warning: do not use sizeof on this: use offsetofend for + * specific fields you need. + */ +struct virtio_pci_modern_common_cfg { +	struct virtio_pci_common_cfg cfg; + +	__le16 queue_notify_data;	/* read-write */ +	__le16 queue_reset;		/* read-write */ + +	__le16 admin_queue_index;	/* read-only */ +	__le16 admin_queue_num;		/* read-only */ +}; +  /* Fields in VIRTIO_PCI_CAP_PCI_CFG: */  struct virtio_pci_cfg_cap {  	struct virtio_pci_cap cap; @@ -193,7 +231,205 @@ struct virtio_pci_cfg_cap {  #define VIRTIO_PCI_COMMON_Q_AVAILHI	44  #define VIRTIO_PCI_COMMON_Q_USEDLO	48  #define VIRTIO_PCI_COMMON_Q_USEDHI	52 +#define VIRTIO_PCI_COMMON_Q_NDATA	56 +#define VIRTIO_PCI_COMMON_Q_RESET	58 +#define VIRTIO_PCI_COMMON_ADM_Q_IDX	60 +#define VIRTIO_PCI_COMMON_ADM_Q_NUM	62  #endif /* VIRTIO_PCI_NO_MODERN */ +/* Admin command status. */ +#define VIRTIO_ADMIN_STATUS_OK		0 + +/* Admin command opcode. */ +#define VIRTIO_ADMIN_CMD_LIST_QUERY	0x0 +#define VIRTIO_ADMIN_CMD_LIST_USE	0x1 + +/* Admin command group type. */ +#define VIRTIO_ADMIN_GROUP_TYPE_SELF	0x0 +#define VIRTIO_ADMIN_GROUP_TYPE_SRIOV	0x1 + +/* Transitional device admin command. */ +#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_WRITE	0x2 +#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_READ		0x3 +#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_WRITE		0x4 +#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_READ		0x5 +#define VIRTIO_ADMIN_CMD_LEGACY_NOTIFY_INFO		0x6 + +/* Device parts access commands. */ +#define VIRTIO_ADMIN_CMD_CAP_ID_LIST_QUERY		0x7 +#define VIRTIO_ADMIN_CMD_DEVICE_CAP_GET			0x8 +#define VIRTIO_ADMIN_CMD_DRIVER_CAP_SET			0x9 +#define VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE		0xa +#define VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY		0xd +#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_GET		0xe +#define VIRTIO_ADMIN_CMD_DEV_PARTS_GET			0xf +#define VIRTIO_ADMIN_CMD_DEV_PARTS_SET			0x10 +#define VIRTIO_ADMIN_CMD_DEV_MODE_SET			0x11 + +struct virtio_admin_cmd_hdr { +	__le16 opcode; +	/* +	 * 1 - SR-IOV +	 * 2-65535 - reserved +	 */ +	__le16 group_type; +	/* Unused, reserved for future extensions. */ +	__u8 reserved1[12]; +	__le64 group_member_id; +}; + +struct virtio_admin_cmd_status { +	__le16 status; +	__le16 status_qualifier; +	/* Unused, reserved for future extensions. */ +	__u8 reserved2[4]; +}; + +struct virtio_admin_cmd_legacy_wr_data { +	__u8 offset; /* Starting offset of the register(s) to write. */ +	__u8 reserved[7]; +	__u8 registers[]; +}; + +struct virtio_admin_cmd_legacy_rd_data { +	__u8 offset; /* Starting offset of the register(s) to read. */ +}; + +#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_END 0 +#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_OWNER_DEV 0x1 +#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_OWNER_MEM 0x2 + +#define VIRTIO_ADMIN_CMD_MAX_NOTIFY_INFO 4 + +struct virtio_admin_cmd_notify_info_data { +	__u8 flags; /* 0 = end of list, 1 = owner device, 2 = member device */ +	__u8 bar; /* BAR of the member or the owner device */ +	__u8 padding[6]; +	__le64 offset; /* Offset within bar. */ +}; + +struct virtio_admin_cmd_notify_info_result { +	struct virtio_admin_cmd_notify_info_data entries[VIRTIO_ADMIN_CMD_MAX_NOTIFY_INFO]; +}; + +#define VIRTIO_DEV_PARTS_CAP 0x0000 + +struct virtio_dev_parts_cap { +	__u8 get_parts_resource_objects_limit; +	__u8 set_parts_resource_objects_limit; +}; + +#define MAX_CAP_ID __KERNEL_DIV_ROUND_UP(VIRTIO_DEV_PARTS_CAP + 1, 64) + +struct virtio_admin_cmd_query_cap_id_result { +	__le64 supported_caps[MAX_CAP_ID]; +}; + +struct virtio_admin_cmd_cap_get_data { +	__le16 id; +	__u8 reserved[6]; +}; + +struct virtio_admin_cmd_cap_set_data { +	__le16 id; +	__u8 reserved[6]; +	__u8 cap_specific_data[]; +}; + +struct virtio_admin_cmd_resource_obj_cmd_hdr { +	__le16 type; +	__u8 reserved[2]; +	__le32 id; /* Indicates unique resource object id per resource object type */ +}; + +struct virtio_admin_cmd_resource_obj_create_data { +	struct virtio_admin_cmd_resource_obj_cmd_hdr hdr; +	__le64 flags; +	__u8 resource_obj_specific_data[]; +}; + +#define VIRTIO_RESOURCE_OBJ_DEV_PARTS 0 + +#define VIRTIO_RESOURCE_OBJ_DEV_PARTS_TYPE_GET 0 +#define VIRTIO_RESOURCE_OBJ_DEV_PARTS_TYPE_SET 1 + +struct virtio_resource_obj_dev_parts { +	__u8 type; +	__u8 reserved[7]; +}; + +#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_TYPE_SIZE 0 +#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_TYPE_COUNT 1 +#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_TYPE_LIST 2 + +struct virtio_admin_cmd_dev_parts_metadata_data { +	struct virtio_admin_cmd_resource_obj_cmd_hdr hdr; +	__u8 type; +	__u8 reserved[7]; +}; + +#define VIRTIO_DEV_PART_F_OPTIONAL 0 + +struct virtio_dev_part_hdr { +	__le16 part_type; +	__u8 flags; +	__u8 reserved; +	union { +		struct { +			__le32 offset; +			__le32 reserved; +		} pci_common_cfg; +		struct { +			__le16 index; +			__u8 reserved[6]; +		} vq_index; +	} selector; +	__le32 length; +}; + +struct virtio_dev_part { +	struct virtio_dev_part_hdr hdr; +	__u8 value[]; +}; + +struct virtio_admin_cmd_dev_parts_metadata_result { +	union { +		struct { +			__le32 size; +			__le32 reserved; +		} parts_size; +		struct { +			__le32 count; +			__le32 reserved; +		} hdr_list_count; +		struct { +			__le32 count; +			__le32 reserved; +			struct virtio_dev_part_hdr hdrs[]; +		} hdr_list; +	}; +}; + +#define VIRTIO_ADMIN_CMD_DEV_PARTS_GET_TYPE_SELECTED 0 +#define VIRTIO_ADMIN_CMD_DEV_PARTS_GET_TYPE_ALL 1 + +struct virtio_admin_cmd_dev_parts_get_data { +	struct virtio_admin_cmd_resource_obj_cmd_hdr hdr; +	__u8 type; +	__u8 reserved[7]; +	struct virtio_dev_part_hdr hdr_list[]; +}; + +struct virtio_admin_cmd_dev_parts_set_data { +	struct virtio_admin_cmd_resource_obj_cmd_hdr hdr; +	struct virtio_dev_part parts[]; +}; + +#define VIRTIO_ADMIN_CMD_DEV_MODE_F_STOPPED 0 + +struct virtio_admin_cmd_dev_mode_set_data { +	__u8 flags; +}; +  #endif diff --git a/include/uapi/linux/virtio_pcidev.h b/include/uapi/linux/virtio_pcidev.h new file mode 100644 index 000000000000..668b07ce515b --- /dev/null +++ b/include/uapi/linux/virtio_pcidev.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* + * Copyright (C) 2021 Intel Corporation + * Author: Johannes Berg <johannes@sipsolutions.net> + */ +#ifndef _UAPI_LINUX_VIRTIO_PCIDEV_H +#define _UAPI_LINUX_VIRTIO_PCIDEV_H +#include <linux/types.h> + +/** + * enum virtio_pcidev_ops - virtual PCI device operations + * @VIRTIO_PCIDEV_OP_RESERVED: reserved to catch errors + * @VIRTIO_PCIDEV_OP_CFG_READ: read config space, size is 1, 2, 4 or 8; + *	the @data field should be filled in by the device (in little endian). + * @VIRTIO_PCIDEV_OP_CFG_WRITE: write config space, size is 1, 2, 4 or 8; + *	the @data field contains the data to write (in little endian). + * @VIRTIO_PCIDEV_OP_MMIO_READ: read BAR mem/pio, size can be variable; + *	the @data field should be filled in by the device (in little endian). + * @VIRTIO_PCIDEV_OP_MMIO_WRITE: write BAR mem/pio, size can be variable; + *	the @data field contains the data to write (in little endian). + * @VIRTIO_PCIDEV_OP_MMIO_MEMSET: memset MMIO, size is variable but + *	the @data field only has one byte (unlike @VIRTIO_PCIDEV_OP_MMIO_WRITE) + * @VIRTIO_PCIDEV_OP_INT: legacy INTx# pin interrupt, the addr field is 1-4 for + *	the number + * @VIRTIO_PCIDEV_OP_MSI: MSI(-X) interrupt, this message basically transports + *	the 16- or 32-bit write that would otherwise be done into memory, + *	analogous to the write messages (@VIRTIO_PCIDEV_OP_MMIO_WRITE) above + * @VIRTIO_PCIDEV_OP_PME: Dummy message whose content is ignored (and should be + *	all zeroes) to signal the PME# pin. + */ +enum virtio_pcidev_ops { +	VIRTIO_PCIDEV_OP_RESERVED = 0, +	VIRTIO_PCIDEV_OP_CFG_READ, +	VIRTIO_PCIDEV_OP_CFG_WRITE, +	VIRTIO_PCIDEV_OP_MMIO_READ, +	VIRTIO_PCIDEV_OP_MMIO_WRITE, +	VIRTIO_PCIDEV_OP_MMIO_MEMSET, +	VIRTIO_PCIDEV_OP_INT, +	VIRTIO_PCIDEV_OP_MSI, +	VIRTIO_PCIDEV_OP_PME, +}; + +/** + * struct virtio_pcidev_msg - virtio PCI device operation + * @op: the operation to do + * @bar: the bar (only with BAR read/write messages) + * @reserved: reserved + * @size: the size of the read/write (in bytes) + * @addr: the address to read/write + * @data: the data, normally @size long, but just one byte for + *	%VIRTIO_PCIDEV_OP_MMIO_MEMSET + * + * Note: the fields are all in native (CPU) endian, however, the + * @data values will often be in little endian (see the ops above.) + */ +struct virtio_pcidev_msg { +	__u8 op; +	__u8 bar; +	__u16 reserved; +	__u32 size; +	__u64 addr; +	__u8 data[]; +}; + +#endif /* _UAPI_LINUX_VIRTIO_PCIDEV_H */ diff --git a/include/uapi/linux/virtio_pmem.h b/include/uapi/linux/virtio_pmem.h index d676b3620383..ede4f3564977 100644 --- a/include/uapi/linux/virtio_pmem.h +++ b/include/uapi/linux/virtio_pmem.h @@ -14,6 +14,13 @@  #include <linux/virtio_ids.h>  #include <linux/virtio_config.h> +/* Feature bits */ +/* guest physical address range will be indicated as shared memory region 0 */ +#define VIRTIO_PMEM_F_SHMEM_REGION 0 + +/* shmid of the shared memory region corresponding to the pmem */ +#define VIRTIO_PMEM_SHMEM_REGION_ID 0 +  struct virtio_pmem_config {  	__le64 start;  	__le64 size; diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h index 476d3e5c0fe7..f8c20d3de8da 100644 --- a/include/uapi/linux/virtio_ring.h +++ b/include/uapi/linux/virtio_ring.h @@ -93,15 +93,21 @@  #define VRING_USED_ALIGN_SIZE 4  #define VRING_DESC_ALIGN_SIZE 16 -/* Virtio ring descriptors: 16 bytes.  These can chain together via "next". */ +/** + * struct vring_desc - Virtio ring descriptors, + * 16 bytes long. These can chain together via @next. + * + * @addr: buffer address (guest-physical) + * @len: buffer length + * @flags: descriptor flags + * @next: index of the next descriptor in the chain, + *        if the VRING_DESC_F_NEXT flag is set. We chain unused + *        descriptors via this, too. + */  struct vring_desc { -	/* Address (guest-physical). */  	__virtio64 addr; -	/* Length. */  	__virtio32 len; -	/* The flags as indicated above. */  	__virtio16 flags; -	/* We chain unused descriptors via this, too */  	__virtio16 next;  }; diff --git a/include/uapi/linux/virtio_rtc.h b/include/uapi/linux/virtio_rtc.h new file mode 100644 index 000000000000..85ee8f013661 --- /dev/null +++ b/include/uapi/linux/virtio_rtc.h @@ -0,0 +1,237 @@ +/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* + * Copyright (C) 2022-2024 OpenSynergy GmbH + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef _LINUX_VIRTIO_RTC_H +#define _LINUX_VIRTIO_RTC_H + +#include <linux/types.h> + +/* alarm feature */ +#define VIRTIO_RTC_F_ALARM	0 + +/* read request message types */ + +#define VIRTIO_RTC_REQ_READ			0x0001 +#define VIRTIO_RTC_REQ_READ_CROSS		0x0002 + +/* control request message types */ + +#define VIRTIO_RTC_REQ_CFG			0x1000 +#define VIRTIO_RTC_REQ_CLOCK_CAP		0x1001 +#define VIRTIO_RTC_REQ_CROSS_CAP		0x1002 +#define VIRTIO_RTC_REQ_READ_ALARM		0x1003 +#define VIRTIO_RTC_REQ_SET_ALARM		0x1004 +#define VIRTIO_RTC_REQ_SET_ALARM_ENABLED	0x1005 + +/* alarmq message types */ + +#define VIRTIO_RTC_NOTIF_ALARM			0x2000 + +/* Message headers */ + +/** common request header */ +struct virtio_rtc_req_head { +	__le16 msg_type; +	__u8 reserved[6]; +}; + +/** common response header */ +struct virtio_rtc_resp_head { +#define VIRTIO_RTC_S_OK			0 +#define VIRTIO_RTC_S_EOPNOTSUPP		2 +#define VIRTIO_RTC_S_ENODEV		3 +#define VIRTIO_RTC_S_EINVAL		4 +#define VIRTIO_RTC_S_EIO		5 +	__u8 status; +	__u8 reserved[7]; +}; + +/** common notification header */ +struct virtio_rtc_notif_head { +	__le16 msg_type; +	__u8 reserved[6]; +}; + +/* read requests */ + +/* VIRTIO_RTC_REQ_READ message */ + +struct virtio_rtc_req_read { +	struct virtio_rtc_req_head head; +	__le16 clock_id; +	__u8 reserved[6]; +}; + +struct virtio_rtc_resp_read { +	struct virtio_rtc_resp_head head; +	__le64 clock_reading; +}; + +/* VIRTIO_RTC_REQ_READ_CROSS message */ + +struct virtio_rtc_req_read_cross { +	struct virtio_rtc_req_head head; +	__le16 clock_id; +/* Arm Generic Timer Counter-timer Virtual Count Register (CNTVCT_EL0) */ +#define VIRTIO_RTC_COUNTER_ARM_VCT	0 +/* x86 Time-Stamp Counter */ +#define VIRTIO_RTC_COUNTER_X86_TSC	1 +/* Invalid */ +#define VIRTIO_RTC_COUNTER_INVALID	0xFF +	__u8 hw_counter; +	__u8 reserved[5]; +}; + +struct virtio_rtc_resp_read_cross { +	struct virtio_rtc_resp_head head; +	__le64 clock_reading; +	__le64 counter_cycles; +}; + +/* control requests */ + +/* VIRTIO_RTC_REQ_CFG message */ + +struct virtio_rtc_req_cfg { +	struct virtio_rtc_req_head head; +	/* no request params */ +}; + +struct virtio_rtc_resp_cfg { +	struct virtio_rtc_resp_head head; +	/** # of clocks -> clock ids < num_clocks are valid */ +	__le16 num_clocks; +	__u8 reserved[6]; +}; + +/* VIRTIO_RTC_REQ_CLOCK_CAP message */ + +struct virtio_rtc_req_clock_cap { +	struct virtio_rtc_req_head head; +	__le16 clock_id; +	__u8 reserved[6]; +}; + +struct virtio_rtc_resp_clock_cap { +	struct virtio_rtc_resp_head head; +#define VIRTIO_RTC_CLOCK_UTC			0 +#define VIRTIO_RTC_CLOCK_TAI			1 +#define VIRTIO_RTC_CLOCK_MONOTONIC		2 +#define VIRTIO_RTC_CLOCK_UTC_SMEARED		3 +#define VIRTIO_RTC_CLOCK_UTC_MAYBE_SMEARED	4 +	__u8 type; +#define VIRTIO_RTC_SMEAR_UNSPECIFIED	0 +#define VIRTIO_RTC_SMEAR_NOON_LINEAR	1 +#define VIRTIO_RTC_SMEAR_UTC_SLS	2 +	__u8 leap_second_smearing; +#define VIRTIO_RTC_FLAG_ALARM_CAP		(1 << 0) +	__u8 flags; +	__u8 reserved[5]; +}; + +/* VIRTIO_RTC_REQ_CROSS_CAP message */ + +struct virtio_rtc_req_cross_cap { +	struct virtio_rtc_req_head head; +	__le16 clock_id; +	__u8 hw_counter; +	__u8 reserved[5]; +}; + +struct virtio_rtc_resp_cross_cap { +	struct virtio_rtc_resp_head head; +#define VIRTIO_RTC_FLAG_CROSS_CAP	(1 << 0) +	__u8 flags; +	__u8 reserved[7]; +}; + +/* VIRTIO_RTC_REQ_READ_ALARM message */ + +struct virtio_rtc_req_read_alarm { +	struct virtio_rtc_req_head head; +	__le16 clock_id; +	__u8 reserved[6]; +}; + +struct virtio_rtc_resp_read_alarm { +	struct virtio_rtc_resp_head head; +	__le64 alarm_time; +#define VIRTIO_RTC_FLAG_ALARM_ENABLED	(1 << 0) +	__u8 flags; +	__u8 reserved[7]; +}; + +/* VIRTIO_RTC_REQ_SET_ALARM message */ + +struct virtio_rtc_req_set_alarm { +	struct virtio_rtc_req_head head; +	__le64 alarm_time; +	__le16 clock_id; +	/* flag VIRTIO_RTC_FLAG_ALARM_ENABLED */ +	__u8 flags; +	__u8 reserved[5]; +}; + +struct virtio_rtc_resp_set_alarm { +	struct virtio_rtc_resp_head head; +	/* no response params */ +}; + +/* VIRTIO_RTC_REQ_SET_ALARM_ENABLED message */ + +struct virtio_rtc_req_set_alarm_enabled { +	struct virtio_rtc_req_head head; +	__le16 clock_id; +	/* flag VIRTIO_RTC_ALARM_ENABLED */ +	__u8 flags; +	__u8 reserved[5]; +}; + +struct virtio_rtc_resp_set_alarm_enabled { +	struct virtio_rtc_resp_head head; +	/* no response params */ +}; + +/** Union of request types for requestq */ +union virtio_rtc_req_requestq { +	struct virtio_rtc_req_read read; +	struct virtio_rtc_req_read_cross read_cross; +	struct virtio_rtc_req_cfg cfg; +	struct virtio_rtc_req_clock_cap clock_cap; +	struct virtio_rtc_req_cross_cap cross_cap; +	struct virtio_rtc_req_read_alarm read_alarm; +	struct virtio_rtc_req_set_alarm set_alarm; +	struct virtio_rtc_req_set_alarm_enabled set_alarm_enabled; +}; + +/** Union of response types for requestq */ +union virtio_rtc_resp_requestq { +	struct virtio_rtc_resp_read read; +	struct virtio_rtc_resp_read_cross read_cross; +	struct virtio_rtc_resp_cfg cfg; +	struct virtio_rtc_resp_clock_cap clock_cap; +	struct virtio_rtc_resp_cross_cap cross_cap; +	struct virtio_rtc_resp_read_alarm read_alarm; +	struct virtio_rtc_resp_set_alarm set_alarm; +	struct virtio_rtc_resp_set_alarm_enabled set_alarm_enabled; +}; + +/* alarmq notifications */ + +/* VIRTIO_RTC_NOTIF_ALARM notification */ + +struct virtio_rtc_notif_alarm { +	struct virtio_rtc_notif_head head; +	__le16 clock_id; +	__u8 reserved[6]; +}; + +/** Union of notification types for alarmq */ +union virtio_rtc_notif_alarmq { +	struct virtio_rtc_notif_alarm alarm; +}; + +#endif /* _LINUX_VIRTIO_RTC_H */ diff --git a/include/uapi/linux/virtio_scmi.h b/include/uapi/linux/virtio_scmi.h new file mode 100644 index 000000000000..f8ddd04a3ace --- /dev/null +++ b/include/uapi/linux/virtio_scmi.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* + * Copyright (C) 2020-2021 OpenSynergy GmbH + * Copyright (C) 2021 ARM Ltd. + */ + +#ifndef _UAPI_LINUX_VIRTIO_SCMI_H +#define _UAPI_LINUX_VIRTIO_SCMI_H + +#include <linux/virtio_types.h> + +/* Device implements some SCMI notifications, or delayed responses. */ +#define VIRTIO_SCMI_F_P2A_CHANNELS 0 + +/* Device implements any SCMI statistics shared memory region */ +#define VIRTIO_SCMI_F_SHARED_MEMORY 1 + +/* Virtqueues */ + +#define VIRTIO_SCMI_VQ_TX 0 /* cmdq */ +#define VIRTIO_SCMI_VQ_RX 1 /* eventq */ +#define VIRTIO_SCMI_VQ_MAX_CNT 2 + +#endif /* _UAPI_LINUX_VIRTIO_SCMI_H */ diff --git a/include/uapi/linux/virtio_snd.h b/include/uapi/linux/virtio_snd.h new file mode 100644 index 000000000000..a4cfb9f6561a --- /dev/null +++ b/include/uapi/linux/virtio_snd.h @@ -0,0 +1,488 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Copyright (C) 2021 OpenSynergy GmbH + */ +#ifndef VIRTIO_SND_IF_H +#define VIRTIO_SND_IF_H + +#include <linux/virtio_types.h> + +/******************************************************************************* + * FEATURE BITS + */ +enum { +	/* device supports control elements */ +	VIRTIO_SND_F_CTLS = 0 +}; + +/******************************************************************************* + * CONFIGURATION SPACE + */ +struct virtio_snd_config { +	/* # of available physical jacks */ +	__le32 jacks; +	/* # of available PCM streams */ +	__le32 streams; +	/* # of available channel maps */ +	__le32 chmaps; +	/* # of available control elements (if VIRTIO_SND_F_CTLS) */ +	__le32 controls; +}; + +enum { +	/* device virtqueue indexes */ +	VIRTIO_SND_VQ_CONTROL = 0, +	VIRTIO_SND_VQ_EVENT, +	VIRTIO_SND_VQ_TX, +	VIRTIO_SND_VQ_RX, +	/* # of device virtqueues */ +	VIRTIO_SND_VQ_MAX +}; + +/******************************************************************************* + * COMMON DEFINITIONS + */ + +/* supported dataflow directions */ +enum { +	VIRTIO_SND_D_OUTPUT = 0, +	VIRTIO_SND_D_INPUT +}; + +enum { +	/* jack control request types */ +	VIRTIO_SND_R_JACK_INFO = 1, +	VIRTIO_SND_R_JACK_REMAP, + +	/* PCM control request types */ +	VIRTIO_SND_R_PCM_INFO = 0x0100, +	VIRTIO_SND_R_PCM_SET_PARAMS, +	VIRTIO_SND_R_PCM_PREPARE, +	VIRTIO_SND_R_PCM_RELEASE, +	VIRTIO_SND_R_PCM_START, +	VIRTIO_SND_R_PCM_STOP, + +	/* channel map control request types */ +	VIRTIO_SND_R_CHMAP_INFO = 0x0200, + +	/* control element request types */ +	VIRTIO_SND_R_CTL_INFO = 0x0300, +	VIRTIO_SND_R_CTL_ENUM_ITEMS, +	VIRTIO_SND_R_CTL_READ, +	VIRTIO_SND_R_CTL_WRITE, +	VIRTIO_SND_R_CTL_TLV_READ, +	VIRTIO_SND_R_CTL_TLV_WRITE, +	VIRTIO_SND_R_CTL_TLV_COMMAND, + +	/* jack event types */ +	VIRTIO_SND_EVT_JACK_CONNECTED = 0x1000, +	VIRTIO_SND_EVT_JACK_DISCONNECTED, + +	/* PCM event types */ +	VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED = 0x1100, +	VIRTIO_SND_EVT_PCM_XRUN, + +	/* control element event types */ +	VIRTIO_SND_EVT_CTL_NOTIFY = 0x1200, + +	/* common status codes */ +	VIRTIO_SND_S_OK = 0x8000, +	VIRTIO_SND_S_BAD_MSG, +	VIRTIO_SND_S_NOT_SUPP, +	VIRTIO_SND_S_IO_ERR +}; + +/* common header */ +struct virtio_snd_hdr { +	__le32 code; +}; + +/* event notification */ +struct virtio_snd_event { +	/* VIRTIO_SND_EVT_XXX */ +	struct virtio_snd_hdr hdr; +	/* optional event data */ +	__le32 data; +}; + +/* common control request to query an item information */ +struct virtio_snd_query_info { +	/* VIRTIO_SND_R_XXX_INFO */ +	struct virtio_snd_hdr hdr; +	/* item start identifier */ +	__le32 start_id; +	/* item count to query */ +	__le32 count; +	/* item information size in bytes */ +	__le32 size; +}; + +/* common item information header */ +struct virtio_snd_info { +	/* function group node id (High Definition Audio Specification 7.1.2) */ +	__le32 hda_fn_nid; +}; + +/******************************************************************************* + * JACK CONTROL MESSAGES + */ +struct virtio_snd_jack_hdr { +	/* VIRTIO_SND_R_JACK_XXX */ +	struct virtio_snd_hdr hdr; +	/* 0 ... virtio_snd_config::jacks - 1 */ +	__le32 jack_id; +}; + +/* supported jack features */ +enum { +	VIRTIO_SND_JACK_F_REMAP = 0 +}; + +struct virtio_snd_jack_info { +	/* common header */ +	struct virtio_snd_info hdr; +	/* supported feature bit map (1 << VIRTIO_SND_JACK_F_XXX) */ +	__le32 features; +	/* pin configuration (High Definition Audio Specification 7.3.3.31) */ +	__le32 hda_reg_defconf; +	/* pin capabilities (High Definition Audio Specification 7.3.4.9) */ +	__le32 hda_reg_caps; +	/* current jack connection status (0: disconnected, 1: connected) */ +	__u8 connected; + +	__u8 padding[7]; +}; + +/* jack remapping control request */ +struct virtio_snd_jack_remap { +	/* .code = VIRTIO_SND_R_JACK_REMAP */ +	struct virtio_snd_jack_hdr hdr; +	/* selected association number */ +	__le32 association; +	/* selected sequence number */ +	__le32 sequence; +}; + +/******************************************************************************* + * PCM CONTROL MESSAGES + */ +struct virtio_snd_pcm_hdr { +	/* VIRTIO_SND_R_PCM_XXX */ +	struct virtio_snd_hdr hdr; +	/* 0 ... virtio_snd_config::streams - 1 */ +	__le32 stream_id; +}; + +/* supported PCM stream features */ +enum { +	VIRTIO_SND_PCM_F_SHMEM_HOST = 0, +	VIRTIO_SND_PCM_F_SHMEM_GUEST, +	VIRTIO_SND_PCM_F_MSG_POLLING, +	VIRTIO_SND_PCM_F_EVT_SHMEM_PERIODS, +	VIRTIO_SND_PCM_F_EVT_XRUNS +}; + +/* supported PCM sample formats */ +enum { +	/* analog formats (width / physical width) */ +	VIRTIO_SND_PCM_FMT_IMA_ADPCM = 0,	/*  4 /  4 bits */ +	VIRTIO_SND_PCM_FMT_MU_LAW,		/*  8 /  8 bits */ +	VIRTIO_SND_PCM_FMT_A_LAW,		/*  8 /  8 bits */ +	VIRTIO_SND_PCM_FMT_S8,			/*  8 /  8 bits */ +	VIRTIO_SND_PCM_FMT_U8,			/*  8 /  8 bits */ +	VIRTIO_SND_PCM_FMT_S16,			/* 16 / 16 bits */ +	VIRTIO_SND_PCM_FMT_U16,			/* 16 / 16 bits */ +	VIRTIO_SND_PCM_FMT_S18_3,		/* 18 / 24 bits */ +	VIRTIO_SND_PCM_FMT_U18_3,		/* 18 / 24 bits */ +	VIRTIO_SND_PCM_FMT_S20_3,		/* 20 / 24 bits */ +	VIRTIO_SND_PCM_FMT_U20_3,		/* 20 / 24 bits */ +	VIRTIO_SND_PCM_FMT_S24_3,		/* 24 / 24 bits */ +	VIRTIO_SND_PCM_FMT_U24_3,		/* 24 / 24 bits */ +	VIRTIO_SND_PCM_FMT_S20,			/* 20 / 32 bits */ +	VIRTIO_SND_PCM_FMT_U20,			/* 20 / 32 bits */ +	VIRTIO_SND_PCM_FMT_S24,			/* 24 / 32 bits */ +	VIRTIO_SND_PCM_FMT_U24,			/* 24 / 32 bits */ +	VIRTIO_SND_PCM_FMT_S32,			/* 32 / 32 bits */ +	VIRTIO_SND_PCM_FMT_U32,			/* 32 / 32 bits */ +	VIRTIO_SND_PCM_FMT_FLOAT,		/* 32 / 32 bits */ +	VIRTIO_SND_PCM_FMT_FLOAT64,		/* 64 / 64 bits */ +	/* digital formats (width / physical width) */ +	VIRTIO_SND_PCM_FMT_DSD_U8,		/*  8 /  8 bits */ +	VIRTIO_SND_PCM_FMT_DSD_U16,		/* 16 / 16 bits */ +	VIRTIO_SND_PCM_FMT_DSD_U32,		/* 32 / 32 bits */ +	VIRTIO_SND_PCM_FMT_IEC958_SUBFRAME	/* 32 / 32 bits */ +}; + +/* supported PCM frame rates */ +enum { +	VIRTIO_SND_PCM_RATE_5512 = 0, +	VIRTIO_SND_PCM_RATE_8000, +	VIRTIO_SND_PCM_RATE_11025, +	VIRTIO_SND_PCM_RATE_16000, +	VIRTIO_SND_PCM_RATE_22050, +	VIRTIO_SND_PCM_RATE_32000, +	VIRTIO_SND_PCM_RATE_44100, +	VIRTIO_SND_PCM_RATE_48000, +	VIRTIO_SND_PCM_RATE_64000, +	VIRTIO_SND_PCM_RATE_88200, +	VIRTIO_SND_PCM_RATE_96000, +	VIRTIO_SND_PCM_RATE_176400, +	VIRTIO_SND_PCM_RATE_192000, +	VIRTIO_SND_PCM_RATE_384000 +}; + +struct virtio_snd_pcm_info { +	/* common header */ +	struct virtio_snd_info hdr; +	/* supported feature bit map (1 << VIRTIO_SND_PCM_F_XXX) */ +	__le32 features; +	/* supported sample format bit map (1 << VIRTIO_SND_PCM_FMT_XXX) */ +	__le64 formats; +	/* supported frame rate bit map (1 << VIRTIO_SND_PCM_RATE_XXX) */ +	__le64 rates; +	/* dataflow direction (VIRTIO_SND_D_XXX) */ +	__u8 direction; +	/* minimum # of supported channels */ +	__u8 channels_min; +	/* maximum # of supported channels */ +	__u8 channels_max; + +	__u8 padding[5]; +}; + +/* set PCM stream format */ +struct virtio_snd_pcm_set_params { +	/* .code = VIRTIO_SND_R_PCM_SET_PARAMS */ +	struct virtio_snd_pcm_hdr hdr; +	/* size of the hardware buffer */ +	__le32 buffer_bytes; +	/* size of the hardware period */ +	__le32 period_bytes; +	/* selected feature bit map (1 << VIRTIO_SND_PCM_F_XXX) */ +	__le32 features; +	/* selected # of channels */ +	__u8 channels; +	/* selected sample format (VIRTIO_SND_PCM_FMT_XXX) */ +	__u8 format; +	/* selected frame rate (VIRTIO_SND_PCM_RATE_XXX) */ +	__u8 rate; + +	__u8 padding; +}; + +/******************************************************************************* + * PCM I/O MESSAGES + */ + +/* I/O request header */ +struct virtio_snd_pcm_xfer { +	/* 0 ... virtio_snd_config::streams - 1 */ +	__le32 stream_id; +}; + +/* I/O request status */ +struct virtio_snd_pcm_status { +	/* VIRTIO_SND_S_XXX */ +	__le32 status; +	/* current device latency */ +	__le32 latency_bytes; +}; + +/******************************************************************************* + * CHANNEL MAP CONTROL MESSAGES + */ +struct virtio_snd_chmap_hdr { +	/* VIRTIO_SND_R_CHMAP_XXX */ +	struct virtio_snd_hdr hdr; +	/* 0 ... virtio_snd_config::chmaps - 1 */ +	__le32 chmap_id; +}; + +/* standard channel position definition */ +enum { +	VIRTIO_SND_CHMAP_NONE = 0,	/* undefined */ +	VIRTIO_SND_CHMAP_NA,		/* silent */ +	VIRTIO_SND_CHMAP_MONO,		/* mono stream */ +	VIRTIO_SND_CHMAP_FL,		/* front left */ +	VIRTIO_SND_CHMAP_FR,		/* front right */ +	VIRTIO_SND_CHMAP_RL,		/* rear left */ +	VIRTIO_SND_CHMAP_RR,		/* rear right */ +	VIRTIO_SND_CHMAP_FC,		/* front center */ +	VIRTIO_SND_CHMAP_LFE,		/* low frequency (LFE) */ +	VIRTIO_SND_CHMAP_SL,		/* side left */ +	VIRTIO_SND_CHMAP_SR,		/* side right */ +	VIRTIO_SND_CHMAP_RC,		/* rear center */ +	VIRTIO_SND_CHMAP_FLC,		/* front left center */ +	VIRTIO_SND_CHMAP_FRC,		/* front right center */ +	VIRTIO_SND_CHMAP_RLC,		/* rear left center */ +	VIRTIO_SND_CHMAP_RRC,		/* rear right center */ +	VIRTIO_SND_CHMAP_FLW,		/* front left wide */ +	VIRTIO_SND_CHMAP_FRW,		/* front right wide */ +	VIRTIO_SND_CHMAP_FLH,		/* front left high */ +	VIRTIO_SND_CHMAP_FCH,		/* front center high */ +	VIRTIO_SND_CHMAP_FRH,		/* front right high */ +	VIRTIO_SND_CHMAP_TC,		/* top center */ +	VIRTIO_SND_CHMAP_TFL,		/* top front left */ +	VIRTIO_SND_CHMAP_TFR,		/* top front right */ +	VIRTIO_SND_CHMAP_TFC,		/* top front center */ +	VIRTIO_SND_CHMAP_TRL,		/* top rear left */ +	VIRTIO_SND_CHMAP_TRR,		/* top rear right */ +	VIRTIO_SND_CHMAP_TRC,		/* top rear center */ +	VIRTIO_SND_CHMAP_TFLC,		/* top front left center */ +	VIRTIO_SND_CHMAP_TFRC,		/* top front right center */ +	VIRTIO_SND_CHMAP_TSL,		/* top side left */ +	VIRTIO_SND_CHMAP_TSR,		/* top side right */ +	VIRTIO_SND_CHMAP_LLFE,		/* left LFE */ +	VIRTIO_SND_CHMAP_RLFE,		/* right LFE */ +	VIRTIO_SND_CHMAP_BC,		/* bottom center */ +	VIRTIO_SND_CHMAP_BLC,		/* bottom left center */ +	VIRTIO_SND_CHMAP_BRC		/* bottom right center */ +}; + +/* maximum possible number of channels */ +#define VIRTIO_SND_CHMAP_MAX_SIZE	18 + +struct virtio_snd_chmap_info { +	/* common header */ +	struct virtio_snd_info hdr; +	/* dataflow direction (VIRTIO_SND_D_XXX) */ +	__u8 direction; +	/* # of valid channel position values */ +	__u8 channels; +	/* channel position values (VIRTIO_SND_CHMAP_XXX) */ +	__u8 positions[VIRTIO_SND_CHMAP_MAX_SIZE]; +}; + +/******************************************************************************* + * CONTROL ELEMENTS MESSAGES + */ +struct virtio_snd_ctl_hdr { +	/* VIRTIO_SND_R_CTL_XXX */ +	struct virtio_snd_hdr hdr; +	/* 0 ... virtio_snd_config::controls - 1 */ +	__le32 control_id; +}; + +/* supported roles for control elements */ +enum { +	VIRTIO_SND_CTL_ROLE_UNDEFINED = 0, +	VIRTIO_SND_CTL_ROLE_VOLUME, +	VIRTIO_SND_CTL_ROLE_MUTE, +	VIRTIO_SND_CTL_ROLE_GAIN +}; + +/* supported value types for control elements */ +enum { +	VIRTIO_SND_CTL_TYPE_BOOLEAN = 0, +	VIRTIO_SND_CTL_TYPE_INTEGER, +	VIRTIO_SND_CTL_TYPE_INTEGER64, +	VIRTIO_SND_CTL_TYPE_ENUMERATED, +	VIRTIO_SND_CTL_TYPE_BYTES, +	VIRTIO_SND_CTL_TYPE_IEC958 +}; + +/* supported access rights for control elements */ +enum { +	VIRTIO_SND_CTL_ACCESS_READ = 0, +	VIRTIO_SND_CTL_ACCESS_WRITE, +	VIRTIO_SND_CTL_ACCESS_VOLATILE, +	VIRTIO_SND_CTL_ACCESS_INACTIVE, +	VIRTIO_SND_CTL_ACCESS_TLV_READ, +	VIRTIO_SND_CTL_ACCESS_TLV_WRITE, +	VIRTIO_SND_CTL_ACCESS_TLV_COMMAND +}; + +struct virtio_snd_ctl_info { +	/* common header */ +	struct virtio_snd_info hdr; +	/* element role (VIRTIO_SND_CTL_ROLE_XXX) */ +	__le32 role; +	/* element value type (VIRTIO_SND_CTL_TYPE_XXX) */ +	__le32 type; +	/* element access right bit map (1 << VIRTIO_SND_CTL_ACCESS_XXX) */ +	__le32 access; +	/* # of members in the element value */ +	__le32 count; +	/* index for an element with a non-unique name */ +	__le32 index; +	/* name identifier string for the element */ +	__u8 name[44]; +	/* additional information about the element's value */ +	union { +		/* VIRTIO_SND_CTL_TYPE_INTEGER */ +		struct { +			/* minimum supported value */ +			__le32 min; +			/* maximum supported value */ +			__le32 max; +			/* fixed step size for value (0 = variable size) */ +			__le32 step; +		} integer; +		/* VIRTIO_SND_CTL_TYPE_INTEGER64 */ +		struct { +			/* minimum supported value */ +			__le64 min; +			/* maximum supported value */ +			__le64 max; +			/* fixed step size for value (0 = variable size) */ +			__le64 step; +		} integer64; +		/* VIRTIO_SND_CTL_TYPE_ENUMERATED */ +		struct { +			/* # of options supported for value */ +			__le32 items; +		} enumerated; +	} value; +}; + +struct virtio_snd_ctl_enum_item { +	/* option name */ +	__u8 item[64]; +}; + +struct virtio_snd_ctl_iec958 { +	/* AES/IEC958 channel status bits */ +	__u8 status[24]; +	/* AES/IEC958 subcode bits */ +	__u8 subcode[147]; +	/* nothing */ +	__u8 pad; +	/* AES/IEC958 subframe bits */ +	__u8 dig_subframe[4]; +}; + +struct virtio_snd_ctl_value { +	union { +		/* VIRTIO_SND_CTL_TYPE_BOOLEAN|INTEGER value */ +		__le32 integer[128]; +		/* VIRTIO_SND_CTL_TYPE_INTEGER64 value */ +		__le64 integer64[64]; +		/* VIRTIO_SND_CTL_TYPE_ENUMERATED value (option indexes) */ +		__le32 enumerated[128]; +		/* VIRTIO_SND_CTL_TYPE_BYTES value */ +		__u8 bytes[512]; +		/* VIRTIO_SND_CTL_TYPE_IEC958 value */ +		struct virtio_snd_ctl_iec958 iec958; +	} value; +}; + +/* supported event reason types */ +enum { +	/* element's value has changed */ +	VIRTIO_SND_CTL_EVT_MASK_VALUE = 0, +	/* element's information has changed */ +	VIRTIO_SND_CTL_EVT_MASK_INFO, +	/* element's metadata has changed */ +	VIRTIO_SND_CTL_EVT_MASK_TLV +}; + +struct virtio_snd_ctl_event { +	/* VIRTIO_SND_EVT_CTL_NOTIFY */ +	struct virtio_snd_hdr hdr; +	/* 0 ... virtio_snd_config::controls - 1 */ +	__le16 control_id; +	/* event reason bit map (1 << VIRTIO_SND_CTL_EVT_MASK_XXX) */ +	__le16 mask; +}; + +#endif /* VIRTIO_SND_IF_H */ diff --git a/include/uapi/linux/virtio_vsock.h b/include/uapi/linux/virtio_vsock.h index 1d57ed3d84d2..64738838bee5 100644 --- a/include/uapi/linux/virtio_vsock.h +++ b/include/uapi/linux/virtio_vsock.h @@ -38,6 +38,9 @@  #include <linux/virtio_ids.h>  #include <linux/virtio_config.h> +/* The feature bitmap for virtio vsock */ +#define VIRTIO_VSOCK_F_SEQPACKET	1	/* SOCK_SEQPACKET supported */ +  struct virtio_vsock_config {  	__le64 guest_cid;  } __attribute__((packed)); @@ -65,6 +68,7 @@ struct virtio_vsock_hdr {  enum virtio_vsock_type {  	VIRTIO_VSOCK_TYPE_STREAM = 1, +	VIRTIO_VSOCK_TYPE_SEQPACKET = 2,  };  enum virtio_vsock_op { @@ -91,4 +95,10 @@ enum virtio_vsock_shutdown {  	VIRTIO_VSOCK_SHUTDOWN_SEND = 2,  }; +/* VIRTIO_VSOCK_OP_RW flags values */ +enum virtio_vsock_rw { +	VIRTIO_VSOCK_SEQ_EOM = 1, +	VIRTIO_VSOCK_SEQ_EOR = 2, +}; +  #endif /* _UAPI_LINUX_VIRTIO_VSOCK_H */ diff --git a/include/uapi/linux/vm_sockets.h b/include/uapi/linux/vm_sockets.h index fd0ed7221645..e05280e41522 100644 --- a/include/uapi/linux/vm_sockets.h +++ b/include/uapi/linux/vm_sockets.h @@ -17,7 +17,12 @@  #ifndef _UAPI_VM_SOCKETS_H  #define _UAPI_VM_SOCKETS_H +#ifndef __KERNEL__ +#include <sys/socket.h>        /* for struct sockaddr and sa_family_t */ +#endif +  #include <linux/socket.h> +#include <linux/types.h>  /* Option name for STREAM socket buffer size.  Use as the option name in   * setsockopt(3) or getsockopt(3) to set or get an unsigned long long that @@ -63,7 +68,7 @@   * timeout for a STREAM socket.   */ -#define SO_VM_SOCKETS_CONNECT_TIMEOUT 6 +#define SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD 6  /* Option name for using non-blocking send/receive.  Use as the option name   * for setsockopt(3) or getsockopt(3) to set or get the non-blocking @@ -80,6 +85,17 @@  #define SO_VM_SOCKETS_NONBLOCK_TXRX 7 +#define SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW 8 + +#if !defined(__KERNEL__) +#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__)) +#define SO_VM_SOCKETS_CONNECT_TIMEOUT SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD +#else +#define SO_VM_SOCKETS_CONNECT_TIMEOUT \ +	(sizeof(time_t) == sizeof(__kernel_long_t) ? SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD : SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW) +#endif +#endif +  /* The vSocket equivalent of INADDR_ANY.  This works for the svm_cid field of   * sockaddr_vm and indicates the context ID of the current endpoint.   */ @@ -114,6 +130,26 @@  #define VMADDR_CID_HOST 2 +/* The current default use case for the vsock channel is the following: + * local vsock communication between guest and host and nested VMs setup. + * In addition to this, implicitly, the vsock packets are forwarded to the host + * if no host->guest vsock transport is set. + * + * Set this flag value in the sockaddr_vm corresponding field if the vsock + * packets need to be always forwarded to the host. Using this behavior, + * vsock communication between sibling VMs can be setup. + * + * This way can explicitly distinguish between vsock channels created for + * different use cases, such as nested VMs (or local communication between + * guest and host) and sibling VMs. + * + * The flag can be set in the connect logic in the user space application flow. + * In the listen logic (from kernel space) the flag is set on the remote peer + * address. This happens for an incoming connection when it is routed from the + * host and comes from the guest (local CID and remote CID > VMADDR_CID_HOST). + */ +#define VMADDR_FLAG_TO_HOST 0x01 +  /* Invalid vSockets version. */  #define VM_SOCKETS_INVALID_VERSION -1U @@ -148,12 +184,32 @@ struct sockaddr_vm {  	unsigned short svm_reserved1;  	unsigned int svm_port;  	unsigned int svm_cid; +	__u8 svm_flags;  	unsigned char svm_zero[sizeof(struct sockaddr) -  			       sizeof(sa_family_t) -  			       sizeof(unsigned short) - -			       sizeof(unsigned int) - sizeof(unsigned int)]; +			       sizeof(unsigned int) - +			       sizeof(unsigned int) - +			       sizeof(__u8)];  };  #define IOCTL_VM_SOCKETS_GET_LOCAL_CID		_IO(7, 0xb9) +/* MSG_ZEROCOPY notifications are encoded in the standard error format, + * sock_extended_err. See Documentation/networking/msg_zerocopy.rst in + * kernel source tree for more details. + */ + +/* 'cmsg_level' field value of 'struct cmsghdr' for notification parsing + * when MSG_ZEROCOPY flag is used on transmissions. + */ + +#define SOL_VSOCK	287 + +/* 'cmsg_type' field value of 'struct cmsghdr' for notification parsing + * when MSG_ZEROCOPY flag is used on transmissions. + */ + +#define VSOCK_RECVERR	1 +  #endif /* _UAPI_VM_SOCKETS_H */ diff --git a/include/uapi/linux/vmclock-abi.h b/include/uapi/linux/vmclock-abi.h new file mode 100644 index 000000000000..2d99b29ac44a --- /dev/null +++ b/include/uapi/linux/vmclock-abi.h @@ -0,0 +1,182 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ + +/* + * This structure provides a vDSO-style clock to VM guests, exposing the + * relationship (or lack thereof) between the CPU clock (TSC, timebase, arch + * counter, etc.) and real time. It is designed to address the problem of + * live migration, which other clock enlightenments do not. + * + * When a guest is live migrated, this affects the clock in two ways. + * + * First, even between identical hosts the actual frequency of the underlying + * counter will change within the tolerances of its specification (typically + * ±50PPM, or 4 seconds a day). This frequency also varies over time on the + * same host, but can be tracked by NTP as it generally varies slowly. With + * live migration there is a step change in the frequency, with no warning. + * + * Second, there may be a step change in the value of the counter itself, as + * its accuracy is limited by the precision of the NTP synchronization on the + * source and destination hosts. + * + * So any calibration (NTP, PTP, etc.) which the guest has done on the source + * host before migration is invalid, and needs to be redone on the new host. + * + * In its most basic mode, this structure provides only an indication to the + * guest that live migration has occurred. This allows the guest to know that + * its clock is invalid and take remedial action. For applications that need + * reliable accurate timestamps (e.g. distributed databases), the structure + * can be mapped all the way to userspace. This allows the application to see + * directly for itself that the clock is disrupted and take appropriate + * action, even when using a vDSO-style method to get the time instead of a + * system call. + * + * In its more advanced mode. this structure can also be used to expose the + * precise relationship of the CPU counter to real time, as calibrated by the + * host. This means that userspace applications can have accurate time + * immediately after live migration, rather than having to pause operations + * and wait for NTP to recover. This mode does, of course, rely on the + * counter being reliable and consistent across CPUs. + * + * Note that this must be true UTC, never with smeared leap seconds. If a + * guest wishes to construct a smeared clock, it can do so. Presenting a + * smeared clock through this interface would be problematic because it + * actually messes with the apparent counter *period*. A linear smearing + * of 1 ms per second would effectively tweak the counter period by 1000PPM + * at the start/end of the smearing period, while a sinusoidal smear would + * basically be impossible to represent. + * + * This structure is offered with the intent that it be adopted into the + * nascent virtio-rtc standard, as a virtio-rtc that does not address the live + * migration problem seems a little less than fit for purpose. For that + * reason, certain fields use precisely the same numeric definitions as in + * the virtio-rtc proposal. The structure can also be exposed through an ACPI + * device with the CID "VMCLOCK", modelled on the "VMGENID" device except for + * the fact that it uses a real _CRS to convey the address of the structure + * (which should be a full page, to allow for mapping directly to userspace). + */ + +#ifndef __VMCLOCK_ABI_H__ +#define __VMCLOCK_ABI_H__ + +#include <linux/types.h> + +struct vmclock_abi { +	/* CONSTANT FIELDS */ +	__le32 magic; +#define VMCLOCK_MAGIC	0x4b4c4356 /* "VCLK" */ +	__le32 size;		/* Size of region containing this structure */ +	__le16 version;	/* 1 */ +	__u8 counter_id; /* Matches VIRTIO_RTC_COUNTER_xxx except INVALID */ +#define VMCLOCK_COUNTER_ARM_VCNT	0 +#define VMCLOCK_COUNTER_X86_TSC		1 +#define VMCLOCK_COUNTER_INVALID		0xff +	__u8 time_type; /* Matches VIRTIO_RTC_TYPE_xxx */ +#define VMCLOCK_TIME_UTC			0	/* Since 1970-01-01 00:00:00z */ +#define VMCLOCK_TIME_TAI			1	/* Since 1970-01-01 00:00:00z */ +#define VMCLOCK_TIME_MONOTONIC			2	/* Since undefined epoch */ +#define VMCLOCK_TIME_INVALID_SMEARED		3	/* Not supported */ +#define VMCLOCK_TIME_INVALID_MAYBE_SMEARED	4	/* Not supported */ + +	/* NON-CONSTANT FIELDS PROTECTED BY SEQCOUNT LOCK */ +	__le32 seq_count;	/* Low bit means an update is in progress */ +	/* +	 * This field changes to another non-repeating value when the CPU +	 * counter is disrupted, for example on live migration. This lets +	 * the guest know that it should discard any calibration it has +	 * performed of the counter against external sources (NTP/PTP/etc.). +	 */ +	__le64 disruption_marker; +	__le64 flags; +	/* Indicates that the tai_offset_sec field is valid */ +#define VMCLOCK_FLAG_TAI_OFFSET_VALID		(1 << 0) +	/* +	 * Optionally used to notify guests of pending maintenance events. +	 * A guest which provides latency-sensitive services may wish to +	 * remove itself from service if an event is coming up. Two flags +	 * indicate the approximate imminence of the event. +	 */ +#define VMCLOCK_FLAG_DISRUPTION_SOON		(1 << 1) /* About a day */ +#define VMCLOCK_FLAG_DISRUPTION_IMMINENT	(1 << 2) /* About an hour */ +#define VMCLOCK_FLAG_PERIOD_ESTERROR_VALID	(1 << 3) +#define VMCLOCK_FLAG_PERIOD_MAXERROR_VALID	(1 << 4) +#define VMCLOCK_FLAG_TIME_ESTERROR_VALID	(1 << 5) +#define VMCLOCK_FLAG_TIME_MAXERROR_VALID	(1 << 6) +	/* +	 * If the MONOTONIC flag is set then (other than leap seconds) it is +	 * guaranteed that the time calculated according this structure at +	 * any given moment shall never appear to be later than the time +	 * calculated via the structure at any *later* moment. +	 * +	 * In particular, a timestamp based on a counter reading taken +	 * immediately after setting the low bit of seq_count (and the +	 * associated memory barrier), using the previously-valid time and +	 * period fields, shall never be later than a timestamp based on +	 * a counter reading taken immediately before *clearing* the low +	 * bit again after the update, using the about-to-be-valid fields. +	 */ +#define VMCLOCK_FLAG_TIME_MONOTONIC		(1 << 7) + +	__u8 pad[2]; +	__u8 clock_status; +#define VMCLOCK_STATUS_UNKNOWN		0 +#define VMCLOCK_STATUS_INITIALIZING	1 +#define VMCLOCK_STATUS_SYNCHRONIZED	2 +#define VMCLOCK_STATUS_FREERUNNING	3 +#define VMCLOCK_STATUS_UNRELIABLE	4 + +	/* +	 * The time exposed through this device is never smeared. This field +	 * corresponds to the 'subtype' field in virtio-rtc, which indicates +	 * the smearing method. However in this case it provides a *hint* to +	 * the guest operating system, such that *if* the guest OS wants to +	 * provide its users with an alternative clock which does not follow +	 * UTC, it may do so in a fashion consistent with the other systems +	 * in the nearby environment. +	 */ +	__u8 leap_second_smearing_hint; /* Matches VIRTIO_RTC_SUBTYPE_xxx */ +#define VMCLOCK_SMEARING_STRICT		0 +#define VMCLOCK_SMEARING_NOON_LINEAR	1 +#define VMCLOCK_SMEARING_UTC_SLS	2 +	__le16 tai_offset_sec; /* Actually two's complement signed */ +	__u8 leap_indicator; +	/* +	 * This field is based on the VIRTIO_RTC_LEAP_xxx values as defined +	 * in the current draft of virtio-rtc, but since smearing cannot be +	 * used with the shared memory device, some values are not used. +	 * +	 * The _POST_POS and _POST_NEG values allow the guest to perform +	 * its own smearing during the day or so after a leap second when +	 * such smearing may need to continue being applied for a leap +	 * second which is now theoretically "historical". +	 */ +#define VMCLOCK_LEAP_NONE	0x00	/* No known nearby leap second */ +#define VMCLOCK_LEAP_PRE_POS	0x01	/* Positive leap second at EOM */ +#define VMCLOCK_LEAP_PRE_NEG	0x02	/* Negative leap second at EOM */ +#define VMCLOCK_LEAP_POS	0x03	/* Set during 23:59:60 second */ +#define VMCLOCK_LEAP_POST_POS	0x04 +#define VMCLOCK_LEAP_POST_NEG	0x05 + +	/* Bit shift for counter_period_frac_sec and its error rate */ +	__u8 counter_period_shift; +	/* +	 * Paired values of counter and UTC at a given point in time. +	 */ +	__le64 counter_value; +	/* +	 * Counter period, and error margin of same. The unit of these +	 * fields is 1/2^(64 + counter_period_shift) of a second. +	 */ +	__le64 counter_period_frac_sec; +	__le64 counter_period_esterror_rate_frac_sec; +	__le64 counter_period_maxerror_rate_frac_sec; + +	/* +	 * Time according to time_type field above. +	 */ +	__le64 time_sec;		/* Seconds since time_type epoch */ +	__le64 time_frac_sec;		/* Units of 1/2^64 of a second */ +	__le64 time_esterror_nanosec; +	__le64 time_maxerror_nanosec; +}; + +#endif /*  __VMCLOCK_ABI_H__ */ diff --git a/include/uapi/linux/vt.h b/include/uapi/linux/vt.h index e9d39c48520a..714483d68c69 100644 --- a/include/uapi/linux/vt.h +++ b/include/uapi/linux/vt.h @@ -2,6 +2,8 @@  #ifndef _UAPI_LINUX_VT_H  #define _UAPI_LINUX_VT_H +#include <linux/ioctl.h> +#include <linux/types.h>  /*   * These constants are also useful for user-level apps (e.g., VC @@ -17,11 +19,11 @@  #define VT_OPENQRY	0x5600	/* find available vt */  struct vt_mode { -	char mode;		/* vt mode */ -	char waitv;		/* if set, hang on writes if not active */ -	short relsig;		/* signal to raise on release req */ -	short acqsig;		/* signal to raise on acquisition */ -	short frsig;		/* unused (set to 0) */ +	__u8 mode;		/* vt mode */ +	__u8 waitv;		/* if set, hang on writes if not active */ +	__s16 relsig;		/* signal to raise on release req */ +	__s16 acqsig;		/* signal to raise on acquisition */ +	__s16 frsig;		/* unused (set to 0) */  };  #define VT_GETMODE	0x5601	/* get mode of active vt */  #define VT_SETMODE	0x5602	/* set mode of active vt */ @@ -30,9 +32,9 @@ struct vt_mode {  #define		VT_ACKACQ	0x02	/* acknowledge switch */  struct vt_stat { -	unsigned short v_active;	/* active vt */ -	unsigned short v_signal;	/* signal to send */ -	unsigned short v_state;		/* vt bitmask */ +	__u16 v_active;	/* active vt */ +	__u16 v_signal;	/* signal to send */ +	__u16 v_state;		/* vt bitmask */  };  #define VT_GETSTATE	0x5603	/* get global vt state info */  #define VT_SENDSIG	0x5604	/* signal to send to bitmask of vts */ @@ -44,19 +46,19 @@ struct vt_stat {  #define VT_DISALLOCATE	0x5608  /* free memory associated to vt */  struct vt_sizes { -	unsigned short v_rows;		/* number of rows */ -	unsigned short v_cols;		/* number of columns */ -	unsigned short v_scrollsize;	/* number of lines of scrollback */ +	__u16 v_rows;		/* number of rows */ +	__u16 v_cols;		/* number of columns */ +	__u16 v_scrollsize;	/* number of lines of scrollback */  };  #define VT_RESIZE	0x5609	/* set kernel's idea of screensize */  struct vt_consize { -	unsigned short v_rows;	/* number of rows */ -	unsigned short v_cols;	/* number of columns */ -	unsigned short v_vlin;	/* number of pixel rows on screen */ -	unsigned short v_clin;	/* number of pixel rows per character */ -	unsigned short v_vcol;	/* number of pixel columns on screen */ -	unsigned short v_ccol;	/* number of pixel columns per character */ +	__u16 v_rows;	/* number of rows */ +	__u16 v_cols;	/* number of columns */ +	__u16 v_vlin;	/* number of pixel rows on screen */ +	__u16 v_clin;	/* number of pixel rows per character */ +	__u16 v_vcol;	/* number of pixel columns on screen */ +	__u16 v_ccol;	/* number of pixel columns per character */  };  #define VT_RESIZEX      0x560A  /* set kernel's idea of screensize + more */  #define VT_LOCKSWITCH   0x560B  /* disallow vt switching */ @@ -64,24 +66,33 @@ struct vt_consize {  #define VT_GETHIFONTMASK 0x560D  /* return hi font mask */  struct vt_event { -	unsigned int event; +	__u32 event;  #define VT_EVENT_SWITCH		0x0001	/* Console switch */  #define VT_EVENT_BLANK		0x0002	/* Screen blank */  #define VT_EVENT_UNBLANK	0x0004	/* Screen unblank */  #define VT_EVENT_RESIZE		0x0008	/* Resize display */  #define VT_MAX_EVENT		0x000F -	unsigned int oldev;		/* Old console */ -	unsigned int newev;		/* New console (if changing) */ -	unsigned int pad[4];		/* Padding for expansion */ +	__u32 oldev;		/* Old console */ +	__u32 newev;		/* New console (if changing) */ +	__u32 pad[4];		/* Padding for expansion */  };  #define VT_WAITEVENT	0x560E	/* Wait for an event */  struct vt_setactivate { -	unsigned int console; +	__u32 console;  	struct vt_mode mode;  };  #define VT_SETACTIVATE	0x560F	/* Activate and set the mode of a console */ +/* get console size and cursor position */ +struct vt_consizecsrpos { +	__u16 con_rows;		/* number of console rows */ +	__u16 con_cols;		/* number of console columns */ +	__u16 csr_row;		/* current cursor's row */ +	__u16 csr_col;		/* current cursor's column */ +}; +#define VT_GETCONSIZECSRPOS	_IOR('V', 0x10, struct vt_consizecsrpos) +  #endif /* _UAPI_LINUX_VT_H */ diff --git a/include/uapi/linux/wimax.h b/include/uapi/linux/wimax.h deleted file mode 100644 index 9f6b77af2f6d..000000000000 --- a/include/uapi/linux/wimax.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Linux WiMax - * API for user space - * - * - * Copyright (C) 2007-2008 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - *   * Redistributions of source code must retain the above copyright - *     notice, this list of conditions and the following disclaimer. - *   * Redistributions in binary form must reproduce the above copyright - *     notice, this list of conditions and the following disclaimer in - *     the documentation and/or other materials provided with the - *     distribution. - *   * Neither the name of Intel Corporation nor the names of its - *     contributors may be used to endorse or promote products derived - *     from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * Intel Corporation <linux-wimax@intel.com> - * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> - *  - Initial implementation - * - * - * This file declares the user/kernel protocol that is spoken over - * Generic Netlink, as well as any type declaration that is to be used - * by kernel and user space. - * - * It is intended for user space to clone it verbatim to use it as a - * primary reference for definitions. - * - * Stuff intended for kernel usage as well as full protocol and stack - * documentation is rooted in include/net/wimax.h. - */ - -#ifndef __LINUX__WIMAX_H__ -#define __LINUX__WIMAX_H__ - -#include <linux/types.h> - -enum { -	/** -	 * Version of the interface (unsigned decimal, MMm, max 25.5) -	 * M - Major: change if removing or modifying an existing call. -	 * m - minor: change when adding a new call -	 */ -	WIMAX_GNL_VERSION = 01, -	/* Generic NetLink attributes */ -	WIMAX_GNL_ATTR_INVALID = 0x00, -	WIMAX_GNL_ATTR_MAX = 10, -}; - - -/* - * Generic NetLink operations - * - * Most of these map to an API call; _OP_ stands for operation, _RP_ - * for reply and _RE_ for report (aka: signal). - */ -enum { -	WIMAX_GNL_OP_MSG_FROM_USER,	/* User to kernel message */ -	WIMAX_GNL_OP_MSG_TO_USER,	/* Kernel to user message */ -	WIMAX_GNL_OP_RFKILL,	/* Run wimax_rfkill() */ -	WIMAX_GNL_OP_RESET,	/* Run wimax_rfkill() */ -	WIMAX_GNL_RE_STATE_CHANGE,	/* Report: status change */ -	WIMAX_GNL_OP_STATE_GET,		/* Request for current state */ -}; - - -/* Message from user / to user */ -enum { -	WIMAX_GNL_MSG_IFIDX = 1, -	WIMAX_GNL_MSG_PIPE_NAME, -	WIMAX_GNL_MSG_DATA, -}; - - -/* - * wimax_rfkill() - * - * The state of the radio (ON/OFF) is mapped to the rfkill subsystem's - * switch state (DISABLED/ENABLED). - */ -enum wimax_rf_state { -	WIMAX_RF_OFF = 0,	/* Radio is off, rfkill on/enabled */ -	WIMAX_RF_ON = 1,	/* Radio is on, rfkill off/disabled */ -	WIMAX_RF_QUERY = 2, -}; - -/* Attributes */ -enum { -	WIMAX_GNL_RFKILL_IFIDX = 1, -	WIMAX_GNL_RFKILL_STATE, -}; - - -/* Attributes for wimax_reset() */ -enum { -	WIMAX_GNL_RESET_IFIDX = 1, -}; - -/* Attributes for wimax_state_get() */ -enum { -	WIMAX_GNL_STGET_IFIDX = 1, -}; - -/* - * Attributes for the Report State Change - * - * For now we just have the old and new states; new attributes might - * be added later on. - */ -enum { -	WIMAX_GNL_STCH_IFIDX = 1, -	WIMAX_GNL_STCH_STATE_OLD, -	WIMAX_GNL_STCH_STATE_NEW, -}; - - -/** - * enum wimax_st - The different states of a WiMAX device - * @__WIMAX_ST_NULL: The device structure has been allocated and zeroed, - *     but still wimax_dev_add() hasn't been called. There is no state. - * - * @WIMAX_ST_DOWN: The device has been registered with the WiMAX and - *     networking stacks, but it is not initialized (normally that is - *     done with 'ifconfig DEV up' [or equivalent], which can upload - *     firmware and enable communications with the device). - *     In this state, the device is powered down and using as less - *     power as possible. - *     This state is the default after a call to wimax_dev_add(). It - *     is ok to have drivers move directly to %WIMAX_ST_UNINITIALIZED - *     or %WIMAX_ST_RADIO_OFF in _probe() after the call to - *     wimax_dev_add(). - *     It is recommended that the driver leaves this state when - *     calling 'ifconfig DEV up' and enters it back on 'ifconfig DEV - *     down'. - * - * @__WIMAX_ST_QUIESCING: The device is being torn down, so no API - *     operations are allowed to proceed except the ones needed to - *     complete the device clean up process. - * - * @WIMAX_ST_UNINITIALIZED: [optional] Communication with the device - *     is setup, but the device still requires some configuration - *     before being operational. - *     Some WiMAX API calls might work. - * - * @WIMAX_ST_RADIO_OFF: The device is fully up; radio is off (wether - *     by hardware or software switches). - *     It is recommended to always leave the device in this state - *     after initialization. - * - * @WIMAX_ST_READY: The device is fully up and radio is on. - * - * @WIMAX_ST_SCANNING: [optional] The device has been instructed to - *     scan. In this state, the device cannot be actively connected to - *     a network. - * - * @WIMAX_ST_CONNECTING: The device is connecting to a network. This - *     state exists because in some devices, the connect process can - *     include a number of negotiations between user space, kernel - *     space and the device. User space needs to know what the device - *     is doing. If the connect sequence in a device is atomic and - *     fast, the device can transition directly to CONNECTED - * - * @WIMAX_ST_CONNECTED: The device is connected to a network. - * - * @__WIMAX_ST_INVALID: This is an invalid state used to mark the - *     maximum numeric value of states. - * - * Description: - * - * Transitions from one state to another one are atomic and can only - * be caused in kernel space with wimax_state_change(). To read the - * state, use wimax_state_get(). - * - * States starting with __ are internal and shall not be used or - * referred to by drivers or userspace. They look ugly, but that's the - * point -- if any use is made non-internal to the stack, it is easier - * to catch on review. - * - * All API operations [with well defined exceptions] will take the - * device mutex before starting and then check the state. If the state - * is %__WIMAX_ST_NULL, %WIMAX_ST_DOWN, %WIMAX_ST_UNINITIALIZED or - * %__WIMAX_ST_QUIESCING, it will drop the lock and quit with - * -%EINVAL, -%ENOMEDIUM, -%ENOTCONN or -%ESHUTDOWN. - * - * The order of the definitions is important, so we can do numerical - * comparisons (eg: < %WIMAX_ST_RADIO_OFF means the device is not ready - * to operate). - */ -/* - * The allowed state transitions are described in the table below - * (states in rows can go to states in columns where there is an X): - * - *                                  UNINI   RADIO READY SCAN CONNEC CONNEC - *             NULL DOWN QUIESCING TIALIZED  OFF        NING  TING   TED - * NULL         -    x - * DOWN              -      x        x       x - * QUIESCING         x      - - * UNINITIALIZED            x        -       x - * RADIO_OFF                x                -     x - * READY                    x                x     -     x     x      x - * SCANNING                 x                x     x     -     x      x - * CONNECTING               x                x     x     x     -      x - * CONNECTED                x                x     x                  - - * - * This table not available in kernel-doc because the formatting messes it up. - */ - enum wimax_st { -	__WIMAX_ST_NULL = 0, -	WIMAX_ST_DOWN, -	__WIMAX_ST_QUIESCING, -	WIMAX_ST_UNINITIALIZED, -	WIMAX_ST_RADIO_OFF, -	WIMAX_ST_READY, -	WIMAX_ST_SCANNING, -	WIMAX_ST_CONNECTING, -	WIMAX_ST_CONNECTED, -	__WIMAX_ST_INVALID			/* Always keep last */ -}; - - -#endif /* #ifndef __LINUX__WIMAX_H__ */ diff --git a/include/uapi/linux/wimax/i2400m.h b/include/uapi/linux/wimax/i2400m.h deleted file mode 100644 index fd198bc24a3c..000000000000 --- a/include/uapi/linux/wimax/i2400m.h +++ /dev/null @@ -1,572 +0,0 @@ -/* - * Intel Wireless WiMax Connection 2400m - * Host-Device protocol interface definitions - * - * - * Copyright (C) 2007-2008 Intel Corporation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - *   * Redistributions of source code must retain the above copyright - *     notice, this list of conditions and the following disclaimer. - *   * Redistributions in binary form must reproduce the above copyright - *     notice, this list of conditions and the following disclaimer in - *     the documentation and/or other materials provided with the - *     distribution. - *   * Neither the name of Intel Corporation nor the names of its - *     contributors may be used to endorse or promote products derived - *     from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * Intel Corporation <linux-wimax@intel.com> - * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> - *  - Initial implementation - * - * - * This header defines the data structures and constants used to - * communicate with the device. - * - * BOOTMODE/BOOTROM/FIRMWARE UPLOAD PROTOCOL - * - * The firmware upload protocol is quite simple and only requires a - * handful of commands. See drivers/net/wimax/i2400m/fw.c for more - * details. - * - * The BCF data structure is for the firmware file header. - * - * - * THE DATA / CONTROL PROTOCOL - * - * This is the normal protocol spoken with the device once the - * firmware is uploaded. It transports data payloads and control - * messages back and forth. - * - * It consists 'messages' that pack one or more payloads each. The - * format is described in detail in drivers/net/wimax/i2400m/rx.c and - * tx.c. - * - * - * THE L3L4 PROTOCOL - * - * The term L3L4 refers to Layer 3 (the device), Layer 4 (the - * driver/host software). - * - * This is the control protocol used by the host to control the i2400m - * device (scan, connect, disconnect...). This is sent to / received - * as control frames. These frames consist of a header and zero or - * more TLVs with information. We call each control frame a "message". - * - * Each message is composed of: - * - * HEADER - * [TLV0 + PAYLOAD0] - * [TLV1 + PAYLOAD1] - * [...] - * [TLVN + PAYLOADN] - * - * The HEADER is defined by 'struct i2400m_l3l4_hdr'. The payloads are - * defined by a TLV structure (Type Length Value) which is a 'header' - * (struct i2400m_tlv_hdr) and then the payload. - * - * All integers are represented as Little Endian. - * - * - REQUESTS AND EVENTS - * - * The requests can be clasified as follows: - * - *   COMMAND:  implies a request from the host to the device requesting - *             an action being performed. The device will reply with a - *             message (with the same type as the command), status and - *             no (TLV) payload. Execution of a command might cause - *             events (of different type) to be sent later on as - *             device's state changes. - * - *   GET/SET:  similar to COMMAND, but will not cause other - *             EVENTs. The reply, in the case of GET, will contain - *             TLVs with the requested information. - * - *   EVENT:    asynchronous messages sent from the device, maybe as a - *             consequence of previous COMMANDs but disassociated from - *             them. - * - * Only one request might be pending at the same time (ie: don't - * parallelize nor post another GET request before the previous - * COMMAND has been acknowledged with it's corresponding reply by the - * device). - * - * The different requests and their formats are described below: - * - *  I2400M_MT_*   Message types - *  I2400M_MS_*   Message status (for replies, events) - *  i2400m_tlv_*  TLVs - * - * data types are named 'struct i2400m_msg_OPNAME', OPNAME matching the - * operation. - */ - -#ifndef __LINUX__WIMAX__I2400M_H__ -#define __LINUX__WIMAX__I2400M_H__ - -#include <linux/types.h> -#include <linux/if_ether.h> - -/* - * Host Device Interface (HDI) common to all busses - */ - -/* Boot-mode (firmware upload mode) commands */ - -/* Header for the firmware file */ -struct i2400m_bcf_hdr { -	__le32 module_type; -	__le32 header_len; -	__le32 header_version; -	__le32 module_id; -	__le32 module_vendor; -	__le32 date;		/* BCD YYYMMDD */ -	__le32 size;            /* in dwords */ -	__le32 key_size;	/* in dwords */ -	__le32 modulus_size;	/* in dwords */ -	__le32 exponent_size;	/* in dwords */ -	__u8 reserved[88]; -} __attribute__ ((packed)); - -/* Boot mode opcodes */ -enum i2400m_brh_opcode { -	I2400M_BRH_READ = 1, -	I2400M_BRH_WRITE = 2, -	I2400M_BRH_JUMP = 3, -	I2400M_BRH_SIGNED_JUMP = 8, -	I2400M_BRH_HASH_PAYLOAD_ONLY = 9, -}; - -/* Boot mode command masks and stuff */ -enum i2400m_brh { -	I2400M_BRH_SIGNATURE = 0xcbbc0000, -	I2400M_BRH_SIGNATURE_MASK = 0xffff0000, -	I2400M_BRH_SIGNATURE_SHIFT = 16, -	I2400M_BRH_OPCODE_MASK = 0x0000000f, -	I2400M_BRH_RESPONSE_MASK = 0x000000f0, -	I2400M_BRH_RESPONSE_SHIFT = 4, -	I2400M_BRH_DIRECT_ACCESS = 0x00000400, -	I2400M_BRH_RESPONSE_REQUIRED = 0x00000200, -	I2400M_BRH_USE_CHECKSUM = 0x00000100, -}; - - -/** - * i2400m_bootrom_header - Header for a boot-mode command - * - * @cmd: the above command descriptor - * @target_addr: where on the device memory should the action be performed. - * @data_size: for read/write, amount of data to be read/written - * @block_checksum: checksum value (if applicable) - * @payload: the beginning of data attached to this header - */ -struct i2400m_bootrom_header { -	__le32 command;		/* Compose with enum i2400_brh */ -	__le32 target_addr; -	__le32 data_size; -	__le32 block_checksum; -	char payload[0]; -} __attribute__ ((packed)); - - -/* - * Data / control protocol - */ - -/* Packet types for the host-device interface */ -enum i2400m_pt { -	I2400M_PT_DATA = 0, -	I2400M_PT_CTRL, -	I2400M_PT_TRACE,	/* For device debug */ -	I2400M_PT_RESET_WARM,	/* device reset */ -	I2400M_PT_RESET_COLD,	/* USB[transport] reset, like reconnect */ -	I2400M_PT_EDATA,	/* Extended RX data */ -	I2400M_PT_ILLEGAL -}; - - -/* - * Payload for a data packet - * - * This is prefixed to each and every outgoing DATA type. - */ -struct i2400m_pl_data_hdr { -	__le32 reserved; -} __attribute__((packed)); - - -/* - * Payload for an extended data packet - * - * New in fw v1.4 - * - * @reorder: if this payload has to be reorder or not (and how) - * @cs: the type of data in the packet, as defined per (802.16e - *     T11.13.19.1). Currently only 2 (IPv4 packet) supported. - * - * This is prefixed to each and every INCOMING DATA packet. - */ -struct i2400m_pl_edata_hdr { -	__le32 reorder;		/* bits defined in i2400m_ro */ -	__u8 cs; -	__u8 reserved[11]; -} __attribute__((packed)); - -enum i2400m_cs { -	I2400M_CS_IPV4_0 = 0, -	I2400M_CS_IPV4 = 2, -}; - -enum i2400m_ro { -	I2400M_RO_NEEDED     = 0x01, -	I2400M_RO_TYPE       = 0x03, -	I2400M_RO_TYPE_SHIFT = 1, -	I2400M_RO_CIN        = 0x0f, -	I2400M_RO_CIN_SHIFT  = 4, -	I2400M_RO_FBN        = 0x07ff, -	I2400M_RO_FBN_SHIFT  = 8, -	I2400M_RO_SN         = 0x07ff, -	I2400M_RO_SN_SHIFT   = 21, -}; - -enum i2400m_ro_type { -	I2400M_RO_TYPE_RESET = 0, -	I2400M_RO_TYPE_PACKET, -	I2400M_RO_TYPE_WS, -	I2400M_RO_TYPE_PACKET_WS, -}; - - -/* Misc constants */ -enum { -	I2400M_PL_ALIGN = 16,	/* Payload data size alignment */ -	I2400M_PL_SIZE_MAX = 0x3EFF, -	I2400M_MAX_PLS_IN_MSG = 60, -	/* protocol barkers: sync sequences; for notifications they -	 * are sent in groups of four. */ -	I2400M_H2D_PREVIEW_BARKER = 0xcafe900d, -	I2400M_COLD_RESET_BARKER = 0xc01dc01d, -	I2400M_WARM_RESET_BARKER = 0x50f750f7, -	I2400M_NBOOT_BARKER = 0xdeadbeef, -	I2400M_SBOOT_BARKER = 0x0ff1c1a1, -	I2400M_SBOOT_BARKER_6050 = 0x80000001, -	I2400M_ACK_BARKER = 0xfeedbabe, -	I2400M_D2H_MSG_BARKER = 0xbeefbabe, -}; - - -/* - * Hardware payload descriptor - * - * Bitfields encoded in a struct to enforce typing semantics. - * - * Look in rx.c and tx.c for a full description of the format. - */ -struct i2400m_pld { -	__le32 val; -} __attribute__ ((packed)); - -#define I2400M_PLD_SIZE_MASK 0x00003fff -#define I2400M_PLD_TYPE_SHIFT 16 -#define I2400M_PLD_TYPE_MASK 0x000f0000 - -/* - * Header for a TX message or RX message - * - * @barker: preamble - * @size: used for management of the FIFO queue buffer; before - *     sending, this is converted to be a real preamble. This - *     indicates the real size of the TX message that starts at this - *     point. If the highest bit is set, then this message is to be - *     skipped. - * @sequence: sequence number of this message - * @offset: offset where the message itself starts -- see the comments - *     in the file header about message header and payload descriptor - *     alignment. - * @num_pls: number of payloads in this message - * @padding: amount of padding bytes at the end of the message to make - *           it be of block-size aligned - * - * Look in rx.c and tx.c for a full description of the format. - */ -struct i2400m_msg_hdr { -	union { -		__le32 barker; -		__u32 size;	/* same size type as barker!! */ -	}; -	union { -		__le32 sequence; -		__u32 offset;	/* same size type as barker!! */ -	}; -	__le16 num_pls; -	__le16 rsv1; -	__le16 padding; -	__le16 rsv2; -	struct i2400m_pld pld[0]; -} __attribute__ ((packed)); - - - -/* - * L3/L4 control protocol - */ - -enum { -	/* Interface version */ -	I2400M_L3L4_VERSION             = 0x0100, -}; - -/* Message types */ -enum i2400m_mt { -	I2400M_MT_RESERVED              = 0x0000, -	I2400M_MT_INVALID               = 0xffff, -	I2400M_MT_REPORT_MASK		= 0x8000, - -	I2400M_MT_GET_SCAN_RESULT  	= 0x4202, -	I2400M_MT_SET_SCAN_PARAM   	= 0x4402, -	I2400M_MT_CMD_RF_CONTROL   	= 0x4602, -	I2400M_MT_CMD_SCAN         	= 0x4603, -	I2400M_MT_CMD_CONNECT      	= 0x4604, -	I2400M_MT_CMD_DISCONNECT   	= 0x4605, -	I2400M_MT_CMD_EXIT_IDLE   	= 0x4606, -	I2400M_MT_GET_LM_VERSION   	= 0x5201, -	I2400M_MT_GET_DEVICE_INFO  	= 0x5202, -	I2400M_MT_GET_LINK_STATUS  	= 0x5203, -	I2400M_MT_GET_STATISTICS   	= 0x5204, -	I2400M_MT_GET_STATE        	= 0x5205, -	I2400M_MT_GET_MEDIA_STATUS	= 0x5206, -	I2400M_MT_SET_INIT_CONFIG	= 0x5404, -	I2400M_MT_CMD_INIT	        = 0x5601, -	I2400M_MT_CMD_TERMINATE		= 0x5602, -	I2400M_MT_CMD_MODE_OF_OP	= 0x5603, -	I2400M_MT_CMD_RESET_DEVICE	= 0x5604, -	I2400M_MT_CMD_MONITOR_CONTROL   = 0x5605, -	I2400M_MT_CMD_ENTER_POWERSAVE   = 0x5606, -	I2400M_MT_GET_TLS_OPERATION_RESULT = 0x6201, -	I2400M_MT_SET_EAP_SUCCESS       = 0x6402, -	I2400M_MT_SET_EAP_FAIL          = 0x6403, -	I2400M_MT_SET_EAP_KEY          	= 0x6404, -	I2400M_MT_CMD_SEND_EAP_RESPONSE = 0x6602, -	I2400M_MT_REPORT_SCAN_RESULT    = 0xc002, -	I2400M_MT_REPORT_STATE		= 0xd002, -	I2400M_MT_REPORT_POWERSAVE_READY = 0xd005, -	I2400M_MT_REPORT_EAP_REQUEST    = 0xe002, -	I2400M_MT_REPORT_EAP_RESTART    = 0xe003, -	I2400M_MT_REPORT_ALT_ACCEPT    	= 0xe004, -	I2400M_MT_REPORT_KEY_REQUEST 	= 0xe005, -}; - - -/* - * Message Ack Status codes - * - * When a message is replied-to, this status is reported. - */ -enum i2400m_ms { -	I2400M_MS_DONE_OK                  = 0, -	I2400M_MS_DONE_IN_PROGRESS         = 1, -	I2400M_MS_INVALID_OP               = 2, -	I2400M_MS_BAD_STATE                = 3, -	I2400M_MS_ILLEGAL_VALUE            = 4, -	I2400M_MS_MISSING_PARAMS           = 5, -	I2400M_MS_VERSION_ERROR            = 6, -	I2400M_MS_ACCESSIBILITY_ERROR      = 7, -	I2400M_MS_BUSY                     = 8, -	I2400M_MS_CORRUPTED_TLV            = 9, -	I2400M_MS_UNINITIALIZED            = 10, -	I2400M_MS_UNKNOWN_ERROR            = 11, -	I2400M_MS_PRODUCTION_ERROR         = 12, -	I2400M_MS_NO_RF                    = 13, -	I2400M_MS_NOT_READY_FOR_POWERSAVE  = 14, -	I2400M_MS_THERMAL_CRITICAL         = 15, -	I2400M_MS_MAX -}; - - -/** - * i2400m_tlv - enumeration of the different types of TLVs - * - * TLVs stand for type-length-value and are the header for a payload - * composed of almost anything. Each payload has a type assigned - * and a length. - */ -enum i2400m_tlv { -	I2400M_TLV_L4_MESSAGE_VERSIONS = 129, -	I2400M_TLV_SYSTEM_STATE = 141, -	I2400M_TLV_MEDIA_STATUS = 161, -	I2400M_TLV_RF_OPERATION = 162, -	I2400M_TLV_RF_STATUS = 163, -	I2400M_TLV_DEVICE_RESET_TYPE = 132, -	I2400M_TLV_CONFIG_IDLE_PARAMETERS = 601, -	I2400M_TLV_CONFIG_IDLE_TIMEOUT = 611, -	I2400M_TLV_CONFIG_D2H_DATA_FORMAT = 614, -	I2400M_TLV_CONFIG_DL_HOST_REORDER = 615, -}; - - -struct i2400m_tlv_hdr { -	__le16 type; -	__le16 length;		/* payload's */ -	__u8   pl[0]; -} __attribute__((packed)); - - -struct i2400m_l3l4_hdr { -	__le16 type; -	__le16 length;		/* payload's */ -	__le16 version; -	__le16 resv1; -	__le16 status; -	__le16 resv2; -	struct i2400m_tlv_hdr pl[0]; -} __attribute__((packed)); - - -/** - * i2400m_system_state - different states of the device - */ -enum i2400m_system_state { -	I2400M_SS_UNINITIALIZED = 1, -	I2400M_SS_INIT, -	I2400M_SS_READY, -	I2400M_SS_SCAN, -	I2400M_SS_STANDBY, -	I2400M_SS_CONNECTING, -	I2400M_SS_WIMAX_CONNECTED, -	I2400M_SS_DATA_PATH_CONNECTED, -	I2400M_SS_IDLE, -	I2400M_SS_DISCONNECTING, -	I2400M_SS_OUT_OF_ZONE, -	I2400M_SS_SLEEPACTIVE, -	I2400M_SS_PRODUCTION, -	I2400M_SS_CONFIG, -	I2400M_SS_RF_OFF, -	I2400M_SS_RF_SHUTDOWN, -	I2400M_SS_DEVICE_DISCONNECT, -	I2400M_SS_MAX, -}; - - -/** - * i2400m_tlv_system_state - report on the state of the system - * - * @state: see enum i2400m_system_state - */ -struct i2400m_tlv_system_state { -	struct i2400m_tlv_hdr hdr; -	__le32 state; -} __attribute__((packed)); - - -struct i2400m_tlv_l4_message_versions { -	struct i2400m_tlv_hdr hdr; -	__le16 major; -	__le16 minor; -	__le16 branch; -	__le16 reserved; -} __attribute__((packed)); - - -struct i2400m_tlv_detailed_device_info { -	struct i2400m_tlv_hdr hdr; -	__u8 reserved1[400]; -	__u8 mac_address[ETH_ALEN]; -	__u8 reserved2[2]; -} __attribute__((packed)); - - -enum i2400m_rf_switch_status { -	I2400M_RF_SWITCH_ON = 1, -	I2400M_RF_SWITCH_OFF = 2, -}; - -struct i2400m_tlv_rf_switches_status { -	struct i2400m_tlv_hdr hdr; -	__u8 sw_rf_switch;	/* 1 ON, 2 OFF */ -	__u8 hw_rf_switch;	/* 1 ON, 2 OFF */ -	__u8 reserved[2]; -} __attribute__((packed)); - - -enum { -	i2400m_rf_operation_on = 1, -	i2400m_rf_operation_off = 2 -}; - -struct i2400m_tlv_rf_operation { -	struct i2400m_tlv_hdr hdr; -	__le32 status;	/* 1 ON, 2 OFF */ -} __attribute__((packed)); - - -enum i2400m_tlv_reset_type { -	I2400M_RESET_TYPE_COLD = 1, -	I2400M_RESET_TYPE_WARM -}; - -struct i2400m_tlv_device_reset_type { -	struct i2400m_tlv_hdr hdr; -	__le32 reset_type; -} __attribute__((packed)); - - -struct i2400m_tlv_config_idle_parameters { -	struct i2400m_tlv_hdr hdr; -	__le32 idle_timeout;	/* 100 to 300000 ms [5min], 100 increments -				 * 0 disabled */ -	__le32 idle_paging_interval;	/* frames */ -} __attribute__((packed)); - - -enum i2400m_media_status { -	I2400M_MEDIA_STATUS_LINK_UP = 1, -	I2400M_MEDIA_STATUS_LINK_DOWN, -	I2400M_MEDIA_STATUS_LINK_RENEW, -}; - -struct i2400m_tlv_media_status { -	struct i2400m_tlv_hdr hdr; -	__le32 media_status; -} __attribute__((packed)); - - -/* New in v1.4 */ -struct i2400m_tlv_config_idle_timeout { -	struct i2400m_tlv_hdr hdr; -	__le32 timeout;	/* 100 to 300000 ms [5min], 100 increments -			 * 0 disabled */ -} __attribute__((packed)); - -/* New in v1.4 -- for backward compat, will be removed */ -struct i2400m_tlv_config_d2h_data_format { -	struct i2400m_tlv_hdr hdr; -	__u8 format; 		/* 0 old format, 1 enhanced */ -	__u8 reserved[3]; -} __attribute__((packed)); - -/* New in v1.4 */ -struct i2400m_tlv_config_dl_host_reorder { -	struct i2400m_tlv_hdr hdr; -	__u8 reorder; 		/* 0 disabled, 1 enabled */ -	__u8 reserved[3]; -} __attribute__((packed)); - - -#endif /* #ifndef __LINUX__WIMAX__I2400M_H__ */ diff --git a/include/uapi/linux/wireguard.h b/include/uapi/linux/wireguard.h index ae88be14c947..8c26391196d5 100644 --- a/include/uapi/linux/wireguard.h +++ b/include/uapi/linux/wireguard.h @@ -101,6 +101,10 @@   *                    WGALLOWEDIP_A_FAMILY: NLA_U16   *                    WGALLOWEDIP_A_IPADDR: struct in_addr or struct in6_addr   *                    WGALLOWEDIP_A_CIDR_MASK: NLA_U8 + *                    WGALLOWEDIP_A_FLAGS: NLA_U32, WGALLOWEDIP_F_REMOVE_ME if + *                                         the specified IP should be removed; + *                                         otherwise, this IP will be added if + *                                         it is not already present.   *                0: NLA_NESTED   *                    ...   *                0: NLA_NESTED @@ -184,11 +188,16 @@ enum wgpeer_attribute {  };  #define WGPEER_A_MAX (__WGPEER_A_LAST - 1) +enum wgallowedip_flag { +	WGALLOWEDIP_F_REMOVE_ME = 1U << 0, +	__WGALLOWEDIP_F_ALL = WGALLOWEDIP_F_REMOVE_ME +};  enum wgallowedip_attribute {  	WGALLOWEDIP_A_UNSPEC,  	WGALLOWEDIP_A_FAMILY,  	WGALLOWEDIP_A_IPADDR,  	WGALLOWEDIP_A_CIDR_MASK, +	WGALLOWEDIP_A_FLAGS,  	__WGALLOWEDIP_A_LAST  };  #define WGALLOWEDIP_A_MAX (__WGALLOWEDIP_A_LAST - 1) diff --git a/include/uapi/linux/wireless.h b/include/uapi/linux/wireless.h index 08967b3f19c8..3c2ad5fae17f 100644 --- a/include/uapi/linux/wireless.h +++ b/include/uapi/linux/wireless.h @@ -835,7 +835,7 @@ struct iw_encode_ext {  			       * individual keys */  	__u16		alg; /* IW_ENCODE_ALG_* */  	__u16		key_len; -	__u8		key[0]; +	__u8		key[];  };  /* SIOCSIWMLME data */ diff --git a/include/uapi/linux/wwan.h b/include/uapi/linux/wwan.h new file mode 100644 index 000000000000..32a2720b4d11 --- /dev/null +++ b/include/uapi/linux/wwan.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * Copyright (C) 2021 Intel Corporation. + */ +#ifndef _UAPI_WWAN_H_ +#define _UAPI_WWAN_H_ + +enum { +	IFLA_WWAN_UNSPEC, +	IFLA_WWAN_LINK_ID, /* u32 */ + +	__IFLA_WWAN_MAX +}; +#define IFLA_WWAN_MAX (__IFLA_WWAN_MAX - 1) + +#endif /* _UAPI_WWAN_H_ */ diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h index 9463db2dfa9d..c7c85bb504ba 100644 --- a/include/uapi/linux/xattr.h +++ b/include/uapi/linux/xattr.h @@ -11,6 +11,7 @@  */  #include <linux/libc-compat.h> +#include <linux/types.h>  #ifndef _UAPI_LINUX_XATTR_H  #define _UAPI_LINUX_XATTR_H @@ -20,6 +21,12 @@  #define XATTR_CREATE	0x1	/* set value, fail if attr already exists */  #define XATTR_REPLACE	0x2	/* set value, fail if attr does not exist */ + +struct xattr_args { +	__aligned_u64 __user value; +	__u32 size; +	__u32 flags; +};  #endif  /* Namespaces */ @@ -76,6 +83,10 @@  #define XATTR_CAPS_SUFFIX "capability"  #define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX +#define XATTR_BPF_LSM_SUFFIX "bpf." +#define XATTR_NAME_BPF_LSM (XATTR_SECURITY_PREFIX XATTR_BPF_LSM_SUFFIX) +#define XATTR_NAME_BPF_LSM_LEN (sizeof(XATTR_NAME_BPF_LSM) - 1) +  #define XATTR_POSIX_ACL_ACCESS  "posix_acl_access"  #define XATTR_NAME_POSIX_ACL_ACCESS XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_ACCESS  #define XATTR_POSIX_ACL_DEFAULT  "posix_acl_default" diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h index ffc6a5391bb7..a23495c0e0a1 100644 --- a/include/uapi/linux/xfrm.h +++ b/include/uapi/linux/xfrm.h @@ -4,6 +4,7 @@  #include <linux/in6.h>  #include <linux/types.h> +#include <linux/stddef.h>  /* All of the structures in this file may not change size as they are   * passed into the kernel from userspace via netlink sockets. @@ -33,7 +34,7 @@ struct xfrm_sec_ctx {  	__u8	ctx_alg;  	__u16	ctx_len;  	__u32	ctx_sid; -	char	ctx_str[0]; +	char	ctx_str[] __counted_by(ctx_len);  };  /* Security Context Domains of Interpretation */ @@ -96,27 +97,27 @@ struct xfrm_replay_state_esn {  	__u32		oseq_hi;  	__u32		seq_hi;  	__u32		replay_window; -	__u32		bmp[0]; +	__u32		bmp[];  };  struct xfrm_algo {  	char		alg_name[64];  	unsigned int	alg_key_len;    /* in bits */ -	char		alg_key[0]; +	char		alg_key[];  };  struct xfrm_algo_auth {  	char		alg_name[64];  	unsigned int	alg_key_len;    /* in bits */  	unsigned int	alg_trunc_len;  /* in bits */ -	char		alg_key[0]; +	char		alg_key[];  };  struct xfrm_algo_aead {  	char		alg_name[64];  	unsigned int	alg_key_len;	/* in bits */  	unsigned int	alg_icv_len;	/* in bits */ -	char		alg_key[0]; +	char		alg_key[];  };  struct xfrm_stats { @@ -140,6 +141,11 @@ enum {  	XFRM_POLICY_MAX	= 3  }; +enum xfrm_sa_dir { +	XFRM_SA_DIR_IN	= 1, +	XFRM_SA_DIR_OUT = 2 +}; +  enum {  	XFRM_SHARE_ANY,		/* No limitations */  	XFRM_SHARE_SESSION,	/* For this session only */ @@ -152,7 +158,8 @@ enum {  #define XFRM_MODE_ROUTEOPTIMIZATION 2  #define XFRM_MODE_IN_TRIGGER 3  #define XFRM_MODE_BEET 4 -#define XFRM_MODE_MAX 5 +#define XFRM_MODE_IPTFS 5 +#define XFRM_MODE_MAX 6  /* Netlink configuration messages.  */  enum { @@ -215,6 +222,11 @@ enum {  	XFRM_MSG_MAPPING,  #define XFRM_MSG_MAPPING XFRM_MSG_MAPPING + +	XFRM_MSG_SETDEFAULT, +#define XFRM_MSG_SETDEFAULT XFRM_MSG_SETDEFAULT +	XFRM_MSG_GETDEFAULT, +#define XFRM_MSG_GETDEFAULT XFRM_MSG_GETDEFAULT  	__XFRM_MSG_MAX  };  #define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1) @@ -222,7 +234,7 @@ enum {  #define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)  /* - * Generic LSM security context for comunicating to user space + * Generic LSM security context for communicating to user space   * NOTE: Same format as sadb_x_sec_ctx   */  struct xfrm_user_sec_ctx { @@ -291,7 +303,7 @@ enum xfrm_attr_type_t {  	XFRMA_ETIMER_THRESH,  	XFRMA_SRCADDR,		/* xfrm_address_t */  	XFRMA_COADDR,		/* xfrm_address_t */ -	XFRMA_LASTUSED,		/* unsigned long  */ +	XFRMA_LASTUSED,		/* __u64 */  	XFRMA_POLICY_TYPE,	/* struct xfrm_userpolicy_type */  	XFRMA_MIGRATE,  	XFRMA_ALG_AEAD,		/* struct xfrm_algo_aead */ @@ -308,6 +320,16 @@ enum xfrm_attr_type_t {  	XFRMA_SET_MARK,		/* __u32 */  	XFRMA_SET_MARK_MASK,	/* __u32 */  	XFRMA_IF_ID,		/* __u32 */ +	XFRMA_MTIMER_THRESH,	/* __u32 in seconds for input SA */ +	XFRMA_SA_DIR,		/* __u8 */ +	XFRMA_NAT_KEEPALIVE_INTERVAL,	/* __u32 in seconds for NAT keepalive */ +	XFRMA_SA_PCPU,		/* __u32 */ +	XFRMA_IPTFS_DROP_TIME,	/* __u32 in: usec to wait for next seq */ +	XFRMA_IPTFS_REORDER_WINDOW, /* __u16 in: reorder window size (pkts) */ +	XFRMA_IPTFS_DONT_FRAG,	/* out: don't use fragmentation */ +	XFRMA_IPTFS_INIT_DELAY,	/* __u32 out: initial packet wait delay (usec) */ +	XFRMA_IPTFS_MAX_QSIZE,	/* __u32 out: max ingress queue size (octets) */ +	XFRMA_IPTFS_PKT_SIZE,	/* __u32 out: size of outer packet, 0 for PMTU */  	__XFRMA_MAX  #define XFRMA_OUTPUT_MARK XFRMA_SET_MARK	/* Compatibility */ @@ -423,6 +445,7 @@ struct xfrm_userpolicy_info {  #define XFRM_POLICY_LOCALOK	1	/* Allow user to override global policy */  	/* Automatically expand selector to include matching ICMP payloads. */  #define XFRM_POLICY_ICMP	2 +#define XFRM_POLICY_CPU_ACQUIRE	4  	__u8				share;  }; @@ -505,8 +528,29 @@ struct xfrm_user_offload {  	int				ifindex;  	__u8				flags;  }; +/* This flag was exposed without any kernel code that supports it. + * Unfortunately, strongswan has the code that sets this flag, + * which makes it impossible to reuse this bit. + * + * So leave it here to make sure that it won't be reused by mistake. + */  #define XFRM_OFFLOAD_IPV6	1  #define XFRM_OFFLOAD_INBOUND	2 +/* Two bits above are relevant for state path only, while + * offload is used for both policy and state flows. + * + * In policy offload mode, they are free and can be safely reused. + */ +#define XFRM_OFFLOAD_PACKET	4 + +struct xfrm_userpolicy_default { +#define XFRM_USERPOLICY_UNSPEC	0 +#define XFRM_USERPOLICY_BLOCK	1 +#define XFRM_USERPOLICY_ACCEPT	2 +	__u8				in; +	__u8				fwd; +	__u8				out; +};  #ifndef __KERNEL__  /* backwards compatibility for userspace */ diff --git a/include/uapi/linux/zorro_ids.h b/include/uapi/linux/zorro_ids.h index 6e574d7b7d79..393f2ee9c042 100644 --- a/include/uapi/linux/zorro_ids.h +++ b/include/uapi/linux/zorro_ids.h @@ -449,6 +449,9 @@  #define  ZORRO_PROD_VMC_ISDN_BLASTER_Z2				ZORRO_ID(VMC, 0x01, 0)  #define  ZORRO_PROD_VMC_HYPERCOM_4				ZORRO_ID(VMC, 0x02, 0) +#define ZORRO_MANUF_CSLAB					0x1400 +#define  ZORRO_PROD_CSLAB_WARP_1260				ZORRO_ID(CSLAB, 0x65, 0) +  #define ZORRO_MANUF_INFORMATION					0x157C  #define  ZORRO_PROD_INFORMATION_ISDN_ENGINE_I			ZORRO_ID(INFORMATION, 0x64, 0)  | 
