FEMU
原版 master 7e238cc
FEMU: Accurate, Scalable and Extensible NVMe SSD Emulator (FAST'18)
|
|
浏览该文件的文档.
250 #define OC12_MAX_GRPS_PR_IDENT (20)
251 #define OC12_FEAT_EXT_START 64
252 #define OC12_FEAT_EXT_END 127
253 #define OC12_PBA_UNMAPPED UINT64_MAX
254 #define OC12_LBA_UNMAPPED UINT64_MAX
261 QEMU_BUILD_BUG_ON(
sizeof(
Oc12RwCmd) != 64);
262 QEMU_BUILD_BUG_ON(
sizeof(
Oc12DmCmd) != 64);
263 QEMU_BUILD_BUG_ON(
sizeof(
Oc12IdCtrl) != 4096);
uint16_t dma_write_prp(FemuCtrl *n, uint8_t *ptr, uint32_t len, uint64_t prp1, uint64_t prp2)
Definition: dma.c:112
uint8_t mtype
Definition: oc12.h:124
uint8_t flags
Definition: oc12.h:40
uint32_t nsid
Definition: oc12.h:42
uint8_t num_ch
Definition: nvme.h:1158
uint32_t blk_per_pl
Definition: oc12.h:195
uint16_t cpar
Definition: oc12.h:145
pthread_spinlock_t chnl_locks[FEMU_MAX_NUM_CHNLS]
Definition: nvme.h:1305
int meta_len
Definition: oc12.h:228
static int oc12_init_bbtbl(FemuCtrl *n, NvmeNamespace *ns)
Definition: oc12.c:794
static int oc12_init_params(FemuCtrl *n)
Definition: oc12.c:862
uint8_t flash_type
Definition: nvme.h:1339
@ NVME_LBA_RANGE
Definition: nvme.h:540
uint64_t pg_mask
Definition: oc12.h:113
uint16_t rsvd2[6]
Definition: oc12.h:35
uint8_t ver_id
Definition: oc12.h:150
uint8_t num_ch
Definition: oc12.h:127
uint16_t pgs_per_blk
Definition: oc12.h:178
femu相关控制参数和数据成员
Definition: nvme.h:1184
#define PPA_SEC(ln, ppa)
Definition: nand.h:118
#define OC12_LBA_UNMAPPED
Definition: oc12.h:254
uint32_t tbet
Definition: oc12.h:141
FemuExtCtrlOps ext_ops
nvme到各模式ssd接口
Definition: nvme.h:1220
uint32_t lun_units
Definition: oc12.h:200
#define PPA_BLK(ln, ppa)
Definition: nand.h:116
uint16_t cid
Definition: oc12.h:68
static void oc12_check_size(void)
Definition: oc12.h:256
QEMUSGList qsg
dma用
Definition: nvme.h:984
struct Oc12IdAddrFormat ppaf
Definition: oc12.h:156
static int oc12_read_tbls(FemuCtrl *n)
Definition: oc12.c:701
Oc12IdCtrl id_ctrl
Definition: oc12.h:218
uint16_t csecs
Definition: oc12.h:134
uint8_t vmnt
Definition: oc12.h:151
uint64_t lun_mask
Definition: oc12.h:110
unsigned long * uncorrectable
Definition: nvme.h:1070
#define femu_log(fmt,...)
Definition: nvme.h:1514
uint32_t nsid
Definition: oc12.h:69
uint8_t num_pln
Definition: oc12.h:186
uint32_t rsvd4[3]
Definition: oc12.h:62
uint32_t sec_per_pl
Definition: oc12.h:190
struct FemuExtCtrlOps FemuExtCtrlOps
扩展操作接口,具体实现在各模式ssd中
uint8_t opcode
Definition: oc12.h:51
uint32_t tbl_entries
Definition: nvme.h:1077
Oc12IdGroup groups[4]
Definition: oc12.h:158
int ch
Definition: oc12.h:243
uint32_t nsid
Definition: oc12.h:85
struct Oc12AddrF Oc12AddrF
uint8_t lun_offset
Definition: oc12.h:116
@ OC12_ADM_CMD_SET_BB_TBL
Definition: oc12.h:10
struct Oc12DmCmd Oc12DmCmd
uint8_t blk_offset
Definition: oc12.h:118
uint32_t total_units
Definition: oc12.h:202
int lun
Definition: oc12.h:244
uint8_t max_sec_per_rq
Definition: nvme.h:1157
static uint64_t ppa2secidx(Oc12Ctrl *ln, uint64_t ppa)
Definition: oc12.c:25
@ OC12_ADM_CMD_GET_L2P_TBL
Definition: oc12.h:8
int backend_rw(SsdDramBackend *b, QEMUSGList *qsg, uint64_t *lbal, bool is_write)
Definition: dram.c:37
#define femu_debug(fmt,...)
Definition: nvme.h:1507
static uint8_t get_page_type(int flash_type, int pg)
Definition: nand.h:126
#define NVME_ID_NS_LBAF_MS(ns, lba_index)
Definition: nvme.h:37
uint8_t opcode
Definition: oc12.h:66
@ NVME_SUCCESS
Definition: nvme.h:526
uint64_t * tbl
Definition: nvme.h:1078
uint32_t trdm
Definition: oc12.h:138
NvmeBar bar
Definition: nvme.h:1188
int64_t advance_chip_timestamp(FemuCtrl *n, int lunid, uint64_t now, int opcode, uint8_t page_type)
Definition: timing.c:72
static void oc12_set_ctrl_str(FemuCtrl *n)
Definition: oc12.c:1061
uint8_t flags
Definition: oc12.h:67
static bool is_oc12_admin_cmd(uint8_t opcode)
Definition: oc12.c:8
uint8_t rsvd3
Definition: oc12.h:61
Oc12Responsibility
Definition: oc12.h:211
uint64_t prp1
Definition: oc12.h:56
uint64_t slba
Definition: oc12.h:78
volatile int64_t chip_next_avail_time[FEMU_MAX_NUM_CHIPS]
Definition: nvme.h:1302
uint64_t prp2
Definition: oc12.h:45
uint16_t rsvd2
Definition: oc12.h:136
#define PPA_PLN(ln, ppa)
Definition: nand.h:115
static uint16_t oc12_write(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc12.c:493
struct Oc12BbtGet Oc12BbtGet
uint16_t cid
Definition: oc12.h:41
@ Oc12RSP_ECC
Definition: oc12.h:213
uint32_t sec_per_lun
Definition: oc12.h:192
uint32_t trdt
Definition: oc12.h:137
uint16_t dma_read_prp(FemuCtrl *n, uint8_t *ptr, uint32_t len, uint64_t prp1, uint64_t prp2)
Definition: dma.c:137
@ OC12_ADM_CMD_GET_BB_TBL
Definition: oc12.h:9
@ NVME_CMD_WRITE
Definition: nvme.h:340
uint64_t start_block
Definition: nvme.h:1074
int cnt
Definition: oc12.h:247
@ NVME_DNR
Definition: nvme.h:581
uint8_t opcode
Definition: oc12.h:39
uint64_t prp1
Definition: oc12.h:31
uint8_t mtype
Definition: oc12.h:183
uint16_t pgs_per_blk
Definition: nvme.h:1156
uint8_t opcode
Definition: oc12.h:26
struct Oc12Params Oc12Params
Oc12MetaState
Definition: oc12.h:19
uint16_t revid
Definition: oc12.h:164
Oc12AddrF ppaf
Definition: oc12.h:219
static uint16_t oc12_nvme_rw(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc12.c:1036
uint8_t page_type
Definition: oc12.h:246
uint8_t bbt_auto_gen
Definition: oc12.h:222
uint8_t meta_auto_gen
Definition: oc12.h:223
uint64_t prp2
Definition: oc12.h:73
@ NVME_UNRECOVERED_READ
Definition: nvme.h:573
Oc12AdminCommands
Definition: oc12.h:6
QEMUIOVector iov
Definition: nvme.h:985
uint16_t fpg_sz
Definition: oc12.h:133
static uint16_t oc12_identity(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc12.c:576
#define OC12_PBA_UNMAPPED
Definition: oc12.h:253
static uint16_t oc12_read(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc12.c:419
#define PPA_LUN(ln, ppa)
Definition: nand.h:114
static int oc12_meta_state_set_written(Oc12Ctrl *ln, uint64_t ppa)
Definition: oc12.c:215
uint32_t thresv
Definition: oc12.h:170
int64_t stime
io开始时间
Definition: nvme.h:987
uint8_t num_lun
Definition: nvme.h:1159
NvmeIdNs id_ns
Definition: nvme.h:1067
uint64_t cap
Definition: nvme.h:40
uint8_t fmtype
Definition: oc12.h:184
uint8_t flags
Definition: oc12.h:27
uint64_t prp1
Definition: oc12.h:72
int meta_tbytes
Definition: oc12.h:227
uint8_t res[906]
Definition: oc12.h:146
void nvme_set_ctrl_name(FemuCtrl *n, const char *mn, const char *sn, int *dev_id)
Definition: nvme-util.c:294
uint8_t vs[3712]
Definition: nvme.h:895
uint64_t pln_mask
Definition: oc12.h:111
uint32_t ch_units
Definition: oc12.h:201
uint8_t tblid[4]
Definition: oc12.h:162
static uint16_t oc12_rw_check_req(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req, uint64_t *psl, uint32_t nr_pages, uint32_t nlb, uint64_t data_size, uint64_t meta_size)
Definition: oc12.c:243
uint8_t num_pln
Definition: oc12.h:129
uint32_t pg_units
Definition: oc12.h:198
uint32_t rsvd1[8]
Definition: oc12.h:86
static void parse_ppa_list(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req, AddrBucket *bucket, int *nr)
Definition: oc12.c:310
struct Oc12IdCtrl Oc12IdCtrl
uint32_t tprt
Definition: oc12.h:139
uint16_t num_blk
Definition: oc12.h:131
void nvme_addr_read(FemuCtrl *n, hwaddr addr, void *buf, int size)
Definition: dma.c:3
static uint16_t oc12_admin_cmd(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc12.c:713
static uint16_t oc12_bbt_set(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc12.c:655
uint32_t pl_units
Definition: oc12.h:197
uint8_t ch_offset
Definition: oc12.h:115
uint32_t rsvd1
Definition: oc12.h:165
uint64_t prp1
Definition: nvme.h:412
uint32_t tprm
Definition: oc12.h:140
uint8_t flags
Definition: oc12.h:83
uint8_t int_meta_size
Definition: oc12.h:229
struct AddrBucket AddrBucket
@ Oc12PMODE_DUAL
Dual-plane (NVM_IO_DUAL_ACCESS)
Definition: oc12.h:207
uint32_t rsvd1[4]
Definition: oc12.h:30
uint32_t nlb
Definition: oc12.h:88
@ OC12_CMD_READ
Definition: oc12.h:15
uint8_t flags
Definition: oc12.h:52
Oc12Ctrl * oc12_ctrl
Definition: nvme.h:1301
uint16_t sos
Definition: nvme.h:1161
pthread_spinlock_t chip_locks[FEMU_MAX_NUM_CHIPS]
Definition: nvme.h:1303
static void oc12_exit(FemuCtrl *n)
Definition: oc12.c:1031
uint16_t sec_size
Definition: oc12.h:179
int init_nand_flash(void *opaque)
Definition: nand.c:148
uint32_t sec_per_ch
Definition: oc12.h:193
uint8_t mdts
Definition: nvme.h:701
uint16_t is_write
是否为写操作
Definition: nvme.h:973
struct oc12_metadata_format __attribute__((__packed__))
void nvme_addr_write(FemuCtrl *n, hwaddr addr, void *buf, int size)
Definition: dma.c:13
struct Oc12IdAddrFormat Oc12IdAddrFormat
uint8_t sec_per_pg
Definition: oc12.h:180
@ OC12_SEC_UNKNOWN
Definition: oc12.h:20
uint32_t nsid
Definition: oc12.h:54
uint32_t total_secs
Definition: oc12.h:194
uint32_t mccap
Definition: oc12.h:144
uint32_t nsid
Definition: nvme.h:410
uint16_t sos
Definition: oc12.h:135
NvmeIdCtrl id_ctrl
Definition: nvme.h:1285
uint64_t prp1
Definition: oc12.h:44
@ OC12_ADM_CMD_IDENTITY
Definition: oc12.h:7
uint8_t strict
Definition: oc12.h:225
#define FEMU_MAX_NUM_CHIPS
Definition: nvme.h:1151
uint32_t rsvd4[4]
Definition: oc12.h:47
uint16_t verid
Definition: oc12.h:163
uint16_t cid
Definition: oc12.h:84
uint8_t rsvd1
Definition: oc12.h:130
uint64_t sec_mask
Definition: oc12.h:114
static int oc12_init_misc(FemuCtrl *n)
Definition: oc12.c:836
static int oc12_init_meta(Oc12Ctrl *ln)
Definition: oc12.c:775
uint64_t prp2
Definition: oc12.h:32
uint32_t state
Definition: oc12.h:2
static int oc12_read_oob_meta(Oc12Ctrl *ln, uint64_t ppa, void *meta)
Definition: oc12.c:84
#define NVME_ID_NS_LBAF_DS(ns, lba_index)
Definition: nvme.h:36
uint8_t value
Definition: oc12.h:60
static void oc12_init(FemuCtrl *n, Error **errp)
Definition: oc12.c:1070
@ NVME_INVALID_OPCODE
Definition: nvme.h:527
uint16_t nlb
Definition: oc12.h:75
uint8_t opcode
Definition: oc12.h:82
uint8_t pln_offset
Definition: oc12.h:117
uint64_t nsze
Definition: nvme.h:864
uint16_t control
Definition: oc12.h:76
uint32_t rsvd2[8]
Definition: oc12.h:171
uint8_t debug
Definition: oc12.h:224
uint8_t num_lun
Definition: oc12.h:128
static int oc12_meta_blk_set_erased(NvmeNamespace *ns, Oc12Ctrl *ln, uint64_t *psl, int nr_ppas)
Definition: oc12.c:113
uint64_t blk_mask
Definition: oc12.h:112
Oc12Bbt ** bbtbl
Definition: nvme.h:1079
uint8_t res
Definition: oc12.h:153
uint8_t secs_per_pg
Definition: nvme.h:1155
uint8_t num_lun
Definition: oc12.h:187
Oc12Pmode
Definition: oc12.h:205
uint32_t tfact
Definition: oc12.h:167
uint64_t spba
Definition: oc12.h:74
#define PPA_PG(ln, ppa)
Definition: nand.h:117
void set_latency(FemuCtrl *n)
Definition: timing.c:3
uint16_t sec_size
Definition: nvme.h:1154
uint16_t cid
Definition: oc12.h:28
static int oc12_advance_status(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc12.c:345
uint32_t mpos
Definition: oc12.h:143
static void oc12_init_id_ctrl(Oc12Ctrl *ln)
Definition: oc12.c:750
uint16_t opcode
Definition: nvme.h:297
int nvme_register_ocssd12(FemuCtrl *n)
Definition: oc12.c:1084
uint32_t dsmgmt
Definition: oc12.h:77
static void * oc12_meta_index(Oc12Ctrl *ln, void *meta, uint32_t index)
Definition: oc12.c:238
uint8_t cgrps
Definition: oc12.h:152
uint64_t metadata
Definition: oc12.h:71
Oc12Params params
Definition: oc12.h:217
uint8_t resv[228]
Definition: oc12.h:157
static uint32_t oc12_tbl_size(NvmeNamespace *ns)
Definition: oc12.c:571
uint32_t sec_per_blk
Definition: oc12.h:191
uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVector *iov, uint64_t prp1, uint64_t prp2, uint32_t len, FemuCtrl *n)
Definition: dma.c:23
uint32_t tblks
Definition: oc12.h:166
static int oc12_write_oob_meta(Oc12Ctrl *ln, uint64_t ppa, void *meta)
Definition: oc12.c:71
static void oc12_release_locks(FemuCtrl *n)
Definition: oc12.c:821
@ Oc12PMODE_QUAD
Quad-plane (NVM_IO_QUAD_ACCESS)
Definition: oc12.h:208
static void oc12_read_ppa_list(FemuCtrl *n, Oc12RwCmd *cmd, uint64_t *ppa_list)
Definition: oc12.c:291
uint16_t cid
Definition: oc12.h:53
uint32_t dom
Definition: oc12.h:155
uint64_t slba
Definition: oc12.h:33
static int oc12_init_more(FemuCtrl *n)
Definition: oc12.c:882
static void oc12_tbl_initialize(NvmeNamespace *ns)
Definition: oc12.c:16
uint32_t nsid
Definition: oc12.h:29
struct Oc12RwCmd Oc12RwCmd
uint64_t rsvd2
Definition: oc12.h:70
uint16_t num_pg
Definition: oc12.h:132
uint8_t flbas
Definition: nvme.h:869
uint8_t blk[0]
Definition: oc12.h:172
int pg
Definition: oc12.h:245
uint32_t tdresv
Definition: oc12.h:169
uint8_t num_pln
Definition: nvme.h:1160
@ Oc12RSP_L2P
Definition: oc12.h:212
int64_t advance_channel_timestamp(FemuCtrl *n, int ch, uint64_t now, int opcode)
Definition: timing.c:38
int64_t expire_time
io应该结束的时间
Definition: nvme.h:990
uint32_t tbem
Definition: oc12.h:142
@ OC12_CMD_WRITE
Definition: oc12.h:14
uint32_t nlb
Definition: oc12.h:34
uint8_t pg_offset
Definition: oc12.h:119
static uint16_t oc12_get_l2p_tbl(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc12.c:591
uint64_t prp2
Definition: oc12.h:57
volatile int64_t chnl_next_avail_time[FEMU_MAX_NUM_CHNLS]
Definition: nvme.h:1304
@ OC12_SEC_ERASED
Definition: oc12.h:22
uint64_t spba
Definition: oc12.h:87
uint8_t num_ch
Definition: oc12.h:185
uint32_t num_namespaces
Definition: nvme.h:1232
uint8_t fmtype
Definition: oc12.h:125
uint8_t max_sec_per_rq
Definition: oc12.h:181
SsdDramBackend * mbe
femu后端内存(实际数据)
Definition: nvme.h:1322
uint64_t spba
Definition: oc12.h:46
uint16_t res16
Definition: oc12.h:126
uint16_t sos
Definition: oc12.h:188
void * state
Definition: nvme.h:1170
describe a physical page addr
Definition: ftl.h:69
static int qemu_fls(int i)
Definition: oc12.c:3
uint32_t tgrown
Definition: oc12.h:168
uint8_t read_l2p_tbl
Definition: oc12.h:220
@ NVME_CMD_READ
Definition: nvme.h:341
uint64_t slba
开始lba
Definition: nvme.h:972
static uint16_t oc12_bbt_get(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc12.c:621
uint64_t spba
Definition: oc12.h:58
uint32_t blk_units
Definition: oc12.h:199
uint64_t prp2
Definition: nvme.h:413
#define NVME_CAP_SET_OC(cap, val)
Definition: nvme.h:117
@ NVME_INVALID_NSID
Definition: nvme.h:537
@ OC12_SEC_WRITTEN
Definition: oc12.h:21
NvmeNamespace * namespaces
Definition: nvme.h:1279
static uint16_t oc12_io_cmd(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc12.c:1043
uint16_t nlb
Definition: oc12.h:59
Oc12DmCommands
Definition: oc12.h:13
uint32_t cap
Definition: oc12.h:154
uint64_t rsvd1[2]
Definition: oc12.h:43
uint8_t * meta_buf
Definition: oc12.h:226
static uint16_t oc12_erase_async(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc12.c:733
uint32_t rsvd2[3]
Definition: oc12.h:89
@ Oc12PMODE_SNGL
Single-plane
Definition: oc12.h:206
uint8_t bbt_gen_freq
Definition: oc12.h:221
OcCtrlParams oc_params
Definition: nvme.h:1299
struct Oc12GetL2PTbl Oc12GetL2PTbl
uint64_t ns_blks
Definition: nvme.h:1073
uint64_t ch_mask
Definition: oc12.h:109
uint16_t page_size
Definition: nvme.h:1224
uint8_t sec_offset
Definition: oc12.h:120
@ NVME_INVALID_FIELD
Definition: nvme.h:528
#define FEMU_MAX_NUM_CHNLS
Definition: nvme.h:1150
static int oc12_meta_state_get(Oc12Ctrl *ln, uint64_t ppa, uint32_t *state)
Definition: oc12.c:96
#define NVME_ID_NS_FLBAS_INDEX(flbas)
Definition: nvme.h:920
@ OC12_CMD_ERASE
Definition: oc12.h:16
struct Oc12IdGroup Oc12IdGroup
#define PPA_CH(ln, ppa)
Definition: nand.h:113
struct Oc12BbtSet Oc12BbtSet
uint64_t rsvd1[2]
Definition: oc12.h:55
#define femu_err(fmt,...)
Definition: nvme.h:1511