31 #include <rte_ethdev.h>
37 #include "flow_common.h"
41 #define PACKET_BURST 128
52 if (signum == SIGINT || signum == SIGTERM) {
53 DOCA_LOG_INFO(
"Signal %d received, preparing to exit", signum);
70 nb_packets = rte_eth_rx_burst(ingress_port, queue_index, packets,
PACKET_BURST);
73 for (i = 0; i < nb_packets; i++) {
74 if (rte_flow_dynf_metadata_avail())
75 DOCA_LOG_INFO(
"Packet received with meta data %d", *RTE_FLOW_DYNF_METADATA(packets[i]));
77 rte_eth_tx_burst(ingress_port, queue_index, packets,
PACKET_BURST);
90 struct doca_flow_pipe *miss_pipe,
91 struct doca_flow_pipe **pipe)
97 struct doca_flow_pipe_cfg *pipe_cfg;
101 memset(&match, 0,
sizeof(match));
103 memset(&
fwd, 0,
sizeof(
fwd));
170 struct doca_flow_pipe_entry *
entry;
179 memset(&match, 0,
sizeof(match));
209 struct doca_flow_pipe_cfg *pipe_cfg;
213 memset(&match, 0,
sizeof(match));
215 memset(&
fwd, 0,
sizeof(
fwd));
279 struct doca_flow_pipe_entry *
entry;
282 memset(&match, 0,
sizeof(match));
317 struct doca_flow_pipe_cfg *pipe_cfg;
320 memset(&match, 0,
sizeof(match));
322 memset(&
fwd, 0,
sizeof(
fwd));
407 struct doca_flow_pipe_entry *
entry;
412 uint8_t encap_ttl = 17;
414 uint8_t src_mac[] = {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
421 memset(&match, 0,
sizeof(match));
459 struct doca_devinfo **list =
NULL;
460 uint32_t list_size = 0;
465 for (i = 0; i < 2; i++)
466 for (j = 0; j < 6; j++)
467 if (mac_addresses[i][j])
476 if ((
const int)list_size <
nb_ports) {
481 for (port_id = 0; port_id <
nb_ports; port_id++) {
509 struct doca_flow_pipe *pipe, *miss_pipe;
511 int num_of_entries = 3;
525 memset(dev_arr, 0,
sizeof(
struct doca_dev *) *
nb_ports);
534 for (port_id = 0; port_id <
nb_ports; port_id++) {
535 memset(&status, 0,
sizeof(status));
606 for (port_id = 0; port_id <
nb_ports; port_id++)
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 create_loopback_pipe(struct doca_flow_port *port, uint16_t port_id, struct doca_flow_pipe **pipe)
static void process_packets(int ingress_port)
static int populate_macs(const int nb_ports, uint8_t mac_addresses[2][6])
static doca_error_t create_rss_tcp_ip_pipe(struct doca_flow_port *port, struct doca_flow_pipe *miss_pipe, struct doca_flow_pipe **pipe)
static doca_error_t add_rss_rss_udp_ip_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static doca_error_t create_rss_udp_ip_pipe(struct doca_flow_port *port, struct doca_flow_pipe **pipe)
DOCA_LOG_REGISTER(FLOW_LOOPBACK)
static doca_error_t add_rss_tcp_ip_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status)
static void signal_handler(int signum)
static doca_error_t add_loopback_pipe_entry(struct doca_flow_pipe *pipe, struct entries_status *status, uint8_t dst_mac[6])
doca_error_t flow_loopback(int nb_queues, uint8_t mac_addresses[2][6])
static struct doca_flow_fwd fwd_miss
static uint16_t * rss_queues
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]
#define DEFAULT_TIMEOUT_US
DOCA_STABLE doca_error_t doca_devinfo_create_list(struct doca_devinfo ***dev_list, uint32_t *nb_devs)
Creates list of all available local devices.
DOCA_STABLE doca_error_t doca_devinfo_destroy_list(struct doca_devinfo **dev_list)
Destroy list of local device info structures.
DOCA_STABLE doca_error_t doca_devinfo_get_mac_addr(const struct doca_devinfo *devinfo, uint8_t *mac_addr, uint32_t size)
Get the MAC address of a DOCA devinfo.
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_TCP
@ 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_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_domain(struct doca_flow_pipe_cfg *cfg, enum doca_flow_pipe_domain domain)
Set pipe's domain.
@ DOCA_FLOW_RESOURCE_TYPE_NON_SHARED
@ DOCA_FLOW_PIPE_DOMAIN_EGRESS
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
uint16_t doca_be16_t
Declare DOCA endianity types.
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)
doca flow actions information
struct doca_flow_resource_encap_cfg encap_cfg
enum doca_flow_resource_type encap_type
struct doca_flow_meta meta
struct doca_flow_header_format outer
struct doca_flow_pipe * next_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
struct doca_flow_parser_meta parser_meta
struct doca_flow_header_format outer
struct doca_flow_encap_action encap
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]