NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
comch_data_path_high_speed_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 <time.h>
27 
28 #include <doca_buf.h>
29 #include <doca_comch.h>
30 #include <doca_comch_consumer.h>
31 #include <doca_comch_producer.h>
32 #include <doca_ctx.h>
33 #include <doca_dev.h>
34 #include <doca_error.h>
35 #include <doca_log.h>
36 #include <doca_pe.h>
37 
38 #include "comch_ctrl_path_common.h"
40 #include "common.h"
41 
42 DOCA_LOG_REGISTER(COMCH_DATA_PATH_HIGH_SPEED_COMMON);
43 
45 {
47  void *mem;
48  size_t mem_size;
49 
50  if (local == NULL)
51  return;
52 
53  if (local->need_alloc_mem == true) {
54  result = doca_mmap_get_memrange(local->mmap, &mem, &mem_size);
55  if (result != DOCA_SUCCESS) {
56  DOCA_LOG_ERR("Unable to get mmap memrange: %s", doca_error_get_descr(result));
57  return;
58  }
59  free(mem);
60  }
61  local->mem = NULL;
62 
63  result = doca_mmap_destroy(local->mmap);
64  if (result != DOCA_SUCCESS) {
65  DOCA_LOG_ERR("Failed to destroy mmap: %s", doca_error_get_descr(result));
66  return;
67  }
68  local->mmap = NULL;
69 
71  if (result != DOCA_SUCCESS) {
72  DOCA_LOG_ERR("Failed to destroy inventory: %s", doca_error_get_descr(result));
73  return;
74  }
75  local->buf_inv = NULL;
76 }
77 
78 doca_error_t init_local_mem_bufs(struct local_mem_bufs *local, struct doca_dev *dev, size_t buf_len, size_t max_bufs)
79 {
81 
82  if (local->need_alloc_mem == true) {
83  local->mem = (char *)malloc(max_bufs * buf_len);
84  if (local->mem == NULL) {
86  DOCA_LOG_ERR("Unable to alloc memory to mmap: %s", doca_error_get_descr(result));
87  return result;
88  }
89  }
90 
91  result = doca_buf_inventory_create(max_bufs, &(local->buf_inv));
92  if (result != DOCA_SUCCESS) {
93  DOCA_LOG_ERR("Unable to create inventory: %s", doca_error_get_descr(result));
94  goto free_mem;
95  }
96 
98  if (result != DOCA_SUCCESS) {
99  DOCA_LOG_ERR("Unable to start inventory: %s", doca_error_get_descr(result));
100  goto destroy_inv;
101  }
102 
103  result = doca_mmap_create(&local->mmap);
104  if (result != DOCA_SUCCESS) {
105  DOCA_LOG_ERR("Unable to create mmap: %s", doca_error_get_descr(result));
106  goto destroy_inv;
107  }
108 
109  result = doca_mmap_add_dev(local->mmap, dev);
110  if (result != DOCA_SUCCESS) {
111  DOCA_LOG_ERR("Unable to add device to mmap: %s", doca_error_get_descr(result));
112  goto destroy_mmap;
113  }
114 
116  if (result != DOCA_SUCCESS) {
117  DOCA_LOG_ERR("Unable to set permission to mmap: %s", doca_error_get_descr(result));
118  goto destroy_mmap;
119  }
120 
121  result = doca_mmap_set_memrange(local->mmap, local->mem, max_bufs * buf_len);
122  if (result != DOCA_SUCCESS) {
123  DOCA_LOG_ERR("Unable to set memrange to mmap: %s", doca_error_get_descr(result));
124  goto destroy_mmap;
125  }
126 
127  result = doca_mmap_start(local->mmap);
128  if (result != DOCA_SUCCESS) {
129  DOCA_LOG_ERR("Unable to start mmap: %s", doca_error_get_descr(result));
130  goto destroy_mmap;
131  }
132 
133  return DOCA_SUCCESS;
134 
135 destroy_mmap:
136  doca_mmap_destroy(local->mmap);
137  local->mmap = NULL;
138 destroy_inv:
140  local->buf_inv = NULL;
141 free_mem:
142  if (local->need_alloc_mem == true) {
143  free(local->mem);
144  local->mem = NULL;
145  }
146  return result;
147 }
148 
149 void clean_comch_producer(struct doca_comch_producer *producer, struct doca_pe *pe)
150 {
152 
153  if (producer != NULL) {
155  if (result != DOCA_SUCCESS)
156  DOCA_LOG_ERR("Failed to destroy producer properly with error=%s", doca_error_get_name(result));
157  }
158 
159  if (pe != NULL) {
161  if (result != DOCA_SUCCESS)
162  DOCA_LOG_ERR("Failed to destroy pe properly with error=%s", doca_error_get_name(result));
163  }
164 }
165 
166 doca_error_t init_comch_producer(struct doca_comch_connection *connection,
168  struct doca_comch_producer **producer,
169  struct doca_pe **pe)
170 {
172  struct doca_ctx *ctx;
173  union doca_data user_data;
174 
176  if (result != DOCA_SUCCESS) {
177  DOCA_LOG_ERR("Failed creating pe with error = %s", doca_error_get_name(result));
178  return result;
179  }
180 
181  result = doca_comch_producer_create(connection, producer);
182  if (result != DOCA_SUCCESS) {
183  DOCA_LOG_ERR("Failed to create producer with error = %s", doca_error_get_name(result));
184  goto destroy_pe;
185  }
186 
187  ctx = doca_comch_producer_as_ctx(*producer);
188 
190  if (result != DOCA_SUCCESS) {
191  DOCA_LOG_ERR("Failed adding pe context to producer with error = %s", doca_error_get_name(result));
192  goto destroy_producer;
193  }
194 
195  result = doca_ctx_set_state_changed_cb(ctx, cfg->ctx_state_changed_cb);
196  if (result != DOCA_SUCCESS) {
197  DOCA_LOG_ERR("Failed setting state change callback with error = %s", doca_error_get_name(result));
198  goto destroy_producer;
199  }
200 
202  cfg->send_task_comp_cb,
203  cfg->send_task_comp_err_cb,
205  if (result != DOCA_SUCCESS) {
206  DOCA_LOG_ERR("Failed setting producer send task cbs with error = %s", doca_error_get_name(result));
207  goto destroy_producer;
208  }
209 
210  user_data.ptr = cfg->ctx_user_data;
211  result = doca_ctx_set_user_data(ctx, user_data);
212  if (result != DOCA_SUCCESS) {
213  DOCA_LOG_ERR("Failed to set ctx user data with error = %s", doca_error_get_name(result));
214  goto destroy_producer;
215  }
216 
218  if (result != DOCA_SUCCESS) {
219  DOCA_LOG_ERR("Failed to start producer context with error = %s", doca_error_get_name(result));
220  goto destroy_producer;
221  }
222 
223  return DOCA_SUCCESS;
224 
225 destroy_producer:
226  doca_comch_producer_destroy(*producer);
227  *producer = NULL;
228 destroy_pe:
230  *pe = NULL;
231  return result;
232 }
233 
234 void clean_comch_consumer(struct doca_comch_consumer *consumer, struct doca_pe *pe)
235 {
237 
238  if (consumer != NULL) {
240  if (result != DOCA_SUCCESS)
241  DOCA_LOG_ERR("Failed to destroy consumer properly with error = %s",
243  }
244 
245  if (pe != NULL) {
247  if (result != DOCA_SUCCESS)
248  DOCA_LOG_ERR("Failed to destroy pe properly with error = %s", doca_error_get_name(result));
249  }
250 }
251 
252 doca_error_t init_comch_consumer(struct doca_comch_connection *connection,
253  struct doca_mmap *user_mmap,
255  struct doca_comch_consumer **consumer,
256  struct doca_pe **pe)
257 {
259  struct doca_ctx *ctx;
260  union doca_data user_data;
261 
263  if (result != DOCA_SUCCESS) {
264  DOCA_LOG_ERR("Failed creating pe with error = %s", doca_error_get_name(result));
265  return result;
266  }
267 
268  result = doca_comch_consumer_create(connection, user_mmap, consumer);
269  if (result != DOCA_SUCCESS) {
270  DOCA_LOG_ERR("Failed to create consumer with error = %s", doca_error_get_name(result));
271  goto destroy_pe;
272  }
273 
274  ctx = doca_comch_consumer_as_ctx(*consumer);
275 
277  if (result != DOCA_SUCCESS) {
278  DOCA_LOG_ERR("Failed adding pe context to server with error = %s", doca_error_get_name(result));
279  goto destroy_consumer;
280  }
281 
282  result = doca_ctx_set_state_changed_cb(ctx, cfg->ctx_state_changed_cb);
283  if (result != DOCA_SUCCESS) {
284  DOCA_LOG_ERR("Failed setting state change callback with error = %s", doca_error_get_name(result));
285  goto destroy_consumer;
286  }
287 
289  cfg->recv_task_comp_cb,
290  cfg->recv_task_comp_err_cb,
292  if (result != DOCA_SUCCESS) {
293  DOCA_LOG_ERR("Failed setting consumer recv task cbs with error = %s", doca_error_get_name(result));
294  goto destroy_consumer;
295  }
296 
297  user_data.ptr = cfg->ctx_user_data;
298  result = doca_ctx_set_user_data(ctx, user_data);
299  if (result != DOCA_SUCCESS) {
300  DOCA_LOG_ERR("Failed to set ctx user data with error = %s", doca_error_get_name(result));
301  goto destroy_consumer;
302  }
303 
306  DOCA_LOG_ERR("Failed to start consumer context with error = %s", doca_error_get_name(result));
307  goto destroy_consumer;
308  }
309 
310  return DOCA_SUCCESS;
311 
312 destroy_consumer:
313  doca_comch_consumer_destroy(*consumer);
314  *consumer = NULL;
315 destroy_pe:
317  *pe = NULL;
318  return result;
319 }
320 
328 static void producer_send_task_completion_callback(struct doca_comch_producer_task_send *task,
329  union doca_data task_user_data,
330  union doca_data ctx_user_data)
331 {
332  struct comch_data_path_objects *data_path;
333  const struct doca_buf *buf;
334 
335  (void)task_user_data;
336 
337  data_path = (struct comch_data_path_objects *)(ctx_user_data.ptr);
338  data_path->producer_result = DOCA_SUCCESS;
339  DOCA_LOG_INFO("Producer task sent successfully");
340 
342  (void)doca_buf_dec_refcount((struct doca_buf *)buf, NULL);
345 }
346 
354 static void producer_send_task_completion_err_callback(struct doca_comch_producer_task_send *task,
355  union doca_data task_user_data,
356  union doca_data ctx_user_data)
357 {
358  struct comch_data_path_objects *data_path;
359  const struct doca_buf *buf;
360 
361  (void)task_user_data;
362 
363  data_path = (struct comch_data_path_objects *)(ctx_user_data.ptr);
365  DOCA_LOG_ERR("Producer message failed to send with error = %s",
367 
369  (void)doca_buf_dec_refcount((struct doca_buf *)buf, NULL);
372 }
373 
381 {
382  struct doca_comch_producer_task_send *producer_task;
383  struct doca_buf *buf;
384  struct doca_task *task_obj;
386 
387  struct timespec ts = {
388  .tv_sec = 0,
389  .tv_nsec = SLEEP_IN_NANOS,
390  };
391 
393  data_path->producer_mem.mmap,
394  (void *)(data_path->text),
395  strnlen(data_path->text, CC_DATA_PATH_MAX_MSG_SIZE),
396  &buf);
397  if (result != DOCA_SUCCESS) {
398  DOCA_LOG_ERR("Failed to get doca buf from producer mmap with error = %s", doca_error_get_name(result));
399  return result;
400  }
401 
403  buf,
404  NULL,
405  0,
406  data_path->remote_consumer_id,
407  &producer_task);
408  if (result != DOCA_SUCCESS) {
409  (void)doca_buf_dec_refcount(buf, NULL);
410  DOCA_LOG_ERR("Failed to get allocate task from producer with error = %s", doca_error_get_name(result));
411  return result;
412  }
413 
414  task_obj = doca_comch_producer_task_send_as_task(producer_task);
415  do {
416  result = doca_task_submit(task_obj);
417  if (result == DOCA_ERROR_AGAIN)
418  nanosleep(&ts, &ts);
419  } while (result == DOCA_ERROR_AGAIN);
420  if (result != DOCA_SUCCESS) {
421  (void)doca_buf_dec_refcount(buf, NULL);
422  doca_task_free(task_obj);
423  DOCA_LOG_ERR("Failed submitting send task with error = %s", doca_error_get_name(result));
424  return result;
425  }
426 
427  return DOCA_SUCCESS;
428 }
429 
438 static void producer_state_changed_callback(const union doca_data user_data,
439  struct doca_ctx *ctx,
440  enum doca_ctx_states prev_state,
441  enum doca_ctx_states next_state)
442 {
443  (void)ctx;
444  (void)prev_state;
445 
446  struct comch_data_path_objects *data_path = (struct comch_data_path_objects *)user_data.ptr;
447 
448  switch (next_state) {
449  case DOCA_CTX_STATE_IDLE:
450  DOCA_LOG_INFO("CC producer context has been stopped");
451  /* We can stop progressing the PE */
452  data_path->producer_finish = true;
453  break;
458  DOCA_LOG_INFO("CC producer context entered into starting state");
459  break;
461  DOCA_LOG_INFO("CC producer context is running. Posting message to consumer, waiting finish");
462  data_path->producer_result = producer_send_msg(data_path);
463  if (data_path->producer_result != DOCA_SUCCESS) {
464  DOCA_LOG_ERR("Failed to submit producer send task with error = %s",
467  }
468  break;
474  DOCA_LOG_INFO("CC producer context entered into stopping state");
475  break;
476  default:
477  break;
478  }
479 }
480 
488 static void consumer_recv_task_completion_callback(struct doca_comch_consumer_task_post_recv *task,
489  union doca_data task_user_data,
490  union doca_data ctx_user_data)
491 {
492  struct comch_data_path_objects *data_path;
493  size_t recv_msg_len;
494  void *recv_msg;
495  struct doca_buf *buf;
496 
497  (void)task_user_data;
498 
499  data_path = (struct comch_data_path_objects *)(ctx_user_data.ptr);
500 
502 
503  data_path->consumer_result = doca_buf_get_data(buf, &recv_msg);
504  if (data_path->consumer_result != DOCA_SUCCESS) {
505  DOCA_LOG_ERR("Failed to get data address from DOCA buf with error = %s",
507  goto err_out;
508  }
509 
510  data_path->consumer_result = doca_buf_get_data_len(buf, &recv_msg_len);
511  if (data_path->consumer_result != DOCA_SUCCESS) {
512  DOCA_LOG_ERR("Failed to get data length from DOCA buf with error = %s",
514  goto err_out;
515  }
516 
517  DOCA_LOG_INFO("Message received: '%.*s'", (int)recv_msg_len, (char *)recv_msg);
518 err_out:
519  (void)doca_buf_dec_refcount(buf, NULL);
522 }
523 
531 static void consumer_recv_task_completion_err_callback(struct doca_comch_consumer_task_post_recv *task,
532  union doca_data task_user_data,
533  union doca_data ctx_user_data)
534 {
535  struct comch_data_path_objects *data_path;
536  struct doca_buf *buf;
537 
538  (void)task_user_data;
539 
540  data_path = (struct comch_data_path_objects *)(ctx_user_data.ptr);
542  DOCA_LOG_ERR("Consumer failed to recv message with error = %s",
544 
546  (void)doca_buf_dec_refcount(buf, NULL);
549 }
550 
558 {
559  struct doca_comch_consumer_task_post_recv *consumer_task;
560  struct doca_buf *buf;
561  struct doca_task *task_obj;
563 
564  /* Receive msg from server */
566  data_path->consumer_mem.mmap,
567  data_path->consumer_mem.mem,
569  &buf);
570  if (result != DOCA_SUCCESS) {
571  DOCA_LOG_ERR("Failed to get doca buf from consumer mmap with error = %s", doca_error_get_name(result));
572  return result;
573  }
574 
575  result = doca_comch_consumer_task_post_recv_alloc_init(data_path->consumer, buf, &consumer_task);
576  if (result != DOCA_SUCCESS) {
577  DOCA_LOG_ERR("Failed to allocate task for consumer with error = %s", doca_error_get_name(result));
578  return result;
579  }
580 
581  task_obj = doca_comch_consumer_task_post_recv_as_task(consumer_task);
582  result = doca_task_submit(task_obj);
583  if (result != DOCA_SUCCESS) {
584  (void)doca_buf_dec_refcount(buf, NULL);
585  doca_task_free(task_obj);
586  DOCA_LOG_ERR("Failed submitting send task with error = %s", doca_error_get_name(result));
587  return result;
588  }
589 
590  return DOCA_SUCCESS;
591 }
592 
601 static void consumer_state_changed_callback(const union doca_data user_data,
602  struct doca_ctx *ctx,
603  enum doca_ctx_states prev_state,
604  enum doca_ctx_states next_state)
605 {
606  (void)ctx;
607  (void)prev_state;
608 
609  struct comch_data_path_objects *data_path = (struct comch_data_path_objects *)user_data.ptr;
610 
611  switch (next_state) {
612  case DOCA_CTX_STATE_IDLE:
613  DOCA_LOG_INFO("CC consumer context has been stopped");
614 
615  /* A move to stop from non running/stopping state means there's been an error */
616  if ((prev_state != DOCA_CTX_STATE_RUNNING) && (prev_state != DOCA_CTX_STATE_STOPPING))
618 
619  /* We can stop progressing the PE */
620  data_path->consumer_finish = true;
621  break;
627  "CC consumer context entered into starting state. Waiting consumer producer negotiation finish");
628  break;
630  DOCA_LOG_INFO("CC consumer context is running. Receiving message from producer, waiting finish");
631  data_path->consumer_result = consumer_recv_msg(data_path);
632  if (data_path->consumer_result != DOCA_SUCCESS) {
633  DOCA_LOG_ERR("Failed to submit consumer recv task with error = %s",
636  }
637  break;
643  DOCA_LOG_INFO("CC consumer context entered into stopping state");
644  break;
645  default:
646  break;
647  }
648 }
649 
651 {
653  struct local_mem_bufs *pmem = &data_path->producer_mem;
654  struct timespec ts = {
655  .tv_sec = 0,
656  .tv_nsec = SLEEP_IN_NANOS,
657  };
659  .send_task_comp_err_cb =
661  .ctx_user_data = data_path,
662  .ctx_state_changed_cb = producer_state_changed_callback};
663 
664  /* When remote_consumer_id != 1, it means the remote_consumer is ready to use */
665  while (data_path->remote_consumer_id == 0) {
666  if (doca_pe_progress(data_path->pe) == 0)
667  nanosleep(&ts, &ts);
668  }
669 
670  if (data_path->remote_consumer_id == INVALID_CONSUMER_ID)
671  return DOCA_ERROR_UNEXPECTED;
672 
673  /*
674  * Need a cc producer to send message to server
675  * Based on user input, to setup producer's mmap and doca_buf infrastructure
676  */
677  pmem->mem = (void *)data_path->text;
678  pmem->need_alloc_mem = false;
679  result = init_local_mem_bufs(pmem, data_path->hw_dev, strnlen(data_path->text, CC_DATA_PATH_MAX_MSG_SIZE), 1);
680  if (result != DOCA_SUCCESS) {
681  DOCA_LOG_ERR("Failed to producer memory with error = %s", doca_error_get_name(result));
682  return result;
683  }
684 
685  /* Init a cc producer */
687  &producer_cb_cfg,
688  &(data_path->producer),
689  &(data_path->producer_pe));
690  if (result != DOCA_SUCCESS) {
691  DOCA_LOG_ERR("Failed to init a producer with error = %s", doca_error_get_name(result));
692  clean_local_mem_bufs(pmem);
693  return result;
694  }
695 
696  /* Send msg to server */
697  while (data_path->producer_finish == false) {
698  if (doca_pe_progress(data_path->producer_pe) == 0)
699  nanosleep(&ts, &ts);
700  }
701 
702  clean_comch_producer(data_path->producer, data_path->producer_pe);
703  data_path->producer = NULL;
704  data_path->producer_pe = NULL;
705  clean_local_mem_bufs(pmem);
706  return data_path->producer_result;
707 }
708 
710 {
712  struct local_mem_bufs *cmem = &data_path->consumer_mem;
713  struct timespec ts = {
714  .tv_sec = 0,
715  .tv_nsec = SLEEP_IN_NANOS,
716  };
718  .recv_task_comp_err_cb =
720  .ctx_user_data = data_path,
721  .ctx_state_changed_cb = consumer_state_changed_callback};
722  /*
723  * Need a cc consumer to recv message from server
724  * Setup consumer's mmap and doca_buf infrastructure
725  */
726  cmem->need_alloc_mem = true;
728  if (result != DOCA_SUCCESS) {
729  DOCA_LOG_ERR("Failed to consumer memory with error = %s", doca_error_get_name(result));
730  return result;
731  }
732 
733  /* Init a consumer */
735  cmem->mmap,
736  &consumer_cb_cfg,
737  &(data_path->consumer),
738  &(data_path->consumer_pe));
739  if (result != DOCA_SUCCESS) {
740  DOCA_LOG_ERR("Failed to init a consumer with error = %s", doca_error_get_name(result));
741  clean_local_mem_bufs(cmem);
742  return result;
743  }
744 
745  /* Receive msg from server */
746  while (data_path->consumer_finish == false) {
747  if (doca_pe_progress(data_path->pe) == 0)
748  nanosleep(&ts, &ts);
749  if (doca_pe_progress(data_path->consumer_pe) == 0)
750  nanosleep(&ts, &ts);
751  }
752 
753  clean_comch_consumer(data_path->consumer, data_path->consumer_pe);
754  data_path->consumer = NULL;
755  data_path->consumer_pe = NULL;
756  clean_local_mem_bufs(cmem);
757 
758  return data_path->consumer_result;
759 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
doca_error_t init_comch_producer(struct doca_comch_connection *connection, struct comch_producer_cb_config *cfg, struct doca_comch_producer **producer, struct doca_pe **pe)
void clean_comch_producer(struct doca_comch_producer *producer, struct doca_pe *pe)
doca_error_t init_local_mem_bufs(struct local_mem_bufs *local, struct doca_dev *dev, size_t buf_len, size_t max_bufs)
static void producer_state_changed_callback(const union doca_data user_data, struct doca_ctx *ctx, enum doca_ctx_states prev_state, enum doca_ctx_states next_state)
static void producer_send_task_completion_err_callback(struct doca_comch_producer_task_send *task, union doca_data task_user_data, union doca_data ctx_user_data)
static doca_error_t consumer_recv_msg(struct comch_data_path_objects *data_path)
static void producer_send_task_completion_callback(struct doca_comch_producer_task_send *task, union doca_data task_user_data, union doca_data ctx_user_data)
static void consumer_state_changed_callback(const union doca_data user_data, struct doca_ctx *ctx, enum doca_ctx_states prev_state, enum doca_ctx_states next_state)
static doca_error_t producer_send_msg(struct comch_data_path_objects *data_path)
DOCA_LOG_REGISTER(COMCH_DATA_PATH_HIGH_SPEED_COMMON)
static void consumer_recv_task_completion_err_callback(struct doca_comch_consumer_task_post_recv *task, union doca_data task_user_data, union doca_data ctx_user_data)
void clean_comch_consumer(struct doca_comch_consumer *consumer, struct doca_pe *pe)
void clean_local_mem_bufs(struct local_mem_bufs *local)
doca_error_t comch_data_path_send_msg(struct comch_data_path_objects *data_path)
doca_error_t init_comch_consumer(struct doca_comch_connection *connection, struct doca_mmap *user_mmap, struct comch_consumer_cb_config *cfg, struct doca_comch_consumer **consumer, struct doca_pe **pe)
static void consumer_recv_task_completion_callback(struct doca_comch_consumer_task_post_recv *task, union doca_data task_user_data, union doca_data ctx_user_data)
doca_error_t comch_data_path_recv_msg(struct comch_data_path_objects *data_path)
#define CC_DATA_PATH_TASK_NUM
#define CC_DATA_PATH_MAX_MSG_SIZE
#define INVALID_CONSUMER_ID
#define SLEEP_IN_NANOS
Definition: comch_utils.c:40
doca_error_t recv_msg(struct doca_rdma *rdma, struct doca_mmap *mmap, struct doca_buf_inventory *buf_inv, void *msg, uint32_t msg_len, void *user_data)
Definition: rdma_common.c:1297
static struct doca_pe * pe
DOCA_STABLE doca_error_t doca_buf_inventory_destroy(struct doca_buf_inventory *inventory)
Destroy buffer inventory structure.
static doca_error_t doca_buf_inventory_buf_get_by_addr(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *addr, size_t len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by addr & len argume...
static doca_error_t doca_buf_inventory_buf_get_by_data(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *data, size_t data_len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by data & data_len a...
DOCA_STABLE doca_error_t doca_buf_inventory_start(struct doca_buf_inventory *inventory)
Start element retrieval from inventory.
DOCA_STABLE doca_error_t doca_buf_inventory_create(size_t num_elements, struct doca_buf_inventory **inventory)
Allocates buffer inventory with default/unset attributes.
DOCA_STABLE doca_error_t doca_buf_dec_refcount(struct doca_buf *buf, uint16_t *refcount)
Decrease the object reference count by 1, if 0 reached, return the element back to the inventory.
DOCA_STABLE doca_error_t doca_buf_get_data(const struct doca_buf *buf, void **data)
Get the buffer's data.
DOCA_STABLE doca_error_t doca_buf_get_data_len(const struct doca_buf *buf, size_t *data_len)
Get buffer's data length.
DOCA_STABLE struct doca_buf * doca_comch_consumer_task_post_recv_get_buf(const struct doca_comch_consumer_task_post_recv *task)
DOCA_STABLE doca_error_t doca_comch_consumer_create(struct doca_comch_connection *comch_connection, struct doca_mmap *buf_mmap, struct doca_comch_consumer **consumer)
DOCA_STABLE doca_error_t doca_comch_consumer_destroy(struct doca_comch_consumer *consumer)
DOCA_STABLE doca_error_t doca_comch_consumer_task_post_recv_set_conf(struct doca_comch_consumer *consumer, doca_comch_consumer_task_post_recv_completion_cb_t task_completion_cb, doca_comch_consumer_task_post_recv_completion_cb_t task_error_cb, uint32_t num_post_recv_tasks)
DOCA_STABLE doca_error_t doca_comch_consumer_task_post_recv_alloc_init(struct doca_comch_consumer *consumer, struct doca_buf *buf, struct doca_comch_consumer_task_post_recv **task)
Allocate and initialize a doca_consumer post receive task.
DOCA_STABLE struct doca_ctx * doca_comch_consumer_as_ctx(struct doca_comch_consumer *consumer)
DOCA_STABLE struct doca_task * doca_comch_consumer_task_post_recv_as_task(struct doca_comch_consumer_task_post_recv *task)
DOCA_STABLE doca_error_t doca_comch_producer_create(struct doca_comch_connection *comch_connection, struct doca_comch_producer **producer)
DOCA_STABLE const struct doca_buf * doca_comch_producer_task_send_get_buf(const struct doca_comch_producer_task_send *task)
DOCA_STABLE struct doca_task * doca_comch_producer_task_send_as_task(struct doca_comch_producer_task_send *task)
DOCA_STABLE doca_error_t doca_comch_producer_task_send_set_conf(struct doca_comch_producer *producer, doca_comch_producer_task_send_completion_cb_t task_completion_cb, doca_comch_producer_task_send_completion_cb_t task_error_cb, uint32_t num_send_tasks)
DOCA_STABLE doca_error_t doca_comch_producer_destroy(struct doca_comch_producer *producer)
DOCA_STABLE struct doca_ctx * doca_comch_producer_as_ctx(struct doca_comch_producer *producer)
DOCA_STABLE doca_error_t doca_comch_producer_task_send_alloc_init(struct doca_comch_producer *producer, const struct doca_buf *buf, uint8_t *imm_data, uint32_t imm_data_len, uint32_t consumer_id, struct doca_comch_producer_task_send **task)
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_set_state_changed_cb(struct doca_ctx *ctx, doca_ctx_state_changed_callback_t cb)
Set state changed callback.
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_ctx_states
This enum defines the states of a context.
Definition: doca_ctx.h:83
@ DOCA_CTX_STATE_STARTING
Definition: doca_ctx.h:93
@ DOCA_CTX_STATE_STOPPING
Definition: doca_ctx.h:106
@ DOCA_CTX_STATE_IDLE
Definition: doca_ctx.h:88
@ DOCA_CTX_STATE_RUNNING
Definition: doca_ctx.h:98
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_UNEXPECTED
Definition: doca_error.h:60
@ DOCA_ERROR_AGAIN
Definition: doca_error.h:43
@ DOCA_SUCCESS
Definition: doca_error.h:38
@ DOCA_ERROR_NO_MEMORY
Definition: doca_error.h:45
@ 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_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_get_memrange(const struct doca_mmap *mmap, void **addr, size_t *len)
Get the memory range of 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_pe_destroy(struct doca_pe *pe)
Destroy doca progress engine.
DOCA_STABLE doca_error_t doca_task_get_status(const struct doca_task *task)
Get task status.
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_ACCESS_FLAG_PCI_READ_WRITE
Definition: doca_types.h:91
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
doca_comch_consumer_task_post_recv_completion_cb_t recv_task_comp_cb
struct doca_comch_consumer * consumer
struct doca_comch_producer * producer
struct doca_comch_connection * connection
doca_comch_producer_task_send_completion_cb_t send_task_comp_cb
struct doca_buf_inventory * buf_inv
Convenience type for representing opaque data.
Definition: doca_types.h:56
void * ptr
Definition: doca_types.h:57
struct upf_accel_ctx * ctx