68 #define EXIT_ON_FAILURE(_expression_) \
70 doca_error_t _status_ = _expression_; \
72 if (_status_ != DOCA_SUCCESS) { \
73 DOCA_LOG_ERR("%s failed with status %s", __func__, doca_error_get_descr(_status_)); \
78 #define NUM_DMA_NODES 2
80 #define NUM_GRAPH_INSTANCES 10
82 #define DMA_BUFFER_SIZE 1024
84 #define REQUIRED_ENTRY_SIZE (DMA_BUFFER_SIZE + (DMA_BUFFER_SIZE * NUM_DMA_NODES))
86 #define BUFFER_SIZE (REQUIRED_ENTRY_SIZE * NUM_GRAPH_INSTANCES)
89 #define GRAPH_INSTANCE_NUM_BUFFERS (1 + NUM_DMA_NODES)
90 #define BUF_INVENTORY_SIZE (GRAPH_INSTANCE_NUM_BUFFERS * NUM_GRAPH_INSTANCES)
254 (void)task_user_data;
346 size_t dma_length = 0;
413 (
void)graph_instance;
414 (void)instance_user_data;
456 graph_user_data.
ptr = state;
491 union doca_data graph_instance_user_data = {};
494 instance->
index = index;
533 graph_instance_user_data.
ptr = instance;
doca_error_t open_doca_device_with_capabilities(tasks_check func, struct doca_dev **retval)
static doca_error_t create_graph_instances(struct graph_sample_state *state)
#define EXIT_ON_FAILURE(_expression_)
static doca_error_t create_mmap(struct graph_sample_state *state)
static doca_error_t run(struct graph_sample_state *state)
#define BUF_INVENTORY_SIZE
#define NUM_GRAPH_INSTANCES
static void destroy_graph_instance(struct graph_sample_state *state, uint32_t index)
static doca_error_t allocate_buffer(struct graph_sample_state *state)
static void cleanup(struct graph_sample_state *state)
static void stop_contexts(struct graph_sample_state *state)
static doca_error_t start_contexts(struct graph_sample_state *state)
static void destroy_graph_instances(struct graph_sample_state *state)
static void poll_for_completion(struct graph_sample_state *state)
doca_error_t run_graph_sample(void)
static void dma_task_completed_callback(struct doca_dma_task_memcpy *task, union doca_data task_user_data, union doca_data ctx_user_data)
static doca_error_t submit_instances(struct graph_sample_state *state)
static doca_error_t create_pe(struct graph_sample_state *state)
static doca_error_t create_graph_instance(struct graph_sample_state *state, uint32_t index)
static doca_error_t user_node_callback(void *cookie)
static void destroy_graph(struct graph_sample_state *state)
static doca_error_t create_dma(struct graph_sample_state *state, uint32_t idx)
static doca_error_t create_graph(struct graph_sample_state *state)
static doca_error_t create_dmas(struct graph_sample_state *state)
static doca_error_t check_dev_dma_capable(struct doca_devinfo *devinfo)
static doca_error_t open_device(struct graph_sample_state *state)
DOCA_LOG_REGISTER(GRAPH::SAMPLE)
static doca_error_t create_buf_inventory(struct graph_sample_state *state)
static void graph_completion_callback(struct doca_graph_instance *graph_instance, union doca_data instance_user_data, union doca_data graph_user_data)
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...
static doca_error_t doca_buf_inventory_buf_get_by_data(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *data, size_t data_len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by data & data_len a...
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_inventory_stop(struct doca_buf_inventory *inventory)
Stop element retrieval from inventory.
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_get_data_len(const struct doca_buf *buf, size_t *data_len)
Get buffer's data length.
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 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_EXPERIMENTAL doca_error_t doca_graph_instance_set_ctx_node_data(struct doca_graph_instance *graph_instance, struct doca_graph_node *node, struct doca_task *task)
Set context node data.
DOCA_EXPERIMENTAL doca_error_t doca_graph_stop(struct doca_graph *graph)
Stop a graph.
DOCA_EXPERIMENTAL doca_error_t doca_graph_instance_set_user_node_data(struct doca_graph_instance *graph_instance, struct doca_graph_node *node, void *cookie)
Set user node data.
DOCA_EXPERIMENTAL doca_error_t doca_graph_instance_destroy(struct doca_graph_instance *graph_instance)
Destroy graph instance.
DOCA_EXPERIMENTAL doca_error_t doca_graph_instance_submit(struct doca_graph_instance *graph_instance)
Submit graph instance to a progress engine.
DOCA_EXPERIMENTAL doca_error_t doca_graph_create(struct doca_pe *pe, struct doca_graph **graph)
Creates a DOCA graph.
DOCA_EXPERIMENTAL doca_error_t doca_graph_set_conf(struct doca_graph *graph, doca_graph_completion_cb_t graph_completion_cb, doca_graph_completion_cb_t graph_error_cb, uint32_t num_instances)
Set graph configuration.
DOCA_EXPERIMENTAL doca_error_t doca_graph_start(struct doca_graph *graph)
Start a graph.
DOCA_EXPERIMENTAL doca_error_t doca_graph_add_dependency(struct doca_graph *graph, struct doca_graph_node *from, struct doca_graph_node *to)
Set dependencies.
DOCA_EXPERIMENTAL doca_error_t doca_graph_node_create_from_ctx(struct doca_graph *graph, const struct doca_ctx *ctx, struct doca_graph_node **node)
Create a context node.
DOCA_EXPERIMENTAL doca_error_t doca_graph_destroy(struct doca_graph *graph)
Destroys a previously created doca_graph.
DOCA_EXPERIMENTAL doca_error_t doca_graph_instance_set_user_data(struct doca_graph_instance *graph_instance, union doca_data user_data)
Set user data to the graph instance.
DOCA_EXPERIMENTAL doca_error_t doca_graph_node_create_from_user(struct doca_graph *graph, doca_graph_user_node_cb_t cb, struct doca_graph_node **node)
Create a user node.
DOCA_EXPERIMENTAL doca_error_t doca_graph_set_user_data(struct doca_graph *graph, union doca_data user_data)
Set user data to the graph.
DOCA_EXPERIMENTAL doca_error_t doca_graph_instance_create(const struct doca_graph *graph, struct doca_graph_instance **graph_instance)
Create a graph instance.
#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(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_pe_destroy(struct doca_pe *pe)
Destroy doca progress engine.
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 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
uint8_t * dma_dest_addr[NUM_DMA_NODES]
struct doca_graph_instance * graph_instance
struct doca_dma_task_memcpy * dma_task[NUM_DMA_NODES]
struct doca_buf * dma_dest[NUM_DMA_NODES]
struct doca_buf_inventory * inventory
struct doca_ctx * contexts[NUM_DMA_NODES]
uint32_t num_completed_instances
struct graph_instance_data instances[NUM_GRAPH_INSTANCES]
uint8_t * available_buffer
struct doca_dma * dma[NUM_DMA_NODES]
struct doca_graph * graph
struct doca_graph_node * user_node
struct doca_graph_node * dma_node[NUM_DMA_NODES]
Convenience type for representing opaque data.