FEMU  原版 master 7e238cc
FEMU: Accurate, Scalable and Extensible NVMe SSD Emulator (FAST'18)
oc20.h
浏览该文件的文档.
1 #ifndef __FEMU_OC20_H
2 #define __FEMU_OC20_H
3 
4 #include "../nvme.h"
5 
6 #define OC20_VID (0x1d1d)
7 #define OC20_DID (0x1f1f)
8 #define OC20_MAGIC ('L' << 24 | 'N' << 16 | 'V' << 8 | 'M')
9 #define OC20_CMD_MAX_LBAS (64)
10 
11 #define OC20_NS_LOGPAGE_CHUNK_INFO_BLK_OFFSET(ns) \
12  ((ns)->blk.begin + sizeof(Oc20NamespaceGeometry))
13 
14 #define OC20_LBA_GET_SECTR(lbaf, lba) \
15  ((lba & (lbaf)->sec_mask) \
16  >> (lbaf)->sec_offset)
17 
18 #define OC20_LBA_GET_CHUNK(lbaf, lba) \
19  ((lba & (lbaf)->chk_mask) \
20  >> (lbaf)->chk_offset)
21 
22 #define OC20_LBA_GET_PUNIT(lbaf, lba) \
23  ((lba & (lbaf)->lun_mask) \
24  >> (lbaf)->lun_offset)
25 
26 #define OC20_LBA_GET_GROUP(lbaf, lba) \
27  (lba >> (lbaf)->grp_offset)
28 
29 #define OC20_LBA(lbaf, group, punit, chunk, sectr) \
30  (sectr << (lbaf)->sec_offset \
31  | chunk << (lbaf)->chk_offset \
32  | punit << (lbaf)->lun_offset \
33  | group << (lbaf)->grp_offset)
34 
35 #define OC20_GROUP_FROM_CHUNK_INDEX(lns, idx) \
36  (idx / (lns)->chks_per_grp)
37 
38 #define OC20_PUNIT_FROM_CHUNK_INDEX(lns, idx) \
39  (idx % (lns)->chks_per_grp / (lns)->chks_per_lun)
40 
41 #define OC20_CHUNK_FROM_CHUNK_INDEX(lns, idx) \
42  (idx % (lns)->chks_per_lun)
43 
44 #define OC20_LBA_FROM_CHUNK_INDEX(lns, idx) \
45  (OC20_GROUP_FROM_CHUNK_INDEX(lns, idx) \
46  << (lns)->lbaf.grp_offset \
47  | OC20_PUNIT_FROM_CHUNK_INDEX(lns, idx) \
48  << (lns)->lbaf.lun_offset \
49  | OC20_CHUNK_FROM_CHUNK_INDEX(lns, idx) \
50  << (lns)->lbaf.chk_offset)
51 
52 #define OC20_LBA_FORMAT_TEMPLATE \
53  "lba 0xffffffffffffffff pugrp 255 punit 255 chunk 65535 sectr 4294967295"
54 
55 #define OC20_CHUNK_RESETABLE \
56  (OC20_CHUNK_FREE | OC20_CHUNK_CLOSED | OC20_CHUNK_OPEN)
57 
62 };
63 
68 };
69 
71  OC20_CHUNK_FREE = 1 << 0,
73  OC20_CHUNK_OPEN = 1 << 2,
75 };
76 
81 };
82 
90 };
91 
92 typedef struct Oc20ChunkState {
93  uint8_t state;
94  uint8_t type;
95  uint8_t wear_index;
96  uint8_t rsvd[5];
97  uint64_t slba;
98  uint64_t cnlb;
99  uint64_t wp;
100 } Oc20CS;
101 
102 typedef struct Oc20RwCmd {
103  uint16_t opcode : 8;
104  uint16_t fuse : 2;
105  uint16_t rsvd1 : 4;
106  uint16_t psdt : 2;
107  uint16_t cid;
108  uint32_t nsid;
109  uint64_t rsvd2;
110  uint64_t metadata;
112  uint64_t lbal;
113  uint16_t nlb;
114  uint16_t control;
115  uint32_t rsvd3;
116  uint64_t rsvd4;
117 } Oc20RwCmd;
118 
119 typedef struct Oc20DmCmd {
120  uint8_t opcode;
121  uint8_t flags;
122  uint16_t cid;
123  uint32_t nsid;
124  uint32_t rsvd1[8];
125  uint64_t spba;
126  uint32_t nlb;
127  uint32_t rsvd2[3];
128 } Oc20DmCmd;
129 
130 typedef struct Oc20AddrF {
131  uint64_t grp_mask;
132  uint64_t lun_mask;
133  uint64_t chk_mask;
134  uint64_t sec_mask;
135  uint8_t grp_offset;
136  uint8_t lun_offset;
137  uint8_t chk_offset;
138  uint8_t sec_offset;
139 } Oc20AddrF;
140 
141 typedef struct Oc20IdGeo {
142  uint16_t num_grp;
143  uint16_t num_lun;
144  uint32_t num_chk;
145  uint32_t clba;
146  uint8_t rsvd[52];
147 } Oc20IdGeo;
148 
149 typedef struct Oc20IdWrt {
150  uint32_t ws_min;
151  uint32_t ws_opt;
152  uint32_t mw_cunits;
153  uint32_t max_open_chks;
154  uint32_t max_open_punits;
155  uint8_t rsvd[44];
156 } Oc20IdWrt;
157 
158 typedef struct Oc20IdPerf {
159  uint32_t trdt;
160  uint32_t trdm;
161  uint32_t tprt;
162  uint32_t tprm;
163  uint32_t tbet;
164  uint32_t tbem;
165  uint8_t rsvd[40];
166 } Oc20IdPerf;
167 
168 typedef struct Oc20IdLBAF {
169  uint8_t grp_len;
170  uint8_t lun_len;
171  uint8_t chk_len;
172  uint8_t sec_len;
173  uint8_t rsvd[4];
174 } Oc20IdLBAF;
175 
176 typedef struct Oc20Header {
177  uint32_t magic;
178  uint32_t version;
179  uint32_t num_namespaces;
180  uint32_t rsvd;
181  uint64_t sector_size;
182  uint32_t md_size;
183  uint64_t ns_size;
184 } Oc20Header;
185 
186 typedef struct Oc20NamespaceGeometry {
187  struct {
188  uint8_t major;
189  uint8_t minor;
190  } ver;
191  uint8_t rsvd1[6];
193  uint32_t mccap;
194  uint8_t rsvd2[12];
195  uint8_t wit;
196  uint8_t rsvd3[31];
200  uint8_t rsvd4[3840];
202 
205  /* OCSSD 2.0 spec de-facto extension */
207 };
208 
211 };
212 
213 typedef struct Oc20Ctrl {
215 } Oc20Ctrl;
216 
217 typedef struct Oc20Namespace {
220 
221  /* reset and write fail error probabilities indexed by namespace */
222  uint8_t *resetfail;
223  uint8_t *writefail;
224 
225  /* derived values (for convenience) */
226  uint32_t chks_per_grp;
227  uint32_t chks_total;
228  uint32_t secs_per_chk;
229  uint32_t secs_per_lun;
230  uint32_t secs_per_grp;
231  uint32_t secs_total;
232 
233  /* chunk info log page */
234  uint64_t chunkinfo_size;
236 } Oc20Namespace;
237 
238 typedef struct Oc20AddrBucket {
239  int ch;
240  int lun;
241  int pg;
242  uint8_t page_type;
243  int cnt;
245 
246 typedef struct NvmeRequest NvmeRequest;
247 typedef struct FemuCtrl FemuCtrl;
248 
249 static inline void _oc20_check_size(void)
250 {
251  QEMU_BUILD_BUG_ON(sizeof(Oc20IdLBAF) != 8);
252  QEMU_BUILD_BUG_ON(sizeof(Oc20IdGeo) != 64);
253  QEMU_BUILD_BUG_ON(sizeof(Oc20IdWrt) != 64);
254  QEMU_BUILD_BUG_ON(sizeof(Oc20IdPerf) != 64);
255  QEMU_BUILD_BUG_ON(sizeof(Oc20RwCmd) != 64);
256  QEMU_BUILD_BUG_ON(sizeof(Oc20DmCmd) != 64);
257  QEMU_BUILD_BUG_ON(sizeof(Oc20NamespaceGeometry) != 4096);
258  QEMU_BUILD_BUG_ON(sizeof(Oc20CS) != 32);
259 }
260 
261 static inline int nvme_rw_is_write(NvmeRequest *req)
262 {
263  return req->cmd_opcode == NVME_CMD_WRITE;
264 }
265 
266 static inline int oc20_rw_is_write(NvmeRequest *req)
267 {
268  return nvme_rw_is_write(req) || req->cmd_opcode == OC20_CMD_VECT_WRITE;
269 }
270 
271 static inline uint64_t nvme_lba_to_sector_index(FemuCtrl *n, NvmeNamespace *ns,
272  uint64_t lba)
273 {
274  return lba;
275 }
276 
277 static inline int oc20_lba_valid(FemuCtrl *n, NvmeNamespace *ns, uint64_t lba)
278 {
279  Oc20Namespace *lns = ns->state;
280  Oc20IdGeo *geo = &lns->id_ctrl.geo;
281  Oc20AddrF *addrf = &lns->lbaf;
282 
283  return (OC20_LBA_GET_SECTR(addrf, lba) < geo->clba &&
284  OC20_LBA_GET_CHUNK(addrf, lba) < geo->num_chk &&
285  OC20_LBA_GET_PUNIT(addrf, lba) < geo->num_lun &&
286  OC20_LBA_GET_GROUP(addrf, lba) < geo->num_grp);
287 }
288 
289 static inline uint64_t oc20_lba_to_chunk_index(FemuCtrl *n, NvmeNamespace *ns,
290  uint64_t lba)
291 {
292  Oc20Namespace *lns = ns->state;
293  Oc20IdGeo *geo = &lns->id_ctrl.geo;
294  Oc20AddrF *addrf = &lns->lbaf;
295 
296  return (OC20_LBA_GET_CHUNK(addrf, lba) +
297  OC20_LBA_GET_PUNIT(addrf, lba) * geo->num_chk +
298  OC20_LBA_GET_GROUP(addrf, lba) * lns->chks_per_grp);
299 }
300 
301 static inline uint64_t oc20_lba_to_sector_index(FemuCtrl *n, NvmeNamespace *ns,
302  uint64_t lba)
303 {
304  Oc20Namespace *lns = ns->state;
305  Oc20AddrF *addrf = &lns->lbaf;
306 
307  return (OC20_LBA_GET_SECTR(addrf, lba) +
308  OC20_LBA_GET_CHUNK(addrf, lba) * lns->secs_per_chk +
309  OC20_LBA_GET_PUNIT(addrf, lba) * lns->secs_per_lun +
310  OC20_LBA_GET_GROUP(addrf, lba) * lns->secs_per_grp);
311 }
312 
313 #endif
dma_write_prp
uint16_t dma_write_prp(FemuCtrl *n, uint8_t *ptr, uint32_t len, uint64_t prp1, uint64_t prp2)
Definition: dma.c:112
Oc20Namespace::secs_per_grp
uint32_t secs_per_grp
Definition: oc20.h:230
Oc20Namespace::lbaf
Oc20AddrF lbaf
Definition: oc20.h:219
Oc20Ctrl
struct Oc20Ctrl Oc20Ctrl
OC20_SEC_UNKNOWN
@ OC20_SEC_UNKNOWN
Definition: oc20.h:65
Oc20NamespaceGeometry::lbaf
Oc20IdLBAF lbaf
Definition: oc20.h:192
Oc20IdPerf::tprm
uint32_t tprm
Definition: oc20.h:162
NvmeCmd
Definition: nvme.h:296
OcCtrlParams::num_ch
uint8_t num_ch
Definition: nvme.h:1158
Oc20RwCmd::rsvd4
uint64_t rsvd4
Definition: oc20.h:116
OC20_CMD_VECT_ERASE
@ OC20_CMD_VECT_ERASE
Definition: oc20.h:59
oc20_writefail_load
static int oc20_writefail_load(FemuCtrl *n, NvmeNamespace *ns, Error **errp)
Definition: oc20.c:656
Oc20StatusCodes
Oc20StatusCodes
Definition: oc20.h:83
NvmeCmd::cdw11
uint32_t cdw11
Definition: nvme.h:307
Oc20AddrBucket
struct Oc20AddrBucket Oc20AddrBucket
Oc20IdWrt::rsvd
uint8_t rsvd[44]
Definition: oc20.h:155
Oc20DmCmd::rsvd1
uint32_t rsvd1[8]
Definition: oc20.h:124
FemuCtrl::chnl_locks
pthread_spinlock_t chnl_locks[FEMU_MAX_NUM_CHNLS]
Definition: nvme.h:1305
Oc20IdLBAF::lun_len
uint8_t lun_len
Definition: oc20.h:170
Oc20Header
Definition: oc20.h:176
Oc20ChunkState::rsvd
uint8_t rsvd[5]
Definition: oc20.h:96
NvmeIdNs::nuse
uint64_t nuse
Definition: nvme.h:866
NvmeNamespace::id
uint32_t id
Definition: nvme.h:1071
Oc20NamespaceGeometry::rsvd1
uint8_t rsvd1[6]
Definition: oc20.h:191
Oc20NamespaceGeometry::rsvd3
uint8_t rsvd3[31]
Definition: oc20.h:196
Oc20Namespace::secs_total
uint32_t secs_total
Definition: oc20.h:231
Oc20ChunkState::type
uint8_t type
Definition: oc20.h:94
FemuCtrl
femu相关控制参数和数据成员
Definition: nvme.h:1184
Oc20IdWrt::ws_min
uint32_t ws_min
Definition: oc20.h:150
Oc20NamespaceGeometry::ver
struct Oc20NamespaceGeometry::@19 ver
Oc20IdGeo
struct Oc20IdGeo Oc20IdGeo
oc20_init
static void oc20_init(FemuCtrl *n, Error **errp)
Definition: oc20.c:1344
OC20_CHUNK_CLOSED
@ OC20_CHUNK_CLOSED
Definition: oc20.h:72
FemuCtrl::ext_ops
FemuExtCtrlOps ext_ops
nvme到各模式ssd接口
Definition: nvme.h:1220
NvmeIdNs
Definition: nvme.h:863
unlikely
#define unlikely(x)
Definition: rte_branch_prediction.h:38
NvmeRequest::qsg
QEMUSGList qsg
dma用
Definition: nvme.h:984
Oc20IdPerf
struct Oc20IdPerf Oc20IdPerf
NvmeIdNs::nlbaf
uint8_t nlbaf
Definition: nvme.h:868
OC20_MAGIC
#define OC20_MAGIC
Definition: oc20.h:8
oc20_nvme_ns_init_identify
static void oc20_nvme_ns_init_identify(FemuCtrl *n, NvmeIdNs *id_ns)
Definition: oc20.c:967
OC20_INVALID_RESET
@ OC20_INVALID_RESET
Definition: oc20.h:89
Oc20Header::md_size
uint32_t md_size
Definition: oc20.h:182
Oc20RwCmd::control
uint16_t control
Definition: oc20.h:114
Oc20AddrF
struct Oc20AddrF Oc20AddrF
femu_log
#define femu_log(fmt,...)
Definition: nvme.h:1514
OC20_WRITE_NEXT_UNIT
@ OC20_WRITE_NEXT_UNIT
Definition: oc20.h:85
Oc20IdGeo::num_chk
uint32_t num_chk
Definition: oc20.h:144
oc20_rw_check_write_req
static uint16_t oc20_rw_check_write_req(FemuCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc20.c:300
oc20_resetfail_load
static int oc20_resetfail_load(FemuCtrl *n, NvmeNamespace *ns, Error **errp)
Definition: oc20.c:629
NvmeCmd::mptr
uint64_t mptr
Definition: nvme.h:304
FemuExtCtrlOps
struct FemuExtCtrlOps FemuExtCtrlOps
扩展操作接口,具体实现在各模式ssd中
nvme_ns_init_predef
static void nvme_ns_init_predef(FemuCtrl *n, NvmeNamespace *ns)
Definition: oc20.c:1002
FemuCtrl::ms_max
uint8_t ms_max
Definition: nvme.h:1257
Oc20IdPerf::tbem
uint32_t tbem
Definition: oc20.h:164
Oc20Params::ws_opt
uint32_t ws_opt
Definition: nvme.h:1100
oc20_init_misc
static int oc20_init_misc(FemuCtrl *n)
Definition: oc20.c:1319
OC20_CHUNK_OPEN
@ OC20_CHUNK_OPEN
Definition: oc20.h:73
NvmeNamespace::meta
uint64_t meta
Definition: nvme.h:1086
Oc20AddrBucket::page_type
uint8_t page_type
Definition: oc20.h:242
oc20_init_namespaces
static int oc20_init_namespaces(FemuCtrl *n, Error **errp)
Definition: oc20.c:1268
OC20_CHUNK_INFO
@ OC20_CHUNK_INFO
Definition: oc20.h:210
Oc20RwCmd::dptr
NvmeCmdDptr dptr
Definition: oc20.h:111
Oc20ChunkState
Definition: oc20.h:92
backend_rw
int backend_rw(SsdDramBackend *b, QEMUSGList *qsg, uint64_t *lbal, bool is_write)
Definition: dram.c:37
lba
uint64_t lba
Definition: oc12.h:2
oc20_advance_wp
static uint16_t oc20_advance_wp(FemuCtrl *n, NvmeNamespace *ns, uint64_t lba, uint16_t nlb, NvmeRequest *req)
Definition: oc20.c:96
NvmeCmd::cdw13
uint32_t cdw13
Definition: nvme.h:309
femu_debug
#define femu_debug(fmt,...)
Definition: nvme.h:1507
NVME_SUCCESS
@ NVME_SUCCESS
Definition: nvme.h:526
FemuCtrl::bar
NvmeBar bar
Definition: nvme.h:1188
advance_chip_timestamp
int64_t advance_chip_timestamp(FemuCtrl *n, int lunid, uint64_t now, int opcode, uint8_t page_type)
Definition: timing.c:72
NVME_ADM_CMD_GET_LOG_PAGE
@ NVME_ADM_CMD_GET_LOG_PAGE
Definition: nvme.h:320
Oc20Namespace::writefail
uint8_t * writefail
Definition: oc20.h:223
oc20_rw_check_chunk_read
static uint16_t oc20_rw_check_chunk_read(FemuCtrl *n, NvmeCmd *cmd, NvmeRequest *req, uint64_t lba)
Definition: oc20.c:343
Oc20AddrF::grp_offset
uint8_t grp_offset
Definition: oc20.h:135
oc20_lba_valid
static int oc20_lba_valid(FemuCtrl *n, NvmeNamespace *ns, uint64_t lba)
Definition: oc20.h:277
Oc20Params::resetfail_fname
char * resetfail_fname
Definition: nvme.h:1108
oc20_set_ctrl_str
static void oc20_set_ctrl_str(FemuCtrl *n)
Definition: oc20.c:1295
Oc20Params::ws_min
uint32_t ws_min
Definition: nvme.h:1099
FemuCtrl::chip_next_avail_time
volatile int64_t chip_next_avail_time[FEMU_MAX_NUM_CHIPS]
Definition: nvme.h:1302
NVME_ERR_REC_DULBE
#define NVME_ERR_REC_DULBE(err_rec)
Definition: nvme.h:813
NvmeParams::ms
uint8_t ms
Definition: nvme.h:1134
Oc20RwCmd::nsid
uint32_t nsid
Definition: oc20.h:108
oc20_rw_check_vector_req
static uint16_t oc20_rw_check_vector_req(FemuCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc20.c:411
NvmeRequest::nlb
uint16_t nlb
逻辑块个数
Definition: nvme.h:974
oc20_rw_check_chunk_write
static uint16_t oc20_rw_check_chunk_write(FemuCtrl *n, NvmeCmd *cmd, uint64_t lba, uint32_t ws, NvmeRequest *req)
Definition: oc20.c:249
FemuCtrl::features
NvmeFeatureVal features
Definition: nvme.h:1284
dma_read_prp
uint16_t dma_read_prp(FemuCtrl *n, uint8_t *ptr, uint32_t len, uint64_t prp1, uint64_t prp2)
Definition: dma.c:137
Oc20Header
struct Oc20Header Oc20Header
NvmeNamespace
Definition: nvme.h:1065
NvmeNamespace::begin
uint64_t begin
Definition: nvme.h:1083
Oc20IdWrt
struct Oc20IdWrt Oc20IdWrt
NVME_CMD_WRITE
@ NVME_CMD_WRITE
Definition: nvme.h:340
NvmeParams
Definition: nvme.h:1112
NVME_DNR
@ NVME_DNR
Definition: nvme.h:581
Oc20DmCmd::spba
uint64_t spba
Definition: oc20.h:125
OC20_CHUNK_EARLY_CLOSE
@ OC20_CHUNK_EARLY_CLOSE
Definition: oc20.h:86
oc20_release_locks
static void oc20_release_locks(FemuCtrl *n)
Definition: oc20.c:1304
set_writefail_sector
static int set_writefail_sector(FemuCtrl *n, NvmeNamespace *ns, char *secinfo)
Definition: oc20.c:595
oc20_lba_to_sector_index
static uint64_t oc20_lba_to_sector_index(FemuCtrl *n, NvmeNamespace *ns, uint64_t lba)
Definition: oc20.h:301
NvmeCmd::nsid
uint32_t nsid
Definition: nvme.h:302
Oc20RwCmd::rsvd3
uint32_t rsvd3
Definition: oc20.h:115
OcCtrlParams::pgs_per_blk
uint16_t pgs_per_blk
Definition: nvme.h:1156
oc20_get_log
static uint16_t oc20_get_log(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc20.c:863
OC20_LBA
#define OC20_LBA(lbaf, group, punit, chunk, sectr)
Definition: oc20.h:29
Oc20NamespaceGeometry::wrt
Oc20IdWrt wrt
Definition: oc20.h:198
oc20_rw
static uint16_t oc20_rw(FemuCtrl *n, NvmeCmd *cmd, NvmeRequest *req, bool vector)
Definition: oc20.c:699
oc20_dma_write
static uint16_t oc20_dma_write(FemuCtrl *n, uint8_t *ptr, uint32_t len, NvmeCmd *cmd)
Definition: oc20.c:18
oc20_io_cmd
static uint16_t oc20_io_cmd(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc20.c:938
NVME_ID_NS_LBADS_BYTES
#define NVME_ID_NS_LBADS_BYTES(ns)
Definition: nvme.h:29
Oc20ChunkState::wp
uint64_t wp
Definition: oc20.h:99
is_oc20_admin_cmd
static bool is_oc20_admin_cmd(uint8_t opcode)
Definition: oc20.c:3
Oc20IdPerf::trdt
uint32_t trdt
Definition: oc20.h:159
Oc20Header::ns_size
uint64_t ns_size
Definition: oc20.h:183
NvmeRequest::iov
QEMUIOVector iov
Definition: nvme.h:985
NvmeNamespace::predef
uint64_t predef
Definition: nvme.h:1084
oc20_chunk_get_state
static Oc20CS * oc20_chunk_get_state(FemuCtrl *n, NvmeNamespace *ns, uint64_t lba)
Definition: oc20.c:85
Oc20IdLBAF
Definition: oc20.h:168
NvmeIdNs::ncap
uint64_t ncap
Definition: nvme.h:865
oc20_lba_to_chunk_index
static uint64_t oc20_lba_to_chunk_index(FemuCtrl *n, NvmeNamespace *ns, uint64_t lba)
Definition: oc20.h:289
Oc20Header::version
uint32_t version
Definition: oc20.h:178
Oc20NamespaceGeometry::minor
uint8_t minor
Definition: oc20.h:189
Oc20AddrF::sec_offset
uint8_t sec_offset
Definition: oc20.h:138
OC20_CHUNK_RESETABLE
#define OC20_CHUNK_RESETABLE
Definition: oc20.h:55
Oc20IdPerf
Definition: oc20.h:158
nvme_register_ocssd20
int nvme_register_ocssd20(FemuCtrl *n)
Definition: oc20.c:1363
Oc20IdWrt
Definition: oc20.h:149
NvmeRequest::stime
int64_t stime
io开始时间
Definition: nvme.h:987
OcCtrlParams::num_lun
uint8_t num_lun
Definition: nvme.h:1159
NvmeNamespace::id_ns
NvmeIdNs id_ns
Definition: nvme.h:1067
Oc20ChunkStates
Oc20ChunkStates
Definition: oc20.h:70
NvmeBar::cap
uint64_t cap
Definition: nvme.h:40
femu_oc20_init_id_ctrl
static void femu_oc20_init_id_ctrl(FemuCtrl *n, NvmeNamespace *ns, Oc20NamespaceGeometry *ln)
Definition: oc20.c:1019
oc20_chunk_info
static uint16_t oc20_chunk_info(FemuCtrl *n, NvmeCmd *cmd, uint32_t buf_len, uint64_t off)
Definition: oc20.c:821
Oc20IdGeo
Definition: oc20.h:141
Oc20RwCmd::cid
uint16_t cid
Definition: oc20.h:107
Oc20IdGeo::rsvd
uint8_t rsvd[52]
Definition: oc20.h:146
NvmeRequest::ns
struct NvmeNamespace * ns
Definition: nvme.h:970
Oc20DmCmd::flags
uint8_t flags
Definition: oc20.h:121
nvme_set_ctrl_name
void nvme_set_ctrl_name(FemuCtrl *n, const char *mn, const char *sn, int *dev_id)
Definition: nvme-util.c:294
NvmeIdNs::vs
uint8_t vs[3712]
Definition: nvme.h:895
Oc20ChunkState::state
uint8_t state
Definition: oc20.h:93
oc20_dma_read
static uint16_t oc20_dma_read(FemuCtrl *n, uint8_t *ptr, uint32_t len, NvmeCmd *cmd)
Definition: oc20.c:9
OC20_ADM_CMD_SET_LOG_PAGE
@ OC20_ADM_CMD_SET_LOG_PAGE
Definition: nvme.h:1373
Oc20RwCmd::opcode
uint16_t opcode
Definition: oc20.h:103
OC20_SEC_ERASED
@ OC20_SEC_ERASED
Definition: oc20.h:67
Oc20AddrBucket::ch
int ch
Definition: oc20.h:239
Oc20AddrF::grp_mask
uint64_t grp_mask
Definition: oc20.h:131
oc20_admin_cmd
static uint16_t oc20_admin_cmd(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc20.c:916
Oc20DmCmd::cid
uint16_t cid
Definition: oc20.h:122
Oc20IdWrt::max_open_punits
uint32_t max_open_punits
Definition: oc20.h:154
Oc20NamespaceGeometry::rsvd4
uint8_t rsvd4[3840]
Definition: oc20.h:200
Oc20DmCmd
Definition: oc20.h:119
oc20.h
oc20_chunk_set_free
static uint16_t oc20_chunk_set_free(FemuCtrl *n, NvmeNamespace *ns, uint64_t lba, hwaddr mptr, NvmeRequest *req)
Definition: oc20.c:421
OC20_CMD_VECT_WRITE
@ OC20_CMD_VECT_WRITE
Definition: oc20.h:60
oc20_erase
static uint16_t oc20_erase(FemuCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc20.c:784
nvme_addr_read
void nvme_addr_read(FemuCtrl *n, hwaddr addr, void *buf, int size)
Definition: dma.c:3
Oc20Namespace::secs_per_lun
uint32_t secs_per_lun
Definition: oc20.h:229
Oc20IdLBAF::grp_len
uint8_t grp_len
Definition: oc20.h:169
OC20_CMD_MAX_LBAS
#define OC20_CMD_MAX_LBAS
Definition: oc20.h:9
NvmeCmd::cdw12
uint32_t cdw12
Definition: nvme.h:308
OC20_OFFLINE_CHUNK
@ OC20_OFFLINE_CHUNK
Definition: oc20.h:88
Oc20IdLBAF::sec_len
uint8_t sec_len
Definition: oc20.h:172
Oc20Namespace
struct Oc20Namespace Oc20Namespace
Oc20ChunkState::slba
uint64_t slba
Definition: oc20.h:97
oc20_set_log
static uint16_t oc20_set_log(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc20.c:889
Oc20NamespaceGeometry::perf
Oc20IdPerf perf
Definition: oc20.h:199
Oc20NamespaceGeometry::major
uint8_t major
Definition: oc20.h:188
FemuCtrl::params
NvmeParams params
Definition: nvme.h:1219
Oc20AddrF
Definition: oc20.h:130
Oc20NamespaceGeometry::rsvd2
uint8_t rsvd2[12]
Definition: oc20.h:194
NvmeRequest::predef
uint64_t predef
Definition: nvme.h:993
NVME_INTERNAL_DEV_ERROR
@ NVME_INTERNAL_DEV_ERROR
Definition: nvme.h:532
OC20_CHUNK_FREE
@ OC20_CHUNK_FREE
Definition: oc20.h:71
nvme_rw_is_write
static int nvme_rw_is_write(NvmeRequest *req)
Definition: oc20.h:261
NvmeParams::extended
uint8_t extended
Definition: nvme.h:1131
Oc20DmCmd
struct Oc20DmCmd Oc20DmCmd
Oc20AddrBucket
Definition: oc20.h:238
FemuCtrl::chip_locks
pthread_spinlock_t chip_locks[FEMU_MAX_NUM_CHIPS]
Definition: nvme.h:1303
oc20_init_namespace
static int oc20_init_namespace(FemuCtrl *n, NvmeNamespace *ns, Error **errp)
Definition: oc20.c:1157
Oc20IdLBAF
struct Oc20IdLBAF Oc20IdLBAF
Oc20Header::magic
uint32_t magic
Definition: oc20.h:177
OC20_CHUNK_OFFLINE
@ OC20_CHUNK_OFFLINE
Definition: oc20.h:74
Oc20NamespaceGeometry::wit
uint8_t wit
Definition: oc20.h:195
Oc20IdPerf::tbet
uint32_t tbet
Definition: oc20.h:163
Oc20NamespaceGeometry::geo
Oc20IdGeo geo
Definition: oc20.h:197
NVME_ID_NS_LBADS
#define NVME_ID_NS_LBADS(ns)
Definition: nvme.h:26
oc20_exit
static void oc20_exit(FemuCtrl *n)
Definition: oc20.c:1353
Oc20RwCmd
Definition: oc20.h:102
Oc20ParamsMccap
Oc20ParamsMccap
Definition: oc20.h:203
NvmeRequest::is_write
uint16_t is_write
是否为写操作
Definition: nvme.h:973
Oc20RwCmd
struct Oc20RwCmd Oc20RwCmd
nvme_addr_write
void nvme_addr_write(FemuCtrl *n, hwaddr addr, void *buf, int size)
Definition: dma.c:13
NVME_ID_NS_MS
#define NVME_ID_NS_MS(ns)
Definition: nvme.h:31
NvmeNamespace::data
uint64_t data
Definition: nvme.h:1085
FemuCtrl::ns_size
uint64_t ns_size
Definition: nvme.h:1235
Oc20IdWrt::ws_opt
uint32_t ws_opt
Definition: oc20.h:151
OC20_CHUNK_TYPE_RAN
@ OC20_CHUNK_TYPE_RAN
Definition: oc20.h:79
OC20_PARAMS_MCCAP_EARLY_RESET
@ OC20_PARAMS_MCCAP_EARLY_RESET
Definition: oc20.h:206
Oc20AddrF::chk_offset
uint8_t chk_offset
Definition: oc20.h:137
OC20_OUT_OF_ORDER_WRITE
@ OC20_OUT_OF_ORDER_WRITE
Definition: oc20.h:87
FemuCtrl::id_ctrl
NvmeIdCtrl id_ctrl
Definition: nvme.h:1285
Oc20RwCmd::nlb
uint16_t nlb
Definition: oc20.h:113
FEMU_MAX_NUM_CHIPS
#define FEMU_MAX_NUM_CHIPS
Definition: nvme.h:1151
Oc20ChunkTypes
Oc20ChunkTypes
Definition: oc20.h:77
OC20_LBA_GET_PUNIT
#define OC20_LBA_GET_PUNIT(lbaf, lba)
Definition: oc20.h:22
NvmeCmdDptr
Definition: nvme.h:281
state
uint32_t state
Definition: oc12.h:2
NVME_INVALID_LOG_ID
@ NVME_INVALID_LOG_ID
Definition: nvme.h:553
Oc20IdPerf::trdm
uint32_t trdm
Definition: oc20.h:160
NvmeCmd::dptr
NvmeCmdDptr dptr
Definition: nvme.h:305
NVME_INVALID_OPCODE
@ NVME_INVALID_OPCODE
Definition: nvme.h:527
NvmeIdNs::nsfeat
uint8_t nsfeat
Definition: nvme.h:867
NvmeParams::oc20
Oc20Params oc20
Definition: nvme.h:1146
Oc20Namespace::chunk_info
Oc20CS * chunk_info
Definition: oc20.h:235
line
line
Definition: ftl.h:198
NvmeIdNs::nsze
uint64_t nsze
Definition: nvme.h:864
Oc20AddrBucket::cnt
int cnt
Definition: oc20.h:243
Oc20IdWrt::mw_cunits
uint32_t mw_cunits
Definition: oc20.h:152
NvmeCmdDptr::prp1
uint64_t prp1
Definition: nvme.h:283
OC20_LBA_GET_GROUP
#define OC20_LBA_GET_GROUP(lbaf, lba)
Definition: oc20.h:26
OcCtrlParams::secs_per_pg
uint8_t secs_per_pg
Definition: nvme.h:1155
Oc20Namespace::chunkinfo_size
uint64_t chunkinfo_size
Definition: oc20.h:234
NvmeSQueue::sqid
uint16_t sqid
Definition: nvme.h:1013
oc20_init_chunk_info
static uint16_t oc20_init_chunk_info(Oc20Namespace *lns)
Definition: oc20.c:63
NvmeLBAF::ms
uint16_t ms
Definition: nvme.h:856
get_ch_lun_chk
static int get_ch_lun_chk(char *chunkinfo, unsigned int *grp, unsigned int *lun, unsigned int *chk)
Definition: oc20.c:527
set_latency
void set_latency(FemuCtrl *n)
Definition: timing.c:3
Oc20Header::rsvd
uint32_t rsvd
Definition: oc20.h:180
Oc20Namespace::secs_per_chk
uint32_t secs_per_chk
Definition: oc20.h:228
Oc20IdWrt::max_open_chks
uint32_t max_open_chks
Definition: oc20.h:153
NvmeIdNs::lbaf
NvmeLBAF lbaf[16]
Definition: nvme.h:893
OC20_LBA_GET_SECTR
#define OC20_LBA_GET_SECTR(lbaf, lba)
Definition: oc20.h:14
Oc20Params::writefail_fname
char * writefail_fname
Definition: nvme.h:1109
NvmeCmd::cdw10
uint32_t cdw10
Definition: nvme.h:306
Oc20IdLBAF::rsvd
uint8_t rsvd[4]
Definition: oc20.h:173
Oc20DmCmd::nsid
uint32_t nsid
Definition: oc20.h:123
OC20_LBAL_SGL_LENGTH_INVALID
@ OC20_LBAL_SGL_LENGTH_INVALID
Definition: oc20.h:84
Oc20AddrF::chk_mask
uint64_t chk_mask
Definition: oc20.h:133
NvmeCmd::opcode
uint16_t opcode
Definition: nvme.h:297
nvme_ns_calc_blks
static uint64_t nvme_ns_calc_blks(FemuCtrl *n, NvmeNamespace *ns)
Definition: oc20.c:997
Oc20IdLBAF::chk_len
uint8_t chk_len
Definition: oc20.h:171
_oc20_check_size
static void _oc20_check_size(void)
Definition: oc20.h:249
OC20_CHUNK_TYPE_SEQ
@ OC20_CHUNK_TYPE_SEQ
Definition: oc20.h:78
Oc20DmCmd::nlb
uint32_t nlb
Definition: oc20.h:126
OC20_PARAMS_MCCAP_MULTIPLE_RESETS
@ OC20_PARAMS_MCCAP_MULTIPLE_RESETS
Definition: oc20.h:204
nvme_map_prp
uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVector *iov, uint64_t prp1, uint64_t prp2, uint32_t len, FemuCtrl *n)
Definition: dma.c:23
NvmeNamespace::blk
struct NvmeNamespace::@18 blk
Oc20IoCommands
Oc20IoCommands
Definition: oc20.h:58
Oc20ChunkState::cnlb
uint64_t cnlb
Definition: oc20.h:98
Oc20AddrF::sec_mask
uint64_t sec_mask
Definition: oc20.h:134
Oc20IdPerf::rsvd
uint8_t rsvd[40]
Definition: oc20.h:165
NvmeRequest::cqe
NvmeCqe cqe
Definition: nvme.h:982
Oc20AddrF::lun_mask
uint64_t lun_mask
Definition: oc20.h:132
NvmeNamespace::state
void * state
Definition: nvme.h:1089
Oc20RwCmd::rsvd2
uint64_t rsvd2
Definition: oc20.h:109
NvmeIdNs::flbas
uint8_t flbas
Definition: nvme.h:869
Oc20Params::early_reset
uint8_t early_reset
Definition: nvme.h:1104
Oc20Params::mccap
uint32_t mccap
Definition: nvme.h:1098
Oc20RwCmd::lbal
uint64_t lbal
Definition: oc20.h:112
OC20_CMD_VECT_READ
@ OC20_CMD_VECT_READ
Definition: oc20.h:61
oc20_free_namespace
static void oc20_free_namespace(FemuCtrl *n, NvmeNamespace *ns)
Definition: oc20.c:959
OcCtrlParams::num_pln
uint8_t num_pln
Definition: nvme.h:1160
Oc20Namespace::chks_per_grp
uint32_t chks_per_grp
Definition: oc20.h:226
NvmeLBAF::lbads
uint8_t lbads
Definition: nvme.h:857
advance_channel_timestamp
int64_t advance_channel_timestamp(FemuCtrl *n, int ch, uint64_t now, int opcode)
Definition: timing.c:38
NvmeRequest::expire_time
int64_t expire_time
io应该结束的时间
Definition: nvme.h:990
oc20_rw_is_write
static int oc20_rw_is_write(NvmeRequest *req)
Definition: oc20.h:266
NvmeRequest::sq
struct NvmeSQueue * sq
Definition: nvme.h:968
FemuCtrl::chnl_next_avail_time
volatile int64_t chnl_next_avail_time[FEMU_MAX_NUM_CHNLS]
Definition: nvme.h:1304
FemuCtrl::num_namespaces
uint32_t num_namespaces
Definition: nvme.h:1232
get_chunk_meta_index
static int get_chunk_meta_index(FemuCtrl *n, NvmeNamespace *ns, unsigned int grp, unsigned int lun, unsigned int chk)
Definition: oc20.c:545
OC20_SEC_WRITTEN
@ OC20_SEC_WRITTEN
Definition: oc20.h:66
cmd_lns
static Oc20Namespace * cmd_lns(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc20.c:683
oc20_parse_lba_list
static void oc20_parse_lba_list(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req, Oc20AddrBucket *bucket, int *nr)
Definition: oc20.c:133
cmd_ns
static NvmeNamespace * cmd_ns(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc20.c:691
FemuCtrl::mbe
SsdDramBackend * mbe
femu后端内存(实际数据)
Definition: nvme.h:1322
NvmeRequest::cmd_opcode
uint8_t cmd_opcode
Definition: nvme.h:983
Oc20Namespace::chks_total
uint32_t chks_total
Definition: oc20.h:227
Oc20AddrBucket::lun
int lun
Definition: oc20.h:240
NVME_DULB
@ NVME_DULB
Definition: nvme.h:579
Oc20RwCmd::metadata
uint64_t metadata
Definition: oc20.h:110
Oc20DmCmd::rsvd2
uint32_t rsvd2[3]
Definition: oc20.h:127
oc20_identify
static uint16_t oc20_identify(FemuCtrl *n, NvmeCmd *cmd)
Definition: oc20.c:769
Oc20IdGeo::num_lun
uint16_t num_lun
Definition: oc20.h:143
FemuExtCtrlOps::state
void * state
Definition: nvme.h:1170
Oc20Header::num_namespaces
uint32_t num_namespaces
Definition: oc20.h:179
Oc20IdPerf::tprt
uint32_t tprt
Definition: oc20.h:161
Oc20Params::mw_cunits
uint32_t mw_cunits
Definition: nvme.h:1101
Oc20Ctrl
Definition: oc20.h:213
NvmeParams::dlfeat
uint8_t dlfeat
Definition: nvme.h:1139
Oc20IdGeo::clba
uint32_t clba
Definition: oc20.h:145
NVME_CMD_READ
@ NVME_CMD_READ
Definition: nvme.h:341
OC20_ADM_CMD_IDENTIFY
@ OC20_ADM_CMD_IDENTIFY
Definition: nvme.h:1372
Oc20Header::sector_size
uint64_t sector_size
Definition: oc20.h:181
Oc20AddrBucket::pg
int pg
Definition: oc20.h:241
oc20_rw_check_read_req
static uint16_t oc20_rw_check_read_req(FemuCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc20.c:391
NvmeRequest::slba
uint64_t slba
开始lba
Definition: nvme.h:972
Oc20ChunkState::wear_index
uint8_t wear_index
Definition: oc20.h:95
Oc20LogPage
Oc20LogPage
Definition: oc20.h:209
Oc20RwCmd::rsvd1
uint16_t rsvd1
Definition: oc20.h:105
nvme_set_error_page
void nvme_set_error_page(FemuCtrl *n, uint16_t sqid, uint16_t cid, uint16_t status, uint16_t location, uint64_t lba, uint32_t nsid)
Definition: nvme-util.c:96
NVME_CAP_SET_OC
#define NVME_CAP_SET_OC(cap, val)
Definition: nvme.h:117
NVME_INVALID_NSID
@ NVME_INVALID_NSID
Definition: nvme.h:537
Oc20NamespaceGeometry
Definition: oc20.h:186
NvmeCmdDptr::prp2
uint64_t prp2
Definition: nvme.h:284
Oc20NamespaceGeometry
struct Oc20NamespaceGeometry Oc20NamespaceGeometry
FemuCtrl::namespaces
NvmeNamespace * namespaces
Definition: nvme.h:1279
Oc20Namespace::resetfail
uint8_t * resetfail
Definition: oc20.h:222
Oc20RwCmd::fuse
uint16_t fuse
Definition: oc20.h:104
get_unsigned
static unsigned get_unsigned(char *string, const char *key, unsigned int *value)
Definition: oc20.c:518
Oc20Params
Definition: nvme.h:1096
oc20_advance_status
static int oc20_advance_status(FemuCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc20.c:168
NvmeRequest
Definition: nvme.h:967
oc20_rw_check_req
static uint16_t oc20_rw_check_req(FemuCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
Definition: oc20.c:475
FemuCtrl::oc_params
OcCtrlParams oc_params
Definition: nvme.h:1299
Oc20NamespaceGeometry::mccap
uint32_t mccap
Definition: oc20.h:193
NvmeNamespace::ns_blks
uint64_t ns_blks
Definition: nvme.h:1073
Oc20Namespace::id_ctrl
Oc20NamespaceGeometry id_ctrl
Definition: oc20.h:218
OC20_LBA_GET_CHUNK
#define OC20_LBA_GET_CHUNK(lbaf, lba)
Definition: oc20.h:18
NVME_WRITE_FAULT
@ NVME_WRITE_FAULT
Definition: nvme.h:572
Oc20Ctrl::blk_hdr
Oc20Header blk_hdr
Definition: oc20.h:214
set_resetfail_chunk
static int set_resetfail_chunk(FemuCtrl *n, NvmeNamespace *ns, char *chunkinfo)
Definition: oc20.c:567
Oc20CS
struct Oc20ChunkState Oc20CS
NVME_INVALID_FIELD
@ NVME_INVALID_FIELD
Definition: nvme.h:528
FEMU_MAX_NUM_CHNLS
#define FEMU_MAX_NUM_CHNLS
Definition: nvme.h:1150
Oc20MetaStates
Oc20MetaStates
Definition: oc20.h:64
Oc20RwCmd::psdt
uint16_t psdt
Definition: oc20.h:106
NvmeCqe::cid
uint16_t cid
cmd id
Definition: nvme.h:521
Oc20Namespace
Definition: oc20.h:217
OC20_CHUNK_TYPE_SRK
@ OC20_CHUNK_TYPE_SRK
Definition: oc20.h:80
Oc20AddrF::lun_offset
uint8_t lun_offset
Definition: oc20.h:136
NvmeFeatureVal::err_rec
uint32_t err_rec
Definition: nvme.h:795
femu_err
#define femu_err(fmt,...)
Definition: nvme.h:1511
nvme_lba_to_sector_index
static uint64_t nvme_lba_to_sector_index(FemuCtrl *n, NvmeNamespace *ns, uint64_t lba)
Definition: oc20.h:271
Oc20DmCmd::opcode
uint8_t opcode
Definition: oc20.h:120
Oc20IdGeo::num_grp
uint16_t num_grp
Definition: oc20.h:142