blob: 94b704a8d83ddc42cd6cf7a3eb3effbf9ba694c0 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Matias Bjørlingcd9e9802015-10-28 19:54:55 +01002#ifndef NVM_H
3#define NVM_H
4
Matias Bjørlingb76eb20b2016-07-07 09:54:16 +02005#include <linux/blkdev.h>
Jens Axboea7fd9a42016-01-13 13:04:11 -07006#include <linux/types.h>
Matias Bjørlingb76eb20b2016-07-07 09:54:16 +02007#include <uapi/linux/lightnvm.h>
Jens Axboea7fd9a42016-01-13 13:04:11 -07008
Matias Bjørlingcd9e9802015-10-28 19:54:55 +01009enum {
10 NVM_IO_OK = 0,
11 NVM_IO_REQUEUE = 1,
12 NVM_IO_DONE = 2,
13 NVM_IO_ERR = 3,
14
15 NVM_IOTYPE_NONE = 0,
16 NVM_IOTYPE_GC = 1,
17};
18
Jens Axboea7fd9a42016-01-13 13:04:11 -070019#define NVM_BLK_BITS (16)
20#define NVM_PG_BITS (16)
21#define NVM_SEC_BITS (8)
22#define NVM_PL_BITS (8)
23#define NVM_LUN_BITS (8)
Matias Bjørlingdf414b32016-05-06 20:03:19 +020024#define NVM_CH_BITS (7)
Jens Axboea7fd9a42016-01-13 13:04:11 -070025
26struct ppa_addr {
27 /* Generic structure for all addresses */
28 union {
29 struct {
30 u64 blk : NVM_BLK_BITS;
31 u64 pg : NVM_PG_BITS;
32 u64 sec : NVM_SEC_BITS;
33 u64 pl : NVM_PL_BITS;
34 u64 lun : NVM_LUN_BITS;
35 u64 ch : NVM_CH_BITS;
Matias Bjørlingdf414b32016-05-06 20:03:19 +020036 u64 reserved : 1;
Jens Axboea7fd9a42016-01-13 13:04:11 -070037 } g;
38
Matias Bjørlingdf414b32016-05-06 20:03:19 +020039 struct {
40 u64 line : 63;
41 u64 is_cached : 1;
42 } c;
43
Jens Axboea7fd9a42016-01-13 13:04:11 -070044 u64 ppa;
45 };
46};
47
48struct nvm_rq;
49struct nvm_id;
50struct nvm_dev;
Javier González8e536242016-11-28 22:39:10 +010051struct nvm_tgt_dev;
Jens Axboea7fd9a42016-01-13 13:04:11 -070052
Jens Axboea7fd9a42016-01-13 13:04:11 -070053typedef int (nvm_id_fn)(struct nvm_dev *, struct nvm_id *);
Matias Bjørlinge11903f2016-05-06 20:03:05 +020054typedef int (nvm_op_bb_tbl_fn)(struct nvm_dev *, struct ppa_addr, u8 *);
Matias Bjørling00ee6cc2016-05-06 20:03:09 +020055typedef int (nvm_op_set_bb_fn)(struct nvm_dev *, struct ppa_addr *, int, int);
Jens Axboea7fd9a42016-01-13 13:04:11 -070056typedef int (nvm_submit_io_fn)(struct nvm_dev *, struct nvm_rq *);
Javier González1a94b2d2017-10-13 14:46:47 +020057typedef int (nvm_submit_io_sync_fn)(struct nvm_dev *, struct nvm_rq *);
Jens Axboea7fd9a42016-01-13 13:04:11 -070058typedef void *(nvm_create_dma_pool_fn)(struct nvm_dev *, char *);
59typedef void (nvm_destroy_dma_pool_fn)(void *);
60typedef void *(nvm_dev_dma_alloc_fn)(struct nvm_dev *, void *, gfp_t,
61 dma_addr_t *);
62typedef void (nvm_dev_dma_free_fn)(void *, void*, dma_addr_t);
63
64struct nvm_dev_ops {
65 nvm_id_fn *identity;
Jens Axboea7fd9a42016-01-13 13:04:11 -070066 nvm_op_bb_tbl_fn *get_bb_tbl;
67 nvm_op_set_bb_fn *set_bb_tbl;
68
69 nvm_submit_io_fn *submit_io;
Javier González1a94b2d2017-10-13 14:46:47 +020070 nvm_submit_io_sync_fn *submit_io_sync;
Jens Axboea7fd9a42016-01-13 13:04:11 -070071
72 nvm_create_dma_pool_fn *create_dma_pool;
73 nvm_destroy_dma_pool_fn *destroy_dma_pool;
74 nvm_dev_dma_alloc_fn *dev_dma_alloc;
75 nvm_dev_dma_free_fn *dev_dma_free;
76
77 unsigned int max_phys_sect;
78};
79
Matias Bjørlingcd9e9802015-10-28 19:54:55 +010080#ifdef CONFIG_NVM
81
82#include <linux/blkdev.h>
Matias Bjørlingcd9e9802015-10-28 19:54:55 +010083#include <linux/file.h>
84#include <linux/dmapool.h>
Matias Bjørlinge3eb3792016-01-12 07:49:36 +010085#include <uapi/linux/lightnvm.h>
Matias Bjørlingcd9e9802015-10-28 19:54:55 +010086
87enum {
88 /* HW Responsibilities */
89 NVM_RSP_L2P = 1 << 0,
90 NVM_RSP_ECC = 1 << 1,
91
92 /* Physical Adressing Mode */
93 NVM_ADDRMODE_LINEAR = 0,
94 NVM_ADDRMODE_CHANNEL = 1,
95
96 /* Plane programming mode for LUN */
Matias Bjørlingd5bdec82016-02-19 13:56:58 +010097 NVM_PLANE_SINGLE = 1,
98 NVM_PLANE_DOUBLE = 2,
99 NVM_PLANE_QUAD = 4,
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100100
101 /* Status codes */
102 NVM_RSP_SUCCESS = 0x0,
103 NVM_RSP_NOT_CHANGEABLE = 0x1,
104 NVM_RSP_ERR_FAILWRITE = 0x40ff,
105 NVM_RSP_ERR_EMPTYPAGE = 0x42ff,
Javier González402ab9a2016-11-28 22:38:57 +0100106 NVM_RSP_ERR_FAILECC = 0x4281,
Javier González38ea2f72017-01-31 13:17:18 +0100107 NVM_RSP_ERR_FAILCRC = 0x4004,
Javier González402ab9a2016-11-28 22:38:57 +0100108 NVM_RSP_WARN_HIGHECC = 0x4700,
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100109
110 /* Device opcodes */
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100111 NVM_OP_PWRITE = 0x91,
112 NVM_OP_PREAD = 0x92,
113 NVM_OP_ERASE = 0x90,
114
115 /* PPA Command Flags */
116 NVM_IO_SNGL_ACCESS = 0x0,
117 NVM_IO_DUAL_ACCESS = 0x1,
118 NVM_IO_QUAD_ACCESS = 0x2,
119
Matias Bjørling57b4bd02015-12-06 11:25:47 +0100120 /* NAND Access Modes */
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100121 NVM_IO_SUSPEND = 0x80,
122 NVM_IO_SLC_MODE = 0x100,
Javier Gonzáleza7737f32017-04-15 20:55:38 +0200123 NVM_IO_SCRAMBLE_ENABLE = 0x200,
Matias Bjørling57b4bd02015-12-06 11:25:47 +0100124
125 /* Block Types */
126 NVM_BLK_T_FREE = 0x0,
127 NVM_BLK_T_BAD = 0x1,
Matias Bjørlingb5d4acd2016-01-12 07:49:32 +0100128 NVM_BLK_T_GRWN_BAD = 0x2,
129 NVM_BLK_T_DEV = 0x4,
130 NVM_BLK_T_HOST = 0x8,
Matias Bjørlingf9a99952016-01-12 07:49:34 +0100131
132 /* Memory capabilities */
133 NVM_ID_CAP_SLC = 0x1,
134 NVM_ID_CAP_CMD_SUSPEND = 0x2,
135 NVM_ID_CAP_SCRAMBLE = 0x4,
136 NVM_ID_CAP_ENCRYPT = 0x8,
Matias Bjørlingca5927e2016-01-12 07:49:35 +0100137
138 /* Memory types */
139 NVM_ID_FMTYPE_SLC = 0,
140 NVM_ID_FMTYPE_MLC = 1,
Matias Bjørlingbf643182016-02-04 15:13:27 +0100141
142 /* Device capabilities */
143 NVM_ID_DCAP_BBLKMGMT = 0x1,
144 NVM_UD_DCAP_ECC = 0x2,
Matias Bjørlingca5927e2016-01-12 07:49:35 +0100145};
146
147struct nvm_id_lp_mlc {
148 u16 num_pairs;
149 u8 pairs[886];
150};
151
152struct nvm_id_lp_tbl {
153 __u8 id[8];
154 struct nvm_id_lp_mlc mlc;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100155};
156
Matias Bjørlingc6ac3f32018-03-30 00:05:01 +0200157struct nvm_addr_format {
158 u8 ch_offset;
159 u8 ch_len;
160 u8 lun_offset;
161 u8 lun_len;
162 u8 pln_offset;
163 u8 pln_len;
164 u8 blk_offset;
165 u8 blk_len;
166 u8 pg_offset;
167 u8 pg_len;
168 u8 sect_offset;
169 u8 sect_len;
170};
171
172struct nvm_id {
173 u8 ver_id;
174 u8 vmnt;
175 u32 cap;
176 u32 dom;
177
178 struct nvm_addr_format ppaf;
179
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100180 u8 num_ch;
181 u8 num_lun;
Matias Bjørlingfae7fae2018-01-05 14:16:03 +0100182 u16 num_chk;
183 u16 clba;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100184 u16 csecs;
185 u16 sos;
Matias Bjørlingfae7fae2018-01-05 14:16:03 +0100186
187 u16 ws_min;
188 u16 ws_opt;
189 u16 ws_seq;
190 u16 ws_per_chk;
191
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100192 u32 trdt;
193 u32 trdm;
194 u32 tprt;
195 u32 tprm;
196 u32 tbet;
197 u32 tbem;
198 u32 mpos;
Matias Bjørling12be5ed2015-11-16 15:34:39 +0100199 u32 mccap;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100200 u16 cpar;
Matias Bjørlingfae7fae2018-01-05 14:16:03 +0100201
202 /* 1.2 compatibility */
Matias Bjørlingc6ac3f32018-03-30 00:05:01 +0200203 u8 mtype;
204 u8 fmtype;
205
Matias Bjørlingfae7fae2018-01-05 14:16:03 +0100206 u8 num_pln;
207 u16 num_pg;
208 u16 fpg_sz;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100209} __packed;
210
211struct nvm_target {
212 struct list_head list;
Javier González8e79b5c2016-11-28 22:39:06 +0100213 struct nvm_tgt_dev *dev;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100214 struct nvm_tgt_type *type;
215 struct gendisk *disk;
216};
217
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100218#define ADDR_EMPTY (~0ULL)
219
Javier Gonzáleze5392732018-01-05 14:16:14 +0100220#define NVM_TARGET_DEFAULT_OP (101)
221#define NVM_TARGET_MIN_OP (3)
222#define NVM_TARGET_MAX_OP (80)
223
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100224#define NVM_VERSION_MAJOR 1
225#define NVM_VERSION_MINOR 0
226#define NVM_VERSION_PATCH 0
227
Matias Bjørling912761622016-01-12 07:49:21 +0100228struct nvm_rq;
Matias Bjørling72d256e2016-01-12 07:49:29 +0100229typedef void (nvm_end_io_fn)(struct nvm_rq *);
Matias Bjørling912761622016-01-12 07:49:21 +0100230
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100231struct nvm_rq {
Javier González8e536242016-11-28 22:39:10 +0100232 struct nvm_tgt_dev *dev;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100233
234 struct bio *bio;
235
236 union {
237 struct ppa_addr ppa_addr;
238 dma_addr_t dma_ppa_list;
239 };
240
241 struct ppa_addr *ppa_list;
242
Javier González003fad32016-05-06 20:03:12 +0200243 void *meta_list;
244 dma_addr_t dma_meta_list;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100245
Matias Bjørling912761622016-01-12 07:49:21 +0100246 nvm_end_io_fn *end_io;
247
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100248 uint8_t opcode;
Javier González6d5be952016-05-06 20:03:20 +0200249 uint16_t nr_ppas;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100250 uint16_t flags;
Matias Bjørling72d256e2016-01-12 07:49:29 +0100251
Matias Bjorling9f867262016-03-03 15:06:39 +0100252 u64 ppa_status; /* ppa media status */
Matias Bjørling72d256e2016-01-12 07:49:29 +0100253 int error;
Matias Bjørling06894ef2017-01-31 13:17:17 +0100254
255 void *private;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100256};
257
258static inline struct nvm_rq *nvm_rq_from_pdu(void *pdu)
259{
260 return pdu - sizeof(struct nvm_rq);
261}
262
263static inline void *nvm_rq_to_pdu(struct nvm_rq *rqdata)
264{
265 return rqdata + 1;
266}
267
Javier Gonzálezff0e4982016-01-12 07:49:33 +0100268enum {
269 NVM_BLK_ST_FREE = 0x1, /* Free block */
Matias Bjørling077d2382016-07-07 09:54:14 +0200270 NVM_BLK_ST_TGT = 0x2, /* Block in use by target */
Javier Gonzálezff0e4982016-01-12 07:49:33 +0100271 NVM_BLK_ST_BAD = 0x8, /* Bad block */
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100272};
273
Matias Bjørlingfae7fae2018-01-05 14:16:03 +0100274
Javier González8e79b5c2016-11-28 22:39:06 +0100275/* Device generic information */
276struct nvm_geo {
Matias Bjørlingfae7fae2018-01-05 14:16:03 +0100277 /* generic geometry */
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100278 int nr_chnls;
Matias Bjørlingfae7fae2018-01-05 14:16:03 +0100279 int all_luns; /* across channels */
280 int nr_luns; /* per channel */
281 int nr_chks; /* per lun */
282
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100283 int sec_size;
284 int oob_size;
Matias Bjørlingf9a99952016-01-12 07:49:34 +0100285 int mccap;
Matias Bjørlingfae7fae2018-01-05 14:16:03 +0100286
287 int sec_per_chk;
288 int sec_per_lun;
289
290 int ws_min;
291 int ws_opt;
292 int ws_seq;
293 int ws_per_chk;
294
295 int max_rq_size;
296
Javier Gonzáleze5392732018-01-05 14:16:14 +0100297 int op;
298
Matias Bjørling7386af22015-11-16 15:34:44 +0100299 struct nvm_addr_format ppaf;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100300
Matias Bjørlingfae7fae2018-01-05 14:16:03 +0100301 /* Legacy 1.2 specific geometry */
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100302 int plane_mode; /* drive device in single, double or quad mode */
Matias Bjørlingfae7fae2018-01-05 14:16:03 +0100303 int nr_planes;
304 int sec_per_pg; /* only sectors for a single page */
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100305 int sec_per_pl; /* all sectors across planes */
Javier González8e79b5c2016-11-28 22:39:06 +0100306};
307
Matias Bjørlingade69e22017-01-31 13:17:09 +0100308/* sub-device structure */
Javier González8e79b5c2016-11-28 22:39:06 +0100309struct nvm_tgt_dev {
310 /* Device information */
311 struct nvm_geo geo;
312
Javier González8e536242016-11-28 22:39:10 +0100313 /* Base ppas for target LUNs */
314 struct ppa_addr *luns;
315
Javier González8e79b5c2016-11-28 22:39:06 +0100316 sector_t total_secs;
317
318 struct nvm_id identity;
319 struct request_queue *q;
320
Javier González959e9112016-11-28 22:39:11 +0100321 struct nvm_dev *parent;
Javier González8e536242016-11-28 22:39:10 +0100322 void *map;
Javier González8e79b5c2016-11-28 22:39:06 +0100323};
324
325struct nvm_dev {
326 struct nvm_dev_ops *ops;
327
328 struct list_head devices;
329
Javier González8e79b5c2016-11-28 22:39:06 +0100330 /* Device information */
331 struct nvm_geo geo;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100332
Matias Bjørling4ece44a2016-02-20 08:52:41 +0100333 unsigned long total_secs;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100334
Wenwei Taoda1e2842016-03-03 15:06:38 +0100335 unsigned long *lun_map;
Javier González75b85642016-05-06 20:03:13 +0200336 void *dma_pool;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100337
338 struct nvm_id identity;
339
340 /* Backend device */
341 struct request_queue *q;
342 char name[DISK_NAME_LEN];
Simon A. F. Lund40267ef2016-09-16 14:25:08 +0200343 void *private_data;
Matias Bjørlinge3eb3792016-01-12 07:49:36 +0100344
Javier González8e536242016-11-28 22:39:10 +0100345 void *rmap;
346
Matias Bjørlinge3eb3792016-01-12 07:49:36 +0100347 struct mutex mlock;
Wenwei Tao4c9dacb2016-03-03 15:06:37 +0100348 spinlock_t lock;
Matias Bjørlingade69e22017-01-31 13:17:09 +0100349
350 /* target management */
351 struct list_head area_list;
352 struct list_head targets;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100353};
354
Matias Bjørlingdab8ee92017-01-31 13:17:14 +0100355static inline struct ppa_addr generic_to_dev_addr(struct nvm_tgt_dev *tgt_dev,
356 struct ppa_addr r)
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100357{
Matias Bjørlingdab8ee92017-01-31 13:17:14 +0100358 struct nvm_geo *geo = &tgt_dev->geo;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100359 struct ppa_addr l;
360
Javier González8e79b5c2016-11-28 22:39:06 +0100361 l.ppa = ((u64)r.g.blk) << geo->ppaf.blk_offset;
362 l.ppa |= ((u64)r.g.pg) << geo->ppaf.pg_offset;
363 l.ppa |= ((u64)r.g.sec) << geo->ppaf.sect_offset;
364 l.ppa |= ((u64)r.g.pl) << geo->ppaf.pln_offset;
365 l.ppa |= ((u64)r.g.lun) << geo->ppaf.lun_offset;
366 l.ppa |= ((u64)r.g.ch) << geo->ppaf.ch_offset;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100367
368 return l;
369}
370
Matias Bjørlingdab8ee92017-01-31 13:17:14 +0100371static inline struct ppa_addr dev_to_generic_addr(struct nvm_tgt_dev *tgt_dev,
372 struct ppa_addr r)
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100373{
Matias Bjørlingdab8ee92017-01-31 13:17:14 +0100374 struct nvm_geo *geo = &tgt_dev->geo;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100375 struct ppa_addr l;
376
Javier González5389a1d2016-07-07 09:54:09 +0200377 l.ppa = 0;
Matias Bjørling7386af22015-11-16 15:34:44 +0100378 /*
379 * (r.ppa << X offset) & X len bitmask. X eq. blk, pg, etc.
380 */
Javier González8e79b5c2016-11-28 22:39:06 +0100381 l.g.blk = (r.ppa >> geo->ppaf.blk_offset) &
382 (((1 << geo->ppaf.blk_len) - 1));
383 l.g.pg |= (r.ppa >> geo->ppaf.pg_offset) &
384 (((1 << geo->ppaf.pg_len) - 1));
385 l.g.sec |= (r.ppa >> geo->ppaf.sect_offset) &
386 (((1 << geo->ppaf.sect_len) - 1));
387 l.g.pl |= (r.ppa >> geo->ppaf.pln_offset) &
388 (((1 << geo->ppaf.pln_len) - 1));
389 l.g.lun |= (r.ppa >> geo->ppaf.lun_offset) &
390 (((1 << geo->ppaf.lun_len) - 1));
391 l.g.ch |= (r.ppa >> geo->ppaf.ch_offset) &
392 (((1 << geo->ppaf.ch_len) - 1));
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100393
394 return l;
395}
396
Jens Axboedece1632015-11-05 10:41:16 -0700397typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *);
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100398typedef sector_t (nvm_tgt_capacity_fn)(void *);
Javier González4af3f752017-04-15 20:55:45 +0200399typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *,
400 int flags);
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100401typedef void (nvm_tgt_exit_fn)(void *);
Javier González9a69b0e2017-01-31 13:17:20 +0100402typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *);
403typedef void (nvm_tgt_sysfs_exit_fn)(struct gendisk *);
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100404
405struct nvm_tgt_type {
406 const char *name;
407 unsigned int version[3];
408
409 /* target entry points */
410 nvm_tgt_make_rq_fn *make_rq;
411 nvm_tgt_capacity_fn *capacity;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100412
413 /* module-specific init/teardown */
414 nvm_tgt_init_fn *init;
415 nvm_tgt_exit_fn *exit;
416
Javier González9a69b0e2017-01-31 13:17:20 +0100417 /* sysfs */
418 nvm_tgt_sysfs_init_fn *sysfs_init;
419 nvm_tgt_sysfs_exit_fn *sysfs_exit;
420
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100421 /* For internal use */
422 struct list_head list;
Rakesh Pandit90014822017-10-13 14:45:50 +0200423 struct module *owner;
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100424};
425
Simon A. F. Lund6063fe32016-05-06 20:03:02 +0200426extern int nvm_register_tgt_type(struct nvm_tgt_type *);
427extern void nvm_unregister_tgt_type(struct nvm_tgt_type *);
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100428
429extern void *nvm_dev_dma_alloc(struct nvm_dev *, gfp_t, dma_addr_t *);
430extern void nvm_dev_dma_free(struct nvm_dev *, void *, dma_addr_t);
431
Matias Bjørlingb0b4e092016-09-16 14:25:07 +0200432extern struct nvm_dev *nvm_alloc_dev(int);
433extern int nvm_register(struct nvm_dev *);
434extern void nvm_unregister(struct nvm_dev *);
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100435
Javier González333ba052016-11-28 22:39:14 +0100436extern int nvm_set_tgt_bb_tbl(struct nvm_tgt_dev *, struct ppa_addr *,
437 int, int);
Javier Gonzáleza2790062016-11-28 22:39:12 +0100438extern int nvm_max_phys_sects(struct nvm_tgt_dev *);
Javier González8e536242016-11-28 22:39:10 +0100439extern int nvm_submit_io(struct nvm_tgt_dev *, struct nvm_rq *);
Javier González1a94b2d2017-10-13 14:46:47 +0200440extern int nvm_submit_io_sync(struct nvm_tgt_dev *, struct nvm_rq *);
Matias Bjørling06894ef2017-01-31 13:17:17 +0100441extern void nvm_end_io(struct nvm_rq *);
Matias Bjørling22e8c972016-05-06 20:02:58 +0200442extern int nvm_bb_tbl_fold(struct nvm_dev *, u8 *, int);
Javier González333ba052016-11-28 22:39:14 +0100443extern int nvm_get_tgt_bb_tbl(struct nvm_tgt_dev *, struct ppa_addr, u8 *);
Matias Bjørlinge3eb3792016-01-12 07:49:36 +0100444
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100445#else /* CONFIG_NVM */
446struct nvm_dev_ops;
447
Matias Bjørlingb0b4e092016-09-16 14:25:07 +0200448static inline struct nvm_dev *nvm_alloc_dev(int node)
449{
450 return ERR_PTR(-EINVAL);
451}
452static inline int nvm_register(struct nvm_dev *dev)
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100453{
454 return -EINVAL;
455}
Matias Bjørlingb0b4e092016-09-16 14:25:07 +0200456static inline void nvm_unregister(struct nvm_dev *dev) {}
Matias Bjørlingcd9e9802015-10-28 19:54:55 +0100457#endif /* CONFIG_NVM */
458#endif /* LIGHTNVM.H */