gennvm.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifndef GENNVM_H_
  15. #define GENNVM_H_
  16. #include <linux/module.h>
  17. #include <linux/vmalloc.h>
  18. #include <linux/lightnvm.h>
  19. struct gen_dev {
  20. struct nvm_dev *dev;
  21. int nr_luns;
  22. struct list_head area_list;
  23. struct mutex lock;
  24. struct list_head targets;
  25. };
  26. /* Map between virtual and physical channel and lun */
  27. struct gen_ch_map {
  28. int ch_off;
  29. int nr_luns;
  30. int *lun_offs;
  31. };
  32. struct gen_dev_map {
  33. struct gen_ch_map *chnls;
  34. int nr_chnls;
  35. };
  36. struct gen_area {
  37. struct list_head list;
  38. sector_t begin;
  39. sector_t end; /* end is excluded */
  40. };
  41. static inline void *ch_map_to_lun_offs(struct gen_ch_map *ch_map)
  42. {
  43. return ch_map + 1;
  44. }
  45. typedef int (gen_trans_fn)(struct nvm_tgt_dev *, struct ppa_addr *);
  46. #define gen_for_each_lun(bm, lun, i) \
  47. for ((i) = 0, lun = &(bm)->luns[0]; \
  48. (i) < (bm)->nr_luns; (i)++, lun = &(bm)->luns[(i)])
  49. #endif /* GENNVM_H_ */