linux/include/uapi/misc/cxl.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
   2/*
   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
  17
  18struct cxl_ioctl_start_work {
  19        __u64 flags;
  20        __u64 work_element_descriptor;
  21        __u64 amr;
  22        __s16 num_interrupts;
  23        __s16 reserved1;
  24        __s32 reserved2;
  25        __u64 reserved3;
  26        __u64 reserved4;
  27        __u64 reserved5;
  28        __u64 reserved6;
  29};
  30
  31#define CXL_START_WORK_AMR              0x0000000000000001ULL
  32#define CXL_START_WORK_NUM_IRQS         0x0000000000000002ULL
  33#define CXL_START_WORK_ERR_FF           0x0000000000000004ULL
  34#define CXL_START_WORK_ALL              (CXL_START_WORK_AMR |\
  35                                         CXL_START_WORK_NUM_IRQS |\
  36                                         CXL_START_WORK_ERR_FF)
  37
  38
  39/* Possible modes that an afu can be in */
  40#define CXL_MODE_DEDICATED   0x1
  41#define CXL_MODE_DIRECTED    0x2
  42
  43/* possible flags for the cxl_afu_id flags field */
  44#define CXL_AFUID_FLAG_SLAVE    0x1  /* In directed-mode afu is in slave mode */
  45
  46struct cxl_afu_id {
  47        __u64 flags;     /* One of CXL_AFUID_FLAG_X */
  48        __u32 card_id;
  49        __u32 afu_offset;
  50        __u32 afu_mode;  /* one of the CXL_MODE_X */
  51        __u32 reserved1;
  52        __u64 reserved2;
  53        __u64 reserved3;
  54        __u64 reserved4;
  55        __u64 reserved5;
  56        __u64 reserved6;
  57};
  58
  59/* base adapter image header is included in the image */
  60#define CXL_AI_NEED_HEADER      0x0000000000000001ULL
  61#define CXL_AI_ALL              CXL_AI_NEED_HEADER
  62
  63#define CXL_AI_HEADER_SIZE 128
  64#define CXL_AI_BUFFER_SIZE 4096
  65#define CXL_AI_MAX_ENTRIES 256
  66#define CXL_AI_MAX_CHUNK_SIZE (CXL_AI_BUFFER_SIZE * CXL_AI_MAX_ENTRIES)
  67
  68struct cxl_adapter_image {
  69        __u64 flags;
  70        __u64 data;
  71        __u64 len_data;
  72        __u64 len_image;
  73        __u64 reserved1;
  74        __u64 reserved2;
  75        __u64 reserved3;
  76        __u64 reserved4;
  77};
  78
  79/* ioctl numbers */
  80#define CXL_MAGIC 0xCA
  81/* AFU devices */
  82#define CXL_IOCTL_START_WORK            _IOW(CXL_MAGIC, 0x00, struct cxl_ioctl_start_work)
  83#define CXL_IOCTL_GET_PROCESS_ELEMENT   _IOR(CXL_MAGIC, 0x01, __u32)
  84#define CXL_IOCTL_GET_AFU_ID            _IOR(CXL_MAGIC, 0x02, struct cxl_afu_id)
  85/* adapter devices */
  86#define CXL_IOCTL_DOWNLOAD_IMAGE        _IOW(CXL_MAGIC, 0x0A, struct cxl_adapter_image)
  87#define CXL_IOCTL_VALIDATE_IMAGE        _IOW(CXL_MAGIC, 0x0B, struct cxl_adapter_image)
  88
  89#define CXL_READ_MIN_SIZE 0x1000 /* 4K */
  90
  91/* Events from read() */
  92enum cxl_event_type {
  93        CXL_EVENT_RESERVED      = 0,
  94        CXL_EVENT_AFU_INTERRUPT = 1,
  95        CXL_EVENT_DATA_STORAGE  = 2,
  96        CXL_EVENT_AFU_ERROR     = 3,
  97        CXL_EVENT_AFU_DRIVER    = 4,
  98};
  99
 100struct cxl_event_header {
 101        __u16 type;
 102        __u16 size;
 103        __u16 process_element;
 104        __u16 reserved1;
 105};
 106
 107struct cxl_event_afu_interrupt {
 108        __u16 flags;
 109        __u16 irq; /* Raised AFU interrupt number */
 110        __u32 reserved1;
 111};
 112
 113struct cxl_event_data_storage {
 114        __u16 flags;
 115        __u16 reserved1;
 116        __u32 reserved2;
 117        __u64 addr;
 118        __u64 dsisr;
 119        __u64 reserved3;
 120};
 121
 122struct cxl_event_afu_error {
 123        __u16 flags;
 124        __u16 reserved1;
 125        __u32 reserved2;
 126        __u64 error;
 127};
 128
 129struct cxl_event_afu_driver_reserved {
 130        /*
 131         * Defines the buffer passed to the cxl driver by the AFU driver.
 132         *
 133         * This is not ABI since the event header.size passed to the user for
 134         * existing events is set in the read call to sizeof(cxl_event_header)
 135         * + sizeof(whatever event is being dispatched) and the user is already
 136         * required to use a 4K buffer on the read call.
 137         *
 138         * Of course the contents will be ABI, but that's up the AFU driver.
 139         */
 140        __u32 data_size;
 141        __u8 data[];
 142};
 143
 144struct cxl_event {
 145        struct cxl_event_header header;
 146        union {
 147                struct cxl_event_afu_interrupt irq;
 148                struct cxl_event_data_storage fault;
 149                struct cxl_event_afu_error afu_error;
 150                struct cxl_event_afu_driver_reserved afu_driver_event;
 151        };
 152};
 153
 154#endif /* _UAPI_MISC_CXL_H */
 155