lightnvm.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Copyright (C) 2015 CNEX Labs. All rights reserved.
  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. * You should have received a copy of the GNU General Public License
  14. * along with this program; see the file COPYING. If not, write to
  15. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  16. * USA.
  17. */
  18. #ifndef _UAPI_LINUX_LIGHTNVM_H
  19. #define _UAPI_LINUX_LIGHTNVM_H
  20. #ifdef __KERNEL__
  21. #include <linux/kernel.h>
  22. #include <linux/ioctl.h>
  23. #else /* __KERNEL__ */
  24. #include <stdio.h>
  25. #include <sys/ioctl.h>
  26. #define DISK_NAME_LEN 32
  27. #endif /* __KERNEL__ */
  28. #include <linux/types.h>
  29. #include <linux/ioctl.h>
  30. #define NVM_TTYPE_NAME_MAX 48
  31. #define NVM_TTYPE_MAX 63
  32. #define NVM_CTRL_FILE "/dev/lightnvm/control"
  33. struct nvm_ioctl_info_tgt {
  34. __u32 version[3];
  35. __u32 reserved;
  36. char tgtname[NVM_TTYPE_NAME_MAX];
  37. };
  38. struct nvm_ioctl_info {
  39. __u32 version[3]; /* in/out - major, minor, patch */
  40. __u16 tgtsize; /* number of targets */
  41. __u16 reserved16; /* pad to 4K page */
  42. __u32 reserved[12];
  43. struct nvm_ioctl_info_tgt tgts[NVM_TTYPE_MAX];
  44. };
  45. enum {
  46. NVM_DEVICE_ACTIVE = 1 << 0,
  47. };
  48. struct nvm_ioctl_device_info {
  49. char devname[DISK_NAME_LEN];
  50. char bmname[NVM_TTYPE_NAME_MAX];
  51. __u32 bmversion[3];
  52. __u32 flags;
  53. __u32 reserved[8];
  54. };
  55. struct nvm_ioctl_get_devices {
  56. __u32 nr_devices;
  57. __u32 reserved[31];
  58. struct nvm_ioctl_device_info info[31];
  59. };
  60. struct nvm_ioctl_create_simple {
  61. __u32 lun_begin;
  62. __u32 lun_end;
  63. };
  64. enum {
  65. NVM_CONFIG_TYPE_SIMPLE = 0,
  66. };
  67. struct nvm_ioctl_create_conf {
  68. __u32 type;
  69. union {
  70. struct nvm_ioctl_create_simple s;
  71. };
  72. };
  73. struct nvm_ioctl_create {
  74. char dev[DISK_NAME_LEN]; /* open-channel SSD device */
  75. char tgttype[NVM_TTYPE_NAME_MAX]; /* target type name */
  76. char tgtname[DISK_NAME_LEN]; /* dev to expose target as */
  77. __u32 flags;
  78. struct nvm_ioctl_create_conf conf;
  79. };
  80. struct nvm_ioctl_remove {
  81. char tgtname[DISK_NAME_LEN];
  82. __u32 flags;
  83. };
  84. /* The ioctl type, 'L', 0x20 - 0x2F documented in ioctl-number.txt */
  85. enum {
  86. /* top level cmds */
  87. NVM_INFO_CMD = 0x20,
  88. NVM_GET_DEVICES_CMD,
  89. /* device level cmds */
  90. NVM_DEV_CREATE_CMD,
  91. NVM_DEV_REMOVE_CMD,
  92. };
  93. #define NVM_IOCTL 'L' /* 0x4c */
  94. #define NVM_INFO _IOWR(NVM_IOCTL, NVM_INFO_CMD, \
  95. struct nvm_ioctl_info)
  96. #define NVM_GET_DEVICES _IOR(NVM_IOCTL, NVM_GET_DEVICES_CMD, \
  97. struct nvm_ioctl_get_devices)
  98. #define NVM_DEV_CREATE _IOW(NVM_IOCTL, NVM_DEV_CREATE_CMD, \
  99. struct nvm_ioctl_create)
  100. #define NVM_DEV_REMOVE _IOW(NVM_IOCTL, NVM_DEV_REMOVE_CMD, \
  101. struct nvm_ioctl_remove)
  102. #define NVM_VERSION_MAJOR 1
  103. #define NVM_VERSION_MINOR 0
  104. #define NVM_VERSION_PATCHLEVEL 0
  105. #endif