/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* bos72F src/bos/kernel/sys/caccel.h 1.26 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* Restricted Materials of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 2014,2016 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ /* @(#)89 1.26 src/bos/kernel/sys/caccel.h, sysios, bos72F, f2016_28A7 6/29/16 05:05:40 */ /* * This file contains constants, functions, data structures, * etc related to coherent accelerators (CAPI). * * This is a shipped header file. */ #ifndef _H_CACCEL #define _H_CACCEL #ifdef __cplusplus extern "C" { #endif #include #include #include #include #include /* * Commands for the Accelerator Function Unit's (i.e. AFU's) ioctl() * Note - there is an internal command CACCEL_PREIOCTL used only in * kernel mode. Look at its defintion before adding a new command here * to avoid duplication. */ #define CACCEL_ATTACH 0xC0082331 /* _IORW('#',0x31,void *) */ #define CACCEL_MMIO 0xC0082335 /* _IORW('#',0x35,void *) */ #define CACCEL_MAP_MMIO 0xC0082337 /* _IORW('#',0x37,void *) */ #define CACCEL_UNMAP_MMIO 0x80082339 /* _IOW('#',0x39,void *) */ #define CACCEL_QUERY_FUNCTION 0x40082341 /* _IOR('#',0x41,void *) */ #define CACCEL_QUERY_EXCEPTIONS 0x40082345 /* _IOR('#',0x45,void *) */ #define CACCEL_DETACH 0x80082333 /* _IOW('#',0x33,uint64_t) */ #define CACCEL_START_RECOVERY 0x80082347 /* _IOW('#',0x47,uint64_t) */ #define CACCEL_REATTACH 0x80082349 /* _IOW('#',0x49,uint64_t) */ /* Commands for the CAPI Bus' ioctl() */ #define CAPI_DOWNLOAD_IMAGE 0x80082343 /* _IOW('#',0x43,void *) */ #define CAPI_EEH_SIM_IOCTL 0x80082344 /* _IOW('#',0x44,void *) */ /* * ============================ IMPORTANT ====================== * All structures should be bzero'ed before setting * 'eyecatcher' and 'version'. Do not reference 'reserved' fields * in them as they may be renamed any time in future. * ============================================================= */ /* Structure and defines for CACCEL_ATTACH */ /* Changes here must be reflected in struct caccel_attach_uinfo32 also */ #define CACCEL_ATTACH_UINFO_VER0 0x1 #define CACCEL_ATTACH_UINFO_VER CACCEL_ATTACH_UINFO_VER0 #define CACCEL_UATT_EYEC_VALID 0x55415456 /* "UATV" */ #define CACCEL_UATT_EYEC_INVALID 0x55415449 /* "UATI" */ /* * Default value for user AMR */ #define CACCEL_UAMR_DEFAULT 0 struct caccel_attach_uinfo { /* Input arguments */ /* The eyecatcher and version must be the first 2 * fields */ int eyecatcher; int version; boolean_t sig_on_error; /* Notify application on errors including bad page faults via SIGCAPI and/or poll/select()*/ boolean_t sig_on_event; /* Notify application on all events (error and non error) via SIGCAPI and/or poll/select()*/ int excp_qdepth; /* Queue depth of exceptions (min. is 1) */ int reserved0; void *wed; /* Work element descriptor pointer */ size_t wed_size; /* Size of WED in bytes */ void *csrp; /* Context save/restore area pointer (4K aligned) */ size_t csrp_size; /* Size of CSRP in 4K pages */ ukeyset_t amr; /* Authority Mask Register for the data areas * that AFU can access */ boolean_t master; /* 1 if master process, 0 if not */ int reserved1[5]; /* Output arguments */ uint64_t openid; /* Opaque id identifying the device open */ uint64_t token; /* Opaque token identifying this context */ uint64_t mmio_addr; /* Starting address of the user-space MMIO range per process context */ size_t mmio_len; /* Length in bytes of the user-space MMIO range per process context */ int reserved2[4]; }; enum caccel_excp_type { CACCEL_INV_EXCP = 0, /* Invalid exception type (must be first) */ CACCEL_UNKNOWN_EXCP, /* Unknown exception type */ CACCEL_BAD_PF, /* Bad page fault on read (load) */ CACCEL_PF, /* Page fault that was resolved */ CACCEL_AFU_EVENT, /* AFU specific event */ CACCEL_EEH_EVENT, /* EEH event */ CACCEL_AFU_ERROR, /* AFU error */ CACCEL_EXCP_RESERVED0, CACCEL_EXCP_RESERVED1, CACCEL_EXCP_RESERVED2, CACCEL_MAX_EXCP /* This must be last */ }; /* Only valid if caccel_excp_type is CACCEL_PF */ enum caccel_pf_type { CACCEL_INV_PF = 0, /* Invalid page fault type (must be first) */ CACCEL_UNKNOWN_PF, /* Unknown page fault type */ CACCEL_NO_PF, /* Not a page fault */ CACCEL_READ_PF, /* Read (load) page fault */ CACCEL_WRITE_PF, /* Write (store) page fault */ CACCEL_XLATER_PF, /* Missing page table entry fault on read (load) */ CACCEL_XLATEW_PF, /* Missing page table entry fault on write (store)*/ CACCEL_PROTR_PF, /* Protection fault on read (load) */ CACCEL_PROTW_PF, /* Protection fault on write (store) */ CACCEL_HKEYR_PF, /* Storage key fault on read (load) */ CACCEL_HKEYW_PF, /* Storage key fault on write (store) */ CACCEL_READ_SF, /* Segment Table fault on read (load) */ CACCEL_WRITE_SF, /* Segment Table fault on write (store) */ CACCEL_PF_RESERVED0, CACCEL_PF_RESERVED1, CACCEL_PF_RESERVED2, CACCEL_PF_RESERVED3, CACCEL_MAX_PF, /* This must be last */ }; /* Structure and defines for CACCEL_QUERY_EXCEPTIONS */ #define CACCEL_QE_INFO_VER0 0x1 #define CACCEL_QE_INFO_VER CACCEL_QE_INFO_VER0 #define CACCEL_QEX_EYEC_VALID 0x51455856 /* "QEXV" */ #define CACCEL_QEX_EYEC_INVALID 0x51455849 /* "QEXI" */ struct caccel_exception_info { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; int reserved0[2]; /* Output arguments */ uint64_t token; /* Context that has this exception */ uint64_t openid; /* openid that has this exception */ enum caccel_excp_type exception_type; /* page fault, error, etc */ enum caccel_pf_type pf_type; /* type of page fault. Only valid for page faults, 0 otherwise */ int exception_source; /* Interrupt source: 1 is always page fault or errors, 2-N are AFU specific */ int reserved1; uint64_t timestamp; /* Timestamp of when the exception arrived. This value is unique and monotonically increasing. */ uint64_t event_info; /* Event info */ int reserved2[4]; }; /* Structure and defines for CACCEL_QUERY_EXCEPTIONS */ #define CACCEL_QE_VEC_VER0 0x1 #define CACCEL_QE_VEC_VER CACCEL_QE_VEC_VER0 #define CACCEL_QEV_EYEC_VALID 0x51455656 /* "QEVV" */ #define CACCEL_QEV_EYEC_INVALID 0x51455649 /* "QEVI" */ struct caccel_exception_vector { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; uint64_t token; /* Token returned on a previous CACCEL_ATTACH. 0 if requesting all exceptions */ uint64_t openid; /* Openid returned a previous CACCEL_ATTACH. 0 if requesting all exceptions */ struct caccel_exception_info *buff; /* buffer for exceptions */ size_t buff_size; /* size of exceptions buffer in bytes */ int reserved0[2]; /* Output arguments */ int return_count; /* Number of structures returned */ int resid_count; /* Count of exceptions still pending */ int reserved1[2]; }; /* Structure and defines for CACCEL_MMIO */ #define CACCEL_MMIO_INFO_VER0 0x1 #define CACCEL_MMIO_INFO_VER CACCEL_MMIO_INFO_VER0 #define CACCEL_MMIO_EYEC_VALID 0x50494F56 /* "PIOV" */ #define CACCEL_MMIO_EYEC_INVALID 0x50494F49 /* "PIOI" */ /* Direction of MMIO */ #define CACCEL_MMIO_READ 0x1 #define CACCEL_MMIO_WRITE 0x2 /* Length of MMIO */ #define CACCEL_MMIO_1B 0x1 #define CACCEL_MMIO_2B 0x2 #define CACCEL_MMIO_4B 0x4 #define CACCEL_MMIO_8B 0x8 struct caccel_mmio_info { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; int direction; /* Direction of MMIO */ int reserved0; uint64_t token; /* Opaque cookie from a previous CACCEL_ATTACH */ uint64_t addr; /* MMIO address */ size_t len; /* Length of MMIO: 1, 2, 4, or 8 bytes */ /* Input if CA_MMIO_WRITE, output if CA_MMIO_READ */ unsigned long long val; /* value to be written or was read*/ }; /* Structure and defines for CACCEL_MAP_MMIO and CACCEL_UNMAP_MMIO */ #define CACCEL_MAP_INFO_VER0 0x1 #define CACCEL_MAP_INFO_VER CACCEL_MAP_INFO_VER0 #define CACCEL_MAP_EYEC_VALID 0x4D415056 /* "MAPV" */ #define CACCEL_MAP_EYEC_INVALID 0x4D415049 /* "MAPI" */ struct caccel_map_info { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; uint64_t token; /* Opaque cookie from a previous CACCEL_ATTACH */ uint64_t addr; /* MMIO address */ size_t len; /* Length of the MMIO region */ boolean_t read_only; /* 1 if mapping should be read-only, 0 for read/write */ boolean_t sgsafe; /* 1 if scatter-gather safe, 0 otherwise */ int reserved0[4]; /* Output arguments */ void *eaddr; /* Full effective address in user space. If * 0, system will pick an address. If * non-zero, system will attempt to map * at the specified address. */ int reserved1[2]; }; /* Structure and defines for CACCEL_QUERY_FUNCTION */ #define CACCEL_QUERY_FUNCTION_VER0 0x1 #define CACCEL_QUERY_FUNCTION_VER CACCEL_QUERY_FUNCTION_VER0 #define CACCEL_QFN_EYEC_VALID 0x51464E56 /* "QFNV" */ #define CACCEL_QFN_EYEC_INVALID 0x51464E49 /* "QFNI" */ struct caccel_function_data { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; dev_t devno; /* Major/minor number of the AFU */ uint config_rec_start; uint config_rec_count; uint vpd_num; void *config_recs; /* Pointer to the buffer for the configuration records */ size_t config_rec_len; /* Length of the config_recs buffer in bytes */ size_t len_per_rec; /* Length in bytes per config record */ void *vpd; /* Pointer to the buffer for the VPD */ size_t vpd_len; /* Length of the VPD buffer in bytes */ int reserved1[2]; /* Output arguments */ size_t vpd_len_actual; /* Actual byte size of the VPD returned */ }; /* Structure and defines for CACCEL_DOWNLOAD_FULLIMAGE and * CACCEL_DOWNLOAD_PARTIMAGE */ #define CACCEL_IMAGE_INFO_VER0 0x1 #define CACCEL_IMAGE_INFO_VER CACCEL_IMAGE_INFO_VER0 #define CACCEL_IMGINFO_EYEC_VALID 0x494D4756 /* "IMGV" */ #define CACCEL_IMGINFO_EYEC_INVALID 0x494D4749 /* "IMGI" */ struct caccel_image_info { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; void *image; /* Pointer to the buffer containing the image stream */ size_t len; /* Length of the bit-stream in bytes */ int reserved0[2]; /* Output arguments */ int reserved1[2]; }; #ifdef _KERNEL /* * Used internally for preioctl notification. * The preioctl command will be called before every ioctl call on a * CAPI DD. The caccel_preioctl_arg will contain the parameters of * the actual ioctl call following it. */ #define CACCEL_PREIOCTL 0x80082351 #define CACCEL_PREIOCTL_ARG_VER0 0x1 #define CACCEL_PREIOCTL_ARG_VER CACCEL_PREIOCTL_ARG_VER0 struct caccel_preioctl_arg { int version; struct file *fp; unsigned long cmd; caddr_t arg; ext_t ext; unsigned long flags; int reserved[4]; }; /* * 32-bit process will pass the following structure * size_t, void *, etc are mapped to 32-bit types. */ struct caccel_attach_uinfo32 { /* Input arguments */ /* The eyecatcher and version must be the first 2 * fields */ int eyecatcher; int version; uint sig_on_error; /* Send SIGCAPI on errors including bad page faults */ uint sig_on_event; /* Send SIGCAPI on all events (error and non error) */ int excp_qdepth; /* Queue depth of exceptions (min. is 1) */ int reserved0; uint wed; /* Work element descriptor pointer */ int wed_size; /* Size of WED in bytes */ uint csrp; /* Context save/restore area pointer (4K aligned) */ int csrp_size; /* Size of CSRP in 4K pages */ ukeyset_t amr; /* Authority Mask Register for the data areas * that AFU can access */ uint master; /* 1 if master process, 0 if not */ int reserved1[5]; /* Output arguments */ uint64_t openid; /* Opaque id identifying the device open */ uint64_t token; /* Opaque token identifying this context */ uint64_t mmio_addr; /* Starting address of the user-space MMIO range per process context */ int mmio_len; /* Length in bytes of the user-space MMIO range per process context */ int reserved2[4]; }; struct caccel_exception_vector32 { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; uint64_t token; /* Token returned on a previous CACCEL_ATTACH. 0 if requesting all exceptions */ uint64_t openid; /* Openid returned a previous CACCEL_ATTACH. 0 if requesting all exceptions */ unsigned int buff; /* buffer for exceptions */ int buff_size; /* size of exceptions buffer in bytes */ int reserved0[2]; /* Output arguments */ int return_count; /* Number of structures returned */ int resid_count; /* Count of exceptions still pending */ int reserved1[2]; }; struct caccel_map_info32 { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; uint64_t token; /* Opaque cookie from a previous CACCEL_ATTACH */ uint64_t addr; /* MMIO address */ int len; /* Length of MMIO: 1, 2, 4, or 8 bytes */ uint read_only; /* 1 if mapping should be read-only, 0 for read/write */ uint sgsafe; /* 1 if scatter-gather safe, 0 otherwise */ int reserved0[4]; /* Output arguments */ uint eaddr; /* Full effective address in user space */ int reserved1[2]; }; struct caccel_mmio_info32 { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; int direction; /* Direction of MMIO */ int reserved0; uint64_t token; /* Opaque cookie from a previous CACCEL_ATTACH */ uint64_t addr; /* MMIO address */ int len; /* Length of MMIO: 1, 2, 4, or 8 bytes */ int reserved1; /* Input if CA_MMIO_WRITE, output if CA_MMIO_READ */ unsigned long long val; /* value to be written or was read*/ }; struct caccel_function_data32 { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; uint devno; /* Major/minor number of the AFU */ uint config_rec_start; uint config_rec_count; uint vpd_num; uint config_recs; /* Pointer to the buffer for the configuration records */ int config_rec_len; /* Length of the config_recs buffer in bytes */ int len_per_rec; /* Length in bytes per config record */ uint vpd; /* Pointer to the buffer for the VPD */ int vpd_len; /* Length of the VPD buffer in bytes */ int reserved1[2]; /* Output arguments */ int vpd_len_actual; /* Actual byte size of the VPD returned */ }; /* * Interrupt info needed from the CAPI devices while attaching a * user or kernel context. */ struct caccel_isn_info { /* Input arguments */ int isn; /* Interrupt source number */ boolean_t register_it; /* 1: Register this ISN via i_init() * 0: Do not call i_init() for this ISN */ int pad[2]; }; /* Internal structure between the AFU driver and the kernel. * The structure and the "isn_list" must be in storage with KKEY_PUBLIC key. */ #define CACCEL_ATTACH_INFO_VER0 0x1 #define CACCEL_ATTACH_INFO_VER CACCEL_ATTACH_INFO_VER0 struct caccel_attach_info { /* Input arguments */ int version; int num_of_interrupts; /* Number of interrupts in isn_list */ dev_t devno; /* Major/minor number of the AFU */ struct caccel_isn_info *isn_list; /* List of interrupt source numbers */ struct caccel_attach_uinfo uinfo; /* This must be the first field */ int channel; /* Channel number if MPX device. -1 otherwise */ int reserved0; long reserved[4]; }; /* Structure and defines for kernel contexts */ #define CACCEL_ATTACH_KINFO_VER0 0x1 #define CACCEL_ATTACH_KINFO_VER CACCEL_ATTACH_KINFO_VER0 #define CACCEL_KATT_EYEC_VALID 0x4B415456 /* "KATV" */ #define CACCEL_KATT_EYEC_INVALID 0x4B415449 /* "KATI" */ struct caccel_attach_kinfo { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; dev_t devno; /* major/minor number of the AFU device */ int excp_qdepth; /* Queue depth of exceptions (min. is 1) */ boolean_t master; /* 1 if master process, 0 if not */ boolean_t call_tlih_on_event; /* Call TLIH on every event */ int num_of_interrupts; /* Number of interrupts in isn_list */ struct caccel_isn_info *isn_list; /* List of interrupt source numbers */ void *stab; /* segment table pointer */ size_t stab_size; /* segment table's size in bytes */ void *wed; /* Work element descriptor pointer */ size_t wed_size; /* Size of WED in bytes */ void *csrp; /* Context save/restore area pointer (4K aligned) */ size_t csrp_size; /* Size of CSRP in 4K pages */ int pad; int tlih_prio; /* Priority at which tlih is called */ int (*tlih)(void *acs, struct caccel_exception_info *info, unsigned long flags); /* Third level interrupt handler to be invoked on bad page fault, etc */ void *acs; /* Adapter structure to be passed back to tlih() */ long reserved1[2]; /* Output arguments */ uint64_t token; /* Opaque token identifying this context */ uint64_t mmio_addr; /* Starting address of the user-space MMIO range per process context */ size_t mmio_len; /* Length in bytes of the user-space MMIO range per process context */ pid_t pid; /* Process ID tied to this kernel context */ long reserved2[2]; }; /* * Structure and defines for caccel_init_afu() service */ #define CACCEL_INIT_AFU_VER0 0x1 #define CACCEL_INIT_AFU_VER CACCEL_INIT_AFU_VER0 struct caccel_afu_info { int version; int bid; /* AIX Bus ID of AFU's parent CAPI bus */ dev_t bus_devno; /* major/minor number of the parent CAPI bus */ dev_t devno; /* major/minor number of the AFU device */ uint64_t unit_address; /* Opaque cookie identifying an AFU */ boolean_t has_aurp; /* 1 if AURP is supported, 0 otherwise */ boolean_t has_csrp; /* 1 if CSRP is supported, 0 otherwise */ uint64_t p2addr; /* Base address of the Priviledged 2 MMIO space */ size_t p2size; /* Length of the Priviledged 2 MMIO space in bytes */ int start_isn; /* First ISN for this AFU device */ boolean_t has_prr; /* 1 if Paged Response Register is implemented, * 0 otherwise */ int reserved0[6]; /* Must be set to 0 */ }; struct caccel_image_info32 { /* Input arguments */ /* The eyecatcher and version must be the first two fields */ int eyecatcher; int version; uint image; /* Pointer to the buffer containing the image stream */ int len; /* Length of the bit-stream in bytes */ int reserved0[2]; /* Output arguments */ int reserved1[2]; }; /* Convert a 'caccel_attach_uinfo.openid' into a channel for select()/poll() */ #define CACCEL_OPENID2CHAN(x) ((int)((x) >> 8)) /* Flags for the kernel services */ /* Do not use flag value 0x1 */ #define CACCEL_DKERNEL 0x010 /* struct in kernel memory */ #define CACCEL_NOACC 0x020 /* Don't access the AFU */ #define CACCEL_PRECLOSE 0x040 /* special kernel flag */ #define CACCEL_EXEC_EVENT 0x080 /* Exec event for AFU driver */ kerrno_t caccel_init_bus(dev_t, uint64_t, int); kerrno_t caccel_clear_bus(dev_t); kerrno_t caccel_init_afu(struct caccel_afu_info *); kerrno_t caccel_clear_afu(dev_t, unsigned long); kerrno_t caccel_attach_uctx(struct caccel_attach_info *); kerrno_t caccel_detach(dev_t, uint64_t, unsigned long); kerrno_t caccel_query_exceptions(dev_t, uint64_t, struct caccel_exception_info *, int *, unsigned long); kerrno_t caccel_mmio(dev_t, struct caccel_mmio_info *, unsigned long); kerrno_t caccel_map_mmio(dev_t, struct caccel_map_info *, unsigned long); kerrno_t caccel_unmap_mmio(dev_t, struct caccel_map_info *, unsigned long); kerrno_t caccel_count_exceptions(dev_t, uint64_t, int *, unsigned long); kerrno_t caccel_query_function(struct caccel_function_data *, unsigned long); kerrno_t caccel_ack_error(dev_t, uint64_t, unsigned long); kerrno_t caccel_get_error(dev_t, uint64_t *, unsigned long); kerrno_t caccel_attach_kctx(struct caccel_attach_kinfo *); kerrno_t caccel_slot_reset(uint64_t, uint64_t); kerrno_t caccel_capify(dev_t, unsigned long); kerrno_t caccel_download_fullimage(dev_t, struct caccel_image_info*, unsigned long); kerrno_t caccel_purge_ctx(dev_t, unsigned long); kerrno_t caccel_reset_afu(dev_t, unsigned long); kerrno_t caccel_reattach_kctx(struct caccel_attach_kinfo*, unsigned long); kerrno_t caccel_reinit_intr(struct intr *); void bsterile(void *, size_t); /* kernel service */ #endif /* _KERNEL */ /* Library (libc) routines */ void __bsterile(void *, size_t); #ifdef __cplusplus } #endif #endif /* _H_CACCEL */