29 #include <rte_ethdev.h>
34 #include "flow_common.h"
39 #define PACKET_BURST 256
42 #define GET_PERCENTAGE(part, total) (((double)part / (double)total) * 100)
45 #define WAITING_TIME 15
56 uint32_t nb_rss_queues,
57 struct doca_flow_pipe **pipe)
66 struct doca_flow_pipe_cfg *pipe_cfg;
71 memset(&match, 0,
sizeof(match));
72 memset(&desc, 0,
sizeof(desc));
73 memset(&counter, 0,
sizeof(counter));
74 memset(&
fwd, 0,
sizeof(
fwd));
79 DOCA_LOG_ERR(
"Failed to allocate RSS queues array memory");
113 desc.
field_op.src.field_string =
"tunnel.esp.spi";
114 desc.
field_op.dst.field_string =
"meta.data";
130 for (i = 0; i < nb_rss_queues; ++i)
158 struct doca_flow_port *port,
160 struct doca_flow_pipe_entry **
entry)
165 memset(&match, 0,
sizeof(match));
166 memset(status, 0,
sizeof(*status));
195 double actuall_percentage;
196 uint32_t total_packets;
198 uint16_t queue_index;
208 total_packets =
stats.counter.total_pkts;
209 if (total_packets == 0) {
210 DOCA_LOG_DBG(
"Port %d doesn't receive any packet", port_id);
214 DOCA_LOG_INFO(
"Port %d RSS distribution information:", port_id);
216 for (i = 0; i < nb_queues; i++) {
218 nb_packets = rte_eth_rx_burst(port_id, queue_index, packets,
PACKET_BURST);
221 DOCA_LOG_INFO(
"Queue %u received %u packets which is %g%% of the traffic (%u/%u)",
228 for (j = 0; j < nb_packets; j++) {
229 uint32_t metadata = 0;
231 if (rte_flow_dynf_metadata_avail())
232 metadata = *RTE_FLOW_DYNF_METADATA(packets[j]);
234 DOCA_LOG_DBG(
"Queue %u packet %d ESP SPI is 0x%08x", queue_index, j, metadata);
257 struct doca_flow_pipe *pipe;
268 memset(dev_arr, 0,
sizeof(
struct doca_dev *) *
nb_ports);
277 for (port_id = 0; port_id <
nb_ports; port_id++) {
298 for (port_id = 0; port_id <
nb_ports; port_id++) {
struct doca_flow_port * init_doca_flow(uint16_t port_id, uint8_t rxq_num)
static struct eth_l2_fwd_stats stats
static doca_error_t destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
static struct doca_flow_pipe_entry * entries[NB_ENTRIES]
static struct doca_flow_fwd fwd_miss
static uint16_t * rss_queues
static struct doca_flow_fwd fwd
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
DOCA_STABLE doca_error_t doca_flow_pipe_cfg_destroy(struct doca_flow_pipe_cfg *cfg)
Destroy DOCA Flow pipe configuration struct.
DOCA_STABLE doca_error_t doca_flow_pipe_cfg_create(struct doca_flow_pipe_cfg **cfg, struct doca_flow_port *port)
Create DOCA Flow pipe configuration struct.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_cfg_set_match(struct doca_flow_pipe_cfg *cfg, const struct doca_flow_match *match, const struct doca_flow_match *match_mask)
Set pipe's match and match mask.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_create(const struct doca_flow_pipe_cfg *cfg, const struct doca_flow_fwd *fwd, const struct doca_flow_fwd *fwd_miss, struct doca_flow_pipe **pipe)
Create one new pipe.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_cfg_set_actions(struct doca_flow_pipe_cfg *cfg, struct doca_flow_actions *const *actions, struct doca_flow_actions *const *actions_masks, struct doca_flow_action_descs *const *action_descs, size_t nr_actions)
Set pipe's actions, actions mask and actions descriptor.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_cfg_set_monitor(struct doca_flow_pipe_cfg *cfg, const struct doca_flow_monitor *monitor)
Set pipe's monitor.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_add_entry(uint16_t pipe_queue, struct doca_flow_pipe *pipe, const struct doca_flow_match *match, const struct doca_flow_actions *actions, const struct doca_flow_monitor *monitor, const struct doca_flow_fwd *fwd, uint32_t flags, void *usr_ctx, struct doca_flow_pipe_entry **entry)
Add one new entry to a pipe.
DOCA_STABLE void doca_flow_destroy(void)
Destroy the doca flow.
DOCA_STABLE doca_error_t doca_flow_pipe_cfg_set_nr_entries(struct doca_flow_pipe_cfg *cfg, uint32_t nr_entries)
Set pipe's maximum number of flow rules.
DOCA_EXPERIMENTAL doca_error_t doca_flow_resource_query_entry(struct doca_flow_pipe_entry *entry, struct doca_flow_resource_query *query_stats)
Extract information about specific entry.
@ DOCA_FLOW_RESOURCE_TYPE_NON_SHARED
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
#define DOCA_LOG_DBG(format,...)
Generates a DEBUG application log message.
doca_error_t flow_process_entries(struct doca_flow_port *port, struct entries_status *status, uint32_t nr_entries)
doca_error_t stop_doca_flow_ports(int nb_ports, struct doca_flow_port *ports[])
doca_error_t init_doca_flow_ports(int nb_ports, struct doca_flow_port *ports[], bool is_hairpin, struct doca_dev *dev_arr[], uint32_t actions_mem_size[])
doca_error_t set_flow_pipe_cfg(struct doca_flow_pipe_cfg *cfg, const char *name, enum doca_flow_pipe_type type, bool is_root)
#define SHARED_RESOURCE_NUM_VALUES
#define ACTIONS_MEM_SIZE(nr_queues, entries)
#define ARRAY_INIT(array, val)
enum doca_flow_action_type type
struct doca_flow_action_desc::@108::@110 field_op
enum doca_flow_fwd_type type
enum doca_flow_resource_type rss_type
struct doca_flow_resource_rss_cfg rss
doca flow matcher information
struct doca_flow_parser_meta parser_meta
doca monitor action configuration
enum doca_flow_resource_type counter_type
user context struct that will be used in entries process callback
static uint32_t actions_mem_size[FLOW_SWITCH_PORTS_MAX]
static struct doca_flow_port * ports[FLOW_SWITCH_PORTS_MAX]