31 #include <sys/select.h> 39 #define OCXL_NO_MESSAGES 0 40 #define OCXL_ERRORS (1 << 0) 41 #define OCXL_TRACING (1 << 1) 61 #define AFU_NAME_MAX 24 66 typedef struct ocxl_identifier { 76 #define OCXL_INVALID_AFU NULL 81 typedef uint16_t ocxl_irq_h; 138 #if defined(LIBOCXL_LIVE_DANGEROUSLY) 139 #define LIBOCXL_WARN_UNUSED 140 #elif defined(__clang__) && __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ <= 8 141 #define LIBOCXL_WARN_UNUSED 143 #define LIBOCXL_WARN_UNUSED __attribute__ ((warn_unused_result)) 159 uint64_t padding[16];
163 #define OCXL_ATTACH_FLAGS_NONE (0) 169 const char *
ocxl_info() LIBOCXL_WARN_UNUSED;
186 const
char *message));
197 uint16_t event_api_version) LIBOCXL_WARN_UNUSED;
207 #if defined(_ARCH_PPC64) && !defined(__STRICT_ANSI__) 240 asm volatile (
".long 0x7c00003c");
242 #elif defined(_ARCH_PPC64) && !defined(LIBOCXL_SUPPRESS_INACCESSIBLE_WARNINGS) 243 #warning LibOCXL ocxl_wait() will not be available while ANSI C mode is enabled 271 uint16_t event_api_version = 0;
286 off_t offset,
ocxl_mmio_h *region) LIBOCXL_WARN_UNUSED;
const char * ocxl_err_to_string(ocxl_err err)
Convert an error value to a string.
AFU data is little-endian.
void ocxl_wait()
A wrapper around the the POWER9 wait instruction.
ocxl_err ocxl_afu_set_ppc64_amr(ocxl_afu_h afu, uint64_t amr)
Set the PPC64-specific PSL AMR register value for restricting access to the AFU.
ocxl_err ocxl_mmio_map_advanced(ocxl_afu_h afu, ocxl_mmio_type type, size_t size, int prot, uint64_t flags, off_t offset, ocxl_mmio_h *region)
Map an MMIO area of an AFU.
ocxl_err ocxl_mmio_read32(ocxl_mmio_h mmio, off_t offset, ocxl_endian endian, uint32_t *out)
Read a 32-bit value from an AFU's MMIO region & convert endianness.
void * info
An opaque pointer associated with the IRQ.
ocxl_err ocxl_mmio_get_info(ocxl_mmio_h region, void **address, size_t *size)
Get the address & size of a mapped MMIO region.
int ocxl_irq_get_fd(ocxl_afu_h afu, ocxl_irq_h irq)
Get the file descriptor associated with an IRQ.
#define AFU_NAME_MAX
The maximum length of an AFU name.
const ocxl_identifier * ocxl_afu_get_identifier(ocxl_afu_h afu)
Get the identifier of the AFU.
int ocxl_afu_get_event_fd(ocxl_afu_h afu)
Get a descriptor that will trigger a poll when an AFU event occurs.
ocxl_err
Potential return values from ocxl_* functions.
size_t ocxl_mmio_size(ocxl_afu_h afu, ocxl_mmio_type type)
Get the size of an MMIO region for an AFU.
void ocxl_set_error_message_handler(void(*handler)(ocxl_err error, const char *message))
Override the default handler for emitting error messages from open calls.
uint16_t ocxl_irq_h
A handle for an IRQ on an AFU.
The action requested falls outside the permitted area.
The call requires an open context on the AFU.
ocxl_err ocxl_mmio_read64(ocxl_mmio_h mmio, off_t offset, ocxl_endian endian, uint64_t *out)
Read a 64-bit value from an AFU's MMIO region & convert endianness.
void * addr
The address that triggered the fault.
void ocxl_mmio_unmap(ocxl_mmio_h region)
Unmap an MMIO region from an AFU.
uint32_t ocxl_afu_get_pasid(ocxl_afu_h afu)
Get the PASID for the currently open context.
ocxl_err ocxl_mmio_map(ocxl_afu_h afu, ocxl_mmio_type type, ocxl_mmio_h *region)
Map an MMIO area of an AFU.
One or more arguments are invalid.
ocxl_err ocxl_afu_get_p9_thread_id(ocxl_afu_h afu, uint16_t *thread_id)
Get the thread ID required to wake up a Power 9 wait instruction.
an internal error has occurred
uint8_t afu_index
The AFU Index.
ocxl_err ocxl_irq_alloc(ocxl_afu_h afu, void *info, ocxl_irq_h *irq_handle)
Allocate an IRQ for an open AFU.
ocxl_err ocxl_afu_open(const char *name, ocxl_afu_h *afu)
Open an AFU context with a specified name.
ocxl_endian
Defines the endianness of an AFU MMIO area.
uint64_t handle
The 64 bit handle of the triggered IRQ.
const char * ocxl_afu_get_device_path(ocxl_afu_h afu)
Get the canonical device path of the AFU.
The OpenCAPI device is not available.
The data for a triggered IRQ event.
A memory translation fault occurred on the AFU.
uint64_t dsisr
The value of the PPC64 specific DSISR (Data storage interrupt status register)
void ocxl_afu_enable_messages(ocxl_afu_h afu, uint64_t sources)
Enable messages from an AFU.
AFU identification information.
ocxl_err ocxl_afu_open_from_dev(const char *path, ocxl_afu_h *afu)
Open an AFU context at a specified path.
const char * ocxl_info()
Get version & compilation information about LibOCXL.
void ocxl_enable_messages(uint64_t sources)
Enable messages from libocxl open calls.
void ocxl_afu_get_version(ocxl_afu_h afu, uint8_t *major, uint8_t *minor)
Get the version of the AFU.
const char * ocxl_afu_get_sysfs_path(ocxl_afu_h afu)
Get the canonical sysfs path of the AFU.
no further interrupts are available, or the interrupt is invalid
uint64_t ocxl_irq_get_handle(ocxl_afu_h afu, ocxl_irq_h irq)
Get the 64 bit IRQ handle for an IRQ.
ocxl_mmio_type
Defines the type of an MMIO area.
ocxl_err ocxl_afu_close(ocxl_afu_h afu)
Close an AFU and detach it from the context.
ocxl_err ocxl_mmio_write32(ocxl_mmio_h mmio, off_t offset, ocxl_endian endian, uint32_t value)
Convert endianness and write a 32-bit value to an AFU's MMIO region.
struct ocxl_afu * ocxl_afu_h
A handle for an AFU.
int ocxl_afu_event_check(ocxl_afu_h afu, int timeout, ocxl_event *events, uint16_t event_count)
Check for pending IRQs and other events.
AFU data is the same endianness as the host.
An out of memory error occurred.
ocxl_err ocxl_mmio_write64(ocxl_mmio_h mmio, off_t offset, ocxl_endian endian, uint64_t value)
Convert endianness and write a 64-bit value to an AFU's MMIO region.
int ocxl_mmio_get_fd(ocxl_afu_h afu, ocxl_mmio_type type)
Get a file descriptor for an MMIO area of an AFU.
void ocxl_afu_set_error_message_handler(ocxl_afu_h afu, void(*handler)(ocxl_afu_h afu, ocxl_err error, const char *message))
Override the default handler for emitting error messages for an AFU.
int ocxl_afu_event_check_versioned(ocxl_afu_h afu, int timeout, ocxl_event *events, uint16_t event_count, uint16_t event_api_version)
Check for pending IRQs and other events.
The data for a triggered translation fault error event.
No more contexts can be opened on the AFU.
ocxl_err ocxl_afu_attach(ocxl_afu_h afu, uint64_t flags)
struct ocxl_mmio_area * ocxl_mmio_h
A handle for an MMIO region on an AFU.
The action requested has already been performed.
uint16_t irq
The IRQ number of the AFU.
ocxl_err ocxl_afu_open_specific(const char *name, const char *physical_function, int16_t afu_index, ocxl_afu_h *afu)
Open an AFU context with a specified name on a specific card/afu index.
uint64_t count
The number of times the interrupt has been triggered since last checked.
ocxl_event_type
OCXL Event types.