29 #include <arpa/inet.h>
38 #include "flow_common.h"
43 #define WAITING_TIME 10
45 #define NB_ENCAP_ACTIONS (2)
46 #define NB_DECAP_ACTIONS (1)
48 #define NB_HAIRPIN_PIPE_ENTRIES (1)
49 #define NB_ENCAP_PIPE_ENTRIES (2)
50 #define NB_DECAP_PIPE_ENTRIES (2)
51 #define NB_INGRESS_PIPE_ENTRIES (NB_HAIRPIN_PIPE_ENTRIES + NB_DECAP_PIPE_ENTRIES)
52 #define NB_EGRESS_PIPE_ENTRIES (NB_ENCAP_PIPE_ENTRIES)
53 #define TOTAL_ENTRIES (NB_INGRESS_PIPE_ENTRIES + NB_EGRESS_PIPE_ENTRIES)
55 #define NEXT_HEADER_IPV4 (4)
56 #define NEXT_HEADER_IPV6 (41)
72 struct doca_flow_pipe **pipe)
74 struct doca_flow_pipe_entry *
entry;
78 struct doca_flow_pipe_cfg *pipe_cfg;
82 memset(&match, 0,
sizeof(match));
84 memset(&
fwd, 0,
sizeof(
fwd));
154 struct doca_flow_pipe_entry *encap_entries[])
161 uint8_t smac[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
162 uint8_t dmac[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
166 memset(&match, 0,
sizeof(match));
214 struct doca_flow_pipe_cfg *pipe_cfg;
217 memset(&match, 0,
sizeof(match));
219 memset(&mon, 0,
sizeof(mon));
220 memset(&actions_ipv4, 0,
sizeof(actions_ipv4));
221 memset(&actions_ipv6, 0,
sizeof(actions_ipv6));
222 memset(&
fwd, 0,
sizeof(
fwd));
244 actions_ipv6 = actions_ipv4;
247 actions_arr[0] = &actions_ipv4;
248 actions_arr[1] = &actions_ipv6;
316 struct doca_flow_pipe_entry *decap_entries[])
322 uint8_t smac[] = {0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc};
323 uint8_t dmac[] = {0xdd, 0xee, 0xff, 0x11, 0x22, 0x33};
325 memset(&match, 0,
sizeof(match));
363 struct doca_flow_pipe *next_pipe,
364 struct doca_flow_pipe **decap_pipe)
370 struct doca_flow_pipe_cfg *pipe_cfg;
373 memset(&match, 0,
sizeof(match));
374 memset(&mon, 0,
sizeof(mon));
376 memset(&
fwd, 0,
sizeof(
fwd));
456 struct doca_flow_port *egress_port,
457 uint32_t egress_port_id,
459 struct doca_flow_pipe_entry *encap_entries[])
461 struct doca_flow_pipe *hairpin_pipe, *encap_pipe;
510 struct doca_flow_pipe_entry *decap_entries[])
512 struct doca_flow_pipe *hairpin_pipe, *decap_pipe;
557 uint32_t raw_port_id = 0;
558 uint32_t tunnel_port_id = raw_port_id ^ 1;
563 decap_ipv6_query_stats;
572 memset(dev_arr, 0,
sizeof(
struct doca_dev *) *
nb_ports);
581 ports[tunnel_port_id],
622 DOCA_LOG_INFO(
"Encap: counted %ld IPv4 packets, %ld IPv6 packets",
623 encap_ipv4_query_stats.
counter.total_pkts,
624 encap_ipv6_query_stats.
counter.total_pkts);
625 DOCA_LOG_INFO(
"Decap: counted %ld IPv4 packets, %ld IPv6 packets",
626 decap_ipv4_query_stats.
counter.total_pkts,
627 decap_ipv6_query_stats.
counter.total_pkts);
struct doca_flow_port * init_doca_flow(uint16_t port_id, uint8_t rxq_num)
#define SET_MAC_ADDR(addr, a, b, c, d, e, f)
static doca_error_t destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
static doca_error_t add_encap_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status, struct doca_flow_pipe_entry *encap_entries[])
static doca_error_t prepare_encap_pipeline(struct doca_flow_port *ingress_port, struct doca_flow_port *egress_port, uint32_t egress_port_id, struct entries_status *status, struct doca_flow_pipe_entry *encap_entries[])
doca_error_t flow_ip_in_ip(int nb_queues)
#define NB_DECAP_PIPE_ENTRIES
#define NB_EGRESS_PIPE_ENTRIES
DOCA_LOG_REGISTER(FLOW_IP_IN_IP)
static doca_error_t create_hairpin_pipe(struct doca_flow_port *port, int dest_port_id, bool is_root, struct entries_status *status, struct doca_flow_pipe **pipe)
#define NB_ENCAP_PIPE_ENTRIES
#define NB_INGRESS_PIPE_ENTRIES
static doca_error_t create_decap_pipe(struct doca_flow_port *port, struct doca_flow_pipe *next_pipe, struct doca_flow_pipe **decap_pipe)
#define NB_HAIRPIN_PIPE_ENTRIES
static doca_error_t create_encap_pipe(struct doca_flow_port *port, uint32_t port_id, struct doca_flow_pipe **encap_pipe)
static doca_error_t add_decap_pipe_entries(struct doca_flow_pipe *pipe, struct entries_status *status, struct doca_flow_pipe_entry *decap_entries[])
static doca_error_t prepare_decap_pipeline(struct doca_flow_port *ingress_port, int egress_port_id, struct entries_status *status, struct doca_flow_pipe_entry *decap_entries[])
static struct doca_flow_fwd fwd_miss
static struct doca_flow_actions actions
static struct doca_flow_fwd fwd
static struct doca_flow_match match_mask
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.
#define DOCA_FLOW_ETHER_TYPE_IPV6
#define DOCA_FLOW_ETHER_TYPE_IPV4
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_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_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_STABLE doca_error_t doca_flow_pipe_cfg_set_domain(struct doca_flow_pipe_cfg *cfg, enum doca_flow_pipe_domain domain)
Set pipe's domain.
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
@ DOCA_FLOW_PIPE_DOMAIN_EGRESS
@ DOCA_FLOW_PIPE_DOMAIN_DEFAULT
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO 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 SET_IPV6_ADDR(addr, a, b, c, d)
#define ARRAY_INIT(array, val)
doca flow actions information
struct doca_flow_resource_encap_cfg encap_cfg
enum doca_flow_resource_type encap_type
enum doca_flow_resource_type decap_type
struct doca_flow_resource_decap_cfg decap_cfg
struct doca_flow_header_format outer
struct doca_flow_pipe * next_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
struct doca_flow_header_eth eth
struct doca_flow_encap_action encap
struct doca_flow_resource_query::@115::@117 counter
enum doca_flow_tun_type 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]