Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions inc/ocf_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ struct ocf_cache_info {
ocf_promotion_t promotion_policy;
/*!< Promotion policy selected */

ocf_pf_mask_t prefetch_mask;
/*!< Prefetchers selected (bitmask) */

ocf_cache_line_size_t cache_line_size;
/*!< Cache line size in KiB */

Expand Down
36 changes: 0 additions & 36 deletions inc/ocf_cfg.h

This file was deleted.

12 changes: 9 additions & 3 deletions inc/ocf_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define __OCF_DEF_H__

#include "ocf_env.h"
#include "ocf_cfg.h"

#define OCF_BITWIDTH(T) (sizeof(T) * __CHAR_BIT__)

Expand All @@ -22,6 +21,13 @@
* @brief OCF definitions
*/

/**
* Enabling debug statistics
*/
#ifndef OCF_CONFIG_DEBUG_STATS
#define OCF_CONFIG_DEBUG_STATS 0
#endif

/**
* @name OCF cache definitions
*/
Expand Down Expand Up @@ -87,7 +93,7 @@
* Must be smaller than (1 << OCF_CORE_ID_BITS) to leave space
* for invalid OCF_CORE_ID_INVALID.
*/
#define OCF_CORE_NUM OCF_CONFIG_MAX_CORES
#define OCF_CORE_NUM 4096
_Static_assert(OCF_CORE_NUM < OCF_MAX_T(uint32_t, OCF_CORE_ID_BITS));
/**
* Minimum value of a valid core ID
Expand Down Expand Up @@ -340,7 +346,7 @@ typedef enum {
/**
* Maximum numbers of IO classes per cache instance
*/
#define OCF_USER_IO_CLASS_MAX OCF_CONFIG_MAX_IO_CLASSES
#define OCF_USER_IO_CLASS_MAX 34
/**
* Minimum value of a valid IO class ID
*/
Expand Down
3 changes: 3 additions & 0 deletions inc/ocf_err.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ typedef enum {
/** Operation interrupted */
OCF_ERR_INTR,

/** Busy */
OCF_ERR_BUSY,

/** Operation not supported */
OCF_ERR_NOT_SUPP,

Expand Down
26 changes: 26 additions & 0 deletions inc/ocf_mngt.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "ocf_cache.h"
#include "ocf_core.h"
#include "ocf_prefetch.h"

/**
* @file
Expand Down Expand Up @@ -1005,6 +1006,31 @@ int ocf_mngt_cache_promotion_set_param(ocf_cache_t cache, ocf_promotion_t type,
int ocf_mngt_cache_promotion_get_param(ocf_cache_t cache, ocf_promotion_t type,
uint8_t param_id, uint32_t *param_value);

/**
* @brief Set prefetch policy in given cache
*
* @attention This changes only runtime state. To make changes persistent
* use function ocf_mngt_cache_save().
*
* @param[in] cache Cache handle
* @param[in] mask Bitmask of prefetch policies to enable
*
* @retval 0 Policy has been set successfully
* @retval Non-zero Error occurred and policy has not been set
*/
int ocf_mngt_cache_prefetch_set_policy(ocf_cache_t cache, ocf_pf_mask_t mask);

/**
* @brief Get prefetch policy in given cache
*
* @param[in] cache Cache handle
* @param[out] mask Bitmask of enabled prefetch policies
*
* @retval 0 success
* @retval Non-zero Error occurred and policy could not be retrieved
*/
int ocf_mngt_cache_prefetch_get_policy(ocf_cache_t cache, ocf_pf_mask_t *mask);

/**
* @brief IO class configuration
*/
Expand Down
28 changes: 28 additions & 0 deletions inc/ocf_prefetch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright(c) 2021-2024 Huawei Technologies Co., Ltd.
* Copyright(c) 2026 Unvertical
* SPDX-License-Identifier: BSD-3-Clause
*/

#ifndef __OCF_PREFETCH_H__
#define __OCF_PREFETCH_H__

#include "ocf_def.h"

/*
* Prefetch policy id
*/
typedef enum {
ocf_pf_none = -1,
ocf_pf_readahead = 0,
ocf_pf_num,
} ocf_pf_id_t;

typedef uint8_t ocf_pf_mask_t;

/* The bitmask must fit all the values of ocf_pf_id_t */
_Static_assert(OCF_BITWIDTH(ocf_pf_mask_t) >= ocf_pf_num);

#define OCF_PF_MASK_DEFAULT 0

#endif /* __OCF_PREFETCH_H__ */
12 changes: 11 additions & 1 deletion inc/ocf_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#ifndef __OCF_STATS_H__
#define __OCF_STATS_H__

#include "ocf_prefetch.h"

/**
* Entire row of statistcs
*/
Expand Down Expand Up @@ -71,7 +73,11 @@
* ║ Pass-Through writes │ 0 │ 0.0 │ Requests ║
* ║ Serviced requests │ 222 │ 100.0 │ Requests ║
* ╟──────────────────────┼───────┼───────┼──────────╢
* ║ Total requests │ 222 │ 100.0 │ Requests ║
* ║ Prefetch: readahead │ 2 │ 0.0 │ Requests ║
* ║ Prefetch total │ 2 │ 0.0 │ Requests ║
* ╟──────────────────────┼───────┼───────┼──────────╢

Check failure on line 78 in inc/ocf_stats.h

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 156 exceeds 80 columns
* ║ User requests │ 222 │ 100.0 │ Requests ║
* ║ Total requests │ 224 │ 100.0 │ Requests ║
* ╚══════════════════════╧═══════╧═══════╧══════════╝
* </pre>
*/
Expand All @@ -89,6 +95,8 @@
struct ocf_stat rd_pt;
struct ocf_stat wr_pt;
struct ocf_stat serviced;
struct ocf_stat prefetch[ocf_pf_num];
struct ocf_stat user;
struct ocf_stat total;
};

Expand Down Expand Up @@ -127,6 +135,8 @@
struct ocf_stat pass_through_rd;
struct ocf_stat pass_through_wr;
struct ocf_stat pass_through_total;
struct ocf_stat prefetch_core_rd[ocf_pf_num];
struct ocf_stat prefetch_cache_wr[ocf_pf_num];
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/engine/engine_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ static int lock_clines(struct ocf_request *req)
* Caller must assure that request map info is up to date (request
* is traversed).
*/
static inline void ocf_prepare_clines_miss(struct ocf_request *req)
void ocf_prepare_clines_miss(struct ocf_request *req)
{
bool part_has_space;

Expand Down Expand Up @@ -599,7 +599,7 @@ void ocf_engine_update_request_stats(struct ocf_request *req)
{
ocf_core_stats_request_update(req->core, req->part_id, req->rw,
req->info.hit_no, req->core_line_count,
req->is_deferred);
req->io.pf_id, req->is_deferred);
}

void inc_fallback_pt_error_counter(ocf_cache_t cache)
Expand Down
7 changes: 7 additions & 0 deletions src/engine/engine_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ struct ocf_engine_callbacks
ocf_req_async_lock_cb resume;
};

