2 * Copyright (C) 2015 CNEX Labs. All rights reserved.
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.
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.
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,
19 #ifndef _UAPI_LINUX_LIGHTNVM_H
20 #define _UAPI_LINUX_LIGHTNVM_H
23 #include <linux/kernel.h>
24 #include <linux/ioctl.h>
25 #else /* __KERNEL__ */
27 #include <sys/ioctl.h>
28 #define DISK_NAME_LEN 32
29 #endif /* __KERNEL__ */
31 #include <linux/types.h>
32 #include <linux/ioctl.h>
34 #define NVM_TTYPE_NAME_MAX 48
35 #define NVM_TTYPE_MAX 63
36 #define NVM_MMTYPE_LEN 8
38 #define NVM_CTRL_FILE "/dev/lightnvm/control"
40 struct nvm_ioctl_info_tgt {
43 char tgtname[NVM_TTYPE_NAME_MAX];
46 struct nvm_ioctl_info {
47 __u32 version[3]; /* in/out - major, minor, patch */
48 __u16 tgtsize; /* number of targets */
49 __u16 reserved16; /* pad to 4K page */
51 struct nvm_ioctl_info_tgt tgts[NVM_TTYPE_MAX];
55 NVM_DEVICE_ACTIVE = 1 << 0,
58 struct nvm_ioctl_device_info {
59 char devname[DISK_NAME_LEN];
60 char bmname[NVM_TTYPE_NAME_MAX];
66 struct nvm_ioctl_get_devices {
69 struct nvm_ioctl_device_info info[31];
72 struct nvm_ioctl_create_simple {
78 NVM_CONFIG_TYPE_SIMPLE = 0,
81 struct nvm_ioctl_create_conf {
84 struct nvm_ioctl_create_simple s;
89 NVM_TARGET_FACTORY = 1 << 0, /* Init target in factory mode */
92 struct nvm_ioctl_create {
93 char dev[DISK_NAME_LEN]; /* open-channel SSD device */
94 char tgttype[NVM_TTYPE_NAME_MAX]; /* target type name */
95 char tgtname[DISK_NAME_LEN]; /* dev to expose target as */
99 struct nvm_ioctl_create_conf conf;
102 struct nvm_ioctl_remove {
103 char tgtname[DISK_NAME_LEN];
108 struct nvm_ioctl_dev_init {
109 char dev[DISK_NAME_LEN]; /* open-channel SSD device */
110 char mmtype[NVM_MMTYPE_LEN]; /* register to media manager */
116 NVM_FACTORY_ERASE_ONLY_USER = 1 << 0, /* erase only blocks used as
117 * host blks or grown blks */
118 NVM_FACTORY_RESET_HOST_BLKS = 1 << 1, /* remove host blk marks */
119 NVM_FACTORY_RESET_GRWN_BBLKS = 1 << 2, /* remove grown blk marks */
120 NVM_FACTORY_NR_BITS = 1 << 3, /* stops here */
123 struct nvm_ioctl_dev_factory {
124 char dev[DISK_NAME_LEN];
129 struct nvm_user_vio {
145 struct nvm_passthru_vio {
167 /* The ioctl type, 'L', 0x20 - 0x2F documented in ioctl-number.txt */
173 /* device level cmds */
177 /* Init a device to support LightNVM media managers */
180 /* Factory reset device */
183 /* Vector user I/O */
184 NVM_DEV_VIO_ADMIN_CMD = 0x41,
185 NVM_DEV_VIO_CMD = 0x42,
186 NVM_DEV_VIO_USER_CMD = 0x43,
189 #define NVM_IOCTL 'L' /* 0x4c */
191 #define NVM_INFO _IOWR(NVM_IOCTL, NVM_INFO_CMD, \
192 struct nvm_ioctl_info)
193 #define NVM_GET_DEVICES _IOR(NVM_IOCTL, NVM_GET_DEVICES_CMD, \
194 struct nvm_ioctl_get_devices)
195 #define NVM_DEV_CREATE _IOW(NVM_IOCTL, NVM_DEV_CREATE_CMD, \
196 struct nvm_ioctl_create)
197 #define NVM_DEV_REMOVE _IOW(NVM_IOCTL, NVM_DEV_REMOVE_CMD, \
198 struct nvm_ioctl_remove)
199 #define NVM_DEV_INIT _IOW(NVM_IOCTL, NVM_DEV_INIT_CMD, \
200 struct nvm_ioctl_dev_init)
201 #define NVM_DEV_FACTORY _IOW(NVM_IOCTL, NVM_DEV_FACTORY_CMD, \
202 struct nvm_ioctl_dev_factory)
204 #define NVME_NVM_IOCTL_IO_VIO _IOWR(NVM_IOCTL, NVM_DEV_VIO_USER_CMD, \
205 struct nvm_passthru_vio)
206 #define NVME_NVM_IOCTL_ADMIN_VIO _IOWR(NVM_IOCTL, NVM_DEV_VIO_ADMIN_CMD,\
207 struct nvm_passthru_vio)
208 #define NVME_NVM_IOCTL_SUBMIT_VIO _IOWR(NVM_IOCTL, NVM_DEV_VIO_CMD,\
211 #define NVM_VERSION_MAJOR 1
212 #define NVM_VERSION_MINOR 0
213 #define NVM_VERSION_PATCHLEVEL 0