CXL_AFU_ATTACH_WORK(3)

NAME
cxl_afu_attach_work - attach the calling process's memory to an open AFU

SYNOPSIS
#include <libcxl.h>

int cxl_afu_attach_work(struct cxl_afu_h *afu, struct cxl_ioctl_work_attach *work);

DESCRIPTION
cxl_afu_attach_work() attaches a context of afu to the current process, specifying various parameters via the work structure, and starts the AFU context.

On success, all memory mapped into this process is accessible to the AFU context using the same effective addresses. No additional calls are required to map/unmap memory. The AFU memory context will be updated as userspace allocates and frees memory.

Three parameters can be set in the work structure:

cxl_work_set_wed() sets the work element descriptor, a 64-bit argument defined by the AFU. Typically this is an effective address pointing to an AFU specific structure describing what work to perform.

cxl_work_set_num_irqs() requests a number of userspace interrupts, in the range defined by cxl_get_irqs_min() and cxl_get_irqs_max(). A negative value specifies that cxl_afu_attach_work() should allocate the minimum number of interrupts required by an AFU context, returned by cxl_get_irqs_min().

cxl_work_set_amr() sets the authority mask register (same as the powerpc AMR). A null value indicates that the authority mask register should not be set.

RETURN VALUE
On success, 0 is returned. On error, -1 is returned and errno is set appropriately.

ERRORS

EINVAL
    Invalid argument value, or AFU not opened.

ENOMEM
    Not enough memory.

ENOSPC
    Not enough interrupts available.

SEE ALSO
cxl(), cxl_afu_attach(), cxl_afu_attach_full(), cxl_afu_fd_to_h(), cxl_afu_free(), cxl_afu_open_dev(), cxl_afu_opened(), cxl_get_irqs_max(), cxl_get_irqs_min(), cxl_get_prefault_mode(), cxl_mmio_map(), cxl_set_irqs_max(), cxl_set_mode(), cxl_set_prefault_mode(), cxl_work_alloc(), cxl_work_free(), cxl_work_get_amr(), cxl_work_get_num_irqs(), cxl_work_get_wed(), cxl_work_set_amr(), cxl_work_set_num_irqs(), cxl_work_set_wed()