NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
eth_txq_lso_send_ethernet_frames_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_buf.h>
30 #include <doca_buf_inventory.h>
31 #include <doca_ctx.h>
32 #include <doca_eth_txq.h>
34 #include <doca_error.h>
35 #include <doca_log.h>
36 
37 #include "common.h"
38 #include "eth_common.h"
39 
40 DOCA_LOG_REGISTER(ETH_TXQ_LSO_SEND_ETHERNET_FRAMES);
41 
42 #define SLEEP_IN_NANOS (10 * 1000) /* sample the task every 10 microseconds */
43 #define MAX_BURST_SIZE 256 /* Max burst size to set for eth_txq */
44 #define MAX_LSO_HEADER_SIZE 64 /* Max header size in LRO packet to set for eth_txq */
45 #define MAX_LIST_LENGTH 1 /* Max number of elements in a doca_buf */
46 #define MSS 1500 /* Max Segment Size in LSO tasks to set for eth_txq */
47 #define BUFS_NUM 1 /* Number of DOCA buffers */
48 #define TASKS_NUM 1 /* Tasks number */
49 #define LSO_PKT_SIZE 4000 /* Size of the packet in doca_eth_txq_task_lso_send task */
50 #define LSO_SEND_TASK_USER_DATA 0x56789 /* User data for LSO send task */
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 *lso_eth_payload_buf; /* DOCA buffer to contain LSO ethernet payload */
57  struct doca_gather_list *lso_pkt_headers; /* DOCA gather list to contain LSO packet headers */
58  struct doca_eth_txq_task_lso_send *lso_send_task; /* LSO send task */
59  uint8_t *lso_pkt_headers_buf; /* Buffer to create lso_pkt_headers with */
60  uint8_t src_mac_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]; /* Device MAC address */
61  uint32_t inflight_tasks; /* In flight tasks */
62 };
63 
64 /*
65  * ETH TXQ LSO send task common callback
66  *
67  * @task_lso_send [in]: Completed task
68  * @task_user_data [in]: User provided data, used for identifying the task
69  * @ctx_user_data [in]: User provided data, used to store sample state
70  */
71 static void task_lso_send_common_cb(struct doca_eth_txq_task_lso_send *task_lso_send,
72  union doca_data task_user_data,
73  union doca_data ctx_user_data)
74 {
75  doca_error_t status, status_task;
76  struct doca_buf *pkt_payload;
77  size_t payload_size;
78  uint32_t *inflight_tasks;
79 
80  inflight_tasks = ctx_user_data.ptr;
81  (*inflight_tasks)--;
82  DOCA_LOG_INFO("LSO send task user data is 0x%lx", task_user_data.u64);
83 
84  status = doca_eth_txq_task_lso_send_get_pkt_payload(task_lso_send, &pkt_payload);
85  if (status != DOCA_SUCCESS) {
86  DOCA_LOG_ERR("Failed to get packet payload of an LSO send task, err: %s", doca_error_get_name(status));
88  return;
89  }
90 
92 
93  status = doca_buf_get_data_len(pkt_payload, &payload_size);
94  if (status != DOCA_SUCCESS) {
95  DOCA_LOG_ERR("Failed to get LSO send packet payload size, err: %s", doca_error_get_name(status));
96  } else {
97  if (status_task == DOCA_SUCCESS)
98  DOCA_LOG_INFO("Sent an LSO packet of payload size %lu successfully", payload_size);
99  else
100  DOCA_LOG_ERR("Failed to send an LSO packet of payload size %lu, err: %s",
101  payload_size,
102  doca_error_get_name(status_task));
103  }
104 
105  status = doca_buf_dec_refcount(pkt_payload, NULL);
106  if (status != DOCA_SUCCESS)
107  DOCA_LOG_ERR("Failed to free packet payload buf, err: %s", doca_error_get_name(status));
108 
110 }
111 
112 /*
113  * Destroy ETH TXQ context related resources
114  *
115  * @state [in]: eth_txq_lso_sample_objects struct to destroy its ETH TXQ context
116  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
117  */
119 {
120  doca_error_t status;
121  enum doca_ctx_states ctx_state;
122  struct timespec ts = {
123  .tv_sec = 0,
124  .tv_nsec = SLEEP_IN_NANOS,
125  };
126 
127  status = doca_ctx_stop(state->core_resources.core_objs.ctx);
128  if (status == DOCA_ERROR_IN_PROGRESS) {
129  while (state->inflight_tasks != 0) {
131  nanosleep(&ts, &ts);
132  }
133 
134  status = doca_ctx_get_state(state->core_resources.core_objs.ctx, &ctx_state);
135  if (status != DOCA_SUCCESS) {
136  DOCA_LOG_ERR("Failed get status of context, err: %s", doca_error_get_name(status));
137  return status;
138  }
139 
140  status = ctx_state == DOCA_CTX_STATE_IDLE ? DOCA_SUCCESS : DOCA_ERROR_BAD_STATE;
141  }
142 
143  if (status != DOCA_SUCCESS) {
144  DOCA_LOG_ERR("Failed to stop DOCA context, err: %s", doca_error_get_name(status));
145  return status;
146  }
147 
148  status = doca_eth_txq_destroy(state->eth_txq);
149  if (status != DOCA_SUCCESS) {
150  DOCA_LOG_ERR("Failed to destroy DOCA ETH TXQ context, err: %s", doca_error_get_name(status));
151  return status;
152  }
153 
154  return DOCA_SUCCESS;
155 }
156 
157 /*
158  * Destroy DOCA buffers for the packets
159  *
160  * @state [in]: eth_txq_lso_sample_objects struct to destroy its packet DOCA buffers
161  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
162  */
164 {
165  doca_error_t status;
166 
168  if (status != DOCA_SUCCESS) {
169  DOCA_LOG_ERR("Failed to destroy lso_eth_payload_buf buffer, err: %s", doca_error_get_name(status));
170  return status;
171  }
172 
173  return DOCA_SUCCESS;
174 }
175 
176 /*
177  * Destroy ETH TXQ tasks
178  *
179  * @state [in]: eth_txq_lso_sample_objects struct to destroy its tasks
180  */
182 {
184 }
185 
186 /*
187  * Retrieve ETH TXQ tasks
188  *
189  * @state [in]: eth_txq_lso_sample_objects struct to retrieve its tasks
190  */
192 {
193  struct timespec ts = {
194  .tv_sec = 0,
195  .tv_nsec = SLEEP_IN_NANOS,
196  };
197 
198  while (state->inflight_tasks != 0) {
200  nanosleep(&ts, &ts);
201  }
202 }
203 
204 /*
205  * Submit ETH TXQ tasks
206  *
207  * @state [in]: eth_txq_lso_sample_objects struct to submit its tasks
208  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
209  */
211 {
212  doca_error_t status;
213 
215  if (status != DOCA_SUCCESS) {
216  DOCA_LOG_ERR("Failed to submit LSO send task, err: %s", doca_error_get_name(status));
217  return status;
218  }
219 
220  state->inflight_tasks++;
221 
222  return DOCA_SUCCESS;
223 }
224 
225 /*
226  * Create ETH TXQ tasks
227  *
228  * @state [in/out]: eth_txq_lso_sample_objects struct to create tasks with its ETH TXQ context
229  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
230  */
232 {
233  doca_error_t status;
234  union doca_data user_data;
235 
236  user_data.u64 = LSO_SEND_TASK_USER_DATA;
238  state->lso_eth_payload_buf,
239  state->lso_pkt_headers,
240  user_data,
241  &(state->lso_send_task));
242  if (status != DOCA_SUCCESS) {
243  DOCA_LOG_ERR("Failed to allocate LSO send task, err: %s", doca_error_get_name(status));
244  return status;
245  }
246 
247  return DOCA_SUCCESS;
248 }
249 
250 /*
251  * Create DOCA buffers for the packets
252  *
253  * @dest_mac_addr [in]: Destination MAC address to set in ethernet header
254  * @state [in/out]: eth_txq_lso_sample_objects struct to create its packet DOCA buffers
255  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
256  */
257 static doca_error_t create_eth_txq_lso_packet_buffers(uint8_t *dest_mac_addr, struct eth_txq_lso_sample_objects *state)
258 {
259  doca_error_t status;
260  struct ether_hdr *eth_hdr;
261  uint8_t *payload;
262 
265  state->core_resources.mmap_addr,
266  LSO_PKT_SIZE,
267  &(state->lso_eth_payload_buf));
268  if (status != DOCA_SUCCESS) {
269  DOCA_LOG_ERR("Failed to create DOCA buffer for LSO ethernet payload, err: %s",
270  doca_error_get_name(status));
271  return status;
272  }
273 
274  state->lso_pkt_headers->addr = state->lso_pkt_headers_buf;
275  state->lso_pkt_headers->len = sizeof(struct ether_hdr);
276  state->lso_pkt_headers->next = NULL;
277 
278  /* Create LSO packet header + payload */
279  eth_hdr = (struct ether_hdr *)state->lso_pkt_headers_buf;
280  payload = state->core_resources.mmap_addr;
281  memcpy(&(eth_hdr->src_addr), state->src_mac_addr, DOCA_DEVINFO_MAC_ADDR_SIZE);
282  memcpy(&(eth_hdr->dst_addr), dest_mac_addr, DOCA_DEVINFO_MAC_ADDR_SIZE);
283  eth_hdr->ether_type = htobe16(ETHER_TYPE_IPV4);
284  memset(payload, 0x22, LSO_PKT_SIZE);
285 
286  return DOCA_SUCCESS;
287 }
288 
289 /*
290  * Create ETH TXQ context related resources
291  *
292  * @state [in/out]: eth_txq_lso_sample_objects struct to create its ETH TXQ context
293  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
294  */
296 {
297  doca_error_t status, clean_status;
298  union doca_data user_data;
299 
301  if (status != DOCA_SUCCESS) {
302  DOCA_LOG_ERR("Failed to create ETH TXQ context, err: %s", doca_error_get_name(status));
303  return status;
304  }
305 
306  status = doca_eth_txq_set_mss(state->eth_txq, MSS);
307  if (status != DOCA_SUCCESS) {
308  DOCA_LOG_ERR("Failed to set MSS, err: %s", doca_error_get_name(status));
309  goto destroy_eth_txq;
310  }
311 
313  if (status != DOCA_SUCCESS) {
314  DOCA_LOG_ERR("Failed to set max_lso_header_size, err: %s", doca_error_get_name(status));
315  goto destroy_eth_txq;
316  }
317 
319  if (status != DOCA_SUCCESS) {
320  DOCA_LOG_ERR("Failed to set type, err: %s", doca_error_get_name(status));
321  goto destroy_eth_txq;
322  }
323 
327  TASKS_NUM);
328  if (status != DOCA_SUCCESS) {
329  DOCA_LOG_ERR("Failed to configure task_lso_send, err: %s", doca_error_get_name(status));
330  goto destroy_eth_txq;
331  }
332 
334  if (state->core_resources.core_objs.ctx == NULL) {
335  DOCA_LOG_ERR("Failed to retrieve DOCA ETH TXQ context as DOCA context, err: %s",
336  doca_error_get_name(status));
337  goto destroy_eth_txq;
338  }
339 
341  if (status != DOCA_SUCCESS) {
342  DOCA_LOG_ERR("Failed to connect PE, err: %s", doca_error_get_name(status));
343  goto destroy_eth_txq;
344  }
345 
346  user_data.ptr = &(state->inflight_tasks);
347  status = doca_ctx_set_user_data(state->core_resources.core_objs.ctx, user_data);
348  if (status != DOCA_SUCCESS) {
349  DOCA_LOG_ERR("Failed to set user data for DOCA context, err: %s", doca_error_get_name(status));
350  goto destroy_eth_txq;
351  }
352 
353  status = doca_ctx_start(state->core_resources.core_objs.ctx);
354  if (status != DOCA_SUCCESS) {
355  DOCA_LOG_ERR("Failed to start DOCA context, err: %s", doca_error_get_name(status));
356  goto destroy_eth_txq;
357  }
358 
359  return DOCA_SUCCESS;
360 destroy_eth_txq:
361  clean_status = doca_eth_txq_destroy(state->eth_txq);
362  state->eth_txq = NULL;
363 
364  if (clean_status != DOCA_SUCCESS)
365  return clean_status;
366 
367  return status;
368 }
369 
370 /*
371  * Clean sample resources
372  *
373  * @state [in]: eth_txq_lso_sample_objects struct to clean
374  */
376 {
377  doca_error_t status;
378 
379  if (state->lso_pkt_headers != NULL)
380  free(state->lso_pkt_headers);
381 
382  if (state->lso_pkt_headers_buf != NULL)
383  free(state->lso_pkt_headers_buf);
384 
385  if (state->eth_txq != NULL) {
386  status = destroy_eth_txq_ctx(state);
387  if (status != DOCA_SUCCESS) {
388  DOCA_LOG_ERR("Failed to destroy eth_txq_ctx, err: %s", doca_error_get_name(status));
389  return;
390  }
391  }
392 
393  if (state->core_resources.core_objs.dev != NULL) {
394  status = destroy_eth_core_resources(&(state->core_resources));
395  if (status != DOCA_SUCCESS) {
396  DOCA_LOG_ERR("Failed to destroy core_resources, err: %s", doca_error_get_name(status));
397  return;
398  }
399  }
400 }
401 
402 /*
403  * Check if device supports needed capabilities
404  *
405  * @devinfo [in]: Device info for device to check
406  * @return: DOCA_SUCCESS in case the device supports needed capabilities and DOCA_ERROR otherwise
407  */
408 static doca_error_t check_device(struct doca_devinfo *devinfo)
409 {
410  doca_error_t status;
411  uint32_t max_supported_burst_size;
412  uint16_t max_supported_lso_header_size;
413 
414  status = doca_eth_txq_cap_get_max_burst_size(devinfo,
417  &max_supported_burst_size);
418  if (status != DOCA_SUCCESS) {
419  DOCA_LOG_ERR("Failed to get supported max burst size, err: %s", doca_error_get_name(status));
420  return status;
421  }
422 
423  if (max_supported_burst_size < MAX_BURST_SIZE)
425 
426  status = doca_eth_txq_cap_get_max_lso_header_size(devinfo, &max_supported_lso_header_size);
427  if (status != DOCA_SUCCESS) {
428  DOCA_LOG_ERR("Failed to get supported max lso header size, err: %s", doca_error_get_name(status));
429  return status;
430  }
431 
432  if (max_supported_lso_header_size < MAX_LSO_HEADER_SIZE)
434 
435  status =
437  if (status != DOCA_SUCCESS && status != DOCA_ERROR_NOT_SUPPORTED) {
438  DOCA_LOG_ERR("Failed to check supported type, err: %s", doca_error_get_name(status));
439  return status;
440  }
441 
442  return status;
443 }
444 
445 /*
446  * Run ETH TXQ send ethernet frames
447  *
448  * @ib_dev_name [in]: IB device name of a doca device
449  * @dest_mac_addr [in]: destination MAC address to associate with the ethernet frames
450  * @return: DOCA_SUCCESS on success, DOCA_ERROR otherwise
451  */
452 doca_error_t eth_txq_lso_send_ethernet_frames(const char *ib_dev_name, uint8_t *dest_mac_addr)
453 {
454  doca_error_t status, clean_status;
455  struct eth_txq_lso_sample_objects state;
456  struct eth_core_config cfg = {.mmap_size = LSO_PKT_SIZE * BUFS_NUM,
457  .inventory_num_elements = BUFS_NUM,
458  .check_device = check_device,
459  .ibdev_name = ib_dev_name};
460 
461  memset(&state, 0, sizeof(struct eth_txq_lso_sample_objects));
462  status = allocate_eth_core_resources(&cfg, &(state.core_resources));
463  if (status != DOCA_SUCCESS) {
464  DOCA_LOG_ERR("Failed allocate core resources, err: %s", doca_error_get_name(status));
465  return status;
466  }
467 
469  state.src_mac_addr,
471  if (status != DOCA_SUCCESS) {
472  DOCA_LOG_ERR("Failed to get device MAC address, err: %s", doca_error_get_name(status));
473  goto txq_lso_cleanup;
474  }
475 
476  status = create_eth_txq_ctx(&state);
477  if (status != DOCA_SUCCESS) {
478  DOCA_LOG_ERR("Failed to create/start ETH TXQ context, err: %s", doca_error_get_name(status));
479  goto txq_lso_cleanup;
480  }
481 
482  state.lso_pkt_headers_buf = (uint8_t *)malloc(sizeof(struct ether_hdr));
483  if (state.lso_pkt_headers_buf == NULL) {
484  DOCA_LOG_ERR("Failed to allocate memory for LSO packet headers");
485  status = DOCA_ERROR_NO_MEMORY;
486  goto txq_lso_cleanup;
487  }
488 
489  state.lso_pkt_headers = (struct doca_gather_list *)malloc(sizeof(struct doca_gather_list));
490  if (state.lso_pkt_headers == NULL) {
491  DOCA_LOG_ERR("Failed to create DOCA gather list node for LSO packet headers");
492  status = DOCA_ERROR_NO_MEMORY;
493  goto txq_lso_cleanup;
494  }
495 
496  status = create_eth_txq_lso_packet_buffers(dest_mac_addr, &state);
497  if (status != DOCA_SUCCESS) {
498  DOCA_LOG_ERR("Failed to create packet buffers, err: %s", doca_error_get_name(status));
499  goto txq_lso_cleanup;
500  }
501 
502  status = create_eth_txq_tasks(&state);
503  if (status != DOCA_SUCCESS) {
504  DOCA_LOG_ERR("Failed to create tasks, err: %s", doca_error_get_name(status));
505  goto destroy_packet_buffers;
506  }
507 
508  status = submit_eth_txq_tasks(&state);
509  if (status != DOCA_SUCCESS) {
510  DOCA_LOG_ERR("Failed to submit tasks, err: %s", doca_error_get_name(status));
511  goto destroy_txq_tasks;
512  }
513 
514  retrieve_eth_txq_tasks(&state);
515 
516  goto txq_lso_cleanup;
517 
518 destroy_txq_tasks:
519  destroy_eth_txq_tasks(&state);
520 destroy_packet_buffers:
521  clean_status = destroy_eth_txq_packet_buffers(&state);
522  if (clean_status != DOCA_SUCCESS)
523  return clean_status;
524 txq_lso_cleanup:
525  eth_txq_lso_cleanup(&state);
526 
527  return status;
528 }
#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 destroy_eth_txq_tasks(struct eth_txq_lso_sample_objects *state)
static doca_error_t create_eth_txq_lso_packet_buffers(uint8_t *dest_mac_addr, struct eth_txq_lso_sample_objects *state)
static void eth_txq_lso_cleanup(struct eth_txq_lso_sample_objects *state)
static doca_error_t create_eth_txq_tasks(struct eth_txq_lso_sample_objects *state)
static doca_error_t destroy_eth_txq_packet_buffers(struct eth_txq_lso_sample_objects *state)
static doca_error_t submit_eth_txq_tasks(struct eth_txq_lso_sample_objects *state)
static void task_lso_send_common_cb(struct doca_eth_txq_task_lso_send *task_lso_send, union doca_data task_user_data, union doca_data ctx_user_data)
DOCA_LOG_REGISTER(ETH_TXQ_LSO_SEND_ETHERNET_FRAMES)
static doca_error_t create_eth_txq_ctx(struct eth_txq_lso_sample_objects *state)
static void retrieve_eth_txq_tasks(struct eth_txq_lso_sample_objects *state)
doca_error_t eth_txq_lso_send_ethernet_frames(const char *ib_dev_name, uint8_t *dest_mac_addr)
static doca_error_t destroy_eth_txq_ctx(struct eth_txq_lso_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_NO_MEMORY
Definition: doca_error.h:45
@ DOCA_ERROR_IN_PROGRESS
Definition: doca_error.h:64
DOCA_EXPERIMENTAL struct doca_task * doca_eth_txq_task_lso_send_as_doca_task(struct doca_eth_txq_task_lso_send *task_lso_send)
This method converts a doca_eth_txq_task_lso_send task to doca_task.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_task_lso_send_allocate_init(struct doca_eth_txq *eth_txq, struct doca_buf *pkt_payload, struct doca_gather_list *headers, union doca_data user_data, struct doca_eth_txq_task_lso_send **task_lso_send)
This method allocates and initializes a doca_eth_txq_task_lso_send task.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_task_lso_send_get_pkt_payload(const struct doca_eth_txq_task_lso_send *task_lso_send, struct doca_buf **pkt_payload)
This method gets payload buffer from doca_eth_txq_task_lso_send task.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_task_lso_send_set_conf(struct doca_eth_txq *eth_txq, doca_eth_txq_task_lso_send_completion_cb_t task_completion_cb, doca_eth_txq_task_lso_send_completion_cb_t task_error_cb, uint32_t task_lso_send_num)
This method sets the doca_eth_txq_task_lso_send tasks configuration.
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_EXPERIMENTAL doca_error_t doca_eth_txq_set_mss(struct doca_eth_txq *eth_txq, uint16_t mss)
Set the Maximum Segment Size for doca_eth_txq. This value will be used per LSO send task / task_batch...
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_set_max_lso_header_size(struct doca_eth_txq *eth_txq, uint16_t max_lso_header_size)
Set the maximum LSO header size for doca_eth_txq. This value is the maximum header size of the LSO pa...
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_cap_get_max_lso_header_size(const struct doca_devinfo *devinfo, uint16_t *max_lso_header_size)
Get the maximum header size of an LSO packet supported by the device.
@ 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_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
#define htobe16
Definition: os_utils.hpp:39
Struct to represent a gather list.
Definition: doca_types.h:64
struct doca_gather_list * next
Definition: doca_types.h:67
uint64_t len
Definition: doca_types.h:66
struct program_core_objects core_objs
Definition: eth_common.h:40
struct doca_eth_txq_task_lso_send * lso_send_task
uint8_t src_mac_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]
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