libocxl
Functions
OpenCAPI AFU Management

These functions provide access to open and close the AFU. More...

Functions

ocxl_err ocxl_afu_open_from_dev (const char *path, ocxl_afu_h *afu)
 Open an AFU context at a specified path. More...
 
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. More...
 
ocxl_err ocxl_afu_open (const char *name, ocxl_afu_h *afu)
 Open an AFU context with a specified name. More...
 
ocxl_err ocxl_afu_attach (ocxl_afu_h afu, __attribute__((unused)) uint64_t flags)
 Attach the calling process's memory to an open AFU context. More...
 
ocxl_err ocxl_afu_close (ocxl_afu_h afu)
 Close an AFU and detach it from the context. More...
 

Detailed Description

These functions provide access to open and close the AFU.

A typical workflow involves the following:

Subsequently, you will need to write information to the AFU's MMIO space (see ocxl_mmio) and also configure and handle interrupts (see ocxl_irq)

Finally, to free the AFU handle, you can use ocxl_afu_close().

Function Documentation

◆ ocxl_afu_attach()

ocxl_err ocxl_afu_attach ( ocxl_afu_h  afu,
__attribute__((unused)) uint64_t  flags 
)

Attach the calling process's memory to an open AFU context.

An open AFU context is sufficient to configure the AFU, but in order for it to access application memory, the context must be attached to the current process.

If specified, also sets the value of the PPC specific PSL AMR.

Precondition
the AFU is opened
Parameters
afuthe AFU to attach
flagsAn ORed bitmask of flags OCXL_ATTACH_FLAGS_NONE accept the default behavior
Return values
OCXL_OKif the AFU was successful attached
OCXL_NO_CONTEXTif the AFU was not opened
OCXL_INTERNAL_ERRORif the AFU was unable to attach (check dmesg)

Definition at line 663 of file afu.c.

◆ ocxl_afu_close()

ocxl_err ocxl_afu_close ( ocxl_afu_h  afu)

Close an AFU and detach it from the context.

This will free all resources allocated to the AFU, including MMIO areas and IRQs. The AFU handle may not be used after it is closed.

Parameters
afua pointer to the AFU handle we want to close
Return values
OCXL_OKif the AFU was freed
OCXL_ALREADY_DONEif the AFU was not open
Postcondition
All resources associated with the handle are closed and freed, the handle is no longer usable

Definition at line 701 of file afu.c.

◆ ocxl_afu_open()

ocxl_err ocxl_afu_open ( const char *  name,
ocxl_afu_h afu 
)

Open an AFU context with a specified name.

Parameters
namethe name of the AFU
[out]afuthe AFU handle which we will allocate. This should be freed with ocxl_afu_close
Return values
OCXL_OKif we have successfully fetched the AFU
OCXL_NO_MEMif an out of memory error occurred
OCXL_NO_DEVif no valid device was found
OCXL_NO_MORE_CONTEXTSif maximum number of AFU contexts has been reached on all matching AFUs

Definition at line 640 of file afu.c.

◆ ocxl_afu_open_from_dev()

ocxl_err ocxl_afu_open_from_dev ( const char *  path,
ocxl_afu_h afu 
)

Open an AFU context at a specified path.

Parameters
paththe path of the AFU
[out]afuthe AFU handle which we will allocate. This should be freed with ocxl_afu_close
Return values
OCXL_OKif we have successfully fetched the AFU
OCXL_NO_MEMif an out of memory error occurred
OCXL_NO_DEVif the device is invalid
OCXL_NO_MORE_CONTEXTSif maximum number of AFU contexts has been reached

Definition at line 541 of file afu.c.

◆ ocxl_afu_open_specific()

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.

Parameters
namethe name of the AFU
physical_functionthe PCI physical function of the card (as a string, or NULL for any)
afu_indexthe AFU index (or -1 for any)
[out]afuthe AFU handle which we will allocate. This should be freed with ocxl_afu_close
Return values
OCXL_OKif we have successfully fetched the AFU
OCXL_NO_MEMif an out of memory error occurred
OCXL_NO_DEVif no valid device was found
OCXL_NO_MORE_CONTEXTSif maximum number of AFU contexts has been reached on all matching AFUs

Definition at line 573 of file afu.c.