LCOV - code coverage report
Current view: top level - lib/ftl/utils - ftl_addr_utils.h (source / functions) Hit Total Coverage
Test: ut_cov_unit.info Lines: 0 32 0.0 %
Date: 2024-07-15 05:34:25 Functions: 0 4 0.0 %

          Line data    Source code
       1             : /*   SPDX-License-Identifier: BSD-3-Clause
       2             :  *   Copyright (C) 2022 Intel Corporation.
       3             :  *   All rights reserved.
       4             :  */
       5             : 
       6             : #ifndef FTL_ADDR_UTILS_H
       7             : #define FTL_ADDR_UTILS_H
       8             : 
       9             : #include "ftl_core.h"
      10             : 
      11             : static inline ftl_addr
      12           0 : ftl_addr_load(struct spdk_ftl_dev *dev, void *buffer, uint64_t offset)
      13             : {
      14           0 :         if (ftl_addr_packed(dev)) {
      15           0 :                 uint32_t *b32 = buffer;
      16           0 :                 ftl_addr addr = b32[offset];
      17             : 
      18           0 :                 if (addr == (uint32_t)FTL_ADDR_INVALID) {
      19           0 :                         return FTL_ADDR_INVALID;
      20             :                 } else {
      21           0 :                         return addr;
      22             :                 }
      23             :         } else {
      24           0 :                 uint64_t *b64 = buffer;
      25           0 :                 return b64[offset];
      26             :         }
      27             : }
      28             : 
      29             : static inline void
      30           0 : ftl_addr_store(struct spdk_ftl_dev *dev, void *buffer, uint64_t offset, ftl_addr addr)
      31             : {
      32           0 :         if (ftl_addr_packed(dev)) {
      33           0 :                 uint32_t *b32 = buffer;
      34           0 :                 b32[offset] = addr;
      35             :         } else {
      36           0 :                 uint64_t *b64 = buffer;
      37           0 :                 b64[offset] = addr;
      38             :         }
      39           0 : }
      40             : 
      41             : static inline uint64_t
      42           0 : ftl_lba_load(struct spdk_ftl_dev *dev, void *buffer, uint64_t offset)
      43             : {
      44           0 :         if (ftl_addr_packed(dev)) {
      45           0 :                 uint32_t *b32 = buffer;
      46           0 :                 uint32_t lba = b32[offset];
      47             : 
      48           0 :                 if (lba == (uint32_t)FTL_LBA_INVALID) {
      49           0 :                         return FTL_LBA_INVALID;
      50             :                 } else {
      51           0 :                         return lba;
      52             :                 }
      53             :         } else {
      54           0 :                 uint64_t *b64 = buffer;
      55           0 :                 return b64[offset];
      56             :         }
      57             : }
      58             : 
      59             : static inline void
      60           0 : ftl_lba_store(struct spdk_ftl_dev *dev, void *buffer, uint64_t offset, uint64_t lba)
      61             : {
      62           0 :         if (ftl_addr_packed(dev)) {
      63           0 :                 uint32_t *b32 = buffer;
      64           0 :                 b32[offset] = lba;
      65             :         } else {
      66           0 :                 uint64_t *b64 = buffer;
      67           0 :                 b64[offset] = lba;
      68             :         }
      69           0 : }
      70             : 
      71             : #endif /* FTL_ADDR_UTILS_H */

Generated by: LCOV version 1.15