Lines Matching refs:part
74 struct mlxsw_sp1_kvdl_part *part, *min_part = NULL; in mlxsw_sp1_kvdl_alloc_size_part() local
78 part = kvdl->parts[i]; in mlxsw_sp1_kvdl_alloc_size_part()
79 if (alloc_size <= part->info.alloc_size && in mlxsw_sp1_kvdl_alloc_size_part()
81 part->info.alloc_size <= min_part->info.alloc_size)) in mlxsw_sp1_kvdl_alloc_size_part()
82 min_part = part; in mlxsw_sp1_kvdl_alloc_size_part()
91 struct mlxsw_sp1_kvdl_part *part; in mlxsw_sp1_kvdl_index_part() local
95 part = kvdl->parts[i]; in mlxsw_sp1_kvdl_index_part()
96 if (kvdl_index >= part->info.start_index && in mlxsw_sp1_kvdl_index_part()
97 kvdl_index <= part->info.end_index) in mlxsw_sp1_kvdl_index_part()
98 return part; in mlxsw_sp1_kvdl_index_part()
118 static int mlxsw_sp1_kvdl_part_alloc(struct mlxsw_sp1_kvdl_part *part, in mlxsw_sp1_kvdl_part_alloc() argument
121 const struct mlxsw_sp1_kvdl_part_info *info = &part->info; in mlxsw_sp1_kvdl_part_alloc()
126 entry_index = find_first_zero_bit(part->usage, nr_entries); in mlxsw_sp1_kvdl_part_alloc()
129 __set_bit(entry_index, part->usage); in mlxsw_sp1_kvdl_part_alloc()
136 static void mlxsw_sp1_kvdl_part_free(struct mlxsw_sp1_kvdl_part *part, in mlxsw_sp1_kvdl_part_free() argument
139 const struct mlxsw_sp1_kvdl_part_info *info = &part->info; in mlxsw_sp1_kvdl_part_free()
143 __clear_bit(entry_index, part->usage); in mlxsw_sp1_kvdl_part_free()
152 struct mlxsw_sp1_kvdl_part *part; in mlxsw_sp1_kvdl_alloc() local
157 part = mlxsw_sp1_kvdl_alloc_size_part(kvdl, entry_count); in mlxsw_sp1_kvdl_alloc()
158 if (IS_ERR(part)) in mlxsw_sp1_kvdl_alloc()
159 return PTR_ERR(part); in mlxsw_sp1_kvdl_alloc()
161 return mlxsw_sp1_kvdl_part_alloc(part, p_entry_index); in mlxsw_sp1_kvdl_alloc()
169 struct mlxsw_sp1_kvdl_part *part; in mlxsw_sp1_kvdl_free() local
171 part = mlxsw_sp1_kvdl_index_part(kvdl, entry_index); in mlxsw_sp1_kvdl_free()
172 if (IS_ERR(part)) in mlxsw_sp1_kvdl_free()
174 mlxsw_sp1_kvdl_part_free(part, entry_index); in mlxsw_sp1_kvdl_free()
184 struct mlxsw_sp1_kvdl_part *part; in mlxsw_sp1_kvdl_alloc_size_query() local
186 part = mlxsw_sp1_kvdl_alloc_size_part(kvdl, entry_count); in mlxsw_sp1_kvdl_alloc_size_query()
187 if (IS_ERR(part)) in mlxsw_sp1_kvdl_alloc_size_query()
188 return PTR_ERR(part); in mlxsw_sp1_kvdl_alloc_size_query()
190 *p_alloc_size = part->info.alloc_size; in mlxsw_sp1_kvdl_alloc_size_query()
195 static void mlxsw_sp1_kvdl_part_update(struct mlxsw_sp1_kvdl_part *part, in mlxsw_sp1_kvdl_part_update() argument
200 part->info.end_index = size - 1; in mlxsw_sp1_kvdl_part_update()
202 part->info.start_index = part_prev->info.end_index + 1; in mlxsw_sp1_kvdl_part_update()
203 part->info.end_index = part->info.start_index + size - 1; in mlxsw_sp1_kvdl_part_update()
213 struct mlxsw_sp1_kvdl_part *part; in mlxsw_sp1_kvdl_part_init() local
227 part = kzalloc(struct_size(part, usage, BITS_TO_LONGS(nr_entries)), in mlxsw_sp1_kvdl_part_init()
229 if (!part) in mlxsw_sp1_kvdl_part_init()
232 memcpy(&part->info, info, sizeof(part->info)); in mlxsw_sp1_kvdl_part_init()
235 mlxsw_sp1_kvdl_part_update(part, part_prev, resource_size); in mlxsw_sp1_kvdl_part_init()
236 return part; in mlxsw_sp1_kvdl_part_init()
239 static void mlxsw_sp1_kvdl_part_fini(struct mlxsw_sp1_kvdl_part *part) in mlxsw_sp1_kvdl_part_fini() argument
241 kfree(part); in mlxsw_sp1_kvdl_part_fini()
277 static u64 mlxsw_sp1_kvdl_part_occ(struct mlxsw_sp1_kvdl_part *part) in mlxsw_sp1_kvdl_part_occ() argument
279 const struct mlxsw_sp1_kvdl_part_info *info = &part->info; in mlxsw_sp1_kvdl_part_occ()
287 while ((bit = find_next_bit(part->usage, nr_entries, bit + 1)) in mlxsw_sp1_kvdl_part_occ()
308 struct mlxsw_sp1_kvdl_part *part; in mlxsw_sp1_kvdl_single_occ_get() local
310 part = kvdl->parts[MLXSW_SP1_KVDL_PART_ID_SINGLE]; in mlxsw_sp1_kvdl_single_occ_get()
311 return mlxsw_sp1_kvdl_part_occ(part); in mlxsw_sp1_kvdl_single_occ_get()
317 struct mlxsw_sp1_kvdl_part *part; in mlxsw_sp1_kvdl_chunks_occ_get() local
319 part = kvdl->parts[MLXSW_SP1_KVDL_PART_ID_CHUNKS]; in mlxsw_sp1_kvdl_chunks_occ_get()
320 return mlxsw_sp1_kvdl_part_occ(part); in mlxsw_sp1_kvdl_chunks_occ_get()
326 struct mlxsw_sp1_kvdl_part *part; in mlxsw_sp1_kvdl_large_chunks_occ_get() local
328 part = kvdl->parts[MLXSW_SP1_KVDL_PART_ID_LARGE_CHUNKS]; in mlxsw_sp1_kvdl_large_chunks_occ_get()
329 return mlxsw_sp1_kvdl_part_occ(part); in mlxsw_sp1_kvdl_large_chunks_occ_get()