blob: b3ac31738214d312a75a25c15b761a34b0da0fa3 [file] [log] [blame]
Christopher Ferris05d08e92016-02-04 13:16:38 -08001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _UAPI_LINUX_LIGHTNVM_H
20#define _UAPI_LINUX_LIGHTNVM_H
21#include <stdio.h>
22#include <sys/ioctl.h>
Christopher Ferris05d08e92016-02-04 13:16:38 -080023#define DISK_NAME_LEN 32
24#include <linux/types.h>
25#include <linux/ioctl.h>
26#define NVM_TTYPE_NAME_MAX 48
Christopher Ferris05d08e92016-02-04 13:16:38 -080027#define NVM_TTYPE_MAX 63
Christopher Ferris106b3a82016-08-24 12:15:38 -070028#define NVM_MMTYPE_LEN 8
Christopher Ferris05d08e92016-02-04 13:16:38 -080029#define NVM_CTRL_FILE "/dev/lightnvm/control"
30struct nvm_ioctl_info_tgt {
Christopher Ferris106b3a82016-08-24 12:15:38 -070031 __u32 version[3];
Christopher Ferris05d08e92016-02-04 13:16:38 -080032 __u32 reserved;
33 char tgtname[NVM_TTYPE_NAME_MAX];
34};
Christopher Ferris106b3a82016-08-24 12:15:38 -070035struct nvm_ioctl_info {
Christopher Ferris05d08e92016-02-04 13:16:38 -080036 __u32 version[3];
37 __u16 tgtsize;
38 __u16 reserved16;
Christopher Ferris106b3a82016-08-24 12:15:38 -070039 __u32 reserved[12];
Christopher Ferris05d08e92016-02-04 13:16:38 -080040 struct nvm_ioctl_info_tgt tgts[NVM_TTYPE_MAX];
41};
42enum {
Christopher Ferris106b3a82016-08-24 12:15:38 -070043 NVM_DEVICE_ACTIVE = 1 << 0,
Christopher Ferris05d08e92016-02-04 13:16:38 -080044};
45struct nvm_ioctl_device_info {
46 char devname[DISK_NAME_LEN];
Christopher Ferris106b3a82016-08-24 12:15:38 -070047 char bmname[NVM_TTYPE_NAME_MAX];
Christopher Ferris05d08e92016-02-04 13:16:38 -080048 __u32 bmversion[3];
49 __u32 flags;
50 __u32 reserved[8];
Christopher Ferris106b3a82016-08-24 12:15:38 -070051};
Christopher Ferris05d08e92016-02-04 13:16:38 -080052struct nvm_ioctl_get_devices {
53 __u32 nr_devices;
54 __u32 reserved[31];
Christopher Ferris106b3a82016-08-24 12:15:38 -070055 struct nvm_ioctl_device_info info[31];
Christopher Ferris05d08e92016-02-04 13:16:38 -080056};
57struct nvm_ioctl_create_simple {
58 __u32 lun_begin;
Christopher Ferris106b3a82016-08-24 12:15:38 -070059 __u32 lun_end;
Christopher Ferris05d08e92016-02-04 13:16:38 -080060};
Christopher Ferris76a1d452018-06-27 14:12:29 -070061struct nvm_ioctl_create_extended {
62 __u16 lun_begin;
63 __u16 lun_end;
64 __u16 op;
65 __u16 rsv;
66};
Christopher Ferris05d08e92016-02-04 13:16:38 -080067enum {
68 NVM_CONFIG_TYPE_SIMPLE = 0,
Christopher Ferris76a1d452018-06-27 14:12:29 -070069 NVM_CONFIG_TYPE_EXTENDED = 1,
Christopher Ferris106b3a82016-08-24 12:15:38 -070070};
Christopher Ferris05d08e92016-02-04 13:16:38 -080071struct nvm_ioctl_create_conf {
72 __u32 type;
73 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -070074 struct nvm_ioctl_create_simple s;
Christopher Ferris76a1d452018-06-27 14:12:29 -070075 struct nvm_ioctl_create_extended e;
Christopher Ferris05d08e92016-02-04 13:16:38 -080076 };
77};
Christopher Ferris525ce912017-07-26 13:12:53 -070078enum {
79 NVM_TARGET_FACTORY = 1 << 0,
80};
Christopher Ferris05d08e92016-02-04 13:16:38 -080081struct nvm_ioctl_create {
Christopher Ferris106b3a82016-08-24 12:15:38 -070082 char dev[DISK_NAME_LEN];
Christopher Ferris05d08e92016-02-04 13:16:38 -080083 char tgttype[NVM_TTYPE_NAME_MAX];
84 char tgtname[DISK_NAME_LEN];
85 __u32 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -070086 struct nvm_ioctl_create_conf conf;
Christopher Ferris05d08e92016-02-04 13:16:38 -080087};
88struct nvm_ioctl_remove {
89 char tgtname[DISK_NAME_LEN];
Christopher Ferris106b3a82016-08-24 12:15:38 -070090 __u32 flags;
91};
92struct nvm_ioctl_dev_init {
93 char dev[DISK_NAME_LEN];
Christopher Ferris106b3a82016-08-24 12:15:38 -070094 char mmtype[NVM_MMTYPE_LEN];
95 __u32 flags;
96};
97enum {
Christopher Ferris106b3a82016-08-24 12:15:38 -070098 NVM_FACTORY_ERASE_ONLY_USER = 1 << 0,
99 NVM_FACTORY_RESET_HOST_BLKS = 1 << 1,
100 NVM_FACTORY_RESET_GRWN_BBLKS = 1 << 2,
101 NVM_FACTORY_NR_BITS = 1 << 3,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700102};
103struct nvm_ioctl_dev_factory {
104 char dev[DISK_NAME_LEN];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800105 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800106};
Christopher Ferris525ce912017-07-26 13:12:53 -0700107struct nvm_user_vio {
108 __u8 opcode;
109 __u8 flags;
110 __u16 control;
111 __u16 nppas;
112 __u16 rsvd;
113 __u64 metadata;
114 __u64 addr;
115 __u64 ppa_list;
116 __u32 metadata_len;
117 __u32 data_len;
118 __u64 status;
119 __u32 result;
120 __u32 rsvd3[3];
121};
122struct nvm_passthru_vio {
123 __u8 opcode;
124 __u8 flags;
125 __u8 rsvd[2];
126 __u32 nsid;
127 __u32 cdw2;
128 __u32 cdw3;
129 __u64 metadata;
130 __u64 addr;
131 __u32 metadata_len;
132 __u32 data_len;
133 __u64 ppa_list;
134 __u16 nppas;
135 __u16 control;
136 __u32 cdw13;
137 __u32 cdw14;
138 __u32 cdw15;
139 __u64 status;
140 __u32 result;
141 __u32 timeout_ms;
142};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800143enum {
144 NVM_INFO_CMD = 0x20,
145 NVM_GET_DEVICES_CMD,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800146 NVM_DEV_CREATE_CMD,
147 NVM_DEV_REMOVE_CMD,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700148 NVM_DEV_INIT_CMD,
149 NVM_DEV_FACTORY_CMD,
Christopher Ferris525ce912017-07-26 13:12:53 -0700150 NVM_DEV_VIO_ADMIN_CMD = 0x41,
151 NVM_DEV_VIO_CMD = 0x42,
152 NVM_DEV_VIO_USER_CMD = 0x43,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800153};
154#define NVM_IOCTL 'L'
Christopher Ferris05d08e92016-02-04 13:16:38 -0800155#define NVM_INFO _IOWR(NVM_IOCTL, NVM_INFO_CMD, struct nvm_ioctl_info)
156#define NVM_GET_DEVICES _IOR(NVM_IOCTL, NVM_GET_DEVICES_CMD, struct nvm_ioctl_get_devices)
157#define NVM_DEV_CREATE _IOW(NVM_IOCTL, NVM_DEV_CREATE_CMD, struct nvm_ioctl_create)
158#define NVM_DEV_REMOVE _IOW(NVM_IOCTL, NVM_DEV_REMOVE_CMD, struct nvm_ioctl_remove)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700159#define NVM_DEV_INIT _IOW(NVM_IOCTL, NVM_DEV_INIT_CMD, struct nvm_ioctl_dev_init)
160#define NVM_DEV_FACTORY _IOW(NVM_IOCTL, NVM_DEV_FACTORY_CMD, struct nvm_ioctl_dev_factory)
Christopher Ferris525ce912017-07-26 13:12:53 -0700161#define NVME_NVM_IOCTL_IO_VIO _IOWR(NVM_IOCTL, NVM_DEV_VIO_USER_CMD, struct nvm_passthru_vio)
162#define NVME_NVM_IOCTL_ADMIN_VIO _IOWR(NVM_IOCTL, NVM_DEV_VIO_ADMIN_CMD, struct nvm_passthru_vio)
163#define NVME_NVM_IOCTL_SUBMIT_VIO _IOWR(NVM_IOCTL, NVM_DEV_VIO_CMD, struct nvm_user_vio)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800164#define NVM_VERSION_MAJOR 1
165#define NVM_VERSION_MINOR 0
166#define NVM_VERSION_PATCHLEVEL 0
167#endif