NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
dpa_basic_initiator_target_kernels_dev.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 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 #include <doca_dpa_dev.h>
27 #include <doca_dpa_dev_rdma.h>
28 #include <doca_dpa_dev_buf.h>
29 #include "../common/dpa_basic_initiator_target_common_defs.h"
30 
42 __dpa_global__ void thread_kernel(uint64_t arg)
43 {
44  DOCA_DPA_DEV_LOG_INFO("%s: Hello from Thread\n", __func__);
45 
46  struct dpa_thread_arg *thread_arg = (struct dpa_thread_arg *)arg;
47 
48  if (thread_arg->dpa_ctx_handle) {
50  }
51 
52  DOCA_DPA_DEV_LOG_INFO("%s: Read completion info\n", __func__);
54  int found = doca_dpa_dev_get_completion(thread_arg->dpa_comp_handle, &comp_element);
55  DOCA_DPA_DEV_LOG_INFO("%s: doca_dpa_dev_get_completion() returned %d\n", __func__, found);
56 
57  if (found) {
58  DOCA_DPA_DEV_LOG_INFO("%s: doca_dpa_dev_get_completion_type() returned %d\n",
59  __func__,
60  doca_dpa_dev_get_completion_type(comp_element));
61  DOCA_DPA_DEV_LOG_INFO("%s: doca_dpa_dev_get_completion_user_data() returned %u\n",
62  __func__,
64 
65  DOCA_DPA_DEV_LOG_INFO("%s: Value of DPA received buffer is %lu\n",
66  __func__,
67  *((uint64_t *)(thread_arg->local_buf_addr)));
68  }
69 
70  DOCA_DPA_DEV_LOG_INFO("%s: Set sync event to %lu\n", __func__, *((uint64_t *)(thread_arg->local_buf_addr)));
71  doca_dpa_dev_sync_event_update_set(thread_arg->sync_event_handle, *((uint64_t *)(thread_arg->local_buf_addr)));
72 
73  DOCA_DPA_DEV_LOG_INFO("%s: Finish\n", __func__);
75 }
76 
89 __dpa_rpc__ uint64_t rdma_post_receive_rpc(doca_dpa_dev_t rdma_dpa_ctx_handle,
93  size_t length)
94 {
95  DOCA_DPA_DEV_LOG_INFO("%s: Post RDMA receive on DPA Mmap handle %u, address 0x%lx, length %lu\n",
96  __func__,
99  length);
100  if (rdma_dpa_ctx_handle) {
101  doca_dpa_dev_device_set(rdma_dpa_ctx_handle);
102  }
104 
105  return 0;
106 }
107 
120 __dpa_rpc__ uint64_t rdma_post_send_rpc(doca_dpa_dev_t rdma_dpa_ctx_handle,
121  doca_dpa_dev_rdma_t rdma,
124  size_t length)
125 {
126  DOCA_DPA_DEV_LOG_INFO("%s: Post RDMA send on DPA Mmap handle %u, address 0x%lx, length %lu\n",
127  __func__,
130  length);
131  if (rdma_dpa_ctx_handle) {
132  doca_dpa_dev_device_set(rdma_dpa_ctx_handle);
133  }
135  0,
138  length,
140 
141  return 0;
142 }
__dpa_rpc__ uint64_t rdma_post_send_rpc(doca_dpa_dev_t rdma_dpa_ctx_handle, doca_dpa_dev_rdma_t rdma, uintptr_t local_buf_addr, doca_dpa_dev_mmap_t dpa_mmap_handle, size_t length)
RPC function to post RDMA send operation.
__dpa_rpc__ uint64_t rdma_post_receive_rpc(doca_dpa_dev_t rdma_dpa_ctx_handle, doca_dpa_dev_rdma_t rdma, doca_dpa_dev_uintptr_t local_buf_addr, doca_dpa_dev_mmap_t dpa_mmap_handle, size_t length)
RPC function to post RDMA receive operation.
__dpa_global__ void thread_kernel(uint64_t arg)
Kernel function for DPA thread.
uint32_t dpa_mmap_handle
struct dpa_thread_arg __dpa_global__
DOCA_EXPERIMENTAL void doca_dpa_dev_rdma_post_receive(doca_dpa_dev_rdma_t rdma, doca_dpa_dev_mmap_t mmap_handle, uint64_t addr, size_t length)
Post an RDMA receive operation.
DOCA_EXPERIMENTAL void doca_dpa_dev_rdma_post_send(doca_dpa_dev_rdma_t rdma, uint32_t connection_id, doca_dpa_dev_mmap_t mmap_handle, uint64_t addr, size_t length, uint32_t flags)
Post an RDMA send operation.
DOCA_EXPERIMENTAL void doca_dpa_dev_sync_event_update_set(doca_dpa_dev_sync_event_t dpa_dev_se_handle, uint64_t value)
Set the counter of a DOCA Sync Event to a given value.
DOCA_EXPERIMENTAL void doca_dpa_dev_device_set(doca_dpa_dev_t dpa_handle)
Set a DPA device.
DOCA_EXPERIMENTAL void doca_dpa_dev_thread_finish(void)
Finish a DPA thread.
DOCA_EXPERIMENTAL uint32_t doca_dpa_dev_get_completion_user_data(doca_dpa_dev_completion_element_t comp_element)
Get completion element user data.
__dpa_global__ typedef uint64_t doca_dpa_dev_completion_element_t
DPA completion element handle type definition.
Definition: doca_dpa_dev.h:77
#define DOCA_DPA_DEV_LOG_INFO(...)
Generate a DOCA DPA device INFO log message.
Definition: doca_dpa_dev.h:287
DOCA_EXPERIMENTAL doca_dpa_dev_completion_type_t doca_dpa_dev_get_completion_type(doca_dpa_dev_completion_element_t comp_element)
Get completion element type.
DOCA_EXPERIMENTAL int doca_dpa_dev_get_completion(doca_dpa_dev_completion_t dpa_comp_handle, doca_dpa_dev_completion_element_t *comp_element)
Get DPA completion element.
@ DOCA_DPA_DEV_SUBMIT_FLAG_OPTIMIZE_REPORTS
Definition: doca_dpa_dev.h:113
@ DOCA_DPA_DEV_SUBMIT_FLAG_FLUSH
Definition: doca_dpa_dev.h:106
uint64_t doca_dpa_dev_t
DPA context handle type definition.
Definition: doca_dpa.h:73
uint64_t doca_dpa_dev_uintptr_t
DPA pointer type definition.
Definition: doca_dpa.h:78
uint32_t doca_dpa_dev_mmap_t
Handle on the DPA for a doca_mmap instance.
Definition: doca_mmap.h:74
uint64_t doca_dpa_dev_rdma_t
Definition: doca_rdma.h:79
__UINTPTR_TYPE__ uintptr_t
Definition: stdint.h:298
DPA thread device argument struct.