4 #include "block/nvme.h"
6 typedef struct NvmeParams
{
8 uint32_t num_queues
; /* deprecated since 5.1 */
14 typedef struct NvmeAsyncEvent
{
15 QSIMPLEQ_ENTRY(NvmeAsyncEvent
) entry
;
19 typedef struct NvmeRequest
{
20 struct NvmeSQueue
*sq
;
28 QTAILQ_ENTRY(NvmeRequest
)entry
;
31 typedef struct NvmeSQueue
{
32 struct NvmeCtrl
*ctrl
;
41 QTAILQ_HEAD(, NvmeRequest
) req_list
;
42 QTAILQ_HEAD(, NvmeRequest
) out_req_list
;
43 QTAILQ_ENTRY(NvmeSQueue
) entry
;
46 typedef struct NvmeCQueue
{
47 struct NvmeCtrl
*ctrl
;
57 QTAILQ_HEAD(, NvmeSQueue
) sq_list
;
58 QTAILQ_HEAD(, NvmeRequest
) req_list
;
61 typedef struct NvmeNamespace
{
65 static inline NvmeLBAF
*nvme_ns_lbaf(NvmeNamespace
*ns
)
67 NvmeIdNs
*id_ns
= &ns
->id_ns
;
68 return &id_ns
->lbaf
[NVME_ID_NS_FLBAS_INDEX(id_ns
->flbas
)];
71 static inline uint8_t nvme_ns_lbads(NvmeNamespace
*ns
)
73 return nvme_ns_lbaf(ns
)->ds
;
76 #define TYPE_NVME "nvme"
78 OBJECT_CHECK(NvmeCtrl, (obj), TYPE_NVME)
80 typedef struct NvmeCtrl
{
83 MemoryRegion ctrl_mem
;
90 uint16_t max_prp_ents
;
94 uint32_t num_namespaces
;
99 uint64_t host_timestamp
; /* Timestamp sent by the host */
100 uint64_t timestamp_set_qemu_clock_ms
; /* QEMU clock time */
102 HostMemoryBackend
*pmrdev
;
104 NvmeNamespace
*namespaces
;
112 /* calculate the number of LBAs that the namespace can accomodate */
113 static inline uint64_t nvme_ns_nlbas(NvmeCtrl
*n
, NvmeNamespace
*ns
)
115 return n
->ns_size
>> nvme_ns_lbads(ns
);
118 #endif /* HW_NVME_H */