30 #include <rte_byteorder.h>
35 #include "flow_common.h"
41 #define GET_PERCENTAGE(part, total) (((double)part / (double)total) * 100)
44 #define WAITING_TIME 15
46 #define MAX_ECMP_PORTS (8)
47 #define MAX_TOTAL_PORTS ((MAX_ECMP_PORTS) + 1)
62 uint32_t shared_counter_id,
63 struct doca_flow_pipe *next_pipe,
66 struct doca_flow_pipe *pipe;
67 struct doca_flow_pipe_entry *
entry;
71 struct doca_flow_pipe_cfg *pipe_cfg;
74 memset(&match, 0,
sizeof(match));
76 memset(&
fwd, 0,
sizeof(
fwd));
150 return (x != 0) && ((x & (x - 1)) == 0);
168 struct doca_flow_pipe_cfg *pipe_cfg;
173 memset(&
fwd, 0,
sizeof(
fwd));
176 DOCA_LOG_WARN(
"Hash pipe nb_flows %u is not power of 2, part of traffic will be lost", nb_flows);
233 uint8_t nb_ecmp_ports,
234 struct doca_flow_pipe_entry **
entries,
240 uint16_t target_port;
243 for (i = 0; i < nb_ecmp_ports; i++) {
248 if (i == nb_ecmp_ports - 1)
273 uint32_t total_packets;
285 total_packets = root_query_stats.
counter.total_pkts;
286 if (total_packets == 0) {
291 DOCA_LOG_INFO(
"Show ECMP results, %u packets are distributed into %u ports:", total_packets, nb_ecmp_ports);
293 for (i = 0; i < nb_ecmp_ports; i++) {
300 nb_packets = hash_query_stats.
counter.total_pkts;
303 DOCA_LOG_INFO(
"Port %u received %u packets which is %g%% of the traffic (%u/%u)",
327 uint32_t shared_counter_id = 0;
328 struct doca_flow_port *switch_port;
330 struct doca_flow_pipe *hash_pipe;
333 uint8_t nb_ecmp_ports =
nb_ports - 1;
343 DOCA_LOG_ERR(
"Number provided ports %d is too big (maximal supported is %d)",
355 memset(dev_arr, 0,
sizeof(
struct doca_dev *) *
nb_ports);
356 dev_arr[0] =
ctx->doca_dev[0];
391 memset(&status, 0,
sizeof(status));
struct doca_flow_port * init_doca_flow(uint16_t port_id, uint8_t rxq_num)
DOCA_LOG_REGISTER(FLOW_ECMP)
#define GET_PERCENTAGE(part, total)
static doca_error_t create_hash_pipe(struct doca_flow_port *port, uint8_t nb_flows, struct doca_flow_pipe **pipe)
static doca_error_t create_root_pipe(struct doca_flow_port *port, uint32_t shared_counter_id, struct doca_flow_pipe *next_pipe, struct entries_status *status)
doca_error_t flow_ecmp(int nb_queues, int nb_ports, struct flow_switch_ctx *ctx)
static bool is_power_of_two(uint8_t x)
static doca_error_t add_hash_pipe_entries(struct doca_flow_pipe *pipe, uint8_t nb_ecmp_ports, struct doca_flow_pipe_entry **entries, struct entries_status *status)
static doca_error_t show_ecmp_results(uint32_t counter_id, struct doca_flow_pipe_entry **entries, uint8_t nb_ecmp_ports)
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_monitor monitor
static struct doca_flow_fwd fwd
static struct doca_flow_match match_mask
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
#define DEFAULT_TIMEOUT_US
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_ERROR_INVALID_VALUE
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_STABLE doca_error_t doca_flow_entries_process(struct doca_flow_port *port, uint16_t pipe_queue, uint64_t timeout, uint32_t max_processed_entries)
Process entries in queue.
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_STABLE doca_error_t doca_flow_shared_resources_bind(enum doca_flow_shared_resource_type type, uint32_t *res_array, uint32_t res_array_len, void *bindable_obj)
Binds a bulk of shared resources to a bindable object.
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_flow_flags_type
doca flow flags type
DOCA_EXPERIMENTAL doca_error_t doca_flow_shared_resource_set_cfg(enum doca_flow_shared_resource_type type, uint32_t id, struct doca_flow_shared_resource_cfg *cfg)
Configure a single shared resource.
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_EXPERIMENTAL doca_error_t doca_flow_pipe_hash_add_entry(uint16_t pipe_queue, struct doca_flow_pipe *pipe, uint32_t entry_index, const struct doca_flow_actions *actions, const struct doca_flow_monitor *monitor, const struct doca_flow_fwd *fwd, const enum doca_flow_flags_type flags, void *usr_ctx, struct doca_flow_pipe_entry **entry)
Add one new entry to an hash pipe.
DOCA_EXPERIMENTAL doca_error_t doca_flow_shared_resources_query(enum doca_flow_shared_resource_type type, uint32_t *res_array, struct doca_flow_resource_query *query_results_array, uint32_t array_len)
Extract information about shared counter.
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_STABLE struct doca_flow_port * doca_flow_port_switch_get(const struct doca_flow_port *port)
Get doca flow switch port.
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_SHARED_RESOURCE_COUNTER
@ DOCA_FLOW_WAIT_FOR_BATCH
@ DOCA_FLOW_RESOURCE_TYPE_SHARED
@ DOCA_FLOW_RESOURCE_TYPE_NON_SHARED
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_WARN(format,...)
Generates a WARNING 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.
const struct ip_frag_config * cfg
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)
struct doca_flow_pipe * next_pipe
struct doca_flow_pipe * pipe
enum doca_flow_fwd_type type
doca flow matcher information
struct doca_flow_parser_meta parser_meta
struct doca_flow_header_format outer
doca monitor action configuration
struct doca_flow_monitor::@103::@107 shared_counter
enum doca_flow_resource_type counter_type
struct doca_flow_resource_query::@115::@117 counter
doca flow shared resource configuration
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]
struct upf_accel_ctx * ctx