45 struct doca_devinfo **dev_list;
47 uint8_t is_addr_equal = 0;
61 for (i = 0; i < nb_devs; i++) {
87 struct doca_dev **retval)
89 struct doca_devinfo **dev_list;
101 DOCA_LOG_ERR(
"Value size too large. Failed to locate device");
104 memcpy(val_copy,
value, val_size);
113 for (i = 0; i < nb_devs; i++) {
115 if (res ==
DOCA_SUCCESS && strncmp(buf, val_copy, val_size) == 0) {
139 struct doca_dev **retval)
141 struct doca_devinfo **dev_list;
153 DOCA_LOG_ERR(
"Value size too large. Failed to locate device");
156 memcpy(val_copy,
value, val_size);
165 for (i = 0; i < nb_devs; i++) {
167 if (res ==
DOCA_SUCCESS && strncmp(buf, val_copy, val_size) == 0) {
190 struct doca_devinfo **dev_list;
205 for (i = 0; i < nb_devs; i++) {
224 const uint8_t *
value,
226 struct doca_dev_rep **retval)
228 uint32_t nb_rdevs = 0;
229 struct doca_devinfo_rep **rep_dev_list =
NULL;
243 memcpy(val_copy,
value, val_size);
249 "Failed to create devinfo representor list. Representor devices are available only on DPU, do not run on Host");
253 for (i = 0; i < nb_rdevs; i++) {
269 const char *pci_addr,
270 struct doca_dev_rep **retval)
272 uint32_t nb_rdevs = 0;
273 struct doca_devinfo_rep **rep_dev_list =
NULL;
274 uint8_t is_addr_equal = 0;
284 "Failed to create devinfo representors list. Representor devices are available only on DPU, do not run on Host");
288 for (i = 0; i < nb_rdevs; i++) {
314 goto destroy_src_mmap;
320 goto destroy_src_mmap;
325 goto destroy_dst_mmap;
332 goto destroy_dst_mmap;
338 goto destroy_buf_inv;
345 goto destroy_buf_inv;
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;
457 const unsigned char *input_buffer;
460 num_lines = (size + 16 - 1) / 16;
461 buffer_size = num_lines * line_size + 1;
462 buffer = (
char *)malloc(buffer_size);
469 for (i = 0; i < num_lines; i++) {
471 snprintf(write_head, buffer_size,
"%08lX: ", i * 16);
473 buffer_size -= 8 + 2;
475 for (r = 0; r < 2; r++) {
476 for (j = 0; j < 8; j++) {
478 if (read_index < size) {
479 cur_char = input_buffer[read_index++];
480 snprintf(write_head, buffer_size,
"%02X ", cur_char);
482 if (
' ' <= cur_char && cur_char <=
'~')
483 printable = cur_char;
489 snprintf(write_head, buffer_size,
" ");
492 ascii_line[r * 8 + j] = printable;
497 snprintf(write_head, buffer_size,
" ");
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;
508 write_head[-1] =
'\0';
514 uint64_t remainder = (
value % alignment);
519 return value + (alignment - remainder);
528 struct doca_mmap *
mmap,
533 struct doca_buf **dbuf)
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;
543 if (buf_inv ==
NULL) {
553 if (buf_addr ==
NULL) {
574 for (i = 0; i < num_buf; i++) {
577 seg_len = other_seg_len;
587 if (set_data_pos ==
true) {
doca_error_t open_doca_device_with_pci(const char *pci_addr, tasks_check func, struct doca_dev **retval)
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)
char * hex_dump(const void *data, size_t size)
doca_error_t request_stop_ctx(struct doca_pe *pe, struct doca_ctx *ctx)
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)
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)
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)
uint64_t align_up_uint64(uint64_t value, uint64_t alignment)
doca_error_t destroy_core_objects(struct program_core_objects *state)
doca_error_t create_core_objects(struct program_core_objects *state, uint32_t max_bufs)
doca_error_t open_doca_device_with_ibdev_name(const uint8_t *value, size_t val_size, tasks_check func, struct doca_dev **retval)
doca_error_t open_doca_device_with_capabilities(tasks_check func, struct doca_dev **retval)
uint64_t align_down_uint64(uint64_t value, uint64_t alignment)
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.
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.
#define DOCA_DEVINFO_IBDEV_NAME_SIZE
Buffer size to hold Infiniband/RoCE device name. Including a null terminator.
#define DOCA_DEVINFO_REP_VUID_SIZE
Buffer size to hold VUID. Including a null terminator.
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.
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.
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
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_WARN(format,...)
Generates a WARNING application log message.
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.
doca_error_t(* tasks_check)(struct doca_devinfo *)
struct doca_mmap * src_mmap
struct doca_buf_inventory * buf_inv
struct doca_mmap * dst_mmap
struct upf_accel_ctx * ctx