NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
gpu_packet_processing.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 #define SLEEP_IN_NANOS (10 * 1000) /* Sample the PE every 10 microseconds */
35 
36 DOCA_LOG_REGISTER(GPU_PACKET_PROCESSING);
37 
39 static struct doca_gpu *gpu_dev;
40 static struct app_gpu_cfg app_cfg = {0};
41 static struct doca_dev *ddev;
42 static uint16_t dpdk_dev_port_id;
43 static struct rxq_udp_queues udp_queues;
44 static struct rxq_tcp_queues tcp_queues;
45 static struct rxq_icmp_queues icmp_queues;
46 static struct txq_http_queues http_queues;
47 static struct doca_flow_port *df_port;
48 static struct doca_pe *pe;
49 static uint64_t icmp_last_ping;
50 
51 /*
52  * DOCA PE callback to be invoked if any Eth Txq get an error
53  * sending packets.
54  *
55  * @event_error [in]: DOCA PE event error handler
56  * @event_user_data [in]: custom user data set at registration time
57  */
58 void error_send_packet_cb(struct doca_eth_txq_gpu_event_error_send_packet *event_error, union doca_data event_user_data)
59 {
60  uint16_t packet_index;
61 
63  DOCA_LOG_INFO("Error in send queue %ld, packet %d. Gracefully killing the app",
64  event_user_data.u64,
65  packet_index);
66  DOCA_GPUNETIO_VOLATILE(force_quit) = true;
67 }
68 
69 /*
70  * DOCA PE callback to be invoked on ICMP Eth Txq to get the debug info
71  * when sending packets
72  *
73  * @event_notify [in]: DOCA PE event debug handler
74  * @event_user_data [in]: custom user data set at registration time
75  */
76 void debug_send_packet_icmp_cb(struct doca_eth_txq_gpu_event_notify_send_packet *event_notify,
77  union doca_data event_user_data)
78 {
79  uint16_t packet_index;
80  uint64_t packet_timestamp;
81  uint64_t ts_diff = 0;
82 
83  doca_eth_txq_gpu_event_notify_send_packet_get_position(event_notify, &packet_index);
84  doca_eth_txq_gpu_event_notify_send_packet_get_timestamp(event_notify, &packet_timestamp);
85 
86  if (icmp_last_ping != 0)
87  ts_diff = packet_timestamp - icmp_last_ping;
88 
89  DOCA_LOG_INFO("ICMP debug event: Queue %ld packet %d sent at %ld time from last ICMP is %.6f sec",
90  event_user_data.u64,
91  packet_index,
92  packet_timestamp,
93  (double)((ts_diff > 0 ? ((double)ts_diff) / 1000000000.0 : 0)));
94 
95  icmp_last_ping = packet_timestamp;
96 }
97 
98 /*
99  * Get timestamp in nanoseconds
100  *
101  * @sec [out]: seconds
102  * @return: UTC timestamp
103  */
104 static uint64_t get_ns(uint64_t *sec)
105 {
106  struct timespec t;
107  int ret;
108 
109  ret = clock_gettime(CLOCK_REALTIME, &t);
110  if (ret != 0)
111  exit(EXIT_FAILURE);
112 
113  (*sec) = (uint64_t)t.tv_sec;
114 
115  return (uint64_t)t.tv_nsec + (uint64_t)t.tv_sec * 1000 * 1000 * 1000;
116 }
117 
118 /*
119  * CPU thread to print statistics from GPU filtering on the console
120  *
121  * @args [in]: thread input args
122  */
123 static void stats_core(void *args)
124 {
125  (void)args;
126 
128  enum doca_gpu_semaphore_status status;
129  struct stats_udp udp_st[MAX_QUEUES] = {0};
130  struct stats_tcp tcp_st[MAX_QUEUES] = {0};
131  uint32_t sem_idx_udp[MAX_QUEUES] = {0};
132  uint32_t sem_idx_tcp[MAX_QUEUES] = {0};
133  uint64_t start_time_sec = 0;
134  uint64_t interval_print = 0;
135  uint64_t interval_sec = 0;
136  struct stats_udp *custom_udp_st;
137  struct stats_tcp *custom_tcp_st;
138 
139  DOCA_LOG_INFO("Core %u is reporting filter stats", rte_lcore_id());
140  get_ns(&start_time_sec);
141  interval_print = get_ns(&interval_sec);
142  while (DOCA_GPUNETIO_VOLATILE(force_quit) == false) {
143  /* Check UDP packets */
144  for (int idxq = 0; idxq < udp_queues.numq; idxq++) {
145  result = doca_gpu_semaphore_get_status(udp_queues.sem_cpu[idxq], sem_idx_udp[idxq], &status);
146  if (result != DOCA_SUCCESS) {
147  DOCA_LOG_ERR("UDP semaphore error");
148  DOCA_GPUNETIO_VOLATILE(force_quit) = true;
149  return;
150  }
151 
152  if (status == DOCA_GPU_SEMAPHORE_STATUS_READY) {
153  result = doca_gpu_semaphore_get_custom_info_addr(udp_queues.sem_cpu[idxq],
154  sem_idx_udp[idxq],
155  (void **)&(custom_udp_st));
156  if (result != DOCA_SUCCESS) {
157  DOCA_LOG_ERR("UDP semaphore get address error");
158  DOCA_GPUNETIO_VOLATILE(force_quit) = true;
159  return;
160  }
161 
162  udp_st[idxq].dns += custom_udp_st->dns;
163  udp_st[idxq].others += custom_udp_st->others;
164  udp_st[idxq].total += custom_udp_st->total;
165 
166  result = doca_gpu_semaphore_set_status(udp_queues.sem_cpu[idxq],
167  sem_idx_udp[idxq],
168  DOCA_GPU_SEMAPHORE_STATUS_FREE);
169  if (result != DOCA_SUCCESS) {
170  DOCA_LOG_ERR("UDP semaphore %d error", sem_idx_udp[idxq]);
171  DOCA_GPUNETIO_VOLATILE(force_quit) = true;
172  return;
173  }
174 
175  sem_idx_udp[idxq] = (sem_idx_udp[idxq] + 1) % udp_queues.nums;
176  }
177  }
178 
179  /* Check TCP packets */
180  for (int idxq = 0; idxq < tcp_queues.numq; idxq++) {
181  result = doca_gpu_semaphore_get_status(tcp_queues.sem_cpu[idxq], sem_idx_tcp[idxq], &status);
182  if (result != DOCA_SUCCESS) {
183  DOCA_LOG_ERR("TCP semaphore error");
184  DOCA_GPUNETIO_VOLATILE(force_quit) = true;
185  return;
186  }
187 
188  if (status == DOCA_GPU_SEMAPHORE_STATUS_READY) {
189  result = doca_gpu_semaphore_get_custom_info_addr(tcp_queues.sem_cpu[idxq],
190  sem_idx_tcp[idxq],
191  (void **)&(custom_tcp_st));
192  if (result != DOCA_SUCCESS) {
193  DOCA_LOG_ERR("TCP semaphore get address error");
194  DOCA_GPUNETIO_VOLATILE(force_quit) = true;
195  return;
196  }
197 
198  tcp_st[idxq].http += custom_tcp_st->http;
199  tcp_st[idxq].http_head += custom_tcp_st->http_head;
200  tcp_st[idxq].http_get += custom_tcp_st->http_get;
201  tcp_st[idxq].http_post += custom_tcp_st->http_post;
202  tcp_st[idxq].tcp_syn += custom_tcp_st->tcp_syn;
203  tcp_st[idxq].tcp_fin += custom_tcp_st->tcp_fin;
204  tcp_st[idxq].tcp_ack += custom_tcp_st->tcp_ack;
205  tcp_st[idxq].others += custom_tcp_st->others;
206  tcp_st[idxq].total += custom_tcp_st->total;
207 
208  result = doca_gpu_semaphore_set_status(tcp_queues.sem_cpu[idxq],
209  sem_idx_tcp[idxq],
210  DOCA_GPU_SEMAPHORE_STATUS_FREE);
211  if (result != DOCA_SUCCESS) {
212  DOCA_LOG_ERR("TCP semaphore %d error", sem_idx_tcp[idxq]);
213  DOCA_GPUNETIO_VOLATILE(force_quit) = true;
214  return;
215  }
216 
217  sem_idx_tcp[idxq] = (sem_idx_tcp[idxq] + 1) % tcp_queues.nums;
218  }
219  }
220 
221  if ((get_ns(&interval_sec) - interval_print) > 5000000000) {
222  printf("\nSeconds %ld\n", interval_sec - start_time_sec);
223 
224  for (int idxq = 0; idxq < udp_queues.numq; idxq++) {
225  printf("[UDP] QUEUE: %d DNS: %ld OTHER: %ld TOTAL: %ld\n",
226  idxq,
227  udp_st[idxq].dns,
228  udp_st[idxq].others,
229  udp_st[idxq].total);
230  }
231 
232  for (int idxq = 0; idxq < tcp_queues.numq; idxq++) {
233  printf("[TCP] QUEUE: %d HTTP: %d HTTP HEAD: %d HTTP GET: %d HTTP POST: %d TCP [SYN: %d FIN: %d ACK: %d] OTHER: %d TOTAL: %d\n",
234  idxq,
235  tcp_st[idxq].http,
236  tcp_st[idxq].http_head,
237  tcp_st[idxq].http_get,
238  tcp_st[idxq].http_post,
239  tcp_st[idxq].tcp_syn,
240  tcp_st[idxq].tcp_fin,
241  tcp_st[idxq].tcp_ack,
242  tcp_st[idxq].others,
243  tcp_st[idxq].total);
244  }
245 
246  interval_print = get_ns(&interval_sec);
247  }
248  }
249 }
250 
251 /*
252  * Signal handler to quit application gracefully
253  *
254  * @signum [in]: signal received
255  */
256 static void signal_handler(int signum)
257 {
258  if (signum == SIGINT || signum == SIGTERM) {
259  DOCA_LOG_INFO("Signal %d received, preparing to exit!", signum);
260  DOCA_GPUNETIO_VOLATILE(force_quit) = true;
261  }
262 }
263 
264 /*
265  * GPU packet processing application main function
266  *
267  * @argc [in]: command line arguments size
268  * @argv [in]: array of command line arguments
269  * @return: EXIT_SUCCESS on success and EXIT_FAILURE otherwise
270  */
271 int main(int argc, char **argv)
272 {
274  int current_lcore = 0;
275  int cuda_id;
276  cudaError_t cuda_ret;
277  struct doca_log_backend *sdk_log;
278  struct timespec ts = {
279  .tv_sec = 0,
280  .tv_nsec = SLEEP_IN_NANOS,
281  };
282 
283  /* Register a logger backend */
285  if (result != DOCA_SUCCESS)
286  return EXIT_FAILURE;
287 
288  /* Register a logger backend for internal SDK errors and warnings */
289  result = doca_log_backend_create_with_file_sdk(stderr, &sdk_log);
290  if (result != DOCA_SUCCESS)
291  return EXIT_FAILURE;
293  if (result != DOCA_SUCCESS)
294  return EXIT_FAILURE;
295 
296  DOCA_LOG_INFO("===========================================================");
297  DOCA_LOG_INFO("DOCA version: %s", doca_version());
298  DOCA_LOG_INFO("===========================================================");
299 
300  /* Basic DPDK initialization */
302  if (result != DOCA_SUCCESS) {
303  DOCA_LOG_ERR("Failed to init ARGP resources: %s", doca_error_get_descr(result));
304  return EXIT_FAILURE;
305  }
306 
308  if (result != DOCA_SUCCESS) {
309  DOCA_LOG_ERR("Failed to parse application input: %s", doca_error_get_descr(result));
310  return EXIT_FAILURE;
311  }
312 
313  result = doca_argp_start(argc, argv);
314  if (result != DOCA_SUCCESS) {
315  DOCA_LOG_ERR("Failed to parse application input: %s", doca_error_get_descr(result));
316  return EXIT_FAILURE;
317  }
318 
319  DOCA_LOG_INFO("Options enabled:\n\tGPU %s\n\tNIC %s\n\tGPU Rx queues %d\n\tGPU HTTP server enabled %s",
323  (app_cfg.http_server == true ? "Yes" : "No"));
324 
325  /* In a multi-GPU system, ensure CUDA refers to the right GPU device */
326  cuda_ret = cudaDeviceGetByPCIBusId(&cuda_id, app_cfg.gpu_pcie_addr);
327  if (cuda_ret != cudaSuccess) {
328  DOCA_LOG_ERR("Invalid GPU bus id provided %s", app_cfg.gpu_pcie_addr);
330  }
331 
332  cudaFree(0);
333  cudaSetDevice(cuda_id);
334 
336  if (result != DOCA_SUCCESS) {
337  DOCA_LOG_ERR("Function init_doca_device returned %s", doca_error_get_descr(result));
338  return EXIT_FAILURE;
339  }
340 
341  /* Initialize DOCA GPU instance */
342  result = doca_gpu_create(app_cfg.gpu_pcie_addr, &gpu_dev);
343  if (result != DOCA_SUCCESS) {
344  DOCA_LOG_ERR("Function doca_gpu_create returned %s", doca_error_get_descr(result));
345  return EXIT_FAILURE;
346  }
347 
349  if (df_port == NULL) {
350  DOCA_LOG_ERR("FAILED: init_doca_flow");
351  return EXIT_FAILURE;
352  }
353 
355  if (result != DOCA_SUCCESS) {
356  DOCA_LOG_ERR("Unable to create pe queue: %s", doca_error_get_descr(result));
357  return EXIT_FAILURE;
358  }
359 
361  if (result != DOCA_SUCCESS) {
362  DOCA_LOG_ERR("Function create_udp_queues returned %s", doca_error_get_descr(result));
363  return EXIT_FAILURE;
364  }
365 
367  df_port,
368  gpu_dev,
369  ddev,
373  &http_queues,
374  pe,
376  if (result != DOCA_SUCCESS) {
377  DOCA_LOG_ERR("Function create_tcp_queues returned %s", doca_error_get_descr(result));
378  return EXIT_FAILURE;
379  }
380 
382  df_port,
383  gpu_dev,
384  ddev,
386  pe,
389  if (result != DOCA_SUCCESS) {
390  DOCA_LOG_ERR("Function create_icmp_queues returned %s", doca_error_get_descr(result));
391  return EXIT_FAILURE;
392  }
393 
394  /* Create root control pipe to route tcp/udp/OS packets */
396  if (result != DOCA_SUCCESS) {
397  DOCA_LOG_ERR("Function create_root_pipe returned %s", doca_error_get_descr(result));
398  return EXIT_FAILURE;
399  }
400 
401  /* Gracefully terminate app if ctrlc */
402  DOCA_GPUNETIO_VOLATILE(force_quit) = false;
403  signal(SIGINT, signal_handler);
404  signal(SIGTERM, signal_handler);
405 
406  cudaStream_t rx_tcp_stream, rx_udp_stream, rx_icmp_stream, tx_http_server;
407  cudaError_t res_rt = cudaSuccess;
408  uint32_t *cpu_exit_condition;
409  uint32_t *gpu_exit_condition;
410 
411  res_rt = cudaStreamCreateWithFlags(&rx_udp_stream, cudaStreamNonBlocking);
412  if (res_rt != cudaSuccess) {
413  DOCA_LOG_ERR("Function cudaStreamCreateWithFlags error %d", res_rt);
414  return EXIT_FAILURE;
415  }
416 
417  res_rt = cudaStreamCreateWithFlags(&rx_tcp_stream, cudaStreamNonBlocking);
418  if (res_rt != cudaSuccess) {
419  DOCA_LOG_ERR("Function cudaStreamCreateWithFlags error %d", res_rt);
420  return EXIT_FAILURE;
421  }
422 
423  res_rt = cudaStreamCreateWithFlags(&rx_icmp_stream, cudaStreamNonBlocking);
424  if (res_rt != cudaSuccess) {
425  DOCA_LOG_ERR("Function cudaStreamCreateWithFlags error %d", res_rt);
426  return EXIT_FAILURE;
427  }
428 
429  if (app_cfg.http_server) {
430  res_rt = cudaStreamCreateWithFlags(&tx_http_server, cudaStreamNonBlocking);
431  if (res_rt != cudaSuccess) {
432  DOCA_LOG_ERR("Function cudaStreamCreateWithFlags error %d", res_rt);
433  return EXIT_FAILURE;
434  }
435  }
436 
437  result = doca_gpu_mem_alloc(gpu_dev,
438  sizeof(uint32_t),
439  4096,
441  (void **)&gpu_exit_condition,
442  (void **)&cpu_exit_condition);
443  if (result != DOCA_SUCCESS || gpu_exit_condition == NULL || cpu_exit_condition == NULL) {
444  DOCA_LOG_ERR("Function doca_gpu_mem_alloc returned %s", doca_error_get_descr(result));
445  return EXIT_FAILURE;
446  }
447  cpu_exit_condition[0] = 0;
448 
449  /*
450  * Some GPUs may require an initial warmup without doing any real operation.
451  */
452  DOCA_LOG_INFO("Warm up CUDA kernels");
453  DOCA_GPUNETIO_VOLATILE(*cpu_exit_condition) = 1;
454  kernel_receive_udp(rx_udp_stream, gpu_exit_condition, &udp_queues);
455  kernel_receive_tcp(rx_tcp_stream, gpu_exit_condition, &tcp_queues, app_cfg.http_server);
456  kernel_receive_icmp(rx_icmp_stream, gpu_exit_condition, &icmp_queues);
457  if (app_cfg.http_server)
458  kernel_http_server(tx_http_server, gpu_exit_condition, &tcp_queues, &http_queues);
459 
460  cudaStreamSynchronize(rx_udp_stream);
461  cudaStreamSynchronize(rx_tcp_stream);
462  cudaStreamSynchronize(rx_icmp_stream);
463  if (app_cfg.http_server)
464  cudaStreamSynchronize(tx_http_server);
465  DOCA_GPUNETIO_VOLATILE(*cpu_exit_condition) = 0;
466 
467  DOCA_LOG_INFO("Launching CUDA kernels");
468 
469  kernel_receive_udp(rx_udp_stream, gpu_exit_condition, &udp_queues);
470  kernel_receive_tcp(rx_tcp_stream, gpu_exit_condition, &tcp_queues, app_cfg.http_server);
471  kernel_receive_icmp(rx_icmp_stream, gpu_exit_condition, &icmp_queues);
472  if (app_cfg.http_server)
473  kernel_http_server(tx_http_server, gpu_exit_condition, &tcp_queues, &http_queues);
474 
475  /* Launch stats proxy thread to report pipeline status */
476  current_lcore = rte_get_next_lcore(current_lcore, true, false);
477  if (rte_eal_remote_launch((void *)stats_core, NULL, current_lcore) != 0) {
478  DOCA_LOG_ERR("Remote launch failed");
479  goto exit;
480  }
481 
482  if (app_cfg.http_server) {
483  tcp_queues.tcp_ack_pkt_pool = rte_pktmbuf_pool_create("tcp_ack_pkt_pool",
484  1023,
485  0,
486  0,
487  RTE_MBUF_DEFAULT_BUF_SIZE,
488  rte_socket_id());
490  DOCA_LOG_ERR("%s: failed to allocate tcp-ack packet pool", __func__);
491  goto exit;
492  }
493 
494  /* Start the CPU RSS threads to address new TCP connections */
495  tcp_queues.lcore_idx_start = rte_get_next_lcore(current_lcore, true, false);
496  for (int i = 0; i < tcp_queues.numq_cpu_rss; i++) {
497  current_lcore = rte_get_next_lcore(current_lcore, true, false);
498  if (rte_eal_remote_launch(tcp_cpu_rss_func, &tcp_queues, current_lcore) != 0) {
499  DOCA_LOG_ERR("Remote launch failed");
500  goto exit;
501  }
502  }
503  }
504 
505  DOCA_LOG_INFO("Waiting for termination");
506  /* This loop keeps busy main thread until force_quit is set to 1 (e.g. typing ctrl+c) */
507  while (DOCA_GPUNETIO_VOLATILE(force_quit) == false) {
509  nanosleep(&ts, &ts);
510  }
511 
512  DOCA_GPUNETIO_VOLATILE(*cpu_exit_condition) = 1;
513  cudaStreamSynchronize(rx_udp_stream);
514  cudaStreamDestroy(rx_udp_stream);
515  cudaStreamSynchronize(rx_tcp_stream);
516  cudaStreamDestroy(rx_tcp_stream);
517  cudaStreamSynchronize(rx_icmp_stream);
518  cudaStreamDestroy(rx_icmp_stream);
519  if (app_cfg.http_server) {
520  cudaStreamSynchronize(tx_http_server);
521  cudaStreamDestroy(tx_http_server);
522  }
523 
524  doca_gpu_mem_free(gpu_dev, gpu_exit_condition);
525 
526  DOCA_LOG_INFO("GPU work ended");
527 
528  current_lcore = 0;
529  RTE_LCORE_FOREACH_WORKER(current_lcore)
530  {
531  if (rte_eal_wait_lcore(current_lcore) < 0) {
532  DOCA_LOG_ERR("Bad exit for coreid: %d", current_lcore);
533  break;
534  }
535  }
536 
537 exit:
538 
540  if (result != DOCA_SUCCESS) {
541  DOCA_LOG_ERR("Function finalize_doca_flow returned %s", doca_error_get_descr(result));
542  return EXIT_FAILURE;
543  }
544 
545  result = doca_gpu_destroy(gpu_dev);
546  if (result != DOCA_SUCCESS) {
547  DOCA_LOG_ERR("Failed to destroy GPU: %s", doca_error_get_descr(result));
548  return EXIT_FAILURE;
549  }
550 
552  if (result != DOCA_SUCCESS) {
553  DOCA_LOG_ERR("Function doca_pe_destroy returned %s", doca_error_get_descr(result));
554  return EXIT_FAILURE;
555  }
556 
558 
559  DOCA_LOG_INFO("Application finished successfully");
560 
561  return EXIT_SUCCESS;
562 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
doca_error_t kernel_receive_icmp(cudaStream_t stream, uint32_t *exit_cond, struct rxq_icmp_queues *icmp_queues)
struct doca_flow_port * init_doca_flow(uint16_t port_id, uint8_t rxq_num)
Definition: flow.c:37
doca_error_t destroy_flow_queue(struct doca_flow_port *port_df, struct rxq_icmp_queues *icmp_queues, struct rxq_udp_queues *udp_queues, struct rxq_tcp_queues *tcp_queues, bool http_server, struct txq_http_queues *http_queues)
Definition: flow.c:944
doca_error_t kernel_receive_udp(cudaStream_t stream, uint32_t *exit_cond, struct rxq_udp_queues *udp_queues)
doca_error_t create_root_pipe(struct rxq_udp_queues *udp_queues, struct rxq_tcp_queues *tcp_queues, struct rxq_icmp_queues *icmp_queues, struct doca_flow_port *port)
Definition: flow.c:632
doca_error_t init_doca_device(char *nic_pcie_addr, struct doca_dev **ddev, uint16_t *dpdk_port_id)
Definition: device.c:80
doca_error_t create_icmp_queues(struct rxq_icmp_queues *icmp_queues, struct doca_flow_port *df_port, struct doca_gpu *gpu_dev, struct doca_dev *ddev, uint32_t queue_num, struct doca_pe *pe, doca_eth_txq_gpu_event_error_send_packet_cb_t event_error_send_packet_cb, doca_eth_txq_gpu_event_notify_send_packet_cb_t event_notify_send_packet_cb)
Definition: icmp_queues.c:34
doca_error_t kernel_http_server(cudaStream_t stream, uint32_t *exit_cond, struct rxq_tcp_queues *tcp_queues, struct txq_http_queues *http_queues)
doca_error_t kernel_receive_tcp(cudaStream_t stream, uint32_t *exit_cond, struct rxq_tcp_queues *tcp_queues, bool http_server)
doca_error_t create_udp_queues(struct rxq_udp_queues *udp_queues, struct doca_flow_port *df_port, struct doca_gpu *gpu_dev, struct doca_dev *ddev, uint32_t queue_num, uint32_t sem_num)
Definition: udp_queues.c:34
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
doca_error_t register_application_params(void)
Definition: args.c:120
#define SEMAPHORES_PER_QUEUE
Definition: defines.h:75
#define MAX_QUEUES
Definition: defines.h:62
#define MAX_QUEUES_ICMP
Definition: defines.h:63
static struct doca_pe * pe
static struct rxq_icmp_queues icmp_queues
int main(int argc, char **argv)
static struct doca_flow_port * df_port
static uint64_t get_ns(uint64_t *sec)
static struct rxq_tcp_queues tcp_queues
void debug_send_packet_icmp_cb(struct doca_eth_txq_gpu_event_notify_send_packet *event_notify, union doca_data event_user_data)
static uint16_t dpdk_dev_port_id
static struct app_gpu_cfg app_cfg
bool force_quit
static struct rxq_udp_queues udp_queues
static struct doca_gpu * gpu_dev
static struct txq_http_queues http_queues
DOCA_LOG_REGISTER(GPU_PACKET_PROCESSING)
static struct doca_dev * ddev
void error_send_packet_cb(struct doca_eth_txq_gpu_event_error_send_packet *event_error, union doca_data event_user_data)
static void stats_core(void *args)
#define SLEEP_IN_NANOS
static void signal_handler(int signum)
static uint64_t icmp_last_ping
DOCA_EXPERIMENTAL doca_error_t doca_argp_start(int argc, char **argv)
Parse incoming arguments (cmd line/json).
DOCA_EXPERIMENTAL doca_error_t doca_argp_init(const char *program_name, void *program_config)
Initialize the parser interface.
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_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_INVALID_VALUE
Definition: doca_error.h:44
@ DOCA_SUCCESS
Definition: doca_error.h:38
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_gpu_event_notify_send_packet_get_position(const struct doca_eth_txq_gpu_event_notify_send_packet *event_notify, uint16_t *packet_index)
This method returns the index in the send queue of the packet which reported the notify info.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_gpu_event_notify_send_packet_get_timestamp(const struct doca_eth_txq_gpu_event_notify_send_packet *event_notify, uint64_t *packet_timestamp)
This method returns the timestamp at which the packet in the send queue was actually sent (fired over...
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_gpu_event_error_send_packet_get_position(const struct doca_eth_txq_gpu_event_error_send_packet *event_error, uint16_t *packet_index)
This method returns the index in the send queue of the packet which caused the error.
DOCA_EXPERIMENTAL doca_error_t doca_log_backend_create_standard(void)
Create default, non configurable backend for application messages.
#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_EXPERIMENTAL doca_error_t doca_log_backend_create_with_file_sdk(FILE *fptr, struct doca_log_backend **backend)
Create a logging backend with a FILE* stream for SDK messages.
DOCA_EXPERIMENTAL doca_error_t doca_log_backend_set_sdk_level(struct doca_log_backend *backend, uint32_t level)
Set the log level limit for SDK logging backends.
@ DOCA_LOG_LEVEL_WARNING
Definition: doca_log.h:47
DOCA_STABLE doca_error_t doca_pe_destroy(struct doca_pe *pe)
Destroy doca 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_GPU_MEM_TYPE_GPU_CPU
Definition: doca_types.h:133
static const char * doca_version(void)
Function returning DOCA's (SDK) exact version string.
Definition: doca_version.h:90
uint8_t queue_num
Definition: common.h:38
bool http_server
Definition: common.h:39
char nic_pcie_addr[DOCA_DEVINFO_PCI_ADDR_SIZE]
Definition: common.h:37
char gpu_pcie_addr[DOCA_DEVINFO_PCI_ADDR_SIZE]
Definition: common.h:36
uint16_t numq
Definition: common.h:47
uint16_t numq_cpu_rss
Definition: common.h:48
struct rte_mempool * tcp_ack_pkt_pool
Definition: common.h:50
uint16_t nums
Definition: common.h:63
struct doca_gpu_semaphore * sem_cpu[MAX_QUEUES]
Definition: common.h:64
uint16_t lcore_idx_start
Definition: common.h:49
uint16_t numq
Definition: common.h:77
uint16_t nums
Definition: common.h:93
struct doca_gpu_semaphore * sem_cpu[MAX_QUEUES]
Definition: common.h:94
uint32_t others
Definition: common.h:155
uint32_t http_post
Definition: common.h:151
uint32_t tcp_ack
Definition: common.h:154
uint32_t total
Definition: common.h:156
uint32_t http_head
Definition: common.h:149
uint32_t http_get
Definition: common.h:150
uint32_t tcp_fin
Definition: common.h:153
uint32_t tcp_syn
Definition: common.h:152
uint32_t http
Definition: common.h:148
uint64_t others
Definition: common.h:162
uint64_t dns
Definition: common.h:161
uint64_t total
Definition: common.h:163
int tcp_cpu_rss_func(void *lcore_args)
Convenience type for representing opaque data.
Definition: doca_types.h:56
uint64_t u64
Definition: doca_types.h:58