4 #include "block/nvme.h"
6 typedef struct NvmeParams
{
8 uint32_t num_queues
; /* deprecated since 5.1 */
13 uint32_t aer_max_queued
;
17 typedef struct NvmeAsyncEvent
{
18 QTAILQ_ENTRY(NvmeAsyncEvent
) entry
;
22 typedef struct NvmeRequest
{
23 struct NvmeSQueue
*sq
;
24 struct NvmeNamespace
*ns
;
32 QTAILQ_ENTRY(NvmeRequest
)entry
;
35 typedef struct NvmeSQueue
{
36 struct NvmeCtrl
*ctrl
;
45 QTAILQ_HEAD(, NvmeRequest
) req_list
;
46 QTAILQ_HEAD(, NvmeRequest
) out_req_list
;
47 QTAILQ_ENTRY(NvmeSQueue
) entry
;
50 typedef struct NvmeCQueue
{
51 struct NvmeCtrl
*ctrl
;
61 QTAILQ_HEAD(, NvmeSQueue
) sq_list
;
62 QTAILQ_HEAD(, NvmeRequest
) req_list
;
65 typedef struct NvmeNamespace
{
69 static inline NvmeLBAF
*nvme_ns_lbaf(NvmeNamespace
*ns
)
71 NvmeIdNs
*id_ns
= &ns
->id_ns
;
72 return &id_ns
->lbaf
[NVME_ID_NS_FLBAS_INDEX(id_ns
->flbas
)];
75 static inline uint8_t nvme_ns_lbads(NvmeNamespace
*ns
)
77 return nvme_ns_lbaf(ns
)->ds
;
80 #define TYPE_NVME "nvme"
82 OBJECT_CHECK(NvmeCtrl, (obj), TYPE_NVME)
84 typedef struct NvmeFeatureVal
{
86 uint16_t temp_thresh_hi
;
87 uint16_t temp_thresh_low
;
89 uint32_t async_config
;
92 typedef struct NvmeCtrl
{
95 MemoryRegion ctrl_mem
;
103 uint16_t max_prp_ents
;
107 uint32_t num_namespaces
;
110 uint8_t outstanding_aers
;
113 uint64_t host_timestamp
; /* Timestamp sent by the host */
114 uint64_t timestamp_set_qemu_clock_ms
; /* QEMU clock time */
115 uint64_t starttime_ms
;
116 uint16_t temperature
;
118 HostMemoryBackend
*pmrdev
;
121 NvmeRequest
**aer_reqs
;
122 QTAILQ_HEAD(, NvmeAsyncEvent
) aer_queue
;
125 NvmeNamespace
*namespaces
;
131 NvmeFeatureVal features
;
134 /* calculate the number of LBAs that the namespace can accomodate */
135 static inline uint64_t nvme_ns_nlbas(NvmeCtrl
*n
, NvmeNamespace
*ns
)
137 return n
->ns_size
>> nvme_ns_lbads(ns
);
140 #endif /* HW_NVME_H */