NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
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 <stdint.h>
27 #include <stdlib.h>
28 #include <string.h>
29 
30 #include <doca_buf.h>
31 #include <doca_buf_inventory.h>
32 #include <doca_ctx.h>
33 #include <doca_dev.h>
34 #include <doca_error.h>
35 #include <doca_log.h>
36 #include <doca_mmap.h>
37 #include <doca_pe.h>
38 
39 #include "common.h"
40 
42 
43 doca_error_t open_doca_device_with_pci(const char *pci_addr, tasks_check func, struct doca_dev **retval)
44 {
45  struct doca_devinfo **dev_list;
46  uint32_t nb_devs;
47  uint8_t is_addr_equal = 0;
48  int res;
49  size_t i;
50 
51  /* Set default return value */
52  *retval = NULL;
53 
54  res = doca_devinfo_create_list(&dev_list, &nb_devs);
55  if (res != DOCA_SUCCESS) {
56  DOCA_LOG_ERR("Failed to load doca devices list: %s", doca_error_get_descr(res));
57  return res;
58  }
59 
60  /* Search */
61  for (i = 0; i < nb_devs; i++) {
62  res = doca_devinfo_is_equal_pci_addr(dev_list[i], pci_addr, &is_addr_equal);
63  if (res == DOCA_SUCCESS && is_addr_equal) {
64  /* If any special capabilities are needed */
65  if (func != NULL && func(dev_list[i]) != DOCA_SUCCESS)
66  continue;
67 
68  /* if device can be opened */
69  res = doca_dev_open(dev_list[i], retval);
70  if (res == DOCA_SUCCESS) {
71  doca_devinfo_destroy_list(dev_list);
72  return res;
73  }
74  }
75  }
76 
77  DOCA_LOG_WARN("Matching device not found");
79 
80  doca_devinfo_destroy_list(dev_list);
81  return res;
82 }
83 
85  size_t val_size,
86  tasks_check func,
87  struct doca_dev **retval)
88 {
89  struct doca_devinfo **dev_list;
90  uint32_t nb_devs;
91  char buf[DOCA_DEVINFO_IBDEV_NAME_SIZE] = {};
92  char val_copy[DOCA_DEVINFO_IBDEV_NAME_SIZE] = {};
93  int res;
94  size_t i;
95 
96  /* Set default return value */
97  *retval = NULL;
98 
99  /* Setup */
100  if (val_size > DOCA_DEVINFO_IBDEV_NAME_SIZE) {
101  DOCA_LOG_ERR("Value size too large. Failed to locate device");
103  }
104  memcpy(val_copy, value, val_size);
105 
106  res = doca_devinfo_create_list(&dev_list, &nb_devs);
107  if (res != DOCA_SUCCESS) {
108  DOCA_LOG_ERR("Failed to load doca devices list: %s", doca_error_get_descr(res));
109  return res;
110  }
111 
112  /* Search */
113  for (i = 0; i < nb_devs; i++) {
115  if (res == DOCA_SUCCESS && strncmp(buf, val_copy, val_size) == 0) {
116  /* If any special capabilities are needed */
117  if (func != NULL && func(dev_list[i]) != DOCA_SUCCESS)
118  continue;
119 
120  /* if device can be opened */
121  res = doca_dev_open(dev_list[i], retval);
122  if (res == DOCA_SUCCESS) {
123  doca_devinfo_destroy_list(dev_list);
124  return res;
125  }
126  }
127  }
128 
129  DOCA_LOG_WARN("Matching device not found");
130  res = DOCA_ERROR_NOT_FOUND;
131 
132  doca_devinfo_destroy_list(dev_list);
133  return res;
134 }
135 
137  size_t val_size,
138  tasks_check func,
139  struct doca_dev **retval)
140 {
141  struct doca_devinfo **dev_list;
142  uint32_t nb_devs;
143  char buf[DOCA_DEVINFO_IFACE_NAME_SIZE] = {};
144  char val_copy[DOCA_DEVINFO_IFACE_NAME_SIZE] = {};
145  int res;
146  size_t i;
147 
148  /* Set default return value */
149  *retval = NULL;
150 
151  /* Setup */
152  if (val_size > DOCA_DEVINFO_IFACE_NAME_SIZE) {
153  DOCA_LOG_ERR("Value size too large. Failed to locate device");
155  }
156  memcpy(val_copy, value, val_size);
157 
158  res = doca_devinfo_create_list(&dev_list, &nb_devs);
159  if (res != DOCA_SUCCESS) {
160  DOCA_LOG_ERR("Failed to load doca devices list: %s", doca_error_get_descr(res));
161  return res;
162  }
163 
164  /* Search */
165  for (i = 0; i < nb_devs; i++) {
167  if (res == DOCA_SUCCESS && strncmp(buf, val_copy, val_size) == 0) {
168  /* If any special capabilities are needed */
169  if (func != NULL && func(dev_list[i]) != DOCA_SUCCESS)
170  continue;
171 
172  /* if device can be opened */
173  res = doca_dev_open(dev_list[i], retval);
174  if (res == DOCA_SUCCESS) {
175  doca_devinfo_destroy_list(dev_list);
176  return res;
177  }
178  }
179  }
180 
181  DOCA_LOG_WARN("Matching device not found");
182  res = DOCA_ERROR_NOT_FOUND;
183 
184  doca_devinfo_destroy_list(dev_list);
185  return res;
186 }
187 
189 {
190  struct doca_devinfo **dev_list;
191  uint32_t nb_devs;
193  size_t i;
194 
195  /* Set default return value */
196  *retval = NULL;
197 
198  result = doca_devinfo_create_list(&dev_list, &nb_devs);
199  if (result != DOCA_SUCCESS) {
200  DOCA_LOG_ERR("Failed to load doca devices list: %s", doca_error_get_descr(result));
201  return result;
202  }
203 
204  /* Search */
205  for (i = 0; i < nb_devs; i++) {
206  /* If any special capabilities are needed */
207  if (func(dev_list[i]) != DOCA_SUCCESS)
208  continue;
209 
210  /* If device can be opened */
211  if (doca_dev_open(dev_list[i], retval) == DOCA_SUCCESS) {
212  doca_devinfo_destroy_list(dev_list);
213  return DOCA_SUCCESS;
214  }
215  }
216 
217  DOCA_LOG_WARN("Matching device not found");
218  doca_devinfo_destroy_list(dev_list);
219  return DOCA_ERROR_NOT_FOUND;
220 }
221 
223  enum doca_devinfo_rep_filter filter,
224  const uint8_t *value,
225  size_t val_size,
226  struct doca_dev_rep **retval)
227 {
228  uint32_t nb_rdevs = 0;
229  struct doca_devinfo_rep **rep_dev_list = NULL;
230  char val_copy[DOCA_DEVINFO_REP_VUID_SIZE] = {};
231  char buf[DOCA_DEVINFO_REP_VUID_SIZE] = {};
233  size_t i;
234 
235  /* Set default return value */
236  *retval = NULL;
237 
238  /* Setup */
239  if (val_size > DOCA_DEVINFO_REP_VUID_SIZE) {
240  DOCA_LOG_ERR("Value size too large. Ignored");
242  }
243  memcpy(val_copy, value, val_size);
244 
245  /* Search */
246  result = doca_devinfo_rep_create_list(local, filter, &rep_dev_list, &nb_rdevs);
247  if (result != DOCA_SUCCESS) {
248  DOCA_LOG_ERR(
249  "Failed to create devinfo representor list. Representor devices are available only on DPU, do not run on Host");
251  }
252 
253  for (i = 0; i < nb_rdevs; i++) {
255  if (result == DOCA_SUCCESS && strncmp(buf, val_copy, DOCA_DEVINFO_REP_VUID_SIZE) == 0 &&
256  doca_dev_rep_open(rep_dev_list[i], retval) == DOCA_SUCCESS) {
257  doca_devinfo_rep_destroy_list(rep_dev_list);
258  return DOCA_SUCCESS;
259  }
260  }
261 
262  DOCA_LOG_WARN("Matching device not found");
263  doca_devinfo_rep_destroy_list(rep_dev_list);
264  return DOCA_ERROR_NOT_FOUND;
265 }
266 
268  enum doca_devinfo_rep_filter filter,
269  const char *pci_addr,
270  struct doca_dev_rep **retval)
271 {
272  uint32_t nb_rdevs = 0;
273  struct doca_devinfo_rep **rep_dev_list = NULL;
274  uint8_t is_addr_equal = 0;
276  size_t i;
277 
278  *retval = NULL;
279 
280  /* Search */
281  result = doca_devinfo_rep_create_list(local, filter, &rep_dev_list, &nb_rdevs);
282  if (result != DOCA_SUCCESS) {
283  DOCA_LOG_ERR(
284  "Failed to create devinfo representors list. Representor devices are available only on DPU, do not run on Host");
286  }
287 
288  for (i = 0; i < nb_rdevs; i++) {
289  result = doca_devinfo_rep_is_equal_pci_addr(rep_dev_list[i], pci_addr, &is_addr_equal);
290  if (result == DOCA_SUCCESS && is_addr_equal &&
291  doca_dev_rep_open(rep_dev_list[i], retval) == DOCA_SUCCESS) {
292  doca_devinfo_rep_destroy_list(rep_dev_list);
293  return DOCA_SUCCESS;
294  }
295  }
296 
297  DOCA_LOG_WARN("Matching device not found");
298  doca_devinfo_rep_destroy_list(rep_dev_list);
299  return DOCA_ERROR_NOT_FOUND;
300 }
301 
302 doca_error_t create_core_objects(struct program_core_objects *state, uint32_t max_bufs)
303 {
304  doca_error_t res;
305 
306  res = doca_mmap_create(&state->src_mmap);
307  if (res != DOCA_SUCCESS) {
308  DOCA_LOG_ERR("Unable to create source mmap: %s", doca_error_get_descr(res));
309  return res;
310  }
311  res = doca_mmap_add_dev(state->src_mmap, state->dev);
312  if (res != DOCA_SUCCESS) {
313  DOCA_LOG_ERR("Unable to add device to source mmap: %s", doca_error_get_descr(res));
314  goto destroy_src_mmap;
315  }
316 
317  res = doca_mmap_create(&state->dst_mmap);
318  if (res != DOCA_SUCCESS) {
319  DOCA_LOG_ERR("Unable to create destination mmap: %s", doca_error_get_descr(res));
320  goto destroy_src_mmap;
321  }
322  res = doca_mmap_add_dev(state->dst_mmap, state->dev);
323  if (res != DOCA_SUCCESS) {
324  DOCA_LOG_ERR("Unable to add device to destination mmap: %s", doca_error_get_descr(res));
325  goto destroy_dst_mmap;
326  }
327 
328  if (max_bufs != 0) {
329  res = doca_buf_inventory_create(max_bufs, &state->buf_inv);
330  if (res != DOCA_SUCCESS) {
331  DOCA_LOG_ERR("Unable to create buffer inventory: %s", doca_error_get_descr(res));
332  goto destroy_dst_mmap;
333  }
334 
335  res = doca_buf_inventory_start(state->buf_inv);
336  if (res != DOCA_SUCCESS) {
337  DOCA_LOG_ERR("Unable to start buffer inventory: %s", doca_error_get_descr(res));
338  goto destroy_buf_inv;
339  }
340  }
341 
342  res = doca_pe_create(&state->pe);
343  if (res != DOCA_SUCCESS) {
344  DOCA_LOG_ERR("Unable to create progress engine: %s", doca_error_get_descr(res));
345  goto destroy_buf_inv;
346  }
347 
348  return DOCA_SUCCESS;
349 
350 destroy_buf_inv:
351  if (state->buf_inv != NULL) {
353  state->buf_inv = NULL;
354  }
355 
356 destroy_dst_mmap:
357  doca_mmap_destroy(state->dst_mmap);
358  state->dst_mmap = NULL;
359 
360 destroy_src_mmap:
361  doca_mmap_destroy(state->src_mmap);
362  state->src_mmap = NULL;
363 
364  return res;
365 }
366 
367 doca_error_t request_stop_ctx(struct doca_pe *pe, struct doca_ctx *ctx)
368 {
369  doca_error_t tmp_result, result = DOCA_SUCCESS;
370 
371  tmp_result = doca_ctx_stop(ctx);
372  if (tmp_result == DOCA_ERROR_IN_PROGRESS) {
373  enum doca_ctx_states ctx_state;
374 
375  do {
376  (void)doca_pe_progress(pe);
377  tmp_result = doca_ctx_get_state(ctx, &ctx_state);
378  if (tmp_result != DOCA_SUCCESS) {
379  DOCA_ERROR_PROPAGATE(result, tmp_result);
380  DOCA_LOG_ERR("Failed to get state from ctx: %s", doca_error_get_descr(tmp_result));
381  break;
382  }
383  } while (ctx_state != DOCA_CTX_STATE_IDLE);
384  } else if (tmp_result != DOCA_SUCCESS) {
385  DOCA_ERROR_PROPAGATE(result, tmp_result);
386  DOCA_LOG_ERR("Failed to stop ctx: %s", doca_error_get_descr(tmp_result));
387  }
388 
389  return result;
390 }
391 
393 {
394  doca_error_t tmp_result, result = DOCA_SUCCESS;
395 
396  if (state->pe != NULL) {
397  tmp_result = doca_pe_destroy(state->pe);
398  if (tmp_result != DOCA_SUCCESS) {
399  DOCA_ERROR_PROPAGATE(result, tmp_result);
400  DOCA_LOG_ERR("Failed to destroy pe: %s", doca_error_get_descr(tmp_result));
401  }
402  state->pe = NULL;
403  }
404 
405  if (state->buf_inv != NULL) {
406  tmp_result = doca_buf_inventory_destroy(state->buf_inv);
407  if (tmp_result != DOCA_SUCCESS) {
408  DOCA_ERROR_PROPAGATE(result, tmp_result);
409  DOCA_LOG_ERR("Failed to destroy buf inventory: %s", doca_error_get_descr(tmp_result));
410  }
411  state->buf_inv = NULL;
412  }
413 
414  if (state->dst_mmap != NULL) {
415  tmp_result = doca_mmap_destroy(state->dst_mmap);
416  if (tmp_result != DOCA_SUCCESS) {
417  DOCA_ERROR_PROPAGATE(result, tmp_result);
418  DOCA_LOG_ERR("Failed to destroy destination mmap: %s", doca_error_get_descr(tmp_result));
419  }
420  state->dst_mmap = NULL;
421  }
422 
423  if (state->src_mmap != NULL) {
424  tmp_result = doca_mmap_destroy(state->src_mmap);
425  if (tmp_result != DOCA_SUCCESS) {
426  DOCA_ERROR_PROPAGATE(result, tmp_result);
427  DOCA_LOG_ERR("Failed to destroy source mmap: %s", doca_error_get_descr(tmp_result));
428  }
429  state->src_mmap = NULL;
430  }
431 
432  if (state->dev != NULL) {
433  tmp_result = doca_dev_close(state->dev);
434  if (tmp_result != DOCA_SUCCESS) {
435  DOCA_ERROR_PROPAGATE(result, tmp_result);
436  DOCA_LOG_ERR("Failed to close device: %s", doca_error_get_descr(tmp_result));
437  }
438  state->dev = NULL;
439  }
440 
441  return result;
442 }
443 
444 char *hex_dump(const void *data, size_t size)
445 {
446  /*
447  * <offset>: <Hex bytes: 1-8> <Hex bytes: 9-16> <Ascii>
448  * 00000000: 31 32 33 34 35 36 37 38 39 30 61 62 63 64 65 66 1234567890abcdef
449  * 8 2 8 * 3 1 8 * 3 1 16 1
450  */
451  const size_t line_size = 8 + 2 + 8 * 3 + 1 + 8 * 3 + 1 + 16 + 1;
452  size_t i, j, r, read_index;
453  size_t num_lines, buffer_size;
454  char *buffer, *write_head;
455  unsigned char cur_char, printable;
456  char ascii_line[17];
457  const unsigned char *input_buffer;
458 
459  /* Allocate a dynamic buffer to hold the full result */
460  num_lines = (size + 16 - 1) / 16;
461  buffer_size = num_lines * line_size + 1;
462  buffer = (char *)malloc(buffer_size);
463  if (buffer == NULL)
464  return NULL;
465  write_head = buffer;
466  input_buffer = data;
467  read_index = 0;
468 
469  for (i = 0; i < num_lines; i++) {
470  /* Offset */
471  snprintf(write_head, buffer_size, "%08lX: ", i * 16);
472  write_head += 8 + 2;
473  buffer_size -= 8 + 2;
474  /* Hex print - 2 chunks of 8 bytes */
475  for (r = 0; r < 2; r++) {
476  for (j = 0; j < 8; j++) {
477  /* If there is content to print */
478  if (read_index < size) {
479  cur_char = input_buffer[read_index++];
480  snprintf(write_head, buffer_size, "%02X ", cur_char);
481  /* Printable chars go "as-is" */
482  if (' ' <= cur_char && cur_char <= '~')
483  printable = cur_char;
484  /* Otherwise, use a '.' */
485  else
486  printable = '.';
487  /* Else, just use spaces */
488  } else {
489  snprintf(write_head, buffer_size, " ");
490  printable = ' ';
491  }
492  ascii_line[r * 8 + j] = printable;
493  write_head += 3;
494  buffer_size -= 3;
495  }
496  /* Spacer between the 2 hex groups */
497  snprintf(write_head, buffer_size, " ");
498  write_head += 1;
499  buffer_size -= 1;
500  }
501  /* Ascii print */
502  ascii_line[16] = '\0';
503  snprintf(write_head, buffer_size, "%s\n", ascii_line);
504  write_head += 16 + 1;
505  buffer_size -= 16 + 1;
506  }
507  /* No need for the last '\n' */
508  write_head[-1] = '\0';
509  return buffer;
510 }
511 
512 uint64_t align_up_uint64(uint64_t value, uint64_t alignment)
513 {
514  uint64_t remainder = (value % alignment);
515 
516  if (remainder == 0)
517  return value;
518 
519  return value + (alignment - remainder);
520 }
521 
522 uint64_t align_down_uint64(uint64_t value, uint64_t alignment)
523 {
524  return value - (value % alignment);
525 }
526 
527 doca_error_t allocat_doca_buf_list(struct doca_buf_inventory *buf_inv,
528  struct doca_mmap *mmap,
529  void *buf_addr,
530  size_t buf_len,
531  int num_buf,
532  bool set_data_pos,
533  struct doca_buf **dbuf)
534 {
535  int i = 0;
536  size_t other_seg_len = buf_len / num_buf;
537  size_t first_seg_len = other_seg_len + (buf_len % num_buf);
539  struct doca_buf *tmp_dbuf = NULL;
540  size_t seg_len = first_seg_len;
541  void *seg_addr = buf_addr;
542 
543  if (buf_inv == NULL) {
545  DOCA_LOG_ERR("Invalid value found, doca_buf_inventory is NULL: %s", doca_error_get_descr(result));
546  return result;
547  }
548  if (mmap == NULL) {
550  DOCA_LOG_ERR("Invalid value found, doca_mmap is NULL: %s", doca_error_get_descr(result));
551  return result;
552  }
553  if (buf_addr == NULL) {
555  DOCA_LOG_ERR("Invalid value found, buf_addr is NULL: %s", doca_error_get_descr(result));
556  return result;
557  }
558  if (buf_len == 0) {
560  DOCA_LOG_ERR("Invalid value found, buf_len is 0: %s", doca_error_get_descr(result));
561  return result;
562  }
563  if (num_buf <= 0) {
565  DOCA_LOG_ERR("Invalid value found, num_buf is <= 0: %s", doca_error_get_descr(result));
566  return result;
567  }
568  if (dbuf == NULL) {
570  DOCA_LOG_ERR("Invalid value found, dbuf is NULL: %s", doca_error_get_descr(result));
571  return result;
572  }
573 
574  for (i = 0; i < num_buf; i++) {
575  if (i > 0) {
576  seg_addr += seg_len;
577  seg_len = other_seg_len;
578  if (seg_len == 0) {
579  break;
580  }
581  }
582  result = doca_buf_inventory_buf_get_by_addr(buf_inv, mmap, seg_addr, seg_len, &tmp_dbuf);
583  if (result != DOCA_SUCCESS) {
584  DOCA_LOG_ERR("Unable to acquire DOCA buffer: %s", doca_error_get_descr(result));
585  return result;
586  }
587  if (set_data_pos == true) {
588  result = doca_buf_set_data(tmp_dbuf, seg_addr, seg_len);
589  if (result != DOCA_SUCCESS) {
590  DOCA_LOG_ERR("Failed to set data for DOCA buffer: %s", doca_error_get_descr(result));
591  return result;
592  }
593  }
594  if (i == 0) {
595  *dbuf = tmp_dbuf;
596  } else {
597  result = doca_buf_chain_list(*dbuf, tmp_dbuf);
598  if (result != DOCA_SUCCESS) {
599  DOCA_LOG_ERR("Failed to construct doca_buf chain: %s", doca_error_get_descr(result));
600  return result;
601  }
602  }
603  }
604 
605  return result;
606 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
doca_error_t open_doca_device_with_pci(const char *pci_addr, tasks_check func, struct doca_dev **retval)
Definition: common.c:43
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)
Definition: common.c:527
char * hex_dump(const void *data, size_t size)
Definition: common.c:444
doca_error_t request_stop_ctx(struct doca_pe *pe, struct doca_ctx *ctx)
Definition: common.c:367
doca_error_t open_doca_device_rep_with_vuid(struct doca_dev *local, enum doca_devinfo_rep_filter filter, const uint8_t *value, size_t val_size, struct doca_dev_rep **retval)
Definition: common.c:222
DOCA_LOG_REGISTER(COMMON)
doca_error_t open_doca_device_with_iface_name(const uint8_t *value, size_t val_size, tasks_check func, struct doca_dev **retval)
Definition: common.c:136
doca_error_t open_doca_device_rep_with_pci(struct doca_dev *local, enum doca_devinfo_rep_filter filter, const char *pci_addr, struct doca_dev_rep **retval)
Definition: common.c:267
uint64_t align_up_uint64(uint64_t value, uint64_t alignment)
Definition: common.c:512
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
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
doca_error_t open_doca_device_with_capabilities(tasks_check func, struct doca_dev **retval)
Definition: common.c:188
uint64_t align_down_uint64(uint64_t value, uint64_t alignment)
Definition: common.c:522
doca_dpa_dev_mmap_t mmap
static struct doca_pe * pe
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_chain_list(struct doca_buf *list1, struct doca_buf *list2)
Append list2 to list1.
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_get_state(const struct doca_ctx *ctx, enum doca_ctx_states *state)
Get context state.
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_IDLE
Definition: doca_ctx.h:88
DOCA_STABLE doca_error_t doca_devinfo_is_equal_pci_addr(const struct doca_devinfo *devinfo, const char *pci_addr_str, uint8_t *is_equal)
Check if a PCI address belongs to a DOCA devinfo.
DOCA_STABLE doca_error_t doca_dev_rep_open(struct doca_devinfo_rep *devinfo, struct doca_dev_rep **dev_rep)
Initialize representor device for use.
DOCA_STABLE doca_error_t doca_devinfo_rep_destroy_list(struct doca_devinfo_rep **dev_list_rep)
Destroy list of representor device info structures.
DOCA_STABLE doca_error_t doca_devinfo_rep_create_list(struct doca_dev *dev, int filter, struct doca_devinfo_rep ***dev_list_rep, uint32_t *nb_devs_rep)
Create list of available representor devices accessible by dev.
DOCA_STABLE doca_error_t doca_devinfo_create_list(struct doca_devinfo ***dev_list, uint32_t *nb_devs)
Creates list of all available local devices.
DOCA_STABLE doca_error_t doca_devinfo_rep_get_vuid(const struct doca_devinfo_rep *devinfo_rep, char *rep_vuid, uint32_t size)
Get the Vendor Unique ID of a representor DOCA devinfo.
DOCA_STABLE doca_error_t doca_devinfo_get_ibdev_name(const struct doca_devinfo *devinfo, char *ibdev_name, uint32_t size)
Get the name of the IB device represented by a DOCA devinfo.
doca_devinfo_rep_filter
Definition: doca_dev.h:65
#define DOCA_DEVINFO_IBDEV_NAME_SIZE
Buffer size to hold Infiniband/RoCE device name. Including a null terminator.
Definition: doca_dev.h:309
#define DOCA_DEVINFO_REP_VUID_SIZE
Buffer size to hold VUID. Including a null terminator.
Definition: doca_dev.h:661
DOCA_STABLE doca_error_t doca_devinfo_destroy_list(struct doca_devinfo **dev_list)
Destroy list of local device info structures.
DOCA_STABLE doca_error_t doca_dev_open(struct doca_devinfo *devinfo, struct doca_dev **dev)
Initialize local device for use.
#define DOCA_DEVINFO_IFACE_NAME_SIZE
Buffer size to hold network interface name. Including a null terminator.
Definition: doca_dev.h:305
DOCA_STABLE doca_error_t doca_devinfo_rep_is_equal_pci_addr(const struct doca_devinfo_rep *devinfo_rep, const char *pci_addr_str, uint8_t *is_equal)
Check if a PCI address belongs to a DOCA devinfo_rep.
DOCA_STABLE doca_error_t doca_devinfo_get_iface_name(const struct doca_devinfo *devinfo, char *iface_name, uint32_t size)
Get the name of the ethernet interface of a DOCA devinfo.
DOCA_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
#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_ERROR_NOT_FOUND
Definition: doca_error.h:54
@ DOCA_SUCCESS
Definition: doca_error.h:38
@ DOCA_ERROR_IN_PROGRESS
Definition: doca_error.h:64
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
Definition: doca_log.h:466
#define DOCA_LOG_WARN(format,...)
Generates a WARNING application log message.
Definition: doca_log.h:476
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_pe_destroy(struct doca_pe *pe)
Destroy doca 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.
type value
doca_error_t(* tasks_check)(struct doca_devinfo *)
Definition: common.h:42
struct doca_pe * pe
Definition: common.h:51
struct doca_mmap * src_mmap
Definition: common.h:47
struct doca_buf_inventory * buf_inv
Definition: common.h:49
struct doca_dev * dev
Definition: common.h:46
struct doca_mmap * dst_mmap
Definition: common.h:48
struct upf_accel_ctx * ctx