/**
* @brief Prepare cache lines for miss request
*
* @param req OCF request
*/
void ocf_prepare_clines_miss(struct ocf_request *req);

/**
* @brief Map and lock cachelines
*
Expand Down
7 changes: 4 additions & 3 deletions src/engine/engine_io.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright(c) 2024 Huawei Technologies
* Copyright(c) 2026 Unvertical
* SPDX-License-Identifier: BSD-3-Clause
*/

Expand Down Expand Up @@ -131,7 +132,7 @@ void ocf_engine_forward_core_io_req(struct ocf_request *req,
ocf_req_end_t callback)
{
ocf_core_stats_core_block_update(req->core, req->part_id, req->rw,
req->bytes);
req->bytes, req->io.pf_id);

ocf_req_forward_core_init(req, callback);

Expand All @@ -143,7 +144,7 @@ void ocf_engine_forward_core_flush_req(struct ocf_request *req,
ocf_req_end_t callback)
{
ocf_core_stats_core_block_update(req->core, req->part_id, req->rw,
req->bytes);
req->bytes, req->io.pf_id);

ocf_req_forward_core_init(req, callback);

Expand All @@ -154,7 +155,7 @@ void ocf_engine_forward_core_discard_req(struct ocf_request *req,
ocf_req_end_t callback)
{
ocf_core_stats_core_block_update(req->core, req->part_id, req->rw,
req->bytes);
req->bytes, req->io.pf_id);

ocf_req_forward_core_init(req, callback);

Expand Down
Loading
Loading