API: Setting the Priority of a Flow

Link-Inline™ Software User Guide

Platform
Napatech SmartNIC
Content Type
User Guide
Capture Software Version
Link-Inline™ Software 3.2

In sustained high traffic load, frames can be discarded in the SmartNIC based on the priority of each flow. Use this DPDK API example to configure the priority of a flow.

Priority attribute

The priority of a flow can be set in a flow rule as shown in the following example.
/* Create group 1 exact match 5-tuple to retransmit offloaded IPv4 UDP packets. */
struct rte_flow_attr attr = { .group = 1, .priority = 2, .ingress = 1 };

struct rte_flow_item_ipv4 ipv4 = { .hdr = {
  .src_addr = RTE_BE32(0x12345678),
  .dst_addr = RTE_BE32(0xbaddecaf) }};
struct rte_flow_item_udp udp = { .hdr = {
  .src_port = RTE_BE16(0x1000),
  .dst_port = RTE_BE16(0x1001) }};
struct rte_flow_item pattern[] = {
  [0] = { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4, .mask = &rte_flow_item_ipv4_mask },
  [1] = { .type = RTE_FLOW_ITEM_TYPE_UDP, .spec = &udp, .mask = &rte_flow_item_udp_mask }};

struct rte_flow_action_port_id port_id = { .id = 1 };
struct rte_flow_action action[] = {
  [0] = { .type = RTE_FLOW_ACTION_TYPE_PORT_ID, .conf = &port_id }};

struct rte_flow_error error;
struct rte_flow *flow = rte_flow_create(PORT_ID, &attr, pattern, action, &error);
if (!flow) {
  /* Error handling */
}
The priority attribute in the rte_flow_attr structure specifies the relative priority of the flow compared to other flows. A value in the range of 0 to 3 can be set, where 0 indicates the highest priority. Setting the priority attribute ensures that flows with lower priority are discarded first in cases of network congestion or oversubscription on the TX port.

For detailed information on the priority of a flow, see Flow priority in DN-1355.

Note: The priority attribute is not applicable to flow rules with group 0.
Note: A flow rule with group 0 must be created before the flow rule in this API example is created. This step has been omitted in this example for brevity.