NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_ct_tcp_actions_sample.c File Reference
#include <unistd.h>
#include <rte_ethdev.h>
#include <doca_log.h>
#include <doca_flow.h>
#include <doca_flow_ct.h>
#include <doca_bitfield.h>
#include "flow_ct_common.h"
#include "flow_common.h"
Include dependency graph for flow_ct_tcp_actions_sample.c:

Go to the source code of this file.

Macros

#define PACKET_BURST   128
 
#define NB_COUNTERS   6
 

Functions

 DOCA_LOG_REGISTER (FLOW_CT_TCP)
 
static doca_error_t create_rss_pipe (struct doca_flow_port *port, struct entries_status *status, struct doca_flow_pipe **pipe)
 
static doca_error_t create_egress_pipe (struct doca_flow_port *port, int port_id, struct entries_status *status, struct doca_flow_pipe **pipe)
 
static doca_error_t create_ct_miss_pipe (struct doca_flow_port *port, struct doca_flow_pipe *fwd_pipe, struct entries_status *status, struct doca_flow_pipe **pipe)
 
static doca_error_t create_tcp_flags_filter_pipe (struct doca_flow_port *port, struct entries_status *status, struct doca_flow_pipe *fwd_pipe, struct doca_flow_pipe *fwd_miss_pipe, struct doca_flow_pipe **pipe)
 
static doca_error_t create_ct_pipe (struct doca_flow_port *port, struct doca_flow_pipe *fwd_pipe, struct doca_flow_pipe *fwd_miss_pipe, struct doca_flow_pipe **pipe)
 
static void parse_packet (struct rte_mbuf *packet, struct doca_flow_ct_match *match_o, struct doca_flow_ct_match *match_r, uint8_t *tcp_state)
 
static doca_error_t process_packets (struct doca_flow_port *port, uint16_t ct_queue, struct entries_status *ct_status, uint32_t shared_handle, struct doca_flow_pipe_entry **entry)
 
static doca_error_t print_pipe_counters (uint16_t ct_queue, struct doca_flow_pipe *ct_pipe)
 
doca_error_t flow_ct_tcp_actions (uint16_t nb_queues, struct doca_dev *ct_dev)
 

Variables

static uint16_t sessions = 0
 
static struct doca_flow_pipe_entry * rss_entry
 
static struct doca_flow_pipe_entry * egress_entry
 
static struct doca_flow_pipe_entry * tcp_flags_filter_entry
 
static struct doca_flow_pipe_entry * ct_miss_entry
 
static struct doca_flow_pipe_entry * ct_entry
 

Macro Definition Documentation

◆ NB_COUNTERS

#define NB_COUNTERS   6

Definition at line 39 of file flow_ct_tcp_actions_sample.c.

◆ PACKET_BURST

#define PACKET_BURST   128

Definition at line 38 of file flow_ct_tcp_actions_sample.c.

Function Documentation

◆ create_ct_miss_pipe()

static doca_error_t create_ct_miss_pipe ( struct doca_flow_port *  port,
struct doca_flow_pipe *  fwd_pipe,
struct entries_status status,
struct doca_flow_pipe **  pipe 
)
static

Definition at line 236 of file flow_ct_tcp_actions_sample.c.

◆ create_ct_pipe()

static doca_error_t create_ct_pipe ( struct doca_flow_port *  port,
struct doca_flow_pipe *  fwd_pipe,
struct doca_flow_pipe *  fwd_miss_pipe,
struct doca_flow_pipe **  pipe 
)
static

Definition at line 405 of file flow_ct_tcp_actions_sample.c.

◆ create_egress_pipe()

static doca_error_t create_egress_pipe ( struct doca_flow_port *  port,
int  port_id,
struct entries_status status,
struct doca_flow_pipe **  pipe 
)
static

Definition at line 160 of file flow_ct_tcp_actions_sample.c.

◆ create_rss_pipe()

