Skip to content

Commit a7fd9a4

Browse files
committed
lightnvm: ensure that nvm_dev_ops can be used without CONFIG_NVM
null_blk defines an empty version of this ops structure if CONFIG_NVM isn't set, but it doesn't know the type. Move those bits out of the protection of CONFIG_NVM in the main lightnvm include. Signed-off-by: Jens Axboe <[email protected]>
1 parent 8b4970c commit a7fd9a4

File tree

1 file changed

+64
-57
lines changed

1 file changed

+64
-57
lines changed

include/linux/lightnvm.h

Lines changed: 64 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef NVM_H
22
#define NVM_H
33

4+
#include <linux/types.h>
5+
46
enum {
57
NVM_IO_OK = 0,
68
NVM_IO_REQUEUE = 1,
@@ -11,10 +13,71 @@ enum {
1113
NVM_IOTYPE_GC = 1,
1214
};
1315

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+
1478
#ifdef CONFIG_NVM
1579

1680
#include <linux/blkdev.h>
17-
#include <linux/types.h>
1881
#include <linux/file.h>
1982
#include <linux/dmapool.h>
2083
#include <uapi/linux/lightnvm.h>
@@ -149,29 +212,6 @@ struct nvm_tgt_instance {
149212
#define NVM_VERSION_MINOR 0
150213
#define NVM_VERSION_PATCH 0
151214

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-
175215
struct nvm_rq;
176216
typedef void (nvm_end_io_fn)(struct nvm_rq *);
177217

@@ -213,39 +253,6 @@ static inline void *nvm_rq_to_pdu(struct nvm_rq *rqdata)
213253

214254
struct nvm_block;
215255

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-
249256
struct nvm_lun {
250257
int id;
251258

0 commit comments

Comments
 (0)