43 #define SLEEP_IN_NANOS (10 * 1000)
44 #define MAX_BURST_SIZE 256
45 #define MAX_LIST_LENGTH 1
46 #define TASKS_IN_TASK_BATCH 32
47 #define BUFS_NUM TASKS_IN_TASK_BATCH
48 #define TASK_BATCHES_NUM 1
49 #define REGULAR_PKT_SIZE 1500
50 #define SEND_TASK_BATCH_USER_DATA 0x43210
51 #define ETHER_TYPE_IPV4 0x0800
79 struct doca_buf **pkt_array,
84 uint32_t *inflight_task_batches;
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);
90 for (uint32_t i = 0; i < tasks_num; i++) {
92 DOCA_LOG_ERR(
"Packet#%u associated with user data %lu: failed to send this packet, err: %s",
94 task_user_data_array[i].
u64,
100 "Packet#%u associated with user data %lu: failed to get successfully sent packet's size, err: %s",
102 task_user_data_array[i].
u64,
106 "Packet#%u associated with user data %lu: packet with size %lu was sent successfully",
108 task_user_data_array[i].
u64,
131 struct timespec ts = {
176 for (uint32_t i = 0; i <
BUFS_NUM; i++) {
179 DOCA_LOG_ERR(
"Failed to destroy eth_frame_bufs[%u] buffer, err: %s",
206 struct timespec ts = {
248 struct doca_buf **pkt_array;
254 task_batch_user_data,
256 &task_user_data_array,
265 task_user_data_array[i].
u64 = i;
295 DOCA_LOG_ERR(
"Failed to create DOCA buffer for regular ethernet frame, err: %s",
302 payload = (uint8_t *)(eth_hdr + 1);
310 for (uint32_t j = 0; j < i; j++) {
342 goto destroy_eth_txq;
352 goto destroy_eth_txq;
357 DOCA_LOG_ERR(
"Failed to retrieve DOCA ETH TXQ context as DOCA context, err: %s",
359 goto destroy_eth_txq;
365 goto destroy_eth_txq;
372 goto destroy_eth_txq;
378 goto destroy_eth_txq;
427 uint32_t max_supported_burst_size;
462 .ibdev_name = ib_dev_name};
494 goto destroy_packet_buffers;
500 goto destroy_txq_task_batch;
507 destroy_txq_task_batch:
509 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 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)
#define SEND_TASK_BATCH_USER_DATA
static void destroy_eth_txq_task_batch(struct eth_txq_batch_send_sample_objects *state)
DOCA_LOG_REGISTER(ETH_TXQ_BATCH_SEND_ETHERNET_FRAMES)
#define TASKS_IN_TASK_BATCH
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.
#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 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
@ 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_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
const struct ip_frag_config * cfg
struct program_core_objects core_objs
uint8_t src_mac_addr[DOCA_DEVINFO_MAC_ADDR_SIZE]
struct doca_buf * eth_frame_bufs[BUFS_NUM]
struct eth_core_resources core_resources
struct doca_eth_txq * eth_txq
uint32_t inflight_task_batches
struct doca_task_batch * send_task_batch
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.