NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
common_common.c
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 #include <unistd.h>
27 #include <time.h>
28 
29 #include <doca_log.h>
30 #include <doca_argp.h>
31 #include <doca_dev.h>
32 #include <doca_pe.h>
33 
34 #include "common_common.h"
35 
36 DOCA_LOG_REGISTER(SYNC_EVENT::COMMON);
37 
38 #define SLEEP_IN_NANOS (10 * 1000) /* Sample the task every 10 microseconds */
39 #define TIMEOUT_IN_NANOS (1 * 1000000000) /* Poll the task for maximum of 1 second */
40 
48 static void task_completion_cb(struct doca_task *se_task, union doca_data task_user_data, union doca_data ctx_user_data)
49 {
50  (void)se_task;
51  (void)task_user_data;
52 
53  struct sync_event_runtime_objects *rt_objs = (struct sync_event_runtime_objects *)ctx_user_data.ptr;
54 
55  rt_objs->se_task_result = DOCA_SUCCESS;
56 }
57 
65 static void task_error_cb(struct doca_task *se_task, union doca_data task_user_data, union doca_data ctx_user_data)
66 {
67  (void)se_task;
68  (void)task_user_data;
69 
70  struct sync_event_runtime_objects *rt_objs = (struct sync_event_runtime_objects *)ctx_user_data.ptr;
71 
73 }
74 
84 static void task_get_completion_cb(struct doca_sync_event_task_get *task,
85  union doca_data task_user_data,
86  union doca_data ctx_user_data)
87 {
88  task_completion_cb(doca_sync_event_task_get_as_doca_task(task), task_user_data, ctx_user_data);
89 }
90 
100 static void task_get_error_cb(struct doca_sync_event_task_get *task,
101  union doca_data task_user_data,
102  union doca_data ctx_user_data)
103 {
104  task_error_cb(doca_sync_event_task_get_as_doca_task(task), task_user_data, ctx_user_data);
105 }
106 
116 static void task_notify_set_completion_cb(struct doca_sync_event_task_notify_set *task,
117  union doca_data task_user_data,
118  union doca_data ctx_user_data)
119 {
120  task_completion_cb(doca_sync_event_task_notify_set_as_doca_task(task), task_user_data, ctx_user_data);
121 }
122 
132 static void task_notify_set_error_cb(struct doca_sync_event_task_notify_set *task,
133  union doca_data task_user_data,
134  union doca_data ctx_user_data)
135 {
136  task_error_cb(doca_sync_event_task_notify_set_as_doca_task(task), task_user_data, ctx_user_data);
137 }
138 
148 static void task_notify_add_completion_cb(struct doca_sync_event_task_notify_add *task,
149  union doca_data task_user_data,
150  union doca_data ctx_user_data)
151 {
152  task_completion_cb(doca_sync_event_task_notify_add_as_doca_task(task), task_user_data, ctx_user_data);
153 }
154 
164 static void task_notify_add_error_cb(struct doca_sync_event_task_notify_add *task,
165  union doca_data task_user_data,
166  union doca_data ctx_user_data)
167 {
168  task_error_cb(doca_sync_event_task_notify_add_as_doca_task(task), task_user_data, ctx_user_data);
169 }
170 
180 static void task_wait_eq_completion_cb(struct doca_sync_event_task_wait_eq *task,
181  union doca_data task_user_data,
182  union doca_data ctx_user_data)
183 {
184  task_completion_cb(doca_sync_event_task_wait_eq_as_doca_task(task), task_user_data, ctx_user_data);
185 }
186 
196 static void task_wait_eq_error_cb(struct doca_sync_event_task_wait_eq *task,
197  union doca_data task_user_data,
198  union doca_data ctx_user_data)
199 {
200  task_error_cb(doca_sync_event_task_wait_eq_as_doca_task(task), task_user_data, ctx_user_data);
201 }
202 
203 /*
204  * common helper for copying PCI address user input
205  *
206  * @pci_addr_src [in]: input PCI address string
207  * @pci_addr_dest [out]: destination PCI address string buffer
208  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
209  */
210 static inline doca_error_t pci_addr_cb(const char *pci_addr_src, char pci_addr_dest[DOCA_DEVINFO_PCI_ADDR_SIZE])
211 {
212  int len = strnlen(pci_addr_src, DOCA_DEVINFO_PCI_ADDR_SIZE);
213 
215  DOCA_LOG_ERR("PCI address exceeding the maximum size of %d", DOCA_DEVINFO_PCI_ADDR_SIZE - 1);
217  }
218 
219  strncpy(pci_addr_dest, pci_addr_src, len + 1);
220 
221  return DOCA_SUCCESS;
222 }
223 
224 /*
225  * argp callback - handle local device PCI address parameter
226  *
227  * @param [in]: input parameter
228  * @config [in/out]: program configuration context
229  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
230  */
231 static inline doca_error_t dev_pci_addr_cb(void *param, void *config)
232 {
233  return pci_addr_cb((char *)param, ((struct sync_event_config *)config)->dev_pci_addr);
234 }
235 
236 /*
237  * argp callback - handle DPU representor PCI address parameter
238  *
239  * @param [in]: input parameter
240  * @config [in/out]: program configuration context
241  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
242  */
243 static inline doca_error_t rep_pci_addr_cb(void *param, void *config)
244 {
245  return pci_addr_cb((char *)param, ((struct sync_event_config *)config)->rep_pci_addr);
246 }
247 
248 /*
249  * argp callback - handle sync event asynchronous mode parameter
250  *
251  * @param [in]: input parameter
252  * @config [in/out]: program configuration context
253  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
254  */
255 static inline doca_error_t is_async_mode_cb(void *param, void *config)
256 {
257  (void)(param);
258 
259  ((struct sync_event_config *)config)->is_async_mode = true;
260 
261  return DOCA_SUCCESS;
262 }
263 
264 /*
265  * argp callback - handle sync event asynchronous number of tasks
266  *
267  * @param [in]: input parameter
268  * @config [in/out]: program configuration context
269  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
270  */
271 static inline doca_error_t async_num_tasks_cb(void *param, void *config)
272 {
273  ((struct sync_event_config *)config)->async_num_tasks = *(int *)param;
274 
275  return DOCA_SUCCESS;
276 }
277 
278 /*
279  * argp callback - handle sync event atomic parameter
280  *
281  * @param [in]: input parameter
282  * @config [in/out]: program configuration context
283  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
284  */
285 static inline doca_error_t is_update_atomic_cb(void *param, void *config)
286 {
287  (void)(param);
288 
289  ((struct sync_event_config *)config)->is_update_atomic = true;
290 
291  return DOCA_SUCCESS;
292 }
293 
294 /*
295  * Register command line parameters for DOCA Sync Event sample
296  *
297  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
298  */
300 {
302  struct doca_argp_param *dev_pci_addr_param = NULL, *is_async_mode_param = NULL, *async_num_tasks = NULL,
303  *is_update_atomic = NULL;
304 
305  result = doca_argp_param_create(&dev_pci_addr_param);
306  if (result != DOCA_SUCCESS) {
307  DOCA_LOG_ERR("Failed to create dev-pci-addr param: %s", doca_error_get_descr(result));
308  return result;
309  }
310 
311  doca_argp_param_set_short_name(dev_pci_addr_param, "d");
312  doca_argp_param_set_long_name(dev_pci_addr_param, "pci-addr");
313  doca_argp_param_set_description(dev_pci_addr_param, "Device PCI address");
314  doca_argp_param_set_mandatory(dev_pci_addr_param);
315  doca_argp_param_set_callback(dev_pci_addr_param, dev_pci_addr_cb);
316  doca_argp_param_set_type(dev_pci_addr_param, DOCA_ARGP_TYPE_STRING);
317 
318  result = doca_argp_register_param(dev_pci_addr_param);
319  if (result != DOCA_SUCCESS) {
320  DOCA_LOG_ERR("Failed to register pci-addr param: %s", doca_error_get_descr(result));
321  return result;
322  }
323 
324 #ifdef DOCA_ARCH_DPU
325  struct doca_argp_param *rep_pci_addr_param = NULL;
326 
327  result = doca_argp_param_create(&rep_pci_addr_param);
328  if (result != DOCA_SUCCESS) {
329  DOCA_LOG_ERR("Failed to create rep-pci-addr param: %s", doca_error_get_descr(result));
330  return result;
331  }
332 
333  doca_argp_param_set_short_name(rep_pci_addr_param, "r");
334  doca_argp_param_set_long_name(rep_pci_addr_param, "rep-pci");
335  doca_argp_param_set_description(rep_pci_addr_param, "DPU representor PCI address");
336  doca_argp_param_set_mandatory(rep_pci_addr_param);
337  doca_argp_param_set_callback(rep_pci_addr_param, rep_pci_addr_cb);
338  doca_argp_param_set_type(rep_pci_addr_param, DOCA_ARGP_TYPE_STRING);
339 
340  result = doca_argp_register_param(rep_pci_addr_param);
341  if (result != DOCA_SUCCESS) {
342  DOCA_LOG_ERR("Failed to register rep-pci param: %s", doca_error_get_descr(result));
343  return result;
344  }
345 #endif
346 
347  result = doca_argp_param_create(&is_async_mode_param);
348  if (result != DOCA_SUCCESS) {
349  DOCA_LOG_ERR("Failed to create async param: %s", doca_error_get_descr(result));
350  return result;
351  }
352 
353  doca_argp_param_set_long_name(is_async_mode_param, "async");
354  doca_argp_param_set_description(is_async_mode_param,
355  "Start DOCA Sync Event in asynchronous mode (synchronous mode by default)");
356  doca_argp_param_set_callback(is_async_mode_param, is_async_mode_cb);
357  doca_argp_param_set_type(is_async_mode_param, DOCA_ARGP_TYPE_BOOLEAN);
358 
359  result = doca_argp_register_param(is_async_mode_param);
360  if (result != DOCA_SUCCESS) {
361  DOCA_LOG_ERR("Failed to register async param: %s", doca_error_get_descr(result));
362  return result;
363  }
364 
365  result = doca_argp_param_create(&async_num_tasks);
366  if (result != DOCA_SUCCESS) {
367  DOCA_LOG_ERR("Failed to create async num tasks param: %s", doca_error_get_descr(result));
368  return result;
369  }
370 
371  doca_argp_param_set_long_name(async_num_tasks, "async-num-tasks");
372  doca_argp_param_set_description(async_num_tasks, "Async num tasks for asynchronous mode");
375 
376  result = doca_argp_register_param(async_num_tasks);
377  if (result != DOCA_SUCCESS) {
378  DOCA_LOG_ERR("Failed to register async num tasks param: %s", doca_error_get_descr(result));
379  return result;
380  }
381 
382  result = doca_argp_param_create(&is_update_atomic);
383  if (result != DOCA_SUCCESS) {
384  DOCA_LOG_ERR("Failed to create atomic param: %s", doca_error_get_descr(result));
385  return result;
386  }
387 
388  doca_argp_param_set_long_name(is_update_atomic, "atomic");
389  doca_argp_param_set_description(is_update_atomic,
390  "Update DOCA Sync Event using Add operation (Set operation by default)");
393 
394  result = doca_argp_register_param(is_update_atomic);
395  if (result != DOCA_SUCCESS) {
396  DOCA_LOG_ERR("Failed to register atomic param: %s", doca_error_get_descr(result));
397  return result;
398  }
399 
400  return DOCA_SUCCESS;
401 }
402 
403 /*
404  * Validate configured flow by user input
405  *
406  * @se_cfg [in]: user configuration represents command line arguments
407  * @se_rt_objs [in]: sample's runtime resources
408  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
409  */
411  const struct sync_event_runtime_objects *se_rt_objs)
412 {
414 
415  if (!se_cfg->is_async_mode)
416  return DOCA_SUCCESS;
417 
419  if (result != DOCA_SUCCESS) {
420  DOCA_LOG_ERR("DOCA Sync Event asynchronous wait is not supported (%s) on the given device",
422  return result;
423  }
424 
425  if (((int)(se_cfg->async_num_tasks) < 0) || (se_cfg->async_num_tasks > UINT32_MAX)) {
426  DOCA_LOG_ERR("Please specify num async tasksin the range [0, 4294967295] (asynchronous mode)");
428  }
429 
430  return DOCA_SUCCESS;
431 }
432 
433 /*
434  * Start Sample's DOCA Sync Event in asynchronous operation mode
435  *
436  * @se_cfg [in]: user configuration represents command line arguments
437  * @se_rt_objs [in]: sample's runtime resources
438  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
439  */
441  struct sync_event_runtime_objects *se_rt_objs)
442 {
444 
445  se_rt_objs->se_ctx = doca_sync_event_as_ctx(se_rt_objs->se);
446  if (se_rt_objs->se_ctx == NULL) {
447  DOCA_LOG_ERR("Failed to convert sync event to ctx");
448  return result;
449  }
450 
451  result = doca_pe_create(&se_rt_objs->se_pe);
452  if (result != DOCA_SUCCESS) {
453  DOCA_LOG_ERR("Failed to create doca pe: %s", doca_error_get_descr(result));
454  return result;
455  }
456 
457  result = doca_pe_connect_ctx(se_rt_objs->se_pe, se_rt_objs->se_ctx);
458  if (result != DOCA_SUCCESS) {
459  DOCA_LOG_ERR("Failed to bind pe with sync event: %s", doca_error_get_descr(result));
460  return result;
461  }
462 
463  union doca_data ctx_user_data = {.ptr = (void *)se_rt_objs};
464 
465  result = doca_ctx_set_user_data(se_rt_objs->se_ctx, ctx_user_data);
466  if (result != DOCA_SUCCESS) {
467  DOCA_LOG_ERR("Failed to set user data for se ctx: %s", doca_error_get_descr(result));
468  return result;
469  }
470 
474  se_cfg->async_num_tasks);
475  if (result != DOCA_SUCCESS) {
476  DOCA_LOG_ERR("Failed to set get task configuration: %s", doca_error_get_descr(result));
477  return result;
478  }
479 
483  se_cfg->async_num_tasks);
484  if (result != DOCA_SUCCESS) {
485  DOCA_LOG_ERR("Failed to set notify set task configuration: %s", doca_error_get_descr(result));
486  return result;
487  }
488 
492  se_cfg->async_num_tasks);
493  if (result != DOCA_SUCCESS) {
494  DOCA_LOG_ERR("Failed to add notify set task configuration: %s", doca_error_get_descr(result));
495  return result;
496  }
497 
501  se_cfg->async_num_tasks);
502  if (result != DOCA_SUCCESS) {
503  DOCA_LOG_ERR("Failed to set wait-grater-than task configuration: %s", doca_error_get_descr(result));
504  return result;
505  }
506 
507  result = doca_ctx_start(se_rt_objs->se_ctx);
508  if (result != DOCA_SUCCESS) {
509  DOCA_LOG_ERR("Failed to start sync event ctx: %s", doca_error_get_descr(result));
510  return result;
511  }
512 
513  return DOCA_SUCCESS;
514 }
515 
516 /*
517  * Callback for send completions
518  *
519  * Frees the allocated task that was used for the send
520  *
521  * @task [in]: send task that has completed
522  * @task_user_data [in]: user data of task
523  * @ctx_user_data [in]: user data of doca context
524  */
525 static void comch_send_completion_cb(struct doca_comch_task_send *task,
526  union doca_data task_user_data,
527  union doca_data ctx_user_data)
528 {
529  (void)task_user_data;
530  (void)ctx_user_data;
531 
533 }
534 
535 /*
536  * Callback for send completion error
537  *
538  * Frees the allocated task that was used for the send
539  * Unexpected code path so logs an error
540  *
541  * @task [in]: send task that has completed
542  * @task_user_data [in]: user data of task
543  * @ctx_user_data [in]: user data of doca context
544  */
545 static void comch_send_completion_err_cb(struct doca_comch_task_send *task,
546  union doca_data task_user_data,
547  union doca_data ctx_user_data)
548 {
549  (void)task_user_data;
550  (void)ctx_user_data;
551 
553  DOCA_LOG_ERR("Send Task got a completion error");
554 }
555 
556 #ifdef DOCA_ARCH_DPU
557 /*
558  * Callback for new server connection
559  *
560  * @event [in]: connection event
561  * @comch_connection [in]: doca connection that triggered the event
562  * @change_successful [in]: indicator of change success
563  */
564 static void comch_server_connection_cb(struct doca_comch_event_connection_status_changed *event,
565  struct doca_comch_connection *comch_connection,
566  uint8_t change_successful)
567 {
568  struct doca_comch_server *server = doca_comch_server_get_server_ctx(comch_connection);
569  struct sync_event_runtime_objects *se_rt_objs;
570  union doca_data ctx_user_data;
572 
573  (void)event;
574  (void)change_successful;
575 
576  result = doca_ctx_get_user_data(doca_comch_server_as_ctx(server), &ctx_user_data);
577  if (result != DOCA_SUCCESS) {
578  DOCA_LOG_ERR("Failed to get user data from server context: %s", doca_error_get_descr(result));
579  return;
580  }
581 
582  se_rt_objs = (struct sync_event_runtime_objects *)ctx_user_data.ptr;
583  se_rt_objs->comch_connection = comch_connection;
584 
585  DOCA_LOG_INFO("Server received a new connection");
586 }
587 
588 /*
589  * Callback for server disconnection
590  *
591  * @event [in]: connection event
592  * @comch_connection [in]: doca connection that triggered the event
593  * @change_successful [in]: indicator of change success
594  */
595 static void comch_server_disconnection_cb(struct doca_comch_event_connection_status_changed *event,
596  struct doca_comch_connection *comch_connection,
597  uint8_t change_successful)
598 {
599  struct doca_comch_server *server = doca_comch_server_get_server_ctx(comch_connection);
600  struct sync_event_runtime_objects *se_rt_objs;
601  union doca_data ctx_user_data;
603 
604  (void)event;
605  (void)change_successful;
606 
607  result = doca_ctx_get_user_data(doca_comch_server_as_ctx(server), &ctx_user_data);
608  if (result != DOCA_SUCCESS) {
609  DOCA_LOG_ERR("Failed to get user data from server context: %s", doca_error_get_descr(result));
610  return;
611  }
612 
613  se_rt_objs = (struct sync_event_runtime_objects *)ctx_user_data.ptr;
614  se_rt_objs->comch_connection = NULL;
615 
616  DOCA_LOG_INFO("Client has disconnected from server");
617 }
618 
619 /*
620  * Initialize Sample's DOCA comch
621  *
622  * @se_rt_objs [in/out]: sample's runtime resources
623  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
624  */
626 {
627  union doca_data user_data = {0};
629 
630  result = doca_pe_create(&se_rt_objs->comch_pe);
631  if (result != DOCA_SUCCESS) {
632  DOCA_LOG_ERR("Failed to progress engine for comch: %s", doca_error_get_descr(result));
633  return result;
634  }
635 
636  result = doca_comch_server_create(se_rt_objs->dev,
637  se_rt_objs->rep,
639  &se_rt_objs->server);
640  if (result != DOCA_SUCCESS) {
641  DOCA_LOG_ERR("Failed to create comch server: %s", doca_error_get_descr(result));
642  return result;
643  }
644 
646  if (result != DOCA_SUCCESS) {
647  DOCA_LOG_ERR("Failed set max message size of server: %s", doca_error_get_descr(result));
648  return result;
649  }
650 
652  if (result != DOCA_SUCCESS) {
653  DOCA_LOG_ERR("Failed set server recv queue size: %s", doca_error_get_descr(result));
654  return result;
655  }
656 
658  if (result != DOCA_SUCCESS) {
659  DOCA_LOG_ERR("Failed to connect comch server context to progress engine: %s",
661  return result;
662  }
663 
668  if (result != DOCA_SUCCESS) {
669  DOCA_LOG_ERR("Failed to configure server task pool: %s", doca_error_get_descr(result));
670  return result;
671  }
672 
674  if (result != DOCA_SUCCESS) {
675  DOCA_LOG_ERR("Failed to register comch server receive event callback: %s",
677  return result;
678  }
679 
681  comch_server_connection_cb,
682  comch_server_disconnection_cb);
683  if (result != DOCA_SUCCESS) {
684  DOCA_LOG_ERR("Failed to register comch server event callback: %s", doca_error_get_descr(result));
685  return result;
686  }
687 
688  user_data.ptr = se_rt_objs;
689  doca_ctx_set_user_data(doca_comch_server_as_ctx(se_rt_objs->server), user_data);
690 
691  return DOCA_SUCCESS;
692 }
693 
694 /*
695  * Establish a connection on DOCA comch
696  *
697  * @se_rt_objs [in/out]: sample's runtime resources
698  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
699  */
701 {
703  int timeout = SYNC_EVENT_CC_TIMEOUT_SEC;
704 
705  result = sync_event_cc_init(se_rt_objs);
706  if (result != DOCA_SUCCESS)
707  return result;
708 
709  se_rt_objs->comch_connection = NULL;
710 
712  if (result != DOCA_SUCCESS) {
713  DOCA_LOG_ERR("Failed to start comch server context: %s", doca_error_get_descr(result));
714  return result;
715  }
716 
717  /* Connection will be populated by the cb when a single client connects */
718  while (se_rt_objs->comch_connection == NULL) {
719  sleep(1);
720  timeout--;
721 
722  if (timeout == 0) {
723  DOCA_LOG_ERR("Failed to receive connection from host: timeout");
724  return DOCA_ERROR_TIME_OUT;
725  }
726  (void)doca_pe_progress(se_rt_objs->comch_pe);
727  }
728 
729  DOCA_LOG_INFO("Received connection from host");
730 
731  return DOCA_SUCCESS;
732 }
733 #else /* host */
734 
735 /*
736  * Initialize Sample's DOCA comch
737  *
738  * @se_rt_objs [in/out]: sample's runtime resources
739  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
740  */
742 {
743  union doca_data user_data = {0};
745 
746  result = doca_pe_create(&se_rt_objs->comch_pe);
747  if (result != DOCA_SUCCESS) {
748  DOCA_LOG_ERR("Failed to progress engine for comch: %s", doca_error_get_descr(result));
749  return result;
750  }
751 
753  if (result != DOCA_SUCCESS) {
754  DOCA_LOG_ERR("Failed to create comch server: %s", doca_error_get_descr(result));
755  return result;
756  }
757 
759  if (result != DOCA_SUCCESS) {
760  DOCA_LOG_ERR("Failed set max message size of client: %s", doca_error_get_descr(result));
761  return result;
762  }
763 
765  if (result != DOCA_SUCCESS) {
766  DOCA_LOG_ERR("Failed set client recv queue size: %s", doca_error_get_descr(result));
767  return result;
768  }
769 
771  if (result != DOCA_SUCCESS) {
772  DOCA_LOG_ERR("Failed to connect comch client context to progress engine: %s",
774  return result;
775  }
776 
781  if (result != DOCA_SUCCESS) {
782  DOCA_LOG_ERR("Failed to configure client task pool: %s", doca_error_get_descr(result));
783  return result;
784  }
785 
787  if (result != DOCA_SUCCESS) {
788  DOCA_LOG_ERR("Failed to register comch client receive event callback: %s",
790  return result;
791  }
792 
793  user_data.ptr = se_rt_objs;
794  doca_ctx_set_user_data(doca_comch_client_as_ctx(se_rt_objs->client), user_data);
795 
796  return DOCA_SUCCESS;
797 }
798 
799 /*
800  * Establish a connection on DOCA comch
801  *
802  * @se_rt_objs [in/out]: sample's runtime resources
803  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
804  */
806 {
808  int timeout = SYNC_EVENT_CC_TIMEOUT_SEC;
809  enum doca_ctx_states state;
810 
811  result = sync_event_cc_init(se_rt_objs);
812  if (result != DOCA_SUCCESS)
813  return result;
814 
817  DOCA_LOG_ERR("Failed to start comch client: %s", doca_error_get_descr(result));
818  return result;
819  }
820 
821  /* Wait for client/server handshake to complete */
822  (void)doca_ctx_get_state(doca_comch_client_as_ctx(se_rt_objs->client), &state);
823  while (state != DOCA_CTX_STATE_RUNNING) {
824  sleep(1);
825  timeout--;
826 
827  if (timeout == 0) {
828  DOCA_LOG_ERR("Failed to connect to server: timeout");
829  return DOCA_ERROR_TIME_OUT;
830  }
831  (void)doca_pe_progress(se_rt_objs->comch_pe);
832  (void)doca_ctx_get_state(doca_comch_client_as_ctx(se_rt_objs->client), &state);
833  }
834 
835  result = doca_comch_client_get_connection(se_rt_objs->client, &se_rt_objs->comch_connection);
836  if (result != DOCA_SUCCESS) {
837  DOCA_LOG_ERR("Failed to set connection from client: %s", doca_error_get_descr(result));
838  return result;
839  }
840 
841  DOCA_LOG_INFO("Connection to DPU has been established");
842 
843  return DOCA_SUCCESS;
844 }
845 #endif
846 
847 /*
848  * Submit asynchronous DOCA task on sample's DOCA Sync Event (DOCA) Context
849  *
850  * @se_rt_objs [in]: sample's runtime resources
851  * @se_task [in]: DOCA task to submit
852  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
853  */
854 doca_error_t sync_event_async_task_submit(struct sync_event_runtime_objects *se_rt_objs, struct doca_task *se_task)
855 {
857  int timeout = TIMEOUT_IN_NANOS;
858  struct timespec ts = {
859  .tv_sec = 0,
860  .tv_nsec = SLEEP_IN_NANOS,
861  };
862 
863  result = doca_task_submit(se_task);
864  if (result != DOCA_SUCCESS) {
865  DOCA_LOG_ERR("Failed to submit set task for sync event: %s", doca_error_get_descr(result));
866  return result;
867  }
868 
869  while (doca_pe_progress(se_rt_objs->se_pe) == 0) {
870  if (timeout == 0) {
871  DOCA_LOG_ERR("Failed to retrieve set task progress: timeout");
872  return DOCA_ERROR_TIME_OUT;
873  }
874 
875  nanosleep(&ts, &ts);
876  timeout -= SLEEP_IN_NANOS;
877  }
878 
879  if (se_rt_objs->se_task_result != DOCA_SUCCESS) {
880  DOCA_LOG_ERR("Failed to execute set task for sync event: %s",
881  doca_error_get_descr(se_rt_objs->se_task_result));
882  return result;
883  }
884 
885  return DOCA_SUCCESS;
886 }
887 
888 /*
889  * Sample's tear down flow
890  *
891  * @se_cfg [in]: user configuration represents command line arguments
892  * @se_rt_objs [in]: sample's runtime resources
893  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
894  */
896 {
898  enum doca_ctx_states state;
899  int timeout;
900 
901 #ifdef DOCA_ARCH_DPU
902  timeout = SYNC_EVENT_CC_TIMEOUT_SEC;
903 
904  /* Wait for the client to disconnect before destroying server */
905  while (se_rt_objs->comch_connection != NULL) {
906  sleep(1);
907  timeout--;
908  if (timeout == 0) {
909  DOCA_LOG_ERR("Server did not get client disconnection: timeout");
910  break;
911  }
912  (void)doca_pe_progress(se_rt_objs->comch_pe);
913  }
914 
915  status = doca_ctx_stop(doca_comch_server_as_ctx(se_rt_objs->server));
916  if (status != DOCA_ERROR_IN_PROGRESS && status != DOCA_SUCCESS)
917  DOCA_LOG_ERR("Failed to stop comch server: %s", doca_error_get_descr(status));
918 
919  timeout = SYNC_EVENT_CC_TIMEOUT_SEC;
920  (void)doca_ctx_get_state(doca_comch_server_as_ctx(se_rt_objs->server), &state);
921  while (state != DOCA_CTX_STATE_IDLE) {
922  sleep(1);
923  timeout--;
924  if (timeout == 0) {
925  DOCA_LOG_ERR("Server could not move to idle state: timeout");
926  break;
927  }
928  (void)doca_pe_progress(se_rt_objs->comch_pe);
929  (void)doca_ctx_get_state(doca_comch_server_as_ctx(se_rt_objs->server), &state);
930  }
931 
932  status = doca_comch_server_destroy(se_rt_objs->server);
933  if (status != DOCA_SUCCESS)
934  DOCA_LOG_ERR("Failed to destroy server: %s", doca_error_get_descr(status));
935  se_rt_objs->server = NULL;
936 #else
937  status = doca_ctx_stop(doca_comch_client_as_ctx(se_rt_objs->client));
938  if (status != DOCA_ERROR_IN_PROGRESS && status != DOCA_SUCCESS)
939  DOCA_LOG_ERR("Failed to stop comch client: %s", doca_error_get_descr(status));
940 
941  timeout = SYNC_EVENT_CC_TIMEOUT_SEC;
942  (void)doca_ctx_get_state(doca_comch_client_as_ctx(se_rt_objs->client), &state);
943  while (state != DOCA_CTX_STATE_IDLE) {
944  sleep(1);
945  timeout--;
946  if (timeout == 0) {
947  DOCA_LOG_ERR("Client could not move to idle state: timeout");
948  break;
949  }
950  (void)doca_pe_progress(se_rt_objs->comch_pe);
951  (void)doca_ctx_get_state(doca_comch_client_as_ctx(se_rt_objs->client), &state);
952  }
953 
954  status = doca_comch_client_destroy(se_rt_objs->client);
955  if (status != DOCA_SUCCESS)
956  DOCA_LOG_ERR("Failed to destroy client: %s", doca_error_get_descr(status));
957  se_rt_objs->client = NULL;
958 #endif
959 
960  status = doca_pe_destroy(se_rt_objs->comch_pe);
961  if (status != DOCA_SUCCESS)
962  DOCA_LOG_ERR("Failed to destroy progress engine: %s", doca_error_get_descr(status));
963  se_rt_objs->comch_pe = NULL;
964 
965  if (se_rt_objs->se_ctx != NULL) {
966  status = doca_ctx_stop(se_rt_objs->se_ctx);
967  if (status == DOCA_ERROR_IN_PROGRESS) {
968  size_t inflight_tasks;
969  enum doca_ctx_states ctx_state;
970  int timeout = TIMEOUT_IN_NANOS;
971  struct timespec ts = {
972  .tv_sec = 0,
973  .tv_nsec = SLEEP_IN_NANOS,
974  };
975  do {
976  (void)doca_pe_progress(se_rt_objs->se_pe);
977  status = doca_ctx_get_num_inflight_tasks(se_rt_objs->se_ctx, &inflight_tasks);
978  if (status != DOCA_SUCCESS) {
979  DOCA_LOG_ERR("Failed to get num inflight tasks: %s",
980  doca_error_get_descr(status));
981  return;
982  }
983  nanosleep(&ts, &ts);
984  timeout -= SLEEP_IN_NANOS;
985  } while (inflight_tasks != 0 && timeout > 0);
986 
987  status = doca_ctx_get_state(se_rt_objs->se_ctx, &ctx_state);
988  if (status != DOCA_SUCCESS) {
989  DOCA_LOG_ERR("Failed get status of context, err: %s", doca_error_get_name(status));
990  return;
991  }
992  status = ctx_state == DOCA_CTX_STATE_IDLE ? DOCA_SUCCESS : DOCA_ERROR_BAD_STATE;
993  }
994 
995  if (status != DOCA_SUCCESS) {
996  DOCA_LOG_ERR("Failed to stop DOCA context, err: %s", doca_error_get_name(status));
997  return;
998  }
999  }
1000 
1001  if (se_rt_objs->se != NULL) {
1002  if (se_rt_objs->se_ctx == NULL) {
1003  status = doca_sync_event_stop(se_rt_objs->se);
1004  if (status != DOCA_SUCCESS)
1005  DOCA_LOG_ERR("Failed to stop se: %s", doca_error_get_descr(status));
1006  }
1007  status = doca_sync_event_destroy(se_rt_objs->se);
1008  if (status != DOCA_SUCCESS)
1009  DOCA_LOG_ERR("Failed to destroy se: %s", doca_error_get_descr(status));
1010  }
1011 
1012  if (se_rt_objs->se_pe != NULL) {
1013  status = doca_pe_destroy(se_rt_objs->se_pe);
1014  if (status != DOCA_SUCCESS)
1015  DOCA_LOG_ERR("Failed to destroy ep: %s", doca_error_get_descr(status));
1016  }
1017 
1018  if (se_rt_objs->rep != NULL) {
1019  status = doca_dev_rep_close(se_rt_objs->rep);
1020  if (status != DOCA_SUCCESS)
1021  DOCA_LOG_ERR("Failed to close rep: %s", doca_error_get_descr(status));
1022  }
1023 
1024  if (se_rt_objs->dev != NULL) {
1025  status = doca_dev_close(se_rt_objs->dev);
1026  if (status != DOCA_SUCCESS)
1027  DOCA_LOG_ERR("Failed to close dev: %s", doca_error_get_descr(status));
1028  }
1029 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
static void task_error_cb(struct doca_task *se_task, union doca_data task_user_data, union doca_data ctx_user_data)
Definition: common_common.c:65
static void task_get_completion_cb(struct doca_sync_event_task_get *task, union doca_data task_user_data, union doca_data ctx_user_data)
Definition: common_common.c:84
void sync_event_tear_down(struct sync_event_runtime_objects *se_rt_objs)
static doca_error_t dev_pci_addr_cb(void *param, void *config)
DOCA_LOG_REGISTER(SYNC_EVENT::COMMON)
doca_error_t sync_event_async_task_submit(struct sync_event_runtime_objects *se_rt_objs, struct doca_task *se_task)
static doca_error_t pci_addr_cb(const char *pci_addr_src, char pci_addr_dest[DOCA_DEVINFO_PCI_ADDR_SIZE])
static doca_error_t sync_event_cc_init(struct sync_event_runtime_objects *se_rt_objs)
doca_error_t sync_event_params_register(void)
static doca_error_t is_update_atomic_cb(void *param, void *config)
static void task_wait_eq_error_cb(struct doca_sync_event_task_wait_eq *task, union doca_data task_user_data, union doca_data ctx_user_data)
doca_error_t sync_event_start_async(const struct sync_event_config *se_cfg, struct sync_event_runtime_objects *se_rt_objs)
static doca_error_t async_num_tasks_cb(void *param, void *config)
doca_error_t sync_event_cc_handshake(struct sync_event_runtime_objects *se_rt_objs)
static void task_notify_add_error_cb(struct doca_sync_event_task_notify_add *task, union doca_data task_user_data, union doca_data ctx_user_data)
static void comch_send_completion_cb(struct doca_comch_task_send *task, union doca_data task_user_data, union doca_data ctx_user_data)
static void task_completion_cb(struct doca_task *se_task, union doca_data task_user_data, union doca_data ctx_user_data)
Definition: common_common.c:48
static void task_notify_set_completion_cb(struct doca_sync_event_task_notify_set *task, union doca_data task_user_data, union doca_data ctx_user_data)
static void task_notify_add_completion_cb(struct doca_sync_event_task_notify_add *task, union doca_data task_user_data, union doca_data ctx_user_data)
static void task_get_error_cb(struct doca_sync_event_task_get *task, union doca_data task_user_data, union doca_data ctx_user_data)
static void task_notify_set_error_cb(struct doca_sync_event_task_notify_set *task, union doca_data task_user_data, union doca_data ctx_user_data)
#define TIMEOUT_IN_NANOS
Definition: common_common.c:39
doca_error_t sync_event_config_validate(const struct sync_event_config *se_cfg, const struct sync_event_runtime_objects *se_rt_objs)
static void task_wait_eq_completion_cb(struct doca_sync_event_task_wait_eq *task, union doca_data task_user_data, union doca_data ctx_user_data)
static void comch_send_completion_err_cb(struct doca_comch_task_send *task, union doca_data task_user_data, union doca_data ctx_user_data)
static doca_error_t is_async_mode_cb(void *param, void *config)
static doca_error_t rep_pci_addr_cb(void *param, void *config)
#define SLEEP_IN_NANOS
Definition: common_common.c:38
#define SYNC_EVENT_CC_MAX_QUEUE_SIZE
Definition: common_common.h:38
#define SYNC_EVENT_CC_MAX_TASKS
Definition: common_common.h:39
#define SYNC_EVENT_CC_SERVICE_NAME
Definition: common_common.h:40
#define SYNC_EVENT_CC_MAX_MSG_SIZE
Definition: common_common.h:37
#define SYNC_EVENT_CC_TIMEOUT_SEC
Definition: common_common.h:41
uint64_t len
DOCA_EXPERIMENTAL void doca_argp_param_set_description(struct doca_argp_param *param, const char *description)
Set the description of the program param, used during program usage.
DOCA_EXPERIMENTAL void doca_argp_param_set_long_name(struct doca_argp_param *param, const char *name)
Set the long name of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_callback(struct doca_argp_param *param, doca_argp_param_cb_t callback)
Set the callback function of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_mandatory(struct doca_argp_param *param)
Mark the program param as mandatory.
DOCA_EXPERIMENTAL doca_error_t doca_argp_param_create(struct doca_argp_param **param)
Create new program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_type(struct doca_argp_param *param, enum doca_argp_type type)
Set the type of the param arguments.
DOCA_EXPERIMENTAL void doca_argp_param_set_short_name(struct doca_argp_param *param, const char *name)
Set the short name of the program param.
DOCA_EXPERIMENTAL doca_error_t doca_argp_register_param(struct doca_argp_param *input_param)
Register a program flag.
@ DOCA_ARGP_TYPE_STRING
Definition: doca_argp.h:56
@ DOCA_ARGP_TYPE_BOOLEAN
Definition: doca_argp.h:58
@ DOCA_ARGP_TYPE_INT
Definition: doca_argp.h:57
DOCA_STABLE doca_error_t doca_comch_client_set_max_msg_size(struct doca_comch_client *comch_client, uint32_t size)
DOCA_STABLE doca_error_t doca_comch_client_get_connection(const struct doca_comch_client *comch_client, struct doca_comch_connection **connection)
DOCA_STABLE struct doca_comch_server * doca_comch_server_get_server_ctx(const struct doca_comch_connection *connection)
DOCA_STABLE doca_error_t doca_comch_server_event_msg_recv_register(struct doca_comch_server *comch_server, doca_comch_event_msg_recv_cb_t recv_event_cb)
Configure the doca_comch recv event callback for server context.
DOCA_STABLE doca_error_t doca_comch_server_event_connection_status_changed_register(struct doca_comch_server *comch_server, doca_comch_event_connection_status_changed_cb_t connect_event_cb, doca_comch_event_connection_status_changed_cb_t disconnect_event_cb)
Configure the doca_comch recv event callback for server context.
DOCA_STABLE doca_error_t doca_comch_client_set_recv_queue_size(struct doca_comch_client *comch_client, uint32_t size)
DOCA_STABLE struct doca_ctx * doca_comch_client_as_ctx(struct doca_comch_client *comch_client)
DOCA_STABLE doca_error_t doca_comch_server_destroy(struct doca_comch_server *comch_server)
DOCA_STABLE doca_error_t doca_comch_server_task_send_set_conf(struct doca_comch_server *comch_server, doca_comch_task_send_completion_cb_t task_completion_cb, doca_comch_task_send_completion_cb_t task_error_cb, uint32_t num_send_tasks)
DOCA_STABLE doca_error_t doca_comch_client_task_send_set_conf(struct doca_comch_client *comch_client, doca_comch_task_send_completion_cb_t task_completion_cb, doca_comch_task_send_completion_cb_t task_error_cb, uint32_t num_send_tasks)
DOCA_STABLE doca_error_t doca_comch_server_set_recv_queue_size(struct doca_comch_server *comch_server, uint32_t size)
DOCA_STABLE doca_error_t doca_comch_client_event_msg_recv_register(struct doca_comch_client *comch_client, doca_comch_event_msg_recv_cb_t recv_event_cb)
Configure the doca_comch recv event callback for client context.
DOCA_STABLE doca_error_t doca_comch_client_destroy(struct doca_comch_client *comch_client)
DOCA_STABLE doca_error_t doca_comch_server_create(struct doca_dev *dev, struct doca_dev_rep *repr, const char *name, struct doca_comch_server **comch_server)
DOCA_STABLE struct doca_task * doca_comch_task_send_as_task(struct doca_comch_task_send *task)
DOCA_STABLE doca_error_t doca_comch_server_set_max_msg_size(struct doca_comch_server *comch_server, uint32_t size)
DOCA_STABLE doca_error_t doca_comch_client_create(struct doca_dev *dev, const char *name, struct doca_comch_client **comch_client)
DOCA_STABLE struct doca_ctx * doca_comch_server_as_ctx(struct doca_comch_server *comch_server)
DOCA_STABLE doca_error_t doca_ctx_start(struct doca_ctx *ctx)
Finalizes all configurations, and starts the DOCA CTX.
DOCA_STABLE doca_error_t doca_ctx_get_state(const struct doca_ctx *ctx, enum doca_ctx_states *state)
Get context state.
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_get_num_inflight_tasks(const struct doca_ctx *ctx, size_t *num_inflight_tasks)
Get number of in flight tasks in a doca context.
DOCA_STABLE doca_error_t doca_ctx_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
doca_ctx_states
This enum defines the states of a context.
Definition: doca_ctx.h:83
DOCA_STABLE doca_error_t doca_ctx_get_user_data(const struct doca_ctx *ctx, union doca_data *user_data)
get user data from context
@ DOCA_CTX_STATE_IDLE
Definition: doca_ctx.h:88
@ DOCA_CTX_STATE_RUNNING
Definition: doca_ctx.h:98
DOCA_STABLE doca_error_t doca_dev_rep_close(struct doca_dev_rep *dev)
Destroy allocated representor device instance.
#define DOCA_DEVINFO_PCI_ADDR_SIZE
Buffer size to hold PCI BDF format: "XXXX:XX:XX.X". Including a null terminator.
Definition: doca_dev.h:313
DOCA_STABLE struct doca_devinfo * doca_dev_as_devinfo(const struct doca_dev *dev)
Get local device info from device. This should be useful when wanting to query information about devi...
DOCA_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_name(doca_error_t error)
Returns the string representation of an error code name.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_TIME_OUT
Definition: doca_error.h:47
@ DOCA_ERROR_INVALID_VALUE
Definition: doca_error.h:44
@ DOCA_ERROR_UNKNOWN
Definition: doca_error.h:39
@ DOCA_ERROR_BAD_STATE
Definition: doca_error.h:56
@ DOCA_SUCCESS
Definition: doca_error.h:38
@ DOCA_ERROR_IN_PROGRESS
Definition: doca_error.h:64
#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_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_task_submit(struct doca_task *task)
Submit a task to a progress engine.
DOCA_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
DOCA_STABLE doca_error_t doca_pe_create(struct doca_pe **pe)
Creates DOCA progress engine.
DOCA_STABLE void doca_task_free(struct doca_task *task)
Free a task back to where it was allocated from.
DOCA_EXPERIMENTAL struct doca_task * doca_sync_event_task_notify_set_as_doca_task(struct doca_sync_event_task_notify_set *task)
Convert a DOCA Sync Event notify-set task to a DOCA Task.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_task_notify_add_set_conf(struct doca_sync_event *event, doca_sync_event_task_notify_add_completion_cb_t completion_cb, doca_sync_event_task_notify_add_completion_cb_t error_cb, uint32_t num_tasks)
Set the DOCA Sync Event notify-add task configuration.
DOCA_EXPERIMENTAL struct doca_task * doca_sync_event_task_wait_eq_as_doca_task(struct doca_sync_event_task_wait_eq *task)
Convert a DOCA Sync Event wait-equal task to a DOCA Task.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_task_get_set_conf(struct doca_sync_event *event, doca_sync_event_task_get_completion_cb_t completion_cb, doca_sync_event_task_get_completion_cb_t error_cb, uint32_t num_tasks)
Set the DOCA Sync Event get task configuration.
DOCA_EXPERIMENTAL struct doca_task * doca_sync_event_task_get_as_doca_task(struct doca_sync_event_task_get *task)
Convert a DOCA Sync Event get task to a DOCA Task.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_task_wait_eq_set_conf(struct doca_sync_event *event, doca_sync_event_task_wait_eq_completion_cb_t completion_cb, doca_sync_event_task_wait_eq_completion_cb_t error_cb, uint32_t num_tasks)
Set the DOCA Sync Event wait-equal task configuration.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_cap_task_wait_eq_is_supported(const struct doca_devinfo *devinfo)
Check if a given device supports submitting a DOCA Sync Event wait-equal task.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_task_notify_set_set_conf(struct doca_sync_event *event, doca_sync_event_task_notify_set_completion_cb_t completion_cb, doca_sync_event_task_notify_set_completion_cb_t error_cb, uint32_t num_tasks)
Set the DOCA Sync Event notify-set task configuration.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_stop(struct doca_sync_event *event)
Stop a Sync Event which has been previously started with 'doca_sync_event_start'.
DOCA_EXPERIMENTAL struct doca_ctx * doca_sync_event_as_ctx(struct doca_sync_event *event)
Convert a Sync Event to a DOCA context.
DOCA_EXPERIMENTAL struct doca_task * doca_sync_event_task_notify_add_as_doca_task(struct doca_sync_event_task_notify_add *task)
Convert a DOCA Sync Event notify-add task to a DOCA Task.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_destroy(struct doca_sync_event *event)
Destroy a Sync Event instance.
uint32_t async_num_tasks
Definition: common_common.h:51
struct doca_dev * dev
Definition: common_common.h:56
struct doca_comch_connection * comch_connection
Definition: common_common.h:69
struct doca_pe * se_pe
Definition: common_common.h:60
struct doca_comch_server * server
Definition: common_common.h:66
struct doca_pe * comch_pe
Definition: common_common.h:64
struct doca_ctx * se_ctx
Definition: common_common.h:59
doca_comch_event_msg_recv_cb_t comch_recv_event_cb
Definition: common_common.h:70
struct doca_comch_client * client
Definition: common_common.h:67
struct doca_sync_event * se
Definition: common_common.h:58
struct doca_dev_rep * rep
Definition: common_common.h:57
Convenience type for representing opaque data.
Definition: doca_types.h:56
void * ptr
Definition: doca_types.h:57