18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2014 IBM Corp. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or 68c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License 78c2ecf20Sopenharmony_ci * as published by the Free Software Foundation; either version 88c2ecf20Sopenharmony_ci * 2 of the License, or (at your option) any later version. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _UAPI_MISC_CXL_H 128c2ecf20Sopenharmony_ci#define _UAPI_MISC_CXL_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/types.h> 158c2ecf20Sopenharmony_ci#include <linux/ioctl.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistruct cxl_ioctl_start_work { 198c2ecf20Sopenharmony_ci __u64 flags; 208c2ecf20Sopenharmony_ci __u64 work_element_descriptor; 218c2ecf20Sopenharmony_ci __u64 amr; 228c2ecf20Sopenharmony_ci __s16 num_interrupts; 238c2ecf20Sopenharmony_ci __u16 tid; 248c2ecf20Sopenharmony_ci __s32 reserved1; 258c2ecf20Sopenharmony_ci __u64 reserved2; 268c2ecf20Sopenharmony_ci __u64 reserved3; 278c2ecf20Sopenharmony_ci __u64 reserved4; 288c2ecf20Sopenharmony_ci __u64 reserved5; 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define CXL_START_WORK_AMR 0x0000000000000001ULL 328c2ecf20Sopenharmony_ci#define CXL_START_WORK_NUM_IRQS 0x0000000000000002ULL 338c2ecf20Sopenharmony_ci#define CXL_START_WORK_ERR_FF 0x0000000000000004ULL 348c2ecf20Sopenharmony_ci#define CXL_START_WORK_TID 0x0000000000000008ULL 358c2ecf20Sopenharmony_ci#define CXL_START_WORK_ALL (CXL_START_WORK_AMR |\ 368c2ecf20Sopenharmony_ci CXL_START_WORK_NUM_IRQS |\ 378c2ecf20Sopenharmony_ci CXL_START_WORK_ERR_FF |\ 388c2ecf20Sopenharmony_ci CXL_START_WORK_TID) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* Possible modes that an afu can be in */ 428c2ecf20Sopenharmony_ci#define CXL_MODE_DEDICATED 0x1 438c2ecf20Sopenharmony_ci#define CXL_MODE_DIRECTED 0x2 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* possible flags for the cxl_afu_id flags field */ 468c2ecf20Sopenharmony_ci#define CXL_AFUID_FLAG_SLAVE 0x1 /* In directed-mode afu is in slave mode */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistruct cxl_afu_id { 498c2ecf20Sopenharmony_ci __u64 flags; /* One of CXL_AFUID_FLAG_X */ 508c2ecf20Sopenharmony_ci __u32 card_id; 518c2ecf20Sopenharmony_ci __u32 afu_offset; 528c2ecf20Sopenharmony_ci __u32 afu_mode; /* one of the CXL_MODE_X */ 538c2ecf20Sopenharmony_ci __u32 reserved1; 548c2ecf20Sopenharmony_ci __u64 reserved2; 558c2ecf20Sopenharmony_ci __u64 reserved3; 568c2ecf20Sopenharmony_ci __u64 reserved4; 578c2ecf20Sopenharmony_ci __u64 reserved5; 588c2ecf20Sopenharmony_ci __u64 reserved6; 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* base adapter image header is included in the image */ 628c2ecf20Sopenharmony_ci#define CXL_AI_NEED_HEADER 0x0000000000000001ULL 638c2ecf20Sopenharmony_ci#define CXL_AI_ALL CXL_AI_NEED_HEADER 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define CXL_AI_HEADER_SIZE 128 668c2ecf20Sopenharmony_ci#define CXL_AI_BUFFER_SIZE 4096 678c2ecf20Sopenharmony_ci#define CXL_AI_MAX_ENTRIES 256 688c2ecf20Sopenharmony_ci#define CXL_AI_MAX_CHUNK_SIZE (CXL_AI_BUFFER_SIZE * CXL_AI_MAX_ENTRIES) 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistruct cxl_adapter_image { 718c2ecf20Sopenharmony_ci __u64 flags; 728c2ecf20Sopenharmony_ci __u64 data; 738c2ecf20Sopenharmony_ci __u64 len_data; 748c2ecf20Sopenharmony_ci __u64 len_image; 758c2ecf20Sopenharmony_ci __u64 reserved1; 768c2ecf20Sopenharmony_ci __u64 reserved2; 778c2ecf20Sopenharmony_ci __u64 reserved3; 788c2ecf20Sopenharmony_ci __u64 reserved4; 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/* ioctl numbers */ 828c2ecf20Sopenharmony_ci#define CXL_MAGIC 0xCA 838c2ecf20Sopenharmony_ci/* AFU devices */ 848c2ecf20Sopenharmony_ci#define CXL_IOCTL_START_WORK _IOW(CXL_MAGIC, 0x00, struct cxl_ioctl_start_work) 858c2ecf20Sopenharmony_ci#define CXL_IOCTL_GET_PROCESS_ELEMENT _IOR(CXL_MAGIC, 0x01, __u32) 868c2ecf20Sopenharmony_ci#define CXL_IOCTL_GET_AFU_ID _IOR(CXL_MAGIC, 0x02, struct cxl_afu_id) 878c2ecf20Sopenharmony_ci/* adapter devices */ 888c2ecf20Sopenharmony_ci#define CXL_IOCTL_DOWNLOAD_IMAGE _IOW(CXL_MAGIC, 0x0A, struct cxl_adapter_image) 898c2ecf20Sopenharmony_ci#define CXL_IOCTL_VALIDATE_IMAGE _IOW(CXL_MAGIC, 0x0B, struct cxl_adapter_image) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define CXL_READ_MIN_SIZE 0x1000 /* 4K */ 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* Events from read() */ 948c2ecf20Sopenharmony_cienum cxl_event_type { 958c2ecf20Sopenharmony_ci CXL_EVENT_RESERVED = 0, 968c2ecf20Sopenharmony_ci CXL_EVENT_AFU_INTERRUPT = 1, 978c2ecf20Sopenharmony_ci CXL_EVENT_DATA_STORAGE = 2, 988c2ecf20Sopenharmony_ci CXL_EVENT_AFU_ERROR = 3, 998c2ecf20Sopenharmony_ci CXL_EVENT_AFU_DRIVER = 4, 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistruct cxl_event_header { 1038c2ecf20Sopenharmony_ci __u16 type; 1048c2ecf20Sopenharmony_ci __u16 size; 1058c2ecf20Sopenharmony_ci __u16 process_element; 1068c2ecf20Sopenharmony_ci __u16 reserved1; 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistruct cxl_event_afu_interrupt { 1108c2ecf20Sopenharmony_ci __u16 flags; 1118c2ecf20Sopenharmony_ci __u16 irq; /* Raised AFU interrupt number */ 1128c2ecf20Sopenharmony_ci __u32 reserved1; 1138c2ecf20Sopenharmony_ci}; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistruct cxl_event_data_storage { 1168c2ecf20Sopenharmony_ci __u16 flags; 1178c2ecf20Sopenharmony_ci __u16 reserved1; 1188c2ecf20Sopenharmony_ci __u32 reserved2; 1198c2ecf20Sopenharmony_ci __u64 addr; 1208c2ecf20Sopenharmony_ci __u64 dsisr; 1218c2ecf20Sopenharmony_ci __u64 reserved3; 1228c2ecf20Sopenharmony_ci}; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cistruct cxl_event_afu_error { 1258c2ecf20Sopenharmony_ci __u16 flags; 1268c2ecf20Sopenharmony_ci __u16 reserved1; 1278c2ecf20Sopenharmony_ci __u32 reserved2; 1288c2ecf20Sopenharmony_ci __u64 error; 1298c2ecf20Sopenharmony_ci}; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cistruct cxl_event_afu_driver_reserved { 1328c2ecf20Sopenharmony_ci /* 1338c2ecf20Sopenharmony_ci * Defines the buffer passed to the cxl driver by the AFU driver. 1348c2ecf20Sopenharmony_ci * 1358c2ecf20Sopenharmony_ci * This is not ABI since the event header.size passed to the user for 1368c2ecf20Sopenharmony_ci * existing events is set in the read call to sizeof(cxl_event_header) 1378c2ecf20Sopenharmony_ci * + sizeof(whatever event is being dispatched) and the user is already 1388c2ecf20Sopenharmony_ci * required to use a 4K buffer on the read call. 1398c2ecf20Sopenharmony_ci * 1408c2ecf20Sopenharmony_ci * Of course the contents will be ABI, but that's up the AFU driver. 1418c2ecf20Sopenharmony_ci */ 1428c2ecf20Sopenharmony_ci __u32 data_size; 1438c2ecf20Sopenharmony_ci __u8 data[]; 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistruct cxl_event { 1478c2ecf20Sopenharmony_ci struct cxl_event_header header; 1488c2ecf20Sopenharmony_ci union { 1498c2ecf20Sopenharmony_ci struct cxl_event_afu_interrupt irq; 1508c2ecf20Sopenharmony_ci struct cxl_event_data_storage fault; 1518c2ecf20Sopenharmony_ci struct cxl_event_afu_error afu_error; 1528c2ecf20Sopenharmony_ci struct cxl_event_afu_driver_reserved afu_driver_event; 1538c2ecf20Sopenharmony_ci }; 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci#endif /* _UAPI_MISC_CXL_H */ 157