• 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   __u32 reserved;
102 } __packed;
103 struct nd_cmd_ars_start {
104   __u64 address;
105   __u64 length;
106   __u16 type;
107   __u8 flags;
108   __u8 reserved[5];
109   __u32 status;
110   __u32 scrub_time;
111 } __packed;
112 struct nd_cmd_ars_status {
113   __u32 status;
114   __u32 out_length;
115   __u64 address;
116   __u64 length;
117   __u64 restart_address;
118   __u64 restart_length;
119   __u16 type;
120   __u16 flags;
121   __u32 num_records;
122   struct nd_ars_record {
123     __u32 handle;
124     __u32 reserved;
125     __u64 err_address;
126     __u64 length;
127   } __packed records[0];
128 } __packed;
129 struct nd_cmd_clear_error {
130   __u64 address;
131   __u64 length;
132   __u32 status;
133   __u8 reserved[4];
134   __u64 cleared;
135 } __packed;
136 enum {
137   ND_CMD_IMPLEMENTED = 0,
138   ND_CMD_ARS_CAP = 1,
139   ND_CMD_ARS_START = 2,
140   ND_CMD_ARS_STATUS = 3,
141   ND_CMD_CLEAR_ERROR = 4,
142   ND_CMD_SMART = 1,
143   ND_CMD_SMART_THRESHOLD = 2,
144   ND_CMD_DIMM_FLAGS = 3,
145   ND_CMD_GET_CONFIG_SIZE = 4,
146   ND_CMD_GET_CONFIG_DATA = 5,
147   ND_CMD_SET_CONFIG_DATA = 6,
148   ND_CMD_VENDOR_EFFECT_LOG_SIZE = 7,
149   ND_CMD_VENDOR_EFFECT_LOG = 8,
150   ND_CMD_VENDOR = 9,
151   ND_CMD_CALL = 10,
152 };
153 enum {
154   ND_ARS_VOLATILE = 1,
155   ND_ARS_PERSISTENT = 2,
156 };
157 #define ND_IOCTL 'N'
158 #define ND_IOCTL_SMART _IOWR(ND_IOCTL, ND_CMD_SMART, struct nd_cmd_smart)
159 #define ND_IOCTL_SMART_THRESHOLD _IOWR(ND_IOCTL, ND_CMD_SMART_THRESHOLD, struct nd_cmd_smart_threshold)
160 #define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS, struct nd_cmd_dimm_flags)
161 #define ND_IOCTL_GET_CONFIG_SIZE _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_SIZE, struct nd_cmd_get_config_size)
162 #define ND_IOCTL_GET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_DATA, struct nd_cmd_get_config_data_hdr)
163 #define ND_IOCTL_SET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_SET_CONFIG_DATA, struct nd_cmd_set_config_hdr)
164 #define ND_IOCTL_VENDOR _IOWR(ND_IOCTL, ND_CMD_VENDOR, struct nd_cmd_vendor_hdr)
165 #define ND_IOCTL_ARS_CAP _IOWR(ND_IOCTL, ND_CMD_ARS_CAP, struct nd_cmd_ars_cap)
166 #define ND_IOCTL_ARS_START _IOWR(ND_IOCTL, ND_CMD_ARS_START, struct nd_cmd_ars_start)
167 #define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL, ND_CMD_ARS_STATUS, struct nd_cmd_ars_status)
168 #define ND_IOCTL_CLEAR_ERROR _IOWR(ND_IOCTL, ND_CMD_CLEAR_ERROR, struct nd_cmd_clear_error)
169 #define ND_DEVICE_DIMM 1
170 #define ND_DEVICE_REGION_PMEM 2
171 #define ND_DEVICE_REGION_BLK 3
172 #define ND_DEVICE_NAMESPACE_IO 4
173 #define ND_DEVICE_NAMESPACE_PMEM 5
174 #define ND_DEVICE_NAMESPACE_BLK 6
175 #define ND_DEVICE_DAX_PMEM 7
176 enum nd_driver_flags {
177   ND_DRIVER_DIMM = 1 << ND_DEVICE_DIMM,
178   ND_DRIVER_REGION_PMEM = 1 << ND_DEVICE_REGION_PMEM,
179   ND_DRIVER_REGION_BLK = 1 << ND_DEVICE_REGION_BLK,
180   ND_DRIVER_NAMESPACE_IO = 1 << ND_DEVICE_NAMESPACE_IO,
181   ND_DRIVER_NAMESPACE_PMEM = 1 << ND_DEVICE_NAMESPACE_PMEM,
182   ND_DRIVER_NAMESPACE_BLK = 1 << ND_DEVICE_NAMESPACE_BLK,
183   ND_DRIVER_DAX_PMEM = 1 << ND_DEVICE_DAX_PMEM,
184 };
185 enum {
186   ND_MIN_NAMESPACE_SIZE = 0x00400000,
187 };
188 enum ars_masks {
189   ARS_STATUS_MASK = 0x0000FFFF,
190   ARS_EXT_STATUS_SHIFT = 16,
191 };
192 struct nd_cmd_pkg {
193   __u64 nd_family;
194   __u64 nd_command;
195   __u32 nd_size_in;
196   __u32 nd_size_out;
197   __u32 nd_reserved2[9];
198   __u32 nd_fw_size;
199   unsigned char nd_payload[];
200 };
201 #define NVDIMM_FAMILY_INTEL 0
202 #define NVDIMM_FAMILY_HPE1 1
203 #define NVDIMM_FAMILY_HPE2 2
204 #define NVDIMM_FAMILY_MSFT 3
205 #define ND_IOCTL_CALL _IOWR(ND_IOCTL, ND_CMD_CALL, struct nd_cmd_pkg)
206 #endif
207