Hi there,
I am new to DOCA, and I managed to “copy-paste” together a simple code from sample applications and SDK docs that initializes everything properly (dpdk ports, doca flow, doca ports, etc.).
My intention is to have a simple application that prints out the 5-tuples crossing it.
I learned from the documentation that if we want to do anything with packets on a port, we have to create a DOCA FLOW PIPE. I managed to do this, set match to be on ipv4 packets.
However, even in sample apps like flow_modify_header, I observe that the code either directly matches on a header field, or just modify the header field via an action.
Is it possible to print out/get access to the packet metadata instead?
my pipe creation looks like this now:
static doca_error_t
create_simple_pipe(struct doca_flow_port *port,
int port_id,
struct doca_flow_pipe **pipe)
{
/* create match struct */
struct doca_flow_match match;
/* create action struct */
struct doca_flow_actions actions, *actions_arr[NB_ACTIONS_ARR];
/* create monitor strut */
struct doca_flow_monitor monitor;
/* create fwd struct */
struct doca_flow_fwd fwd;
/* create pipe_cfg struct */
struct doca_flow_pipe_cfg pipe_cfg;
/* initialize these structs with 0s */
memset(&match, 0, sizeof(match));
memset(&actions, 0, sizeof(actions));
memset(&monitor, 0, sizeof(monitor));
memset(&fwd, 0, sizeof(fwd));
memset(&pipe_cfg, 0, sizeof(pipe_cfg));
/* ============== */
/* configure pipe */
/* ============== */
/* attributes first */
pipe_cfg.attr.name = "SIMPLE PIPE";
pipe_cfg.attr.type = DOCA_FLOW_PIPE_BASIC; //this mean a flow pipe
pipe_cfg.attr.domain = DOCA_FLOW_PIPE_DOMAIN_DEFAULT; // default pipe domain for action on ingress traffic
pipe_cfg.attr.is_root = true; //determines whether the pipeline is root
pipe_cfg.attr.enable_strict_matching = false; //if true, relaxed matching is disabled
pipe_cfg.attr.nb_flows = 8000; //default value is 8k
pipe_cfg.attr.nb_actions = NB_ACTIONS_ARR; //maximum number of DOCA Flow action array. Default is 1 if not set. mutually exclusive with nb_ordered_lists.
pipe_cfg.attr.nb_ordered_lists = 0; // Number of ordered lists in the array. Default is 0.
pipe_cfg.attr.dir_info = DOCA_FLOW_DIRECTION_BIDIRECTIONAL; //default
pipe_cfg.attr.miss_counter = true; //speaks for itself
/* define which port is assigned to the pipe sia */
pipe_cfg.port = port;
/* add match to the pipe */
pipe_cfg.match = &match;
//match.parser_meta.outer_l4_type = DOCA_FLOW_L4_META_TCP;
match.outer.l3_type = DOCA_FLOW_L3_TYPE_IP4; //let's match on IPv4 packets (only)
/* create monitor */
pipe_cfg.monitor = &monitor;
/* Packets matching the pipe entry are counted on the shared_counter_id. */
/* let's have non shared counters */
monitor.meter_type = DOCA_FLOW_RESOURCE_TYPE_NON_SHARED;
/* create actions */
actions_arr[0] = &actions;
pipe_cfg.actions = actions_arr;
/* create fwd entry */
fwd.type = DOCA_FLOW_FWD_PORT; //forward to another port
fwd.port_id = port_id ^ 1; //forward to given output port
/* call doca pipe creation with the config and return the created pipe sia */
return doca_flow_pipe_create(&pipe_cfg, &fwd, NULL, pipe);
}
Where and how should I put a statement to get the packet metadata? Is it even feasible?