| NVIDIA DOCA SDK | Data Center on a Chip Framework Documentation |
#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <doca_mmap.h>#include <doca_buf.h>#include <doca_buf_inventory.h>#include <doca_ctx.h>#include <doca_pe.h>#include <doca_dma.h>#include <doca_graph.h>#include <doca_types.h>#include <doca_log.h>#include <samples/common.h>
Go to the source code of this file.
Data Structures | |
| struct | graph_instance_data |
| struct | graph_sample_state |
Macros | |
| #define | EXIT_ON_FAILURE(_expression_) |
| #define | NUM_DMA_NODES 2 |
| #define | NUM_GRAPH_INSTANCES 10 |
| #define | DMA_BUFFER_SIZE 1024 |
| #define | REQUIRED_ENTRY_SIZE (DMA_BUFFER_SIZE + (DMA_BUFFER_SIZE * NUM_DMA_NODES)) |
| #define | BUFFER_SIZE (REQUIRED_ENTRY_SIZE * NUM_GRAPH_INSTANCES) |
| #define | GRAPH_INSTANCE_NUM_BUFFERS (1 + NUM_DMA_NODES) |
| #define | BUF_INVENTORY_SIZE (GRAPH_INSTANCE_NUM_BUFFERS * NUM_GRAPH_INSTANCES) |
| #define BUF_INVENTORY_SIZE (GRAPH_INSTANCE_NUM_BUFFERS * NUM_GRAPH_INSTANCES) |
Definition at line 90 of file graph_sample.c.
| #define BUFFER_SIZE (REQUIRED_ENTRY_SIZE * NUM_GRAPH_INSTANCES) |
Definition at line 86 of file graph_sample.c.
| #define DMA_BUFFER_SIZE 1024 |
Definition at line 82 of file graph_sample.c.
| #define EXIT_ON_FAILURE | ( | _expression_ | ) |
This sample creates the following graph:
+-----+ +-----+
| DMA | | DMA |
+--+--+ +-----+
| |
+---------+---------+
|
+-----------+
| User Node |
+-----------+
The DMA nodes copy one source to two destinations. The user node compares the destinations to the source. The sample uses only one type of context to simplify the code, but a graph can use any context.
The sample runs 10 graph instances and uses polling to simplify the code. This macro is used to minimize code size. The macro runs an expression and returns error if the expression status is not DOCA_SUCCESS
Definition at line 68 of file graph_sample.c.
| #define GRAPH_INSTANCE_NUM_BUFFERS (1 + NUM_DMA_NODES) |
Definition at line 89 of file graph_sample.c.
| #define NUM_DMA_NODES 2 |
Definition at line 78 of file graph_sample.c.
| #define NUM_GRAPH_INSTANCES 10 |
Definition at line 80 of file graph_sample.c.
| #define REQUIRED_ENTRY_SIZE (DMA_BUFFER_SIZE + (DMA_BUFFER_SIZE * NUM_DMA_NODES)) |
Definition at line 84 of file graph_sample.c.
|
static |
Allocates a buffer that will be used for the source and destination buffers.
@state [in]: sample state
Definition at line 150 of file graph_sample.c.
|
static |
Definition at line 169 of file graph_sample.c.
|
static |
This method cleans up the sample resources in reverse order of their creation. This method does not check for destroy return values for simplify. Real code should check the return value and act accordingly.
@state [in]: sample state
Definition at line 612 of file graph_sample.c.
|
static |
Create buffer inventory, initialize and start it.
@state [in]: sample state
Definition at line 229 of file graph_sample.c.
|
static |
Create DMA
@state [in]: sample state @idx [in]: context index
Definition at line 265 of file graph_sample.c.
|
static |
Create DMAs
@state [in]: sample state
Definition at line 288 of file graph_sample.c.
|
static |
This method creates the graph. Creating a node adds it to the graph roots. Adding dependency removes a dependent node from the graph roots. The method creates all nodes and then adds the dependency out of convenience. Adding dependency during node creation is supported.
@state [in]: sample state
Definition at line 431 of file graph_sample.c.
|
static |
This method creates a graph instance Graph instance creation usually includes initializing the data for the nodes (e.g. initializing tasks).
@state [in]: sample state @index [in]: the graph instance index
Definition at line 487 of file graph_sample.c.
|
static |
Create graph instances
@state [in]: sample state
Definition at line 545 of file graph_sample.c.
|
static |
Create MMAP, initialize and start it.
@state [in]: sample state
Definition at line 210 of file graph_sample.c.
|
static |
Creates a progress engine
@state [in]: sample state
Definition at line 195 of file graph_sample.c.
|
static |
|
static |
Destroy graph instance
@state [in]: sample state @index [in]: the graph instance index
Definition at line 373 of file graph_sample.c.
|
static |
|
static |
DMA task completed callback
: This method is used as a mandatory input for the doca_dma_task_memcpy_set_conf but will never be called because task completion callbacks are not invoked when the task is submitted to a graph.
@task [in]: DMA task @task_user_data [in]: Task user data @ctx_user_data [in]: context user data
Definition at line 249 of file graph_sample.c.
| DOCA_LOG_REGISTER | ( | GRAPH::SAMPLE | ) |
|
static |
This method processes a graph instance completion. The sample does not care if the instance was successful or failed and will act the same way on both cases.
@graph_instance [in]: completed graph instance @instance_user_data [in]: graph instance user data @graph_user_data [in]: graph user data
Definition at line 408 of file graph_sample.c.
|
static |
Opens a device that supports DMA
@state [in]: sample state
Definition at line 180 of file graph_sample.c.
|
static |
Poll the work queue until all instances are completed
@state [in]: sample state
Definition at line 593 of file graph_sample.c.
|
static |
Run the sample The method (and the method it calls) does not cleanup anything in case of failures. It assumes that cleanup is called after it at any case.
@state [in]: sample state
Definition at line 654 of file graph_sample.c.
| doca_error_t run_graph_sample | ( | void | ) |
Run the graph sample
Definition at line 676 of file graph_sample.c.
|
static |
Start contexts The method adds the device to the contexts, starts them and add them to the work queue.
@state [in]: sample state
Definition at line 305 of file graph_sample.c.
|
static |
Stop contexts The method removes the contexts from the work queue, stops them and removes the device from them.
@state [in]: sample state
Definition at line 323 of file graph_sample.c.
|
static |
Submit graph instances
@state [in]: sample state
Definition at line 576 of file graph_sample.c.
|
static |
User node callback This callback is called when the graph user node is executed. The callback compares the source buffer to the destination buffers.
@cookie [in]: callback cookie
Definition at line 341 of file graph_sample.c.