Lines Matching refs:part

56 static int mlxsw_sp2_kvdl_part_find_zero_bits(struct mlxsw_sp2_kvdl_part *part,  in mlxsw_sp2_kvdl_part_find_zero_bits()  argument
65 start_bit = part->last_allocated_bit + 1; in mlxsw_sp2_kvdl_part_find_zero_bits()
66 if (start_bit == part->usage_bit_count) in mlxsw_sp2_kvdl_part_find_zero_bits()
70 bit = find_next_zero_bit(part->usage, part->usage_bit_count, bit); in mlxsw_sp2_kvdl_part_find_zero_bits()
71 if (!wrap && bit + bit_count >= part->usage_bit_count) { in mlxsw_sp2_kvdl_part_find_zero_bits()
79 if (test_bit(bit + i, part->usage)) { in mlxsw_sp2_kvdl_part_find_zero_bits()
88 static int mlxsw_sp2_kvdl_part_alloc(struct mlxsw_sp2_kvdl_part *part, in mlxsw_sp2_kvdl_part_alloc() argument
97 bit_count = DIV_ROUND_UP(size, part->indexes_per_usage_bit); in mlxsw_sp2_kvdl_part_alloc()
98 err = mlxsw_sp2_kvdl_part_find_zero_bits(part, bit_count, &bit); in mlxsw_sp2_kvdl_part_alloc()
102 __set_bit(bit + i, part->usage); in mlxsw_sp2_kvdl_part_alloc()
103 *p_kvdl_index = bit * part->indexes_per_usage_bit; in mlxsw_sp2_kvdl_part_alloc()
125 struct mlxsw_sp2_kvdl_part *part, in mlxsw_sp2_kvdl_part_free() argument
134 err = mlxsw_sp2_kvdl_rec_del(mlxsw_sp, part->info->res_type, in mlxsw_sp2_kvdl_part_free()
139 bit_count = DIV_ROUND_UP(size, part->indexes_per_usage_bit); in mlxsw_sp2_kvdl_part_free()
140 bit = kvdl_index / part->indexes_per_usage_bit; in mlxsw_sp2_kvdl_part_free()
142 __clear_bit(bit + i, part->usage); in mlxsw_sp2_kvdl_part_free()
152 struct mlxsw_sp2_kvdl_part *part = kvdl->parts[type]; in mlxsw_sp2_kvdl_alloc() local
154 return mlxsw_sp2_kvdl_part_alloc(part, size, p_entry_index); in mlxsw_sp2_kvdl_alloc()
164 struct mlxsw_sp2_kvdl_part *part = kvdl->parts[type]; in mlxsw_sp2_kvdl_free() local
166 return mlxsw_sp2_kvdl_part_free(mlxsw_sp, part, size, entry_index); in mlxsw_sp2_kvdl_free()
184 struct mlxsw_sp2_kvdl_part *part; in mlxsw_sp2_kvdl_part_init() local
206 part = kzalloc(sizeof(*part) + usage_size, GFP_KERNEL); in mlxsw_sp2_kvdl_part_init()
207 if (!part) in mlxsw_sp2_kvdl_part_init()
209 part->info = info; in mlxsw_sp2_kvdl_part_init()
210 part->usage_bit_count = usage_bit_count; in mlxsw_sp2_kvdl_part_init()
211 part->indexes_per_usage_bit = indexes_per_usage_bit; in mlxsw_sp2_kvdl_part_init()
212 part->last_allocated_bit = usage_bit_count - 1; in mlxsw_sp2_kvdl_part_init()
213 return part; in mlxsw_sp2_kvdl_part_init()
216 static void mlxsw_sp2_kvdl_part_fini(struct mlxsw_sp2_kvdl_part *part) in mlxsw_sp2_kvdl_part_fini() argument
218 kfree(part); in mlxsw_sp2_kvdl_part_fini()