LCOV - code coverage report
Current view: top level - lib/ftl/utils - ftl_property.h (source / functions) Hit Total Coverage
Test: ut_cov_unit.info Lines: 0 3 0.0 %
Date: 2024-12-16 07:10:28 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*   SPDX-License-Identifier: BSD-3-Clause
       2             :  *   Copyright 2023 Solidigm All Rights Reserved
       3             :  */
       4             : 
       5             : #ifndef FTL_PROPERTY_H
       6             : #define FTL_PROPERTY_H
       7             : 
       8             : #include "spdk/stdinc.h"
       9             : 
      10             : struct spdk_ftl_dev;
      11             : struct ftl_property;
      12             : 
      13             : /**
      14             :  * @brief Init the FTL properties system
      15             :  *
      16             :  * @retval 0 Success
      17             :  * @retval Non-zero a Failure
      18             :  */
      19             : int ftl_properties_init(struct spdk_ftl_dev *dev);
      20             : 
      21             : /**
      22             :  * @brief Deinit the FTL properties system
      23             :  */
      24             : void ftl_properties_deinit(struct spdk_ftl_dev *dev);
      25             : 
      26             : /**
      27             :  * @brief A function to dump the FTL property which type is bool
      28             :  */
      29             : void ftl_property_dump_bool(struct spdk_ftl_dev *dev, const struct ftl_property *property,
      30             :                             struct spdk_json_write_ctx *w);
      31             : 
      32             : /**
      33             :  * @brief A function to dump the FTL property which type is uint64
      34             :  */
      35             : void ftl_property_dump_uint64(struct spdk_ftl_dev *dev, const struct ftl_property *property,
      36             :                               struct spdk_json_write_ctx *w);
      37             : 
      38             : /**
      39             :  * @brief A function to dump the FTL property which type is uint32
      40             :  */
      41             : void ftl_property_dump_uint32(struct spdk_ftl_dev *dev, const struct ftl_property *property,
      42             :                               struct spdk_json_write_ctx *w);
      43             : 
      44             : /**
      45             :  * @brief Dump the value of property into the specified JSON RPC request
      46             :  *
      47             :  * @param dev FTL device
      48             :  * @param property The property to dump to the JSON RPC request
      49             :  * @param[out] w JSON RPC request
      50             :  */
      51             : typedef void (*ftl_property_dump_fn)(struct spdk_ftl_dev *dev, const struct ftl_property *property,
      52             :                                      struct spdk_json_write_ctx *w);
      53             : 
      54             : /**
      55             :  * @brief Decode property value and store it in output
      56             :  *
      57             :  * @param dev FTL device
      58             :  * @param property The property
      59             :  * @param value The new property value
      60             :  * @param value_size The size of the value buffer
      61             :  * @param output The output where to store new value
      62             :  * @param output_size The decoded value output size
      63             :  */
      64             : typedef int (*ftl_property_decode_fn)(struct spdk_ftl_dev *dev, struct ftl_property *property,
      65             :                                       const char *value, size_t value_size, void *output, size_t output_size);
      66             : 
      67             : /**
      68             :  * @brief Set the FTL property
      69             :  *
      70             :  * @param dev FTL device
      71             :  * @param mngt FTL management process handle
      72             :  * @param property The property
      73             :  * @param new_value The new property value to be set
      74             :  * @param new_value_size The size of the new property value
      75             :  */
      76             : typedef void (*ftl_property_set_fn)(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mngt,
      77             :                                     const struct ftl_property *property, void *new_value, size_t new_value_size);
      78             : 
      79             : /**
      80             :  * @brief Register a FTL property
      81             :  *
      82             :  * @param dev FTL device
      83             :  * @param name the FTL property name
      84             :  * @param value Pointer to the value of property
      85             :  * @param size The value size of the property
      86             :  * @param unit The unit of the property value
      87             :  * @param desc The property description for user help
      88             :  * @param dump The function to dump the property to the JSON RPC request
      89             :  * @param decode The function to decode a new value of the property
      90             :  * @param set The function to execute the property setting procedure
      91             :  * @param verbose_mode The property is available in verbose mode only
      92             :  */
      93             : void ftl_property_register(struct spdk_ftl_dev *dev,
      94             :                            const char *name, void *value, size_t size,
      95             :                            const char *unit, const char *desc,
      96             :                            ftl_property_dump_fn dump,
      97             :                            ftl_property_decode_fn decode,
      98             :                            ftl_property_set_fn set,
      99             :                            bool verbose_mode);
     100             : 
     101             : /**
     102             :  * @brief Dump FTL properties to the JSON request
     103             :  *
     104             :  * @param dev FTL device
     105             :  * @param request The JSON request where to store the FTL properties
     106             :  */
     107             : void ftl_property_dump(struct spdk_ftl_dev *dev, struct spdk_jsonrpc_request *request);
     108             : 
     109             : /**
     110             :  * @brief Decode property value and store it in output
     111             :  *
     112             :  * @param dev FTL device
     113             :  * @param name The property name to be decoded
     114             :  * @param value The new property value
     115             :  * @param value_size The new property value buffer size
     116             :  * @param output The output where to store new value
     117             :  * @param output_size The decoded value output size
     118             :  */
     119             : int ftl_property_decode(struct spdk_ftl_dev *dev, const char *name, const char *value,
     120             :                         size_t value_size, void **output, size_t *output_size);
     121             : 
     122             : /**
     123             :  * @brief The property bool decoder
     124             :  */
     125             : int ftl_property_decode_bool(struct spdk_ftl_dev *dev, struct ftl_property *property,
     126             :                              const char *value, size_t value_size, void *output, size_t output_size);
     127             : 
     128             : /**
     129             :  * @brief Set FTL property
     130             :  *
     131             :  * @param dev FTL device
     132             :  * @param mngt FTL management process handle
     133             :  * @param name The property name to be set
     134             :  * @param value The new property decoded value
     135             :  * @param output The size of the new property decoded value
     136             :  */
     137             : int ftl_property_set(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mngt,
     138             :                      const char *name, void *value, size_t value_size);
     139             : 
     140             : /**
     141             :  * @brief Generic setter of the property
     142             :  *
     143             :  * @note This setter does binary copy and finishes always call the next management step
     144             :  */
     145             : void ftl_property_set_generic(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mngt,
     146             :                               const struct ftl_property *property,
     147             :                               void *new_value, size_t new_value_size);
     148             : 
     149             : /**
     150             :  * @brief The wrapper function to register mutable boolean property
     151             :  *
     152             :  * @param dev FTL device
     153             :  * @param name The property name
     154             :  * @param value The pointer to the boolean value of the property
     155             :  * @param unit The property unit
     156             :  * @param desc The property description
     157             :  * @param verbose_mode The verbose mode flag
     158             :  */
     159             : static inline void
     160           0 : ftl_property_register_bool_rw(struct spdk_ftl_dev *dev, const char *name, bool *value,
     161             :                               const char *unit, const char *desc, bool verbose_mode)
     162             : {
     163           0 :         ftl_property_register(dev, name, value, sizeof(*value), unit, desc, ftl_property_dump_bool,
     164             :                               ftl_property_decode_bool, ftl_property_set_generic, verbose_mode);
     165           0 : }
     166             : 
     167             : #endif

Generated by: LCOV version 1.15