NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
tcp_queues.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023-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 <stdlib.h>
27 #include <string.h>
28 #include <rte_ethdev.h>
29 
30 #include "common.h"
33 
34 DOCA_LOG_REGISTER(GPU_PACKET_PROCESSING_TCP);
35 
37  struct doca_flow_port *df_port,
38  struct doca_gpu *gpu_dev,
39  struct doca_dev *ddev,
40  uint32_t queue_num,
41  uint32_t sem_num,
42  bool http_server,
44  struct doca_pe *pe,
45  doca_eth_txq_gpu_event_error_send_packet_cb_t event_error_send_packet_cb)
46 {
48  uint32_t cyclic_buffer_size = 0;
49  union doca_data event_user_data[MAX_QUEUES] = {0};
50 
51  if (tcp_queues == NULL || df_port == NULL || gpu_dev == NULL || ddev == NULL || queue_num == 0 ||
52  sem_num == 0 || (http_server && http_queues == NULL)) {
53  DOCA_LOG_ERR("Can't create TCP queues, invalid input");
55  }
56 
57  tcp_queues->ddev = ddev;
60  tcp_queues->numq = queue_num;
61  tcp_queues->numq_cpu_rss = queue_num;
62  tcp_queues->nums = sem_num;
63 
64  for (uint32_t idx = 0; idx < queue_num; idx++) {
65  DOCA_LOG_INFO("Creating TCP Eth Rxq %d", idx);
66 
70  &(tcp_queues->eth_rxq_cpu[idx]));
71  if (result != DOCA_SUCCESS) {
72  DOCA_LOG_ERR("Failed doca_eth_rxq_create: %s", doca_error_get_descr(result));
73  return DOCA_ERROR_BAD_STATE;
74  }
75 
77  if (result != DOCA_SUCCESS) {
78  DOCA_LOG_ERR("Failed doca_eth_rxq_set_type: %s", doca_error_get_descr(result));
79  return DOCA_ERROR_BAD_STATE;
80  }
81 
83  0,
84  0,
87  0,
88  0,
89  0,
90  &cyclic_buffer_size);
91  if (result != DOCA_SUCCESS) {
92  DOCA_LOG_ERR("Failed to get eth_rxq cyclic buffer size: %s", doca_error_get_descr(result));
94  return DOCA_ERROR_BAD_STATE;
95  }
96 
98  if (result != DOCA_SUCCESS) {
99  DOCA_LOG_ERR("Failed to create mmap: %s", doca_error_get_descr(result));
101  return DOCA_ERROR_BAD_STATE;
102  }
103 
105  if (result != DOCA_SUCCESS) {
106  DOCA_LOG_ERR("Failed to add dev to mmap: %s", doca_error_get_descr(result));
108  return DOCA_ERROR_BAD_STATE;
109  }
110 
111  result = doca_gpu_mem_alloc(tcp_queues->gpu_dev,
112  cyclic_buffer_size,
115  &tcp_queues->gpu_pkt_addr[idx],
116  NULL);
117  if (result != DOCA_SUCCESS || tcp_queues->gpu_pkt_addr[idx] == NULL) {
118  DOCA_LOG_ERR("Failed to allocate gpu memory %s", doca_error_get_descr(result));
120  return DOCA_ERROR_BAD_STATE;
121  }
122 
123  /* Map GPU memory buffer used to receive packets with DMABuf */
124  result = doca_gpu_dmabuf_fd(tcp_queues->gpu_dev,
125  tcp_queues->gpu_pkt_addr[idx],
126  cyclic_buffer_size,
127  &(tcp_queues->dmabuf_fd[idx]));
128  if (result != DOCA_SUCCESS) {
129  DOCA_LOG_INFO("Mapping receive queue buffer (0x%p size %dB) with nvidia-peermem mode",
130  tcp_queues->gpu_pkt_addr[idx],
131  cyclic_buffer_size);
132 
133  /* If failed, use nvidia-peermem method */
135  tcp_queues->gpu_pkt_addr[idx],
136  cyclic_buffer_size);
137  if (result != DOCA_SUCCESS) {
138  DOCA_LOG_ERR("Failed to set memrange for mmap %s", doca_error_get_descr(result));
140  return DOCA_ERROR_BAD_STATE;
141  }
142  } else {
143  DOCA_LOG_INFO("Mapping receive queue buffer (0x%p size %dB dmabuf fd %d) with dmabuf mode",
144  tcp_queues->gpu_pkt_addr[idx],
145  cyclic_buffer_size,
146  tcp_queues->dmabuf_fd[idx]);
147 
149  tcp_queues->dmabuf_fd[idx],
150  tcp_queues->gpu_pkt_addr[idx],
151  0,
152  cyclic_buffer_size);
153  if (result != DOCA_SUCCESS) {
154  DOCA_LOG_ERR("Failed to set dmabuf memrange for mmap %s", doca_error_get_descr(result));
156  return DOCA_ERROR_BAD_STATE;
157  }
158  }
159 
163  if (result != DOCA_SUCCESS) {
164  DOCA_LOG_ERR("Failed to set permissions for mmap %s", doca_error_get_descr(result));
166  return DOCA_ERROR_BAD_STATE;
167  }
168 
170  if (result != DOCA_SUCCESS) {
171  DOCA_LOG_ERR("Failed to start mmap %s", doca_error_get_descr(result));
173  return DOCA_ERROR_BAD_STATE;
174  }
175 
178  0,
179  cyclic_buffer_size);
180  if (result != DOCA_SUCCESS) {
181  DOCA_LOG_ERR("Failed to set cyclic buffer %s", doca_error_get_descr(result));
183  return DOCA_ERROR_BAD_STATE;
184  }
185 
187  if (tcp_queues->eth_rxq_ctx[idx] == NULL) {
188  DOCA_LOG_ERR("Failed doca_eth_rxq_as_doca_ctx: %s", doca_error_get_descr(result));
190  return DOCA_ERROR_BAD_STATE;
191  }
192 
194  if (result != DOCA_SUCCESS) {
195  DOCA_LOG_ERR("Failed doca_ctx_set_datapath_on_gpu: %s", doca_error_get_descr(result));
197  return DOCA_ERROR_BAD_STATE;
198  }
199 
201  if (result != DOCA_SUCCESS) {
202  DOCA_LOG_ERR("Failed doca_ctx_start: %s", doca_error_get_descr(result));
204  return DOCA_ERROR_BAD_STATE;
205  }
206 
208  if (result != DOCA_SUCCESS) {
209  DOCA_LOG_ERR("Failed doca_eth_rxq_get_gpu_handle: %s", doca_error_get_descr(result));
211  return DOCA_ERROR_BAD_STATE;
212  }
213 
214  result = doca_gpu_semaphore_create(tcp_queues->gpu_dev, &(tcp_queues->sem_cpu[idx]));
215  if (result != DOCA_SUCCESS) {
216  DOCA_LOG_ERR("Failed doca_gpu_semaphore_create: %s", doca_error_get_descr(result));
218  return DOCA_ERROR_BAD_STATE;
219  }
220 
221  /*
222  * Semaphore memory reside on CPU visible from GPU.
223  * CPU will poll in busy wait on this semaphore (multiple reads)
224  * while GPU access each item only once to update values.
225  */
226  result = doca_gpu_semaphore_set_memory_type(tcp_queues->sem_cpu[idx], DOCA_GPU_MEM_TYPE_CPU_GPU);
227  if (result != DOCA_SUCCESS) {
228  DOCA_LOG_ERR("Failed doca_gpu_semaphore_set_memory_type: %s", doca_error_get_descr(result));
230  return DOCA_ERROR_BAD_STATE;
231  }
232 
233  result = doca_gpu_semaphore_set_items_num(tcp_queues->sem_cpu[idx], tcp_queues->nums);
234  if (result != DOCA_SUCCESS) {
235  DOCA_LOG_ERR("Failed doca_gpu_semaphore_set_items_num: %s", doca_error_get_descr(result));
237  return DOCA_ERROR_BAD_STATE;
238  }
239 
240  /*
241  * Semaphore memory reside on CPU visible from GPU.
242  * The CPU reads packets info from this structure.
243  * The GPU access each item only once to update values.
244  */
245  result = doca_gpu_semaphore_set_custom_info(tcp_queues->sem_cpu[idx],
246  sizeof(struct stats_tcp),
248  if (result != DOCA_SUCCESS) {
249  DOCA_LOG_ERR("Failed doca_gpu_semaphore_set_custom_info: %s", doca_error_get_descr(result));
251  return DOCA_ERROR_BAD_STATE;
252  }
253 
254  result = doca_gpu_semaphore_start(tcp_queues->sem_cpu[idx]);
255  if (result != DOCA_SUCCESS) {
256  DOCA_LOG_ERR("Failed doca_gpu_semaphore_start: %s", doca_error_get_descr(result));
258  return DOCA_ERROR_BAD_STATE;
259  }
260 
261  result = doca_gpu_semaphore_get_gpu_handle(tcp_queues->sem_cpu[idx], &(tcp_queues->sem_gpu[idx]));
262  if (result != DOCA_SUCCESS) {
263  DOCA_LOG_ERR("Failed doca_gpu_semaphore_get_gpu_handle: %s", doca_error_get_descr(result));
265  return DOCA_ERROR_BAD_STATE;
266  }
267 
268  if (http_server) {
270  http_queues->ddev = ddev;
271 
272  result = doca_gpu_semaphore_create(tcp_queues->gpu_dev, &(tcp_queues->sem_http_cpu[idx]));
273  if (result != DOCA_SUCCESS) {
274  DOCA_LOG_ERR("Failed doca_gpu_semaphore_create: %s", doca_error_get_descr(result));
276  return DOCA_ERROR_BAD_STATE;
277  }
278 
279  /*
280  * Semaphore memory reside on CPU visible from GPU.
281  * CPU will poll in busy wait on this semaphore (multiple reads)
282  * while GPU access each item only once to update values.
283  */
284  result = doca_gpu_semaphore_set_memory_type(tcp_queues->sem_http_cpu[idx],
286  if (result != DOCA_SUCCESS) {
287  DOCA_LOG_ERR("Failed doca_gpu_semaphore_set_memory_type: %s",
290  return DOCA_ERROR_BAD_STATE;
291  }
292 
293  result = doca_gpu_semaphore_set_items_num(tcp_queues->sem_http_cpu[idx], tcp_queues->nums);
294  if (result != DOCA_SUCCESS) {
295  DOCA_LOG_ERR("Failed doca_gpu_semaphore_set_items_num: %s",
298  return DOCA_ERROR_BAD_STATE;
299  }
300 
301  /*
302  * Semaphore memory reside on GPU, not visible from CPU.
303  * This semaphore is needed only across CUDA kernels to exchange HTTP GET info.
304  */
305  result = doca_gpu_semaphore_set_custom_info(tcp_queues->sem_http_cpu[idx],
306  sizeof(struct info_http),
308  if (result != DOCA_SUCCESS) {
309  DOCA_LOG_ERR("Failed doca_gpu_semaphore_set_custom_info: %s",
312  return DOCA_ERROR_BAD_STATE;
313  }
314 
315  result = doca_gpu_semaphore_start(tcp_queues->sem_http_cpu[idx]);
316  if (result != DOCA_SUCCESS) {
317  DOCA_LOG_ERR("Failed doca_gpu_semaphore_start: %s", doca_error_get_descr(result));
319  return DOCA_ERROR_BAD_STATE;
320  }
321 
322  result = doca_gpu_semaphore_get_gpu_handle(tcp_queues->sem_http_cpu[idx],
323  &(tcp_queues->sem_http_gpu[idx]));
324  if (result != DOCA_SUCCESS) {
325  DOCA_LOG_ERR("Failed doca_gpu_semaphore_get_gpu_handle: %s",
328  return DOCA_ERROR_BAD_STATE;
329  }
330 
333  &(http_queues->eth_txq_cpu[idx]));
334  if (result != DOCA_SUCCESS) {
335  DOCA_LOG_ERR("Failed doca_eth_txq_create: %s", doca_error_get_descr(result));
337  return DOCA_ERROR_BAD_STATE;
338  }
339 
341  if (result != DOCA_SUCCESS) {
342  DOCA_LOG_ERR("Failed to set eth_txq l3 offloads: %s", doca_error_get_descr(result));
344  return DOCA_ERROR_BAD_STATE;
345  }
346 
348  if (result != DOCA_SUCCESS) {
349  DOCA_LOG_ERR("Failed to set eth_txq l3 offloads: %s", doca_error_get_descr(result));
351  return DOCA_ERROR_BAD_STATE;
352  }
353 
355  if (http_queues->eth_txq_ctx[idx] == NULL) {
356  DOCA_LOG_ERR("Failed doca_eth_txq_as_doca_ctx: %s", doca_error_get_descr(result));
358  return DOCA_ERROR_BAD_STATE;
359  }
360 
362  if (result != DOCA_SUCCESS) {
363  DOCA_LOG_ERR("Failed doca_ctx_set_datapath_on_gpu: %s", doca_error_get_descr(result));
365  return DOCA_ERROR_BAD_STATE;
366  }
367 
368  if (pe != NULL) {
369  event_user_data[idx].u64 = idx;
370  result =
372  event_error_send_packet_cb,
373  event_user_data[idx]);
374  if (result != DOCA_SUCCESS) {
375  DOCA_LOG_ERR("Unable to set DOCA progress engine callback: %s",
378  return DOCA_ERROR_BAD_STATE;
379  }
380 
382  if (result != DOCA_SUCCESS) {
383  DOCA_LOG_ERR("Unable to set DOCA progress engine to DOCA Eth Txq: %s",
386  return DOCA_ERROR_BAD_STATE;
387  }
388  }
389 
391  if (result != DOCA_SUCCESS) {
392  DOCA_LOG_ERR("Failed doca_ctx_start: %s", doca_error_get_descr(result));
394  return DOCA_ERROR_BAD_STATE;
395  }
396 
398  &(http_queues->eth_txq_gpu[idx]));
399  if (result != DOCA_SUCCESS) {
400  DOCA_LOG_ERR("Failed doca_eth_txq_get_gpu_handle: %s", doca_error_get_descr(result));
402  return DOCA_ERROR_BAD_STATE;
403  }
404  }
405  }
406 
407  if (http_server) {
408  /* Prepare packets for HTTP response to GET INDEX */
411  http_queues->ddev,
412  TX_BUF_NUM,
413  TX_BUF_MAX_SZ);
414  if (result != DOCA_SUCCESS) {
415  DOCA_LOG_ERR("Failed create buf_page_index: %s", doca_error_get_descr(result));
417  return DOCA_ERROR_BAD_STATE;
418  }
419 
421  if (result != DOCA_SUCCESS) {
422  DOCA_LOG_ERR("Failed prepare buf_page_index: %s", doca_error_get_descr(result));
424  return DOCA_ERROR_BAD_STATE;
425  }
426 
427  /* Prepare packets for HTTP response to GET CONTACTS */
430  http_queues->ddev,
431  TX_BUF_NUM,
432  TX_BUF_MAX_SZ);
433  if (result != DOCA_SUCCESS) {
434  DOCA_LOG_ERR("Failed create buf_page_contacts: %s", doca_error_get_descr(result));
436  return DOCA_ERROR_BAD_STATE;
437  }
438 
440  if (result != DOCA_SUCCESS) {
441  DOCA_LOG_ERR("Failed prepare buf_page_contacts: %s", doca_error_get_descr(result));
443  return DOCA_ERROR_BAD_STATE;
444  }
445 
446  /* Prepare packets for HTTP response to any other GET request */
449  http_queues->ddev,
450  TX_BUF_NUM,
451  TX_BUF_MAX_SZ);
452  if (result != DOCA_SUCCESS) {
453  DOCA_LOG_ERR("Failed create buf_page_not_found: %s", doca_error_get_descr(result));
455  return DOCA_ERROR_BAD_STATE;
456  }
457 
459  if (result != DOCA_SUCCESS) {
460  DOCA_LOG_ERR("Failed prepare buf_page_not_found: %s", doca_error_get_descr(result));
462  return DOCA_ERROR_BAD_STATE;
463  }
464 
465  /* Create TCP based flow pipes */
467  if (result != DOCA_SUCCESS) {
468  DOCA_LOG_ERR("Function create_tcp_cpu_pipe returned %s", doca_error_get_descr(result));
470  return DOCA_ERROR_BAD_STATE;
471  }
472  }
473 
474  /* Create UDP based flow pipe */
475  result = create_tcp_gpu_pipe(tcp_queues, df_port, http_server);
476  if (result != DOCA_SUCCESS) {
477  DOCA_LOG_ERR("Function create_tcp_gpu_pipe returned %s", doca_error_get_descr(result));
479  return DOCA_ERROR_BAD_STATE;
480  }
481 
482  return DOCA_SUCCESS;
483 }
484 
486  bool http_server,
488 {
490 
491  if (tcp_queues == NULL || (http_server && http_queues == NULL)) {
492  DOCA_LOG_ERR("Can't destroy TCP queues, invalid input");
494  }
495 
496  for (int idx = 0; idx < tcp_queues->numq; idx++) {
497  DOCA_LOG_INFO("Destroying TCP queue %d", idx);
498 
499  if (tcp_queues->sem_cpu[idx]) {
500  result = doca_gpu_semaphore_stop(tcp_queues->sem_cpu[idx]);
501  if (result != DOCA_SUCCESS) {
502  DOCA_LOG_ERR("Failed doca_gpu_semaphore_start: %s", doca_error_get_descr(result));
503  return DOCA_ERROR_BAD_STATE;
504  }
505 
506  result = doca_gpu_semaphore_destroy(tcp_queues->sem_cpu[idx]);
507  if (result != DOCA_SUCCESS) {
508  DOCA_LOG_ERR("Failed doca_gpu_semaphore_destroy: %s", doca_error_get_descr(result));
509  return DOCA_ERROR_BAD_STATE;
510  }
511  }
512 
513  if (tcp_queues->eth_rxq_ctx[idx]) {
515  if (result != DOCA_SUCCESS) {
516  DOCA_LOG_ERR("Failed doca_ctx_stop: %s", doca_error_get_descr(result));
517  return DOCA_ERROR_BAD_STATE;
518  }
519  }
520 
521  if (tcp_queues->pkt_buff_mmap[idx]) {
523  if (result != DOCA_SUCCESS) {
524  DOCA_LOG_ERR("Failed to start mmap %s", doca_error_get_descr(result));
525  return DOCA_ERROR_BAD_STATE;
526  }
527 
529  if (result != DOCA_SUCCESS) {
530  DOCA_LOG_ERR("Failed to destroy mmap: %s", doca_error_get_descr(result));
531  return DOCA_ERROR_BAD_STATE;
532  }
533  }
534 
535  if (tcp_queues->gpu_pkt_addr[idx]) {
536  result = doca_gpu_mem_free(tcp_queues->gpu_dev, tcp_queues->gpu_pkt_addr[idx]);
537  if (result != DOCA_SUCCESS) {
538  DOCA_LOG_ERR("Failed to free gpu memory: %s", doca_error_get_descr(result));
539  return DOCA_ERROR_BAD_STATE;
540  }
541  }
542 
543  if (tcp_queues->eth_rxq_cpu[idx]) {
545  if (result != DOCA_SUCCESS) {
546  DOCA_LOG_ERR("Failed doca_eth_rxq_destroy: %s", doca_error_get_descr(result));
547  return DOCA_ERROR_BAD_STATE;
548  }
549  }
550 
551  if (http_server) {
552  DOCA_LOG_INFO("Destroying HTTP queue %d", idx);
553 
554  if (tcp_queues->sem_http_cpu[idx]) {
555  result = doca_gpu_semaphore_stop(tcp_queues->sem_http_cpu[idx]);
556  if (result != DOCA_SUCCESS) {
557  DOCA_LOG_ERR("Failed doca_gpu_semaphore_start: %s",
559  return DOCA_ERROR_BAD_STATE;
560  }
561 
562  result = doca_gpu_semaphore_destroy(tcp_queues->sem_http_cpu[idx]);
563  if (result != DOCA_SUCCESS) {
564  DOCA_LOG_ERR("Failed doca_gpu_semaphore_destroy: %s",
566  return DOCA_ERROR_BAD_STATE;
567  }
568  }
569 
570  if (http_queues->eth_txq_ctx[idx]) {
572  if (result != DOCA_SUCCESS) {
573  DOCA_LOG_ERR("Failed doca_ctx_stop: %s", doca_error_get_descr(result));
574  return DOCA_ERROR_BAD_STATE;
575  }
576  }
577 
578  if (http_queues->eth_txq_cpu[idx]) {
580  if (result != DOCA_SUCCESS) {
581  DOCA_LOG_ERR("Failed doca_eth_rxq_destroy: %s", doca_error_get_descr(result));
582  return DOCA_ERROR_BAD_STATE;
583  }
584  }
585  }
586  }
587 
588  if (http_server) {
590  if (result != DOCA_SUCCESS) {
591  DOCA_LOG_ERR("Failed create buf_page_index: %s", doca_error_get_descr(result));
592  return DOCA_ERROR_BAD_STATE;
593  }
594 
596  if (result != DOCA_SUCCESS) {
597  DOCA_LOG_ERR("Failed create buf_page_contacts: %s", doca_error_get_descr(result));
598  return DOCA_ERROR_BAD_STATE;
599  }
600 
602  if (result != DOCA_SUCCESS) {
603  DOCA_LOG_ERR("Failed create buf_page_not_found: %s", doca_error_get_descr(result));
604  return DOCA_ERROR_BAD_STATE;
605  }
606  }
607 
608  return DOCA_SUCCESS;
609 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
doca_error_t create_tx_buf(struct tx_buf *buf, struct doca_gpu *gpu_dev, struct doca_dev *ddev, uint32_t num_packets, uint32_t max_pkt_sz)
Definition: http_txbuf.c:97
doca_error_t create_tcp_gpu_pipe(struct rxq_tcp_queues *tcp_queues, struct doca_flow_port *port, bool connection_based_flows)
Definition: flow.c:395
doca_error_t destroy_tx_buf(struct tx_buf *buf)
Definition: http_txbuf.c:287
doca_error_t create_tcp_cpu_pipe(struct rxq_tcp_queues *tcp_queues, struct doca_flow_port *port)
Definition: flow.c:280
doca_error_t prepare_tx_buf(struct tx_buf *buf, enum http_page_get page_type)
Definition: http_txbuf.c:217
#define MAX_QUEUES
Definition: defines.h:62
#define TX_BUF_NUM
Definition: defines.h:84
#define GPU_PAGE_SIZE
Definition: defines.h:58
#define MAX_PKT_SIZE
Definition: defines.h:65
#define MAX_SQ_DESCR_NUM
Definition: defines.h:74
#define TX_BUF_MAX_SZ
Definition: defines.h:85
#define MAX_PKT_NUM
Definition: defines.h:64
@ HTTP_GET_INDEX
Definition: defines.h:91
@ HTTP_GET_NOT_FOUND
Definition: defines.h:93
@ HTTP_GET_CONTACTS
Definition: defines.h:92
static struct doca_pe * pe
static struct doca_flow_port * df_port
static struct rxq_tcp_queues tcp_queues
static struct doca_gpu * gpu_dev
static struct txq_http_queues http_queues
static struct doca_dev * ddev
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_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
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_INVALID_VALUE
Definition: doca_error.h:44
@ DOCA_ERROR_BAD_STATE
Definition: doca_error.h:56
@ DOCA_SUCCESS
Definition: doca_error.h:38
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_gpu_event_error_send_packet_register(struct doca_eth_txq *eth_txq, doca_eth_txq_gpu_event_error_send_packet_cb_t event_error_send_packet_cb, union doca_data event_user_data)
This method registers a doca_eth_txq_gpu_event_error_send_packet event. can only be called before cal...
void(* doca_eth_txq_gpu_event_error_send_packet_cb_t)(struct doca_eth_txq_gpu_event_error_send_packet *event_error, union doca_data event_user_data)
Function to be executed on send packet error event occurrence.
DOCA_EXPERIMENTAL struct doca_ctx * doca_eth_txq_as_doca_ctx(struct doca_eth_txq *eth_txq)
Convert doca_eth_txq instance into a generalized context for use with doca core objects.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_get_gpu_handle(const struct doca_eth_txq *eth_txq, struct doca_gpu_eth_txq **eth_txq_ext)
Get a gpu handle of a doca_eth_txq.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_create(struct doca_dev *dev, uint32_t max_burst_size, struct doca_eth_txq **eth_txq)
Create a DOCA ETH TXQ instance.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_set_l3_chksum_offload(struct doca_eth_txq *eth_txq, uint8_t enable_l3_chksum)
Set offload for the calculation of IPv4 checksum (L3) on transmitted packets. If the users enables L3...
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_destroy(struct doca_eth_txq *eth_txq)
Destroy a DOCA ETH TXQ instance.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_set_l4_chksum_offload(struct doca_eth_txq *eth_txq, uint8_t enable_l4_chksum)
Set offload for the calculation of TCP/UDP checksum (L4) on transmitted packets. If the users enables...
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_set_type(struct doca_eth_rxq *eth_rxq, enum doca_eth_rxq_type type)
Set RX queue type property for doca_eth_rxq. can only be called before calling doca_ctx_start().
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_destroy(struct doca_eth_rxq *eth_rxq)
Destroy a DOCA ETH RXQ instance.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_get_gpu_handle(const struct doca_eth_rxq *eth_rxq, struct doca_gpu_eth_rxq **eth_rxq_ext)
Get a gpu handle of a doca_eth_rxq.
DOCA_EXPERIMENTAL struct doca_ctx * doca_eth_rxq_as_doca_ctx(struct doca_eth_rxq *eth_rxq)
Convert doca_eth_rxq instance into a generalized context for use with doca core objects.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_create(struct doca_dev *dev, uint32_t max_burst_size, uint32_t max_packet_size, struct doca_eth_rxq **eth_rxq)
Create a DOCA ETH RXQ instance.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_set_pkt_buf(struct doca_eth_rxq *eth_rxq, struct doca_mmap *mmap, uint32_t mmap_offset, uint32_t mmap_len)
Set Eth packet buffer for a doca_eth_rxq. can only be called before calling doca_ctx_start().
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_estimate_packet_buf_size(enum doca_eth_rxq_type type, uint32_t rate, uint16_t pkt_max_time, uint32_t max_packet_size, uint32_t max_burst_size, uint8_t log_max_lro_pkt_sz, uint16_t head_size, uint16_t tail_size, uint32_t *buf_size)
Get the recommended size for the mmap buffer of a doca_eth_rxq.
@ DOCA_ETH_RXQ_TYPE_CYCLIC
Definition: doca_eth_rxq.h:65
#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_stop(struct doca_mmap *mmap)
Stop 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_set_dmabuf_memrange(struct doca_mmap *mmap, int dmabuf_fd, void *addr, size_t dmabuf_offset, size_t len)
Set the memory range of DOCA memory map using dmabuf.
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_GPU_MEM_TYPE_CPU_GPU
Definition: doca_types.h:135
@ DOCA_GPU_MEM_TYPE_GPU
Definition: doca_types.h:131
@ DOCA_ACCESS_FLAG_LOCAL_READ_WRITE
Definition: doca_types.h:83
@ DOCA_ACCESS_FLAG_PCI_RELAXED_ORDERING
Definition: doca_types.h:95
uint16_t numq
Definition: common.h:47
uint16_t numq_cpu_rss
Definition: common.h:48
struct doca_gpu_semaphore * sem_http_cpu[MAX_QUEUES]
Definition: common.h:66
void * gpu_pkt_addr[MAX_QUEUES]
Definition: common.h:55
struct doca_dev * ddev
Definition: common.h:45
struct doca_gpu_eth_rxq * eth_rxq_gpu[MAX_QUEUES]
Definition: common.h:53
struct doca_gpu_semaphore_gpu * sem_gpu[MAX_QUEUES]
Definition: common.h:65
uint16_t nums
Definition: common.h:63
struct doca_flow_port * port
Definition: common.h:58
int dmabuf_fd[MAX_QUEUES]
Definition: common.h:56
struct doca_gpu * gpu_dev
Definition: common.h:44
struct doca_ctx * eth_rxq_ctx[MAX_QUEUES]
Definition: common.h:51
struct doca_mmap * pkt_buff_mmap[MAX_QUEUES]
Definition: common.h:54
struct doca_eth_rxq * eth_rxq_cpu[MAX_QUEUES]
Definition: common.h:52
struct doca_gpu_semaphore * sem_cpu[MAX_QUEUES]
Definition: common.h:64
struct doca_gpu_semaphore_gpu * sem_http_gpu[MAX_QUEUES]
Definition: common.h:68
struct tx_buf buf_page_contacts
Definition: common.h:142
struct doca_gpu * gpu_dev
Definition: common.h:135
struct tx_buf buf_page_not_found
Definition: common.h:143
struct doca_dev * ddev
Definition: common.h:136
struct doca_eth_txq * eth_txq_cpu[MAX_QUEUES]
Definition: common.h:138
struct doca_gpu_eth_txq * eth_txq_gpu[MAX_QUEUES]
Definition: common.h:139
struct tx_buf buf_page_index
Definition: common.h:141
struct doca_ctx * eth_txq_ctx[MAX_QUEUES]
Definition: common.h:137
doca_error_t destroy_tcp_queues(struct rxq_tcp_queues *tcp_queues, bool http_server, struct txq_http_queues *http_queues)
Definition: tcp_queues.c:485
DOCA_LOG_REGISTER(GPU_PACKET_PROCESSING_TCP)
doca_error_t create_tcp_queues(struct rxq_tcp_queues *tcp_queues, struct doca_flow_port *df_port, struct doca_gpu *gpu_dev, struct doca_dev *ddev, uint32_t queue_num, uint32_t sem_num, bool http_server, struct txq_http_queues *http_queues, struct doca_pe *pe, doca_eth_txq_gpu_event_error_send_packet_cb_t event_error_send_packet_cb)
Definition: tcp_queues.c:36
Convenience type for representing opaque data.
Definition: doca_types.h:56
uint64_t u64
Definition: doca_types.h:58