46 #define NUM_DMA_TASKS (1)
47 #define MEM_BUF_LEN (4 * 1024)
145 uint8_t supported = 0;
164 struct doca_ctx *
ctx;
167 if (*devemu_name == 0) {
324 struct doca_mmap *src_mmap,
326 struct doca_mmap *dst_mmap,
330 struct doca_buf *src_doca_buf, *dst_doca_buf;
332 struct doca_task *task;
333 struct doca_dma_task_memcpy *dma_task;
334 struct timespec ts = {
348 goto destroy_src_buf;
351 task_user_data.
ptr = &task_result;
359 goto destroy_dst_buf;
368 goto cleanup_dma_task;
374 goto cleanup_dma_task;
383 goto destroy_dst_buf;
404 const char *pci_address,
405 const char *emulated_dev_vuid)
541 const char *devemu_name,
542 const char *emulated_dev_vuid,
543 uint64_t host_dma_mem_iova,
544 const char *write_data)
549 void *remote_addr = (
void *)host_dma_mem_iova;
doca_error_t open_doca_device_with_ibdev_name(const uint8_t *value, size_t val_size, tasks_check func, struct doca_dev **retval)
void devemu_resources_cleanup(struct devemu_resources *resources, bool destroy_rep)
static doca_error_t setup_local_mmap(struct dma_resources *resources, char *buf, int len)
static doca_error_t dma_device_caps_is_supported(struct doca_devinfo *devinfo)
static doca_error_t do_dma_copy(struct dma_resources *resources, int len, struct doca_mmap *src_mmap, void *src_addr, struct doca_mmap *dst_mmap, void *dst_addr)
static doca_error_t setup_buf_inventory(struct dma_resources *resources, int max_bufs)
doca_error_t devemu_pci_device_dma_dpu(const char *pci_address, const char *devemu_name, const char *emulated_dev_vuid, uint64_t host_dma_mem_iova, const char *write_data)
DOCA_LOG_REGISTER(DEVEMU_PCI_DEVICE_DMA_DPU)
static doca_error_t setup_remote_mmap(struct dma_resources *resources, char *buf, int len)
static void dma_memcpy_completed_callback(struct doca_dma_task_memcpy *dma_task, union doca_data task_user_data, union doca_data ctx_user_data)
static doca_error_t setup_devemu_resources(struct devemu_resources *resources, const char *pci_address, const char *emulated_dev_vuid)
static void dma_memcpy_error_callback(struct doca_dma_task_memcpy *dma_task, union doca_data task_user_data, union doca_data ctx_user_data)
static void dma_resources_cleanup(struct dma_resources *resources)
static doca_error_t setup_dma_ctx(struct dma_resources *resources, const char *devemu_name)
struct rdma_resources resources
DOCA_STABLE doca_error_t doca_buf_inventory_destroy(struct doca_buf_inventory *inventory)
Destroy buffer inventory structure.
static doca_error_t doca_buf_inventory_buf_get_by_addr(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *addr, size_t len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by addr & len argume...
DOCA_STABLE doca_error_t doca_buf_inventory_start(struct doca_buf_inventory *inventory)
Start element retrieval from inventory.
DOCA_STABLE doca_error_t doca_buf_inventory_create(size_t num_elements, struct doca_buf_inventory **inventory)
Allocates buffer inventory with default/unset attributes.
DOCA_STABLE doca_error_t doca_buf_dec_refcount(struct doca_buf *buf, uint16_t *refcount)
Decrease the object reference count by 1, if 0 reached, return the element back to the inventory.
DOCA_STABLE doca_error_t doca_buf_set_data(struct doca_buf *buf, void *data, size_t data_len)
DOCA_STABLE doca_error_t doca_ctx_start(struct doca_ctx *ctx)
Finalizes all configurations, and starts the DOCA CTX.
DOCA_STABLE doca_error_t doca_ctx_set_user_data(struct doca_ctx *ctx, union doca_data user_data)
set user data to context
DOCA_STABLE doca_error_t doca_ctx_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_type_create(const char *name, struct doca_devemu_pci_type **pci_type)
Create a stopped DOCA devemu PCI type.
#define DOCA_DEVEMU_PCI_TYPE_NAME_LEN
Maximal length for the NULL terminated string that describe the name of the emulated PCI device type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_cap_type_is_hotplug_supported(const struct doca_devinfo *devinfo, const struct doca_devemu_pci_type *pci_type, uint8_t *supported)
Get the hotplug capability of the device for a given DOCA devemu PCI type.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_cap_is_mmap_add_dev_supported(const struct doca_devinfo *devinfo, uint8_t *supported)
Check if adding the device to a DOCA mmap associated with a DOCA devemu PCI device is supported.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_dev_create(struct doca_devemu_pci_type *pci_type, struct doca_dev_rep *dev_rep, struct doca_pe *progress_engine, struct doca_devemu_pci_dev **pci_dev)
Allocate DOCA devemu PCI device.
DOCA_EXPERIMENTAL doca_error_t doca_devemu_pci_mmap_create(struct doca_devemu_pci_dev *pci_dev, struct doca_mmap **mmap)
Allocates zero size memory map object with default/unset attributes associated with a DOCA devemu PCI...
DOCA_EXPERIMENTAL struct doca_ctx * doca_devemu_pci_dev_as_ctx(struct doca_devemu_pci_dev *pci_dev)
Convert DOCA devemu PCI device instance into DOCA context.
DOCA_STABLE doca_error_t doca_dev_open(struct doca_devinfo *devinfo, struct doca_dev **dev)
Initialize local device for use.
DOCA_STABLE struct doca_devinfo * doca_dev_as_devinfo(const struct doca_dev *dev)
Get local device info from device. This should be useful when wanting to query information about devi...
DOCA_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
DOCA_STABLE struct doca_task * doca_dma_task_memcpy_as_task(struct doca_dma_task_memcpy *task)
This method converts a memcpy task to doca_task.
DOCA_STABLE doca_error_t doca_dma_task_memcpy_alloc_init(struct doca_dma *dma, const struct doca_buf *src, struct doca_buf *dst, union doca_data user_data, struct doca_dma_task_memcpy **task)
This method allocates and initializes a DMA memcpy task.
DOCA_STABLE struct doca_ctx * doca_dma_as_ctx(struct doca_dma *dma)
DOCA_STABLE doca_error_t doca_dma_task_memcpy_set_conf(struct doca_dma *dma, doca_dma_task_memcpy_completion_cb_t task_completion_cb, doca_dma_task_memcpy_completion_cb_t task_error_cb, uint32_t num_memcpy_tasks)
This method sets the DMA memcpy tasks configuration.
DOCA_STABLE doca_error_t doca_dma_cap_task_memcpy_is_supported(const struct doca_devinfo *devinfo)
DOCA_STABLE doca_error_t doca_dma_create(struct doca_dev *dev, struct doca_dma **dma)
DOCA_STABLE doca_error_t doca_dma_destroy(struct doca_dma *dma)
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_NOT_SUPPORTED
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
DOCA_STABLE doca_error_t doca_mmap_set_memrange(struct doca_mmap *mmap, void *addr, size_t len)
Set the memory range of DOCA memory map.
DOCA_STABLE doca_error_t doca_mmap_set_max_num_devices(struct doca_mmap *mmap, uint32_t max_num_devices)
Set a new max number of devices to add to a DOCA Memory Map.
DOCA_STABLE doca_error_t doca_mmap_destroy(struct doca_mmap *mmap)
Destroy DOCA Memory Map structure.
DOCA_STABLE doca_error_t doca_mmap_create(struct doca_mmap **mmap)
Allocates zero size memory map object with default/unset attributes.
DOCA_STABLE doca_error_t doca_mmap_set_permissions(struct doca_mmap *mmap, uint32_t access_mask)
Set access flags of the registered memory.
DOCA_STABLE doca_error_t doca_mmap_start(struct doca_mmap *mmap)
Start DOCA Memory Map.
DOCA_STABLE doca_error_t doca_mmap_stop(struct doca_mmap *mmap)
Stop DOCA Memory Map.
DOCA_STABLE doca_error_t doca_mmap_add_dev(struct doca_mmap *mmap, struct doca_dev *dev)
Register DOCA memory map on a given device.
DOCA_STABLE doca_error_t doca_task_get_status(const struct doca_task *task)
Get task status.
DOCA_STABLE doca_error_t doca_pe_connect_ctx(struct doca_pe *pe, struct doca_ctx *ctx)
This method connects a context to a progress engine.
DOCA_STABLE doca_error_t doca_task_submit(struct doca_task *task)
Submit a task to a progress engine.
DOCA_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
DOCA_STABLE doca_error_t doca_pe_create(struct doca_pe **pe)
Creates DOCA progress engine.
DOCA_STABLE void doca_task_free(struct doca_task *task)
Free a task back to where it was allocated from.
@ DOCA_ACCESS_FLAG_LOCAL_READ_WRITE
doca_error_t configure_and_start_pci_type(struct doca_devemu_pci_type *pci_type, struct doca_dev *dev)
doca_error_t find_emulated_device(struct doca_devemu_pci_type *pci_type, const char *vuid, struct doca_dev_rep **rep)
doca_error_t find_supported_device(const char *dev_name, const struct doca_devemu_pci_type *pci_type, emulation_supported_cb_t has_support, struct doca_dev **dev)
struct doca_mmap * remote_mmap
struct doca_dma * dma_ctx
size_t num_remaining_tasks
struct doca_buf_inventory * buf_inv
struct devemu_resources devemu_res
struct doca_dev * dma_dev
struct doca_mmap * local_mmap
struct doca_mmap * remote_mmap
size_t num_remaining_tasks
Convenience type for representing opaque data.
struct upf_accel_ctx * ctx