Rate This Document
Findability
Accuracy
Completeness
Readability

DPDK Header File Format

DPDK is a C library that processes flow table information issued by the control plane. The header file format of HydraInfo is adapted for DPDK and can be directly included in the user's DPDK C file. The following describes the generated content.

Mandatory Items

#include "rte_flow.h"

struct hydra_flow_action {
  enum hydra_action_type action_type;
  void* action_data;
  size_t action_data_size;
};

struct hydra_flow_item {
  enum hydra_item_type item_type;
  void* item_data;
  size_t item_data_size;
};
  • rte_flow header file: Used to support the DPDK enumeration type.
  • hydra_flow_action: Provides action information for DPDK flow entry issuance.
  • hydra_flow_item: Provides key (item) information for DPDK flow entry issuance.

Group, Action, and Item Enumerations

The example code for the hydra_group_type enum is shown below.

enum hydra_group_type {
  HYDRA_TABLE_INVALID = 0x0000,
  HYDRA_TABLE_MY_CONTROL_MY_TABLE,
};

The example code for the hydra_default_action_type enum is shown below.

enum hydra_default_action_type {
  DEFAULT_FLOW_ACTION_TYPE_UPCALL = 359,
  DEFAULT_FLOW_ACTION_TYPE_CT = 357,
  DEFAULT_FLOW_ACTION_TYPE_INNER_RSS = 364,
};

The example code for the hydra_action_type enum is shown below.

enum hydra_action_type {
  HYDRA_ACTION_INVALID = 0x1000,
  HYDRA_ACTION_COUNT,
  HYDRA_ACTION_CUSTOM_ACTION,
};

The example code for the hydra_item_type enum is shown below.

enum hydra_item_type {
  HYDRA_ITEM_INVALID = 0x2000,
  HYDRA_ITEM_MY_CONTROL_MY_TABLE_HDR_IPV6,
  HYDRA_ITEM_MY_CONTROL_MY_TABLE_IDX2_2BIT_2,
  HYDRA_ITEM_MY_CONTROL_MY_TABLE_H,
  HYDRA_ITEM_MY_CONTROL_MY_TABLE_HDR_IPV4,
  HYDRA_ITEM_MY_CONTROL_MY_TABLE_IDX6_4BIT_8,
};
  • The number of HydraGroup enum members is the same as the number of table keywords, which are used for flow table jumps.

    Naming rule: HYDRA_TABLE_<ControlName>_<TableName>

  • The HydraDefaultAction enum has three members, which are used to support built-in actions that are not DPDK actions.

    Naming rule: HYDRA_DEFAULT_ACTION_<ActionName>

  • The number of HydraAction enum members is the same as the number of non-DPDK action keywords, which are used to support non-DPDK actions.

    Naming rule: HYDRA_ACTION_<ActionName>

  • The number of HydraItem enum members is the same as the number of non-DPDK match fields within a table, which are used to support non-DPDK keys.
    • Variable naming rule: HYDRA_ITEM_<ControlName>_<TableName>_<MatchFieldName>
    • Constant naming rule: HYDRA_ITEM_<ControlName>_<TableName>_IDX<Index>_<BitWidth>BIT_<value>

Table Key Information

int table_patterns_my_control_my_table [6] = { 
  HYDRA_ITEM_MY_CONTROL_MY_TABLE_HDR_IPV6,
  HYDRA_ITEM_MY_CONTROL_MY_TABLE_IDX2_2BIT_2,
  RTE_FLOW_ITEM_TYPE_TCP,
  HYDRA_ITEM_MY_CONTROL_MY_TABLE_H,
  HYDRA_ITEM_MY_CONTROL_MY_TABLE_HDR_IPV4,
  HYDRA_ITEM_MY_CONTROL_MY_TABLE_IDX6_4BIT_8,
};

Each table has an int array prefixed with table_patterns. This array informs the user which match fields need to be contained within the table entries. Non-DPDK match fields utilize the macros defined within the HydraItemType enum, whereas DPDK match fields reuse pre-defined DPDK macros, such as RTE_FLOW_ITEM_TYPE_TCP.

Table Action Information

int table_actions_my_control_my_table [7] = {
  HYDRA_ACTION_CT,
  HYDRA_ACTION_COUNT,
  RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
  RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
  RTE_FLOW_ACTION_TYPE_SET_UDP_SRC,
  RTE_FLOW_ACTION_TYPE_SET_UDP_DST,
  HYDRA_ACTION_CUSTOMACTION,
};

Each table has an int array prefixed with table_actions. This array informs the user which actions can be contained within the table entries. Non-DPDK actions utilize the macros defined within the HydraActionType enum, whereas DPDK actions reuse pre-defined DPDK macros, such as RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC.

Hydra Struct Information

typedef struct {
    int32_t a;
    uint32_t b;
    int32_t c;
    uint32_t d;
} hydra_struct_str_t;

The valid value range for each struct member aligns with the range defined on the DSL data plane. Failure to maintain this consistency will result in data truncation or overflow. Examples:

  • DSL data plane definition
    struct s {
        bit<10> a; // The valid value range is [0, 1023].
    }
  • Valid value range on the DPDK control plane
    hydra_struct_s.a = 1023; // The valid value range is [0, 1023].
  • An invalid value on the DPDK control plane
    hydra_struct_s.a = 1024;

Hydra Action Information

A data structure prefixed with hydra_action_data is generated for each action. The following is a DSL code example:

action action_z(bit<8> data_a, bit<8> data_b) {}

Generated result:

typedef struct hydra_action_data_action_z {
uint8_t data_a: 8;
uint8_t data_b: 8;
} __attribute__((packed)) hydra_action_data_action_z;