Commit 003f4f9a authored by Rongwei Liu's avatar Rongwei Liu Committed by Saeed Mahameed
Browse files

net/mlx5: DR, Remove mr_addr rkey from struct mlx5dr_icm_chunk



Reduce memory footprint by removing mr_addr and rkey from
mlx5_dr_icm_chunk.
1. mr_addr is calculated by mlx5dr_icm_pool_get_chunk_mr_addr()
2. rkey is calculated by mlx5dr_icm_pool_get_chunk_rkey()
The two new functions are very lightweight and straightforward.

Reduce 8 bytes from struct mlx5_dr_icm_chunk, its current size is
72 bytes.

Signed-off-by: default avatarRongwei Liu <rongweil@nvidia.com>
Reviewed-by: default avatarShun Hao <shunh@nvidia.com>
Reviewed-by: default avatarYevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 8f853365
Loading
Loading
Loading
Loading
+12 −2
Original line number Original line Diff line number Diff line
@@ -57,6 +57,18 @@ static int dr_icm_create_dm_mkey(struct mlx5_core_dev *mdev,
	return mlx5_core_create_mkey(mdev, mkey, in, inlen);
	return mlx5_core_create_mkey(mdev, mkey, in, inlen);
}
}


u64 mlx5dr_icm_pool_get_chunk_mr_addr(struct mlx5dr_icm_chunk *chunk)
{
	u32 offset = mlx5dr_icm_pool_dm_type_to_entry_size(chunk->buddy_mem->pool->icm_type);

	return (u64)offset * chunk->seg;
}

u32 mlx5dr_icm_pool_get_chunk_rkey(struct mlx5dr_icm_chunk *chunk)
{
	return chunk->buddy_mem->icm_mr->mkey;
}

