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, ...@@ -572,12 +572,12 @@ int mlx5dr_send_postsend_action(struct mlx5dr_domain *dmn,
struct postsend_info send_info = {}; struct postsend_info send_info = {};
int ret; int ret;
send_info.write.addr = (uintptr_t)action->rewrite.data; send_info.write.addr = (uintptr_t)action->rewrite->data;
send_info.write.length = action->rewrite.num_of_actions * send_info.write.length = action->rewrite->num_of_actions *
DR_MODIFY_ACTION_SIZE; DR_MODIFY_ACTION_SIZE;
send_info.write.lkey = 0; send_info.write.lkey = 0;
send_info.remote_addr = action->rewrite.chunk->mr_addr; send_info.remote_addr = action->rewrite->chunk->mr_addr;
send_info.rkey = action->rewrite.chunk->rkey; send_info.rkey = action->rewrite->chunk->rkey;
ret = dr_postsend_icm_data(dmn, &send_info); ret = dr_postsend_icm_data(dmn, &send_info);
......
...@@ -29,7 +29,7 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, ...@@ -29,7 +29,7 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
last_htbl = tbl->rx.s_anchor; last_htbl = tbl->rx.s_anchor;
tbl->rx.default_icm_addr = action ? 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; tbl->rx.nic_dmn->default_icm_addr;
info.type = CONNECT_MISS; info.type = CONNECT_MISS;
...@@ -53,7 +53,7 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, ...@@ -53,7 +53,7 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
last_htbl = tbl->tx.s_anchor; last_htbl = tbl->tx.s_anchor;
tbl->tx.default_icm_addr = action ? 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; tbl->tx.nic_dmn->default_icm_addr;
info.type = CONNECT_MISS; info.type = CONNECT_MISS;
......
...@@ -806,11 +806,7 @@ struct mlx5dr_ste_action_modify_field { ...@@ -806,11 +806,7 @@ struct mlx5dr_ste_action_modify_field {
u8 l4_type; u8 l4_type;
}; };
struct mlx5dr_action { struct mlx5dr_action_rewrite {
enum mlx5dr_action_type action_type;
refcount_t refcount;
union {
struct {
struct mlx5dr_domain *dmn; struct mlx5dr_domain *dmn;
struct mlx5dr_icm_chunk *chunk; struct mlx5dr_icm_chunk *chunk;
u8 *data; u8 *data;
...@@ -819,13 +815,15 @@ struct mlx5dr_action { ...@@ -819,13 +815,15 @@ struct mlx5dr_action {
u8 allow_rx:1; u8 allow_rx:1;
u8 allow_tx:1; u8 allow_tx:1;
u8 modify_ttl:1; u8 modify_ttl:1;
} rewrite; };
struct {
struct mlx5dr_action_reformat {
struct mlx5dr_domain *dmn; struct mlx5dr_domain *dmn;
u32 reformat_id; u32 reformat_id;
u32 reformat_size; u32 reformat_size;
} reformat; };
struct {
struct mlx5dr_action_dest_tbl {
u8 is_fw_tbl:1; u8 is_fw_tbl:1;
union { union {
struct mlx5dr_table *tbl; struct mlx5dr_table *tbl;
...@@ -840,19 +838,39 @@ struct mlx5dr_action { ...@@ -840,19 +838,39 @@ struct mlx5dr_action {
u32 num_of_ref_actions; u32 num_of_ref_actions;
} fw_tbl; } fw_tbl;
}; };
} dest_tbl; };
struct {
struct mlx5dr_action_ctr {
u32 ctr_id; u32 ctr_id;
u32 offeset; u32 offeset;
} ctr; };
struct {
struct mlx5dr_action_vport {
struct mlx5dr_domain *dmn; struct mlx5dr_domain *dmn;
struct mlx5dr_cmd_vport_cap *caps; struct mlx5dr_cmd_vport_cap *caps;
} vport; };
struct {
struct mlx5dr_action_push_vlan {
u32 vlan_hdr; /* tpid_pcp_dei_vid */ u32 vlan_hdr; /* tpid_pcp_dei_vid */
} push_vlan; };
struct mlx5dr_action_flow_tag {
u32 flow_tag; u32 flow_tag;
};
struct mlx5dr_action {
enum mlx5dr_action_type action_type;
refcount_t refcount;
union {
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