lightnvm: refactor dev->online_target to global nvm_targets
[platform/kernel/linux-rpi.git] / include / linux / lightnvm.h
index c3c4318..5eabdba 100644 (file)
@@ -41,11 +41,12 @@ struct nvm_id;
 struct nvm_dev;
 
 typedef int (nvm_l2p_update_fn)(u64, u32, __le64 *, void *);
-typedef int (nvm_bb_update_fn)(struct ppa_addr, int, u8 *, void *);
+typedef int (nvm_bb_update_fn)(struct nvm_dev *, struct ppa_addr, u8 *, int,
+                                                               void *);
 typedef int (nvm_id_fn)(struct nvm_dev *, struct nvm_id *);
 typedef int (nvm_get_l2p_tbl_fn)(struct nvm_dev *, u64, u32,
                                nvm_l2p_update_fn *, void *);
-typedef int (nvm_op_bb_tbl_fn)(struct nvm_dev *, struct ppa_addr, int,
+typedef int (nvm_op_bb_tbl_fn)(struct nvm_dev *, struct ppa_addr,
                                nvm_bb_update_fn *, void *);
 typedef int (nvm_op_set_bb_fn)(struct nvm_dev *, struct nvm_rq *, int);
 typedef int (nvm_submit_io_fn)(struct nvm_dev *, struct nvm_rq *);
@@ -242,6 +243,7 @@ struct nvm_rq {
        uint16_t nr_pages;
        uint16_t flags;
 
+       u64 ppa_status; /* ppa media status */
        int error;
 };
 
@@ -306,7 +308,6 @@ struct nvm_dev {
        struct nvm_dev_ops *ops;
 
        struct list_head devices;
-       struct list_head online_targets;
 
        /* Media manager */
        struct nvmm_type *mt;
@@ -322,6 +323,8 @@ struct nvm_dev {
        int sec_per_pg; /* only sectors for a single page */
        int pgs_per_blk;
        int blks_per_lun;
+       int fpg_size;
+       int pfpg_size; /* size of buffer if all pages are to be read */
        int sec_size;
        int oob_size;
        int mccap;
@@ -346,6 +349,7 @@ struct nvm_dev {
        int nr_luns;
        unsigned max_pages_per_blk;
 
+       unsigned long *lun_map;
        void *ppalist_pool;
 
        struct nvm_id identity;
@@ -355,6 +359,7 @@ struct nvm_dev {
        char name[DISK_NAME_LEN];
 
        struct mutex mlock;
+       spinlock_t lock;
 };
 
 static inline struct ppa_addr generic_to_dev_addr(struct nvm_dev *dev,
@@ -447,8 +452,8 @@ struct nvm_tgt_type {
        struct list_head list;
 };
 
-extern int nvm_register_target(struct nvm_tgt_type *);
-extern void nvm_unregister_target(struct nvm_tgt_type *);
+extern int nvm_register_tgt_type(struct nvm_tgt_type *);
+extern void nvm_unregister_tgt_type(struct nvm_tgt_type *);
 
 extern void *nvm_dev_dma_alloc(struct nvm_dev *, gfp_t, dma_addr_t *);
 extern void nvm_dev_dma_free(struct nvm_dev *, void *, dma_addr_t);
@@ -465,8 +470,13 @@ typedef int (nvmm_submit_io_fn)(struct nvm_dev *, struct nvm_rq *);
 typedef int (nvmm_erase_blk_fn)(struct nvm_dev *, struct nvm_block *,
                                                                unsigned long);
 typedef struct nvm_lun *(nvmm_get_lun_fn)(struct nvm_dev *, int);
+typedef int (nvmm_reserve_lun)(struct nvm_dev *, int);
+typedef void (nvmm_release_lun)(struct nvm_dev *, int);
 typedef void (nvmm_lun_info_print_fn)(struct nvm_dev *);
 
+typedef int (nvmm_get_area_fn)(struct nvm_dev *, sector_t *, sector_t);
+typedef void (nvmm_put_area_fn)(struct nvm_dev *, sector_t);
+
 struct nvmm_type {
        const char *name;
        unsigned int version[3];
@@ -488,9 +498,15 @@ struct nvmm_type {
 
        /* Configuration management */
        nvmm_get_lun_fn *get_lun;
+       nvmm_reserve_lun *reserve_lun;
+       nvmm_release_lun *release_lun;
 
        /* Statistics */
        nvmm_lun_info_print_fn *lun_info_print;
+
+       nvmm_get_area_fn *get_area;
+       nvmm_put_area_fn *put_area;
+
        struct list_head list;
 };
 
@@ -520,6 +536,9 @@ extern int nvm_erase_blk(struct nvm_dev *, struct nvm_block *);
 extern void nvm_end_io(struct nvm_rq *, int);
 extern int nvm_submit_ppa(struct nvm_dev *, struct ppa_addr *, int, int, int,
                                                                void *, int);
+extern int nvm_submit_ppa_list(struct nvm_dev *, struct ppa_addr *, int, int,
+                                                       int, void *, int);
+extern int nvm_bb_tbl_fold(struct nvm_dev *, u8 *, int);
 
 /* sysblk.c */
 #define NVM_SYSBLK_MAGIC 0x4E564D53 /* "NVMS" */