NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
pe_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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 #ifndef PE_COMMON_H_
27 #define PE_COMMON_H_
28 
29 #include <doca_ctx.h>
30 #include <doca_dma.h>
31 
39  struct doca_dev *device;
40  struct doca_mmap *mmap;
41  struct doca_buf_inventory *inventory;
42  struct doca_pe *pe;
43 
44  size_t buffer_size;
46 
52  uint8_t *buffer;
53  uint8_t *available_buffer; /* Points to the available location in the buffer, used during initialization */
54 
55  /* Common state */
57 };
58 
59 /*
60  * Process completed task
61  *
62  * @dma_task [in]: Completed task
63  * @expected_value [in]: Expected value in the destination.
64  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
65  */
66 doca_error_t process_completed_dma_memcpy_task(struct doca_dma_task_memcpy *dma_task, uint8_t expected_value);
67 
68 /*
69  * Free task buffers
70  *
71  * @dma_task [in]: task
72  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
73  */
74 doca_error_t free_dma_memcpy_task_buffers(struct doca_dma_task_memcpy *dma_task);
75 
76 /*
77  * Free DMA task
78  *
79  * @dma_task [in]: task
80  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
81  */
82 doca_error_t dma_task_free(struct doca_dma_task_memcpy *dma_task);
83 
91 
104  struct doca_dma *dma,
105  uint32_t num_tasks,
106  size_t dma_buffer_size,
107  struct doca_dma_task_memcpy **tasks);
108 
116 doca_error_t submit_dma_tasks(uint32_t num_tasks, struct doca_dma_task_memcpy **tasks);
117 
125 
133 
141 
149 
157 doca_error_t poll_for_completion(struct pe_sample_state_base *state, uint32_t num_tasks);
158 
167 void pe_sample_base_cleanup(struct pe_sample_state_base *state);
168 
169 #endif /* PE_COMMON_H_ */
enum doca_error doca_error_t
DOCA API return codes.
void pe_sample_base_cleanup(struct pe_sample_state_base *state)
Definition: pe_common.c:311
doca_error_t allocate_buffer(struct pe_sample_state_base *state)
Definition: pe_common.c:131
doca_error_t create_buf_inventory(struct pe_sample_state_base *state)
Definition: pe_common.c:294
doca_error_t dma_task_free(struct doca_dma_task_memcpy *dma_task)
Definition: pe_common.c:108
doca_error_t create_mmap(struct pe_sample_state_base *state)
Definition: pe_common.c:275
doca_error_t free_dma_memcpy_task_buffers(struct doca_dma_task_memcpy *dma_task)
Definition: pe_common.c:93
doca_error_t submit_dma_tasks(uint32_t num_tasks, struct doca_dma_task_memcpy **tasks)
Definition: pe_common.c:211
doca_error_t poll_for_completion(struct pe_sample_state_base *state, uint32_t num_tasks)
Definition: pe_common.c:340
doca_error_t create_pe(struct pe_sample_state_base *state)
Definition: pe_common.c:260
doca_error_t open_device(struct pe_sample_state_base *state)
Definition: pe_common.c:245
doca_error_t allocate_dma_tasks(struct pe_sample_state_base *state, struct doca_dma *dma, uint32_t num_tasks, size_t dma_buffer_size, struct doca_dma_task_memcpy **tasks)
Definition: pe_common.c:155
doca_error_t process_completed_dma_memcpy_task(struct doca_dma_task_memcpy *dma_task, uint8_t expected_value)
Definition: pe_common.c:66
uint8_t * available_buffer
Definition: pe_common.h:53
struct doca_dev * device
Definition: pe_common.h:39
size_t buf_inventory_size
Definition: pe_common.h:45
uint8_t * buffer
Definition: pe_common.h:52
struct doca_buf_inventory * inventory
Definition: pe_common.h:41
struct doca_mmap * mmap
Definition: pe_common.h:40
struct doca_pe * pe
Definition: pe_common.h:42
uint32_t num_completed_tasks
Definition: pe_common.h:56