diff --git a/modules/cas_cache/layer_cache_management.c b/modules/cas_cache/layer_cache_management.c index 8495617..e37741f 100644 --- a/modules/cas_cache/layer_cache_management.c +++ b/modules/cas_cache/layer_cache_management.c @@ -348,6 +348,73 @@ int cache_mngt_get_cleaning_param(ocf_cache_t cache, ocf_cleaning_t type, return result; } +int cache_mngt_set_promotion_policy(ocf_cache_t cache, uint32_t type) +{ + int result; + + result = _cache_mngt_lock_sync(cache); + if (result) { + return result; + } + + result = ocf_mngt_cache_promotion_set_policy(cache, type); + if (result) + goto out; + + result = _cache_mngt_save_sync(cache); + +out: + ocf_mngt_cache_unlock(cache); + return result; +} + +int cache_mngt_get_promotion_policy(ocf_cache_t cache, uint32_t *type) +{ + int result; + + result = _cache_mngt_read_lock_sync(cache); + if (result) { + return result; + } + + *type = ocf_mngt_cache_promotion_get_policy(cache); + + ocf_mngt_cache_read_unlock(cache); + return result; +} + +int cache_mngt_set_promotion_param(ocf_cache_t cache, uint32_t param_id, + uint32_t param_value) +{ + int result; + + result = _cache_mngt_lock_sync(cache); + if (result) { + return result; + } + + result = ocf_mngt_cache_promotion_set_param(cache, param_id, param_value); + + ocf_mngt_cache_unlock(cache); + return result; +} + +int cache_mngt_get_promotion_param(ocf_cache_t cache, uint32_t param_id, + uint32_t *param_value) +{ + int result; + + result = _cache_mngt_read_lock_sync(cache); + if (result) { + return result; + } + + result = ocf_mngt_cache_promotion_get_param(cache, param_id, param_value); + + ocf_mngt_cache_read_unlock(cache); + return result; +} + struct get_paths_ctx { char *core_path_name_tab; int max_count; @@ -1064,6 +1131,7 @@ int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg, cfg->cache_mode = cmd->caching_mode; cfg->cache_line_size = cmd->line_size; cfg->eviction_policy = cmd->eviction_policy; + cfg->promotion_policy = ocf_promotion_default; cfg->cache_line_size = cmd->line_size; cfg->pt_unaligned_io = !unaligned_io; cfg->use_submit_io_fast = !use_io_scheduler; @@ -2109,6 +2177,19 @@ int cache_mngt_get_cache_params(struct kcas_get_cache_param *info) ocf_cleaning_acp, ocf_acp_flush_max_buffers, &info->param_value); break; + case cache_param_promotion_policy_type: + result = cache_mngt_get_promotion_policy(cache, &info->param_value); + break; + case cache_param_promotion_nhit_insertion_threshold: + result = cache_mngt_get_promotion_param(cache, + ocf_nhit_insertion_threshold, + &info->param_value); + break; + case cache_param_promotion_nhit_trigger_threshold: + result = cache_mngt_get_promotion_param(cache, + ocf_nhit_trigger_threshold, + &info->param_value); + break; default: result = -EINVAL; } diff --git a/modules/cas_cache/layer_cache_management.h b/modules/cas_cache/layer_cache_management.h index bd1babd..f646423 100644 --- a/modules/cas_cache/layer_cache_management.h +++ b/modules/cas_cache/layer_cache_management.h @@ -20,6 +20,16 @@ int cache_mngt_set_cleaning_param(ocf_cache_t cache, ocf_cleaning_t type, int cache_mngt_get_cleaning_param(ocf_cache_t cache, ocf_cleaning_t type, uint32_t param_id, uint32_t *param_value); +int cache_mngt_set_promotion_policy(ocf_cache_t cache, uint32_t type); + +int cache_mngt_get_promotion_policy(ocf_cache_t cache, uint32_t *type); + +int cache_mngt_set_promotion_param(ocf_cache_t cache, uint32_t param_id, + uint32_t param_value); + +int cache_mngt_get_promotion_param(ocf_cache_t cache, uint32_t param_id, + uint32_t *param_value); + int cache_mngt_add_core_to_cache(const char *cache_name, struct ocf_mngt_core_config *cfg, struct kcas_insert_core *cmd_info); diff --git a/ocf b/ocf index f86287e..af48ee5 160000 --- a/ocf +++ b/ocf @@ -1 +1 @@ -Subproject commit f86287ef06190b080f9529c9f2514e56da8b726b +Subproject commit af48ee56e3d86c5de4a0ce7def35a1fedf35edf4