static doca_error_t create_rss_pipe ( struct doca_flow_port *  port,
struct entries_status status,
struct doca_flow_pipe **  pipe 
)
static

PUT NIC in MP-ESWITCH mode

Root pipe -> CT pipe -> CT miss pipe -> rss pipe -> SYN: create CT rule -> tcp flags filter pipe -> egress pipe -> port 1 -> rss pipe -> FIN/RST: delete CT rule CT rule actions: origin: set pkt_meta to 1 reply: NAT(reverse L3 addresses and L4 ports)

Input: port 0 and port 1, IPv4(dst=1.1.1.1) TCP packets with SYN flag set

send SYN packet will create a new CT rule

sendp(Ether(dst="2")/IP(src="1.1.1.1",dst="2.2.2.2")/TCP(dport=1,sport=2,flags="S"),iface="eth2")

wait 5 seconds

send TCP known packet with reverse L3 addresses and L4 ports which match reply direction of CT rule

sendp(Ether(dst="2")/IP(dst="1.1.1.1",src="2.2.2.2")/TCP(sport=1,dport=2,flags=""),iface="eth2") Output: Known TCP session on port 1

modified by CT reply direction rule action(reverse L3 addresses and L4 ports)

IPv4 TCP 1.1.1.1:2 > 2.2.2.2:1

Definition at line 79 of file flow_ct_tcp_actions_sample.c.

◆ create_tcp_flags_filter_pipe()

static doca_error_t create_tcp_flags_filter_pipe ( struct doca_flow_port *  port,
struct entries_status status,
struct doca_flow_pipe *  fwd_pipe,
struct doca_flow_pipe *  fwd_miss_pipe,
struct doca_flow_pipe **  pipe 
)
static

Definition at line 313 of file flow_ct_tcp_actions_sample.c.

◆ DOCA_LOG_REGISTER()

DOCA_LOG_REGISTER ( FLOW_CT_TCP  )

◆ flow_ct_tcp_actions()

doca_error_t flow_ct_tcp_actions ( uint16_t  nb_queues,
struct doca_dev *  ct_dev 
)

Definition at line 735 of file flow_ct_tcp_actions_sample.c.

◆ parse_packet()

static void parse_packet ( struct rte_mbuf *  packet,
struct doca_flow_ct_match match_o,
struct doca_flow_ct_match match_r,
uint8_t *  tcp_state 
)
static

Definition at line 498 of file flow_ct_tcp_actions_sample.c.

◆ print_pipe_counters()

static doca_error_t print_pipe_counters ( uint16_t  ct_queue,
struct doca_flow_pipe *  ct_pipe 
)
static

Definition at line 670 of file flow_ct_tcp_actions_sample.c.

◆ process_packets()

static doca_error_t process_packets ( struct doca_flow_port *  port,
uint16_t  ct_queue,
struct entries_status ct_status,
uint32_t  shared_handle,
struct doca_flow_pipe_entry **  entry 
)
static

Definition at line 538 of file flow_ct_tcp_actions_sample.c.

Variable Documentation

◆ ct_entry

struct doca_flow_pipe_entry* ct_entry
static

Definition at line 46 of file flow_ct_tcp_actions_sample.c.

◆ ct_miss_entry

struct doca_flow_pipe_entry* ct_miss_entry
static

Definition at line 45 of file flow_ct_tcp_actions_sample.c.

◆ egress_entry

struct doca_flow_pipe_entry* egress_entry
static

Definition at line 43 of file flow_ct_tcp_actions_sample.c.

◆ rss_entry

struct doca_flow_pipe_entry* rss_entry
static

Definition at line 42 of file flow_ct_tcp_actions_sample.c.

◆ sessions

uint16_t sessions = 0
static

Definition at line 41 of file flow_ct_tcp_actions_sample.c.

◆ tcp_flags_filter_entry

struct doca_flow_pipe_entry* tcp_flags_filter_entry
static

Definition at line 44 of file flow_ct_tcp_actions_sample.c.