2018-10-29 11:29:03 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
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 */
|