45 #define SLEEP_IN_NANOS (10 * 1000)
46 #define MAX_BURST_SIZE 2048
47 #define MAX_PKT_SIZE 1600
49 #define LOG_MAX_LRO_PKT_SIZE 15
50 #define PKT_MAX_TIME 10
51 #define COUNTERS_NUM (1 << 19)
52 #define SAMPLE_RUNS_TIME 30
75 uint16_t events_number,
78 struct doca_buf **pkt_array)
82 const uint32_t *metadata_array =
NULL, *flow_tag_array =
NULL, *rx_hash_array =
NULL;
83 const uint64_t *timestamp_array =
NULL;
88 state = event_batch_user_data.
ptr;
91 DOCA_LOG_INFO(
"Received %u packets successfully", events_number);
112 for (uint16_t i = 0; i < events_number; i++) {
115 DOCA_LOG_ERR(
"Packet#%u: failed to get received packet data size, err: %s",
119 DOCA_LOG_INFO(
"Packet#%u: received a packet with data size %lu successfully", i, packet_size);
124 DOCA_LOG_ERR(
"Packet#%u: failed to get packet headroom size, err: %s",
128 DOCA_LOG_INFO(
"Packet#%u: received a packet with headroom size %d, requested %d",
136 DOCA_LOG_ERR(
"Packet#%u: failed to get packet tailroom size, err: %s",
140 DOCA_LOG_INFO(
"Packet#%u: received a packet with tailroom size %d, requested %d",
146 if (metadata_array !=
NULL)
147 DOCA_LOG_INFO(
"Packet#%u: metadata associated with the packet is %u",
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]);
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]);
160 if (timestamp_array !=
NULL)
161 DOCA_LOG_INFO(
"Packet#%u: timestamp associated with the packet is %lu", i, timestamp_array[i]);
177 uint16_t events_number,
180 struct doca_buf **pkt_array)
217 struct timespec ts = {
221 time_t start_time, end_time;
222 double elapsed_time = 0;
224 start_time = time(
NULL);
226 end_time = time(
NULL);
227 elapsed_time = difftime(end_time, start_time);
259 goto destroy_eth_rxq;
268 goto destroy_eth_rxq;
271 user_data.
ptr = state;
280 goto destroy_eth_rxq;
286 goto destroy_eth_rxq;
292 goto destroy_eth_rxq;
298 goto destroy_eth_rxq;
304 goto destroy_eth_rxq;
310 goto destroy_eth_rxq;
316 goto destroy_eth_rxq;
321 DOCA_LOG_ERR(
"Failed to retrieve DOCA ETH RXQ context as DOCA context, err: %s",
323 goto destroy_eth_rxq;
329 goto destroy_eth_rxq;
335 goto destroy_eth_rxq;
410 uint32_t max_supported_burst_size;
411 uint32_t max_supported_packet_size;
450 bool timestamp_enable,
451 uint16_t headroom_size,
452 uint16_t tailroom_size)
460 .inventory_num_elements = 0,
462 .ibdev_name = ib_dev_name};
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 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)
#define LOG_MAX_LRO_PKT_SIZE
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
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
@ DOCA_ETH_RXQ_DATA_PATH_TYPE_CPU
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.
#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_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
@ DOCA_EVENT_BATCH_EVENTS_NUMBER_64
@ DOCA_EVENT_BATCH_EVENTS_NUMBER_32
const struct ip_frag_config * cfg
struct program_core_objects core_objs
uint16_t * rxq_flow_queue_ids
struct doca_flow_pipe * root_pipe
struct doca_flow_port * df_port
struct eth_rxq_flow_resources flow_resources
uint64_t total_received_packets
uint16_t rxq_flow_queue_id
struct eth_core_resources core_resources
struct doca_eth_rxq * eth_rxq
struct doca_mmap * src_mmap
Convenience type for representing opaque data.