1
1
#ifndef NVM_H
2
2
#define NVM_H
3
3
4
+ #include <linux/types.h>
5
+
4
6
enum {
5
7
NVM_IO_OK = 0 ,
6
8
NVM_IO_REQUEUE = 1 ,
@@ -11,10 +13,71 @@ enum {
11
13
NVM_IOTYPE_GC = 1 ,
12
14
};
13
15
16
+ #define NVM_BLK_BITS (16)
17
+ #define NVM_PG_BITS (16)
18
+ #define NVM_SEC_BITS (8)
19
+ #define NVM_PL_BITS (8)
20
+ #define NVM_LUN_BITS (8)
21
+ #define NVM_CH_BITS (8)
22
+
23
+ struct ppa_addr {
24
+ /* Generic structure for all addresses */
25
+ union {
26
+ struct {
27
+ u64 blk : NVM_BLK_BITS ;
28
+ u64 pg : NVM_PG_BITS ;
29
+ u64 sec : NVM_SEC_BITS ;
30
+ u64 pl : NVM_PL_BITS ;
31
+ u64 lun : NVM_LUN_BITS ;
32
+ u64 ch : NVM_CH_BITS ;
33
+ } g ;
34
+
35
+ u64 ppa ;
36
+ };
37
+ };
38
+
39
+ struct nvm_rq ;
40
+ struct nvm_id ;
41
+ struct nvm_dev ;
42
+
43
+ typedef int (nvm_l2p_update_fn )(u64 , u32 , __le64 * , void * );
44
+ typedef int (nvm_bb_update_fn )(struct ppa_addr , int , u8 * , void * );
45
+ typedef int (nvm_id_fn )(struct nvm_dev * , struct nvm_id * );
46
+ typedef int (nvm_get_l2p_tbl_fn )(struct nvm_dev * , u64 , u32 ,
47
+ nvm_l2p_update_fn * , void * );
48
+ typedef int (nvm_op_bb_tbl_fn )(struct nvm_dev * , struct ppa_addr , int ,
49
+ nvm_bb_update_fn * , void * );
50
+ typedef int (nvm_op_set_bb_fn )(struct nvm_dev * , struct nvm_rq * , int );
51
+ typedef int (nvm_submit_io_fn )(struct nvm_dev * , struct nvm_rq * );
52
+ typedef int (nvm_erase_blk_fn )(struct nvm_dev * , struct nvm_rq * );
53
+ typedef void * (nvm_create_dma_pool_fn )(struct nvm_dev * , char * );
54
+ typedef void (nvm_destroy_dma_pool_fn )(void * );
55
+ typedef void * (nvm_dev_dma_alloc_fn )(struct nvm_dev * , void * , gfp_t ,
56
+ dma_addr_t * );
57
+ typedef void (nvm_dev_dma_free_fn )(void * , void * , dma_addr_t );
58
+
59
+ struct nvm_dev_ops {
60
+ nvm_id_fn * identity ;
61
+ nvm_get_l2p_tbl_fn * get_l2p_tbl ;
62
+ nvm_op_bb_tbl_fn * get_bb_tbl ;
63
+ nvm_op_set_bb_fn * set_bb_tbl ;
64
+
65
+ nvm_submit_io_fn * submit_io ;
66
+ nvm_erase_blk_fn * erase_block ;
67
+
68
+ nvm_create_dma_pool_fn * create_dma_pool ;
69
+ nvm_destroy_dma_pool_fn * destroy_dma_pool ;
70
+ nvm_dev_dma_alloc_fn * dev_dma_alloc ;
71
+ nvm_dev_dma_free_fn * dev_dma_free ;
72
+
73
+ unsigned int max_phys_sect ;
74
+ };
75
+
76
+
77
+
14
78
#ifdef CONFIG_NVM
15
79
16
80
#include <linux/blkdev.h>
17
- #include <linux/types.h>
18
81
#include <linux/file.h>
19
82
#include <linux/dmapool.h>
20
83
#include <uapi/linux/lightnvm.h>
@@ -149,29 +212,6 @@ struct nvm_tgt_instance {
149
212
#define NVM_VERSION_MINOR 0
150
213
#define NVM_VERSION_PATCH 0
151
214
152
- #define NVM_BLK_BITS (16)
153
- #define NVM_PG_BITS (16)
154
- #define NVM_SEC_BITS (8)
155
- #define NVM_PL_BITS (8)
156
- #define NVM_LUN_BITS (8)
157
- #define NVM_CH_BITS (8)
158
-
159
- struct ppa_addr {
160
- /* Generic structure for all addresses */
161
- union {
162
- struct {
163
- u64 blk : NVM_BLK_BITS ;
164
- u64 pg : NVM_PG_BITS ;
165
- u64 sec : NVM_SEC_BITS ;
166
- u64 pl : NVM_PL_BITS ;
167
- u64 lun : NVM_LUN_BITS ;
168
- u64 ch : NVM_CH_BITS ;
169
- } g ;
170
-
171
- u64 ppa ;
172
- };
173
- };
174
-
175
215
struct nvm_rq ;
176
216
typedef void (nvm_end_io_fn )(struct nvm_rq * );
177
217
@@ -213,39 +253,6 @@ static inline void *nvm_rq_to_pdu(struct nvm_rq *rqdata)
213
253
214
254
struct nvm_block ;
215
255
216
- typedef int (nvm_l2p_update_fn )(u64 , u32 , __le64 * , void * );
217
- typedef int (nvm_bb_update_fn )(struct ppa_addr , int , u8 * , void * );
218
- typedef int (nvm_id_fn )(struct nvm_dev * , struct nvm_id * );
219
- typedef int (nvm_get_l2p_tbl_fn )(struct nvm_dev * , u64 , u32 ,
220
- nvm_l2p_update_fn * , void * );
221
- typedef int (nvm_op_bb_tbl_fn )(struct nvm_dev * , struct ppa_addr , int ,
222
- nvm_bb_update_fn * , void * );
223
- typedef int (nvm_op_set_bb_fn )(struct nvm_dev * , struct nvm_rq * , int );
224
- typedef int (nvm_submit_io_fn )(struct nvm_dev * , struct nvm_rq * );
225
- typedef int (nvm_erase_blk_fn )(struct nvm_dev * , struct nvm_rq * );
226
- typedef void * (nvm_create_dma_pool_fn )(struct nvm_dev * , char * );
227
- typedef void (nvm_destroy_dma_pool_fn )(void * );
228
- typedef void * (nvm_dev_dma_alloc_fn )(struct nvm_dev * , void * , gfp_t ,
229
- dma_addr_t * );
230
- typedef void (nvm_dev_dma_free_fn )(void * , void * , dma_addr_t );
231
-
232
- struct nvm_dev_ops {
233
- nvm_id_fn * identity ;
234
- nvm_get_l2p_tbl_fn * get_l2p_tbl ;
235
- nvm_op_bb_tbl_fn * get_bb_tbl ;
236
- nvm_op_set_bb_fn * set_bb_tbl ;
237
-
238
- nvm_submit_io_fn * submit_io ;
239
- nvm_erase_blk_fn * erase_block ;
240
-
241
- nvm_create_dma_pool_fn * create_dma_pool ;
242
- nvm_destroy_dma_pool_fn * destroy_dma_pool ;
243
- nvm_dev_dma_alloc_fn * dev_dma_alloc ;
244
- nvm_dev_dma_free_fn * dev_dma_free ;
245
-
246
- unsigned int max_phys_sect ;
247
- };
248
-
249
256
struct nvm_lun {
250
257
int id ;
251
258
0 commit comments