| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 1 | /**************************************************************************** | 
|  | 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 Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 23 | #define DISK_NAME_LEN 32 | 
|  | 24 | #include <linux/types.h> | 
|  | 25 | #include <linux/ioctl.h> | 
|  | 26 | #define NVM_TTYPE_NAME_MAX 48 | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 27 | #define NVM_TTYPE_MAX 63 | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 28 | #define NVM_MMTYPE_LEN 8 | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 29 | #define NVM_CTRL_FILE "/dev/lightnvm/control" | 
|  | 30 | struct nvm_ioctl_info_tgt { | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 31 | __u32 version[3]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 32 | __u32 reserved; | 
|  | 33 | char tgtname[NVM_TTYPE_NAME_MAX]; | 
|  | 34 | }; | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 35 | struct nvm_ioctl_info { | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 36 | __u32 version[3]; | 
|  | 37 | __u16 tgtsize; | 
|  | 38 | __u16 reserved16; | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 39 | __u32 reserved[12]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 40 | struct nvm_ioctl_info_tgt tgts[NVM_TTYPE_MAX]; | 
|  | 41 | }; | 
|  | 42 | enum { | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 43 | NVM_DEVICE_ACTIVE = 1 << 0, | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 44 | }; | 
|  | 45 | struct nvm_ioctl_device_info { | 
|  | 46 | char devname[DISK_NAME_LEN]; | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 47 | char bmname[NVM_TTYPE_NAME_MAX]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 48 | __u32 bmversion[3]; | 
|  | 49 | __u32 flags; | 
|  | 50 | __u32 reserved[8]; | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 51 | }; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 52 | struct nvm_ioctl_get_devices { | 
|  | 53 | __u32 nr_devices; | 
|  | 54 | __u32 reserved[31]; | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 55 | struct nvm_ioctl_device_info info[31]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 56 | }; | 
|  | 57 | struct nvm_ioctl_create_simple { | 
|  | 58 | __u32 lun_begin; | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 59 | __u32 lun_end; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 60 | }; | 
|  | 61 | enum { | 
|  | 62 | NVM_CONFIG_TYPE_SIMPLE = 0, | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 63 | }; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 64 | struct nvm_ioctl_create_conf { | 
|  | 65 | __u32 type; | 
|  | 66 | union { | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 67 | struct nvm_ioctl_create_simple s; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 68 | }; | 
|  | 69 | }; | 
| Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 70 | enum { | 
|  | 71 | NVM_TARGET_FACTORY = 1 << 0, | 
|  | 72 | }; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 73 | struct nvm_ioctl_create { | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 74 | char dev[DISK_NAME_LEN]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 75 | char tgttype[NVM_TTYPE_NAME_MAX]; | 
|  | 76 | char tgtname[DISK_NAME_LEN]; | 
|  | 77 | __u32 flags; | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 78 | struct nvm_ioctl_create_conf conf; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 79 | }; | 
|  | 80 | struct nvm_ioctl_remove { | 
|  | 81 | char tgtname[DISK_NAME_LEN]; | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 82 | __u32 flags; | 
|  | 83 | }; | 
|  | 84 | struct nvm_ioctl_dev_init { | 
|  | 85 | char dev[DISK_NAME_LEN]; | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 86 | char mmtype[NVM_MMTYPE_LEN]; | 
|  | 87 | __u32 flags; | 
|  | 88 | }; | 
|  | 89 | enum { | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 90 | NVM_FACTORY_ERASE_ONLY_USER = 1 << 0, | 
|  | 91 | NVM_FACTORY_RESET_HOST_BLKS = 1 << 1, | 
|  | 92 | NVM_FACTORY_RESET_GRWN_BBLKS = 1 << 2, | 
|  | 93 | NVM_FACTORY_NR_BITS = 1 << 3, | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 94 | }; | 
|  | 95 | struct nvm_ioctl_dev_factory { | 
|  | 96 | char dev[DISK_NAME_LEN]; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 97 | __u32 flags; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 98 | }; | 
| Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 99 | struct nvm_user_vio { | 
|  | 100 | __u8 opcode; | 
|  | 101 | __u8 flags; | 
|  | 102 | __u16 control; | 
|  | 103 | __u16 nppas; | 
|  | 104 | __u16 rsvd; | 
|  | 105 | __u64 metadata; | 
|  | 106 | __u64 addr; | 
|  | 107 | __u64 ppa_list; | 
|  | 108 | __u32 metadata_len; | 
|  | 109 | __u32 data_len; | 
|  | 110 | __u64 status; | 
|  | 111 | __u32 result; | 
|  | 112 | __u32 rsvd3[3]; | 
|  | 113 | }; | 
|  | 114 | struct nvm_passthru_vio { | 
|  | 115 | __u8 opcode; | 
|  | 116 | __u8 flags; | 
|  | 117 | __u8 rsvd[2]; | 
|  | 118 | __u32 nsid; | 
|  | 119 | __u32 cdw2; | 
|  | 120 | __u32 cdw3; | 
|  | 121 | __u64 metadata; | 
|  | 122 | __u64 addr; | 
|  | 123 | __u32 metadata_len; | 
|  | 124 | __u32 data_len; | 
|  | 125 | __u64 ppa_list; | 
|  | 126 | __u16 nppas; | 
|  | 127 | __u16 control; | 
|  | 128 | __u32 cdw13; | 
|  | 129 | __u32 cdw14; | 
|  | 130 | __u32 cdw15; | 
|  | 131 | __u64 status; | 
|  | 132 | __u32 result; | 
|  | 133 | __u32 timeout_ms; | 
|  | 134 | }; | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 135 | enum { | 
|  | 136 | NVM_INFO_CMD = 0x20, | 
|  | 137 | NVM_GET_DEVICES_CMD, | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 138 | NVM_DEV_CREATE_CMD, | 
|  | 139 | NVM_DEV_REMOVE_CMD, | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 140 | NVM_DEV_INIT_CMD, | 
|  | 141 | NVM_DEV_FACTORY_CMD, | 
| Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 142 | NVM_DEV_VIO_ADMIN_CMD = 0x41, | 
|  | 143 | NVM_DEV_VIO_CMD = 0x42, | 
|  | 144 | NVM_DEV_VIO_USER_CMD = 0x43, | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 145 | }; | 
|  | 146 | #define NVM_IOCTL 'L' | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 147 | #define NVM_INFO _IOWR(NVM_IOCTL, NVM_INFO_CMD, struct nvm_ioctl_info) | 
|  | 148 | #define NVM_GET_DEVICES _IOR(NVM_IOCTL, NVM_GET_DEVICES_CMD, struct nvm_ioctl_get_devices) | 
|  | 149 | #define NVM_DEV_CREATE _IOW(NVM_IOCTL, NVM_DEV_CREATE_CMD, struct nvm_ioctl_create) | 
|  | 150 | #define NVM_DEV_REMOVE _IOW(NVM_IOCTL, NVM_DEV_REMOVE_CMD, struct nvm_ioctl_remove) | 
| Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 151 | #define NVM_DEV_INIT _IOW(NVM_IOCTL, NVM_DEV_INIT_CMD, struct nvm_ioctl_dev_init) | 
|  | 152 | #define NVM_DEV_FACTORY _IOW(NVM_IOCTL, NVM_DEV_FACTORY_CMD, struct nvm_ioctl_dev_factory) | 
| Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 153 | #define NVME_NVM_IOCTL_IO_VIO _IOWR(NVM_IOCTL, NVM_DEV_VIO_USER_CMD, struct nvm_passthru_vio) | 
|  | 154 | #define NVME_NVM_IOCTL_ADMIN_VIO _IOWR(NVM_IOCTL, NVM_DEV_VIO_ADMIN_CMD, struct nvm_passthru_vio) | 
|  | 155 | #define NVME_NVM_IOCTL_SUBMIT_VIO _IOWR(NVM_IOCTL, NVM_DEV_VIO_CMD, struct nvm_user_vio) | 
| Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 156 | #define NVM_VERSION_MAJOR 1 | 
|  | 157 | #define NVM_VERSION_MINOR 0 | 
|  | 158 | #define NVM_VERSION_PATCHLEVEL 0 | 
|  | 159 | #endif |