NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
worker_rdmo.h
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 #ifndef WORKER_RDMO_H_
27 #define WORKER_RDMO_H_
28 
29 #include <doca_log.h>
30 #include <doca_error.h>
31 
32 #include <ucp/api/ucp.h>
33 #include <ucs/datastruct/khash.h>
34 #include <ucs/datastruct/list.h>
35 #include <ucs/datastruct/mpool.h>
36 
37 #include <doca_urom_plugin.h>
38 
39 #define UROM_RDMO_AM_ID 0 /* RDMO AM id */
40 #define UROM_RDMO_HDR_LEN_MAX 64 /* Must fit struct urom_rdmo_hdr and urom_rdmo_xxx_hdr_t */
41 
42 /* RDMO UCP data structure */
43 struct ucp_data {
44  ucp_context_h ucp_context; /* UCP context */
45  ucp_worker_h ucp_worker; /* UCP worker instance */
46  ucp_address_t *worker_address; /* UCP worker address */
47  size_t ucp_addrlen; /* UCP worker address length */
48 };
49 
50 /* RDMO EP structure */
52  ucp_ep_h ep; /* UCP ep structure */
53  uint64_t peer_uid; /* Peer id */
54  int ref_cnt; /* Reference counter */
55  ucs_list_link_t fenced_ops; /* Fenced ops list */
56  int oreqs; /* Operation requests number */
57 };
58 
59 /* Init RDMO endpoints UCX map */
61 
62 /* RDMO RQ structure */
64  uint64_t id; /* RQ id */
65  struct urom_worker_rdmo_ep *ep; /* RQ's end-point */
66 };
67 
68 /* Init RDMO RQs map */
70 
71 /* Init RDMO RQs memory cache */
72 KHASH_MAP_INIT_INT64(mem_cache, uint64_t);
73 
74 /* RDMO memory key structure */
76  ucp_rkey_h ucp_rkey; /* UCP remote key */
77  ucp_mem_h ucp_memh; /* UCP memory handle */
78  khash_t(mem_cache) * mem_cache; /* Memory cache */
79  uint64_t va; /* Host memory address */
80  size_t len; /* Data length */
81 };
82 
83 /* Init RDMO mkey map */
85 
86 /* RDMO client structure */
88  struct urom_worker_rdmo *rdmo_worker; /* RDMO worker context */
89  uint64_t id; /* Client id */
90  uint64_t dest_id; /* Destination id */
91  struct urom_worker_rdmo_ep *ep; /* Host memory access EP */
92  khash_t(rq) * rqs; /* Initiator connections */
93  uint64_t next_rq_id; /* Next request id */
94  khash_t(mkey) * mkeys; /* Registered memory regions */
95  ucs_list_link_t paused_ops; /* Paused operations list */
96  int pause; /* If client is paused */
97  uint64_t get_result; /* Client result */
98 };
99 
100 /* Init RDMO clients map */
102 
103 /* RDMO request structure */
104 struct urom_worker_rdmo_req;
105 
106 /* RDMO request ops structure */
108  doca_error_t (*progress)(struct urom_worker_rdmo_req *req); /* RDMO request's progress handler */
109 };
110 
111 /* RDMO request structure */
113  ucs_list_link_t entry; /* Request entry in the list */
114  struct urom_worker_rdmo_client *client; /* RDMO client */
115  struct urom_worker_rdmo_ep *ep; /* RDMO endpoint */
116  /* AM */
117  uint8_t header[UROM_RDMO_HDR_LEN_MAX]; /* RDMO header data */
118  void *data; /* RDMO data */
119  uint64_t length; /* RDMO data length */
120  ucp_am_recv_param_t param; /* UCP recv parameters */
121  struct urom_worker_rdmo_req_ops *ops; /* RDMO ops */
122  uint64_t ctx[4]; /* Request context */
123 };
124 
125 /* UROM RDMO worker context structure */
127  struct ucp_data ucp_data; /* UCP data structure */
128  ucs_mpool_t req_mp; /* Requests memory map */
129  khash_t(client) * clients; /* local client connections */
130  khash_t(ep) * eps; /* Peer endpoints */
131  ucs_list_link_t completed_reqs; /* RDMO worker commands completion list */
132 };
133 
134 /* RDMO worker requests operations */
136 
137 /*
138  * Handle request in client RDMO queue
139  *
140  * @req [in]: Client RDMO request
141  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
142  */
144 
145 /* UROM RDMO worker interface */
147  struct urom_plugin_iface super; /* DOCA UROM worker plugin interface */
148 };
149 
150 /*
151  * Get DOCA worker plugin interface for RDMO plugin.
152  * DOCA UROM worker will load the urom_plugin_get_iface symbol to get the RDMO interface
153  *
154  * @iface [out]: Set DOCA UROM plugin interface for RDMO
155  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
156  */
158 
159 /*
160  * Get RDMO plugin version, will be used to verify that the host and DPU plugin versions are compatible
161  *
162  * @version [out]: Set the RDMO worker plugin version
163  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
164  */
165 doca_error_t urom_plugin_get_version(uint64_t *version);
166 
167 #endif /* WORKER_RDMO_H_ */
struct urom_worker_rdmo_req_ops * urom_worker_rdmo_ops_table[]
doca_error_t urom_worker_rdmo_req_queue(struct urom_worker_rdmo_req *req)
KHASH_MAP_INIT_INT64(ep, struct urom_worker_rdmo_ep *)
#define UROM_RDMO_HDR_LEN_MAX
Definition: worker_rdmo.h:40
doca_error_t urom_plugin_get_version(uint64_t *version)
Definition: worker_rdmo.c:997
doca_error_t urom_plugin_get_iface(struct urom_plugin_iface *iface)
Definition: worker_rdmo.c:987
enum doca_error doca_error_t
DOCA API return codes.
ucp_context_h ucp_context
Definition: worker_rdmo.h:44
ucp_address_t * worker_address
Definition: worker_rdmo.h:46
size_t ucp_addrlen
Definition: worker_rdmo.h:47
ucp_worker_h ucp_worker
Definition: worker_rdmo.h:45
UROM Worker plugin interface.
ucs_list_link_t paused_ops
Definition: worker_rdmo.h:95
struct urom_worker_rdmo * rdmo_worker
Definition: worker_rdmo.h:88
struct urom_worker_rdmo_ep * ep
Definition: worker_rdmo.h:91
ucs_list_link_t fenced_ops
Definition: worker_rdmo.h:55
struct urom_plugin_iface super
Definition: worker_rdmo.h:147
khash_t(mem_cache) *mem_cache
doca_error_t(* progress)(struct urom_worker_rdmo_req *req)
Definition: worker_rdmo.h:108
uint8_t header[UROM_RDMO_HDR_LEN_MAX]
Definition: worker_rdmo.h:117
struct urom_worker_rdmo_ep * ep
Definition: worker_rdmo.h:115
ucs_list_link_t entry
Definition: worker_rdmo.h:113
struct urom_worker_rdmo_req_ops * ops
Definition: worker_rdmo.h:121
struct urom_worker_rdmo_client * client
Definition: worker_rdmo.h:114
ucp_am_recv_param_t param
Definition: worker_rdmo.h:120
struct urom_worker_rdmo_ep * ep
Definition: worker_rdmo.h:65
ucs_list_link_t completed_reqs
Definition: worker_rdmo.h:131
ucs_mpool_t req_mp
Definition: worker_rdmo.h:128
khash_t(client) *clients