2013-06-04 19:17:10 +04:00
|
|
|
#ifndef HW_NVME_H
|
|
|
|
#define HW_NVME_H
|
2018-01-16 09:08:59 +03:00
|
|
|
#include "block/nvme.h"
|
2013-06-04 19:17:10 +04:00
|
|
|
|
|
|
|
typedef struct NvmeAsyncEvent {
|
|
|
|
QSIMPLEQ_ENTRY(NvmeAsyncEvent) entry;
|
|
|
|
NvmeAerResult result;
|
|
|
|
} NvmeAsyncEvent;
|
|
|
|
|
|
|
|
typedef struct NvmeRequest {
|
|
|
|
struct NvmeSQueue *sq;
|
2014-10-07 15:59:14 +04:00
|
|
|
BlockAIOCB *aiocb;
|
2013-06-04 19:17:10 +04:00
|
|
|
uint16_t status;
|
2015-06-11 13:01:38 +03:00
|
|
|
bool has_sg;
|
2013-06-04 19:17:10 +04:00
|
|
|
NvmeCqe cqe;
|
|
|
|
BlockAcctCookie acct;
|
|
|
|
QEMUSGList qsg;
|
2017-06-13 13:08:35 +03:00
|
|
|
QEMUIOVector iov;
|
2013-06-04 19:17:10 +04:00
|
|
|
QTAILQ_ENTRY(NvmeRequest)entry;
|
|
|
|
} NvmeRequest;
|
|
|
|
|
|
|
|
typedef struct NvmeSQueue {
|
|
|
|
struct NvmeCtrl *ctrl;
|
|
|
|
uint16_t sqid;
|
|
|
|
uint16_t cqid;
|
|
|
|
uint32_t head;
|
|
|
|
uint32_t tail;
|
|
|
|
uint32_t size;
|
|
|
|
uint64_t dma_addr;
|
|
|
|
QEMUTimer *timer;
|
|
|
|
NvmeRequest *io_req;
|
|
|
|
QTAILQ_HEAD(sq_req_list, NvmeRequest) req_list;
|
|
|
|
QTAILQ_HEAD(out_req_list, NvmeRequest) out_req_list;
|
|
|
|
QTAILQ_ENTRY(NvmeSQueue) entry;
|
|
|
|
} NvmeSQueue;
|
|
|
|
|
|
|
|
typedef struct NvmeCQueue {
|
|
|
|
struct NvmeCtrl *ctrl;
|
|
|
|
uint8_t phase;
|
|
|
|
uint16_t cqid;
|
|
|
|
uint16_t irq_enabled;
|
|
|
|
uint32_t head;
|
|
|
|
uint32_t tail;
|
|
|
|
uint32_t vector;
|
|
|
|
uint32_t size;
|
|
|
|
uint64_t dma_addr;
|
|
|
|
QEMUTimer *timer;
|
|
|
|
QTAILQ_HEAD(sq_list, NvmeSQueue) sq_list;
|
|
|
|
QTAILQ_HEAD(cq_req_list, NvmeRequest) req_list;
|
|
|
|
} NvmeCQueue;
|
|
|
|
|
|
|
|
typedef struct NvmeNamespace {
|
|
|
|
NvmeIdNs id_ns;
|
|
|
|
} NvmeNamespace;
|
|
|
|
|
|
|
|
#define TYPE_NVME "nvme"
|
|
|
|
#define NVME(obj) \
|
|
|
|
OBJECT_CHECK(NvmeCtrl, (obj), TYPE_NVME)
|
|
|
|
|
|
|
|
typedef struct NvmeCtrl {
|
|
|
|
PCIDevice parent_obj;
|
|
|
|
MemoryRegion iomem;
|
2017-05-16 22:10:59 +03:00
|
|
|
MemoryRegion ctrl_mem;
|
2013-06-04 19:17:10 +04:00
|
|
|
NvmeBar bar;
|
|
|
|
BlockConf conf;
|
|
|
|
|
2014-11-27 06:39:21 +03:00
|
|
|
uint32_t page_size;
|
2013-06-04 19:17:10 +04:00
|
|
|
uint16_t page_bits;
|
|
|
|
uint16_t max_prp_ents;
|
|
|
|
uint16_t cqe_size;
|
|
|
|
uint16_t sqe_size;
|
|
|
|
uint32_t reg_size;
|
|
|
|
uint32_t num_namespaces;
|
|
|
|
uint32_t num_queues;
|
|
|
|
uint32_t max_q_ents;
|
|
|
|
uint64_t ns_size;
|
2017-05-16 22:10:59 +03:00
|
|
|
uint32_t cmb_size_mb;
|
|
|
|
uint32_t cmbsz;
|
|
|
|
uint32_t cmbloc;
|
|
|
|
uint8_t *cmbuf;
|
2017-12-18 08:00:43 +03:00
|
|
|
uint64_t irq_status;
|
2013-06-04 19:17:10 +04:00
|
|
|
|
|
|
|
char *serial;
|
|
|
|
NvmeNamespace *namespaces;
|
|
|
|
NvmeSQueue **sq;
|
|
|
|
NvmeCQueue **cq;
|
|
|
|
NvmeSQueue admin_sq;
|
|
|
|
NvmeCQueue admin_cq;
|
|
|
|
NvmeIdCtrl id_ctrl;
|
|
|
|
} NvmeCtrl;
|
|
|
|
|
|
|
|
#endif /* HW_NVME_H */
|