33 #include "flow_common.h"
37 #define NB_ACTION_DESC (1)
38 #define TEST_LPM_EM_TAG 1
39 #define META_U32_BIT_OFFSET(idx) (offsetof(struct doca_flow_meta, u32[(idx)]) << 3)
51 struct doca_flow_pipe *main_pipe,
52 struct doca_flow_pipe **pipe)
58 struct doca_flow_pipe_cfg *pipe_cfg;
61 memset(&match, 0,
sizeof(match));
63 memset(&
fwd, 0,
sizeof(
fwd));
119 struct doca_flow_pipe_entry **
entry)
127 memset(&match, 0,
sizeof(match));
141 struct doca_flow_pipe *next_pipe,
142 struct doca_flow_pipe **pipe)
150 struct doca_flow_pipe_cfg *pipe_cfg;
156 memset(&match, 0,
sizeof(match));
157 memset(&counter, 0,
sizeof(counter));
159 memset(&
fwd, 0,
sizeof(
fwd));
161 memset(&descs, 0,
sizeof(descs));
166 descs_arr[0] = &descs;
177 desc_array[0].
field_op.src.field_string =
"outer.eth_vlan0.tci";
178 desc_array[0].
field_op.src.bit_offset = 0;
179 desc_array[0].
field_op.dst.field_string =
"meta.data";
230 struct doca_flow_pipe_entry **
entry)
234 memset(&match, 0,
sizeof(match));
254 struct doca_flow_pipe_cfg *pipe_cfg;
259 memset(&match, 0,
sizeof(match));
262 memset(&counter, 0,
sizeof(counter));
332 uint32_t exact_match_meta,
333 uint32_t exact_match_vni,
334 uint8_t *exact_match_inner_dmac,
337 struct doca_flow_pipe_entry **
entry)
345 match.
meta.
u32[1] = exact_match_meta;
380 struct doca_flow_pipe_entry **
entries)
383 uint8_t inner_dmac[6] = {0};
389 RTE_BE32(0x00000000),
400 memset(inner_dmac, 1,
sizeof(inner_dmac));
404 RTE_BE32(0xffffffff),
414 memset(inner_dmac, 2,
sizeof(inner_dmac));
418 RTE_BE32(0xffffffff),
429 memset(inner_dmac, 3,
sizeof(inner_dmac));
433 RTE_BE32(0xffffffff),
447 RTE_BE32(0xffff0000),
475 const int num_of_entries = 7;
476 const int classifier_entry_idx = 0;
477 const int main_entry_idx = 1;
478 const int lpm_entries_idx = 2;
484 struct doca_flow_pipe *classifier_pipe;
485 struct doca_flow_pipe *main_pipe;
486 struct doca_flow_pipe *lpm_pipe;
491 int port_id, lpm_entry_id;
499 memset(dev_arr, 0,
sizeof(
struct doca_dev *) *
nb_ports);
508 for (port_id = 0; port_id <
nb_ports; port_id++) {
509 memset(&status, 0,
sizeof(status));
575 DOCA_LOG_INFO(
"===================================================");
577 for (port_id = 0; port_id <
nb_ports; port_id++) {
581 DOCA_LOG_ERR(
"Port %d failed to query classifier pipe entry: %s",
591 DOCA_LOG_ERR(
"Port %d failed to query main pipe entry: %s",
600 for (lpm_entry_id = lpm_entries_idx; lpm_entry_id < num_of_entries; lpm_entry_id++) {
603 DOCA_LOG_ERR(
"Port %d failed to query LPM entry %d: %s",
610 DOCA_LOG_INFO(
"\tEntry %d received %lu packets", lpm_entry_id - 1,
stats.counter.total_pkts);
612 DOCA_LOG_INFO(
"===================================================");
struct doca_flow_port * init_doca_flow(uint16_t port_id, uint8_t rxq_num)
static struct eth_l2_fwd_stats stats
static doca_error_t destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
static struct doca_flow_pipe_entry * entries[NB_ENTRIES]
static doca_error_t add_lpm_one_entry(struct doca_flow_pipe *pipe, uint16_t port_id, doca_be32_t src_ip_addr, doca_be32_t src_ip_addr_mask, uint32_t exact_match_meta, uint32_t exact_match_vni, uint8_t *exact_match_inner_dmac, const enum doca_flow_flags_type flag, struct entries_status *status, struct doca_flow_pipe_entry **entry)
static doca_error_t add_lpm_pipe_entries(struct doca_flow_pipe *pipe, uint16_t port_id, struct entries_status *status, struct doca_flow_pipe_entry **entries)
doca_error_t flow_lpm_em(int nb_queues)
DOCA_LOG_REGISTER(FLOW_LPM_EM)
static doca_error_t add_main_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status, struct doca_flow_pipe_entry **entry)
static doca_error_t add_classifier_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status, struct doca_flow_pipe_entry **entry)
static doca_error_t create_main_pipe(struct doca_flow_port *port, struct doca_flow_pipe *next_pipe, struct doca_flow_pipe **pipe)
static doca_error_t create_classifier_pipe(struct doca_flow_port *port, struct doca_flow_pipe *main_pipe, struct doca_flow_pipe **pipe)
#define META_U32_BIT_OFFSET(idx)
static doca_error_t create_lpm_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
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_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.
#define DOCA_FLOW_VXLAN_DEFAULT_PORT
@ 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_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_lpm_add_entry(uint16_t pipe_queue, struct doca_flow_pipe *pipe, const struct doca_flow_match *match, const struct doca_flow_match *match_mask, const struct doca_flow_actions *actions, const struct doca_flow_monitor *monitor, const struct doca_flow_fwd *fwd, const enum doca_flow_flags_type flag, void *usr_ctx, struct doca_flow_pipe_entry **entry)
Add one new entry to a lpm 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_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_WAIT_FOR_BATCH
@ DOCA_FLOW_RESOURCE_TYPE_NON_SHARED
@ DOCA_FLOW_FWD_CHANGEABLE
@ DOCA_FLOW_L2_META_SINGLE_VLAN
#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 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)
enum doca_flow_action_type type
struct doca_flow_action_desc::@108::@110 field_op
struct doca_flow_action_desc * desc_array
doca flow actions information
struct doca_flow_pipe * next_pipe
struct doca_flow_pipe * pipe
enum doca_flow_fwd_type type
doca flow matcher information
struct doca_flow_header_format inner
struct doca_flow_parser_meta parser_meta
struct doca_flow_header_format outer
struct doca_flow_meta meta
doca monitor action configuration
enum doca_flow_resource_type counter_type
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]