Rename ocf_engine_cb to ocf_req_cb and move it from engine_common.h to ocf_request.h

Signed-off-by: Ian Levine <ian.levine@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
This commit is contained in:
Ian Levine 2023-10-12 14:41:15 +03:00 committed by Robert Baldyga
parent 88e39b5827
commit de32a9649a
5 changed files with 37 additions and 32 deletions

View File

@ -138,7 +138,7 @@ const char *ocf_get_io_iface_name(ocf_req_cache_mode_t cache_mode)
return cache_mode_io_if_map[cache_mode]->name; return cache_mode_io_if_map[cache_mode]->name;
} }
static ocf_engine_cb ocf_io_if_type_to_engine_cb( static ocf_req_cb ocf_io_if_type_to_engine_cb(
enum ocf_io_if_type io_if_type, int rw) enum ocf_io_if_type io_if_type, int rw)
{ {
if (unlikely(io_if_type == OCF_IO_MAX_IF || if (unlikely(io_if_type == OCF_IO_MAX_IF ||
@ -149,7 +149,7 @@ static ocf_engine_cb ocf_io_if_type_to_engine_cb(
return IO_IFS[io_if_type].cbs[rw]; return IO_IFS[io_if_type].cbs[rw];
} }
static ocf_engine_cb ocf_cache_mode_to_engine_cb( static ocf_req_cb ocf_cache_mode_to_engine_cb(
ocf_req_cache_mode_t req_cache_mode, int rw) ocf_req_cache_mode_t req_cache_mode, int rw)
{ {
if (req_cache_mode == ocf_req_cache_mode_max) if (req_cache_mode == ocf_req_cache_mode_max)
@ -271,7 +271,7 @@ int ocf_engine_hndl_req(struct ocf_request *req)
int ocf_engine_hndl_fast_req(struct ocf_request *req) int ocf_engine_hndl_fast_req(struct ocf_request *req)
{ {
ocf_engine_cb engine_cb; ocf_req_cb engine_cb;
int ret; int ret;
engine_cb = ocf_cache_mode_to_engine_cb(req->cache_mode, req->rw); engine_cb = ocf_cache_mode_to_engine_cb(req->cache_mode, req->rw);

View File

@ -7,42 +7,22 @@
#ifndef __CACHE_ENGINE_H_ #ifndef __CACHE_ENGINE_H_
#define __CACHE_ENGINE_H_ #define __CACHE_ENGINE_H_
#include "../ocf_request.h"
struct ocf_thread_priv; struct ocf_thread_priv;
struct ocf_request;
#define LOOKUP_HIT 5 #define LOOKUP_HIT 5
#define LOOKUP_MISS 6 #define LOOKUP_MISS 6
#define LOOKUP_REMAPPED 8 #define LOOKUP_REMAPPED 8
typedef enum {
/* modes inherited from user API */
ocf_req_cache_mode_wt = ocf_cache_mode_wt,
ocf_req_cache_mode_wb = ocf_cache_mode_wb,
ocf_req_cache_mode_wa = ocf_cache_mode_wa,
ocf_req_cache_mode_pt = ocf_cache_mode_pt,
ocf_req_cache_mode_wi = ocf_cache_mode_wi,
ocf_req_cache_mode_wo = ocf_cache_mode_wo,
/* internal modes */
ocf_req_cache_mode_fast,
/*!< Fast path */
ocf_req_cache_mode_d2c,
/*!< Direct to Core - pass through to core without
touching cacheline metadata */
ocf_req_cache_mode_max,
} ocf_req_cache_mode_t;
static inline ocf_req_cache_mode_t ocf_cache_mode_to_req_cache_mode( static inline ocf_req_cache_mode_t ocf_cache_mode_to_req_cache_mode(
ocf_cache_mode_t mode) ocf_cache_mode_t mode)
{ {
return (ocf_req_cache_mode_t)mode; return (ocf_req_cache_mode_t)mode;
} }
typedef int (*ocf_engine_cb)(struct ocf_request *req);
struct ocf_io_if { struct ocf_io_if {
ocf_engine_cb cbs[2]; /* READ and WRITE */ ocf_req_cb cbs[2]; /* READ and WRITE */
const char *name; const char *name;
}; };

View File

@ -1,6 +1,6 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies Co., Ltd. * Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -645,11 +645,11 @@ void ocf_engine_push_req_front(struct ocf_request *req, bool allow_sync)
} }
void ocf_engine_push_req_front_cb(struct ocf_request *req, void ocf_engine_push_req_front_cb(struct ocf_request *req,
ocf_engine_cb engine_cb, ocf_req_cb req_cb,
bool allow_sync) bool allow_sync)
{ {
req->error = 0; /* Please explain why!!! */ req->error = 0; /* Please explain why!!! */
req->engine_handler = engine_cb; req->engine_handler = req_cb;
ocf_engine_push_req_front(req, allow_sync); ocf_engine_push_req_front(req, allow_sync);
} }

View File

@ -1,5 +1,6 @@
/* /*
* Copyright(c) 2012-2022 Intel Corporation * Copyright(c) 2012-2022 Intel Corporation
* Copyright(c) 2024 Huawei Technologies
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
@ -309,7 +310,7 @@ void ocf_engine_push_req_front(struct ocf_request *req,
from push function in caller context from push function in caller context
*/ */
void ocf_engine_push_req_front_cb(struct ocf_request *req, void ocf_engine_push_req_front_cb(struct ocf_request *req,
ocf_engine_cb engine_cb, ocf_req_cb req_cb,
bool allow_sync); bool allow_sync);
void inc_fallback_pt_error_counter(ocf_cache_t cache); void inc_fallback_pt_error_counter(ocf_cache_t cache);

View File

@ -9,9 +9,27 @@
#include "ocf_env.h" #include "ocf_env.h"
#include "ocf_io_priv.h" #include "ocf_io_priv.h"
#include "engine/cache_engine.h"
#include "metadata/metadata_structs.h" #include "metadata/metadata_structs.h"
typedef enum {
/* modes inherited from user API */
ocf_req_cache_mode_wt = ocf_cache_mode_wt,
ocf_req_cache_mode_wb = ocf_cache_mode_wb,
ocf_req_cache_mode_wa = ocf_cache_mode_wa,
ocf_req_cache_mode_pt = ocf_cache_mode_pt,
ocf_req_cache_mode_wi = ocf_cache_mode_wi,
ocf_req_cache_mode_wo = ocf_cache_mode_wo,
/* internal modes */
ocf_req_cache_mode_fast,
/*!< Fast path */
ocf_req_cache_mode_d2c,
/*!< Direct to Core - pass through to core without
touching cacheline metadata */
ocf_req_cache_mode_max,
} ocf_req_cache_mode_t;
struct ocf_req_allocator; struct ocf_req_allocator;
struct ocf_req_info { struct ocf_req_info {
@ -94,6 +112,12 @@ struct ocf_req_discard_info {
/*!< Number of processed sector during discard operation */ /*!< Number of processed sector during discard operation */
}; };
/**
* @brief OCF IO engine handler callback
*/
struct ocf_request;
typedef int (*ocf_req_cb)(struct ocf_request *req);
/** /**
* @brief OCF IO request * @brief OCF IO request
*/ */
@ -129,7 +153,7 @@ struct ocf_request {
ocf_core_t core; ocf_core_t core;
/*!< Handle to core instance */ /*!< Handle to core instance */
ocf_engine_cb engine_handler; ocf_req_cb engine_handler;
/*!< IO engine handler */ /*!< IO engine handler */
void *priv; void *priv;