29 #include <rte_ethdev.h>
36 #include "flow_common.h"
63 int num_of_aged_entries;
74 if (num_of_aged_entries == -1 && status->
nb_processed > 0) {
78 }
else if (num_of_aged_entries < -1) {
79 DOCA_LOG_ERR(
"Error in aging handle: %d", num_of_aged_entries);
81 }
else if (num_of_aged_entries > 0) {
82 *total_counter += num_of_aged_entries;
83 DOCA_LOG_INFO(
"Num of aged connections: %d, total: %d", num_of_aged_entries, *total_counter);
85 }
while (num_of_aged_entries > 0);
108 if (user_data ==
NULL)
140 struct doca_flow_pipe *fwd_pipe,
141 struct doca_flow_pipe **pipe)
145 struct doca_flow_pipe_cfg *
cfg;
150 memset(&match, 0,
sizeof(match));
151 memset(&mask, 0,
sizeof(mask));
152 memset(&
fwd, 0,
sizeof(
fwd));
198 struct doca_flow_pipe_cfg *pipe_cfg;
201 memset(&match, 0,
sizeof(match));
203 memset(&
fwd, 0,
sizeof(
fwd));
249 memset(&match, 0,
sizeof(match));
284 const int nb_aging_entries,
290 struct doca_flow_pipe_entry *
entry;
291 uint32_t aging_sec, flags;
297 for (i = 0; i < nb_aging_entries; i++) {
299 if (user_data[i] ==
NULL) {
304 aging_sec = (uint32_t)((rte_rand() % 10) + 3);
306 memset(&match_o, 0,
sizeof(match_o));
307 memset(&match_r, 0,
sizeof(match_r));
322 user_data[i]->entry_num = i;
323 user_data[i]->port_id = 0;
324 user_data[i]->status =
status;
327 if (i == nb_aging_entries - 1 || ((i + 1) %
N_BURST) == 0) {
379 const int nb_ports = 1, nb_aged_entries = 600;
383 struct doca_flow_pipe *count_pipe, *ct_pipe =
NULL, *udp_pipe;
385 struct doca_flow_meta o_zone_mask, o_modify_mask, r_zone_mask, r_modify_mask;
390 uint32_t ct_flags = 0, nb_arm_queues = 1, nb_ctrl_queues = 1, nb_user_actions = 0,
391 nb_ipv6_sessions = 0;
392 uint16_t ct_queue = nb_queues;
395 memset(&ct_status, 0,
sizeof(ct_status));
396 memset(&resource, 0,
sizeof(resource));
397 memset(user_data, 0,
sizeof(
struct aging_user_data *) * nb_aged_entries);
414 memset(&o_zone_mask, 0,
sizeof(o_zone_mask));
415 memset(&o_modify_mask, 0,
sizeof(o_modify_mask));
416 memset(&r_zone_mask, 0,
sizeof(r_zone_mask));
417 memset(&r_modify_mask, 0,
sizeof(r_modify_mask));
438 memset(dev_arr, 0,
sizeof(
struct doca_dev *) *
nb_ports);
463 goto entries_cleanup;
468 memset(&ct_status, 0,
sizeof(ct_status));
469 while (aged_entry_counter < nb_aged_entries) {
static void cleanup(struct cache_invalidate_sample_state *state)
DOCA_LOG_REGISTER(FLOW_CT_AGING)
static doca_error_t create_count_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
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 create_ct_pipe(struct doca_flow_port *port, struct doca_flow_pipe *fwd_pipe, struct doca_flow_pipe **pipe)
doca_error_t flow_ct_aging(uint16_t nb_queues, struct doca_dev *ct_dev)
static doca_error_t add_age_ct_entries(struct doca_flow_port *port, uint16_t ct_queue, const int nb_aging_entries, struct entries_status *status, struct aging_user_data *user_data[nb_aging_entries])
static doca_error_t handle_aged_flow(struct doca_flow_port *port, uint16_t ct_queue, struct entries_status *status, int *total_counter)
uint32_t flow_ct_hash_6tuple(const struct doca_flow_ct_match *match, doca_be32_t zone_field, bool is_ipv6)
doca_error_t init_doca_flow_ct(uint32_t flags, uint32_t nb_arm_queues, uint32_t nb_ctrl_queues, uint32_t nb_user_actions, doca_flow_ct_entry_finalize_cb entry_finalize_cb, uint32_t nb_ipv4_sessions, uint32_t nb_ipv6_sessions, uint32_t dup_filter_sz, bool o_match_inner, struct doca_flow_meta *o_zone_mask, struct doca_flow_meta *o_modify_mask, bool r_match_inner, struct doca_flow_meta *r_zone_mask, struct doca_flow_meta *r_modify_mask)
doca_error_t create_ct_root_pipe(struct doca_flow_port *port, bool is_ipv4, bool is_ipv6, enum doca_flow_l4_meta l4_type, struct doca_flow_pipe *fwd_pipe, struct entries_status *status, struct doca_flow_pipe **pipe)
doca_error_t flow_ct_queue_reserve(struct doca_flow_port *port, uint16_t ct_queue, struct entries_status *status, uint32_t room)
void cleanup_procedure(struct doca_flow_pipe *ct_pipe, int nb_ports, struct doca_flow_port *ports[])
static doca_error_t destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
static struct doca_flow_fwd fwd_miss
#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_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
DOCA_EXPERIMENTAL doca_error_t doca_flow_ct_add_entry(uint16_t queue, struct doca_flow_pipe *pipe, uint32_t flags, struct doca_flow_ct_match *match_origin, struct doca_flow_ct_match *match_reply, const struct doca_flow_ct_actions *actions_origin, const struct doca_flow_ct_actions *actions_reply, uint32_t fwd_handle_origin, uint32_t fwd_handle_reply, uint32_t timeout_s, void *usr_ctx, struct doca_flow_pipe_entry *entry)
Add new entry to doca flow CT pipe.
DOCA_EXPERIMENTAL void doca_flow_ct_destroy(void)
Destroy the doca flow ct.
DOCA_EXPERIMENTAL doca_error_t doca_flow_ct_rm_entry(uint16_t queue, struct doca_flow_pipe *pipe, uint32_t flags, struct doca_flow_pipe_entry *entry)
remove CT entry.
DOCA_EXPERIMENTAL doca_error_t doca_flow_ct_entry_prepare(uint16_t queue, struct doca_flow_pipe *pipe, uint32_t flags, struct doca_flow_ct_match *match_origin, uint32_t hash_origin, struct doca_flow_ct_match *match_reply, uint32_t hash_reply, struct doca_flow_pipe_entry **entry, bool *conn_found)
Lookup recent CT entry and create on miss.
@ DOCA_FLOW_CT_ENTRY_FLAGS_DIR_ORIGIN
@ DOCA_FLOW_CT_ENTRY_FLAGS_NO_WAIT
@ DOCA_FLOW_CT_ENTRY_FLAGS_DIR_REPLY
@ DOCA_FLOW_CT_ENTRY_FLAGS_ALLOC_ON_MISS
#define DOCA_FLOW_PROTO_UDP
@ DOCA_FLOW_L4_TYPE_EXT_UDP
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_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_flow_entry_status
doca flow entry status
DOCA_STABLE void doca_flow_destroy(void)
Destroy the doca flow.
@ DOCA_FLOW_ENTRY_OP_AGED
@ DOCA_FLOW_RESOURCE_TYPE_NON_SHARED
@ 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.
const struct ip_frag_config * cfg
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
struct doca_flow_header_l4_port l4_port
doca flow CT match pattern
struct doca_flow_ct_match4 ipv4
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
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]