Lines Matching defs:pool

13  * (for example, TLS) after last revalidation in a pool or a bulk.
19 #define MLX5_CRYPTO_DEK_POOL_CALC_FREED(pool) MLX5_CRYPTO_DEK_CALC_FREED(pool)
33 int num_deks; /* the total number of keys in this pool */
34 int avail_deks; /* the number of available keys in this pool */
35 int in_use_deks; /* the number of being used keys in this pool */
288 mlx5_crypto_dek_bulk_create(struct mlx5_crypto_dek_pool *pool)
290 struct mlx5_crypto_dek_priv *dek_priv = pool->mdev->mlx5e_res.dek_priv;
291 struct mlx5_core_dev *mdev = pool->mdev;
313 err = mlx5_crypto_create_dek_bulk(mdev, pool->key_purpose,
334 mlx5_crypto_dek_pool_add_bulk(struct mlx5_crypto_dek_pool *pool)
338 bulk = mlx5_crypto_dek_bulk_create(pool);
342 pool->avail_deks += bulk->num_deks;
343 pool->num_deks += bulk->num_deks;
344 list_add(&bulk->entry, &pool->partial_list);
357 static void mlx5_crypto_dek_pool_remove_bulk(struct mlx5_crypto_dek_pool *pool,
361 pool->num_deks -= bulk->num_deks;
362 pool->avail_deks -= bulk->avail_deks;
363 pool->in_use_deks -= bulk->in_use_deks;
370 mlx5_crypto_dek_pool_pop(struct mlx5_crypto_dek_pool *pool, u32 *obj_offset)
375 mutex_lock(&pool->lock);
376 bulk = list_first_entry_or_null(&pool->partial_list,
383 mlx5_core_err(pool->mdev, "Wrong DEK bulk avail_start.\n");
388 bulk = list_first_entry_or_null(&pool->avail_list,
392 list_move(&bulk->entry, &pool->partial_list);
394 bulk = mlx5_crypto_dek_pool_add_bulk(pool);
407 list_move(&bulk->entry, &pool->full_list);
412 pool->avail_deks--;
413 pool->in_use_deks++;
416 mutex_unlock(&pool->lock);
420 static bool mlx5_crypto_dek_need_sync(struct mlx5_crypto_dek_pool *pool)
422 return !pool->syncing &&
423 MLX5_CRYPTO_DEK_POOL_CALC_FREED(pool) > MLX5_CRYPTO_DEK_POOL_SYNC_THRESH;
426 static int mlx5_crypto_dek_free_locked(struct mlx5_crypto_dek_pool *pool,
441 pool->in_use_deks--;
444 list_move(&bulk->entry, &pool->sync_list);
446 if (mlx5_crypto_dek_need_sync(pool) && schedule_work(&pool->sync_work))
447 pool->syncing = true;
454 static int mlx5_crypto_dek_pool_push(struct mlx5_crypto_dek_pool *pool,
459 mutex_lock(&pool->lock);
460 if (pool->syncing)
461 list_add(&dek->entry, &pool->wait_for_free);
463 err = mlx5_crypto_dek_free_locked(pool, dek);
464 mutex_unlock(&pool->lock);
479 static void mlx5_crypto_dek_bulk_reset_synced(struct mlx5_crypto_dek_pool *pool,
496 pool->avail_deks += reused;
510 static bool mlx5_crypto_dek_bulk_handle_avail(struct mlx5_crypto_dek_pool *pool,
514 if (list_empty(&pool->avail_list)) {
515 list_move(&bulk->entry, &pool->avail_list);
519 mlx5_crypto_dek_pool_remove_bulk(pool, bulk, true);
524 static void mlx5_crypto_dek_pool_splice_destroy_list(struct mlx5_crypto_dek_pool *pool,
528 spin_lock(&pool->destroy_lock);
530 spin_unlock(&pool->destroy_lock);
533 static void mlx5_crypto_dek_pool_free_wait_keys(struct mlx5_crypto_dek_pool *pool)
537 list_for_each_entry_safe(dek, next, &pool->wait_for_free, entry) {
539 mlx5_crypto_dek_free_locked(pool, dek);
548 static void mlx5_crypto_dek_pool_reset_synced(struct mlx5_crypto_dek_pool *pool)
553 list_for_each_entry_safe(bulk, tmp, &pool->partial_list, entry) {
554 mlx5_crypto_dek_bulk_reset_synced(pool, bulk);
556 mlx5_crypto_dek_bulk_handle_avail(pool, bulk, &destroy_list);
559 list_for_each_entry_safe(bulk, tmp, &pool->full_list, entry) {
560 mlx5_crypto_dek_bulk_reset_synced(pool, bulk);
566 mlx5_crypto_dek_bulk_handle_avail(pool, bulk, &destroy_list);
568 list_move(&bulk->entry, &pool->partial_list);
571 list_for_each_entry_safe(bulk, tmp, &pool->sync_list, entry) {
573 pool->avail_deks += bulk->num_deks;
574 if (mlx5_crypto_dek_bulk_handle_avail(pool, bulk, &destroy_list)) {
580 mlx5_crypto_dek_pool_free_wait_keys(pool);
583 mlx5_crypto_dek_pool_splice_destroy_list(pool, &destroy_list,
584 &pool->destroy_list);
585 schedule_work(&pool->destroy_work);
591 struct mlx5_crypto_dek_pool *pool =
595 err = mlx5_crypto_cmd_sync_crypto(pool->mdev, BIT(pool->key_purpose));
596 mutex_lock(&pool->lock);
598 mlx5_crypto_dek_pool_reset_synced(pool);
599 pool->syncing = false;
600 mutex_unlock(&pool->lock);
672 struct mlx5_crypto_dek_pool *pool =
676 mlx5_crypto_dek_pool_splice_destroy_list(pool, &pool->destroy_list,
684 struct mlx5_crypto_dek_pool *pool;
686 pool = kzalloc(sizeof(*pool), GFP_KERNEL);
687 if (!pool)
690 pool->mdev = mdev;
691 pool->key_purpose = key_purpose;
693 mutex_init(&pool->lock);
694 INIT_LIST_HEAD(&pool->avail_list);
695 INIT_LIST_HEAD(&pool->partial_list);
696 INIT_LIST_HEAD(&pool->full_list);
697 INIT_LIST_HEAD(&pool->sync_list);
698 INIT_LIST_HEAD(&pool->wait_for_free);
699 INIT_WORK(&pool->sync_work, mlx5_crypto_dek_sync_work_fn);
700 spin_lock_init(&pool->destroy_lock);
701 INIT_LIST_HEAD(&pool->destroy_list);
702 INIT_WORK(&pool->destroy_work, mlx5_crypto_dek_destroy_work_fn);
704 return pool;
707 void mlx5_crypto_dek_pool_destroy(struct mlx5_crypto_dek_pool *pool)
711 cancel_work_sync(&pool->sync_work);
712 cancel_work_sync(&pool->destroy_work);
714 mlx5_crypto_dek_pool_free_wait_keys(pool);
716 list_for_each_entry_safe(bulk, tmp, &pool->avail_list, entry)
717 mlx5_crypto_dek_pool_remove_bulk(pool, bulk, false);
719 list_for_each_entry_safe(bulk, tmp, &pool->full_list, entry)
720 mlx5_crypto_dek_pool_remove_bulk(pool, bulk, false);
722 list_for_each_entry_safe(bulk, tmp, &pool->sync_list, entry)
723 mlx5_crypto_dek_pool_remove_bulk(pool, bulk, false);
725 list_for_each_entry_safe(bulk, tmp, &pool->partial_list, entry)
726 mlx5_crypto_dek_pool_remove_bulk(pool, bulk, false);
728 mlx5_crypto_dek_free_destroy_list(&pool->destroy_list);
730 mutex_destroy(&pool->lock);
732 kfree(pool);