flexda_custom_construct_key
接口功能
用户构建并下发硬件流表key。
接口格式
int flexda_custom_construct_key ( void *ctx, const struct flexda_custom_info_t *info, struct rte_flow_item *hw_key)
参数说明
参数名 |
参数类型 |
入参/出参 |
说明 |
|---|---|---|---|
ctx |
void * |
入参 |
自定义上下文的地址。提取的头信息也保存其中。 |
info |
struct flexda_custom_info_t * |
入参 |
dpak-ovs提供flexda-ovs读取使用的信息。详情请参见表1。 |
hw_key |
struct rte_flow_item * |
入参 |
该接口组装硬件流表key的地址。 |
函数返回值 |
int |
出参 |
若函数执行成功则返回0,若函数执行失败则返回错误码。 |
使用实例
int flexda_custom_construct_key(void *ctx, flexda_custom_info_t info, struct rte_flow_item *hw_key)
{
struct custom_packet_ctx *custom_ctx = (struct custom_packet_ctx *)ctx;
struct flexda_sub_hdr *out_header = &custom_ctx->out_header;
struct rte_flow_item_eth *eth = NULL;
struct rte_flow_item_port_id *port_id = NULL;
// 根据上下文条件控制组key流程,需要与Hydra里为table定义的key匹配
if (custom_ctx->vlan_poped == 1) { // vlan rx
// 下发vlan id key,需要先调用内存api申请内存,写入key数据后调用插入key api,之后内存管理权限交给框架不需要释放
struct rte_flow_item_vlan *vlan = flexda_calloc(1, sizeof(struct rte_flow_item_vlan));
vlan->tci = custom_ctx->out_header.l2.vlan.vlan_id;
flexda_insert_rte_key(hw_key, -1, vlan, RTE_FLOW_ITEM_TYPE_VLAN);
// 下发vlan eth_type key,Hydra自定义key类型使用匹配的插入key api,提供与Hydra匹配的长度和类型枚举值
uint16_t *encap = flexda_calloc(1, sizeof(uint16_t));
*encap = custom_ctx->out_header.l2.vlan.encap;
flexda_insert_hydra_key(hw_key, -1, encap, sizeof(uint16_t), HYDRA_ITEM_MYMAINPIPE_GENEVE_EXACT_INNER_ETH_TYPE);
return 0;
}
return -EINVAL;
}
父主题: Hook函数