Rate This Document
Findability
Accuracy
Completeness
Readability

flexda_custom_construct_action

Function

Constructs and issues an action to a hardware flow table.

Syntax

int flexda_custom_construct_action ( void *ctx, const struct flexda_custom_info_t *info, struct rte_flow_action *hw_action)

Parameters

Parameter

Type

Input/Output

Description

ctx

void *

Input

Pointer to the custom context. It also stores the extracted header information.

info

struct flexda_custom_info_t *

Input

Information provided by dpak-ovs for flexda-ovs to read. For details, see Table 1.

hw_action

struct rte_flow_action *

Input

Address of the hardware flow table action. This address already contains the software flow table actions after jump table concatenation.

Return value

int

Output

The function returns 0 upon successful execution; otherwise, it returns an error code.

Table 1 struct flexda_custom_info_t

Attribute Type

Attribute Name

Description

uint16_t

input_port_id

Source input port of the current packet in OVS offload.

dp_packet *

pkt

Current packet in OVS offload.

rte_flow_action *

src_actions

Actions of the current software flow table in OVS offload.

Example

int flexda_custom_construct_action(void *ctx, flexda_custom_info_t info, struct rte_flow_action *hw_action)
{
    struct custom_packet_ctx *custom_ctx = (struct custom_packet_ctx *)ctx;
    // Control the action construction process based on context conditions. The constructed action must match the action definitions specified for the table in Hydra code.
    #define HWOFF_FLOW_ACT_DEF_INNER_RSS 364
    if (custom_ctx->vlan_poped == 1) {
        // Issue the RSS action. First, call the memory API to allocate memory. After the action data is written, call the action insertion API. Then, the memory management permission is handed over to the framework and it does not need to be released.
        uint32_t *rss = flexda_calloc(1, sizeof(uint32_t));
        // Note that the action data must undergo endianness conversion when issuing it to the hardware flow table.
        *rss = htonl(1);
        // Use the matching action insertion API with the custom action types defined in Hydra, and provide the length and type enumeration values that meet the Hydra code requirements.
        flexda_insert_hydra_action(hw_action, -1, rss, sizeof(uint32_t), HWOFF_FLOW_ACT_DEF_INNER_RSS);
    }
    return 0;
}