27 #include <rte_ethdev.h>
107 struct doca_dev *dev,
108 bool sn_offload_disable,
109 struct doca_flow_port **port)
111 struct doca_flow_port_cfg *port_cfg;
123 goto destroy_port_cfg;
129 goto destroy_port_cfg;
135 goto destroy_port_cfg;
138 if (sn_offload_disable) {
141 DOCA_LOG_ERR(
"Failed to set doca_flow_port_cfg sn offload disable: %s",
143 goto destroy_port_cfg;
150 goto destroy_port_cfg;
170 struct doca_dev *dev;
171 struct doca_flow_cfg *flow_cfg;
172 struct doca_flow_tune_server_cfg *server_cfg;
177 bool sn_offload_disable;
179 memset(&flow_cfg, 0,
sizeof(flow_cfg));
194 mode_args =
"vnf,hws,isolated";
196 mode_args =
"switch,hws,isolated,expert";
249 sn_offload_disable =
app_cfg->sw_sn_inc_enable &&
app_cfg->sw_antireplay;
250 for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
252 if (!rte_eth_dev_is_valid_port(port_id))
258 dev =
app_cfg->objects.secured_dev.doca_dev;
273 free(
ports[port_idx]);
278 ports[port_idx]->port_id = port_id;
296 DOCA_LOG_ERR(
"Failed to create flow tune server configuration");
303 DOCA_LOG_DBG(
"DOCA Flow Tune Server isn't supported in this runtime version");
305 DOCA_LOG_ERR(
"Failed to initialize the flow tune server");
336 struct doca_flow_port *secured_port;
351 app_cfg->app_rules.nb_encrypt_rules,
364 for (port_id =
nb_ports - 1; port_id >= 0; port_id--) {
367 free(
ports[port_id]);
385 struct doca_flow_port *port,
387 struct doca_flow_pipe **rss_pipe)
392 struct doca_flow_pipe_cfg *pipe_cfg;
393 int num_of_entries = 2;
400 memset(&match, 0,
sizeof(match));
402 memset(&
fwd, 0,
sizeof(
fwd));
403 memset(&
app_cfg->secured_status[0], 0,
sizeof(
app_cfg->secured_status[0]));
411 rss_queues = (uint16_t *)calloc(nb_queues - 1,
sizeof(uint16_t));
413 DOCA_LOG_ERR(
"Failed to allocate memory for RSS queues");
417 for (i = 0; i < nb_queues - 1; i++)
501 if (
app_cfg->secured_status[0].nb_processed != num_of_entries ||
app_cfg->secured_status[0].failure) {
519 uint32_t nb_queues =
app_cfg->dpdk_config->port_config.nb_queues;
522 memset(
fwd, 0,
sizeof(*
fwd));
532 for (i = 0; i < nb_queues - 1; i++)
565 struct doca_flow_pipe_cfg *pipe_cfg;
569 memset(&match, 0,
sizeof(match));
616 struct doca_flow_pipe *encrypt_root,
617 struct doca_flow_pipe *decrypt_root,
618 struct doca_flow_pipe *
pipe,
623 int num_of_entries = 2;
626 memset(&
app_cfg->secured_status[0], 0,
sizeof(
app_cfg->secured_status[0]));
627 memset(&match, 0,
sizeof(match));
629 app_cfg->secured_status[0].entries_in_queue = num_of_entries;
674 if (
app_cfg->secured_status[0].nb_processed != num_of_entries ||
app_cfg->secured_status[0].failure)
688 struct doca_flow_pipe_cfg *pipe_cfg;
695 memset(&match, 0,
sizeof(match));
753 struct doca_flow_pipe *encrypt_pipe,
754 struct doca_flow_pipe *pipe,
759 int num_of_entries = 2;
763 memset(&match, 0,
sizeof(match));
764 memset(&
app_cfg->secured_status[0], 0,
sizeof(
app_cfg->secured_status[0]));
809 if (
app_cfg->secured_status[0].nb_processed != num_of_entries ||
app_cfg->secured_status[0].failure)
818 struct doca_flow_pipe *match_port_pipe;
828 app_cfg->encrypt_pipes.encrypt_root.pipe,
829 app_cfg->decrypt_pipes.decrypt_root.pipe,
852 app_cfg->encrypt_pipes.egress_ip_classifier.pipe,
853 app_cfg->switch_pipes.pkt_meta_pipe.pipe,
872 struct rte_ether_hdr *oh;
873 struct rte_ipv4_hdr *ipv4;
874 struct rte_ipv6_hdr *ipv6;
875 uint32_t payload_len, payload_len_l3, l2_l3_len;
877 oh = rte_pktmbuf_mtod(*m,
struct rte_ether_hdr *);
879 if (RTE_ETH_IS_IPV4_HDR((*m)->packet_type)) {
880 ipv4 = (
void *)(oh + 1);
881 l2_l3_len = rte_ipv4_hdr_len(ipv4) +
sizeof(
struct rte_ether_hdr);
882 payload_len_l3 = rte_be_to_cpu_16(ipv4->total_length) - rte_ipv4_hdr_len(ipv4);
884 ipv6 = (
void *)(oh + 1);
885 l2_l3_len =
sizeof(
struct rte_ipv6_hdr) + sizeof(struct rte_ether_hdr);
886 payload_len_l3 = rte_be_to_cpu_16(ipv6->payload_len);
889 payload_len = (*m)->pkt_len - l2_l3_len;
892 if (payload_len > payload_len_l3) {
894 rte_pktmbuf_trim(*m, payload_len - payload_len_l3);
957 free(
app_cfg->unsecured_status);
void doca_flow_cleanup(int nb_ports, struct ipsec_security_gw_ports_map *ports[])
static void security_gateway_free_encrypt_resources(struct encrypt_pipes *encrypt_pipes)
DOCA_LOG_REGISTER(IPSEC_SECURITY_GW::flow_common)
doca_error_t create_rss_pipe(struct ipsec_security_gw_config *app_cfg, struct doca_flow_port *port, uint16_t nb_queues, struct doca_flow_pipe **rss_pipe)
void remove_ethernet_padding(struct rte_mbuf **m)
static void security_gateway_free_decrypt_resources(struct decrypt_pipes *decrypt_pipes)
doca_error_t process_entries(struct doca_flow_port *port, struct entries_status *status, int timeout, uint16_t pipe_queue)
static doca_error_t add_switch_port_meta_entries(struct ipsec_security_gw_ports_map *ports[], struct doca_flow_pipe *encrypt_root, struct doca_flow_pipe *decrypt_root, struct doca_flow_pipe *pipe, struct ipsec_security_gw_config *app_cfg)
doca_error_t ipsec_security_gw_init_status(struct ipsec_security_gw_config *app_cfg, int nb_queues)
doca_error_t create_switch_ingress_root_pipes(struct ipsec_security_gw_ports_map *ports[], struct ipsec_security_gw_config *app_cfg)
void security_gateway_free_status_entries(struct ipsec_security_gw_config *app_cfg)
static doca_error_t create_switch_pkt_meta_pipe(struct doca_flow_pipe **pipe)
doca_error_t ipsec_security_gw_bind(struct ipsec_security_gw_ports_map *ports[], struct ipsec_security_gw_config *app_cfg)
void security_gateway_free_resources(struct ipsec_security_gw_config *app_cfg)
doca_error_t ipsec_security_gw_init_doca_flow(const struct ipsec_security_gw_config *app_cfg, int nb_queues, struct ipsec_security_gw_ports_map *ports[])
void create_hairpin_pipe_fwd(struct ipsec_security_gw_config *app_cfg, int port_id, bool encrypt, uint16_t *rss_queues, uint32_t rss_flags, struct doca_flow_fwd *fwd)
static doca_error_t add_switch_pkt_meta_entries(struct ipsec_security_gw_ports_map *ports[], struct doca_flow_pipe *encrypt_pipe, struct doca_flow_pipe *pipe, struct ipsec_security_gw_config *app_cfg)
static doca_error_t create_doca_flow_port(int port_id, struct doca_dev *dev, bool sn_offload_disable, struct doca_flow_port **port)
doca_error_t create_switch_egress_root_pipes(struct ipsec_security_gw_ports_map *ports[], struct ipsec_security_gw_config *app_cfg)
static void check_for_valid_entry(struct doca_flow_pipe_entry *entry, uint16_t pipe_queue, enum doca_flow_entry_status status, enum doca_flow_entry_op op, void *user_ctx)
static doca_error_t create_switch_port_meta_pipe(struct doca_flow_pipe **pipe)
uint32_t get_icv_len_int(enum doca_flow_crypto_icv_len icv_len)
doca_error_t bind_decrypt_ids(int nb_rules, int initial_id, struct doca_flow_port *port)
doca_error_t bind_encrypt_ids(int nb_rules, 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_fwd fwd
static struct doca_flow_match match_mask
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
#define DEFAULT_TIMEOUT_US
static struct app_gpu_cfg app_cfg
#define DOCA_ERROR_PROPAGATE(r, t)
Save the first encountered doca_error_t.
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_INITIALIZATION
@ DOCA_ERROR_NOT_SUPPORTED
doca_flow_crypto_icv_len
doca flow crypto ICV length
@ DOCA_FLOW_CRYPTO_ICV_LENGTH_12
@ DOCA_FLOW_CRYPTO_ICV_LENGTH_8
DOCA_EXPERIMENTAL doca_error_t doca_flow_tune_server_init(struct doca_flow_tune_server_cfg *cfg)
Initialize a DOCA Flow Tune Server.
DOCA_EXPERIMENTAL doca_error_t doca_flow_tune_server_cfg_destroy(struct doca_flow_tune_server_cfg *cfg)
Destroy DOCA Flow Tune Server configuration struct.
DOCA_EXPERIMENTAL doca_error_t doca_flow_tune_server_cfg_create(struct doca_flow_tune_server_cfg **cfg)
Create DOCA Flow Tune Server configuration struct.
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_port_pair(struct doca_flow_port *port, struct doca_flow_port *pair_port)
pair two doca flow ports.
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_port_start(const struct doca_flow_port_cfg *cfg, struct doca_flow_port **port)
Start a doca port.
doca_flow_entry_op
doca flow entry operation
DOCA_STABLE doca_error_t doca_flow_cfg_set_cb_entry_process(struct doca_flow_cfg *cfg, doca_flow_entry_process_cb cb)
Set callback for entry create/destroy.
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_STABLE doca_error_t doca_flow_cfg_set_queue_depth(struct doca_flow_cfg *cfg, uint32_t queue_depth)
Set number of pre-configured queue_size.
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_EXPERIMENTAL doca_error_t doca_flow_port_cfg_set_dev(struct doca_flow_port_cfg *cfg, struct doca_dev *dev)
Set port's device.
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_cfg_set_ipsec_sn_offload_disable(struct doca_flow_port_cfg *cfg)
Disable SN offload for ipsec - Anti-replay and sn increment will not be activated.
DOCA_EXPERIMENTAL doca_error_t doca_flow_port_cfg_set_actions_mem_size(struct doca_flow_port_cfg *cfg, uint32_t size)
Set max memory size used by actions.
DOCA_STABLE doca_error_t doca_flow_cfg_set_nr_shared_resource(struct doca_flow_cfg *cfg, uint32_t nr_shared_resource, enum doca_flow_shared_resource_type type)
Set number of shared resource.
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_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_flow_entry_status
doca flow entry status
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_EXPERIMENTAL doca_error_t doca_flow_cfg_set_default_rss(struct doca_flow_cfg *cfg, const struct doca_flow_resource_rss_cfg *rss)
Set RSS global configuration.
DOCA_STABLE doca_error_t doca_flow_port_cfg_create(struct doca_flow_port_cfg **cfg)
Create DOCA Flow port configuration struct.
DOCA_EXPERIMENTAL doca_error_t doca_flow_pipe_cfg_set_dir_info(struct doca_flow_pipe_cfg *cfg, enum doca_flow_direction_info dir_info)
Set pipe's Direction info.
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 struct doca_flow_port * doca_flow_port_switch_get(const struct doca_flow_port *port)
Get doca flow switch port.
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_STABLE doca_error_t doca_flow_cfg_destroy(struct doca_flow_cfg *cfg)
Destroy DOCA Flow configuration struct.
@ DOCA_FLOW_SHARED_RESOURCE_IPSEC_SA
@ DOCA_FLOW_DIRECTION_HOST_TO_NETWORK
@ DOCA_FLOW_WAIT_FOR_BATCH
@ DOCA_FLOW_RESOURCE_TYPE_NON_SHARED
@ DOCA_FLOW_FWD_CHANGEABLE
@ DOCA_FLOW_ENTRY_STATUS_SUCCESS
@ DOCA_FLOW_PIPE_DOMAIN_EGRESS
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_DBG(format,...)
Generates a DEBUG application log message.
doca_error_t find_port_action_type_vnf(const struct ipsec_security_gw_config *app_cfg, int port_id, struct doca_dev **connected_dev, int *idx)
doca_error_t find_port_action_type_switch(int port_id, int *idx)
@ IPSEC_SECURITY_GW_TUNNEL
@ IPSEC_SECURITY_GW_SWITCH
#define MAX_ACTIONS_MEM_SIZE
@ IPSEC_SECURITY_GW_ESP_OFFLOAD_ENCAP
@ IPSEC_SECURITY_GW_ESP_OFFLOAD_DECAP
@ IPSEC_SECURITY_GW_ESP_OFFLOAD_NONE
struct security_gateway_pipe_info decrypt_ipv4_pipe
struct security_gateway_pipe_info vxlan_decap_ipv6_pipe
struct security_gateway_pipe_info marker_remove_pipe
struct security_gateway_pipe_info decrypt_ipv6_pipe
struct security_gateway_pipe_info decrypt_root
struct security_gateway_pipe_info decap_pipe
struct security_gateway_pipe_info vxlan_decap_ipv4_pipe
struct doca_flow_pipe * next_pipe
struct doca_flow_pipe * 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_meta meta
struct security_gateway_pipe_info ipv4_encrypt_pipe
struct security_gateway_pipe_info ipv6_tcp_pipe
struct security_gateway_pipe_info ipv6_src_udp_pipe
struct security_gateway_pipe_info ipv4_udp_pipe
struct security_gateway_pipe_info encrypt_root
struct security_gateway_pipe_info egress_ip_classifier
struct security_gateway_pipe_info marker_insert_pipe
struct security_gateway_pipe_info ipv6_udp_pipe
struct security_gateway_pipe_info vxlan_encap_pipe
struct security_gateway_pipe_info ipv6_src_tcp_pipe
struct security_gateway_pipe_info ipv6_encrypt_pipe
struct security_gateway_pipe_info ipv4_tcp_pipe
user context struct that will be used in entries process callback
struct security_gateway_entry_info * entries_info
static struct doca_flow_port * ports[FLOW_SWITCH_PORTS_MAX]
void linear_array_init_u16(uint16_t *array, uint16_t n)