Matias Bjørling | 48add0f | 2015-10-28 19:54:56 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright: Matias Bjorling <mb@bjorling.me> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License version |
| 6 | * 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * General Public License for more details. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef GENNVM_H_ |
| 16 | #define GENNVM_H_ |
| 17 | |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/vmalloc.h> |
| 20 | |
| 21 | #include <linux/lightnvm.h> |
| 22 | |
Matias Bjørling | 5e60edb | 2016-07-07 09:54:15 +0200 | [diff] [blame] | 23 | struct gen_dev { |
Matias Bjørling | 1145046 | 2015-11-16 15:34:37 +0100 | [diff] [blame] | 24 | struct nvm_dev *dev; |
| 25 | |
Matias Bjørling | 48add0f | 2015-10-28 19:54:56 +0100 | [diff] [blame] | 26 | int nr_luns; |
Wenwei Tao | 4c9dacb | 2016-03-03 15:06:37 +0100 | [diff] [blame] | 27 | struct list_head area_list; |
Matias Bjørling | b76eb20b | 2016-07-07 09:54:16 +0200 | [diff] [blame] | 28 | |
| 29 | struct mutex lock; |
| 30 | struct list_head targets; |
Matias Bjørling | 48add0f | 2015-10-28 19:54:56 +0100 | [diff] [blame] | 31 | }; |
| 32 | |
Javier González | 8e53624 | 2016-11-28 22:39:10 +0100 | [diff] [blame] | 33 | /* Map between virtual and physical channel and lun */ |
| 34 | struct gen_ch_map { |
| 35 | int ch_off; |
| 36 | int nr_luns; |
| 37 | int *lun_offs; |
| 38 | }; |
| 39 | |
| 40 | struct gen_dev_map { |
| 41 | struct gen_ch_map *chnls; |
| 42 | int nr_chnls; |
| 43 | }; |
| 44 | |
Matias Bjørling | 5e60edb | 2016-07-07 09:54:15 +0200 | [diff] [blame] | 45 | struct gen_area { |
Wenwei Tao | 4c9dacb | 2016-03-03 15:06:37 +0100 | [diff] [blame] | 46 | struct list_head list; |
| 47 | sector_t begin; |
| 48 | sector_t end; /* end is excluded */ |
| 49 | }; |
Matias Bjørling | 5e60edb | 2016-07-07 09:54:15 +0200 | [diff] [blame] | 50 | |
Javier González | 8e53624 | 2016-11-28 22:39:10 +0100 | [diff] [blame] | 51 | static inline void *ch_map_to_lun_offs(struct gen_ch_map *ch_map) |
| 52 | { |
| 53 | return ch_map + 1; |
| 54 | } |
| 55 | |
| 56 | typedef int (gen_trans_fn)(struct nvm_tgt_dev *, struct ppa_addr *); |
| 57 | |
Matias Bjørling | 5e60edb | 2016-07-07 09:54:15 +0200 | [diff] [blame] | 58 | #define gen_for_each_lun(bm, lun, i) \ |
Matias Bjørling | 48add0f | 2015-10-28 19:54:56 +0100 | [diff] [blame] | 59 | for ((i) = 0, lun = &(bm)->luns[0]; \ |
| 60 | (i) < (bm)->nr_luns; (i)++, lun = &(bm)->luns[(i)]) |
| 61 | |
| 62 | #endif /* GENNVM_H_ */ |