-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathnvm_admin.h
120 lines (93 loc) · 3.96 KB
/
nvm_admin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef __NVM_ADMIN_H__
#define __NVM_ADMIN_H__
// #ifndef __CUDACC__
// #define __device__
// #define __host__
// #endif
#include <nvm_types.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
/*
* Get controller information.
*/
int nvm_admin_ctrl_info(nvm_aq_ref ref, // AQ pair reference
struct nvm_ctrl_info* info, // Controller information structure
void* buffer, // Temporary buffer (must be at least 4 KB)
uint64_t ioaddr); // Bus address of buffer as seen by the controller
/*
* Get namespace information.
*/
int nvm_admin_ns_info(nvm_aq_ref ref, // AQ pair reference
struct nvm_ns_info* info, // NVM namespace information
uint32_t ns_id, // Namespace identifier
void* buffer, // Temporary buffer (must be at least 4 KB)
uint64_t ioaddr); // Bus address of buffer as seen by controller
/*
* Make controller allocate and reserve queues.
*/
int nvm_admin_set_num_queues(nvm_aq_ref ref, uint16_t n_cqs, uint16_t n_sqs);
/*
* Retrieve the number of allocated queues.
*/
int nvm_admin_get_num_queues(nvm_aq_ref ref, uint16_t* n_cqs, uint16_t* n_sqs);
/*
* Make controller allocate number of queues before issuing them.
*/
int nvm_admin_request_num_queues(nvm_aq_ref ref, uint16_t* n_cqs, uint16_t* n_sqs);
/*
* Create IO completion queue (CQ)
* Caller must set queue memory to zero manually.
*
* If number of queue entries (qs) exceeds a page,
* DMA memory must be contiguous.
*
* If qs is 0, the API will use one page for queue memory.
*/
int nvm_admin_cq_create(nvm_aq_ref ref, // AQ pair reference
nvm_queue_t* cq, // CQ descriptor
uint16_t id, // Queue identifier
const nvm_dma_t* dma, // Queue memory handle
size_t page_offset, // Number of pages to offset into the handle
size_t qs, // Queue size/depth
bool need_prp = false); // non-contiguous queue
/*
* Delete IO completion queue (CQ)
* After calling this, the queue is no longer used and must be recreated.
* All associated submission queues must be deleted first.
*/
int nvm_admin_cq_delete(nvm_aq_ref ref, nvm_queue_t* cq);
/*
* Create IO submission queue (SQ)
* Caller must set queue memory to zero manually.
*
* If number of queue entries (qs) exceeds a page,
* DMA memory must be contiguous.
*
* If qs is 0, the API will use one page for queue memory.
*/
int nvm_admin_sq_create(nvm_aq_ref ref, // AQ pair reference
nvm_queue_t* sq, // SQ descriptor
const nvm_queue_t* cq, // Descriptor to paired CQ
uint16_t id, // Queue identifier
const nvm_dma_t* dma, // Queue memory handle
size_t page_offset, // Number of pages to offset into the handle
size_t qs, // Number of pages to use
bool need_prp = false); // non-contiguous queue
/*
* Delete IO submission queue (SQ)
* After calling this, the queue is no longer used and must be recreated.
*/
int nvm_admin_sq_delete(nvm_aq_ref ref,
nvm_queue_t* sq,
const nvm_queue_t* cq);
/*
* Get log page.
*/
int nvm_admin_get_log_page(nvm_aq_ref ref,
uint32_t ns_id,
void* ptr,
uint64_t ioaddr,
uint8_t log_id,
uint64_t log_offset);
#endif /* #ifdef __NVM_ADMIN_H__ */