NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
eth_txq_batch_send_ethernet_frames_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_buf.h>
31 #include <doca_buf_inventory.h>
32 #include <doca_ctx.h>
33 #include <doca_eth_txq.h>
35 #include <doca_error.h>
36 #include <doca_log.h>
37 
38 #include "common.h"
39 #include "eth_common.h"
40 
41 DOCA_LOG_REGISTER(ETH_TXQ_BATCH_SEND_ETHERNET_FRAMES);
42 
43 #define SLEEP_IN_NANOS (10 * 1000) /* sample the task batch every 10 microseconds */
44 #define MAX_BURST_SIZE 256 /* Max burst size to set for eth_txq */
45 #define MAX_LIST_LENGTH 1 /* Max number of elements in a doca_buf */
46 #define TASKS_IN_TASK_BATCH 32 /* Number of tasks associated with task batch */
47 #define BUFS_NUM TASKS_IN_TASK_BATCH /* Number of DOCA buffers */
48 #define TASK_BATCHES_NUM 1 /* Task batches number */
49 #define REGULAR_PKT_SIZE 1500 /* Size of the packets in send task batch */
50 #define SEND_TASK_BATCH_USER_DATA 0x43210 /* User data for send task batch */
51 #define ETHER_TYPE_IPV4 0x0800 /* IPV4 type */
52 
54  struct eth_core_resources core_resources; /* A struct to hold ETH core resources */
55  struct doca_eth_txq *eth_txq; /* DOCA ETH TXQ context */
56  struct doca_buf *eth_frame_bufs[BUFS_NUM]; /* DOCA buffers array to contain regular ethernet frames */
57  struct doca_task_batch *send_task_batch; /* Send task batch */
58  uint8_t src_mac_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]; /* Device MAC address */
59  uint32_t inflight_task_batches; /* In flight task batches */
60 };
61 
62 /*
63  * ETH TXQ send task batch common callback
64  *
65  * @task_batch [in]: Completed task batch
66  * @tasks_num [in]: Task number associated with task batch
67  * @ctx_user_data [in]: User provided data, used to store sample state
68  * @task_batch_user_data [in]: User provided data, used for identifying the task batch
69  * @task_user_data_array [in]: Array of user provided data, each used for identifying the each task behind task batch
70  * @pkt_array [in]: Array of packets, each associated to one send task that's part of the send task batch
71  * @status_array [in]: Array of status, each associated to one send task that's part of the send task batch (in
72  * successful CB, all are DOCA_SUCCESS)
73  */
74 static void task_batch_send_common_cb(struct doca_task_batch *task_batch,
75  uint16_t tasks_num,
76  union doca_data ctx_user_data,
77  union doca_data task_batch_user_data,
78  union doca_data *task_user_data_array,
79  struct doca_buf **pkt_array,
80  doca_error_t *status_array)
81 {
82  doca_error_t status;
83  size_t packet_size;
84  uint32_t *inflight_task_batches;
85 
86  inflight_task_batches = (uint32_t *)ctx_user_data.ptr;
87  (*inflight_task_batches)--;
88  DOCA_LOG_INFO("Send task batch user data is 0x%lx", task_batch_user_data.u64);
89 
90  for (uint32_t i = 0; i < tasks_num; i++) {
91  if (status_array[i] != DOCA_SUCCESS) {
92  DOCA_LOG_ERR("Packet#%u associated with user data %lu: failed to send this packet, err: %s",
93  i,
94  task_user_data_array[i].u64,
95  doca_error_get_name(status_array[i]));
96  } else {
97  status = doca_buf_get_data_len(pkt_array[i], &packet_size);
98  if (status != DOCA_SUCCESS) {
100  "Packet#%u associated with user data %lu: failed to get successfully sent packet's size, err: %s",
101  i,
102  task_user_data_array[i].u64,
103  doca_error_get_name(status));
104  } else {
106  "Packet#%u associated with user data %lu: packet with size %lu was sent successfully",
107  i,
108  task_user_data_array[i].u64,
109  packet_size);
110  }
111  }
112 
113  status = doca_buf_dec_refcount(pkt_array[i], NULL);
114  if (status != DOCA_SUCCESS)
115  DOCA_LOG_ERR("Packet#%u: failed to free packet buf, err: %s", i, doca_error_get_name(status));
116  }
117 
118  doca_task_batch_free(task_batch);
119 }
120 
121 /*
122  * Destroy ETH TXQ context related resources
123  *
124  * @state [in]: eth_txq_batch_send_sample_objects struct to destroy its ETH TXQ context
125  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
126  */
128 {
129  doca_error_t status;
130  enum doca_ctx_states ctx_state;
131  struct timespec ts = {
132  .tv_sec = 0,
133  .tv_nsec = SLEEP_IN_NANOS,
134  };
135 
136  status = doca_ctx_stop(state->core_resources.core_objs.ctx);
137  if (status == DOCA_ERROR_IN_PROGRESS) {
138  while (state->inflight_task_batches != 0) {
140  nanosleep(&ts, &ts);
141  }
142 
143  status = doca_ctx_get_state(state->core_resources.core_objs.ctx, &ctx_state);
144  if (status != DOCA_SUCCESS) {
145  DOCA_LOG_ERR("Failed get status of context, err: %s", doca_error_get_name(status));
146  return status;
147  }
148 
149  status = ctx_state == DOCA_CTX_STATE_IDLE ? DOCA_SUCCESS : DOCA_ERROR_BAD_STATE;
150  }
151 
152  if (status != DOCA_SUCCESS) {
153  DOCA_LOG_ERR("Failed to stop DOCA context, err: %s", doca_error_get_name(status));
154  return status;
155  }
156 
157  status = doca_eth_txq_destroy(state->eth_txq);
158  if (status != DOCA_SUCCESS) {
159  DOCA_LOG_ERR("Failed to destroy DOCA ETH TXQ context, err: %s", doca_error_get_name(status));
160  return status;
161  }
162 
163  return DOCA_SUCCESS;
164 }
165 
166 /*
167  * Destroy DOCA buffers for the packets
168  *
169  * @state [in]: eth_txq_batch_send_sample_objects struct to destroy its packets DOCA buffers
170  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
171  */
173 {
174  doca_error_t status;
175 
176  for (uint32_t i = 0; i < BUFS_NUM; i++) {
177  status = doca_buf_dec_refcount(state->eth_frame_bufs[i], NULL);
178  if (status != DOCA_SUCCESS) {
179  DOCA_LOG_ERR("Failed to destroy eth_frame_bufs[%u] buffer, err: %s",
180  i,
181  doca_error_get_name(status));
182  return status;
183  }
184  }
185 
186  return DOCA_SUCCESS;
187 }
188 
189 /*
190  * Destroy ETH TXQ task batch
191  *
192  * @state [in]: eth_txq_batch_send_sample_objects struct to destroy its task batch
193  */
195 {
197 }
198 
199 /*
200  * Retrieve ETH TXQ task batch
201  *
202  * @state [in]: eth_txq_batch_send_sample_objects struct to retrieve its task batch
203  */
205 {
206  struct timespec ts = {
207  .tv_sec = 0,
208  .tv_nsec = SLEEP_IN_NANOS,
209  };
210 
211  while (state->inflight_task_batches != 0) {
213  nanosleep(&ts, &ts);
214  }
215 }
216 
217 /*
218  * Submit ETH TXQ task batch
219  *
220  * @state [in]: eth_txq_batch_send_sample_objects struct to submit its task batch
221  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
222  */
224 {
225  doca_error_t status;
226 
227  status = doca_task_batch_submit(state->send_task_batch);
228  if (status != DOCA_SUCCESS) {
229  DOCA_LOG_ERR("Failed to submit send task batch, err: %s", doca_error_get_name(status));
230  return status;
231  }
232 
233  state->inflight_task_batches++;
234 
235  return DOCA_SUCCESS;
236 }
237 
238 /*
239  * Create ETH TXQ task batch
240  *
241  * @state [in/out]: eth_txq_batch_send_sample_objects struct to create task batch with its ETH TXQ context
242  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
243  */
245 {
246  doca_error_t status;
247  union doca_data task_batch_user_data;
248  struct doca_buf **pkt_array;
249  union doca_data *task_user_data_array;
250 
251  task_batch_user_data.u64 = SEND_TASK_BATCH_USER_DATA;
254  task_batch_user_data,
255  &pkt_array,
256  &task_user_data_array,
257  &(state->send_task_batch));
258  if (status != DOCA_SUCCESS) {
259  DOCA_LOG_ERR("Failed to allocate send task batch, err: %s", doca_error_get_name(status));
260  return status;
261  }
262 
263  for (uint32_t i = 0; i < TASKS_IN_TASK_BATCH; i++) {
264  pkt_array[i] = state->eth_frame_bufs[i];
265  task_user_data_array[i].u64 = i;
266  }
267 
268  return DOCA_SUCCESS;
269 }
270 
271 /*
272  * Create DOCA buffers for the packets
273  *
274  * @dest_mac_addr [in]: Destination MAC address to set in ethernet header
275  * @state [in/out]: eth_txq_batch_send_sample_objects struct to create its packet DOCA buffers
276  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
277  */
278 static doca_error_t create_eth_txq_packet_buffers(uint8_t *dest_mac_addr,
279  struct eth_txq_batch_send_sample_objects *state)
280 {
281  doca_error_t status, clean_status;
282  struct ether_hdr *eth_hdr;
283  uint8_t *payload;
284  void *pkt_addr;
285  uint32_t i;
286 
287  for (i = 0; i < BUFS_NUM; i++) {
288  pkt_addr = (void *)(((uint8_t *)state->core_resources.mmap_addr) + (i * REGULAR_PKT_SIZE));
291  pkt_addr,
293  &(state->eth_frame_bufs[i]));
294  if (status != DOCA_SUCCESS) {
295  DOCA_LOG_ERR("Failed to create DOCA buffer for regular ethernet frame, err: %s",
296  doca_error_get_name(status));
297  break;
298  }
299 
300  /* Create regular packet header + payload */
301  eth_hdr = (struct ether_hdr *)pkt_addr;
302  payload = (uint8_t *)(eth_hdr + 1);
303  memcpy(&(eth_hdr->src_addr), state->src_mac_addr, DOCA_DEVINFO_MAC_ADDR_SIZE);
304  memcpy(&(eth_hdr->dst_addr), dest_mac_addr, DOCA_DEVINFO_MAC_ADDR_SIZE);
305  eth_hdr->ether_type = htobe16(ETHER_TYPE_IPV4);
306  memset(payload, i, REGULAR_PKT_SIZE - sizeof(struct ether_hdr));
307  }
308 
309  if (status != DOCA_SUCCESS) {
310  for (uint32_t j = 0; j < i; j++) {
311  clean_status = doca_buf_dec_refcount(state->eth_frame_bufs[j], NULL);
312  if (clean_status != DOCA_SUCCESS)
313  return status;
314  }
315 
316  return status;
317  }
318 
319  return DOCA_SUCCESS;
320 }
321 
322 /*
323  * Create ETH TXQ context related resources
324  *
325  * @state [in/out]: eth_txq_batch_send_sample_objects struct to create its ETH TXQ context
326  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
327  */
329 {
330  doca_error_t status, clean_status;
331  union doca_data user_data;
332 
334  if (status != DOCA_SUCCESS) {
335  DOCA_LOG_ERR("Failed to create ETH TXQ context, err: %s", doca_error_get_name(status));
336  return status;
337  }
338 
340  if (status != DOCA_SUCCESS) {
341  DOCA_LOG_ERR("Failed to set type, err: %s", doca_error_get_name(status));
342  goto destroy_eth_txq;
343  }
344 
350  if (status != DOCA_SUCCESS) {
351  DOCA_LOG_ERR("Failed to configure send task batch, err: %s", doca_error_get_name(status));
352  goto destroy_eth_txq;
353  }
354 
356  if (state->core_resources.core_objs.ctx == NULL) {
357  DOCA_LOG_ERR("Failed to retrieve DOCA ETH TXQ context as DOCA context, err: %s",
358  doca_error_get_name(status));
359  goto destroy_eth_txq;
360  }
361 
363  if (status != DOCA_SUCCESS) {
364  DOCA_LOG_ERR("Failed to connect PE, err: %s", doca_error_get_name(status));
365  goto destroy_eth_txq;
366  }
367 
368  user_data.ptr = &(state->inflight_task_batches);
369  status = doca_ctx_set_user_data(state->core_resources.core_objs.ctx, user_data);
370  if (status != DOCA_SUCCESS) {
371  DOCA_LOG_ERR("Failed to set user data for DOCA context, err: %s", doca_error_get_name(status));
372  goto destroy_eth_txq;
373  }
374 
375  status = doca_ctx_start(state->core_resources.core_objs.ctx);
376  if (status != DOCA_SUCCESS) {
377  DOCA_LOG_ERR("Failed to start DOCA context, err: %s", doca_error_get_name(status));
378  goto destroy_eth_txq;
379  }
380 
381  return DOCA_SUCCESS;
382 destroy_eth_txq:
383  clean_status = doca_eth_txq_destroy(state->eth_txq);
384  state->eth_txq = NULL;
385 
386  if (clean_status != DOCA_SUCCESS)
387  return clean_status;
388 
389  return status;
390 }
391 
392 /*
393  * Clean sample resources
394  *
395  * @state [in]: eth_txq_batch_send_sample_objects struct to clean
396  */
398 {
399  doca_error_t status;
400 
401  if (state->eth_txq != NULL) {
402  status = destroy_eth_txq_ctx(state);
403  if (status != DOCA_SUCCESS) {
404  DOCA_LOG_ERR("Failed to destroy eth_txq_ctx, err: %s", doca_error_get_name(status));
405  return;
406  }
407  }
408 
409  if (state->core_resources.core_objs.dev != NULL) {
410  status = destroy_eth_core_resources(&(state->core_resources));
411  if (status != DOCA_SUCCESS) {
412  DOCA_LOG_ERR("Failed to destroy core_resources, err: %s", doca_error_get_name(status));
413  return;
414  }
415  }
416 }
417 
418 /*
419  * Check if device supports needed capabilities
420  *
421  * @devinfo [in]: Device info for device to check
422  * @return: DOCA_SUCCESS in case the device supports needed capabilities and DOCA_ERROR otherwise
423  */
424 static doca_error_t check_device(struct doca_devinfo *devinfo)
425 {
426  doca_error_t status;
427  uint32_t max_supported_burst_size;
428 
429  status = doca_eth_txq_cap_get_max_burst_size(devinfo, MAX_LIST_LENGTH, 0, &max_supported_burst_size);
430  if (status != DOCA_SUCCESS) {
431  DOCA_LOG_ERR("Failed to get supported max burst size, err: %s", doca_error_get_name(status));
432  return status;
433  }
434 
435  if (max_supported_burst_size < MAX_BURST_SIZE)
437 
438  status =
440  if (status != DOCA_SUCCESS && status != DOCA_ERROR_NOT_SUPPORTED) {
441  DOCA_LOG_ERR("Failed to check supported type, err: %s", doca_error_get_name(status));
442  return status;
443  }
444 
445  return status;
446 }
447 
448 /*
449  * Run ETH TXQ batch send ethernet frames
450  *
451  * @ib_dev_name [in]: IB device name of a doca device
452  * @dest_mac_addr [in]: destination MAC address to associate with the ethernet frames
453  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
454  */
455 doca_error_t eth_txq_batch_send_ethernet_frames(const char *ib_dev_name, uint8_t *dest_mac_addr)
456 {
457  doca_error_t status, clean_status;
459  struct eth_core_config cfg = {.mmap_size = REGULAR_PKT_SIZE * BUFS_NUM,
460  .inventory_num_elements = BUFS_NUM,
461  .check_device = check_device,
462  .ibdev_name = ib_dev_name};
463 
464  memset(&state, 0, sizeof(struct eth_txq_batch_send_sample_objects));
465  status = allocate_eth_core_resources(&cfg, &(state.core_resources));
466  if (status != DOCA_SUCCESS) {
467  DOCA_LOG_ERR("Failed allocate core resources, err: %s", doca_error_get_name(status));
468  return status;
469  }
470 
472  state.src_mac_addr,
474  if (status != DOCA_SUCCESS) {
475  DOCA_LOG_ERR("Failed to get device MAC address, err: %s", doca_error_get_name(status));
476  goto txq_cleanup;
477  }
478 
479  status = create_eth_txq_ctx(&state);
480  if (status != DOCA_SUCCESS) {
481  DOCA_LOG_ERR("Failed to create/start ETH TXQ context, err: %s", doca_error_get_name(status));
482  goto txq_cleanup;
483  }
484 
485  status = create_eth_txq_packet_buffers(dest_mac_addr, &state);
486  if (status != DOCA_SUCCESS) {
487  DOCA_LOG_ERR("Failed to create packet buffers, err: %s", doca_error_get_name(status));
488  goto txq_cleanup;
489  }
490 
491  status = create_eth_txq_task_batch(&state);
492  if (status != DOCA_SUCCESS) {
493  DOCA_LOG_ERR("Failed to create task batch, err: %s", doca_error_get_name(status));
494  goto destroy_packet_buffers;
495  }
496 
497  status = submit_eth_txq_task_batch(&state);
498  if (status != DOCA_SUCCESS) {
499  DOCA_LOG_ERR("Failed to submit task batch, err: %s", doca_error_get_name(status));
500  goto destroy_txq_task_batch;
501  }
502 
504 
505  goto txq_cleanup;
506 
507 destroy_txq_task_batch:
509 destroy_packet_buffers:
510  clean_status = destroy_eth_txq_packet_buffers(&state);
511  if (clean_status != DOCA_SUCCESS)
512  return clean_status;
513 txq_cleanup:
514  eth_txq_cleanup(&state);
515 
516  return status;
517 }
#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 doca_error_t create_eth_txq_task_batch(struct eth_txq_batch_send_sample_objects *state)
static doca_error_t create_eth_txq_ctx(struct eth_txq_batch_send_sample_objects *state)
static void eth_txq_cleanup(struct eth_txq_batch_send_sample_objects *state)
static void destroy_eth_txq_task_batch(struct eth_txq_batch_send_sample_objects *state)
DOCA_LOG_REGISTER(ETH_TXQ_BATCH_SEND_ETHERNET_FRAMES)
static void task_batch_send_common_cb(struct doca_task_batch *task_batch, uint16_t tasks_num, union doca_data ctx_user_data, union doca_data task_batch_user_data, union doca_data *task_user_data_array, struct doca_buf **pkt_array, doca_error_t *status_array)
static doca_error_t destroy_eth_txq_packet_buffers(struct eth_txq_batch_send_sample_objects *state)
static void retrieve_eth_txq_task_batch(struct eth_txq_batch_send_sample_objects *state)
doca_error_t eth_txq_batch_send_ethernet_frames(const char *ib_dev_name, uint8_t *dest_mac_addr)
static doca_error_t create_eth_txq_packet_buffers(uint8_t *dest_mac_addr, struct eth_txq_batch_send_sample_objects *state)
static doca_error_t submit_eth_txq_task_batch(struct eth_txq_batch_send_sample_objects *state)
static doca_error_t destroy_eth_txq_ctx(struct eth_txq_batch_send_sample_objects *state)
static doca_error_t check_device(struct doca_devinfo *devinfo)
static doca_error_t doca_buf_inventory_buf_get_by_data(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *data, size_t data_len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by data & data_len a...
DOCA_STABLE doca_error_t doca_buf_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
#define DOCA_DEVINFO_MAC_ADDR_SIZE
Length of MAC address.
Definition: doca_dev.h:301
DOCA_STABLE doca_error_t doca_devinfo_get_mac_addr(const struct doca_devinfo *devinfo, uint8_t *mac_addr, uint32_t size)
Get the MAC address of a DOCA devinfo.
DOCA_STABLE struct doca_devinfo * doca_dev_as_devinfo(const struct doca_dev *dev)
Get local device info from device. This should be useful when wanting to query information about devi...
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_txq_task_batch_send_set_conf(struct doca_eth_txq *eth_txq, enum doca_task_batch_max_tasks_number max_tasks_number, uint16_t num_task_batches, doca_eth_txq_task_batch_send_completion_cb_t success_completion_cb, doca_eth_txq_task_batch_send_completion_cb_t error_completion_cb)
This method sets the task_batch of send tasks configuration.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_task_batch_send_allocate(struct doca_eth_txq *eth_txq, uint16_t tasks_num, union doca_data task_batch_user_data, struct doca_buf ***pkt_array, union doca_data **task_user_data_array, struct doca_task_batch **task_batch)
This method allocates a doca_taskbtach of doca_eth_txq_task_send tasks.
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_cap_get_max_burst_size(const struct doca_devinfo *devinfo, uint32_t max_send_buf_list_len, uint16_t max_lso_header_size, uint32_t *max_burst_size)
Get the maximum burst size supported by the device.
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_destroy(struct doca_eth_txq *eth_txq)
Destroy a DOCA ETH TXQ instance.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_set_type(struct doca_eth_txq *eth_txq, enum doca_eth_txq_type type)
Set TX queue type property for doca_eth_txq. can only be called before calling doca_ctx_start().
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_cap_is_type_supported(const struct doca_devinfo *devinfo, enum doca_eth_txq_type type, enum doca_eth_txq_data_path_type data_path_type)
Check if TX queue type is supported.
@ DOCA_ETH_TXQ_DATA_PATH_TYPE_CPU
Definition: doca_eth_txq.h:72
@ DOCA_ETH_TXQ_TYPE_REGULAR
Definition: doca_eth_txq.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_pe_connect_ctx(struct doca_pe *pe, struct doca_ctx *ctx)
This method connects a context to a progress engine.
DOCA_EXPERIMENTAL void doca_task_batch_free(struct doca_task_batch *task_batch)
Free a task_batch back to where it was allocated from.
DOCA_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
DOCA_EXPERIMENTAL doca_error_t doca_task_batch_submit(struct doca_task_batch *task_batch)
Submit a task_batch to a progress engine.
@ DOCA_TASK_BATCH_MAX_TASKS_NUMBER_64
Definition: doca_pe.h:51
uint64_t u64
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
#define htobe16
Definition: os_utils.hpp:39
struct program_core_objects core_objs
Definition: eth_common.h:40
uint8_t dst_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]
Definition: eth_common.h:54
uint16_t ether_type
Definition: packets.h:63
uint8_t src_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]
Definition: eth_common.h:55
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