LCOV - code coverage report
Current view: top level - lib/env_ocf/include/ocf - ocf_io.h (source / functions) Hit Total Coverage
Test: ut_cov_unit.info Lines: 0 5 0.0 %
Date: 2024-11-20 22:29:12 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright(c) 2012-2021 Intel Corporation
       3             :  * SPDX-License-Identifier: BSD-3-Clause
       4             :  */
       5             : 
       6             : 
       7             : #ifndef __OCF_IO_H__
       8             : #define __OCF_IO_H__
       9             : 
      10             : #include "ocf_types.h"
      11             : 
      12             : /**
      13             :  * @file
      14             :  * @brief OCF IO definitions
      15             :  */
      16             : 
      17             : struct ocf_io;
      18             : 
      19             : /**
      20             :  * @brief OCF IO start
      21             :  *
      22             :  * @note OCF IO start notification callback
      23             :  *
      24             :  * @param[in] io OCF IO being started
      25             :  */
      26             : typedef void (*ocf_start_io_t)(struct ocf_io *io);
      27             : 
      28             : /**
      29             :  * @brief OCF IO handle
      30             :  *
      31             :  * @note OCF IO handle callback
      32             :  *
      33             :  * @param[in] io OCF IO to handle
      34             :  */
      35             : typedef void (*ocf_handle_io_t)(struct ocf_io *io, void *opaque);
      36             : 
      37             : /**
      38             :  * @brief OCF IO completion
      39             :  *
      40             :  * @note Completion function for OCF IO
      41             :  *
      42             :  * @param[in] io OCF IO being completed
      43             :  * @param[in] error Completion status code
      44             :  */
      45             : typedef void (*ocf_end_io_t)(struct ocf_io *io, int error);
      46             : 
      47             : /**
      48             :  * @brief OCF IO main structure
      49             :  */
      50             : struct ocf_io {
      51             :         /**
      52             :          * @brief OCF IO destination address
      53             :          */
      54             :         uint64_t addr;
      55             : 
      56             :         /**
      57             :          * @brief OCF IO flags
      58             :          */
      59             :         uint64_t flags;
      60             : 
      61             :         /**
      62             :          * @brief OCF IO size in bytes
      63             :          */
      64             :         uint32_t bytes;
      65             : 
      66             :         /**
      67             :          * @brief OCF IO destination class
      68             :          */
      69             :         uint32_t io_class;
      70             : 
      71             :         /**
      72             :          * @brief OCF IO direction
      73             :          */
      74             :         uint32_t dir;
      75             : 
      76             :         /**
      77             :          * @brief Queue handle
      78             :          */
      79             :         ocf_queue_t io_queue;
      80             : 
      81             :         /**
      82             :          * @brief OCF IO start function
      83             :          */
      84             :         ocf_start_io_t start;
      85             : 
      86             :         /**
      87             :          * @brief OCF IO private 1
      88             :          */
      89             :         void *priv1;
      90             : 
      91             :         /**
      92             :          * @brief OCF IO private 2
      93             :          */
      94             :         void *priv2;
      95             : 
      96             :         /**
      97             :          * @brief OCF IO handle function
      98             :          */
      99             :         ocf_handle_io_t handle;
     100             : 
     101             :         /**
     102             :          * @brief OCF IO completion function
     103             :          */
     104             :         ocf_end_io_t end;
     105             : };
     106             : 
     107             : /**
     108             :  * @brief OCF IO operations set structure
     109             :  */
     110             : struct ocf_io_ops {
     111             :         /**
     112             :          * @brief Set up data vector in OCF IO
     113             :          *
     114             :          * @param[in] io OCF IO to set up
     115             :          * @param[in] data Source context data
     116             :          * @param[in] offset Data offset in source context data
     117             :          *
     118             :          * @retval 0 Data set up successfully
     119             :          * @retval Non-zero Data set up failure
     120             :          */
     121             :         int (*set_data)(struct ocf_io *io, ctx_data_t *data,
     122             :                         uint32_t offset);
     123             : 
     124             :         /**
     125             :          * @brief Get context data from OCF IO
     126             :          *
     127             :          * @param[in] io OCF IO to get data
     128             :          *
     129             :          * @return Data vector from IO
     130             :          */
     131             :         ctx_data_t *(*get_data)(struct ocf_io *io);
     132             : };
     133             : 
     134             : /**
     135             :  * @brief Get IO private context structure
     136             :  *
     137             :  * @param[in] io OCF IO
     138             :  *
     139             :  * @return IO private context structure
     140             :  */
     141             : void *ocf_io_get_priv(struct ocf_io *io);
     142             : 
     143             : /**
     144             :  * @brief Increase reference counter in OCF IO
     145             :  *
     146             :  * @note Wrapper for get IO operation
     147             :  *
     148             :  * @param[in] io OCF IO
     149             :  */
     150             : void ocf_io_get(struct ocf_io *io);
     151             : 
     152             : /**
     153             :  * @brief Decrease reference counter in OCF IO
     154             :  *
     155             :  * @note If IO don't have any reference - deallocate it
     156             :  *
     157             :  * @param[in] io OCF IO
     158             :  */
     159             : void ocf_io_put(struct ocf_io *io);
     160             : 
     161             : /**
     162             :  * @brief Set OCF IO completion function
     163             :  *
     164             :  * @param[in] io OCF IO
     165             :  * @param[in] context Context for completion function
     166             :  * @param[in] fn Completion function
     167             :  */
     168           0 : static inline void ocf_io_set_cmpl(struct ocf_io *io, void *context,
     169             :                 void *context2, ocf_end_io_t fn)
     170             : {
     171           0 :         io->priv1 = context;
     172           0 :         io->priv2 = context2;
     173           0 :         io->end = fn;
     174           0 : }
     175             : 
     176             : /**
     177             :  * @brief Set OCF IO start function
     178             :  *
     179             :  * @param[in] io OCF IO
     180             :  * @param[in] fn Start callback function
     181             :  */
     182             : static inline void ocf_io_set_start(struct ocf_io *io, ocf_start_io_t fn)
     183             : {
     184             :         io->start = fn;
     185             : }
     186             : 
     187             : /**
     188             :  * @brief Set OCF IO handle function
     189             :  *
     190             :  * @param[in] io OCF IO
     191             :  * @param[in] fn Handle callback function
     192             :  */
     193             : static inline void ocf_io_set_handle(struct ocf_io *io, ocf_handle_io_t fn)
     194             : {
     195             :         io->handle = fn;
     196             : }
     197             : 
     198             : /**
     199             :  * @brief Set up data vector in OCF IO
     200             :  *
     201             :  * @note Wrapper for set up data vector function
     202             :  *
     203             :  * @param[in] io OCF IO to set up
     204             :  * @param[in] data Source data vector
     205             :  * @param[in] offset Data offset in source data vector
     206             :  *
     207             :  * @retval 0 Data set up successfully
     208             :  * @retval Non-zero Data set up failure
     209             :  */
     210             : int ocf_io_set_data(struct ocf_io *io, ctx_data_t *data, uint32_t offset);
     211             : 
     212             : /**
     213             :  * @brief Get data vector from OCF IO
     214             :  *
     215             :  * @note Wrapper for get data vector function
     216             :  *
     217             :  * @param[in] io OCF IO to get data
     218             :  *
     219             :  * @return Data vector from IO
     220             :  */
     221             : ctx_data_t *ocf_io_get_data(struct ocf_io *io);
     222             : 
     223             : /**
     224             :  * @brief Handle IO in cache engine
     225             :  *
     226             :  * @param[in] io OCF IO to be handled
     227             :  * @param[in] opaque OCF opaque
     228             :  */
     229             : void ocf_io_handle(struct ocf_io *io, void *opaque);
     230             : 
     231             : /**
     232             :  * @brief Get volume associated with io
     233             :  *
     234             :  * @param[in] io OCF IO to be handled
     235             :  */
     236             : ocf_volume_t ocf_io_get_volume(struct ocf_io *io);
     237             : 
     238             : #endif /* __OCF_IO_H__ */

Generated by: LCOV version 1.15