static struct mlx5dr_icm_mr *
static struct mlx5dr_icm_mr *
dr_icm_pool_mr_create(struct mlx5dr_icm_pool *pool)
dr_icm_pool_mr_create(struct mlx5dr_icm_pool *pool)
{
{
@@ -298,8 +310,6 @@ dr_icm_chunk_create(struct mlx5dr_icm_pool *pool,


	offset = mlx5dr_icm_pool_dm_type_to_entry_size(pool->icm_type) * seg;
	offset = mlx5dr_icm_pool_dm_type_to_entry_size(pool->icm_type) * seg;


	chunk->rkey = buddy_mem_pool->icm_mr->mkey;
	chunk->mr_addr = offset;
	chunk->icm_addr =
	chunk->icm_addr =
		(uintptr_t)buddy_mem_pool->icm_mr->icm_start_addr + offset;
		(uintptr_t)buddy_mem_pool->icm_mr->icm_start_addr + offset;
	chunk->num_of_entries =
	chunk->num_of_entries =
+6 −5
Original line number Original line Diff line number Diff line
@@ -453,7 +453,7 @@ int mlx5dr_send_postsend_ste(struct mlx5dr_domain *dmn, struct mlx5dr_ste *ste,
	send_info.write.length = size;
	send_info.write.length = size;
	send_info.write.lkey = 0;
	send_info.write.lkey = 0;
	send_info.remote_addr = mlx5dr_ste_get_mr_addr(ste) + offset;
	send_info.remote_addr = mlx5dr_ste_get_mr_addr(ste) + offset;
	send_info.rkey = ste->htbl->chunk->rkey;
	send_info.rkey = mlx5dr_icm_pool_get_chunk_rkey(ste->htbl->chunk);


	return dr_postsend_icm_data(dmn, &send_info);
	return dr_postsend_icm_data(dmn, &send_info);
}
}
@@ -512,7 +512,7 @@ int mlx5dr_send_postsend_htbl(struct mlx5dr_domain *dmn,
		send_info.write.lkey = 0;
		send_info.write.lkey = 0;
		send_info.remote_addr =
		send_info.remote_addr =
			mlx5dr_ste_get_mr_addr(htbl->ste_arr + ste_index);
			mlx5dr_ste_get_mr_addr(htbl->ste_arr + ste_index);
		send_info.rkey = htbl->chunk->rkey;
		send_info.rkey = mlx5dr_icm_pool_get_chunk_rkey(htbl->chunk);


		ret = dr_postsend_icm_data(dmn, &send_info);
		ret = dr_postsend_icm_data(dmn, &send_info);
		if (ret)
		if (ret)
@@ -569,7 +569,7 @@ int mlx5dr_send_postsend_formatted_htbl(struct mlx5dr_domain *dmn,
		send_info.write.lkey = 0;
		send_info.write.lkey = 0;
		send_info.remote_addr =
		send_info.remote_addr =
			mlx5dr_ste_get_mr_addr(htbl->ste_arr + ste_index);
			mlx5dr_ste_get_mr_addr(htbl->ste_arr + ste_index);
		send_info.rkey = htbl->chunk->rkey;
		send_info.rkey = mlx5dr_icm_pool_get_chunk_rkey(htbl->chunk);


		ret = dr_postsend_icm_data(dmn, &send_info);
		ret = dr_postsend_icm_data(dmn, &send_info);
		if (ret)
		if (ret)
@@ -591,8 +591,9 @@ int mlx5dr_send_postsend_action(struct mlx5dr_domain *dmn,
	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 =
	send_info.rkey = action->rewrite->chunk->rkey;
		mlx5dr_icm_pool_get_chunk_mr_addr(action->rewrite->chunk);
	send_info.rkey = mlx5dr_icm_pool_get_chunk_rkey(action->rewrite->chunk);


	ret = dr_postsend_icm_data(dmn, &send_info);
	ret = dr_postsend_icm_data(dmn, &send_info);


+1 −1
Original line number Original line Diff line number Diff line
@@ -122,7 +122,7 @@ u64 mlx5dr_ste_get_mr_addr(struct mlx5dr_ste *ste)
{
{
	u32 index = ste - ste->htbl->ste_arr;
	u32 index = ste - ste->htbl->ste_arr;


	return ste->htbl->chunk->mr_addr + DR_STE_SIZE * index;
	return mlx5dr_icm_pool_get_chunk_mr_addr(ste->htbl->chunk) + DR_STE_SIZE * index;
}
}


struct list_head *mlx5dr_ste_get_miss_list(struct mlx5dr_ste *ste)
struct list_head *mlx5dr_ste_get_miss_list(struct mlx5dr_ste *ste)
+3 −2
Original line number Original line Diff line number Diff line
@@ -1097,11 +1097,9 @@ int mlx5dr_rule_get_reverse_rule_members(struct mlx5dr_ste **ste_arr,
struct mlx5dr_icm_chunk {
struct mlx5dr_icm_chunk {
	struct mlx5dr_icm_buddy_mem *buddy_mem;
	struct mlx5dr_icm_buddy_mem *buddy_mem;
	struct list_head chunk_list;
	struct list_head chunk_list;
	u32 rkey;
	u32 num_of_entries;
	u32 num_of_entries;
	u32 byte_size;
	u32 byte_size;
	u64 icm_addr;
	u64 icm_addr;
	u64 mr_addr;


	/* indicates the index of this chunk in the whole memory,
	/* indicates the index of this chunk in the whole memory,
	 * used for deleting the chunk from the buddy
	 * used for deleting the chunk from the buddy
@@ -1146,6 +1144,9 @@ int mlx5dr_matcher_select_builders(struct mlx5dr_matcher *matcher,
				   enum mlx5dr_ipv outer_ipv,
				   enum mlx5dr_ipv outer_ipv,
				   enum mlx5dr_ipv inner_ipv);
				   enum mlx5dr_ipv inner_ipv);


u64 mlx5dr_icm_pool_get_chunk_mr_addr(struct mlx5dr_icm_chunk *chunk);
u32 mlx5dr_icm_pool_get_chunk_rkey(struct mlx5dr_icm_chunk *chunk);

static inline int
static inline int
mlx5dr_icm_pool_dm_type_to_entry_size(enum mlx5dr_icm_type icm_type)
mlx5dr_icm_pool_dm_type_to_entry_size(enum mlx5dr_icm_type icm_type)
{
{