42 #define SLEEP_IN_NANOS (10 * 1000)
43 #define MAX_BURST_SIZE 256
44 #define MAX_LSO_HEADER_SIZE 64
45 #define MAX_LIST_LENGTH 1
49 #define LSO_PKT_SIZE 4000
50 #define LSO_SEND_TASK_USER_DATA 0x56789
51 #define ETHER_TYPE_IPV4 0x0800
76 struct doca_buf *pkt_payload;
78 uint32_t *inflight_tasks;
80 inflight_tasks = ctx_user_data.
ptr;
98 DOCA_LOG_INFO(
"Sent an LSO packet of payload size %lu successfully", payload_size);
100 DOCA_LOG_ERR(
"Failed to send an LSO packet of payload size %lu, err: %s",
122 struct timespec ts = {
193 struct timespec ts = {
269 DOCA_LOG_ERR(
"Failed to create DOCA buffer for LSO ethernet payload, err: %s",
309 goto destroy_eth_txq;
315 goto destroy_eth_txq;
321 goto destroy_eth_txq;
330 goto destroy_eth_txq;
335 DOCA_LOG_ERR(
"Failed to retrieve DOCA ETH TXQ context as DOCA context, err: %s",
337 goto destroy_eth_txq;
343 goto destroy_eth_txq;
350 goto destroy_eth_txq;
356 goto destroy_eth_txq;
411 uint32_t max_supported_burst_size;
412 uint16_t max_supported_lso_header_size;
417 &max_supported_burst_size);
459 .ibdev_name = ib_dev_name};
473 goto txq_lso_cleanup;
479 goto txq_lso_cleanup;
484 DOCA_LOG_ERR(
"Failed to allocate memory for LSO packet headers");
486 goto txq_lso_cleanup;
491 DOCA_LOG_ERR(
"Failed to create DOCA gather list node for LSO packet headers");
493 goto txq_lso_cleanup;
499 goto txq_lso_cleanup;
505 goto destroy_packet_buffers;
511 goto destroy_txq_tasks;
516 goto txq_lso_cleanup;
520 destroy_packet_buffers:
doca_error_t destroy_eth_core_resources(struct eth_core_resources *resources)
doca_error_t allocate_eth_core_resources(struct eth_core_config *cfg, struct eth_core_resources *resources)
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)
#define MAX_LSO_HEADER_SIZE
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)
#define LSO_SEND_TASK_USER_DATA
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.
#define DOCA_DEVINFO_MAC_ADDR_SIZE
Length of MAC address.
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_NOT_SUPPORTED
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
@ DOCA_ETH_TXQ_TYPE_REGULAR
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
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
Struct to represent a gather list.
struct doca_gather_list * next
struct program_core_objects core_objs
struct doca_eth_txq_task_lso_send * lso_send_task
uint8_t * lso_pkt_headers_buf
struct doca_buf * lso_eth_payload_buf
struct eth_core_resources core_resources
uint8_t src_mac_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]
struct doca_gather_list * lso_pkt_headers
struct doca_eth_txq * eth_txq
uint8_t dst_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]
uint8_t src_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]
struct doca_mmap * src_mmap
struct doca_buf_inventory * buf_inv
Convenience type for representing opaque data.