Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  * Copyright 2014 IBM Corp.
0004  *
0005  * This program is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU General Public License
0007  * as published by the Free Software Foundation; either version
0008  * 2 of the License, or (at your option) any later version.
0009  */
0010 
0011 #ifndef _UAPI_MISC_CXL_H
0012 #define _UAPI_MISC_CXL_H
0013 
0014 #include <linux/types.h>
0015 #include <linux/ioctl.h>
0016 
0017 
0018 struct cxl_ioctl_start_work {
0019     __u64 flags;
0020     __u64 work_element_descriptor;
0021     __u64 amr;
0022     __s16 num_interrupts;
0023     __u16 tid;
0024     __s32 reserved1;
0025     __u64 reserved2;
0026     __u64 reserved3;
0027     __u64 reserved4;
0028     __u64 reserved5;
0029 };
0030 
0031 #define CXL_START_WORK_AMR      0x0000000000000001ULL
0032 #define CXL_START_WORK_NUM_IRQS     0x0000000000000002ULL
0033 #define CXL_START_WORK_ERR_FF       0x0000000000000004ULL
0034 #define CXL_START_WORK_TID      0x0000000000000008ULL
0035 #define CXL_START_WORK_ALL      (CXL_START_WORK_AMR |\
0036                      CXL_START_WORK_NUM_IRQS |\
0037                      CXL_START_WORK_ERR_FF |\
0038                      CXL_START_WORK_TID)
0039 
0040 
0041 /* Possible modes that an afu can be in */
0042 #define CXL_MODE_DEDICATED   0x1
0043 #define CXL_MODE_DIRECTED    0x2
0044 
0045 /* possible flags for the cxl_afu_id flags field */
0046 #define CXL_AFUID_FLAG_SLAVE    0x1  /* In directed-mode afu is in slave mode */
0047 
0048 struct cxl_afu_id {
0049     __u64 flags;     /* One of CXL_AFUID_FLAG_X */
0050     __u32 card_id;
0051     __u32 afu_offset;
0052     __u32 afu_mode;  /* one of the CXL_MODE_X */
0053     __u32 reserved1;
0054     __u64 reserved2;
0055     __u64 reserved3;
0056     __u64 reserved4;
0057     __u64 reserved5;
0058     __u64 reserved6;
0059 };
0060 
0061 /* base adapter image header is included in the image */
0062 #define CXL_AI_NEED_HEADER  0x0000000000000001ULL
0063 #define CXL_AI_ALL      CXL_AI_NEED_HEADER
0064 
0065 #define CXL_AI_HEADER_SIZE 128
0066 #define CXL_AI_BUFFER_SIZE 4096
0067 #define CXL_AI_MAX_ENTRIES 256
0068 #define CXL_AI_MAX_CHUNK_SIZE (CXL_AI_BUFFER_SIZE * CXL_AI_MAX_ENTRIES)
0069 
0070 struct cxl_adapter_image {
0071     __u64 flags;
0072     __u64 data;
0073     __u64 len_data;
0074     __u64 len_image;
0075     __u64 reserved1;
0076     __u64 reserved2;
0077     __u64 reserved3;
0078     __u64 reserved4;
0079 };
0080 
0081 /* ioctl numbers */
0082 #define CXL_MAGIC 0xCA
0083 /* AFU devices */
0084 #define CXL_IOCTL_START_WORK        _IOW(CXL_MAGIC, 0x00, struct cxl_ioctl_start_work)
0085 #define CXL_IOCTL_GET_PROCESS_ELEMENT   _IOR(CXL_MAGIC, 0x01, __u32)
0086 #define CXL_IOCTL_GET_AFU_ID            _IOR(CXL_MAGIC, 0x02, struct cxl_afu_id)
0087 /* adapter devices */
0088 #define CXL_IOCTL_DOWNLOAD_IMAGE        _IOW(CXL_MAGIC, 0x0A, struct cxl_adapter_image)
0089 #define CXL_IOCTL_VALIDATE_IMAGE        _IOW(CXL_MAGIC, 0x0B, struct cxl_adapter_image)
0090 
0091 #define CXL_READ_MIN_SIZE 0x1000 /* 4K */
0092 
0093 /* Events from read() */
0094 enum cxl_event_type {
0095     CXL_EVENT_RESERVED      = 0,
0096     CXL_EVENT_AFU_INTERRUPT = 1,
0097     CXL_EVENT_DATA_STORAGE  = 2,
0098     CXL_EVENT_AFU_ERROR     = 3,
0099     CXL_EVENT_AFU_DRIVER    = 4,
0100 };
0101 
0102 struct cxl_event_header {
0103     __u16 type;
0104     __u16 size;
0105     __u16 process_element;
0106     __u16 reserved1;
0107 };
0108 
0109 struct cxl_event_afu_interrupt {
0110     __u16 flags;
0111     __u16 irq; /* Raised AFU interrupt number */
0112     __u32 reserved1;
0113 };
0114 
0115 struct cxl_event_data_storage {
0116     __u16 flags;
0117     __u16 reserved1;
0118     __u32 reserved2;
0119     __u64 addr;
0120     __u64 dsisr;
0121     __u64 reserved3;
0122 };
0123 
0124 struct cxl_event_afu_error {
0125     __u16 flags;
0126     __u16 reserved1;
0127     __u32 reserved2;
0128     __u64 error;
0129 };
0130 
0131 struct cxl_event_afu_driver_reserved {
0132     /*
0133      * Defines the buffer passed to the cxl driver by the AFU driver.
0134      *
0135      * This is not ABI since the event header.size passed to the user for
0136      * existing events is set in the read call to sizeof(cxl_event_header)
0137      * + sizeof(whatever event is being dispatched) and the user is already
0138      * required to use a 4K buffer on the read call.
0139      *
0140      * Of course the contents will be ABI, but that's up the AFU driver.
0141      */
0142     __u32 data_size;
0143     __u8 data[];
0144 };
0145 
0146 struct cxl_event {
0147     struct cxl_event_header header;
0148     union {
0149         struct cxl_event_afu_interrupt irq;
0150         struct cxl_event_data_storage fault;
0151         struct cxl_event_afu_error afu_error;
0152         struct cxl_event_afu_driver_reserved afu_driver_event;
0153     };
0154 };
0155 
0156 #endif /* _UAPI_MISC_CXL_H */