| NVIDIA DOCA SDK | Data Center on a Chip Framework Documentation |

Typedefs | |
| typedef void(* | doca_graph_completion_cb_t) (struct doca_graph_instance *instance, union doca_data instance_user_data, union doca_data graph_user_data) |
| Graph completion callback. More... | |
| typedef doca_error_t(* | doca_graph_user_node_cb_t) (void *cookie) |
| User node callback. More... | |
Functions | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_create (struct doca_pe *pe, struct doca_graph **graph) |
| Creates a DOCA graph. More... | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_destroy (struct doca_graph *graph) |
| Destroys a previously created doca_graph. More... | |
| 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. More... | |
| 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. More... | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_get_user_data (const struct doca_graph *graph, union doca_data *user_data) |
| Set user data to the graph. More... | |
| 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. More... | |
| 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. More... | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_node_create_from_graph (struct doca_graph *graph, struct doca_graph *sub_graph, struct doca_graph_node **node) |
| Create a sub graph node. More... | |
| 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. More... | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_start (struct doca_graph *graph) |
| Start a graph. More... | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_stop (struct doca_graph *graph) |
| Stop a graph. More... | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_instance_create (const struct doca_graph *graph, struct doca_graph_instance **graph_instance) |
| Create a graph instance. More... | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_instance_destroy (struct doca_graph_instance *graph_instance) |
| Destroy graph instance. More... | |
| 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. More... | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_instance_get_user_data (const struct doca_graph_instance *graph_instance, union doca_data *user_data) |
| Set user data to the graph instance. More... | |
| 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. More... | |
| 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. More... | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_instance_set_sub_graph_node_data (struct doca_graph_instance *graph_instance, struct doca_graph_node *node, struct doca_graph_instance *sub_graph_instance) |
| Set sub graph node data. More... | |
| DOCA_EXPERIMENTAL doca_error_t | doca_graph_instance_submit (struct doca_graph_instance *graph_instance) |
| Submit graph instance to a progress engine. More... | |
DOCA graph facilitates submitting an ordered set of tasks and user callbacks. A graph can contain nodes of the following types:
Graph Instance A graph creates a graph instance (or more) Every node in the graph instance is set with corresponding data (task, callback, etc. depending on the type of the node). Node data can be set during runtime, but it is not recommended. Application should instead change the task content.
Usage:
Notes
Graph implementation example: This example builds a graph with 2 nodes, creates an instance and submits it to a progress engine. node1 -> node2 The example is focused on the graph API. It does not include progress engine, contexts creation etc. or error handling.
Create the graph and connect it to a progress engine. struct doca_graph *my_graph; doca_graph_create(pe, &my_graph); doca_graph_set_conf(my_graph, graph_completion_cb, graph_error_cb, log_num_instances);
Create the nodes struct doca_graph_node *node1, node2; doca_graph_node_create_from_ctx(my_graph, ctx1, &node1); doca_graph_node_create_from_ctx(my_graph, ctx2, &node2);
Set dependency (node1 -> node2) doca_graph_add_dependency(my_graph, node1, node2);
Start the graph doca_graph_start(my_graph);
Create a graph instance and set nodes data struct doca_graph_instance *my_graph_instance doca_graph_instance_create(my_graph, &my_graph_instance); doca_graph_instance_set_ctx_node_data(my_graph_instance, node1, &node_1_task); doca_graph_instance_set_ctx_node_data(my_graph_instance, node2, &node_2_task);
Submit the graph instance to the progress engine doca_graph_instance_submit(my_graph_instance);
Call progress one to tick the progress engine until graph is completed (graph instance completed callback will be invoked). doca_pe_progress(pe);
Resubmit instance Set tasks parameters if required. doca_graph_instance_submit(my_graph_instance);
| typedef void(* doca_graph_completion_cb_t) (struct doca_graph_instance *instance, union doca_data instance_user_data, union doca_data graph_user_data) |
Graph completion callback.
| [in] | instance | Graph instance that was completed. |
| [in] | instance_user_data | Graph instance user data |
| [in] | graph_user_data | Graph user data |
Definition at line 138 of file doca_graph.h.
| typedef doca_error_t(* doca_graph_user_node_cb_t) (void *cookie) |
User node callback.
Definition of a user node callback.
| [in] | cookie | A cookie set to the node ( |
Definition at line 277 of file doca_graph.h.
| 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.
This method adds a dependent node to a node. Node dependency can only be set before the graph is started. Setting dependency must not form a circle in the graph
| [in] | graph | The graph that both from node and to node reside in. |
| [in] | from | Node to depend on |
| [in] | to | Node that depends on the from node |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_create | ( | struct doca_pe * | pe, |
| struct doca_graph ** | graph | ||
| ) |
Creates a DOCA graph.
This method creates an empty doca_graph.
| [in] | pe | Progress engine to bind the graph to |
| [out] | graph | The created graph. The application is expected to destroy the graph when it is no longer needed ( |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_destroy | ( | struct doca_graph * | graph | ) |
Destroys a previously created doca_graph.
A DOCA graph can be destroyed only if it was stopped
| [in] | graph | The graph to destroy |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_get_user_data | ( | const struct doca_graph * | graph, |
| union doca_data * | user_data | ||
| ) |
Set user data to the graph.
| [in] | graph | The graph to set the user data to |
| [out] | user_data | user data to get |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_instance_create | ( | const struct doca_graph * | graph, |
| struct doca_graph_instance ** | graph_instance | ||
| ) |
Create a graph instance.
This method creates a graph instance. Graph instance contains the nodes data (tasks, callbacks, sub graphs, etc.) and is submitted to a progress engine to be executed. A graph must be started before it can create an instance.
| [in] | graph | Graph to create the instance from. |
| [out] | graph_instance | Instance created by the graph. |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_instance_destroy | ( | struct doca_graph_instance * | graph_instance | ) |
Destroy graph instance.
This method destroys a graph instance A graph instance can not be destroyed if it is submitted or if it is set as a sub graph node data.
| [in] | graph_instance | Graph instance to destroy |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_instance_get_user_data | ( | const struct doca_graph_instance * | graph_instance, |
| union doca_data * | user_data | ||
| ) |
Set user data to the graph instance.
| [in] | graph_instance | The graph instance to set the user data to |
| [out] | user_data | user data to get |
| 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.
This method sets context node data (task). It is recommended to set the node data once and change the task content (if required) every instance run.
| [in] | graph_instance | Graph instance to set the node data to |
| [in] | node | Graph node that facilitates setting the data to the correct node in the instance.
|
| [in] | task | doca_task to set to the node. The task context must match the context of the graph node. task lifespan must be >= to the lifespan of the graph instance. Task callbacks (completed & error) are not invoked when used in a graph. |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_instance_set_sub_graph_node_data | ( | struct doca_graph_instance * | graph_instance, |
| struct doca_graph_node * | node, | ||
| struct doca_graph_instance * | sub_graph_instance | ||
| ) |
Set sub graph node data.
This method sets sub graph node data It is recommended to set the node data once and change the task content (if required) every instance run.
| [in] | graph_instance | Graph instance to set the node data to |
| [in] | node | Graph node that facilitates setting the data to the correct node in the instance.
|
| [in] | sub_graph_instance | Graph instance to be run by the node. – Instance must be created by the graph that the sub graph node was created with. – Instance must not be submitted. |
| 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.
| [in] | graph_instance | The graph instance to set the user data to |
| [in] | user_data | doca_data to attach to the graph instance |
| 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.
This method sets user node data It is recommended to set the node data once and change the task content (if required) every instance run.
| [in] | graph_instance | Graph instance to set the node data to |
| [in] | node | Graph node that facilitates setting the data to the correct node in the instance.
|
| [in] | cookie | cookie supplied by the application (passed to the callback when it is executes). |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_instance_submit | ( | struct doca_graph_instance * | graph_instance | ) |
Submit graph instance to a progress engine.
This method submits a graph instance to a progress engine Graph submission executes the graph root nodes. A submitted graph can't be aborted or flushed.
| [in] | graph_instance | The graph instance to submit |
| 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.
This method creates a context node (A node that points to a context and contains a doca_task for the context) A node is automatically added to the graph as a root when it is created A node can only be added before the graph is started.
| [in] | graph | The graph to add the node to. |
| [in] | ctx | Context to run the task. |
| [out] | node | Reference to the created graph node. The node shall be used to set dependencies and set node data. A node does not need to be destroyed by the application. |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_node_create_from_graph | ( | struct doca_graph * | graph, |
| struct doca_graph * | sub_graph, | ||
| struct doca_graph_node ** | node | ||
| ) |
Create a sub graph node.
This method creates a sub graph node (a node that points to a doca_graph). A node is automatically added to the graph as a root when it is created A node can only be added before the graph is started. Sub graph must not form a circle with the graph that it is added to (e.g. Graph A -> Graph B -> Graph A)
| [in] | graph | The graph to add the node to. |
| [in] | sub_graph | Graph to be executed as a sub graph. |
| [out] | node | Reference to the created graph node. The node shall be used to set dependencies and set node data. A node does not need to be destroyed by the application. |
| 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.
This method creates a user node (A node that points to a callback supplied by the user and contains a user defined doca_task.) A node is automatically added to the graph as a root when it is created A node can only be added before the graph is started.
| [in] | graph | The graph to add the node to. |
| [in] | cb | Callback to be called when the node is executed |
| [out] | node | Reference to the created graph node. The node shall be used to set dependencies and set node data. A node does not need to be destroyed by the application. |
| 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.
| [in] | graph | DOCA graph to config |
| [in] | graph_completion_cb | Graph completion callback. Invoked when a graph instance is completed successfully. |
| [in] | graph_error_cb | Graph error callback. Invoked when a graph instance fails. |
| [in] | num_instances | Number of the instances that the graph can allocate. |
| 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.
| [in] | graph | The graph to set the user data to |
| [in] | user_data | doca_data to attach to the graph instance |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_start | ( | struct doca_graph * | graph | ) |
Start a graph.
This method starts a graph. A doca_graph can only be used after it was started (
| [in] | graph | Graph to start |
| DOCA_EXPERIMENTAL doca_error_t doca_graph_stop | ( | struct doca_graph * | graph | ) |
Stop a graph.
This method stops a graph. A graph can be stopped only after all the instances created by it were destroyed.
| [in] | graph | Graph to stop |