26 #include <arpa/inet.h>
27 #include <rte_ethdev.h>
40 struct doca_flow_port_cfg *port_cfg;
42 struct doca_flow_cfg *rxq_flow_cfg;
44 struct rte_eth_dev_info
dev_info = {0};
52 .offloads = RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
53 RTE_ETH_TX_OFFLOAD_TCP_CKSUM,
56 struct rte_mempool *
mp =
NULL;
57 struct rte_eth_txconf tx_conf;
58 struct rte_flow_error error;
68 ret = rte_eth_dev_info_get(port_id, &
dev_info);
70 DOCA_LOG_ERR(
"Failed rte_eth_dev_info_get with: %s", rte_strerror(-ret));
74 ret = rte_eth_dev_configure(port_id, rxq_num, rxq_num, &
eth_conf);
76 DOCA_LOG_ERR(
"Failed rte_eth_dev_configure with: %s", rte_strerror(-ret));
80 mp = rte_pktmbuf_pool_create(
"TEST", 8192, 0, 0,
MAX_PKT_SIZE, rte_eth_dev_socket_id(port_id));
82 DOCA_LOG_ERR(
"Failed rte_pktmbuf_pool_create with: %s", rte_strerror(-ret));
87 tx_conf.offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | RTE_ETH_TX_OFFLOAD_UDP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
89 for (
int idx = 0; idx < rxq_num; idx++) {
90 ret = rte_eth_rx_queue_setup(port_id, idx, 2048, rte_eth_dev_socket_id(port_id),
NULL,
mp);
92 DOCA_LOG_ERR(
"Failed rte_eth_rx_queue_setup with: %s", rte_strerror(-ret));
96 ret = rte_eth_tx_queue_setup(port_id, idx, 2048, rte_eth_dev_socket_id(port_id), &tx_conf);
98 DOCA_LOG_ERR(
"Failed rte_eth_tx_queue_setup with: %s", rte_strerror(-ret));
103 ret = rte_flow_isolate(port_id, 1, &error);
105 DOCA_LOG_ERR(
"Failed rte_flow_isolate with: %s", error.message);
109 ret = rte_eth_dev_start(port_id);
111 DOCA_LOG_ERR(
"Failed rte_eth_dev_start with: %s", rte_strerror(-ret));
182 struct doca_flow_pipe_cfg *pipe_cfg;
183 struct doca_flow_pipe_entry *
entry;
184 uint16_t flow_queue_id;
189 const char *pipe_name =
"GPU_RXQ_UDP_PIPE";
323 struct doca_flow_pipe_cfg *pipe_cfg;
324 const char *pipe_name =
"CPU_RXQ_TCP_PIPE";
396 struct doca_flow_port *port,
397 bool connection_based_flows)
399 uint16_t flow_queue_id;
402 struct doca_flow_pipe_entry *dummy_entry =
NULL;
413 .ip4.next_proto = IPPROTO_TCP,
417 if (connection_based_flows) {
449 struct doca_flow_pipe_cfg *pipe_cfg;
450 const char *pipe_name =
"GPU_RXQ_TCP_PIPE";
492 if (!connection_based_flows) {
532 struct doca_flow_pipe_cfg *pipe_cfg;
533 struct doca_flow_pipe_entry *
entry;
534 uint16_t flow_queue_id;
539 const char *pipe_name =
"GPU_RXQ_ICMP_PIPE";
635 struct doca_flow_port *port)
637 uint32_t priority_high = 1;
638 uint32_t priority_low = 3;
647 struct doca_flow_pipe_cfg *pipe_cfg;
648 const char *pipe_name =
"ROOT_PIPE";
692 .outer.ip4.next_proto = IPPROTO_UDP,
722 .outer.ip4.next_proto = IPPROTO_ICMP,
753 .outer.ip4.next_proto = IPPROTO_TCP,
784 .outer.ip4.next_proto = IPPROTO_TCP,
793 uint8_t individual_tcp_flags[] = {
802 .outer.ip4.next_proto = 0xFF,
805 for (
int i = 0; i < 3; i++) {
807 tcp_match_cpu_mask.
outer.
tcp.
flags = individual_tcp_flags[i];
822 DOCA_LOG_ERR(
"Root pipe TCP CPU %d entry creation failed with: %s",
843 struct doca_flow_pipe *gpu_rss_pipe,
858 .tcp.l4_port.src_port = session_entry->
key.
src_port,
859 .tcp.l4_port.dst_port = session_entry->
key.
dst_port,
871 &session_entry->
flow);
875 DOCA_LOG_ERR(
"Failed to create TCP offload session; error = %s, session = %s:%d>%s:%d",
925 DOCA_LOG_ERR(
"Failed to destroy TCP offload session; error = %s, session = %s:%d>%s:%d",
doca_error_t destroy_tcp_queues(struct rxq_tcp_queues *tcp_queues, bool http_server, struct txq_http_queues *http_queues)
doca_error_t destroy_icmp_queues(struct rxq_icmp_queues *icmp_queues)
doca_error_t destroy_udp_queues(struct rxq_udp_queues *udp_queues)
struct rte_eth_conf eth_conf
struct rte_eth_dev_info dev_info
doca_error_t enable_tcp_gpu_offload(struct doca_flow_port *port, uint16_t queue_id, struct doca_flow_pipe *gpu_rss_pipe, struct tcp_session_entry *session_entry)
struct doca_flow_port * init_doca_flow(uint16_t port_id, uint8_t rxq_num)
doca_error_t destroy_flow_queue(struct doca_flow_port *port_df, struct rxq_icmp_queues *icmp_queues, struct rxq_udp_queues *udp_queues, struct rxq_tcp_queues *tcp_queues, bool http_server, struct txq_http_queues *http_queues)
doca_error_t create_tcp_gpu_pipe(struct rxq_tcp_queues *tcp_queues, struct doca_flow_port *port, bool connection_based_flows)
DOCA_LOG_REGISTER(GPU_PACKET_PROCESSING_FLOW)
doca_error_t create_root_pipe(struct rxq_udp_queues *udp_queues, struct rxq_tcp_queues *tcp_queues, struct rxq_icmp_queues *icmp_queues, struct doca_flow_port *port)
static uint64_t default_flow_timeout_usec
doca_error_t disable_tcp_gpu_offload(struct doca_flow_port *port, uint16_t queue_id, struct tcp_session_entry *session_entry)
doca_error_t create_tcp_cpu_pipe(struct rxq_tcp_queues *tcp_queues, struct doca_flow_port *port)
doca_error_t create_icmp_gpu_pipe(struct rxq_icmp_queues *icmp_queues, struct doca_flow_port *port)
doca_error_t create_udp_pipe(struct rxq_udp_queues *udp_queues, struct doca_flow_port *port)
static doca_error_t destroy_pipe_cfg(struct doca_flow_pipe_cfg *cfg)
static uint16_t * rss_queues
static struct doca_flow_monitor monitor
static struct doca_flow_fwd fwd
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
static volatile bool force_quit
static struct rxq_icmp_queues icmp_queues
static struct doca_flow_port * df_port
static struct rxq_tcp_queues tcp_queues
static struct rxq_udp_queues udp_queues
static struct txq_http_queues http_queues
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_ERROR_INVALID_VALUE
DOCA_EXPERIMENTAL doca_error_t doca_eth_rxq_get_flow_queue_id(struct doca_eth_rxq *eth_rxq, uint16_t *flow_queue_id)
Get the DPDK queue ID of the doca_eth receive queue. can only be called after calling doca_ctx_start(...
#define DOCA_FLOW_ETHER_TYPE_IPV4
@ DOCA_FLOW_L4_TYPE_EXT_TCP
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_cfg_set_mode_args(struct doca_flow_cfg *cfg, const char *mode_args)
Set DOCA mode args.
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_STABLE doca_error_t doca_flow_pipe_cfg_set_name(struct doca_flow_pipe_cfg *cfg, const char *name)
Set pipe's name.
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_control_add_entry(uint16_t pipe_queue, uint32_t priority, struct doca_flow_pipe *pipe, const struct doca_flow_match *match, const struct doca_flow_match *match_mask, const struct doca_flow_match_condition *condition, const struct doca_flow_actions *actions, const struct doca_flow_actions *actions_mask, const struct doca_flow_action_descs *action_descs, const struct doca_flow_monitor *monitor, const struct doca_flow_fwd *fwd, void *usr_ctx, struct doca_flow_pipe_entry **entry)
Add one new entry to a control pipe.
DOCA_EXPERIMENTAL doca_error_t doca_flow_port_start(const struct doca_flow_port_cfg *cfg, struct doca_flow_port **port)
Start a doca port.
DOCA_STABLE doca_error_t doca_flow_pipe_cfg_set_is_root(struct doca_flow_pipe_cfg *cfg, bool is_root)
Set if pipe is root or not.
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 doca_error_t doca_flow_cfg_create(struct doca_flow_cfg **cfg)
Create DOCA Flow configuration struct.
DOCA_STABLE doca_error_t doca_flow_pipe_cfg_set_type(struct doca_flow_pipe_cfg *cfg, enum doca_flow_pipe_type type)
Set pipe's type.
DOCA_EXPERIMENTAL doca_error_t doca_flow_init(struct doca_flow_cfg *cfg)
Initialize the doca flow.
DOCA_STABLE doca_error_t doca_flow_cfg_set_nr_counters(struct doca_flow_cfg *cfg, uint32_t nr_counters)
Set number of counters to configure.
DOCA_STABLE doca_error_t doca_flow_port_stop(struct doca_flow_port *port)
Stop a doca port.
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 doca_error_t doca_flow_pipe_remove_entry(uint16_t pipe_queue, uint32_t flags, struct doca_flow_pipe_entry *entry)
Free one pipe entry.
DOCA_STABLE void doca_flow_destroy(void)
Destroy the doca flow.
DOCA_EXPERIMENTAL doca_error_t doca_flow_port_cfg_set_port_id(struct doca_flow_port_cfg *cfg, uint16_t port_id)
Set the logical port ID.
DOCA_STABLE doca_error_t doca_flow_port_cfg_create(struct doca_flow_port_cfg **cfg)
Create DOCA Flow port configuration struct.
DOCA_STABLE doca_error_t doca_flow_port_cfg_destroy(struct doca_flow_port_cfg *cfg)
Destroy DOCA Flow port configuration struct.
DOCA_STABLE doca_error_t doca_flow_cfg_set_pipe_queues(struct doca_flow_cfg *cfg, uint16_t pipe_queues)
Set pipe queues.
DOCA_STABLE doca_error_t doca_flow_cfg_destroy(struct doca_flow_cfg *cfg)
Destroy DOCA Flow configuration struct.
@ DOCA_FLOW_MATCH_TCP_FLAG_FIN
@ DOCA_FLOW_MATCH_TCP_FLAG_RST
@ DOCA_FLOW_MATCH_TCP_FLAG_SYN
@ 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.
#define DOCA_LOG_DBG(format,...)
Generates a DEBUG application log message.
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
doca monitor action configuration
enum doca_flow_resource_type counter_type
struct doca_flow_pipe * rxq_pipe
struct doca_eth_rxq * eth_rxq_cpu[MAX_QUEUES]
struct doca_flow_pipe_entry * cpu_rss_entry
struct doca_flow_pipe * rxq_pipe_cpu
struct doca_flow_pipe * rxq_pipe_gpu
struct doca_eth_rxq * eth_rxq_cpu[MAX_QUEUES]
struct doca_eth_rxq * eth_rxq_cpu[MAX_QUEUES]
struct doca_flow_pipe * root_pipe
struct doca_flow_pipe * rxq_pipe
struct doca_flow_pipe_entry * root_udp_entry
struct doca_flow_pipe_entry * root_tcp_entry_cpu[3]
struct doca_flow_pipe_entry * root_tcp_entry_gpu
struct doca_flow_pipe_entry * root_icmp_entry_gpu
struct doca_flow_pipe_entry * flow
struct tcp_session_key key
struct rte_hash * tcp_session_table
struct rte_hash_parameters tcp_session_ht_params