1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (C) 2018 Intel Corporation. 3 * All rights reserved. 4 */ 5 6 #ifndef VBDEV_OCF_UTILS_H 7 #define VBDEV_OCF_UTILS_H 8 9 #include <ocf/ocf.h> 10 #include "vbdev_ocf.h" 11 12 ocf_cache_mode_t ocf_get_cache_mode(const char *cache_mode); 13 const char *ocf_get_cache_modename(ocf_cache_mode_t mode); 14 15 /* Get cache line size in KiB units */ 16 int ocf_get_cache_line_size(ocf_cache_t cache); 17 18 /* Get sequential cutoff policy by name */ 19 ocf_seq_cutoff_policy ocf_get_seqcutoff_policy(const char *policy_name); 20 21 /* Initiate management operation 22 * Receives NULL terminated array of functions (path) 23 * and callback (cb) 24 * and callback argument (cb_arg) 25 * This function may fail with ENOMEM or EBUSY */ 26 int vbdev_ocf_mngt_start(struct vbdev_ocf *vbdev, vbdev_ocf_mngt_fn *path, 27 vbdev_ocf_mngt_callback cb, void *cb_arg); 28 29 /* Continue execution with polling operation (fn) 30 * fn must invoke vbdev_ocf_mngt_continue() to stop polling 31 * Poller has default timeout of 5 seconds */ 32 void vbdev_ocf_mngt_poll(struct vbdev_ocf *vbdev, vbdev_ocf_mngt_fn fn); 33 34 /* Continue execution with next function that is on path 35 * If next function is NULL, finish management operation and invoke callback */ 36 void vbdev_ocf_mngt_continue(struct vbdev_ocf *vbdev, int status); 37 38 /* Stop the execution, if status is non zero set it, 39 * if rollback function is not null invoke rollback 40 * else invoke callback with last status returned */ 41 void vbdev_ocf_mngt_stop(struct vbdev_ocf *vbdev, vbdev_ocf_mngt_fn *rollback_path, int status); 42 43 /* Get status */ 44 int vbdev_ocf_mngt_get_status(struct vbdev_ocf *vbdev); 45 #endif 46