blob: 56376d3907d83c3bf3c79bc73448dfd16d2d83f0 [file] [log] [blame]
Greg Kroah-Hartmane2be04c2017-11-01 15:09:13 +01001/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
Ian Munsie66b43082014-10-08 19:55:03 +11002/*
3 * Copyright 2014 IBM Corp.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11#ifndef _UAPI_MISC_CXL_H
12#define _UAPI_MISC_CXL_H
13
14#include <linux/types.h>
15#include <linux/ioctl.h>
16
Ian Munsiea9282d02014-10-08 19:55:05 +110017
Ian Munsie66b43082014-10-08 19:55:03 +110018struct cxl_ioctl_start_work {
19 __u64 flags;
20 __u64 work_element_descriptor;
21 __u64 amr;
22 __s16 num_interrupts;
Christophe Lombardb1db5512018-01-11 09:55:25 +010023 __u16 tid;
24 __s32 reserved1;
25 __u64 reserved2;
Ian Munsie66b43082014-10-08 19:55:03 +110026 __u64 reserved3;
27 __u64 reserved4;
28 __u64 reserved5;
Ian Munsie66b43082014-10-08 19:55:03 +110029};
Ian Munsiea9282d02014-10-08 19:55:05 +110030
Ian Munsie66b43082014-10-08 19:55:03 +110031#define CXL_START_WORK_AMR 0x0000000000000001ULL
32#define CXL_START_WORK_NUM_IRQS 0x0000000000000002ULL
Ian Munsied9232a32015-07-23 16:43:56 +100033#define CXL_START_WORK_ERR_FF 0x0000000000000004ULL
Christophe Lombardb1db5512018-01-11 09:55:25 +010034#define CXL_START_WORK_TID 0x0000000000000008ULL
Ian Munsie66b43082014-10-08 19:55:03 +110035#define CXL_START_WORK_ALL (CXL_START_WORK_AMR |\
Ian Munsied9232a32015-07-23 16:43:56 +100036 CXL_START_WORK_NUM_IRQS |\
Christophe Lombardb1db5512018-01-11 09:55:25 +010037 CXL_START_WORK_ERR_FF |\
38 CXL_START_WORK_TID)
Ian Munsie66b43082014-10-08 19:55:03 +110039
Vaibhav Jain27d4dc72015-04-29 15:47:23 +053040
41/* Possible modes that an afu can be in */
42#define CXL_MODE_DEDICATED 0x1
43#define CXL_MODE_DIRECTED 0x2
44
45/* possible flags for the cxl_afu_id flags field */
46#define CXL_AFUID_FLAG_SLAVE 0x1 /* In directed-mode afu is in slave mode */
47
48struct cxl_afu_id {
49 __u64 flags; /* One of CXL_AFUID_FLAG_X */
50 __u32 card_id;
51 __u32 afu_offset;
52 __u32 afu_mode; /* one of the CXL_MODE_X */
53 __u32 reserved1;
54 __u64 reserved2;
55 __u64 reserved3;
56 __u64 reserved4;
57 __u64 reserved5;
58 __u64 reserved6;
59};
60
Christophe Lombard594ff7d2016-03-04 12:26:38 +010061/* base adapter image header is included in the image */
62#define CXL_AI_NEED_HEADER 0x0000000000000001ULL
63#define CXL_AI_ALL CXL_AI_NEED_HEADER
64
65#define CXL_AI_HEADER_SIZE 128
66#define CXL_AI_BUFFER_SIZE 4096
67#define CXL_AI_MAX_ENTRIES 256
68#define CXL_AI_MAX_CHUNK_SIZE (CXL_AI_BUFFER_SIZE * CXL_AI_MAX_ENTRIES)
69
70struct cxl_adapter_image {
71 __u64 flags;
72 __u64 data;
73 __u64 len_data;
74 __u64 len_image;
75 __u64 reserved1;
76 __u64 reserved2;
77 __u64 reserved3;
78 __u64 reserved4;
79};
80
Ian Munsiea9282d02014-10-08 19:55:05 +110081/* ioctl numbers */
Ian Munsie66b43082014-10-08 19:55:03 +110082#define CXL_MAGIC 0xCA
Christophe Lombard594ff7d2016-03-04 12:26:38 +010083/* AFU devices */
Ian Munsie66b43082014-10-08 19:55:03 +110084#define CXL_IOCTL_START_WORK _IOW(CXL_MAGIC, 0x00, struct cxl_ioctl_start_work)
85#define CXL_IOCTL_GET_PROCESS_ELEMENT _IOR(CXL_MAGIC, 0x01, __u32)
Vaibhav Jain27d4dc72015-04-29 15:47:23 +053086#define CXL_IOCTL_GET_AFU_ID _IOR(CXL_MAGIC, 0x02, struct cxl_afu_id)
Christophe Lombard594ff7d2016-03-04 12:26:38 +010087/* adapter devices */
88#define CXL_IOCTL_DOWNLOAD_IMAGE _IOW(CXL_MAGIC, 0x0A, struct cxl_adapter_image)
89#define CXL_IOCTL_VALIDATE_IMAGE _IOW(CXL_MAGIC, 0x0B, struct cxl_adapter_image)
Ian Munsie66b43082014-10-08 19:55:03 +110090
Ian Munsie66b43082014-10-08 19:55:03 +110091#define CXL_READ_MIN_SIZE 0x1000 /* 4K */
92
Ian Munsiea9282d02014-10-08 19:55:05 +110093/* Events from read() */
Ian Munsie66b43082014-10-08 19:55:03 +110094enum cxl_event_type {
95 CXL_EVENT_RESERVED = 0,
96 CXL_EVENT_AFU_INTERRUPT = 1,
97 CXL_EVENT_DATA_STORAGE = 2,
98 CXL_EVENT_AFU_ERROR = 3,
Philippe Bergheaudb8102532016-06-23 15:03:53 +020099 CXL_EVENT_AFU_DRIVER = 4,
Ian Munsie66b43082014-10-08 19:55:03 +1100100};
101
102struct cxl_event_header {
103 __u16 type;
104 __u16 size;
105 __u16 process_element;
106 __u16 reserved1;
107};
108
109struct cxl_event_afu_interrupt {
110 __u16 flags;
111 __u16 irq; /* Raised AFU interrupt number */
112 __u32 reserved1;
113};
114
115struct cxl_event_data_storage {
116 __u16 flags;
117 __u16 reserved1;
118 __u32 reserved2;
119 __u64 addr;
120 __u64 dsisr;
121 __u64 reserved3;
122};
123
124struct cxl_event_afu_error {
125 __u16 flags;
126 __u16 reserved1;
127 __u32 reserved2;
128 __u64 error;
129};
130
Philippe Bergheaudb8102532016-06-23 15:03:53 +0200131struct cxl_event_afu_driver_reserved {
132 /*
133 * Defines the buffer passed to the cxl driver by the AFU driver.
134 *
135 * This is not ABI since the event header.size passed to the user for
136 * existing events is set in the read call to sizeof(cxl_event_header)
137 * + sizeof(whatever event is being dispatched) and the user is already
138 * required to use a 4K buffer on the read call.
139 *
140 * Of course the contents will be ABI, but that's up the AFU driver.
141 */
Philippe Bergheaudcbd74e12016-08-05 14:02:00 +0200142 __u32 data_size;
143 __u8 data[];
Philippe Bergheaudb8102532016-06-23 15:03:53 +0200144};
145
Ian Munsie66b43082014-10-08 19:55:03 +1100146struct cxl_event {
147 struct cxl_event_header header;
148 union {
149 struct cxl_event_afu_interrupt irq;
150 struct cxl_event_data_storage fault;
151 struct cxl_event_afu_error afu_error;
Philippe Bergheaudb8102532016-06-23 15:03:53 +0200152 struct cxl_event_afu_driver_reserved afu_driver_event;
Ian Munsie66b43082014-10-08 19:55:03 +1100153 };
154};
155
156#endif /* _UAPI_MISC_CXL_H */