Commit 5c4f9b6e authored by Rongwei Liu's avatar Rongwei Liu Committed by Saeed Mahameed
Browse files

net/mlx5: DR, Remove icm_addr from mlx5dr_icm_chunk to reduce memory



It can be calculated quickly from buddy memory pool by
function mlx5dr_icm_pool_get_chunk_icm_addr().
This function is very lightweight and straightforward.

Reduce 8 bytes and current size of struct mlx5_dr_icm_chunk
is 64 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 003f4f9a
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -570,6 +570,7 @@ int mlx5dr_actions_build_ste_arr(struct mlx5dr_matcher *matcher,

	for (i = 0; i < num_actions; i++) {
		struct mlx5dr_action_dest_tbl *dest_tbl;
		struct mlx5dr_icm_chunk *chunk;
		struct mlx5dr_action *action;
		int max_actions_type = 1;
		u32 action_type;
@@ -598,9 +599,9 @@ int mlx5dr_actions_build_ste_arr(struct mlx5dr_matcher *matcher,
						   matcher->tbl->level,
						   dest_tbl->tbl->level);
				}
				attr.final_icm_addr = rx_rule ?
					dest_tbl->tbl->rx.s_anchor->chunk->icm_addr :
					dest_tbl->tbl->tx.s_anchor->chunk->icm_addr;
				chunk = rx_rule ? dest_tbl->tbl->rx.s_anchor->chunk :
					dest_tbl->tbl->tx.s_anchor->chunk;
				attr.final_icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(chunk);
			} else {
				struct mlx5dr_cmd_query_flow_table_details output;
				int ret;
@@ -1123,7 +1124,8 @@ dr_action_create_reformat_action(struct mlx5dr_domain *dmn,
		}

		action->rewrite->data = (void *)hw_actions;
		action->rewrite->index = (action->rewrite->chunk->icm_addr -
		action->rewrite->index = (mlx5dr_icm_pool_get_chunk_icm_addr
					  (action->rewrite->chunk) -
					 dmn->info.caps.hdr_modify_icm_addr) /
					 ACTION_CACHE_LINE_SIZE;

@@ -1702,7 +1704,7 @@ static int dr_action_create_modify_action(struct mlx5dr_domain *dmn,
	action->rewrite->modify_ttl = modify_ttl;
	action->rewrite->data = (u8 *)hw_actions;
	action->rewrite->num_of_actions = num_hw_actions;
	action->rewrite->index = (chunk->icm_addr -
	action->rewrite->index = (mlx5dr_icm_pool_get_chunk_icm_addr(chunk) -
				  dmn->info.caps.hdr_modify_icm_addr) /
				  ACTION_CACHE_LINE_SIZE;

+8 −3
Original line number Diff line number Diff line
@@ -346,16 +346,19 @@ dr_dump_matcher_rx_tx(struct seq_file *file, bool is_rx,
		      const u64 matcher_id)
{
	enum dr_dump_rec_type rec_type;
	u64 s_icm_addr, e_icm_addr;
	int i, ret;

	rec_type = is_rx ? DR_DUMP_REC_TYPE_MATCHER_RX :
			   DR_DUMP_REC_TYPE_MATCHER_TX;

	s_icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(matcher_rx_tx->s_htbl->chunk);
	e_icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(matcher_rx_tx->e_anchor->chunk);
	seq_printf(file, "%d,0x%llx,0x%llx,%d,0x%llx,0x%llx\n",
		   rec_type, DR_DBG_PTR_TO_ID(matcher_rx_tx),
		   matcher_id, matcher_rx_tx->num_of_builders,
		   dr_dump_icm_to_idx(matcher_rx_tx->s_htbl->chunk->icm_addr),
		   dr_dump_icm_to_idx(matcher_rx_tx->e_anchor->chunk->icm_addr));
		   dr_dump_icm_to_idx(s_icm_addr),
		   dr_dump_icm_to_idx(e_icm_addr));

	for (i = 0; i < matcher_rx_tx->num_of_builders; i++) {
		ret = dr_dump_matcher_builder(file,
@@ -426,12 +429,14 @@ dr_dump_table_rx_tx(struct seq_file *file, bool is_rx,
		    const u64 table_id)
{
	enum dr_dump_rec_type rec_type;
	u64 s_icm_addr;

	rec_type = is_rx ? DR_DUMP_REC_TYPE_TABLE_RX :
			   DR_DUMP_REC_TYPE_TABLE_TX;

	s_icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(table_rx_tx->s_anchor->chunk);
	seq_printf(file, "%d,0x%llx,0x%llx\n", rec_type, table_id,
		   dr_dump_icm_to_idx(table_rx_tx->s_anchor->chunk->icm_addr));
		   dr_dump_icm_to_idx(s_icm_addr));

	return 0;
}
+7 −2
Original line number Diff line number Diff line
@@ -69,6 +69,13 @@ u32 mlx5dr_icm_pool_get_chunk_rkey(struct mlx5dr_icm_chunk *chunk)
	return chunk->buddy_mem->icm_mr->mkey;
}

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

	return (u64)chunk->buddy_mem->icm_mr->icm_start_addr + size * chunk->seg;
}

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

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

	chunk->icm_addr =
		(uintptr_t)buddy_mem_pool->icm_mr->icm_start_addr + offset;
	chunk->num_of_entries =
		mlx5dr_icm_pool_chunk_size_to_entries(chunk_size);
	chunk->byte_size =
+1 −1
Original line number Diff line number Diff line
@@ -705,7 +705,7 @@ static int dr_nic_matcher_connect(struct mlx5dr_domain *dmn,

	/* Connect start hash table to end anchor */
	info.type = CONNECT_MISS;
	info.miss_icm_addr = curr_nic_matcher->e_anchor->chunk->icm_addr;
	info.miss_icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(curr_nic_matcher->e_anchor->chunk);
	ret = mlx5dr_ste_htbl_init_and_postsend(dmn, nic_dmn,
						curr_nic_matcher->s_htbl,
						&info, false);
+11 −8
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ dr_rule_create_collision_htbl(struct mlx5dr_matcher *matcher,
	struct mlx5dr_ste_ctx *ste_ctx = dmn->ste_ctx;
	struct mlx5dr_ste_htbl *new_htbl;
	struct mlx5dr_ste *ste;
	u64 icm_addr;

	/* Create new table for miss entry */
	new_htbl = mlx5dr_ste_htbl_alloc(dmn->ste_icm_pool,
@@ -54,8 +55,8 @@ dr_rule_create_collision_htbl(struct mlx5dr_matcher *matcher,

	/* One and only entry, never grows */
	ste = new_htbl->ste_arr;
	mlx5dr_ste_set_miss_addr(ste_ctx, hw_ste,
				 nic_matcher->e_anchor->chunk->icm_addr);
	icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(nic_matcher->e_anchor->chunk);
	mlx5dr_ste_set_miss_addr(ste_ctx, hw_ste, icm_addr);
	mlx5dr_htbl_get(new_htbl);

	return ste;
@@ -235,6 +236,7 @@ dr_rule_rehash_copy_ste(struct mlx5dr_matcher *matcher,
	bool use_update_list = false;
	u8 hw_ste[DR_STE_SIZE] = {};
	struct mlx5dr_ste *new_ste;
	u64 icm_addr;
	int new_idx;
	u8 sb_idx;

@@ -243,9 +245,9 @@ dr_rule_rehash_copy_ste(struct mlx5dr_matcher *matcher,
	mlx5dr_ste_set_bit_mask(hw_ste, nic_matcher->ste_builder[sb_idx].bit_mask);

	/* Copy STE control and tag */
	icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(nic_matcher->e_anchor->chunk);
	memcpy(hw_ste, cur_ste->hw_ste, DR_STE_SIZE_REDUCED);
	mlx5dr_ste_set_miss_addr(dmn->ste_ctx, hw_ste,
				 nic_matcher->e_anchor->chunk->icm_addr);
	mlx5dr_ste_set_miss_addr(dmn->ste_ctx, hw_ste, icm_addr);

	new_idx = mlx5dr_ste_calc_hash_index(hw_ste, new_htbl);
	new_ste = &new_htbl->ste_arr[new_idx];
@@ -398,7 +400,7 @@ dr_rule_rehash_htbl(struct mlx5dr_rule *rule,

	/* Write new table to HW */
	info.type = CONNECT_MISS;
	info.miss_icm_addr = nic_matcher->e_anchor->chunk->icm_addr;
	info.miss_icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(nic_matcher->e_anchor->chunk);
	mlx5dr_ste_set_formatted_ste(dmn->ste_ctx,
				     dmn->info.caps.gvmi,
				     nic_dmn->type,
@@ -447,7 +449,7 @@ dr_rule_rehash_htbl(struct mlx5dr_rule *rule,
		 */
		mlx5dr_ste_set_hit_addr(dmn->ste_ctx,
					prev_htbl->ste_arr[0].hw_ste,
					new_htbl->chunk->icm_addr,
					mlx5dr_icm_pool_get_chunk_icm_addr(new_htbl->chunk),
					new_htbl->chunk->num_of_entries);

		ste_to_update = &prev_htbl->ste_arr[0];
@@ -755,6 +757,7 @@ static int dr_rule_handle_empty_entry(struct mlx5dr_matcher *matcher,
{
	struct mlx5dr_domain *dmn = matcher->tbl->dmn;
	struct mlx5dr_ste_send_info *ste_info;
	u64 icm_addr;

	/* Take ref on table, only on first time this ste is used */
	mlx5dr_htbl_get(cur_htbl);
@@ -762,8 +765,8 @@ static int dr_rule_handle_empty_entry(struct mlx5dr_matcher *matcher,
	/* new entry -> new branch */
	list_add_tail(&ste->miss_list_node, miss_list);

	mlx5dr_ste_set_miss_addr(dmn->ste_ctx, hw_ste,
				 nic_matcher->e_anchor->chunk->icm_addr);
	icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(nic_matcher->e_anchor->chunk);
	mlx5dr_ste_set_miss_addr(dmn->ste_ctx, hw_ste, icm_addr);

	ste->ste_chain_location = ste_location;

Loading