NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
eth_rxq_regular_receive_sample.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 #include <unistd.h>
28 
29 #include <doca_flow.h>
30 #include <doca_buf.h>
31 #include <doca_buf_inventory.h>
32 #include <doca_ctx.h>
33 #include <doca_eth_rxq.h>
35 #include <doca_error.h>
36 #include <doca_log.h>
37 
38 #include "common.h"
39 #include "eth_common.h"
40 #include "eth_rxq_common.h"
41 
42 DOCA_LOG_REGISTER(ETH_RXQ_REGULAR_RECEIVE);
43 
44 #define SLEEP_IN_NANOS (10 * 1000) /* sample the task every 10 microseconds */
45 #define MAX_BURST_SIZE 256 /* Max burst size to set for eth_rxq */
46 #define MAX_PKT_SIZE 1600 /* Max packet size to set for eth_rxq */
47 #define BUFS_NUM 1 /* Number of DOCA buffers */
48 #define TASKS_NUM 1 /* Tasks number */
49 #define RECV_TASK_USER_DATA 0x43210 /* User data for receive task */
50 
52  struct eth_core_resources core_resources; /* A struct to hold ETH core resources */
53  struct eth_rxq_flow_resources flow_resources; /* A struct to hold DOCA flow resources */
54  struct doca_eth_rxq *eth_rxq; /* DOCA ETH RXQ context */
55  struct doca_buf *packet_buf; /* DOCA buffer to contain received packet */
56  struct doca_eth_rxq_task_recv *recv_task; /* Receive task */
57  uint32_t inflight_tasks; /* Inflight tasks count */
58  uint16_t rxq_flow_queue_id; /* DOCA ETH RXQ's flow queue ID */
59  bool timestamp_enable; /* timestamp enable */
60 };
61 
62 /*
63  * ETH RXQ receive task common callback
64  *
65  * @task_recv [in]: Completed task
66  * @task_user_data [in]: User provided data, used for identifying the task
67  * @ctx_user_data [in]: User provided data, used to store sample state
68  */
69 static void task_recv_common_cb(struct doca_eth_rxq_task_recv *task_recv,
70  union doca_data task_user_data,
71  union doca_data ctx_user_data)
72 {
73  doca_error_t status, task_status;
74  struct eth_rxq_sample_objects *state;
75  struct doca_buf *pkt;
76  size_t packet_size;
77  uint32_t flow_tag, rx_hash;
78  const uint32_t *metadata_array;
79  uint64_t timestamp;
80 
81  state = ctx_user_data.ptr;
82  state->inflight_tasks--;
83  DOCA_LOG_INFO("Receive task user data is 0x%lx", task_user_data.u64);
84 
85  status = doca_eth_rxq_task_recv_get_pkt(task_recv, &pkt);
86  if (status != DOCA_SUCCESS) {
87  DOCA_LOG_ERR("Failed to get packet of a receive task, err: %s", doca_error_get_name(status));
89  return;
90  }
91 
93 
94  if (task_status != DOCA_SUCCESS) {
95  DOCA_LOG_ERR("Failed to receive a packet, err: %s", doca_error_get_name(task_status));
96  } else {
97  status = doca_eth_rxq_task_recv_get_metadata_array(task_recv, &metadata_array);
98  if (status != DOCA_SUCCESS)
99  DOCA_LOG_ERR("Failed to get metadata_array, err: %s", doca_error_get_name(status));
100  else
101  DOCA_LOG_INFO("Received a packet with metadata %u", metadata_array[0]);
102 
103  status = doca_eth_rxq_task_recv_get_flow_tag(task_recv, &flow_tag);
104  if (status != DOCA_SUCCESS)
105  DOCA_LOG_ERR("Failed to get flow_tag, err: %s", doca_error_get_name(status));
106  else
107  DOCA_LOG_INFO("Received a packet with flow_tag %u", flow_tag);
108 
109  status = doca_eth_rxq_task_recv_get_rx_hash(task_recv, &rx_hash);
110  if (status != DOCA_SUCCESS)
111  DOCA_LOG_ERR("Failed to get rx_hash, err: %s", doca_error_get_name(status));
112  else
113  DOCA_LOG_INFO("Received a packet with rx_hash %u", rx_hash);
114 
115  if (state->timestamp_enable) {
116  status = doca_eth_rxq_task_recv_get_timestamp(task_recv, &timestamp);
117  if (status != DOCA_SUCCESS)
118  DOCA_LOG_ERR("Failed to get timestamp, err: %s", doca_error_get_name(status));
119  else
120  DOCA_LOG_INFO("Received a packet with timestamp %lu", timestamp);
121  }
122 
123  status = doca_buf_get_data_len(pkt, &packet_size);
124  if (status != DOCA_SUCCESS)
125  DOCA_LOG_ERR("Failed to get receive packet size, err: %s", doca_error_get_name(status));
126  else
127  DOCA_LOG_INFO("Received a packet of size %lu successfully", packet_size);
128  }
129 
130  status = doca_buf_dec_refcount(pkt, NULL);
131  if (status != DOCA_SUCCESS)
132  DOCA_LOG_ERR("Failed to free packet buf, err: %s", doca_error_get_name(status));
133 
135 }
136 
137 /*
138  * Destroy ETH RXQ context related resources
139  *
140  * @state [in]: eth_rxq_sample_objects struct to destroy its ETH RXQ context
141  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
142  */
144 {
145  doca_error_t status;
146  enum doca_ctx_states ctx_state;
147  struct timespec ts = {
148  .tv_sec = 0,
149  .tv_nsec = SLEEP_IN_NANOS,
150  };
151 
152  status = doca_ctx_stop(state->core_resources.core_objs.ctx);
153  if (status == DOCA_ERROR_IN_PROGRESS) {
154  while (state->inflight_tasks != 0) {
156  nanosleep(&ts, &ts);
157  }
158 
159  status = doca_ctx_get_state(state->core_resources.core_objs.ctx, &ctx_state);
160  if (status != DOCA_SUCCESS) {
161  DOCA_LOG_ERR("Failed get status of context, err: %s", doca_error_get_name(status));
162  return status;
163  }
164 
165  status = ctx_state == DOCA_CTX_STATE_IDLE ? DOCA_SUCCESS : DOCA_ERROR_BAD_STATE;
166  }
167 
168  if (status != DOCA_SUCCESS) {
169  DOCA_LOG_ERR("Failed to stop DOCA context, err: %s", doca_error_get_name(status));
170  return status;
171  }
172 
173  status = doca_eth_rxq_destroy(state->eth_rxq);
174  if (status != DOCA_SUCCESS) {
175  DOCA_LOG_ERR("Failed to destroy DOCA ETH RXQ context, err: %s", doca_error_get_name(status));
176  return status;
177  }
178 
179  return DOCA_SUCCESS;
180 }
181 
182 /*
183  * Destroy DOCA buffers for the packets
184  *
185  * @state [in]: eth_rxq_sample_objects struct to destroy its packet DOCA buffers
186  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
187  */
189 {
190  doca_error_t status;
191 
192  status = doca_buf_dec_refcount(state->packet_buf, NULL);
193  if (status != DOCA_SUCCESS) {
194  DOCA_LOG_ERR("Failed to destroy packet_buf buffer, err: %s", doca_error_get_name(status));
195  return status;
196  }
197 
198  return DOCA_SUCCESS;
199 }
200 
201 /*
202  * Destroy ETH RXQ tasks
203  *
204  * @state [in]: eth_rxq_sample_objects struct to destroy its tasks
205  */
207 {
209 }
210 
211 /*
212  * Retrieve ETH RXQ tasks
213  *
214  * @state [in]: eth_rxq_sample_objects struct to retrieve tasks from
215  */
217 {
218  struct timespec ts = {
219  .tv_sec = 0,
220  .tv_nsec = SLEEP_IN_NANOS,
221  };
222 
223  while (state->inflight_tasks != 0) {
225  nanosleep(&ts, &ts);
226  }
227 }
228 
229 /*
230  * Create ETH RXQ context related resources
231  *
232  * @state [in/out]: eth_rxq_sample_objects struct to create its ETH RXQ context
233  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
234  */
236 {
237  doca_error_t status, clean_status;
238  union doca_data user_data;
239 
242  MAX_PKT_SIZE,
243  &(state->eth_rxq));
244  if (status != DOCA_SUCCESS) {
245  DOCA_LOG_ERR("Failed to create ETH RXQ context, err: %s", doca_error_get_name(status));
246  return status;
247  }
248 
250  if (status != DOCA_SUCCESS) {
251  DOCA_LOG_ERR("Failed to set type, err: %s", doca_error_get_name(status));
252  goto destroy_eth_rxq;
253  }
254 
256  if (status != DOCA_SUCCESS) {
257  DOCA_LOG_ERR("Failed to set receive task configuration, err: %s", doca_error_get_name(status));
258  goto destroy_eth_rxq;
259  }
260 
261  status = doca_eth_rxq_set_metadata_num(state->eth_rxq, 1);
262  if (status != DOCA_SUCCESS) {
263  DOCA_LOG_ERR("Failed to enable metadata, err: %s", doca_error_get_name(status));
264  goto destroy_eth_rxq;
265  }
266 
267  status = doca_eth_rxq_set_flow_tag(state->eth_rxq, 1);
268  if (status != DOCA_SUCCESS) {
269  DOCA_LOG_ERR("Failed to enable flow_tag, err: %s", doca_error_get_name(status));
270  goto destroy_eth_rxq;
271  }
272 
273  status = doca_eth_rxq_set_rx_hash(state->eth_rxq, 1);
274  if (status != DOCA_SUCCESS) {
275  DOCA_LOG_ERR("Failed to enable rx_hash, err: %s", doca_error_get_name(status));
276  goto destroy_eth_rxq;
277  }
278 
279  status = doca_eth_rxq_set_timestamp(state->eth_rxq, state->timestamp_enable);
280  if (status != DOCA_SUCCESS) {
281  DOCA_LOG_ERR("Failed to set enable timestamp, err: %s", doca_error_get_name(status));
282  goto destroy_eth_rxq;
283  }
284 
286  if (state->core_resources.core_objs.ctx == NULL) {
287  DOCA_LOG_ERR("Failed to retrieve DOCA ETH RXQ context as DOCA context, err: %s",
288  doca_error_get_name(status));
289  goto destroy_eth_rxq;
290  }
291 
293  if (status != DOCA_SUCCESS) {
294  DOCA_LOG_ERR("Failed to connect PE, err: %s", doca_error_get_name(status));
295  goto destroy_eth_rxq;
296  }
297 
298  user_data.ptr = state;
299  status = doca_ctx_set_user_data(state->core_resources.core_objs.ctx, user_data);
300  if (status != DOCA_SUCCESS) {
301  DOCA_LOG_ERR("Failed to set user data for DOCA context, err: %s", doca_error_get_name(status));
302  goto destroy_eth_rxq;
303  }
304 
305  status = doca_ctx_start(state->core_resources.core_objs.ctx);
306  if (status != DOCA_SUCCESS) {
307  DOCA_LOG_ERR("Failed to start DOCA context, err: %s", doca_error_get_name(status));
308  goto destroy_eth_rxq;
309  }
310 
311  status = doca_eth_rxq_get_flow_queue_id(state->eth_rxq, &(state->rxq_flow_queue_id));
312  if (status != DOCA_SUCCESS) {
313  DOCA_LOG_ERR("Failed to get flow queue ID of RXQ, err: %s", doca_error_get_name(status));
314  goto stop_ctx;
315  }
316 
317  return DOCA_SUCCESS;
318 stop_ctx:
319  clean_status = doca_ctx_stop(state->core_resources.core_objs.ctx);
320  state->core_resources.core_objs.ctx = NULL;
321 
322  if (clean_status != DOCA_SUCCESS)
323  return status;
324 destroy_eth_rxq:
325  clean_status = doca_eth_rxq_destroy(state->eth_rxq);
326  state->eth_rxq = NULL;
327 
328  if (clean_status != DOCA_SUCCESS)
329  return status;
330 
331  return status;
332 }
333 
334 /*
335  * Submit ETH RXQ tasks
336  *
337  * @state [in/out]: eth_rxq_sample_objects struct to submit its tasks
338  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
339  */
341 {
342  doca_error_t status;
343 
345  if (status != DOCA_SUCCESS) {
346  DOCA_LOG_ERR("Failed to submit receive task, err: %s", doca_error_get_name(status));
347  return status;
348  }
349 
350  state->inflight_tasks++;
351 
352  return DOCA_SUCCESS;
353 }
354 
355 /*
356  * Create ETH RXQ tasks
357  *
358  * @state [in/out]: eth_rxq_sample_objects struct to create tasks with its ETH RXQ context
359  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
360  */
362 {
363  doca_error_t status;
364  union doca_data user_data;
365 
366  user_data.u64 = RECV_TASK_USER_DATA;
367  status =
368  doca_eth_rxq_task_recv_allocate_init(state->eth_rxq, state->packet_buf, user_data, &(state->recv_task));
369  if (status != DOCA_SUCCESS) {
370  DOCA_LOG_ERR("Failed to allocate receive task, err: %s", doca_error_get_name(status));
371  return status;
372  }
373 
374  return DOCA_SUCCESS;
375 }
376 
377 /*
378  * Create DOCA buffers for the packet
379  *
380  * @state [in/out]: eth_rxq_sample_objects struct to create its packet DOCA buffers
381  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
382  */
384 {
385  doca_error_t status;
386 
389  state->core_resources.mmap_addr,
390  MAX_PKT_SIZE,
391  &(state->packet_buf));
392  if (status != DOCA_SUCCESS) {
393  DOCA_LOG_ERR("Failed to create DOCA buffer for ethernet frame, err: %s", doca_error_get_name(status));
394  return status;
395  }
396 
397  return DOCA_SUCCESS;
398 }
399 
400 /*
401  * Clean sample resources
402  *
403  * @state [in]: eth_rxq_sample_objects struct to clean
404  */
405 static void eth_rxq_cleanup(struct eth_rxq_sample_objects *state)
406 {
407  doca_error_t status;
408 
409  if (state->flow_resources.root_pipe != NULL)
411 
412  if (state->flow_resources.df_port != NULL) {
413  status = doca_flow_port_stop(state->flow_resources.df_port);
414  if (status != DOCA_SUCCESS) {
415  DOCA_LOG_ERR("Failed to stop DOCA flow port, err: %s", doca_error_get_name(status));
416  return;
417  }
418  }
419 
420  if (state->eth_rxq != NULL) {
421  status = destroy_eth_rxq_ctx(state);
422  if (status != DOCA_SUCCESS) {
423  DOCA_LOG_ERR("Failed to destroy eth_rxq_ctx, err: %s", doca_error_get_name(status));
424  return;
425  }
426  }
427 
428  if (state->core_resources.core_objs.dev != NULL) {
429  status = destroy_eth_core_resources(&(state->core_resources));
430  if (status != DOCA_SUCCESS) {
431  DOCA_LOG_ERR("Failed to destroy core_resources, err: %s", doca_error_get_name(status));
432  return;
433  }
434  }
435 
436  if (state->flow_resources.df_port != NULL)
438 }
439 
440 /*
441  * Check if device supports needed capabilities
442  *
443  * @devinfo [in]: Device info for device to check
444  * @return: DOCA_SUCCESS in case the device supports needed capabilities and DOCA_ERROR otherwise
445  */
446 static doca_error_t check_device(struct doca_devinfo *devinfo)
447 {
448  doca_error_t status;
449  uint32_t max_supported_burst_size;
450  uint32_t max_supported_packet_size;
451 
452  status = doca_eth_rxq_cap_get_max_burst_size(devinfo, &max_supported_burst_size);
453  if (status != DOCA_SUCCESS) {
454  DOCA_LOG_ERR("Failed to get supported max burst size, err: %s", doca_error_get_name(status));
455  return status;
456  }
457 
458  if (max_supported_burst_size < MAX_BURST_SIZE)
460 
461  status = doca_eth_rxq_cap_get_max_packet_size(devinfo, &max_supported_packet_size);
462  if (status != DOCA_SUCCESS) {
463  DOCA_LOG_ERR("Failed to get supported max packet size, err: %s", doca_error_get_name(status));
464  return status;
465  }
466 
467  if (max_supported_packet_size < MAX_PKT_SIZE)
469 
470  status =
472  if (status != DOCA_SUCCESS && status != DOCA_ERROR_NOT_SUPPORTED) {
473  DOCA_LOG_ERR("Failed to check supported type, err: %s", doca_error_get_name(status));
474  return status;
475  }
476 
477  return status;
478 }
479 
480 /*
481  * Run ETH RXQ regular mode receive
482  *
483  * @ib_dev_name [in]: IB device name of a doca device
484  * @timestamp_enable [in]: timestamp enable
485  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
486  */
487 doca_error_t eth_rxq_regular_receive(const char *ib_dev_name, bool timestamp_enable)
488 {
489  doca_error_t status, clean_status;
491  struct eth_core_config cfg = {.mmap_size = MAX_PKT_SIZE * BUFS_NUM,
492  .inventory_num_elements = BUFS_NUM,
493  .check_device = check_device,
494  .ibdev_name = ib_dev_name};
495  struct eth_rxq_flow_config flow_cfg = {};
496 
497  status = allocate_eth_core_resources(&cfg, &(state.core_resources));
498  if (status != DOCA_SUCCESS) {
499  DOCA_LOG_ERR("Failed allocate core resources, err: %s", doca_error_get_name(status));
500  goto rxq_cleanup;
501  }
502 
503  flow_cfg.dev = state.core_resources.core_objs.dev;
504 
505  status = rxq_common_init_doca_flow(flow_cfg.dev, &(state.flow_resources));
506  if (status != DOCA_SUCCESS) {
507  DOCA_LOG_ERR("Failed to init doca flow, err: %s", doca_error_get_name(status));
508  goto rxq_cleanup;
509  }
510 
511  status = create_eth_rxq_ctx(&state);
512  if (status != DOCA_SUCCESS) {
513  DOCA_LOG_ERR("Failed to create/start ETH RXQ context, err: %s", doca_error_get_name(status));
514  goto rxq_cleanup;
515  }
516 
517  flow_cfg.rxq_flow_queue_ids = &(state.rxq_flow_queue_id);
518  flow_cfg.nb_queues = 1;
519 
520  status = allocate_eth_rxq_flow_resources(&flow_cfg, &(state.flow_resources));
521  if (status != DOCA_SUCCESS) {
522  DOCA_LOG_ERR("Failed to allocate flow resources, err: %s", doca_error_get_name(status));
523  goto rxq_cleanup;
524  }
525 
526  status = create_eth_rxq_packet_buffer(&state);
527  if (status != DOCA_SUCCESS) {
528  DOCA_LOG_ERR("Failed to create packer buffer, err: %s", doca_error_get_name(status));
529  goto rxq_cleanup;
530  }
531 
532  status = create_eth_rxq_tasks(&state);
533  if (status != DOCA_SUCCESS) {
534  DOCA_LOG_ERR("Failed to create tasks, err: %s", doca_error_get_name(status));
535  goto destroy_packet_buffers;
536  }
537 
538  status = submit_eth_rxq_tasks(&state);
539  if (status != DOCA_SUCCESS) {
540  DOCA_LOG_ERR("Failed to submit tasks, err: %s", doca_error_get_name(status));
541  goto destroy_rxq_tasks;
542  }
543 
544  retrieve_rxq_recv_tasks(&state);
545 
546  goto rxq_cleanup;
547 
548 destroy_rxq_tasks:
549  destroy_eth_rxq_tasks(&state);
550 destroy_packet_buffers:
551  clean_status = destroy_eth_rxq_packet_buffers(&state);
552  if (clean_status != DOCA_SUCCESS)
553  return status;
554 rxq_cleanup:
555  eth_rxq_cleanup(&state);
556 
557  return status;
558 }
#define NULL
Definition: __stddef_null.h:26
doca_telemetry_exporter_timestamp_t timestamp
doca_error_t destroy_eth_core_resources(struct eth_core_resources *resources)
Definition: eth_common.c:98
doca_error_t allocate_eth_core_resources(struct eth_core_config *cfg, struct eth_core_resources *resources)
Definition: eth_common.c:38
doca_error_t allocate_eth_rxq_flow_resources(struct eth_rxq_flow_config *cfg, struct eth_rxq_flow_resources *resources)
doca_error_t rxq_common_init_doca_flow(struct doca_dev *dev, struct eth_rxq_flow_resources *resources)
static doca_error_t destroy_eth_rxq_packet_buffers(struct eth_rxq_sample_objects *state)
static doca_error_t create_eth_rxq_packet_buffer(struct eth_rxq_sample_objects *state)
DOCA_LOG_REGISTER(ETH_RXQ_REGULAR_RECEIVE)
static void destroy_eth_rxq_tasks(struct eth_rxq_sample_objects *state)
static doca_error_t submit_eth_rxq_tasks(struct eth_rxq_sample_objects *state)
#define RECV_TASK_USER_DATA
static void task_recv_common_cb(struct doca_eth_rxq_task_recv *task_recv, union doca_data task_user_data, union doca_data ctx_user_data)
static void eth_rxq_cleanup(struct eth_rxq_sample_objects *state)
#define MAX_PKT_SIZE
static doca_error_t create_eth_rxq_ctx(struct eth_rxq_sample_objects *state)
#define MAX_BURST_SIZE
static void retrieve_rxq_recv_tasks(struct eth_rxq_sample_objects *state)
static doca_error_t destroy_eth_rxq_ctx(struct eth_rxq_sample_objects *state)
doca_error_t eth_rxq_regular_receive(const char *ib_dev_name, bool timestamp_enable)
#define SLEEP_IN_NANOS
static doca_error_t create_eth_rxq_tasks(struct eth_rxq_sample_objects *state)
static doca_error_t check_device(struct doca_devinfo *devinfo)
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...
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_len(const struct doca_buf *buf, size_t *data_len)
Get buffer's data length.
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_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_IDLE
Definition: doca_ctx.h:88
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_ERROR_BAD_STATE
Definition: doca_error.h:56
@ DOCA_ERROR_NOT_SUPPORTED
Definition: doca_error.h:42
@ DOCA_SUCCESS
Definition: doca_error.h:38
@ DOCA_ERROR_IN_PROGRESS
Definition: doca_error.h:64
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_task_recv_get_flow_tag(const struct doca_eth_rxq_task_recv *task_recv, uint32_t *flow_tag)
This method gets the flow tag of a finished receive task.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_task_recv_allocate_init(struct doca_eth_rxq *eth_rxq, struct doca_buf *pkt, union doca_data user_data, struct doca_eth_rxq_task_recv **task_recv)
This method allocates and initializes a doca_eth_rxq_task_recv task.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_task_recv_get_pkt(const struct doca_eth_rxq_task_recv *task_recv, struct doca_buf **pkt)
This method gets packet buffer from doca_eth_rxq_task_recv task.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_task_recv_set_conf(struct doca_eth_rxq *eth_rxq, doca_eth_rxq_task_recv_completion_cb_t task_completion_cb, doca_eth_rxq_task_recv_completion_cb_t task_error_cb, uint32_t task_recv_num)
This method sets the doca_eth_rxq_task_recv tasks configuration. can only be called before calling do...
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_task_recv_get_metadata_array(const struct doca_eth_rxq_task_recv *task_recv, const uint32_t **metadata_array)
This method gets metadata array for the packet received by receive task.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_task_recv_get_timestamp(const struct doca_eth_rxq_task_recv *task_recv, uint64_t *timestamp)
This method gets the timestamp of a finished receive task.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_task_recv_get_rx_hash(const struct doca_eth_rxq_task_recv *task_recv, uint32_t *rx_hash)
This method gets the RX hash of a finished receive task.
DOCA_EXPERIMENTAL struct doca_task * doca_eth_rxq_task_recv_as_doca_task(struct doca_eth_rxq_task_recv *task_recv)
This method converts a doca_eth_rxq_task_recv task to doca_task.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_set_flow_tag(struct doca_eth_rxq *eth_rxq, uint8_t enable_flow_tag)
Setter to enable flow tag support. User can retrieve flow tag per packet when this is enabled....
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_get_flow_queue_id(struct doca_eth_rxq *eth_rxq, uint16_t *flow_queue_id)
Get the DPDK queue ID of the doca_eth receive queue. can only be called after calling doca_ctx_start(...
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_set_timestamp(struct doca_eth_rxq *eth_rxq, uint8_t enable_timestamp)
Setter to enable timestamp support. User can retrieve timestamp in nanoseconds per packet when this i...
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_cap_is_type_supported(const struct doca_devinfo *devinfo, enum doca_eth_rxq_type type, enum doca_eth_rxq_data_path_type data_path_type)
Check if RX queue type is supported.
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_cap_get_max_packet_size(const struct doca_devinfo *devinfo, uint32_t *max_packet_size)
Get the maximum packet size supported by the device.
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_cap_get_max_burst_size(const struct doca_devinfo *devinfo, uint32_t *max_burst_size)
Get the maximum burst size supported by the device.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_set_metadata_num(struct doca_eth_rxq *eth_rxq, uint8_t metadata_num)
Set metadata number for doca_eth_rxq. can only be called before calling doca_ctx_start().
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_set_rx_hash(struct doca_eth_rxq *eth_rxq, uint8_t enable_rx_hash)
Setter to enable RX hash support. User can retrieve RX hash per packet when this is enabled....
@ DOCA_ETH_RXQ_TYPE_REGULAR
Definition: doca_eth_rxq.h:85
@ DOCA_ETH_RXQ_DATA_PATH_TYPE_CPU
Definition: doca_eth_rxq.h:95
DOCA_STABLE void doca_flow_pipe_destroy(struct doca_flow_pipe *pipe)
Destroy one pipe.
DOCA_STABLE doca_error_t doca_flow_port_stop(struct doca_flow_port *port)
Stop a doca port.
DOCA_STABLE void doca_flow_destroy(void)
Destroy the doca flow.
#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_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 void doca_task_free(struct doca_task *task)
Free a task back to where it was allocated from.
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
struct program_core_objects core_objs
Definition: eth_common.h:40
uint16_t * rxq_flow_queue_ids
struct doca_dev * dev
struct doca_flow_pipe * root_pipe
struct doca_flow_port * df_port
struct doca_eth_rxq_task_recv * recv_task
struct doca_pe * pe
Definition: common.h:51
struct doca_mmap * src_mmap
Definition: common.h:47
struct doca_buf_inventory * buf_inv
Definition: common.h:49
struct doca_dev * dev
Definition: common.h:46
struct doca_ctx * ctx
Definition: common.h:50
Convenience type for representing opaque data.
Definition: doca_types.h:56
uint64_t u64
Definition: doca_types.h:58
void * ptr
Definition: doca_types.h:57