2022-06-03 19:15:11 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2018-10-29 11:29:03 +00:00
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-09-06 12:08:03 +00:00
|
|
|
#ifndef FTL_ADDR_H
|
|
|
|
#define FTL_ADDR_H
|
2018-10-29 11:29:03 +00:00
|
|
|
|
2018-10-29 12:17:34 +00:00
|
|
|
#include "spdk/stdinc.h"
|
2018-10-29 11:29:03 +00:00
|
|
|
|
2019-09-06 12:08:03 +00:00
|
|
|
/* Marks address as invalid */
|
|
|
|
#define FTL_ADDR_INVALID (-1)
|
2018-10-29 11:29:03 +00:00
|
|
|
/* Marks LBA as invalid */
|
|
|
|
#define FTL_LBA_INVALID ((uint64_t)-1)
|
|
|
|
/* Smallest data unit size */
|
|
|
|
#define FTL_BLOCK_SIZE 4096
|
|
|
|
|
2020-01-07 13:29:27 +00:00
|
|
|
/* This structure represents on-disk address. It can have one of the following */
|
2018-10-29 11:29:03 +00:00
|
|
|
/* formats: */
|
2019-09-20 11:26:16 +00:00
|
|
|
/* - offset inside the disk */
|
2020-01-07 13:29:27 +00:00
|
|
|
/* - cache_offset inside the cache (indicated by the cached flag) */
|
2018-10-29 11:29:03 +00:00
|
|
|
/* - packed version of the two formats above (can be only used when the */
|
2019-09-20 11:26:16 +00:00
|
|
|
/* offset can be represented in less than 32 bits) */
|
2018-10-29 11:29:03 +00:00
|
|
|
/* Packed format is used, when possible, to avoid wasting RAM on the L2P table. */
|
2019-09-06 12:08:03 +00:00
|
|
|
struct ftl_addr {
|
2018-10-29 11:29:03 +00:00
|
|
|
union {
|
|
|
|
struct {
|
2020-01-07 13:29:27 +00:00
|
|
|
uint64_t cache_offset : 63;
|
|
|
|
uint64_t cached : 1;
|
2018-10-29 11:29:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
struct {
|
2020-01-07 13:29:27 +00:00
|
|
|
uint32_t cache_offset : 31;
|
|
|
|
uint32_t cached : 1;
|
2018-10-29 11:29:03 +00:00
|
|
|
};
|
|
|
|
|
2019-09-20 11:26:16 +00:00
|
|
|
uint32_t offset;
|
2018-10-29 11:29:03 +00:00
|
|
|
};
|
|
|
|
uint32_t rsvd;
|
|
|
|
} pack;
|
|
|
|
|
2019-09-20 11:26:16 +00:00
|
|
|
uint64_t offset;
|
2018-10-29 11:29:03 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-09-06 12:08:03 +00:00
|
|
|
#endif /* FTL_ADDR_H */
|