]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/uapi/linux/lightnvm.h
Merge tag 'imx-fixes-4.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo...
[mirror_ubuntu-bionic-kernel.git] / include / uapi / linux / lightnvm.h
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
19 #ifndef _UAPI_LINUX_LIGHTNVM_H
20 #define _UAPI_LINUX_LIGHTNVM_H
21
22 #ifdef __KERNEL__
23 #include <linux/kernel.h>
24 #include <linux/ioctl.h>
25 #else /* __KERNEL__ */
26 #include <stdio.h>
27 #include <sys/ioctl.h>
28 #define DISK_NAME_LEN 32
29 #endif /* __KERNEL__ */
30
31 #include <linux/types.h>
32 #include <linux/ioctl.h>
33
34 #define NVM_TTYPE_NAME_MAX 48
35 #define NVM_TTYPE_MAX 63
36
37 #define NVM_CTRL_FILE "/dev/lightnvm/control"
38
39 struct nvm_ioctl_info_tgt {
40 __u32 version[3];
41 __u32 reserved;
42 char tgtname[NVM_TTYPE_NAME_MAX];
43 };
44
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 */
49 __u32 reserved[12];
50 struct nvm_ioctl_info_tgt tgts[NVM_TTYPE_MAX];
51 };
52
53 enum {
54 NVM_DEVICE_ACTIVE = 1 << 0,
55 };
56
57 struct nvm_ioctl_device_info {
58 char devname[DISK_NAME_LEN];
59 char bmname[NVM_TTYPE_NAME_MAX];
60 __u32 bmversion[3];
61 __u32 flags;
62 __u32 reserved[8];
63 };
64
65 struct nvm_ioctl_get_devices {
66 __u32 nr_devices;
67 __u32 reserved[31];
68 struct nvm_ioctl_device_info info[31];
69 };
70
71 struct nvm_ioctl_create_simple {
72 __u32 lun_begin;
73 __u32 lun_end;
74 };
75
76 enum {
77 NVM_CONFIG_TYPE_SIMPLE = 0,
78 };
79
80 struct nvm_ioctl_create_conf {
81 __u32 type;
82 union {
83 struct nvm_ioctl_create_simple s;
84 };
85 };
86
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 */
91
92 __u32 flags;
93
94 struct nvm_ioctl_create_conf conf;
95 };
96
97 struct nvm_ioctl_remove {
98 char tgtname[DISK_NAME_LEN];
99
100 __u32 flags;
101 };
102
103
104 /* The ioctl type, 'L', 0x20 - 0x2F documented in ioctl-number.txt */
105 enum {
106 /* top level cmds */
107 NVM_INFO_CMD = 0x20,
108 NVM_GET_DEVICES_CMD,
109
110 /* device level cmds */
111 NVM_DEV_CREATE_CMD,
112 NVM_DEV_REMOVE_CMD,
113 };
114
115 #define NVM_IOCTL 'L' /* 0x4c */
116
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)
125
126 #define NVM_VERSION_MAJOR 1
127 #define NVM_VERSION_MINOR 0
128 #define NVM_VERSION_PATCHLEVEL 0
129
130 #endif