28 #include <rte_ethdev.h>
35 #include "flow_common.h"
37 #define PACKET_BURST 128
51 struct doca_flow_pipe **pipe)
54 struct doca_flow_pipe_cfg *
cfg;
59 memset(&match, 0,
sizeof(match));
60 memset(&
fwd, 0,
sizeof(
fwd));
122 struct doca_flow_pipe *fwd_pipe,
123 struct doca_flow_pipe *fwd_miss_pipe,
124 struct doca_flow_pipe **
pipe)
128 struct doca_flow_pipe_cfg *
cfg;
133 memset(&match, 0,
sizeof(match));
134 memset(&mask, 0,
sizeof(mask));
135 memset(&
fwd, 0,
sizeof(
fwd));
179 struct doca_flow_pipe **
pipe)
185 struct doca_flow_pipe_cfg *pipe_cfg;
189 memset(&match, 0,
sizeof(match));
191 memset(&
fwd, 0,
sizeof(
fwd));
257 struct doca_flow_pipe *fwd_pipe,
259 struct doca_flow_pipe **pipe)
265 struct doca_flow_pipe_cfg *pipe_cfg;
268 memset(&match, 0,
sizeof(match));
270 memset(&
fwd, 0,
sizeof(
fwd));
340 const struct rte_udp_hdr *
udp_hdr;
342 ipv4_hdr = rte_pktmbuf_mtod_offset(packet,
struct rte_ipv4_hdr *,
sizeof(
struct rte_ether_hdr));
374 struct doca_flow_pipe *ct_pipe,
380 struct doca_flow_pipe_entry *
entry;
383 int i,
entries, nb_packets = 0;
384 bool conn_found =
false;
386 memset(&match_o, 0,
sizeof(match_o));
387 memset(&match_r, 0,
sizeof(match_r));
389 DOCA_LOG_INFO(
"Listening on port %u, please send UDP packet with DIP 1.1.1.1", port_id);
391 nb_packets = rte_eth_rx_burst(port_id, 0, packets,
PACKET_BURST);
392 }
while (nb_packets == 0);
397 DOCA_LOG_INFO(
"Sample received %d packets on port %d", nb_packets, port_id);
407 packets[i]->hash.rss,
409 packets[i]->hash.rss,
450 DOCA_LOG_ERR(
"Flow CT entries process returned with a failure");
473 struct doca_flow_pipe *rss_pipes[
nb_ports];
474 struct doca_flow_pipe *hairpin_pipes[
nb_ports];
475 struct doca_flow_pipe *count_pipes[
nb_ports];
476 struct doca_flow_pipe *ct_pipes[
nb_ports];
477 struct doca_flow_pipe *udp_pipes[
nb_ports];
480 struct doca_flow_meta o_zone_mask, o_modify_mask, r_zone_mask, r_modify_mask;
482 uint32_t ct_flags, nb_arm_queues = 1, nb_ctrl_queues = 1, nb_user_actions = 0, nb_ipv4_sessions = 1024,
483 nb_ipv6_sessions = 0;
484 uint16_t ct_queue = nb_queues;
488 memset(&resource, 0,
sizeof(resource));
489 memset(rss_pipes, 0,
sizeof(
struct doca_flow_pipe *) *
nb_ports);
490 memset(hairpin_pipes, 0,
sizeof(
struct doca_flow_pipe *) *
nb_ports);
491 memset(count_pipes, 0,
sizeof(
struct doca_flow_pipe *) *
nb_ports);
492 memset(ct_pipes, 0,
sizeof(
struct doca_flow_pipe *) *
nb_ports);
493 memset(udp_pipes, 0,
sizeof(
struct doca_flow_pipe *) *
nb_ports);
504 memset(&o_zone_mask, 0,
sizeof(o_zone_mask));
505 memset(&o_modify_mask, 0,
sizeof(o_modify_mask));
506 memset(&r_zone_mask, 0,
sizeof(r_zone_mask));
507 memset(&r_modify_mask, 0,
sizeof(r_modify_mask));
540 memset(&ctrl_status, 0,
sizeof(ctrl_status));
575 DOCA_LOG_INFO(
"Please send same UDP packets to see the CT entries being created\n");
577 memset(&ct_status, 0,
sizeof(ct_status));
587 if (udp_pipes[i] !=
NULL)
589 if (ct_pipes[i] !=
NULL)
591 if (hairpin_pipes[i] !=
NULL)
593 if (count_pipes[i] !=
NULL)
595 if (rss_pipes[i] !=
NULL)
struct doca_flow_port * init_doca_flow(uint16_t port_id, uint8_t rxq_num)
static void cleanup(struct cache_invalidate_sample_state *state)
DOCA_LOG_REGISTER(FLOW_CT_2_PORTS)
static doca_error_t create_count_pipe(struct doca_flow_port *port, struct doca_flow_pipe *fwd_pipe, struct entries_status *status, struct doca_flow_pipe **pipe)
static doca_error_t process_packets(struct doca_flow_port *port, uint16_t port_id, uint16_t ct_queue, struct doca_flow_pipe *ct_pipe, struct entries_status *ct_status)
static doca_error_t create_ct_pipe(struct doca_flow_port *port, struct doca_flow_pipe *fwd_pipe, struct doca_flow_pipe *fwd_miss_pipe, struct doca_flow_pipe **pipe)
doca_error_t flow_ct_2_ports(uint16_t nb_queues, struct doca_dev *dev_arr[], int nb_ports)
static doca_error_t create_rss_pipe(struct doca_flow_port *port, struct entries_status *status, struct doca_flow_pipe **pipe)
static void parse_packet(struct rte_mbuf *packet, struct doca_flow_ct_match *match_o, struct doca_flow_ct_match *match_r)
static doca_error_t create_hairpin_pipe(struct doca_flow_port *port, struct entries_status *status, struct doca_flow_pipe **pipe)
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)
void cleanup_procedure(struct doca_flow_pipe *ct_pipe, int nb_ports, struct doca_flow_port *ports[])
#define DUP_FILTER_CONN_NUM
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_actions actions
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_entries_process(struct doca_flow_port *port, uint16_t pipe_queue, uint32_t min_room, uint32_t max_processed_entries, uint32_t *queue_room)
Process CT entries in queue.
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_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
@ DOCA_FLOW_CT_ENTRY_FLAGS_DUP_FILTER_REPLY
@ DOCA_FLOW_CT_ENTRY_FLAGS_DUP_FILTER_ORIGIN
@ DOCA_FLOW_CT_FLAG_NO_COUNTER
@ DOCA_FLOW_CT_FLAG_NO_AGING
#define DOCA_FLOW_PROTO_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_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 void doca_flow_pipe_destroy(struct doca_flow_pipe *pipe)
Destroy one 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_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.
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)
#define SHARED_RESOURCE_NUM_VALUES
#define ACTIONS_MEM_SIZE(nr_queues, entries)
#define ARRAY_INIT(array, val)
doca flow actions information
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
enum doca_flow_resource_type rss_type
struct doca_flow_resource_rss_cfg rss
doca flow matcher information
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]