1/****************************************************************************
2 ****************************************************************************
3 ***
4 ***   This header was automatically generated from a Linux kernel header
5 ***   of the same name, to make information necessary for userspace to
6 ***   call into the kernel available to libc.  It contains only constants,
7 ***   structures, and macros generated from the original header, and thus,
8 ***   contains no copyrightable information.
9 ***
10 ***   To edit the content of this header, modify the corresponding
11 ***   source file (e.g. under external/kernel-headers/original/) then
12 ***   run bionic/libc/kernel/tools/update_all.py
13 ***
14 ***   Any manual change here will be lost the next time this script will
15 ***   be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _UAPI_MISC_CXL_H
20#define _UAPI_MISC_CXL_H
21#include <linux/types.h>
22#include <linux/ioctl.h>
23struct cxl_ioctl_start_work {
24  __u64 flags;
25  __u64 work_element_descriptor;
26  __u64 amr;
27  __s16 num_interrupts;
28  __s16 reserved1;
29  __s32 reserved2;
30  __u64 reserved3;
31  __u64 reserved4;
32  __u64 reserved5;
33  __u64 reserved6;
34};
35#define CXL_START_WORK_AMR 0x0000000000000001ULL
36#define CXL_START_WORK_NUM_IRQS 0x0000000000000002ULL
37#define CXL_START_WORK_ERR_FF 0x0000000000000004ULL
38#define CXL_START_WORK_ALL (CXL_START_WORK_AMR | CXL_START_WORK_NUM_IRQS | CXL_START_WORK_ERR_FF)
39#define CXL_MODE_DEDICATED 0x1
40#define CXL_MODE_DIRECTED 0x2
41#define CXL_AFUID_FLAG_SLAVE 0x1
42struct cxl_afu_id {
43  __u64 flags;
44  __u32 card_id;
45  __u32 afu_offset;
46  __u32 afu_mode;
47  __u32 reserved1;
48  __u64 reserved2;
49  __u64 reserved3;
50  __u64 reserved4;
51  __u64 reserved5;
52  __u64 reserved6;
53};
54#define CXL_AI_NEED_HEADER 0x0000000000000001ULL
55#define CXL_AI_ALL CXL_AI_NEED_HEADER
56#define CXL_AI_HEADER_SIZE 128
57#define CXL_AI_BUFFER_SIZE 4096
58#define CXL_AI_MAX_ENTRIES 256
59#define CXL_AI_MAX_CHUNK_SIZE (CXL_AI_BUFFER_SIZE * CXL_AI_MAX_ENTRIES)
60struct cxl_adapter_image {
61  __u64 flags;
62  __u64 data;
63  __u64 len_data;
64  __u64 len_image;
65  __u64 reserved1;
66  __u64 reserved2;
67  __u64 reserved3;
68  __u64 reserved4;
69};
70#define CXL_MAGIC 0xCA
71#define CXL_IOCTL_START_WORK _IOW(CXL_MAGIC, 0x00, struct cxl_ioctl_start_work)
72#define CXL_IOCTL_GET_PROCESS_ELEMENT _IOR(CXL_MAGIC, 0x01, __u32)
73#define CXL_IOCTL_GET_AFU_ID _IOR(CXL_MAGIC, 0x02, struct cxl_afu_id)
74#define CXL_IOCTL_DOWNLOAD_IMAGE _IOW(CXL_MAGIC, 0x0A, struct cxl_adapter_image)
75#define CXL_IOCTL_VALIDATE_IMAGE _IOW(CXL_MAGIC, 0x0B, struct cxl_adapter_image)
76#define CXL_READ_MIN_SIZE 0x1000
77enum cxl_event_type {
78  CXL_EVENT_RESERVED = 0,
79  CXL_EVENT_AFU_INTERRUPT = 1,
80  CXL_EVENT_DATA_STORAGE = 2,
81  CXL_EVENT_AFU_ERROR = 3,
82  CXL_EVENT_AFU_DRIVER = 4,
83};
84struct cxl_event_header {
85  __u16 type;
86  __u16 size;
87  __u16 process_element;
88  __u16 reserved1;
89};
90struct cxl_event_afu_interrupt {
91  __u16 flags;
92  __u16 irq;
93  __u32 reserved1;
94};
95struct cxl_event_data_storage {
96  __u16 flags;
97  __u16 reserved1;
98  __u32 reserved2;
99  __u64 addr;
100  __u64 dsisr;
101  __u64 reserved3;
102};
103struct cxl_event_afu_error {
104  __u16 flags;
105  __u16 reserved1;
106  __u32 reserved2;
107  __u64 error;
108};
109struct cxl_event_afu_driver_reserved {
110  __u32 data_size;
111  __u8 data[];
112};
113struct cxl_event {
114  struct cxl_event_header header;
115  union {
116    struct cxl_event_afu_interrupt irq;
117    struct cxl_event_data_storage fault;
118    struct cxl_event_afu_error afu_error;
119    struct cxl_event_afu_driver_reserved afu_driver_event;
120  };
121};
122#endif
123