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
37 #define NVM_CTRL_FILE "/dev/lightnvm/control"
39 struct nvm_ioctl_info_tgt {
42 char tgtname[NVM_TTYPE_NAME_MAX];
45 struct nvm_ioctl_info {
46 __u32 version[3]; /* in/out - major, minor, patch */
47 __u16 tgtsize; /* number of targets */
48 __u16 reserved16; /* pad to 4K page */
50 struct nvm_ioctl_info_tgt tgts[NVM_TTYPE_MAX];
54 NVM_DEVICE_ACTIVE = 1 << 0,
57 struct nvm_ioctl_device_info {
58 char devname[DISK_NAME_LEN];
59 char bmname[NVM_TTYPE_NAME_MAX];
65 struct nvm_ioctl_get_devices {
68 struct nvm_ioctl_device_info info[31];
71 struct nvm_ioctl_create_simple {
77 NVM_CONFIG_TYPE_SIMPLE = 0,
80 struct nvm_ioctl_create_conf {
83 struct nvm_ioctl_create_simple s;
87 struct nvm_ioctl_create {
88 char dev[DISK_NAME_LEN]; /* open-channel SSD device */
89 char tgttype[NVM_TTYPE_NAME_MAX]; /* target type name */
90 char tgtname[DISK_NAME_LEN]; /* dev to expose target as */
94 struct nvm_ioctl_create_conf conf;
97 struct nvm_ioctl_remove {
98 char tgtname[DISK_NAME_LEN];
104 /* The ioctl type, 'L', 0x20 - 0x2F documented in ioctl-number.txt */
110 /* device level cmds */
115 #define NVM_IOCTL 'L' /* 0x4c */
117 #define NVM_INFO _IOWR(NVM_IOCTL, NVM_INFO_CMD, \
118 struct nvm_ioctl_info)
119 #define NVM_GET_DEVICES _IOR(NVM_IOCTL, NVM_GET_DEVICES_CMD, \
120 struct nvm_ioctl_get_devices)
121 #define NVM_DEV_CREATE _IOW(NVM_IOCTL, NVM_DEV_CREATE_CMD, \
122 struct nvm_ioctl_create)
123 #define NVM_DEV_REMOVE _IOW(NVM_IOCTL, NVM_DEV_REMOVE_CMD, \
124 struct nvm_ioctl_remove)
126 #define NVM_VERSION_MAJOR 1
127 #define NVM_VERSION_MINOR 0
128 #define NVM_VERSION_PATCHLEVEL 0