30 #include <rte_byteorder.h>
35 #include "flow_common.h"
40 #define WAITING_TIME 5
66 struct doca_flow_pipe_cfg **pipe_cfg)
68 struct doca_flow_pipe_cfg *
cfg;
157 struct doca_flow_pipe **pipe)
159 struct doca_flow_pipe_cfg *
cfg;
164 DOCA_LOG_ERR(
"Failed to create basic pipe, configuration failed");
170 DOCA_LOG_ERR(
"Failed to create basic pipe, pipe creation failed");
177 DOCA_LOG_ERR(
"Failed to create basic pipe, configuration destruction failed");
182 DOCA_LOG_DBG(
"Basic pipe %s is created successfully", name);
198 struct doca_flow_pipe **pipe_ptr)
207 struct doca_flow_pipe *pipe;
208 struct doca_flow_pipe_entry *
entry;
212 ip4_desc.
field_op.src.field_string =
"outer.ipv4.version_ihl";
213 ip4_desc.
field_op.dst.field_string =
"outer.ipv4.dscp_ecn";
217 ip6_desc.
field_op.src.field_string =
"outer.ipv6.payload_len";
218 ip6_desc.
field_op.dst.field_string =
"outer.ipv6.traffic_class";
221 result =
create_basic_pipe(port,
"MODIFY_PIPE", &match,
NULL, descs_arr,
fwd,
NULL, 2, 2,
false,
false, &pipe);
223 DOCA_LOG_ERR(
"Failed to create modify pipe, pipe creation failed");
231 DOCA_LOG_ERR(
"Failed to create modify pipe, IPv4 entry adding failed");
240 DOCA_LOG_ERR(
"Failed to create modify pipe, IPv6 entry adding failed");
261 struct doca_flow_pipe **pipe_ptr)
266 struct doca_flow_pipe *pipe;
267 struct doca_flow_pipe_entry *
entry;
275 result =
create_basic_pipe(port,
"PUSH_PIPE", &match, actions_arr,
NULL,
fwd,
NULL, 1, 1,
false,
false, &pipe);
277 DOCA_LOG_ERR(
"Failed to create push pipe, pipe creation failed");
283 DOCA_LOG_ERR(
"Failed to create push pipe, entry adding failed");
304 struct doca_flow_pipe *modify_pipe,
306 struct doca_flow_pipe **pipe_ptr)
310 struct doca_flow_pipe *pipe;
311 struct doca_flow_pipe_entry *
entry;
318 result =
create_basic_pipe(port,
"IPV4_PIPE", &match,
NULL,
NULL,
fwd, &
fwd_miss, 0, 1,
false,
false, &pipe);
320 DOCA_LOG_ERR(
"Failed to create IPv4 pipe, pipe creation failed");
326 DOCA_LOG_ERR(
"Failed to create IPv4 pipe, entry adding failed");
346 struct doca_flow_pipe *ipv4_pipe,
347 struct doca_flow_pipe *modify_pipe,
349 struct doca_flow_pipe **pipe_ptr)
354 struct doca_flow_pipe *pipe;
355 struct doca_flow_pipe_entry *
entry;
371 DOCA_LOG_ERR(
"Failed to create ip selector pipe, pipe creation failed");
377 DOCA_LOG_ERR(
"Failed to create ip selector pipe, entry adding failed");
396 struct doca_flow_pipe *next_pipe,
398 struct doca_flow_pipe **pipe_ptr)
403 struct doca_flow_pipe *pipe;
404 struct doca_flow_pipe_entry *
entry;
407 result =
create_basic_pipe(port,
"ROOT_PIPE", &match,
NULL,
NULL, &
fwd, &
fwd_miss, 0, 2,
true,
true, &pipe);
409 DOCA_LOG_ERR(
"Failed to create root pipe, pipe creation failed");
416 DOCA_LOG_ERR(
"Failed to create root pipe, IPv4 entry adding failed");
424 DOCA_LOG_ERR(
"Failed to create root pipe, IPv6 entry adding failed");
443 struct doca_flow_pipe *ip_selector_pipe,
444 bool miss_is_updated,
456 DOCA_LOG_INFO(
"Port %d root pipe miss %ld packets %s updating",
458 query_stats.
counter.total_pkts,
459 miss_is_updated ?
"after" :
"before");
463 DOCA_LOG_ERR(
"Port %u failed to query IP selector pipe miss: %s",
469 DOCA_LOG_INFO(
"Port %d IP selector pipe miss %ld packets %s updating",
471 query_stats.
counter.total_pkts,
472 miss_is_updated ?
"after" :
"before");
517 uint32_t num_of_entries = 6;
527 memset(dev_arr, 0,
sizeof(
struct doca_dev *) *
nb_ports);
536 for (port_id = 0; port_id <
nb_ports; port_id++) {
537 memset(&status, 0,
sizeof(status));
538 pipes = pipes_array[port_id];
539 port =
ports[port_id];
540 fwd_port.
port_id = port_id ^ 1;
542 DOCA_LOG_DBG(
"Port %u starts preparing the first pipeline", port_id);
562 DOCA_LOG_ERR(
"Port %u failed to create IP selector pipe: %s",
580 DOCA_LOG_ERR(
"Port %u failed to process %u entries: %s",
594 DOCA_LOG_DBG(
"Show miss counter results after first batch of packets");
596 for (port_id = 0; port_id <
nb_ports; port_id++) {
597 pipes = pipes_array[port_id];
601 DOCA_LOG_ERR(
"Port %u failed to query miss counters before updating: %s",
610 for (port_id = 0; port_id <
nb_ports; port_id++) {
611 memset(&status, 0,
sizeof(status));
612 pipes = pipes_array[port_id];
613 port =
ports[port_id];
614 fwd_port.
port_id = port_id ^ 1;
616 DOCA_LOG_DBG(
"Port %u starts preparing the second pipeline", port_id);
628 DOCA_LOG_ERR(
"Port %u failed to process pipe push entry: %s",
636 DOCA_LOG_DBG(
"Port %u updates the FWD miss actions", port_id);
640 DOCA_LOG_ERR(
"Port %u failed to update fwd miss for IPv4 pipe: %s",
650 DOCA_LOG_ERR(
"Port %u failed to update fwd miss for IP selector pipe: %s",
663 DOCA_LOG_DBG(
"Show miss counter results after second batch of packets");
665 for (port_id = 0; port_id <
nb_ports; port_id++) {
666 pipes = pipes_array[port_id];
670 DOCA_LOG_ERR(
"Port %u failed to query miss counters after updating: %s",
struct doca_flow_port * init_doca_flow(uint16_t port_id, uint8_t rxq_num)
static doca_error_t update_miss_fwd_next_pipe(struct doca_flow_pipe *pipe, struct doca_flow_pipe *next_pipe)
doca_error_t flow_fwd_miss(int nb_queues)
static doca_error_t miss_counters_query(struct doca_flow_pipe *root_pipe, struct doca_flow_pipe *ip_selector_pipe, bool miss_is_updated, int port_id)
static doca_error_t create_root_pipe(struct doca_flow_port *port, struct doca_flow_pipe *next_pipe, struct entries_status *status, struct doca_flow_pipe **pipe_ptr)
static doca_error_t create_pipe_cfg(struct doca_flow_port *port, const char *name, struct doca_flow_match *match, struct doca_flow_actions **actions, struct doca_flow_action_descs **descs, uint32_t nb_actions, uint32_t nb_flows, bool is_root, bool miss_counter, struct doca_flow_pipe_cfg **pipe_cfg)
static doca_error_t create_ip_selector_pipe(struct doca_flow_port *port, struct doca_flow_pipe *ipv4_pipe, struct doca_flow_pipe *modify_pipe, struct entries_status *status, struct doca_flow_pipe **pipe_ptr)
static doca_error_t create_basic_pipe(struct doca_flow_port *port, const char *name, struct doca_flow_match *match, struct doca_flow_actions **actions, struct doca_flow_action_descs **descs, struct doca_flow_fwd *fwd, struct doca_flow_fwd *fwd_miss, uint32_t nb_actions, uint32_t nb_flows, bool is_root, bool miss_counter, struct doca_flow_pipe **pipe)
static doca_error_t destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
static doca_error_t create_modify_pipe(struct doca_flow_port *port, struct doca_flow_fwd *fwd, struct entries_status *status, struct doca_flow_pipe **pipe_ptr)
DOCA_LOG_REGISTER(FLOW_FWD_MISS)
static doca_error_t create_ipv4_pipe(struct doca_flow_port *port, struct doca_flow_fwd *fwd, struct doca_flow_pipe *modify_pipe, struct entries_status *status, struct doca_flow_pipe **pipe_ptr)
static doca_error_t create_push_pipe(struct doca_flow_port *port, struct doca_flow_fwd *fwd, struct entries_status *status, struct doca_flow_pipe **pipe_ptr)
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_fwd fwd
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_VLAN
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_update_miss(struct doca_flow_pipe *pipe, const struct doca_flow_fwd *fwd_miss)
Update the forward miss action.
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_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_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_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_PUSH_ACTION_VLAN
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
#define DOCA_LOG_DBG(format,...)
Generates a DEBUG application log message.
const struct ip_frag_config * cfg
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 ARRAY_INIT(array, val)
enum doca_flow_action_type type
struct doca_flow_action_desc::@108::@110 field_op
doca flow actions information
struct doca_flow_push_action push
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
struct doca_flow_push_vlan_action vlan
enum doca_flow_push_action_type type
struct doca_flow_header_eth_vlan vlan_hdr
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]