NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
dma_common.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2023 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #include <string.h>
27 #include <unistd.h>
28 
29 #include <doca_argp.h>
30 #include <doca_buf_inventory.h>
31 #include <doca_dev.h>
32 #include <doca_ctx.h>
33 #include <doca_dma.h>
34 #include <doca_error.h>
35 #include <doca_log.h>
36 #include <doca_mmap.h>
37 #include <doca_pe.h>
38 
39 #include "dma_common.h"
40 
41 DOCA_LOG_REGISTER(DMA_COMMON);
42 
43 /*
44  * ARGP Callback - Handle PCI device address parameter
45  *
46  * @param [in]: Input parameter
47  * @config [in/out]: Program configuration context
48  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
49  */
50 static doca_error_t pci_callback(void *param, void *config)
51 {
52  struct dma_config *conf = (struct dma_config *)config;
53  const char *addr = (char *)param;
54  int addr_len = strnlen(addr, DOCA_DEVINFO_PCI_ADDR_SIZE);
55 
56  /* Check using >= to make static code analysis satisfied */
57  if (addr_len >= DOCA_DEVINFO_PCI_ADDR_SIZE) {
58  DOCA_LOG_ERR("Entered device PCI address exceeding the maximum size of %d",
61  }
62 
63  /* The string will be '\0' terminated due to the strnlen check above */
64  strncpy(conf->pci_address, addr, addr_len + 1);
65 
66  return DOCA_SUCCESS;
67 }
68 
69 /*
70  * ARGP Callback - Handle text to copy parameter
71  *
72  * @param [in]: Input parameter
73  * @config [in/out]: Program configuration context
74  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
75  */
76 static doca_error_t text_callback(void *param, void *config)
77 {
78  struct dma_config *conf = (struct dma_config *)config;
79  const char *txt = (char *)param;
80  int txt_len = strnlen(txt, MAX_TXT_SIZE);
81 
82  /* Check using >= to make static code analysis satisfied */
83  if (txt_len >= MAX_TXT_SIZE) {
84  DOCA_LOG_ERR("Entered text exceeded buffer size of: %d", MAX_USER_TXT_SIZE);
86  }
87 
88  /* The string will be '\0' terminated due to the strnlen check above */
89  strncpy(conf->cpy_txt, txt, txt_len + 1);
90 
91  return DOCA_SUCCESS;
92 }
93 
94 /*
95  * ARGP Callback - Handle exported descriptor file path parameter
96  *
97  * @param [in]: Input parameter
98  * @config [in/out]: Program configuration context
99  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
100  */
101 static doca_error_t descriptor_path_callback(void *param, void *config)
102 {
103  struct dma_config *conf = (struct dma_config *)config;
104  const char *path = (char *)param;
105  int path_len = strnlen(path, MAX_ARG_SIZE);
106 
107  /* Check using >= to make static code analysis satisfied */
108  if (path_len >= MAX_ARG_SIZE) {
109  DOCA_LOG_ERR("Entered path exceeded buffer size: %d", MAX_USER_ARG_SIZE);
111  }
112 
113 #ifdef DOCA_ARCH_DPU
114  if (access(path, F_OK | R_OK) != 0) {
115  DOCA_LOG_ERR("Failed to find file path pointed by export descriptor: %s", path);
117  }
118 #endif
119 
120  /* The string will be '\0' terminated due to the strnlen check above */
121  strncpy(conf->export_desc_path, path, path_len + 1);
122 
123  return DOCA_SUCCESS;
124 }
125 
126 #ifdef DOCA_ARCH_DPU
127 /*
128  * ARGP Callback - Handle number of source doca_buf parameter
129  *
130  * @param [in]: Input parameter
131  * @config [in/out]: Program configuration context
132  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
133  */
134 static doca_error_t num_src_buf_callback(void *param, void *config)
135 {
136  struct dma_config *conf = (struct dma_config *)config;
137  const int *num = (int *)param;
138 
139  if (*num <= 0) {
140  DOCA_LOG_ERR("Entered number of source doca_buf: %d, valid value must be >= 1", *num);
142  }
143 
144  conf->num_src_buf = *num;
145 
146  return DOCA_SUCCESS;
147 }
148 
149 /*
150  * ARGP Callback - Handle number of destination doca_buf parameter
151  *
152  * @param [in]: Input parameter
153  * @config [in/out]: Program configuration context
154  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
155  */
156 static doca_error_t num_dst_buf_callback(void *param, void *config)
157 {
158  struct dma_config *conf = (struct dma_config *)config;
159  const int *num = (int *)param;
160 
161  if (*num <= 0) {
162  DOCA_LOG_ERR("Entered number of destination doca_buf: %d, valid value must be >= 1", *num);
164  }
165 
166  conf->num_dst_buf = *num;
167 
168  return DOCA_SUCCESS;
169 }
170 #endif /* DOCA_ARCH_DPU */
171 
172 /*
173  * ARGP Callback - Handle buffer information file path parameter
174  *
175  * @param [in]: Input parameter
176  * @config [in/out]: Program configuration context
177  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
178  */
179 static doca_error_t buf_info_path_callback(void *param, void *config)
180 {
181  struct dma_config *conf = (struct dma_config *)config;
182  const char *path = (char *)param;
183  int path_len = strnlen(path, MAX_ARG_SIZE);
184 
185  /* Check using >= to make static code analysis satisfied */
186  if (path_len >= MAX_ARG_SIZE) {
187  DOCA_LOG_ERR("Entered path exceeded buffer size: %d", MAX_USER_ARG_SIZE);
189  }
190 
191 #ifdef DOCA_ARCH_DPU
192  if (access(path, F_OK | R_OK) != 0) {
193  DOCA_LOG_ERR("Failed to find file path pointed by buffer information: %s", path);
195  }
196 #endif
197 
198  /* The string will be '\0' terminated due to the strnlen check above */
199  strncpy(conf->buf_info_path, path, path_len + 1);
200 
201  return DOCA_SUCCESS;
202 }
203 
205 {
207  struct doca_argp_param *pci_address_param, *cpy_txt_param, *export_desc_path_param, *buf_info_path_param;
208 #ifdef DOCA_ARCH_DPU
209  struct doca_argp_param *num_src_buf_param, *num_dst_buf_param;
210 #endif /* DOCA_ARCH_DPU */
211 
212  /* Create and register PCI address param */
213  result = doca_argp_param_create(&pci_address_param);
214  if (result != DOCA_SUCCESS) {
215  DOCA_LOG_ERR("Failed to create ARGP param: %s", doca_error_get_descr(result));
216  return result;
217  }
218  doca_argp_param_set_short_name(pci_address_param, "p");
219  doca_argp_param_set_long_name(pci_address_param, "pci-addr");
220  doca_argp_param_set_description(pci_address_param, "DOCA DMA device PCI address");
221  doca_argp_param_set_callback(pci_address_param, pci_callback);
223  result = doca_argp_register_param(pci_address_param);
224  if (result != DOCA_SUCCESS) {
225  DOCA_LOG_ERR("Failed to register program param: %s", doca_error_get_descr(result));
226  return result;
227  }
228 
229  /* Create and register text to copy param */
230  result = doca_argp_param_create(&cpy_txt_param);
231  if (result != DOCA_SUCCESS) {
232  DOCA_LOG_ERR("Failed to create ARGP param: %s", doca_error_get_descr(result));
233  return result;
234  }
235  doca_argp_param_set_short_name(cpy_txt_param, "t");
236  doca_argp_param_set_long_name(cpy_txt_param, "text");
237  doca_argp_param_set_description(cpy_txt_param,
238  "Text to DMA copy from the Host to the DPU (relevant only on the Host side)");
241  result = doca_argp_register_param(cpy_txt_param);
242  if (result != DOCA_SUCCESS) {
243  DOCA_LOG_ERR("Failed to register program param: %s", doca_error_get_descr(result));
244  return result;
245  }
246 
247  if (is_remote) {
248  /* Create and register exported descriptor file path param */
249  result = doca_argp_param_create(&export_desc_path_param);
250  if (result != DOCA_SUCCESS) {
251  DOCA_LOG_ERR("Failed to create ARGP param: %s", doca_error_get_descr(result));
252  return result;
253  }
254  doca_argp_param_set_short_name(export_desc_path_param, "d");
255  doca_argp_param_set_long_name(export_desc_path_param, "descriptor-path");
256  doca_argp_param_set_description(export_desc_path_param,
257  "Exported descriptor file path to save (Host) or to read from (DPU)");
259  doca_argp_param_set_type(export_desc_path_param, DOCA_ARGP_TYPE_STRING);
260  result = doca_argp_register_param(export_desc_path_param);
261  if (result != DOCA_SUCCESS) {
262  DOCA_LOG_ERR("Failed to register program param: %s", doca_error_get_descr(result));
263  return result;
264  }
265 
266  /* Create and register buffer information file param */
267  result = doca_argp_param_create(&buf_info_path_param);
268  if (result != DOCA_SUCCESS) {
269  DOCA_LOG_ERR("Failed to create ARGP param: %s", doca_error_get_descr(result));
270  return result;
271  }
272  doca_argp_param_set_short_name(buf_info_path_param, "b");
273  doca_argp_param_set_long_name(buf_info_path_param, "buffer-path");
274  doca_argp_param_set_description(buf_info_path_param,
275  "Buffer information file path to save (Host) or to read from (DPU)");
277  doca_argp_param_set_type(buf_info_path_param, DOCA_ARGP_TYPE_STRING);
278  result = doca_argp_register_param(buf_info_path_param);
279  if (result != DOCA_SUCCESS) {
280  DOCA_LOG_ERR("Failed to register program param: %s", doca_error_get_descr(result));
281  return result;
282  }
283  }
284 
285 #ifdef DOCA_ARCH_DPU
286  /* Create and register number of source doca_buf param */
287  result = doca_argp_param_create(&num_src_buf_param);
288  if (result != DOCA_SUCCESS) {
289  DOCA_LOG_ERR("Failed to create ARGP param: %s", doca_error_get_descr(result));
290  return result;
291  }
292  doca_argp_param_set_short_name(num_src_buf_param, "ns");
293  doca_argp_param_set_long_name(num_src_buf_param, "num-src-buf");
294  doca_argp_param_set_description(num_src_buf_param, "number of doca_buf for source buffer");
296  doca_argp_param_set_type(num_src_buf_param, DOCA_ARGP_TYPE_INT);
297  result = doca_argp_register_param(num_src_buf_param);
298  if (result != DOCA_SUCCESS) {
299  DOCA_LOG_ERR("Failed to register program param: %s", doca_error_get_descr(result));
300  return result;
301  }
302 
303  /* Create and register number of destination doca_buf param */
304  result = doca_argp_param_create(&num_dst_buf_param);
305  if (result != DOCA_SUCCESS) {
306  DOCA_LOG_ERR("Failed to create ARGP param: %s", doca_error_get_descr(result));
307  return result;
308  }
309  doca_argp_param_set_short_name(num_dst_buf_param, "nd");
310  doca_argp_param_set_long_name(num_dst_buf_param, "num-dst-buf");
311  doca_argp_param_set_description(num_dst_buf_param, "number of doca_buf for destination buffer");
313  doca_argp_param_set_type(num_dst_buf_param, DOCA_ARGP_TYPE_INT);
314  result = doca_argp_register_param(num_dst_buf_param);
315  if (result != DOCA_SUCCESS) {
316  DOCA_LOG_ERR("Failed to register program param: %s", doca_error_get_descr(result));
317  return result;
318  }
319 #endif /* DOCA_ARCH_DPU */
320 
321  return DOCA_SUCCESS;
322 }
323 
324 /*
325  * DMA Memcpy task completed callback
326  *
327  * @dma_task [in]: Completed task
328  * @task_user_data [in]: doca_data from the task
329  * @ctx_user_data [in]: doca_data from the context
330  */
331 static void dma_memcpy_completed_callback(struct doca_dma_task_memcpy *dma_task,
332  union doca_data task_user_data,
333  union doca_data ctx_user_data)
334 {
335  struct dma_resources *resources = (struct dma_resources *)ctx_user_data.ptr;
336  doca_error_t *result = (doca_error_t *)task_user_data.ptr;
337 
338  /* Assign success to the result */
339  *result = DOCA_SUCCESS;
340  DOCA_LOG_INFO("DMA task was completed successfully");
341 
342  /* Free task */
344  /* Decrement number of remaining tasks */
346  /* Stop context once all tasks are completed */
347  if (resources->num_remaining_tasks == 0)
348  (void)doca_ctx_stop(resources->state.ctx);
349 }
350 
351 /*
352  * Memcpy task error callback
353  *
354  * @dma_task [in]: failed task
355  * @task_user_data [in]: doca_data from the task
356  * @ctx_user_data [in]: doca_data from the context
357  */
358 static void dma_memcpy_error_callback(struct doca_dma_task_memcpy *dma_task,
359  union doca_data task_user_data,
360  union doca_data ctx_user_data)
361 {
362  struct dma_resources *resources = (struct dma_resources *)ctx_user_data.ptr;
363  struct doca_task *task = doca_dma_task_memcpy_as_task(dma_task);
364  doca_error_t *result = (doca_error_t *)task_user_data.ptr;
365 
366  /* Get the result of the task */
367  *result = doca_task_get_status(task);
368  DOCA_LOG_ERR("DMA task failed: %s", doca_error_get_descr(*result));
369 
370  /* Free task */
371  doca_task_free(task);
372  /* Decrement number of remaining tasks */
374  /* Stop context once all tasks are completed */
375  if (resources->num_remaining_tasks == 0)
376  (void)doca_ctx_stop(resources->state.ctx);
377 }
378 
387 static void dma_state_changed_callback(const union doca_data user_data,
388  struct doca_ctx *ctx,
389  enum doca_ctx_states prev_state,
390  enum doca_ctx_states next_state)
391 {
392  (void)ctx;
393  (void)prev_state;
394 
395  struct dma_resources *resources = (struct dma_resources *)user_data.ptr;
396 
397  switch (next_state) {
398  case DOCA_CTX_STATE_IDLE:
399  DOCA_LOG_INFO("DMA context has been stopped");
400  /* We can stop progressing the PE */
401  resources->run_pe_progress = false;
402  break;
407  DOCA_LOG_ERR("DMA context entered into starting state. Unexpected transition");
408  break;
410  DOCA_LOG_INFO("DMA context is running");
411  break;
420  DOCA_LOG_INFO("DMA context entered into stopping state. Any inflight tasks will be flushed");
421  break;
422  default:
423  break;
424  }
425 }
426 
427 doca_error_t allocate_dma_resources(const char *pcie_addr, int num_buf, struct dma_resources *resources)
428 {
429  memset(resources, 0, sizeof(*resources));
430  union doca_data ctx_user_data = {0};
431  struct program_core_objects *state = &resources->state;
432  doca_error_t result, tmp_result;
433  uint32_t max_buf_list_len = 0;
434 
436  if (result != DOCA_SUCCESS) {
437  DOCA_LOG_ERR("Failed to open DOCA device for DMA: %s", doca_error_get_descr(result));
438  return result;
439  }
440 
442  if (result != DOCA_SUCCESS) {
443  DOCA_LOG_ERR("Failed to get memcpy task max_buf_list_len capability for DMA: %s",
445  return result;
446  }
447  if ((uint32_t)num_buf > max_buf_list_len) {
449  DOCA_LOG_ERR("Number of doca_buf [%d] exceed the limitation [%u]: %s",
450  num_buf,
451  max_buf_list_len,
453  return result;
454  }
455 
456  result = create_core_objects(state, (uint32_t)num_buf);
457  if (result != DOCA_SUCCESS) {
458  DOCA_LOG_ERR("Failed to create DOCA core objects: %s", doca_error_get_descr(result));
459  goto close_device;
460  }
461 
462  result = doca_dma_create(state->dev, &resources->dma_ctx);
463  if (result != DOCA_SUCCESS) {
464  DOCA_LOG_ERR("Failed to create DMA context: %s", doca_error_get_descr(result));
466  }
467 
468  state->ctx = doca_dma_as_ctx(resources->dma_ctx);
469 
471  if (result != DOCA_SUCCESS) {
472  DOCA_LOG_ERR("Unable to set DMA state change callback: %s", doca_error_get_descr(result));
473  goto destroy_dma;
474  }
475 
479  NUM_DMA_TASKS);
480  if (result != DOCA_SUCCESS) {
481  DOCA_LOG_ERR("Failed to set configurations for DMA memcpy task: %s", doca_error_get_descr(result));
482  goto destroy_dma;
483  }
484 
485  /* Include resources in user data of context to be used in callbacks */
486  ctx_user_data.ptr = resources;
487  doca_ctx_set_user_data(state->ctx, ctx_user_data);
488 
489  return result;
490 
491 destroy_dma:
492  tmp_result = doca_dma_destroy(resources->dma_ctx);
493  if (tmp_result != DOCA_SUCCESS) {
494  DOCA_ERROR_PROPAGATE(result, tmp_result);
495  DOCA_LOG_ERR("Failed to destroy DOCA DMA context: %s", doca_error_get_descr(tmp_result));
496  }
498  tmp_result = destroy_core_objects(state);
499  if (tmp_result != DOCA_SUCCESS) {
500  DOCA_ERROR_PROPAGATE(result, tmp_result);
501  DOCA_LOG_ERR("Failed to destroy DOCA core objects: %s", doca_error_get_descr(tmp_result));
502  }
503 close_device:
504  tmp_result = doca_dev_close(state->dev);
505  if (tmp_result != DOCA_SUCCESS) {
506  DOCA_ERROR_PROPAGATE(result, tmp_result);
507  DOCA_LOG_ERR("Failed to close DOCA device: %s", doca_error_get_descr(tmp_result));
508  }
509 
510  return result;
511 }
512 
514 {
515  doca_error_t result, tmp_result;
516 
517  result = doca_dma_destroy(resources->dma_ctx);
518  if (result != DOCA_SUCCESS)
519  DOCA_LOG_ERR("Failed to destroy DOCA DMA context: %s", doca_error_get_descr(result));
520 
521  tmp_result = destroy_core_objects(&resources->state);
522  if (tmp_result != DOCA_SUCCESS) {
523  DOCA_ERROR_PROPAGATE(result, tmp_result);
524  DOCA_LOG_ERR("Failed to destroy DOCA core objects: %s", doca_error_get_descr(tmp_result));
525  }
526 
527  tmp_result = doca_dev_close(resources->state.dev);
528  if (tmp_result != DOCA_SUCCESS) {
529  DOCA_ERROR_PROPAGATE(result, tmp_result);
530  DOCA_LOG_ERR("Failed to close DOCA device: %s", doca_error_get_descr(tmp_result));
531  }
532 
533  return result;
534 }
535 
536 doca_error_t allocate_dma_host_resources(const char *pcie_addr, struct program_core_objects *state)
537 {
538  doca_error_t result, tmp_result;
539 
541  if (result != DOCA_SUCCESS) {
542  DOCA_LOG_ERR("Failed to open DOCA device for DMA: %s", doca_error_get_descr(result));
543  return result;
544  }
545 
546  result = doca_mmap_create(&state->src_mmap);
547  if (result != DOCA_SUCCESS) {
548  DOCA_LOG_ERR("Failed to create mmap: %s", doca_error_get_descr(result));
549  goto close_device;
550  }
551 
552  result = doca_mmap_add_dev(state->src_mmap, state->dev);
553  if (result != DOCA_SUCCESS) {
554  DOCA_LOG_ERR("Failed to add device to mmap: %s", doca_error_get_descr(result));
555  goto destroy_mmap;
556  }
557 
558  return result;
559 
560 destroy_mmap:
561  tmp_result = doca_mmap_destroy(state->src_mmap);
562  if (tmp_result != DOCA_SUCCESS) {
563  DOCA_ERROR_PROPAGATE(result, tmp_result);
564  DOCA_LOG_ERR("Failed to destroy DOCA mmap: %s", doca_error_get_descr(tmp_result));
565  }
566 close_device:
567  tmp_result = doca_dev_close(state->dev);
568  if (tmp_result != DOCA_SUCCESS) {
569  DOCA_ERROR_PROPAGATE(result, tmp_result);
570  DOCA_LOG_ERR("Failed to close DOCA device: %s", doca_error_get_descr(tmp_result));
571  }
572 
573  return result;
574 }
575 
577 {
578  doca_error_t result, tmp_result;
579 
581  if (result != DOCA_SUCCESS)
582  DOCA_LOG_ERR("Failed to destroy DOCA mmap: %s", doca_error_get_descr(result));
583 
584  tmp_result = doca_dev_close(state->dev);
585  if (tmp_result != DOCA_SUCCESS) {
586  DOCA_ERROR_PROPAGATE(result, tmp_result);
587  DOCA_LOG_ERR("Failed to close DOCA device: %s", doca_error_get_descr(tmp_result));
588  }
589 
590  return result;
591 }
592 
593 doca_error_t dma_task_is_supported(struct doca_devinfo *devinfo)
594 {
596 }
static doca_error_t num_dst_buf_callback(void *param, void *config)
static doca_error_t num_src_buf_callback(void *param, void *config)
char path[MAX_PATH_LEN+1]
int32_t result
#define MAX_TXT_SIZE
doca_error_t destroy_core_objects(struct program_core_objects *state)
Definition: common.c:392
doca_error_t create_core_objects(struct program_core_objects *state, uint32_t max_bufs)
Definition: common.c:302
static doca_error_t open_doca_device_with_pci(const char *pcie_value, struct doca_dev **retval)
Definition: device.c:43
doca_error_t dma_task_is_supported(struct doca_devinfo *devinfo)
Definition: dma_common.c:593
static doca_error_t pci_callback(void *param, void *config)
Definition: dma_common.c:50
doca_error_t register_dma_params(bool is_remote)
Definition: dma_common.c:204
static doca_error_t text_callback(void *param, void *config)
Definition: dma_common.c:76
doca_error_t destroy_dma_host_resources(struct program_core_objects *state)
Definition: dma_common.c:576
doca_error_t allocate_dma_host_resources(const char *pcie_addr, struct program_core_objects *state)
Definition: dma_common.c:536
DOCA_LOG_REGISTER(DMA_COMMON)
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)
Definition: dma_common.c:331
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)
Definition: dma_common.c:358
doca_error_t destroy_dma_resources(struct dma_resources *resources)
Definition: dma_common.c:513
doca_error_t allocate_dma_resources(const char *pcie_addr, int num_buf, struct dma_resources *resources)
Definition: dma_common.c:427
static void dma_state_changed_callback(const union doca_data user_data, struct doca_ctx *ctx, enum doca_ctx_states prev_state, enum doca_ctx_states next_state)
Definition: dma_common.c:387
static doca_error_t buf_info_path_callback(void *param, void *config)
Definition: dma_common.c:179
static doca_error_t descriptor_path_callback(void *param, void *config)
Definition: dma_common.c:101
#define MAX_USER_TXT_SIZE
Definition: dma_common.h:39
#define MAX_ARG_SIZE
Definition: dma_copy_core.h:39
#define NUM_DMA_TASKS
Definition: dma_copy_core.h:41
uintptr_t addr
struct rdma_resources resources
DOCA_EXPERIMENTAL void doca_argp_param_set_description(struct doca_argp_param *param, const char *description)
Set the description of the program param, used during program usage.
DOCA_EXPERIMENTAL void doca_argp_param_set_long_name(struct doca_argp_param *param, const char *name)
Set the long name of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_callback(struct doca_argp_param *param, doca_argp_param_cb_t callback)
Set the callback function of the program param.
DOCA_EXPERIMENTAL doca_error_t doca_argp_param_create(struct doca_argp_param **param)
Create new program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_type(struct doca_argp_param *param, enum doca_argp_type type)
Set the type of the param arguments.
DOCA_EXPERIMENTAL void doca_argp_param_set_short_name(struct doca_argp_param *param, const char *name)
Set the short name of the program param.
DOCA_EXPERIMENTAL doca_error_t doca_argp_register_param(struct doca_argp_param *input_param)
Register a program flag.
@ DOCA_ARGP_TYPE_STRING
Definition: doca_argp.h:56
@ DOCA_ARGP_TYPE_INT
Definition: doca_argp.h:57
DOCA_STABLE doca_error_t doca_ctx_set_state_changed_cb(struct doca_ctx *ctx, doca_ctx_state_changed_callback_t cb)
Set state changed callback.
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_ctx_states
This enum defines the states of a context.
Definition: doca_ctx.h:83
@ DOCA_CTX_STATE_STARTING
Definition: doca_ctx.h:93
@ DOCA_CTX_STATE_STOPPING
Definition: doca_ctx.h:106
@ DOCA_CTX_STATE_IDLE
Definition: doca_ctx.h:88
@ DOCA_CTX_STATE_RUNNING
Definition: doca_ctx.h:98
#define DOCA_DEVINFO_PCI_ADDR_SIZE
Buffer size to hold PCI BDF format: "XXXX:XX:XX.X". Including a null terminator.
Definition: doca_dev.h:313
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_cap_task_memcpy_get_max_buf_list_len(const struct doca_devinfo *devinfo, uint32_t *max_buf_list_len)
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)
#define DOCA_ERROR_PROPAGATE(r, t)
Save the first encountered doca_error_t.
Definition: doca_error.h:83
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_INVALID_VALUE
Definition: doca_error.h:44
@ DOCA_SUCCESS
Definition: doca_error.h:38
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
Definition: doca_log.h:466
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
Definition: doca_log.h:486
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_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 void doca_task_free(struct doca_task *task)
Free a task back to where it was allocated from.
#define MAX_USER_ARG_SIZE
Definition: pcc_core.h:45
char buf_info_path[MAX_ARG_SIZE]
Definition: dma_common.h:49
int num_dst_buf
Definition: dma_common.h:51
char export_desc_path[MAX_ARG_SIZE]
Definition: dma_common.h:48
char cpy_txt[MAX_TXT_SIZE]
Definition: dma_common.h:47
char pci_address[DOCA_DEVINFO_PCI_ADDR_SIZE]
Definition: dma_common.h:46
int num_src_buf
Definition: dma_common.h:50
struct doca_mmap * src_mmap
Definition: common.h:47
struct doca_dev * dev
Definition: common.h:46
struct doca_ctx * ctx
Definition: common.h:50
size_t num_remaining_tasks
Definition: rdma_common.h:134
bool run_pe_progress
Definition: rdma_common.h:133
Convenience type for representing opaque data.
Definition: doca_types.h:56
void * ptr
Definition: doca_types.h:57
struct upf_accel_ctx * ctx