Commit 9dac2966 authored by Jianbo Liu's avatar Jianbo Liu Committed by Saeed Mahameed

net/mlx5: DR, Use variably sized data structures for different actions

mlx5dr_action is a generally used data structure, and there is an
union for different types of actions in it. The size of mlx5dr_action
is about 72 bytes, but for those actions with fewer fields, most of
the allocated memory is wasted.
Remove this union, and mlx5dr_action becomes a generic action header.
Then actions are dynamically allocated with needed memory, the data
for each action is stored right after the header.
Signed-off-by: default avatarJianbo Liu <jianbol@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent a74ed24c
......@@ -572,12 +572,12 @@ int mlx5dr_send_postsend_action(struct mlx5dr_domain *dmn,
struct postsend_info send_info = {};
int ret;
send_info.write.addr = (uintptr_t)action->rewrite.data;
send_info.write.length = action->rewrite.num_of_actions *
send_info.write.addr = (uintptr_t)action->rewrite->data;
send_info.write.length = action->rewrite->num_of_actions *
DR_MODIFY_ACTION_SIZE;
send_info.write.lkey = 0;
send_info.remote_addr = action->rewrite.chunk->mr_addr;
send_info.rkey = action->rewrite.chunk->rkey;
send_info.remote_addr = action->rewrite->chunk->mr_addr;
send_info.rkey = action->rewrite->chunk->rkey;
ret = dr_postsend_icm_data(dmn, &send_info);
......
......@@ -29,7 +29,7 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
last_htbl = tbl->rx.s_anchor;
tbl->rx.default_icm_addr = action ?
action->dest_tbl.tbl->rx.s_anchor->chunk->icm_addr :
action->dest_tbl->tbl->rx.s_anchor->chunk->icm_addr :
tbl->rx.nic_dmn->default_icm_addr;
info.type = CONNECT_MISS;
......@@ -53,7 +53,7 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
last_htbl = tbl->tx.s_anchor;
tbl->tx.default_icm_addr = action ?
action->dest_tbl.tbl->tx.s_anchor->chunk->icm_addr :
action->dest_tbl->tbl->tx.s_anchor->chunk->icm_addr :
tbl->tx.nic_dmn->default_icm_addr;
info.type = CONNECT_MISS;
......
......@@ -806,53 +806,71 @@ struct mlx5dr_ste_action_modify_field {
u8 l4_type;
};
struct mlx5dr_action_rewrite {
struct mlx5dr_domain *dmn;
struct mlx5dr_icm_chunk *chunk;
u8 *data;
u16 num_of_actions;
u32 index;
u8 allow_rx:1;
u8 allow_tx:1;
u8 modify_ttl:1;
};
struct mlx5dr_action_reformat {
struct mlx5dr_domain *dmn;
u32 reformat_id;
u32 reformat_size;
};
struct mlx5dr_action_dest_tbl {
u8 is_fw_tbl:1;
union {
struct mlx5dr_table *tbl;
struct {
struct mlx5dr_domain *dmn;
u32 id;
u32 group_id;
enum fs_flow_table_type type;
u64 rx_icm_addr;
u64 tx_icm_addr;
struct mlx5dr_action **ref_actions;
u32 num_of_ref_actions;
} fw_tbl;
};
};
struct mlx5dr_action_ctr {
u32 ctr_id;
u32 offeset;
};
struct mlx5dr_action_vport {
struct mlx5dr_domain *dmn;
struct mlx5dr_cmd_vport_cap *caps;
};
struct mlx5dr_action_push_vlan {
u32 vlan_hdr; /* tpid_pcp_dei_vid */
};
struct mlx5dr_action_flow_tag {
u32 flow_tag;
};
struct mlx5dr_action {
enum mlx5dr_action_type action_type;
refcount_t refcount;
union {
struct {
struct mlx5dr_domain *dmn;
struct mlx5dr_icm_chunk *chunk;
u8 *data;
u16 num_of_actions;
u32 index;
u8 allow_rx:1;
u8 allow_tx:1;
u8 modify_ttl:1;
} rewrite;
struct {
struct mlx5dr_domain *dmn;
u32 reformat_id;
u32 reformat_size;
} reformat;
struct {
u8 is_fw_tbl:1;
union {
struct mlx5dr_table *tbl;
struct {
struct mlx5dr_domain *dmn;
u32 id;
u32 group_id;
enum fs_flow_table_type type;
u64 rx_icm_addr;
u64 tx_icm_addr;
struct mlx5dr_action **ref_actions;
u32 num_of_ref_actions;
} fw_tbl;
};
} dest_tbl;
struct {
u32 ctr_id;
u32 offeset;
} ctr;
struct {
struct mlx5dr_domain *dmn;
struct mlx5dr_cmd_vport_cap *caps;
} vport;
struct {
u32 vlan_hdr; /* tpid_pcp_dei_vid */
} push_vlan;
u32 flow_tag;
void *data;
struct mlx5dr_action_rewrite *rewrite;
struct mlx5dr_action_reformat *reformat;
struct mlx5dr_action_dest_tbl *dest_tbl;
struct mlx5dr_action_ctr *ctr;
struct mlx5dr_action_vport *vport;
struct mlx5dr_action_push_vlan *push_vlan;
struct mlx5dr_action_flow_tag *flow_tag;
};
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment