NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
devemu_pci_device_dma_dpu_sample.c File Reference
#include <devemu_pci_common.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <doca_ctx.h>
#include <doca_devemu_pci.h>
#include <doca_dev.h>
#include <doca_error.h>
#include <doca_log.h>
#include <doca_dma.h>
#include <doca_buf.h>
#include <doca_buf_inventory.h>
#include <common.h>
Include dependency graph for devemu_pci_device_dma_dpu_sample.c:

Go to the source code of this file.

Data Structures

struct  dma_resources
 

Macros

#define NUM_DMA_TASKS   (1) /* DMA tasks number */
 
#define MEM_BUF_LEN   (4 * 1024) /* Mem buffer size. It's the same as Host side */
 

Functions

 DOCA_LOG_REGISTER (DEVEMU_PCI_DEVICE_DMA_DPU)
 
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 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 doca_error_t setup_buf_inventory (struct dma_resources *resources, int max_bufs)
 
static doca_error_t dma_device_caps_is_supported (struct doca_devinfo *devinfo)
 
static doca_error_t setup_dma_ctx (struct dma_resources *resources, const char *devemu_name)
 
static doca_error_t setup_remote_mmap (struct dma_resources *resources, char *buf, int len)
 
static doca_error_t setup_local_mmap (struct dma_resources *resources, char *buf, int len)
 
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_devemu_resources (struct devemu_resources *resources, const char *pci_address, const char *emulated_dev_vuid)
 
static void dma_resources_cleanup (struct dma_resources *resources)
 
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)
 

Macro Definition Documentation

◆ MEM_BUF_LEN

#define MEM_BUF_LEN   (4 * 1024) /* Mem buffer size. It's the same as Host side */

Definition at line 47 of file devemu_pci_device_dma_dpu_sample.c.

◆ NUM_DMA_TASKS

#define NUM_DMA_TASKS   (1) /* DMA tasks number */

Definition at line 46 of file devemu_pci_device_dma_dpu_sample.c.

Function Documentation

◆ devemu_pci_device_dma_dpu()

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 
)

Definition at line 540 of file devemu_pci_device_dma_dpu_sample.c.

◆ dma_device_caps_is_supported()

static doca_error_t dma_device_caps_is_supported ( struct doca_devinfo *  devinfo)
static

Definition at line 141 of file devemu_pci_device_dma_dpu_sample.c.

◆ dma_memcpy_completed_callback()

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

Definition at line 67 of file devemu_pci_device_dma_dpu_sample.c.

◆ dma_memcpy_error_callback()

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

Definition at line 91 of file devemu_pci_device_dma_dpu_sample.c.

◆ dma_resources_cleanup()

static void dma_resources_cleanup ( struct dma_resources resources)
static

Definition at line 465 of file devemu_pci_device_dma_dpu_sample.c.

◆ do_dma_copy()

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

Do DMA copy task

@resources [in]: struct dma_resources @len [in]: The length of data to copy @src_mmap [in]: Source DOCA mmap @src_addr [in]: Source memory address @dst_mmap [in]: Destination DOCA mmap @dst_addr [in]: Destination memory address

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 322 of file devemu_pci_device_dma_dpu_sample.c.

◆ DOCA_LOG_REGISTER()

DOCA_LOG_REGISTER ( DEVEMU_PCI_DEVICE_DMA_DPU  )

◆ setup_buf_inventory()

static doca_error_t setup_buf_inventory ( struct dma_resources resources,
int  max_bufs 
)
static

Setup DOCA buf inventory

@resources [in]: struct dma_resources @max_bufs [in]: The max number of buffers

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 116 of file devemu_pci_device_dma_dpu_sample.c.

◆ setup_devemu_resources()

static doca_error_t setup_devemu_resources ( struct devemu_resources resources,
const char *  pci_address,
const char *  emulated_dev_vuid 
)
static

Definition at line 403 of file devemu_pci_device_dma_dpu_sample.c.

◆ setup_dma_ctx()

static doca_error_t setup_dma_ctx ( struct dma_resources resources,
const char *  devemu_name 
)
static

Setup DOCA DMA context

@resources [in]: struct dma_resources @devemu_name [in]: The DMA device name

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 160 of file devemu_pci_device_dma_dpu_sample.c.

◆ setup_local_mmap()

static doca_error_t setup_local_mmap ( struct dma_resources resources,
char *  buf,
int  len 
)
static

Setup local mmap

@resources [in]: struct dma_resources @buf [in]: Local memory buffer @len [in]: Length of local memory buffer

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 282 of file devemu_pci_device_dma_dpu_sample.c.

◆ setup_remote_mmap()

static doca_error_t setup_remote_mmap ( struct dma_resources resources,
char *  buf,
int  len 
)
static

Setup remote mmap

@resources [in]: dma_resources @buf [in]: address of remote memory buffer @len [in]: len of remote memory buffer

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 232 of file devemu_pci_device_dma_dpu_sample.c.