30 #include <rte_byteorder.h>
31 #include <rte_random.h>
37 #include "flow_common.h"
66 if (entry_status ==
NULL)
74 DOCA_LOG_ERR(
"Failed to remove entry number %d from port %d: %s",
79 DOCA_LOG_INFO(
"Entry number %d from port %d aged out and removed",
99 struct doca_flow_pipe **pipe)
106 struct doca_flow_pipe_cfg *pipe_cfg;
109 memset(&match, 0,
sizeof(match));
112 memset(&
fwd, 0,
sizeof(
fwd));
114 memset(&pipe_cfg, 0,
sizeof(pipe_cfg));
195 struct doca_flow_port *port,
197 int num_of_aging_entries,
211 for (i = 0; i < num_of_aging_entries; i++) {
214 memset(&match, 0,
sizeof(match));
227 user_data[i].
port_id = port_id;
228 user_data[i].
status = status;
230 if (i == num_of_aging_entries - 1)
251 DOCA_LOG_ERR(
"Failed to process entries, status is not success");
295 uint64_t quota_time = 20;
296 int num_of_aged_entries = 0;
300 while (num_of_aged_entries != -1) {
301 if (num_of_aged_entries > 0) {
302 *total_counter += num_of_aged_entries;
303 DOCA_LOG_INFO(
"Num of aged entries: %d, total: %d", num_of_aged_entries, *total_counter);
326 struct doca_flow_pipe *pipe;
329 int num_of_aging_entries = 10;
330 int aged_entry_counter = 0;
348 memset(dev_arr, 0,
sizeof(
struct doca_dev *) *
nb_ports);
365 goto entries_cleanup;
373 goto entries_cleanup;
380 num_of_aging_entries,
384 goto entries_cleanup;
389 DOCA_LOG_INFO(
"Wait %d seconds for first batch of packets to arrive", 5);
392 DOCA_LOG_INFO(
"Show miss counter results after first iteration of sending packets");
397 goto entries_cleanup;
401 DOCA_LOG_INFO(
"Wait few seconds for all entries to age out");
404 while (aged_entry_counter < num_of_aging_entries *
nb_ports) {
410 goto entries_cleanup;
417 while (
status[
port_id].nb_processed < num_of_aging_entries) {
424 goto entries_cleanup;
427 DOCA_LOG_ERR(
"Failed to process entries, status is not success");
428 goto entries_cleanup;
434 DOCA_LOG_INFO(
"Wait %d seconds for second batch of packets to arrive", 5);
437 DOCA_LOG_INFO(
"Show miss counter results after second batch of packets");
442 goto entries_cleanup;
static doca_error_t handle_aged_flow(struct doca_flow_port *port, int *total_counter)
static doca_error_t add_aging_pipe_entries(struct doca_flow_pipe *pipe, struct aging_user_data *user_data, struct doca_flow_port *port, int port_id, int num_of_aging_entries, struct entries_status *status)
static void check_for_valid_entry_aging(struct doca_flow_pipe_entry *entry, uint16_t pipe_queue, enum doca_flow_entry_status status, enum doca_flow_entry_op op, void *user_ctx)
static doca_error_t miss_counter_query(struct doca_flow_pipe *pipe, int port_id)
static doca_error_t create_aging_pipe(struct doca_flow_port *port, int port_id, uint32_t n_entries, struct doca_flow_pipe **pipe)
DOCA_LOG_REGISTER(FLOW_AGING)
doca_error_t flow_aging(int nb_queues)
static doca_error_t destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
static struct doca_flow_fwd fwd_miss
static struct doca_flow_actions actions
#define BE_IPV4_ADDR(a, b, c, d)
static struct doca_flow_monitor monitor
static struct doca_flow_fwd fwd
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
#define DEFAULT_TIMEOUT_US
enum doca_error doca_error_t
DOCA API return codes.
doca_error
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_FLOW_L4_TYPE_EXT_TCP
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_flow_entry_op
doca flow entry operation
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_miss_counter(struct doca_flow_pipe_cfg *cfg, bool miss_counter)
Set to enable pipe's miss counter.
doca_flow_flags_type
doca flow flags type
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_STABLE int doca_flow_aging_handle(struct doca_flow_port *port, uint16_t queue, uint64_t quota, uint64_t max_entries)
Handle aging of entries.
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 doca_error_t doca_flow_pipe_remove_entry(uint16_t pipe_queue, uint32_t flags, struct doca_flow_pipe_entry *entry)
Free one pipe entry.
doca_flow_entry_status
doca flow entry status
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_pipe_miss(struct doca_flow_pipe *pipe, struct doca_flow_resource_query *query_stats)
Extract information about pipe miss entry.
@ DOCA_FLOW_ENTRY_OP_AGED
@ DOCA_FLOW_WAIT_FOR_BATCH
@ DOCA_FLOW_ENTRY_STATUS_SUCCESS
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
uint16_t doca_be16_t
Declare DOCA endianity types.
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)
doca_error_t init_doca_flow_cb(int nb_queues, const char *mode, struct flow_resources *resource, uint32_t nr_shared_resources[], doca_flow_entry_process_cb cb, doca_flow_pipe_process_cb pipe_process_cb, struct doca_flow_definitions *defs)
#define SHARED_RESOURCE_NUM_VALUES
#define ACTIONS_MEM_SIZE(nr_queues, entries)
#define ARRAY_INIT(array, val)
struct entries_status * status
doca flow actions information
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_resource_query::@115::@117 counter
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]