• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __NDCTL_H__
20 #define __NDCTL_H__
21 #include <linux/types.h>
22 struct nd_cmd_smart {
23   __u32 status;
24   __u8 data[128];
25 } __packed;
26 #define ND_SMART_HEALTH_VALID (1 << 0)
27 #define ND_SMART_SPARES_VALID (1 << 1)
28 #define ND_SMART_USED_VALID (1 << 2)
29 #define ND_SMART_TEMP_VALID (1 << 3)
30 #define ND_SMART_CTEMP_VALID (1 << 4)
31 #define ND_SMART_ALARM_VALID (1 << 9)
32 #define ND_SMART_SHUTDOWN_VALID (1 << 10)
33 #define ND_SMART_VENDOR_VALID (1 << 11)
34 #define ND_SMART_SPARE_TRIP (1 << 0)
35 #define ND_SMART_TEMP_TRIP (1 << 1)
36 #define ND_SMART_CTEMP_TRIP (1 << 2)
37 #define ND_SMART_NON_CRITICAL_HEALTH (1 << 0)
38 #define ND_SMART_CRITICAL_HEALTH (1 << 1)
39 #define ND_SMART_FATAL_HEALTH (1 << 2)
40 struct nd_smart_payload {
41   __u32 flags;
42   __u8 reserved0[4];
43   __u8 health;
44   __u8 spares;
45   __u8 life_used;
46   __u8 alarm_flags;
47   __u16 temperature;
48   __u16 ctrl_temperature;
49   __u8 reserved1[15];
50   __u8 shutdown_state;
51   __u32 vendor_size;
52   __u8 vendor_data[92];
53 } __packed;
54 struct nd_cmd_smart_threshold {
55   __u32 status;
56   __u8 data[8];
57 } __packed;
58 struct nd_smart_threshold_payload {
59   __u8 alarm_control;
60   __u8 reserved0;
61   __u16 temperature;
62   __u8 spares;
63   __u8 reserved[3];
64 } __packed;
65 struct nd_cmd_dimm_flags {
66   __u32 status;
67   __u32 flags;
68 } __packed;
69 struct nd_cmd_get_config_size {
70   __u32 status;
71   __u32 config_size;
72   __u32 max_xfer;
73 } __packed;
74 struct nd_cmd_get_config_data_hdr {
75   __u32 in_offset;
76   __u32 in_length;
77   __u32 status;
78   __u8 out_buf[0];
79 } __packed;
80 struct nd_cmd_set_config_hdr {
81   __u32 in_offset;
82   __u32 in_length;
83   __u8 in_buf[0];
84 } __packed;
85 struct nd_cmd_vendor_hdr {
86   __u32 opcode;
87   __u32 in_length;
88   __u8 in_buf[0];
89 } __packed;
90 struct nd_cmd_vendor_tail {
91   __u32 status;
92   __u32 out_length;
93   __u8 out_buf[0];
94 } __packed;
95 struct nd_cmd_ars_cap {
96   __u64 address;
97   __u64 length;
98   __u32 status;
99   __u32 max_ars_out;
100   __u32 clear_err_unit;
101   __u16 flags;
102   __u16 reserved;
103 } __packed;
104 struct nd_cmd_ars_start {
105   __u64 address;
106   __u64 length;
107   __u16 type;
108   __u8 flags;
109   __u8 reserved[5];
110   __u32 status;
111   __u32 scrub_time;
112 } __packed;
113 struct nd_cmd_ars_status {
114   __u32 status;
115   __u32 out_length;
116   __u64 address;
117   __u64 length;
118   __u64 restart_address;
119   __u64 restart_length;
120   __u16 type;
121   __u16 flags;
122   __u32 num_records;
123   struct nd_ars_record {
124     __u32 handle;
125     __u32 reserved;
126     __u64 err_address;
127     __u64 length;
128   } __packed records[0];
129 } __packed;
130 struct nd_cmd_clear_error {
131   __u64 address;
132   __u64 length;
133   __u32 status;
134   __u8 reserved[4];
135   __u64 cleared;
136 } __packed;
137 enum {
138   ND_CMD_IMPLEMENTED = 0,
139   ND_CMD_ARS_CAP = 1,
140   ND_CMD_ARS_START = 2,
141   ND_CMD_ARS_STATUS = 3,
142   ND_CMD_CLEAR_ERROR = 4,
143   ND_CMD_SMART = 1,
144   ND_CMD_SMART_THRESHOLD = 2,
145   ND_CMD_DIMM_FLAGS = 3,
146   ND_CMD_GET_CONFIG_SIZE = 4,
147   ND_CMD_GET_CONFIG_DATA = 5,
148   ND_CMD_SET_CONFIG_DATA = 6,
149   ND_CMD_VENDOR_EFFECT_LOG_SIZE = 7,
150   ND_CMD_VENDOR_EFFECT_LOG = 8,
151   ND_CMD_VENDOR = 9,
152   ND_CMD_CALL = 10,
153 };
154 enum {
155   ND_ARS_VOLATILE = 1,
156   ND_ARS_PERSISTENT = 2,
157   ND_ARS_RETURN_PREV_DATA = 1 << 1,
158   ND_CONFIG_LOCKED = 1,
159 };
160 #define ND_IOCTL 'N'
161 #define ND_IOCTL_SMART _IOWR(ND_IOCTL, ND_CMD_SMART, struct nd_cmd_smart)
162 #define ND_IOCTL_SMART_THRESHOLD _IOWR(ND_IOCTL, ND_CMD_SMART_THRESHOLD, struct nd_cmd_smart_threshold)
163 #define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS, struct nd_cmd_dimm_flags)
164 #define ND_IOCTL_GET_CONFIG_SIZE _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_SIZE, struct nd_cmd_get_config_size)
165 #define ND_IOCTL_GET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_DATA, struct nd_cmd_get_config_data_hdr)
166 #define ND_IOCTL_SET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_SET_CONFIG_DATA, struct nd_cmd_set_config_hdr)
167 #define ND_IOCTL_VENDOR _IOWR(ND_IOCTL, ND_CMD_VENDOR, struct nd_cmd_vendor_hdr)
168 #define ND_IOCTL_ARS_CAP _IOWR(ND_IOCTL, ND_CMD_ARS_CAP, struct nd_cmd_ars_cap)
169 #define ND_IOCTL_ARS_START _IOWR(ND_IOCTL, ND_CMD_ARS_START, struct nd_cmd_ars_start)
170 #define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL, ND_CMD_ARS_STATUS, struct nd_cmd_ars_status)
171 #define ND_IOCTL_CLEAR_ERROR _IOWR(ND_IOCTL, ND_CMD_CLEAR_ERROR, struct nd_cmd_clear_error)
172 #define ND_DEVICE_DIMM 1
173 #define ND_DEVICE_REGION_PMEM 2
174 #define ND_DEVICE_REGION_BLK 3
175 #define ND_DEVICE_NAMESPACE_IO 4
176 #define ND_DEVICE_NAMESPACE_PMEM 5
177 #define ND_DEVICE_NAMESPACE_BLK 6
178 #define ND_DEVICE_DAX_PMEM 7
179 enum nd_driver_flags {
180   ND_DRIVER_DIMM = 1 << ND_DEVICE_DIMM,
181   ND_DRIVER_REGION_PMEM = 1 << ND_DEVICE_REGION_PMEM,
182   ND_DRIVER_REGION_BLK = 1 << ND_DEVICE_REGION_BLK,
183   ND_DRIVER_NAMESPACE_IO = 1 << ND_DEVICE_NAMESPACE_IO,
184   ND_DRIVER_NAMESPACE_PMEM = 1 << ND_DEVICE_NAMESPACE_PMEM,
185   ND_DRIVER_NAMESPACE_BLK = 1 << ND_DEVICE_NAMESPACE_BLK,
186   ND_DRIVER_DAX_PMEM = 1 << ND_DEVICE_DAX_PMEM,
187 };
188 enum {
189   ND_MIN_NAMESPACE_SIZE = 0x00400000,
190 };
191 enum ars_masks {
192   ARS_STATUS_MASK = 0x0000FFFF,
193   ARS_EXT_STATUS_SHIFT = 16,
194 };
195 struct nd_cmd_pkg {
196   __u64 nd_family;
197   __u64 nd_command;
198   __u32 nd_size_in;
199   __u32 nd_size_out;
200   __u32 nd_reserved2[9];
201   __u32 nd_fw_size;
202   unsigned char nd_payload[];
203 };
204 #define NVDIMM_FAMILY_INTEL 0
205 #define NVDIMM_FAMILY_HPE1 1
206 #define NVDIMM_FAMILY_HPE2 2
207 #define NVDIMM_FAMILY_MSFT 3
208 #define ND_IOCTL_CALL _IOWR(ND_IOCTL, ND_CMD_CALL, struct nd_cmd_pkg)
209 #endif
210