NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
devemu_pci_device_dma_dpu_sample.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 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 <devemu_pci_common.h>
27 
28 #include <signal.h>
29 #include <stdbool.h>
30 #include <stdint.h>
31 #include <string.h>
32 #include <time.h>
33 
34 #include <doca_ctx.h>
35 #include <doca_devemu_pci.h>
36 #include <doca_dev.h>
37 #include <doca_error.h>
38 #include <doca_log.h>
39 #include <doca_dma.h>
40 #include <doca_buf.h>
41 #include <doca_buf_inventory.h>
42 #include <common.h>
43 
44 DOCA_LOG_REGISTER(DEVEMU_PCI_DEVICE_DMA_DPU);
45 
46 #define NUM_DMA_TASKS (1) /* DMA tasks number */
47 #define MEM_BUF_LEN (4 * 1024) /* Mem buffer size. It's the same as Host side */
48 
49 struct dma_resources {
50  struct devemu_resources devemu_res; /* DOCA devemu resources*/
51  struct doca_dma *dma_ctx; /* DOCA DMA context */
52  struct doca_mmap *remote_mmap; /* DOCA mmap for remote buffer */
53  struct doca_mmap *local_mmap; /* DOCA mmap for local buffer */
54  struct doca_buf_inventory *buf_inv; /* DOCA buffer inventory */
55  struct doca_dev *dma_dev; /* Dma device */
56  char *local_mem_buf; /* Local memory buf for DMA operation */
57  size_t num_remaining_tasks; /* Number of remaining tasks to process */
58 };
59 
60 /*
61  * DMA Memcpy task completed callback
62  *
63  * @dma_task [in]: Completed task
64  * @task_user_data [in]: doca_data from the task
65  * @ctx_user_data [in]: doca_data from the context
66  */
67 static void dma_memcpy_completed_callback(struct doca_dma_task_memcpy *dma_task,
68  union doca_data task_user_data,
69  union doca_data ctx_user_data)
70 {
71  struct dma_resources *resources = (struct dma_resources *)ctx_user_data.ptr;
72  doca_error_t *result = (doca_error_t *)task_user_data.ptr;
73 
74  /* Assign success to the result */
76  DOCA_LOG_INFO("DMA task was completed successfully");
77 
78  /* Free task */
80  /* Decrement number of remaining tasks */
82 }
83 
84 /*
85  * Memcpy task error callback
86  *
87  * @dma_task [in]: failed task
88  * @task_user_data [in]: doca_data from the task
89  * @ctx_user_data [in]: doca_data from the context
90  */
91 static void dma_memcpy_error_callback(struct doca_dma_task_memcpy *dma_task,
92  union doca_data task_user_data,
93  union doca_data ctx_user_data)
94 {
95  struct dma_resources *resources = (struct dma_resources *)ctx_user_data.ptr;
96  struct doca_task *task = doca_dma_task_memcpy_as_task(dma_task);
97  doca_error_t *result = (doca_error_t *)task_user_data.ptr;
98 
99  /* Get the result of the task */
100  *result = doca_task_get_status(task);
101  DOCA_LOG_ERR("DMA task failed: %s", doca_error_get_descr(*result));
102 
103  /* Free task */
104  doca_task_free(task);
105  /* Decrement number of remaining tasks */
107 }
108 
117 {
119  if (max_bufs != 0) {
120  result = doca_buf_inventory_create(max_bufs, &resources->buf_inv);
121  if (result != DOCA_SUCCESS) {
122  DOCA_LOG_ERR("Unable to create buffer inventory: %s", doca_error_get_descr(result));
123  return result;
124  }
125 
127  if (result != DOCA_SUCCESS) {
128  DOCA_LOG_ERR("Unable to start buffer inventory: %s", doca_error_get_descr(result));
129  return result;
130  }
131  }
132  return result;
133 }
134 
135 /*
136  * Function to check DMA device capabilities
137  *
138  * @devinfo [in]: DMA device info
139  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
140  */
141 static doca_error_t dma_device_caps_is_supported(struct doca_devinfo *devinfo)
142 {
144 
145  uint8_t supported = 0;
146  result = doca_devemu_pci_cap_is_mmap_add_dev_supported((const struct doca_devinfo *)devinfo, &supported);
147  if (result != DOCA_SUCCESS || supported == 0)
149 
150  return doca_dma_cap_task_memcpy_is_supported((const struct doca_devinfo *)devinfo);
151 }
152 
160 static doca_error_t setup_dma_ctx(struct dma_resources *resources, const char *devemu_name)
161 {
163  union doca_data ctx_user_data = {0};
164  struct doca_ctx *ctx;
165 
166  /* If device name wasn't provided, use the device emulation's device */
167  if (*devemu_name == 0) {
168  result = doca_dev_open(doca_dev_as_devinfo(resources->devemu_res.dev), &(resources->dma_dev));
169  if (result != DOCA_SUCCESS) {
170  DOCA_LOG_ERR("Failed to open DOCA device: %s", doca_error_get_descr(result));
171  return result;
172  }
173  } else {
174  /* Open DOCA device */
175  result = open_doca_device_with_ibdev_name((const uint8_t *)(devemu_name),
176  strlen(devemu_name),
178  &(resources->dma_dev));
179  if (result != DOCA_SUCCESS) {
180  DOCA_LOG_ERR("Failed to open DOCA device: %s", doca_error_get_descr(result));
181  return result;
182  }
183  }
184 
185  result = doca_dma_create(resources->dma_dev, &resources->dma_ctx);
186  if (result != DOCA_SUCCESS) {
187  DOCA_LOG_ERR("Failed to create DMA context: %s", doca_error_get_descr(result));
188  return result;
189  }
190  ctx = doca_dma_as_ctx(resources->dma_ctx);
191 
195  NUM_DMA_TASKS);
196  if (result != DOCA_SUCCESS) {
197  DOCA_LOG_ERR("Failed to set configurations for DMA memcpy task: %s", doca_error_get_descr(result));
198  return result;
199  }
200 
201  /* Include resources in user data of context to be used in callbacks */
202  ctx_user_data.ptr = resources;
203  result = doca_ctx_set_user_data(ctx, ctx_user_data);
204  if (result != DOCA_SUCCESS) {
205  DOCA_LOG_ERR("Unable to set context user data: %s", doca_error_get_descr(result));
206  return result;
207  }
208 
209  result = doca_pe_connect_ctx(resources->devemu_res.pe, ctx);
210  if (result != DOCA_SUCCESS) {
211  DOCA_LOG_ERR("Failed to connect progress engine to context: %s", doca_error_get_descr(result));
212  return result;
213  }
214 
216  if (result != DOCA_SUCCESS) {
217  DOCA_LOG_ERR("Failed to start context: %s", doca_error_get_descr(result));
218  return result;
219  }
220 
221  return result;
222 }
223 
233 {
236  if (result != DOCA_SUCCESS) {
237  DOCA_LOG_ERR("Failed to create mmap for devemu pci device: %s", doca_error_get_descr(result));
238  return result;
239  }
240 
242  if (result != DOCA_SUCCESS) {
243  DOCA_LOG_ERR("Failed to set max_num devices: %s", doca_error_get_descr(result));
244  return result;
245  }
246 
248  if (result != DOCA_SUCCESS) {
249  DOCA_LOG_ERR("Failed to add device: %s", doca_error_get_descr(result));
250  return result;
251  }
252 
254  if (result != DOCA_SUCCESS) {
255  DOCA_LOG_ERR("Failed to set permission: %s", doca_error_get_descr(result));
256  return result;
257  }
258 
260  if (result != DOCA_SUCCESS) {
261  DOCA_LOG_ERR("Failed to set dst_mmap range: %s", doca_error_get_descr(result));
262  return result;
263  }
264 
266  if (result != DOCA_SUCCESS) {
267  DOCA_LOG_ERR("Failed to start remote mmap: %s", doca_error_get_descr(result));
268  return result;
269  }
270 
271  return result;
272 }
273 
282 static doca_error_t setup_local_mmap(struct dma_resources *resources, char *buf, int len)
283 {
285  result = doca_mmap_create(&resources->local_mmap);
286  if (result != DOCA_SUCCESS) {
287  DOCA_LOG_ERR("Unable to create destination mmap: %s", doca_error_get_descr(result));
288  return result;
289  }
290 
291  result = doca_mmap_add_dev(resources->local_mmap, resources->dma_dev);
292  if (result != DOCA_SUCCESS) {
293  DOCA_LOG_ERR("Unable to add device to destination mmap: %s", doca_error_get_descr(result));
294  return result;
295  }
296 
297  result = doca_mmap_set_memrange(resources->local_mmap, buf, len);
298  if (result != DOCA_SUCCESS) {
299  DOCA_LOG_ERR("Failed to set dst_mmap range: %s", doca_error_get_descr(result));
300  return result;
301  }
302 
303  result = doca_mmap_start(resources->local_mmap);
304  if (result != DOCA_SUCCESS) {
305  DOCA_LOG_ERR("Failed to create dst_mmap: %s", doca_error_get_descr(result));
306  return result;
307  }
308  return DOCA_SUCCESS;
309 }
310 
323  int len,
324  struct doca_mmap *src_mmap,
325  void *src_addr,
326  struct doca_mmap *dst_mmap,
327  void *dst_addr)
328 {
329  doca_error_t result, task_result;
330  struct doca_buf *src_doca_buf, *dst_doca_buf;
331  union doca_data task_user_data = {0};
332  struct doca_task *task;
333  struct doca_dma_task_memcpy *dma_task;
334  struct timespec ts = {
335  .tv_sec = 0,
336  .tv_nsec = SLEEP_IN_NANOS,
337  };
338 
339  result = doca_buf_inventory_buf_get_by_addr(resources->buf_inv, src_mmap, src_addr, len, &src_doca_buf);
340  if (result != DOCA_SUCCESS) {
341  DOCA_LOG_ERR("Unable to acquire DOCA buffer representing src buffer: %s", doca_error_get_descr(result));
342  return result;
343  }
344 
345  result = doca_buf_inventory_buf_get_by_addr(resources->buf_inv, dst_mmap, dst_addr, len, &dst_doca_buf);
346  if (result != DOCA_SUCCESS) {
347  DOCA_LOG_ERR("Unable to acquire DOCA buffer representing dst buffer: %s", doca_error_get_descr(result));
348  goto destroy_src_buf;
349  }
350 
351  task_user_data.ptr = &task_result;
353  src_doca_buf,
354  dst_doca_buf,
355  task_user_data,
356  &dma_task);
357  if (result != DOCA_SUCCESS) {
358  DOCA_LOG_ERR("Failed to allocate DMA memcpy task: %s", doca_error_get_descr(result));
359  goto destroy_dst_buf;
360  }
361 
363  task = doca_dma_task_memcpy_as_task(dma_task);
364 
365  result = doca_buf_set_data(src_doca_buf, src_addr, len);
366  if (result != DOCA_SUCCESS) {
367  DOCA_LOG_ERR("Failed to set data for DOCA buffer: %s", doca_error_get_descr(result));
368  goto cleanup_dma_task;
369  }
370 
371  result = doca_task_submit(task);
372  if (result != DOCA_SUCCESS) {
373  DOCA_LOG_ERR("Failed to submit DMA task: %s", doca_error_get_descr(result));
374  goto cleanup_dma_task;
375  }
376 
377  /* Wait DMA done */
378  while (resources->num_remaining_tasks != 0) {
379  if (doca_pe_progress(resources->devemu_res.pe) == 0)
380  nanosleep(&ts, &ts);
381  }
382  result = task_result;
383  goto destroy_dst_buf;
384 
385 cleanup_dma_task:
386  doca_task_free(task);
387 destroy_dst_buf:
388  doca_buf_dec_refcount(dst_doca_buf, NULL);
389 destroy_src_buf:
390  doca_buf_dec_refcount(src_doca_buf, NULL);
391 
392  return result;
393 }
394 
395 /*
396  * Setup devemu resources
397  *
398  * @resources [in]: General resources of DOCA devemu PCI
399  * @pci_address [in]: Device PCI address
400  * @emulated_dev_vuid [in]: VUID of the emulated device
401  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
402  */
404  const char *pci_address,
405  const char *emulated_dev_vuid)
406 {
408  const char pci_type_name[DOCA_DEVEMU_PCI_TYPE_NAME_LEN] = PCI_TYPE_NAME;
409 
411  if (result != DOCA_SUCCESS) {
412  DOCA_LOG_ERR("Unable to create progress engine: %s", doca_error_get_descr(result));
413  return result;
414  }
415 
416  result = doca_devemu_pci_type_create(pci_type_name, &resources->pci_type);
417  if (result != DOCA_SUCCESS) {
418  DOCA_LOG_ERR("Unable to create PCI type: %s", doca_error_get_descr(result));
419  return result;
420  }
421 
422  result = find_supported_device(pci_address,
423  resources->pci_type,
425  &resources->dev);
426  if (result != DOCA_SUCCESS)
427  return result;
428 
429  /* Set PCIe configuration space values */
431  if (result != DOCA_SUCCESS)
432  return result;
433 
434  /* Find existing emulated device */
435  result = find_emulated_device(resources->pci_type, emulated_dev_vuid, &resources->rep);
436  if (result != DOCA_SUCCESS) {
437  DOCA_LOG_ERR("Unable to find PCI emulated device representor: %s", doca_error_get_descr(result));
438  return result;
439  }
440 
441  /* Create emulated device context */
443  if (result != DOCA_SUCCESS) {
444  DOCA_LOG_ERR("Unable to create PCI emulated device context: %s", doca_error_get_descr(result));
445  return result;
446  }
447 
449  if (result != DOCA_SUCCESS) {
450  DOCA_LOG_ERR("Unable to start PCI emulated device context: %s", doca_error_get_descr(result));
451  return result;
452  }
453 
454  /* Defer assignment so that cleanup does not stop the context in case it was not started */
456 
457  return DOCA_SUCCESS;
458 }
459 
460 /*
461  * Cleanup DMA resources
462  *
463  * @resources [in]: DMA sample resources
464  */
466 {
467  doca_error_t res;
468 
469  if (resources->buf_inv != NULL) {
470  res = doca_buf_inventory_destroy(resources->buf_inv);
471  if (res != DOCA_SUCCESS)
472  DOCA_LOG_ERR("Failed to destroy DOCA buffer inventory: %s", doca_error_get_descr(res));
473  resources->buf_inv = NULL;
474  }
475 
476  if (resources->local_mmap != NULL) {
477  res = doca_mmap_stop(resources->local_mmap);
478  if (res != DOCA_SUCCESS)
479  DOCA_LOG_ERR("Failed to stop local mmap: %s", doca_error_get_descr(res));
480  }
481 
482  if (resources->local_mmap != NULL) {
483  res = doca_mmap_destroy(resources->local_mmap);
484  if (res != DOCA_SUCCESS)
485  DOCA_LOG_ERR("Failed to destroy local mmap: %s", doca_error_get_descr(res));
486  resources->local_mmap = NULL;
487  }
488 
489  if (resources->local_mem_buf != NULL) {
490  free(resources->local_mem_buf);
491  resources->local_mem_buf = NULL;
492  }
493 
494  if (resources->remote_mmap != NULL) {
496  if (res != DOCA_SUCCESS)
497  DOCA_LOG_ERR("Failed to stop remote mmap: %s", doca_error_get_descr(res));
498  }
499 
500  if (resources->remote_mmap != NULL) {
502  if (res != DOCA_SUCCESS)
503  DOCA_LOG_ERR("Failed to destroy remote mmap: %s", doca_error_get_descr(res));
505  }
506 
507  if (resources->dma_ctx != NULL) {
508  res = doca_ctx_stop(doca_dma_as_ctx(resources->dma_ctx));
509  if (res != DOCA_SUCCESS)
510  DOCA_LOG_ERR("Failed to stop dma ctx: %s", doca_error_get_descr(res));
511  }
512 
513  if (resources->dma_ctx != NULL) {
514  res = doca_dma_destroy(resources->dma_ctx);
515  if (res != DOCA_SUCCESS)
516  DOCA_LOG_ERR("Failed to destroy dma ctx: %s", doca_error_get_descr(res));
517  resources->dma_ctx = NULL;
518  }
519 
520  if (resources->dma_dev != NULL) {
521  res = doca_dev_close(resources->dma_dev);
522  if (res != DOCA_SUCCESS)
523  DOCA_LOG_ERR("Failed to destroy dma device: %s", doca_error_get_descr(res));
524  resources->dma_dev = NULL;
525  }
526 
527  devemu_resources_cleanup(&resources->devemu_res, false);
528 }
529 
530 /*
531  * Run DOCA Device Emulation DMA DPU sample
532  *
533  * @pci_address [in]: DMA device PCI address
534  * @devemu_name [in]: Device emulation manager name
535  * @emulated_dev_vuid [in]: VUID of the emulated device
536  * @host_dma_mem_iova [in]: Host DMA memory IOVA
537  * @write_data [in]: Data write to host memory
538  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
539  */
540 doca_error_t devemu_pci_device_dma_dpu(const char *pci_address,
541  const char *devemu_name,
542  const char *emulated_dev_vuid,
543  uint64_t host_dma_mem_iova,
544  const char *write_data)
545 {
547  struct dma_resources resources = {0};
548  size_t len = MEM_BUF_LEN;
549  void *remote_addr = (void *)host_dma_mem_iova;
550 
551  result = setup_devemu_resources(&resources.devemu_res, pci_address, emulated_dev_vuid);
552  if (result != DOCA_SUCCESS) {
553  return result;
554  }
555 
556  result = setup_dma_ctx(&resources, devemu_name);
557  if (result != DOCA_SUCCESS) {
558  DOCA_LOG_ERR("Unable to setup dma ctx: %s", doca_error_get_descr(result));
560  return result;
561  }
562 
563  result = setup_remote_mmap(&resources, remote_addr, len);
564  if (result != DOCA_SUCCESS) {
565  DOCA_LOG_ERR("Unable to setup remote mmap: %s", doca_error_get_descr(result));
567  return result;
568  }
569 
570  resources.local_mem_buf = (char *)calloc(1, len);
571  if (resources.local_mem_buf == NULL) {
572  DOCA_LOG_ERR("Failed to allocate memory");
575  return result;
576  }
577 
578  result = setup_local_mmap(&resources, resources.local_mem_buf, len);
579  if (result != DOCA_SUCCESS) {
580  DOCA_LOG_ERR("Unable to setup remote mmap: %s", doca_error_get_descr(result));
582  return result;
583  }
584 
586  if (result != DOCA_SUCCESS) {
587  DOCA_LOG_ERR("Unable to allocated buf inventory: %s", doca_error_get_descr(result));
589  return result;
590  }
591 
592  /* DMA read data from host */
594  len,
596  remote_addr,
597  resources.local_mmap,
598  resources.local_mem_buf);
599  if (result != DOCA_SUCCESS) {
600  DOCA_LOG_ERR("Failed to DMA read data from host: %s", doca_error_get_descr(result));
602  return result;
603  }
604  DOCA_LOG_INFO("Success, DMA memory copied from host: %s", resources.local_mem_buf);
605 
606  /* DMA write data to host (if any)*/
607  if (strnlen(write_data, MEM_BUF_LEN) > 0) {
608  strncpy(resources.local_mem_buf, write_data, MEM_BUF_LEN);
610  len,
611  resources.local_mmap,
612  resources.local_mem_buf,
614  remote_addr);
615  if (result != DOCA_SUCCESS) {
616  DOCA_LOG_ERR("Failed to DMA write data to host: %s", doca_error_get_descr(result));
618  return result;
619  }
620  DOCA_LOG_INFO("Success, DMA memory copied to host: %s", resources.local_mem_buf);
621  }
622 
624  return result;
625 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
#define SLEEP_IN_NANOS
Definition: comch_utils.c:40
doca_error_t open_doca_device_with_ibdev_name(const uint8_t *value, size_t val_size, tasks_check func, struct doca_dev **retval)
Definition: common.c:84
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)
#define PCI_TYPE_NAME
uint64_t len
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
Definition: doca_error.h:42
@ DOCA_SUCCESS
Definition: doca_error.h:38
@ DOCA_ERROR_NO_MEMORY
Definition: doca_error.h:45
#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_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
Definition: doca_types.h:83
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)
uint32_t src_addr
Definition: packets.h:8
uint32_t dst_addr
Definition: packets.h:9
struct doca_mmap * remote_mmap
struct doca_buf_inventory * buf_inv
struct devemu_resources devemu_res
struct doca_mmap * remote_mmap
Definition: rdma_common.h:113
size_t num_remaining_tasks
Definition: rdma_common.h:134
struct doca_pe * pe
Definition: rdma_common.h:86
Convenience type for representing opaque data.
Definition: doca_types.h:56
void * ptr
Definition: doca_types.h:57
struct upf_accel_ctx * ctx