NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
eth_rxq_batch_managed_mempool_receive_sample.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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 <time.h>
27 #include <stdint.h>
28 #include <unistd.h>
29 
30 #include <doca_flow.h>
31 #include <doca_buf.h>
32 #include <doca_buf_inventory.h>
33 #include <doca_ctx.h>
34 #include <doca_eth_rxq.h>
36 #include <doca_error.h>
37 #include <doca_log.h>
38 
39 #include "common.h"
40 #include "eth_common.h"
41 #include "eth_rxq_common.h"
42 
43 DOCA_LOG_REGISTER(ETH_RXQ_BATCH_MANAGED_MEMPOOL_RECEIVE);
44 
45 #define SLEEP_IN_NANOS (10 * 1000) /* sample for event batch every 10 microseconds */
46 #define MAX_BURST_SIZE 2048 /* Max burst size to set for eth_rxq */
47 #define MAX_PKT_SIZE 1600 /* Max packet size to set for eth_rxq */
48 #define RATE 10000 /* Traffic max rate in [MB/s] */
49 #define LOG_MAX_LRO_PKT_SIZE 15 /* Log of max LRO packet size */
50 #define PKT_MAX_TIME 10 /* Max time in [μs] to process a packet */
51 #define COUNTERS_NUM (1 << 19) /* Number of counters to configure for DOCA flow*/
52 #define SAMPLE_RUNS_TIME 30 /* Sample total run-time in [s] */
53 
55  struct eth_core_resources core_resources; /* A struct to hold ETH core resources */
56  struct eth_rxq_flow_resources flow_resources; /* A struct to hold DOCA flow resources */
57  struct doca_eth_rxq *eth_rxq; /* DOCA ETH RXQ context */
58  uint64_t total_received_packets; /* Counter for received packets */
59  uint16_t rxq_flow_queue_id; /* DOCA ETH RXQ's flow queue ID */
60  bool timestamp_enable; /* timestamp enable */
61  uint16_t headroom_size; /* headroom size */
62  uint16_t tailroom_size; /* tailroom size */
63 };
64 
65 /*
66  * ETH RXQ managed receive event batch successful callback
67  *
68  * @event_batch_managed_recv [in]: The managed receive event batch
69  * @events_number [in]: Number of retrieved events, each representing a received packet
70  * @event_batch_user_data [in]: User provided data, used to associate with a specific type of event batch
71  * @status [in]: Status of retrieved event batch (DOCA_SUCCESS in case of success callback)
72  * @pkt_array [in]: Array of doca_bufs containing the received packets (NULL in case of error callback)
73  */
74 static void event_batch_managed_rcv_success_cb(struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv,
75  uint16_t events_number,
76  union doca_data event_batch_user_data,
77  doca_error_t status,
78  struct doca_buf **pkt_array)
79 {
80  doca_error_t ret;
81  struct eth_rxq_sample_objects *state;
82  const uint32_t *metadata_array = NULL, *flow_tag_array = NULL, *rx_hash_array = NULL;
83  const uint64_t *timestamp_array = NULL;
84  size_t packet_size;
85  uint16_t headroom_size;
86  uint16_t tailroom_size;
87 
88  state = event_batch_user_data.ptr;
89  state->total_received_packets += events_number;
90 
91  DOCA_LOG_INFO("Received %u packets successfully", events_number);
92 
93  ret = doca_eth_rxq_event_batch_managed_recv_get_metadata_array(event_batch_managed_recv, &metadata_array);
94  if (ret != DOCA_SUCCESS)
95  DOCA_LOG_ERR("Failed to get metadata_array, err: %s", doca_error_get_name(ret));
96 
97  ret = doca_eth_rxq_event_batch_managed_recv_get_flow_tag_array(event_batch_managed_recv, &flow_tag_array);
98  if (ret != DOCA_SUCCESS)
99  DOCA_LOG_ERR("Failed to get flow_tag_arrat, err: %s", doca_error_get_name(ret));
100 
101  ret = doca_eth_rxq_event_batch_managed_recv_get_rx_hash_array(event_batch_managed_recv, &rx_hash_array);
102  if (ret != DOCA_SUCCESS)
103  DOCA_LOG_ERR("Failed to get rx_hash_array, err: %s", doca_error_get_name(ret));
104 
105  if (state->timestamp_enable) {
106  ret = doca_eth_rxq_event_batch_managed_recv_get_timestamp_array(event_batch_managed_recv,
107  &timestamp_array);
108  if (ret != DOCA_SUCCESS)
109  DOCA_LOG_ERR("Failed to get timestamp_array, err: %s", doca_error_get_name(ret));
110  }
111 
112  for (uint16_t i = 0; i < events_number; i++) {
113  ret = doca_buf_get_data_len(pkt_array[i], &packet_size);
114  if (ret != DOCA_SUCCESS)
115  DOCA_LOG_ERR("Packet#%u: failed to get received packet data size, err: %s",
116  i,
117  doca_error_get_name(ret));
118  else
119  DOCA_LOG_INFO("Packet#%u: received a packet with data size %lu successfully", i, packet_size);
120 
121  if (state->headroom_size > 0) {
122  status = get_pkt_headroom(pkt_array[i], &headroom_size);
123  if (status != DOCA_SUCCESS)
124  DOCA_LOG_ERR("Packet#%u: failed to get packet headroom size, err: %s",
125  i,
126  doca_error_get_name(status));
127  else
128  DOCA_LOG_INFO("Packet#%u: received a packet with headroom size %d, requested %d",
129  i,
131  state->headroom_size);
132  }
133  if (state->tailroom_size > 0) {
134  status = get_pkt_tailroom(pkt_array[i], &tailroom_size);
135  if (status != DOCA_SUCCESS)
136  DOCA_LOG_ERR("Packet#%u: failed to get packet tailroom size, err: %s",
137  i,
138  doca_error_get_name(status));
139  else
140  DOCA_LOG_INFO("Packet#%u: received a packet with tailroom size %d, requested %d",
141  i,
143  state->tailroom_size);
144  }
145 
146  if (metadata_array != NULL)
147  DOCA_LOG_INFO("Packet#%u: metadata associated with the packet is %u",
148  i,
150  1,
151  i,
152  0));
153 
154  if (flow_tag_array != NULL)
155  DOCA_LOG_INFO("Packet#%u: flow_tag associated with the packet is %u", i, flow_tag_array[i]);
156 
157  if (rx_hash_array != NULL)
158  DOCA_LOG_INFO("Packet#%u: rx_hash associated with the packet is %u", i, rx_hash_array[i]);
159 
160  if (timestamp_array != NULL)
161  DOCA_LOG_INFO("Packet#%u: timestamp associated with the packet is %lu", i, timestamp_array[i]);
162  }
163 
165 }
166 
167 /*
168  * ETH RXQ managed receive event batch error callback
169  *
170  * @event_batch_managed_recv [in]: The managed receive event batch
171  * @events_number [in]: Number of retrieved events, each representing a received packet
172  * @event_batch_user_data [in]: User provided data, used to associate with a specific type of event batch
173  * @status [in]: Status of retrieved event batch (DOCA_SUCCESS in case of success callback)
174  * @pkt_array [in]: Array of doca_bufs containing the received packets (NULL in case of error callback)
175  */
176 static void event_batch_managed_rcv_error_cb(struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv,
177  uint16_t events_number,
178  union doca_data event_batch_user_data,
179  doca_error_t status,
180  struct doca_buf **pkt_array)
181 {
182  DOCA_LOG_ERR("Failed to receive packets, err: %s", doca_error_get_name(status));
183 }
184 
185 /*
186  * Destroy ETH RXQ context related resources
187  *
188  * @state [in]: eth_rxq_sample_objects struct to destroy its ETH RXQ context
189  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
190  */
192 {
193  doca_error_t status;
194 
195  status = doca_ctx_stop(state->core_resources.core_objs.ctx);
196  if (status != DOCA_SUCCESS) {
197  DOCA_LOG_ERR("Failed to stop DOCA context, err: %s", doca_error_get_name(status));
198  return status;
199  }
200 
201  status = doca_eth_rxq_destroy(state->eth_rxq);
202  if (status != DOCA_SUCCESS) {
203  DOCA_LOG_ERR("Failed to destroy DOCA ETH RXQ context, err: %s", doca_error_get_name(status));
204  return status;
205  }
206 
207  return DOCA_SUCCESS;
208 }
209 
210 /*
211  * Retrieve ETH RXQ event batches
212  *
213  * @state [in]: eth_rxq_sample_objects struct to retrieve event batches from
214  */
216 {
217  struct timespec ts = {
218  .tv_sec = 0,
219  .tv_nsec = SLEEP_IN_NANOS,
220  };
221  time_t start_time, end_time;
222  double elapsed_time = 0;
223 
224  start_time = time(NULL);
225  while (elapsed_time <= SAMPLE_RUNS_TIME) {
226  end_time = time(NULL);
227  elapsed_time = difftime(end_time, start_time);
228 
230  nanosleep(&ts, &ts);
231  }
232 
233  DOCA_LOG_INFO("Total packets received: %lu", state->total_received_packets);
234 }
235 
236 /*
237  * Create ETH RXQ context related resources
238  *
239  * @state [in/out]: eth_rxq_sample_objects struct to create its ETH RXQ context
240  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
241  */
243 {
244  doca_error_t status, clean_status;
245  union doca_data user_data;
246 
249  MAX_PKT_SIZE,
250  &(state->eth_rxq));
251  if (status != DOCA_SUCCESS) {
252  DOCA_LOG_ERR("Failed to create ETH RXQ context, err: %s", doca_error_get_name(status));
253  return status;
254  }
255 
257  if (status != DOCA_SUCCESS) {
258  DOCA_LOG_ERR("Failed to set type, err: %s", doca_error_get_name(status));
259  goto destroy_eth_rxq;
260  }
261 
262  status = doca_eth_rxq_set_pkt_buf(state->eth_rxq,
264  0,
265  state->core_resources.mmap_size);
266  if (status != DOCA_SUCCESS) {
267  DOCA_LOG_ERR("Failed to set packet buffer, err: %s", doca_error_get_name(status));
268  goto destroy_eth_rxq;
269  }
270 
271  user_data.ptr = state;
275  user_data,
278  if (status != DOCA_SUCCESS) {
279  DOCA_LOG_ERR("Failed to register managed receive event batch, err: %s", doca_error_get_name(status));
280  goto destroy_eth_rxq;
281  }
282 
283  status = doca_eth_rxq_set_metadata_num(state->eth_rxq, 1);
284  if (status != DOCA_SUCCESS) {
285  DOCA_LOG_ERR("Failed to enable metadata, err: %s", doca_error_get_name(status));
286  goto destroy_eth_rxq;
287  }
288 
289  status = doca_eth_rxq_set_flow_tag(state->eth_rxq, 1);
290  if (status != DOCA_SUCCESS) {
291  DOCA_LOG_ERR("Failed to enable flow_tag, err: %s", doca_error_get_name(status));
292  goto destroy_eth_rxq;
293  }
294 
295  status = doca_eth_rxq_set_rx_hash(state->eth_rxq, 1);
296  if (status != DOCA_SUCCESS) {
297  DOCA_LOG_ERR("Failed to enable rx_hash, err: %s", doca_error_get_name(status));
298  goto destroy_eth_rxq;
299  }
300 
301  status = doca_eth_rxq_set_timestamp(state->eth_rxq, state->timestamp_enable);
302  if (status != DOCA_SUCCESS) {
303  DOCA_LOG_ERR("Failed to set enable timestamp, err: %s", doca_error_get_name(status));
304  goto destroy_eth_rxq;
305  }
306 
307  status = doca_eth_rxq_set_packet_headroom(state->eth_rxq, state->headroom_size);
308  if (status != DOCA_SUCCESS) {
309  DOCA_LOG_ERR("Failed to set packet headroom size, err: %s", doca_error_get_name(status));
310  goto destroy_eth_rxq;
311  }
312 
313  status = doca_eth_rxq_set_packet_tailroom(state->eth_rxq, state->tailroom_size);
314  if (status != DOCA_SUCCESS) {
315  DOCA_LOG_ERR("Failed to set packet tailroom size, err: %s", doca_error_get_name(status));
316  goto destroy_eth_rxq;
317  }
318 
320  if (state->core_resources.core_objs.ctx == NULL) {
321  DOCA_LOG_ERR("Failed to retrieve DOCA ETH RXQ context as DOCA context, err: %s",
322  doca_error_get_name(status));
323  goto destroy_eth_rxq;
324  }
325 
327  if (status != DOCA_SUCCESS) {
328  DOCA_LOG_ERR("Failed to connect PE, err: %s", doca_error_get_name(status));
329  goto destroy_eth_rxq;
330  }
331 
332  status = doca_ctx_start(state->core_resources.core_objs.ctx);
333  if (status != DOCA_SUCCESS) {
334  DOCA_LOG_ERR("Failed to start DOCA context, err: %s", doca_error_get_name(status));
335  goto destroy_eth_rxq;
336  }
337 
338  status = doca_eth_rxq_get_flow_queue_id(state->eth_rxq, &(state->rxq_flow_queue_id));
339  if (status != DOCA_SUCCESS) {
340  DOCA_LOG_ERR("Failed to get flow queue ID of RXQ, err: %s", doca_error_get_name(status));
341  goto stop_ctx;
342  }
343 
344  return DOCA_SUCCESS;
345 stop_ctx:
346  clean_status = doca_ctx_stop(state->core_resources.core_objs.ctx);
347  state->core_resources.core_objs.ctx = NULL;
348 
349  if (clean_status != DOCA_SUCCESS)
350  return status;
351 destroy_eth_rxq:
352  clean_status = doca_eth_rxq_destroy(state->eth_rxq);
353  state->eth_rxq = NULL;
354 
355  if (clean_status != DOCA_SUCCESS)
356  return status;
357 
358  return status;
359 }
360 
361 /*
362  * Clean sample resources
363  *
364  * @state [in]: eth_rxq_sample_objects struct to clean
365  */
366 static void eth_rxq_cleanup(struct eth_rxq_sample_objects *state)
367 {
368  doca_error_t status;
369 
370  if (state->flow_resources.root_pipe != NULL)
372 
373  if (state->flow_resources.df_port != NULL) {
374  status = doca_flow_port_stop(state->flow_resources.df_port);
375  if (status != DOCA_SUCCESS) {
376  DOCA_LOG_ERR("Failed to stop DOCA flow port, err: %s", doca_error_get_name(status));
377  return;
378  }
379  }
380 
381  if (state->eth_rxq != NULL) {
382  status = destroy_eth_rxq_ctx(state);
383  if (status != DOCA_SUCCESS) {
384  DOCA_LOG_ERR("Failed to destroy eth_rxq_ctx, err: %s", doca_error_get_name(status));
385  return;
386  }
387  }
388 
389  if (state->core_resources.core_objs.dev != NULL) {
390  status = destroy_eth_core_resources(&(state->core_resources));
391  if (status != DOCA_SUCCESS) {
392  DOCA_LOG_ERR("Failed to destroy core_resources, err: %s", doca_error_get_name(status));
393  return;
394  }
395  }
396 
397  if (state->flow_resources.df_port != NULL)
399 }
400 
401 /*
402  * Check if device supports needed capabilities
403  *
404  * @devinfo [in]: Device info for device to check
405  * @return: DOCA_SUCCESS in case the device supports needed capabilities and DOCA_ERROR otherwise
406  */
407 static doca_error_t check_device(struct doca_devinfo *devinfo)
408 {
409  doca_error_t status;
410  uint32_t max_supported_burst_size;
411  uint32_t max_supported_packet_size;
412 
413  status = doca_eth_rxq_cap_get_max_burst_size(devinfo, &max_supported_burst_size);
414  if (status != DOCA_SUCCESS) {
415  DOCA_LOG_ERR("Failed to get supported max burst size, err: %s", doca_error_get_name(status));
416  return status;
417  }
418 
419  if (max_supported_burst_size < MAX_BURST_SIZE)
421 
422  status = doca_eth_rxq_cap_get_max_packet_size(devinfo, &max_supported_packet_size);
423  if (status != DOCA_SUCCESS) {
424  DOCA_LOG_ERR("Failed to get supported max packet size, err: %s", doca_error_get_name(status));
425  return status;
426  }
427 
428  if (max_supported_packet_size < MAX_PKT_SIZE)
430 
431  status = doca_eth_rxq_cap_is_type_supported(devinfo,
434  if (status != DOCA_SUCCESS && status != DOCA_ERROR_NOT_SUPPORTED) {
435  DOCA_LOG_ERR("Failed to check supported type, err: %s", doca_error_get_name(status));
436  return status;
437  }
438 
439  return status;
440 }
441 
442 /*
443  * Run ETH RXQ batch managed mempool receive
444  *
445  * @ib_dev_name [in]: IB device name of a doca device
446  * @timestamp_enable [in]: timestamp enable
447  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
448  */
450  bool timestamp_enable,
451  uint16_t headroom_size,
452  uint16_t tailroom_size)
453 {
454  doca_error_t status;
455  struct eth_rxq_sample_objects state = {.total_received_packets = 0,
456  .timestamp_enable = timestamp_enable,
457  .headroom_size = headroom_size,
458  .tailroom_size = tailroom_size};
459  struct eth_core_config cfg = {.mmap_size = 0,
460  .inventory_num_elements = 0,
461  .check_device = check_device,
462  .ibdev_name = ib_dev_name};
463  struct eth_rxq_flow_config flow_cfg = {};
464 
466  RATE,
467  PKT_MAX_TIME,
468  MAX_PKT_SIZE,
471  headroom_size,
472  tailroom_size,
473  &(cfg.mmap_size));
474  if (status != DOCA_SUCCESS) {
475  DOCA_LOG_ERR("Failed to estimate mmap size for ETH RXQ, err: %s", doca_error_get_name(status));
476  return status;
477  }
478 
479  status = allocate_eth_core_resources(&cfg, &(state.core_resources));
480  if (status != DOCA_SUCCESS) {
481  DOCA_LOG_ERR("Failed allocate core resources, err: %s", doca_error_get_name(status));
482  goto rxq_cleanup;
483  }
484 
485  flow_cfg.dev = state.core_resources.core_objs.dev;
486 
487  status = rxq_common_init_doca_flow(flow_cfg.dev, &(state.flow_resources));
488  if (status != DOCA_SUCCESS) {
489  DOCA_LOG_ERR("Failed to init doca flow, err: %s", doca_error_get_name(status));
490  goto rxq_cleanup;
491  }
492 
493  status = create_eth_rxq_ctx(&state);
494  if (status != DOCA_SUCCESS) {
495  DOCA_LOG_ERR("Failed to create/start ETH RXQ context, err: %s", doca_error_get_name(status));
496  goto rxq_cleanup;
497  }
498 
499  flow_cfg.rxq_flow_queue_ids = &(state.rxq_flow_queue_id);
500  flow_cfg.nb_queues = 1;
501 
502  status = allocate_eth_rxq_flow_resources(&flow_cfg, &(state.flow_resources));
503  if (status != DOCA_SUCCESS) {
504  DOCA_LOG_ERR("Failed to allocate flow resources, err: %s", doca_error_get_name(status));
505  goto rxq_cleanup;
506  }
507 
509 rxq_cleanup:
510  eth_rxq_cleanup(&state);
511 
512  return status;
513 }
#define NULL
Definition: __stddef_null.h:26
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
static void event_batch_managed_rcv_error_cb(struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv, uint16_t events_number, union doca_data event_batch_user_data, doca_error_t status, struct doca_buf **pkt_array)
DOCA_LOG_REGISTER(ETH_RXQ_BATCH_MANAGED_MEMPOOL_RECEIVE)
doca_error_t eth_rxq_batch_managed_mempool_receive(const char *ib_dev_name, bool timestamp_enable, uint16_t headroom_size, uint16_t tailroom_size)
static void event_batch_managed_rcv_success_cb(struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv, uint16_t events_number, union doca_data event_batch_user_data, doca_error_t status, struct doca_buf **pkt_array)
static void eth_rxq_cleanup(struct eth_rxq_sample_objects *state)
static doca_error_t create_eth_rxq_ctx(struct eth_rxq_sample_objects *state)
static doca_error_t destroy_eth_rxq_ctx(struct eth_rxq_sample_objects *state)
static void retrieve_rxq_managed_recv_event_batches(struct eth_rxq_sample_objects *state)
static doca_error_t check_device(struct doca_devinfo *devinfo)
doca_error_t get_pkt_tailroom(struct doca_buf *pkt, uint16_t *tailroom_size)
doca_error_t get_pkt_headroom(struct doca_buf *pkt, uint16_t *headroom_size)
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)
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_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_name(doca_error_t error)
Returns the string representation of an error code name.
@ DOCA_ERROR_NOT_SUPPORTED
Definition: doca_error.h:42
@ DOCA_SUCCESS
Definition: doca_error.h:38
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_event_batch_managed_recv_get_metadata_array(const struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv, const uint32_t **metadata_array)
This method gets metadata array for the packet received by managed receive event batch.
DOCA_EXPERIMENTAL void doca_eth_rxq_event_batch_managed_recv_pkt_array_free(struct doca_buf **pkt_array)
This method frees the packet array acquired using managed receive event batch and returns it to the o...
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_event_batch_managed_recv_get_flow_tag_array(const struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv, const uint32_t **flow_tag_array)
This method gets the flow tag array of a managed receive event batch.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_event_batch_managed_recv_get_timestamp_array(const struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv, const uint64_t **timestamp_array)
This method gets the timestamp array of a managed receive event batch.
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_event_batch_managed_recv_get_rx_hash_array(const struct doca_eth_rxq_event_batch_managed_recv *event_batch_managed_recv, const uint32_t **rx_hash_array)
This method gets the RX hash array of a managed receive event batch.
#define doca_eth_rxq_event_batch_managed_recv_metadata_array_get_metadata(metadata_array, metadata_num, packet_index, metadata_index)
This MACRO is used to get a specific metadata of a specific packet from metadata_array from managed r...
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_event_batch_managed_recv_register(struct doca_eth_rxq *eth_rxq, enum doca_event_batch_events_number events_number_max, enum doca_event_batch_events_number events_number_min, union doca_data user_data, doca_eth_rxq_event_batch_managed_recv_handler_cb_t success_event_batch_handler, doca_eth_rxq_event_batch_managed_recv_handler_cb_t error_event_batch_handler)
This method registers a doca_eth_rxq_event_managed_recv event batch. Allows user to get multiple even...
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_packet_tailroom(struct doca_eth_rxq *eth_rxq, uint16_t tail_size)
Setter to enable packet tailroom support. User can use doca_buf's tailroom of size tail_size when thi...
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_packet_headroom(struct doca_eth_rxq *eth_rxq, uint16_t head_size)
Setter to enable packet headroom support. User can use doca_buf's headroom of size head_size when thi...
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_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_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_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_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_MANAGED_MEMPOOL
Definition: doca_eth_rxq.h:75
@ 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_pe_connect_ctx(struct doca_pe *pe, struct doca_ctx *ctx)
This method connects a context to a progress engine.
DOCA_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
@ DOCA_EVENT_BATCH_EVENTS_NUMBER_64
Definition: doca_pe.h:65
@ DOCA_EVENT_BATCH_EVENTS_NUMBER_32
Definition: doca_pe.h:64
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
struct program_core_objects core_objs
Definition: eth_common.h:40
uint32_t mmap_size
Definition: eth_common.h:43
uint16_t * rxq_flow_queue_ids
struct doca_dev * dev
struct doca_flow_pipe * root_pipe
struct doca_flow_port * df_port
struct doca_pe * pe
Definition: common.h:51
struct doca_mmap * src_mmap
Definition: common.h:47
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
void * ptr
Definition: doca_types.h:57