Lines Matching refs:list
223 mlx5_clist_default_create_cb(struct mlx5_cache_list *list, in mlx5_clist_default_create_cb() argument
227 return mlx5_malloc(MLX5_MEM_ZERO, list->entry_sz, 0, SOCKET_ID_ANY); in mlx5_clist_default_create_cb()
231 mlx5_clist_default_remove_cb(struct mlx5_cache_list *list __rte_unused, in mlx5_clist_default_remove_cb()
238 mlx5_cache_list_init(struct mlx5_cache_list *list, const char *name, in mlx5_cache_list_init() argument
244 MLX5_ASSERT(list); in mlx5_cache_list_init()
248 snprintf(list->name, sizeof(list->name), "%s", name); in mlx5_cache_list_init()
249 list->entry_sz = entry_size; in mlx5_cache_list_init()
250 list->ctx = ctx; in mlx5_cache_list_init()
251 list->cb_create = cb_create ? cb_create : mlx5_clist_default_create_cb; in mlx5_cache_list_init()
252 list->cb_match = cb_match; in mlx5_cache_list_init()
253 list->cb_remove = cb_remove ? cb_remove : mlx5_clist_default_remove_cb; in mlx5_cache_list_init()
254 rte_rwlock_init(&list->lock); in mlx5_cache_list_init()
255 DRV_LOG(DEBUG, "Cache list %s initialized.", list->name); in mlx5_cache_list_init()
256 LIST_INIT(&list->head); in mlx5_cache_list_init()
261 __cache_lookup(struct mlx5_cache_list *list, void *ctx, bool reuse) in __cache_lookup() argument
265 LIST_FOREACH(entry, &list->head, next) { in __cache_lookup()
266 if (list->cb_match(list, entry, ctx)) in __cache_lookup()
272 list->name, (void *)entry, entry->ref_cnt); in __cache_lookup()
280 cache_lookup(struct mlx5_cache_list *list, void *ctx, bool reuse) in cache_lookup() argument
284 rte_rwlock_read_lock(&list->lock); in cache_lookup()
285 entry = __cache_lookup(list, ctx, reuse); in cache_lookup()
286 rte_rwlock_read_unlock(&list->lock); in cache_lookup()
291 mlx5_cache_lookup(struct mlx5_cache_list *list, void *ctx) in mlx5_cache_lookup() argument
293 return cache_lookup(list, ctx, false); in mlx5_cache_lookup()
297 mlx5_cache_register(struct mlx5_cache_list *list, void *ctx) in mlx5_cache_register() argument
302 MLX5_ASSERT(list); in mlx5_cache_register()
303 prev_gen_cnt = __atomic_load_n(&list->gen_cnt, __ATOMIC_ACQUIRE); in mlx5_cache_register()
305 entry = cache_lookup(list, ctx, true); in mlx5_cache_register()
309 rte_rwlock_write_lock(&list->lock); in mlx5_cache_register()
311 if (prev_gen_cnt != __atomic_load_n(&list->gen_cnt, __ATOMIC_ACQUIRE)) { in mlx5_cache_register()
313 entry = __cache_lookup(list, ctx, true); in mlx5_cache_register()
317 entry = list->cb_create(list, entry, ctx); in mlx5_cache_register()
320 list->name, (void *)entry); in mlx5_cache_register()
324 LIST_INSERT_HEAD(&list->head, entry, next); in mlx5_cache_register()
325 __atomic_add_fetch(&list->gen_cnt, 1, __ATOMIC_RELEASE); in mlx5_cache_register()
326 __atomic_add_fetch(&list->count, 1, __ATOMIC_ACQUIRE); in mlx5_cache_register()
328 list->name, (void *)entry, entry->ref_cnt); in mlx5_cache_register()
330 rte_rwlock_write_unlock(&list->lock); in mlx5_cache_register()
335 mlx5_cache_unregister(struct mlx5_cache_list *list, in mlx5_cache_unregister() argument
338 rte_rwlock_write_lock(&list->lock); in mlx5_cache_unregister()
341 list->name, (void *)entry, entry->ref_cnt); in mlx5_cache_unregister()
343 rte_rwlock_write_unlock(&list->lock); in mlx5_cache_unregister()
346 __atomic_add_fetch(&list->gen_cnt, 1, __ATOMIC_ACQUIRE); in mlx5_cache_unregister()
347 __atomic_sub_fetch(&list->count, 1, __ATOMIC_ACQUIRE); in mlx5_cache_unregister()
349 list->cb_remove(list, entry); in mlx5_cache_unregister()
350 rte_rwlock_write_unlock(&list->lock); in mlx5_cache_unregister()
352 list->name, (void *)entry); in mlx5_cache_unregister()
357 mlx5_cache_list_destroy(struct mlx5_cache_list *list) in mlx5_cache_list_destroy() argument
361 MLX5_ASSERT(list); in mlx5_cache_list_destroy()
363 while (!LIST_EMPTY(&list->head)) { in mlx5_cache_list_destroy()
364 entry = LIST_FIRST(&list->head); in mlx5_cache_list_destroy()
366 list->cb_remove(list, entry); in mlx5_cache_list_destroy()
368 list->name, (void *)entry); in mlx5_cache_list_destroy()
370 memset(list, 0, sizeof(*list)); in mlx5_cache_list_destroy()
374 mlx5_cache_list_get_entry_num(struct mlx5_cache_list *list) in mlx5_cache_list_get_entry_num() argument
376 MLX5_ASSERT(list); in mlx5_cache_list_get_entry_num()
377 return __atomic_load_n(&list->count, __ATOMIC_RELAXED); in mlx5_cache_list_get_entry_num()