NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
rdma_common.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 <stdio.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <string.h>
30 
31 #include <doca_log.h>
32 #include <doca_error.h>
33 #include <doca_argp.h>
34 #include <doca_pe.h>
35 
36 #include "rdma_common.h"
37 #include "common.h"
38 
39 DOCA_LOG_REGISTER(GPURDMA::COMMON);
40 
41 /*
42  * RDMA CM connect_request callback
43  *
44  * @connection [in]: RDMA Connection
45  * @ctx_user_data [in]: Context user data
46  */
47 void rdma_cm_connect_request_cb(struct doca_rdma_connection *connection, union doca_data ctx_user_data)
48 {
49  struct rdma_resources *resource = (struct rdma_resources *)ctx_user_data.ptr;
51  union doca_data connection_user_data;
52 
54  if (result != DOCA_SUCCESS) {
55  DOCA_LOG_ERR("Failed to accept rdma cm connection: %s", doca_error_get_descr(result));
56  (void)doca_ctx_stop(resource->rdma_ctx);
57  return;
58  }
59 
60  connection_user_data.ptr = ctx_user_data.ptr;
61  result = doca_rdma_connection_set_user_data(connection, connection_user_data);
62  if (result != DOCA_SUCCESS) {
63  DOCA_LOG_ERR("Failed to set server connection user data: %s", doca_error_get_descr(result));
64  (void)doca_ctx_stop(resource->rdma_ctx);
65  }
66 }
67 
68 /*
69  * RDMA CM connect_established callback
70  *
71  * @connection [in]: RDMA Connection
72  * @connection_user_data [in]: Connection user data
73  * @ctx_user_data [in]: Context user data
74  */
75 void rdma_cm_connect_established_cb(struct doca_rdma_connection *connection,
76  union doca_data connection_user_data,
77  union doca_data ctx_user_data)
78 {
79  (void)connection_user_data;
80  struct rdma_resources *resource = (struct rdma_resources *)ctx_user_data.ptr;
81  static int is_first_connection_established = 0;
82 
83  if (is_first_connection_established == 0) {
84  resource->connection = connection;
85  resource->connection_established = true;
86  } else {
87  resource->connection2 = connection;
88  resource->connection2_established = true;
89  }
90 
91  is_first_connection_established = 1;
92 }
93 
94 /*
95  * RDMA CM connect_failure callback
96  *
97  * @connection [in]: RDMA Connection
98  * @connection_user_data [in]: Connection user data
99  * @ctx_user_data [in]: Context user data
100  */
101 void rdma_cm_connect_failure_cb(struct doca_rdma_connection *connection,
102  union doca_data connection_user_data,
103  union doca_data ctx_user_data)
104 {
105  (void)connection;
106  (void)connection_user_data;
107  struct rdma_resources *resource = (struct rdma_resources *)ctx_user_data.ptr;
108  static int is_first_connection_failure = 0;
109 
110  if (is_first_connection_failure == 0) {
111  resource->connection_established = false;
112  resource->connection_error = true;
113  } else {
114  resource->connection2_established = false;
115  resource->connection2_error = true;
116  }
117 
118  is_first_connection_failure = 1;
119 }
120 
121 /*
122  * RDMA CM disconnect callback
123  *
124  * @connection [in]: RDMA Connection
125  * @connection_user_data [in]: Connection user data
126  * @ctx_user_data [in]: Context user data
127  */
128 void rdma_cm_disconnect_cb(struct doca_rdma_connection *connection,
129  union doca_data connection_user_data,
130  union doca_data ctx_user_data)
131 {
132  (void)connection_user_data;
133  struct rdma_resources *resource = (struct rdma_resources *)ctx_user_data.ptr;
135 
137  if (result != DOCA_SUCCESS) {
138  DOCA_LOG_ERR("Failed to disconnect rdma cm connection: %s", doca_error_get_descr(result));
139  (void)doca_ctx_stop(resource->rdma_ctx);
140  return;
141  }
142 
143  resource->connection_established = false;
144 }
145 
146 /*
147  * OOB connection to exchange RDMA info - server side
148  *
149  * @oob_sock_fd [out]: Socket FD
150  * @oob_client_sock [out]: Client socket FD
151  * @return: positive integer on success and -1 otherwise
152  */
154 {
155  struct sockaddr_in server_addr = {0}, client_addr = {0};
156  unsigned int client_size = 0;
157  int enable = 1;
158  int oob_sock_fd_ = 0;
159  int oob_client_sock_ = 0;
160 
161  /* Create socket */
162  oob_sock_fd_ = socket(AF_INET, SOCK_STREAM, 0);
163  if (oob_sock_fd_ < 0) {
164  DOCA_LOG_ERR("Error while creating socket %d", oob_sock_fd_);
165  return -1;
166  }
167  DOCA_LOG_INFO("Socket created successfully");
168 
169  if (setsockopt(oob_sock_fd_, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(enable))) {
170  DOCA_LOG_ERR("Error setting socket options");
171  close(oob_sock_fd_);
172  return -1;
173  }
174 
175  /* Set port and IP: */
176  server_addr.sin_family = AF_INET;
177  server_addr.sin_port = htons(2000);
178  server_addr.sin_addr.s_addr = INADDR_ANY; /* listen on any interface */
179 
180  /* Bind to the set port and IP: */
181  if (bind(oob_sock_fd_, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
182  DOCA_LOG_ERR("Couldn't bind to the port");
183  close(oob_sock_fd_);
184  return -1;
185  }
186  DOCA_LOG_INFO("Done with binding");
187 
188  /* Listen for clients: */
189  if (listen(oob_sock_fd_, 1) < 0) {
190  DOCA_LOG_ERR("Error while listening");
191  close(oob_sock_fd_);
192  return -1;
193  }
194  DOCA_LOG_INFO("Listening for incoming connections");
195 
196  /* Accept an incoming connection: */
197  client_size = sizeof(client_addr);
198  oob_client_sock_ = accept(oob_sock_fd_, (struct sockaddr *)&client_addr, &client_size);
199  if (oob_client_sock_ < 0) {
200  DOCA_LOG_ERR("Can't accept socket connection %d", oob_client_sock_);
201  close(oob_sock_fd_);
202  return -1;
203  }
204 
205  *(oob_sock_fd) = oob_sock_fd_;
206  *(oob_client_sock) = oob_client_sock_;
207 
208  DOCA_LOG_INFO("Client connected at IP: %s and port: %i",
209  inet_ntoa(client_addr.sin_addr),
210  ntohs(client_addr.sin_port));
211 
212  return 0;
213 }
214 
215 /*
216  * OOB connection to exchange RDMA info - server side closure
217  *
218  * @oob_sock_fd [in]: Socket FD
219  * @oob_client_sock [in]: Client socket FD
220  * @return: positive integer on success and -1 otherwise
221  */
223 {
224  if (oob_client_sock > 0)
225  close(oob_client_sock);
226 
227  if (oob_sock_fd > 0)
228  close(oob_sock_fd);
229 }
230 
231 /*
232  * OOB connection to exchange RDMA info - client side
233  *
234  * @server_ip [in]: Server IP address to connect
235  * @oob_sock_fd [out]: Socket FD
236  * @return: positive integer on success and -1 otherwise
237  */
238 int oob_connection_client_setup(const char *server_ip, int *oob_sock_fd)
239 {
240  struct sockaddr_in server_addr = {0};
241  int oob_sock_fd_;
242 
243  /* Create socket */
244  oob_sock_fd_ = socket(AF_INET, SOCK_STREAM, 0);
245  if (oob_sock_fd_ < 0) {
246  DOCA_LOG_ERR("Unable to create socket");
247  return -1;
248  }
249  DOCA_LOG_INFO("Socket created successfully");
250 
251  /* Set port and IP the same as server-side: */
252  server_addr.sin_family = AF_INET;
253  server_addr.sin_port = htons(2000);
254  server_addr.sin_addr.s_addr = inet_addr(server_ip);
255 
256  /* Send connection request to server: */
257  if (connect(oob_sock_fd_, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
258  close(oob_sock_fd_);
259  DOCA_LOG_ERR("Unable to connect to server at %s", server_ip);
260  return -1;
261  }
262  DOCA_LOG_INFO("Connected with server successfully");
263 
264  *oob_sock_fd = oob_sock_fd_;
265  return 0;
266 }
267 
268 /*
269  * OOB connection to exchange RDMA info - client side closure
270  *
271  * @oob_sock_fd [in]: Socket FD
272  * @return: positive integer on success and -1 otherwise
273  */
275 {
276  if (oob_sock_fd > 0)
277  close(oob_sock_fd);
278 }
279 
280 /*
281  * Wrapper to fix const type of doca_rdma_cap_task_write_is_supported
282  *
283  * @devinfo [in]: RDMA device info
284  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
285  */
287 {
288  return doca_rdma_cap_task_write_is_supported((const struct doca_devinfo *)devinfo);
289 }
290 
291 /*
292  * Create and initialize DOCA RDMA resources
293  *
294  * @cfg [in]: Configuration parameters
295  * @rdma_permissions [in]: Access permission flags for DOCA RDMA
296  * @resources [in/out]: DOCA RDMA resources to create
297  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
298  */
300  const uint32_t rdma_permissions,
301  struct rdma_resources *resources)
302 {
303  union doca_data ctx_user_data = {0};
304  doca_error_t result, tmp_result;
305 
306  resources->cfg = cfg;
307 
308  /* Open DOCA device */
309  result = open_doca_device_with_ibdev_name((const uint8_t *)(cfg->device_name),
310  strlen(cfg->device_name),
312  &(resources->doca_device));
313  if (result != DOCA_SUCCESS) {
314  DOCA_LOG_ERR("Failed to open DOCA device: %s", doca_error_get_descr(result));
315  return result;
316  }
317 
318  /* Create DOCA GPU */
319  result = doca_gpu_create(cfg->gpu_pcie_addr, &(resources->gpudev));
320  if (result != DOCA_SUCCESS) {
321  DOCA_LOG_ERR("Failed to create DOCA GPU: %s", doca_error_get_descr(result));
322  goto close_doca_dev;
323  }
324 
325  /* Create DOCA RDMA instance */
327  if (result != DOCA_SUCCESS) {
328  DOCA_LOG_ERR("Failed to create DOCA RDMA: %s", doca_error_get_descr(result));
329  goto destroy_doca_gpu;
330  }
331 
332  /* Convert DOCA RDMA to general DOCA context */
334  if (resources->rdma_ctx == NULL) {
336  DOCA_LOG_ERR("Failed to convert DOCA RDMA to DOCA context: %s", doca_error_get_descr(result));
337  goto destroy_doca_rdma;
338  }
339 
340  /* Set permissions to DOCA RDMA */
341  result = doca_rdma_set_permissions(resources->rdma, rdma_permissions);
342  if (result != DOCA_SUCCESS) {
343  DOCA_LOG_ERR("Failed to set permissions to DOCA RDMA: %s", doca_error_get_descr(result));
344  goto destroy_doca_rdma;
345  }
346 
347  /* Set gid_index to DOCA RDMA if it's provided */
348  if (cfg->is_gid_index_set) {
349  /* Set gid_index to DOCA RDMA */
351  if (result != DOCA_SUCCESS) {
352  DOCA_LOG_ERR("Failed to set gid_index to DOCA RDMA: %s", doca_error_get_descr(result));
353  goto destroy_doca_rdma;
354  }
355  }
356 
357  /* Set send queue size to DOCA RDMA */
359  if (result != DOCA_SUCCESS) {
360  DOCA_LOG_ERR("Failed to set send queue size to DOCA RDMA: %s", doca_error_get_descr(result));
361  goto destroy_doca_rdma;
362  }
363 
364  /* Setup datapath of RDMA CTX on GPU */
366  if (result != DOCA_SUCCESS) {
367  DOCA_LOG_ERR("Failed to set datapath on GPU: %s", doca_error_get_descr(result));
368  goto destroy_doca_rdma;
369  }
370 
371  /* Set receive queue size to DOCA RDMA */
373  if (result != DOCA_SUCCESS) {
374  DOCA_LOG_ERR("Failed to set receive queue size to DOCA RDMA: %s", doca_error_get_descr(result));
375  goto destroy_doca_rdma;
376  }
377 
378  /* Set GRH to DOCA RDMA */
380  if (result != DOCA_SUCCESS) {
381  DOCA_LOG_ERR("Failed to set GRH to DOCA RDMA: %s", doca_error_get_descr(result));
382  goto destroy_doca_rdma;
383  }
384 
385  if (cfg->use_rdma_cm) {
386  /* Set PE */
388  if (result != DOCA_SUCCESS) {
389  DOCA_LOG_ERR("Failed to create DOCA progress engine: %s", doca_error_get_descr(result));
390  goto destroy_doca_rdma;
391  }
392 
394  if (result != DOCA_SUCCESS) {
395  DOCA_LOG_ERR("Failed to connect progress engine to context: %s", doca_error_get_descr(result));
396  goto destroy_doca_rdma;
397  }
398 
400  if (result != DOCA_SUCCESS) {
401  DOCA_LOG_ERR("Failed doca_rdma_set_max_num_connections: %s", doca_error_get_descr(result));
402  goto destroy_doca_rdma;
403  }
404 
405  /* Set rdma cm connection configuration callbacks */
411  if (result != DOCA_SUCCESS) {
412  DOCA_LOG_ERR("Failed to set CM callbacks: %s", doca_error_get_descr(result));
413  goto destroy_doca_rdma;
414  }
415  }
416 
417  /* Include the program's resources in user data of context to be used in callbacks */
418  ctx_user_data.ptr = resources;
419  result = doca_ctx_set_user_data(resources->rdma_ctx, ctx_user_data);
420  if (result != DOCA_SUCCESS) {
421  DOCA_LOG_ERR("Failed to set context user data: %s", doca_error_get_descr(result));
422  goto destroy_doca_rdma;
423  }
424 
425  /* Start RDMA context */
427  if (result != DOCA_SUCCESS) {
428  DOCA_LOG_ERR("Failed to start RDMA context: %s", doca_error_get_descr(result));
429  goto destroy_doca_rdma;
430  }
431 
432  return DOCA_SUCCESS;
433 
434 destroy_doca_rdma:
435  /* Destroy DOCA RDMA */
436  tmp_result = doca_rdma_destroy(resources->rdma);
437  if (tmp_result != DOCA_SUCCESS)
438  DOCA_LOG_ERR("Failed to destroy DOCA RDMA: %s", doca_error_get_descr(tmp_result));
439 
440  if (resources->pe) {
441  /* Destroy DOCA progress engine */
442  tmp_result = doca_pe_destroy(resources->pe);
443  if (tmp_result != DOCA_SUCCESS)
444  DOCA_LOG_ERR("Failed to destroy DOCA progress engine: %s", doca_error_get_descr(tmp_result));
445  }
446 
447 destroy_doca_gpu:
448  /* Close DOCA GPU device */
449  if (resources->gpudev) {
450  tmp_result = doca_gpu_destroy(resources->gpudev);
451  if (tmp_result != DOCA_SUCCESS)
452  DOCA_LOG_ERR("Failed to close DOCA GPU device: %s", doca_error_get_descr(tmp_result));
453  }
454 
455 close_doca_dev:
456  /* Close DOCA device */
457  tmp_result = doca_dev_close(resources->doca_device);
458  if (tmp_result != DOCA_SUCCESS)
459  DOCA_LOG_ERR("Failed to close DOCA device: %s", doca_error_get_descr(tmp_result));
460 
461  return result;
462 }
463 
464 /*
465  * Destroy DOCA RDMA resources
466  *
467  * @resources [in]: DOCA RDMA resources to destroy
468  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
469  */
471 {
472  doca_error_t result = DOCA_SUCCESS, tmp_result;
473 
474  /* Destroy CM objects */
475  if (resources->cfg->use_rdma_cm) {
476  if (resources->connection) {
478  if (tmp_result != DOCA_SUCCESS) {
479  DOCA_LOG_ERR("Failed to disconnect RDMA connection: %s",
480  doca_error_get_descr(tmp_result));
481  DOCA_ERROR_PROPAGATE(result, tmp_result);
482  }
483  }
484 
485  if (resources->connection2) {
487  if (tmp_result != DOCA_SUCCESS) {
488  DOCA_LOG_ERR("Failed to disconnect RDMA connection: %s",
489  doca_error_get_descr(tmp_result));
490  DOCA_ERROR_PROPAGATE(result, tmp_result);
491  }
492  }
493 
494  if (resources->cfg->is_server) {
497  if (tmp_result != DOCA_SUCCESS) {
498  DOCA_LOG_ERR("Failed to stop listen to port: %s",
499  doca_error_get_descr(tmp_result));
500  DOCA_ERROR_PROPAGATE(result, tmp_result);
501  }
502  }
503  } else { /* Case of Client */
504  if (resources->cm_addr) {
506  if (tmp_result != DOCA_SUCCESS) {
507  DOCA_LOG_ERR("Failed to destroy CM address: %s",
508  doca_error_get_descr(tmp_result));
509  DOCA_ERROR_PROPAGATE(result, tmp_result);
510  }
511  }
512  }
513  }
514 
515  /* Stop DOCA context */
516  if (resources->rdma_ctx) {
517  tmp_result = doca_ctx_stop(resources->rdma_ctx);
518  if (tmp_result != DOCA_SUCCESS) {
519  DOCA_LOG_ERR("Failed to stop RDMA context: %s", doca_error_get_descr(tmp_result));
520  DOCA_ERROR_PROPAGATE(result, tmp_result);
521  }
522  }
523 
524  /* Destroy DOCA RDMA */
525  if (resources->rdma) {
526  tmp_result = doca_rdma_destroy(resources->rdma);
527  if (tmp_result != DOCA_SUCCESS) {
528  DOCA_LOG_ERR("Failed to destroy DOCA RDMA: %s", doca_error_get_descr(tmp_result));
529  DOCA_ERROR_PROPAGATE(result, tmp_result);
530  }
531  }
532 
533  /* Destroy DOCA progress engine */
534  if (resources->pe) {
535  tmp_result = doca_pe_destroy(resources->pe);
536  if (tmp_result != DOCA_SUCCESS) {
537  DOCA_LOG_ERR("Failed to destroy DOCA progress engine: %s", doca_error_get_descr(tmp_result));
538  DOCA_ERROR_PROPAGATE(result, tmp_result);
539  }
540  }
541 
542  /* Close DOCA device */
543  if (resources->doca_device) {
544  tmp_result = doca_dev_close(resources->doca_device);
545  if (tmp_result != DOCA_SUCCESS) {
546  DOCA_LOG_ERR("Failed to close DOCA device: %s", doca_error_get_descr(tmp_result));
547  DOCA_ERROR_PROPAGATE(result, tmp_result);
548  }
549  }
550 
551  /* Destroy DOCA GPU */
552  if (resources->gpudev) {
553  tmp_result = doca_gpu_destroy(resources->gpudev);
554  if (tmp_result != DOCA_SUCCESS) {
555  DOCA_LOG_ERR("Failed to destroy DOCA GPU: %s", doca_error_get_descr(tmp_result));
556  DOCA_ERROR_PROPAGATE(result, tmp_result);
557  }
558  }
559 
560  return result;
561 }
562 
563 /*
564  * Create a DOCA mmap object
565  *
566  * @mmap_obj [in]: mmap object to populate
567  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
568  */
570 {
571  /* setup mmap */
572  doca_error_t result, result2;
573 
574  result = doca_mmap_create(&(mmap_obj->mmap));
575  if (result != DOCA_SUCCESS)
576  return result;
577 
578  result = doca_mmap_set_permissions(mmap_obj->mmap, mmap_obj->permissions);
579  if (result != DOCA_SUCCESS)
580  goto error;
581 
582  result = doca_mmap_set_memrange(mmap_obj->mmap, mmap_obj->memrange_addr, mmap_obj->memrange_len);
583  if (result != DOCA_SUCCESS)
584  goto error;
585 
586  result = doca_mmap_add_dev(mmap_obj->mmap, mmap_obj->doca_device);
587  if (result != DOCA_SUCCESS)
588  goto error;
589 
590  result = doca_mmap_start(mmap_obj->mmap);
591  if (result != DOCA_SUCCESS)
592  goto error;
593 
594  /* export mmap for rdma */
595  result = doca_mmap_export_rdma(mmap_obj->mmap,
596  mmap_obj->doca_device,
597  &(mmap_obj->rdma_export),
598  &(mmap_obj->export_len));
599  if (result != DOCA_SUCCESS)
600  goto error;
601 
602  return result;
603 
604 error:
605  result2 = doca_mmap_destroy(mmap_obj->mmap);
606  if (result2 != DOCA_SUCCESS)
607  DOCA_LOG_ERR("Failed to call doca_mmap_destroy: %s", doca_error_get_descr(result2));
608 
609  return result;
610 }
611 
612 /*
613  * Create a buffer array on GPU
614  *
615  * @buf_arr_obj [in]: buffer array object to populate
616  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
617  */
619 {
620  /* setup buf array */
621  doca_error_t result, result2;
622 
624  if (result != DOCA_SUCCESS)
625  return result;
626 
628  if (result != DOCA_SUCCESS)
629  goto error;
630 
632  if (result != DOCA_SUCCESS)
633  goto error;
634 
636  if (result != DOCA_SUCCESS)
637  goto error;
638 
640  if (result != DOCA_SUCCESS)
641  goto error;
642 
643  return result;
644 error:
646  if (result2 != DOCA_SUCCESS)
647  DOCA_LOG_ERR("Failed to call doca_buf_arr_destroy: %s", doca_error_get_descr(result2));
648 
649  return result;
650 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
doca_error_t open_doca_device_with_ibdev_name(const uint8_t *value, size_t val_size, tasks_check func, struct doca_dev **retval)
Definition: common.c:84
doca_error_t wrapper_doca_rdma_cap_task_write_is_supported(struct doca_devinfo *devinfo)
Definition: rdma_common.c:286
doca_error_t create_buf_arr_on_gpu(struct buf_arr_obj *buf_arr_obj)
Definition: rdma_common.c:618
doca_error_t destroy_rdma_resources(struct rdma_resources *resources)
Definition: rdma_common.c:470
void rdma_cm_connect_established_cb(struct doca_rdma_connection *connection, union doca_data connection_user_data, union doca_data ctx_user_data)
Definition: rdma_common.c:75
void rdma_cm_disconnect_cb(struct doca_rdma_connection *connection, union doca_data connection_user_data, union doca_data ctx_user_data)
Definition: rdma_common.c:128
int oob_connection_client_setup(const char *server_ip, int *oob_sock_fd)
Definition: rdma_common.c:238
doca_error_t create_mmap(struct rdma_mmap_obj *mmap_obj)
Definition: rdma_common.c:569
void oob_connection_server_close(int oob_sock_fd, int oob_client_sock)
Definition: rdma_common.c:222
int oob_connection_server_setup(int *oob_sock_fd, int *oob_client_sock)
Definition: rdma_common.c:153
doca_error_t create_rdma_resources(struct rdma_config *cfg, const uint32_t rdma_permissions, struct rdma_resources *resources)
Definition: rdma_common.c:299
void rdma_cm_connect_failure_cb(struct doca_rdma_connection *connection, union doca_data connection_user_data, union doca_data ctx_user_data)
Definition: rdma_common.c:101
void rdma_cm_connect_request_cb(struct doca_rdma_connection *connection, union doca_data ctx_user_data)
Definition: rdma_common.c:47
void oob_connection_client_close(int oob_sock_fd)
Definition: rdma_common.c:274
DOCA_LOG_REGISTER(GPURDMA::COMMON)
#define RDMA_RECV_QUEUE_SIZE
Definition: rdma_common.h:57
#define RDMA_SEND_QUEUE_SIZE
Definition: rdma_common.h:56
if(bitoffset % 64+bitlength > 64) result|
struct rdma_resources resources
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_destroy(struct doca_buf_arr *buf_arr)
Destroys a doca buf array instance.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_set_params(struct doca_buf_arr *buf_arr, struct doca_mmap *mmap, size_t elem_size, uint64_t start_offset)
Sets the buf array params.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_set_target_gpu(struct doca_buf_arr *buf_arr, struct doca_gpu *gpu_handler)
Configures the buf array to be created on the gpu device.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_get_gpu_handle(const struct doca_buf_arr *buf_arr, struct doca_gpu_buf_arr **gpu_buf_arr)
Retrieves the handle in the gpu memory space of a doca_buf_arr.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_create(size_t num_elem, struct doca_buf_arr **buf_arr)
Allocates a doca_buf_arr.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_start(struct doca_buf_arr *buf_arr)
This method enables the allocation of doca_bufs.
DOCA_STABLE doca_error_t doca_ctx_start(struct doca_ctx *ctx)
Finalizes all configurations, and starts the DOCA CTX.
DOCA_EXPERIMENTAL doca_error_t doca_ctx_set_datapath_on_gpu(struct doca_ctx *ctx, struct doca_gpu *gpu_dev)
This function binds the DOCA context to a gpu device.
DOCA_STABLE doca_error_t doca_ctx_set_user_data(struct doca_ctx *ctx, union doca_data user_data)
set user data to context
DOCA_STABLE doca_error_t doca_ctx_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
DOCA_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
#define DOCA_ERROR_PROPAGATE(r, t)
Save the first encountered doca_error_t.
Definition: doca_error.h:83
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_UNEXPECTED
Definition: doca_error.h:60
@ DOCA_SUCCESS
Definition: doca_error.h:38
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
Definition: doca_log.h:466
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
Definition: doca_log.h:486
DOCA_STABLE doca_error_t doca_mmap_set_memrange(struct doca_mmap *mmap, void *addr, size_t len)
Set the memory range of DOCA memory map.
DOCA_STABLE doca_error_t doca_mmap_destroy(struct doca_mmap *mmap)
Destroy DOCA Memory Map structure.
DOCA_STABLE doca_error_t doca_mmap_create(struct doca_mmap **mmap)
Allocates zero size memory map object with default/unset attributes.
DOCA_STABLE doca_error_t doca_mmap_set_permissions(struct doca_mmap *mmap, uint32_t access_mask)
Set access flags of the registered memory.
DOCA_STABLE doca_error_t doca_mmap_start(struct doca_mmap *mmap)
Start DOCA Memory Map.
DOCA_STABLE doca_error_t doca_mmap_add_dev(struct doca_mmap *mmap, struct doca_dev *dev)
Register DOCA memory map on a given device.
DOCA_STABLE doca_error_t doca_mmap_export_rdma(struct doca_mmap *mmap, const struct doca_dev *dev, const void **export_desc, size_t *export_desc_len)
Compose memory map representation for later import with doca_mmap_create_from_export() for one of the...
DOCA_STABLE doca_error_t doca_pe_destroy(struct doca_pe *pe)
Destroy doca progress engine.
DOCA_STABLE doca_error_t doca_pe_connect_ctx(struct doca_pe *pe, struct doca_ctx *ctx)
This method connects a context to a progress engine.
DOCA_STABLE doca_error_t doca_pe_create(struct doca_pe **pe)
Creates DOCA progress engine.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_destroy(struct doca_rdma *rdma)
Destroy a DOCA RDMA instance.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_set_grh_enabled(struct doca_rdma *rdma, uint8_t grh_enabled)
Set whether to use GRH in connection. The value can be queried using doca_rdma_get_grh_enabled()....
DOCA_EXPERIMENTAL doca_error_t doca_rdma_stop_listen_to_port(struct doca_rdma *rdma, uint16_t port)
End the listen process for a connection from remote doca_rdma peers. Can be called when the ctx is in...
DOCA_EXPERIMENTAL doca_error_t doca_rdma_addr_destroy(struct doca_rdma_addr *addr)
Destroy connection address object for doca_rdma.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_set_connection_state_callbacks(struct doca_rdma *rdma, doca_rdma_connection_request_cb_t doca_rdma_connect_request_cb, doca_rdma_connection_established_cb_t doca_rdma_connect_established_cb, doca_rdma_connection_failure_cb_t doca_rdma_connect_failure_cb, doca_rdma_connection_disconnection_cb_t doca_rdma_disconnect_cb)
This method set the function executed on RDMA connection events.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_set_permissions(struct doca_rdma *rdma, uint32_t permissions)
Set rdma permissions for doca_rdma. The value can be queried using doca_rdma_get_permissions()....
DOCA_EXPERIMENTAL doca_error_t doca_rdma_set_send_queue_size(struct doca_rdma *rdma, uint32_t send_queue_size)
Set send queue size property for doca_rdma. The value can be queried using doca_rdma_get_send_queue_s...
DOCA_EXPERIMENTAL doca_error_t doca_rdma_set_recv_queue_size(struct doca_rdma *rdma, uint32_t recv_queue_size)
Set recv queue size property for doca_rdma. The value can be queried using doca_rdma_get_recv_queue_s...
DOCA_EXPERIMENTAL doca_error_t doca_rdma_set_max_num_connections(struct doca_rdma *rdma, uint16_t max_num_connections)
Set the maximum number of connections property for a context. The value can be queried using doca_rdm...
DOCA_EXPERIMENTAL doca_error_t doca_rdma_connection_disconnect(struct doca_rdma_connection *rdma_connection)
Finalize a connection with a remote doca_rdma peer. Can be called when the ctx is in DOCA_CTX_STATE_R...
DOCA_EXPERIMENTAL doca_error_t doca_rdma_set_gid_index(struct doca_rdma *rdma, uint32_t gid_index)
Set GID index for doca_rdma. The value can be queried using doca_rdma_get_gid_index()....
DOCA_EXPERIMENTAL doca_error_t doca_rdma_connection_accept(struct doca_rdma_connection *rdma_connection, void *private_data, uint8_t private_data_len)
Accept an incoming connection request from remote doca_rdma peer. Can be called when the ctx is in DO...
DOCA_EXPERIMENTAL struct doca_ctx * doca_rdma_as_ctx(struct doca_rdma *rdma)
Convert doca_rdma instance into a generalized context for use with doca core objects.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_cap_task_write_is_supported(const struct doca_devinfo *devinfo)
DOCA_EXPERIMENTAL doca_error_t doca_rdma_create(struct doca_dev *dev, struct doca_rdma **rdma)
Create a DOCA RDMA instance.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_connection_set_user_data(struct doca_rdma_connection *rdma_connection, union doca_data connection_user_data)
Set user data to include in each connection.
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
uint32_t num_elem
Definition: rdma_common.h:117
struct doca_gpu_buf_arr * gpu_buf_arr
Definition: rdma_common.h:120
size_t elem_size
Definition: rdma_common.h:118
struct doca_gpu * gpudev
Definition: rdma_common.h:115
struct doca_buf_arr * buf_arr
Definition: rdma_common.h:119
struct doca_mmap * mmap
Definition: rdma_common.h:116
bool use_rdma_cm
Definition: rdma_common.h:71
uint32_t cm_port
Definition: rdma_common.h:72
bool is_server
Definition: rdma_common.h:68
struct doca_dev * doca_device
Definition: rdma_common.h:104
size_t memrange_len
Definition: rdma_common.h:107
void * memrange_addr
Definition: rdma_common.h:106
struct doca_mmap * mmap
Definition: rdma_common.h:108
uint32_t permissions
Definition: rdma_common.h:105
size_t export_len
Definition: rdma_common.h:110
const void * rdma_export
Definition: rdma_common.h:109
bool server_listen_active
Definition: rdma_common.h:95
struct doca_rdma_connection * connection2
Definition: rdma_common.h:97
struct doca_rdma_connection * connection
Definition: rdma_common.h:92
struct doca_ctx * rdma_ctx
Definition: rdma_common.h:85
bool connection2_established
Definition: rdma_common.h:98
struct rdma_config * cfg
Definition: rdma_common.h:80
struct doca_rdma_addr * cm_addr
Definition: rdma_common.h:91
struct doca_rdma * rdma
Definition: rdma_common.h:83
struct doca_pe * pe
Definition: rdma_common.h:86
struct doca_dev * doca_device
Definition: rdma_common.h:81
bool connection2_error
Definition: rdma_common.h:99
bool connection_error
Definition: rdma_common.h:94
bool connection_established
Definition: rdma_common.h:93
struct doca_gpu * gpudev
Definition: rdma_common.h:82
Convenience type for representing opaque data.
Definition: doca_types.h:56
void * ptr
Definition: doca_types.h:57