---
title: flexda_custom_construct_action
description: "用户构建下发硬件流表action。"
url: https://www.hikunpeng.com/document/detail/zh/flexda/api/dpak_api028.html
sourcePath: /source/zh/flexda/api/dpak_api028.html
indexId: 227ff31cf8df9f4465f7541de72477f439b14481d4018eacc666fd71b7018daf38
---
# flexda_custom_construct_action

#### 接口功能

用户构建下发硬件流表action。


#### 接口格式

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


#### 参数说明

| 参数名 | 参数类型 | 入参/出参 | 说明 |
| --- | --- | --- | --- |
| ctx | void \* | 入参 | 自定义上下文的地址。提取的头信息也保存其中。 |
| info | struct flexda\_custom\_info\_t \* | 入参 | dpak\-ovs提供flexda\-ovs读取使用的信息。详情可参见表1。 |
| hw\_action | struct rte\_flow\_action \* | 入参 | 该参数包含硬件流表action的地址，其中已保存拼接跳表后的软件流表action。 |
| 函数返回值 | int | 出参 | 若函数执行成功则返回0，若函数执行失败则返回错误码。 |


**表1 struct flexda_custom_info_t**

| 属性类型 | 属性名称 | 属性描述 |
| --- | --- | --- |
| uint16\_t | input\_port\_id | 当前OVS卸载报文的源input端口。 |
| dp\_packet \* | pkt | 当前OVS卸载的报文。 |
| rte\_flow\_action \* | src\_actions | 当前OVS卸载的软件流表action。 |


#### 使用实例

```
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;
// 根据上下文条件控制组action流程，需要保证下发Hydra里table支持的action
#define HWOFF_FLOW_ACT_DEF_INNER_RSS 364
if (custom_ctx->vlan_poped == 1) {
// 下发rss action，需要先调用内存api申请内存，写入action数据后调用插入action api，之后内存管理权限交给框架不需要释放
uint32_t *rss = flexda_calloc(1, sizeof(uint32_t));
// 需注意action下发data要进行字节大小端转换
*rss = htonl(1);
// Hydra自定义action类型使用匹配的插入action api，提供与Hydra匹配的长度和类型枚举值
flexda_insert_hydra_action(hw_action, -1, rss, sizeof(uint32_t), HWOFF_FLOW_ACT_DEF_INNER_RSS);
}
return 0;
}
```
