46 #define SLEEP_IN_NANOS (10 * 1000)
47 #define RECV_BUF_SIZE (512)
61 const char *buffer_info_file_path,
63 size_t *export_desc_len,
65 size_t *remote_addr_len)
72 fp = fopen(export_desc_file_path,
"r");
74 DOCA_LOG_ERR(
"Failed to open %s", export_desc_file_path);
78 if (fseek(fp, 0, SEEK_END) != 0) {
84 file_size = ftell(fp);
85 if (file_size == -1) {
94 *export_desc_len = file_size;
96 if (fseek(fp, 0L, SEEK_SET) != 0) {
102 if (fread(export_desc, 1, file_size, fp) != (
size_t)file_size) {
103 DOCA_LOG_ERR(
"Failed to allocate memory for source buffer");
111 fp = fopen(buffer_info_file_path,
"r");
113 DOCA_LOG_ERR(
"Failed to open %s", buffer_info_file_path);
119 DOCA_LOG_ERR(
"Failed to read the source (host) buffer address");
123 convert_value = strtoull(buffer,
NULL, 0);
124 if (convert_value == ULLONG_MAX) {
125 DOCA_LOG_ERR(
"Failed to read the source (host) buffer address. Data is corrupted");
129 *remote_addr = (
char *)convert_value;
135 DOCA_LOG_ERR(
"Failed to read the source (host) buffer length");
139 convert_value = strtoull(buffer,
NULL, 0);
140 if (convert_value == ULLONG_MAX) {
141 DOCA_LOG_ERR(
"Failed to read the source (host) buffer length. Data is corrupted");
145 *remote_addr_len = convert_value;
163 char *buffer_info_file_path,
164 const char *pcie_addr,
170 struct doca_dma_task_memcpy *dma_task =
NULL;
171 struct doca_task *task =
NULL;
173 struct doca_buf *src_doca_buf =
NULL;
174 struct doca_buf *dst_doca_buf =
NULL;
175 struct doca_mmap *remote_mmap =
NULL;
176 char export_desc[1024] = {0};
177 char *remote_addr =
NULL;
179 size_t dst_buffer_size, remote_addr_len = 0, export_desc_len = 0;
180 size_t max_buffer_size;
181 struct timespec ts = {
198 goto destroy_resources;
204 goto destroy_resources;
216 buffer_info_file_path,
226 if (remote_addr_len == 0) {
228 DOCA_LOG_ERR(
"Remote buffer from host is zero: failed to parse the buffer information file");
230 }
else if (remote_addr_len > max_buffer_size) {
232 DOCA_LOG_ERR(
"Remote buffer from Host exceeds max allowed buffer: %zu > %zu",
239 dst_buffer_size = remote_addr_len;
240 dpu_buffer = (
char *)malloc(dst_buffer_size);
241 if (dpu_buffer ==
NULL) {
250 goto free_dpu_buffer;
256 goto free_dpu_buffer;
264 goto free_dpu_buffer;
276 DOCA_LOG_ERR(
"Unable to acquire DOCA buffer representing remote buffer: %s",
278 goto destroy_remote_mmap;
290 DOCA_LOG_ERR(
"Unable to acquire DOCA buffer representing destination buffer: %s",
292 goto destroy_src_buf;
296 task_user_data.
ptr = &task_result;
306 goto destroy_dst_buf;
318 goto destroy_dst_buf;
332 dpu_buffer[dst_buffer_size - 1] =
'\0';
346 DOCA_LOG_ERR(
"Failed to decrease DOCA destination buffer reference count: %s",
353 DOCA_LOG_ERR(
"Failed to decrease DOCA source buffer reference count: %s",
doca_error_t allocat_doca_buf_list(struct doca_buf_inventory *buf_inv, struct doca_mmap *mmap, void *buf_addr, size_t buf_len, int num_buf, bool set_data_pos, struct doca_buf **dbuf)
doca_error_t destroy_dma_resources(struct dma_resources *resources)
doca_error_t allocate_dma_resources(const char *pcie_addr, int num_buf, struct dma_resources *resources)
doca_error_t dma_copy_dpu(char *export_desc_file_path, char *buffer_info_file_path, const char *pcie_addr, int num_src_buf, int num_dst_buf)
DOCA_LOG_REGISTER(DMA_COPY_DPU)
static doca_error_t save_config_info_to_buffers(const char *export_desc_file_path, const char *buffer_info_file_path, char *export_desc, size_t *export_desc_len, char **remote_addr, size_t *remote_addr_len)
struct rdma_resources resources
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_ctx_start(struct doca_ctx *ctx)
Finalizes all configurations, and starts the DOCA CTX.
DOCA_STABLE doca_error_t doca_ctx_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
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 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 doca_error_t doca_dma_cap_task_memcpy_get_max_buf_size(const struct doca_devinfo *devinfo, uint64_t *buf_size)
#define DOCA_ERROR_PROPAGATE(r, t)
Save the first encountered doca_error_t.
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.
#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_destroy(struct doca_mmap *mmap)
Destroy DOCA Memory Map structure.
DOCA_STABLE doca_error_t doca_mmap_create_from_export(const union doca_data *user_data, const void *export_desc, size_t export_desc_len, struct doca_dev *dev, struct doca_mmap **mmap)
Creates a memory map object representing memory ranges in remote system memory space.
DOCA_STABLE doca_error_t doca_mmap_start(struct doca_mmap *mmap)
Start DOCA Memory Map.
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 void doca_task_free(struct doca_task *task)
Free a task back to where it was allocated from.
struct doca_buf_inventory * buf_inv
struct doca_mmap * dst_mmap
size_t num_remaining_tasks
Convenience type for representing opaque data.