Ian Munsie | 66b4308 | 2014-10-08 19:55:03 +1100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 IBM Corp. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version |
| 7 | * 2 of the License, or (at your option) any later version. |
| 8 | */ |
| 9 | |
| 10 | #ifndef _UAPI_MISC_CXL_H |
| 11 | #define _UAPI_MISC_CXL_H |
| 12 | |
| 13 | #include <linux/types.h> |
| 14 | #include <linux/ioctl.h> |
| 15 | |
Ian Munsie | a9282d0 | 2014-10-08 19:55:05 +1100 | [diff] [blame] | 16 | |
Ian Munsie | 66b4308 | 2014-10-08 19:55:03 +1100 | [diff] [blame] | 17 | struct cxl_ioctl_start_work { |
| 18 | __u64 flags; |
| 19 | __u64 work_element_descriptor; |
| 20 | __u64 amr; |
| 21 | __s16 num_interrupts; |
| 22 | __s16 reserved1; |
| 23 | __s32 reserved2; |
| 24 | __u64 reserved3; |
| 25 | __u64 reserved4; |
| 26 | __u64 reserved5; |
| 27 | __u64 reserved6; |
| 28 | }; |
Ian Munsie | a9282d0 | 2014-10-08 19:55:05 +1100 | [diff] [blame] | 29 | |
Ian Munsie | 66b4308 | 2014-10-08 19:55:03 +1100 | [diff] [blame] | 30 | #define CXL_START_WORK_AMR 0x0000000000000001ULL |
| 31 | #define CXL_START_WORK_NUM_IRQS 0x0000000000000002ULL |
Ian Munsie | d9232a3 | 2015-07-23 16:43:56 +1000 | [diff] [blame] | 32 | #define CXL_START_WORK_ERR_FF 0x0000000000000004ULL |
Ian Munsie | 66b4308 | 2014-10-08 19:55:03 +1100 | [diff] [blame] | 33 | #define CXL_START_WORK_ALL (CXL_START_WORK_AMR |\ |
Ian Munsie | d9232a3 | 2015-07-23 16:43:56 +1000 | [diff] [blame] | 34 | CXL_START_WORK_NUM_IRQS |\ |
| 35 | CXL_START_WORK_ERR_FF) |
Ian Munsie | 66b4308 | 2014-10-08 19:55:03 +1100 | [diff] [blame] | 36 | |
Vaibhav Jain | 27d4dc7 | 2015-04-29 15:47:23 +0530 | [diff] [blame] | 37 | |
| 38 | /* Possible modes that an afu can be in */ |
| 39 | #define CXL_MODE_DEDICATED 0x1 |
| 40 | #define CXL_MODE_DIRECTED 0x2 |
| 41 | |
| 42 | /* possible flags for the cxl_afu_id flags field */ |
| 43 | #define CXL_AFUID_FLAG_SLAVE 0x1 /* In directed-mode afu is in slave mode */ |
| 44 | |
| 45 | struct cxl_afu_id { |
| 46 | __u64 flags; /* One of CXL_AFUID_FLAG_X */ |
| 47 | __u32 card_id; |
| 48 | __u32 afu_offset; |
| 49 | __u32 afu_mode; /* one of the CXL_MODE_X */ |
| 50 | __u32 reserved1; |
| 51 | __u64 reserved2; |
| 52 | __u64 reserved3; |
| 53 | __u64 reserved4; |
| 54 | __u64 reserved5; |
| 55 | __u64 reserved6; |
| 56 | }; |
| 57 | |
Christophe Lombard | 594ff7d | 2016-03-04 12:26:38 +0100 | [diff] [blame] | 58 | /* base adapter image header is included in the image */ |
| 59 | #define CXL_AI_NEED_HEADER 0x0000000000000001ULL |
| 60 | #define CXL_AI_ALL CXL_AI_NEED_HEADER |
| 61 | |
| 62 | #define CXL_AI_HEADER_SIZE 128 |
| 63 | #define CXL_AI_BUFFER_SIZE 4096 |
| 64 | #define CXL_AI_MAX_ENTRIES 256 |
| 65 | #define CXL_AI_MAX_CHUNK_SIZE (CXL_AI_BUFFER_SIZE * CXL_AI_MAX_ENTRIES) |
| 66 | |
| 67 | struct cxl_adapter_image { |
| 68 | __u64 flags; |
| 69 | __u64 data; |
| 70 | __u64 len_data; |
| 71 | __u64 len_image; |
| 72 | __u64 reserved1; |
| 73 | __u64 reserved2; |
| 74 | __u64 reserved3; |
| 75 | __u64 reserved4; |
| 76 | }; |
| 77 | |
Ian Munsie | a9282d0 | 2014-10-08 19:55:05 +1100 | [diff] [blame] | 78 | /* ioctl numbers */ |
Ian Munsie | 66b4308 | 2014-10-08 19:55:03 +1100 | [diff] [blame] | 79 | #define CXL_MAGIC 0xCA |
Christophe Lombard | 594ff7d | 2016-03-04 12:26:38 +0100 | [diff] [blame] | 80 | /* AFU devices */ |
Ian Munsie | 66b4308 | 2014-10-08 19:55:03 +1100 | [diff] [blame] | 81 | #define CXL_IOCTL_START_WORK _IOW(CXL_MAGIC, 0x00, struct cxl_ioctl_start_work) |
| 82 | #define CXL_IOCTL_GET_PROCESS_ELEMENT _IOR(CXL_MAGIC, 0x01, __u32) |
Vaibhav Jain | 27d4dc7 | 2015-04-29 15:47:23 +0530 | [diff] [blame] | 83 | #define CXL_IOCTL_GET_AFU_ID _IOR(CXL_MAGIC, 0x02, struct cxl_afu_id) |
Christophe Lombard | 594ff7d | 2016-03-04 12:26:38 +0100 | [diff] [blame] | 84 | /* adapter devices */ |
| 85 | #define CXL_IOCTL_DOWNLOAD_IMAGE _IOW(CXL_MAGIC, 0x0A, struct cxl_adapter_image) |
| 86 | #define CXL_IOCTL_VALIDATE_IMAGE _IOW(CXL_MAGIC, 0x0B, struct cxl_adapter_image) |
Ian Munsie | 66b4308 | 2014-10-08 19:55:03 +1100 | [diff] [blame] | 87 | |
Ian Munsie | 66b4308 | 2014-10-08 19:55:03 +1100 | [diff] [blame] | 88 | #define CXL_READ_MIN_SIZE 0x1000 /* 4K */ |
| 89 | |
Ian Munsie | a9282d0 | 2014-10-08 19:55:05 +1100 | [diff] [blame] | 90 | /* Events from read() */ |
Ian Munsie | 66b4308 | 2014-10-08 19:55:03 +1100 | [diff] [blame] | 91 | enum cxl_event_type { |
| 92 | CXL_EVENT_RESERVED = 0, |
| 93 | CXL_EVENT_AFU_INTERRUPT = 1, |
| 94 | CXL_EVENT_DATA_STORAGE = 2, |
| 95 | CXL_EVENT_AFU_ERROR = 3, |
| 96 | }; |
| 97 | |
| 98 | struct cxl_event_header { |
| 99 | __u16 type; |
| 100 | __u16 size; |
| 101 | __u16 process_element; |
| 102 | __u16 reserved1; |
| 103 | }; |
| 104 | |
| 105 | struct cxl_event_afu_interrupt { |
| 106 | __u16 flags; |
| 107 | __u16 irq; /* Raised AFU interrupt number */ |
| 108 | __u32 reserved1; |
| 109 | }; |
| 110 | |
| 111 | struct cxl_event_data_storage { |
| 112 | __u16 flags; |
| 113 | __u16 reserved1; |
| 114 | __u32 reserved2; |
| 115 | __u64 addr; |
| 116 | __u64 dsisr; |
| 117 | __u64 reserved3; |
| 118 | }; |
| 119 | |
| 120 | struct cxl_event_afu_error { |
| 121 | __u16 flags; |
| 122 | __u16 reserved1; |
| 123 | __u32 reserved2; |
| 124 | __u64 error; |
| 125 | }; |
| 126 | |
| 127 | struct cxl_event { |
| 128 | struct cxl_event_header header; |
| 129 | union { |
| 130 | struct cxl_event_afu_interrupt irq; |
| 131 | struct cxl_event_data_storage fault; |
| 132 | struct cxl_event_afu_error afu_error; |
| 133 | }; |
| 134 | }; |
| 135 | |
| 136 | #endif /* _UAPI_MISC_CXL_H */ |