2 * Copyright (c) 2014-2016, Intel Corporation.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU Lesser General Public License,
6 * version 2.1, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT ANY
9 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16 #include <linux/types.h>
23 #define ND_SMART_HEALTH_VALID (1 << 0)
24 #define ND_SMART_SPARES_VALID (1 << 1)
25 #define ND_SMART_USED_VALID (1 << 2)
26 #define ND_SMART_TEMP_VALID (1 << 3)
27 #define ND_SMART_CTEMP_VALID (1 << 4)
28 #define ND_SMART_ALARM_VALID (1 << 9)
29 #define ND_SMART_SHUTDOWN_VALID (1 << 10)
30 #define ND_SMART_VENDOR_VALID (1 << 11)
31 #define ND_SMART_SPARE_TRIP (1 << 0)
32 #define ND_SMART_TEMP_TRIP (1 << 1)
33 #define ND_SMART_CTEMP_TRIP (1 << 2)
34 #define ND_SMART_NON_CRITICAL_HEALTH (1 << 0)
35 #define ND_SMART_CRITICAL_HEALTH (1 << 1)
36 #define ND_SMART_FATAL_HEALTH (1 << 2)
38 struct nd_smart_payload {
46 __u16 ctrl_temperature;
53 struct nd_cmd_smart_threshold {
58 struct nd_smart_threshold_payload {
66 struct nd_cmd_dimm_flags {
71 struct nd_cmd_get_config_size {
77 struct nd_cmd_get_config_data_hdr {
84 struct nd_cmd_set_config_hdr {
90 struct nd_cmd_vendor_hdr {
96 struct nd_cmd_vendor_tail {
102 struct nd_cmd_ars_cap {
107 __u32 clear_err_unit;
112 struct nd_cmd_ars_start {
122 struct nd_cmd_ars_status {
127 __u64 restart_address;
128 __u64 restart_length;
132 struct nd_ars_record {
137 } __packed records[0];
140 struct nd_cmd_clear_error {
149 ND_CMD_IMPLEMENTED = 0,
153 ND_CMD_ARS_START = 2,
154 ND_CMD_ARS_STATUS = 3,
155 ND_CMD_CLEAR_ERROR = 4,
157 /* per-dimm commands */
159 ND_CMD_SMART_THRESHOLD = 2,
160 ND_CMD_DIMM_FLAGS = 3,
161 ND_CMD_GET_CONFIG_SIZE = 4,
162 ND_CMD_GET_CONFIG_DATA = 5,
163 ND_CMD_SET_CONFIG_DATA = 6,
164 ND_CMD_VENDOR_EFFECT_LOG_SIZE = 7,
165 ND_CMD_VENDOR_EFFECT_LOG = 8,
172 ND_ARS_PERSISTENT = 2,
173 ND_ARS_RETURN_PREV_DATA = 1 << 1,
174 ND_CONFIG_LOCKED = 1,
177 static inline const char *nvdimm_bus_cmd_name(unsigned cmd)
180 case ND_CMD_ARS_CAP: return "ars_cap";
181 case ND_CMD_ARS_START: return "ars_start";
182 case ND_CMD_ARS_STATUS: return "ars_status";
183 case ND_CMD_CLEAR_ERROR: return "clear_error";
184 case ND_CMD_CALL: return "cmd_call";
185 default: return "unknown";
189 static inline const char *nvdimm_cmd_name(unsigned cmd)
192 case ND_CMD_SMART: return "smart";
193 case ND_CMD_SMART_THRESHOLD: return "smart_thresh";
194 case ND_CMD_DIMM_FLAGS: return "flags";
195 case ND_CMD_GET_CONFIG_SIZE: return "get_size";
196 case ND_CMD_GET_CONFIG_DATA: return "get_data";
197 case ND_CMD_SET_CONFIG_DATA: return "set_data";
198 case ND_CMD_VENDOR_EFFECT_LOG_SIZE: return "effect_size";
199 case ND_CMD_VENDOR_EFFECT_LOG: return "effect_log";
200 case ND_CMD_VENDOR: return "vendor";
201 case ND_CMD_CALL: return "cmd_call";
202 default: return "unknown";
208 #define ND_IOCTL_SMART _IOWR(ND_IOCTL, ND_CMD_SMART,\
211 #define ND_IOCTL_SMART_THRESHOLD _IOWR(ND_IOCTL, ND_CMD_SMART_THRESHOLD,\
212 struct nd_cmd_smart_threshold)
214 #define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS,\
215 struct nd_cmd_dimm_flags)
217 #define ND_IOCTL_GET_CONFIG_SIZE _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_SIZE,\
218 struct nd_cmd_get_config_size)
220 #define ND_IOCTL_GET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_DATA,\
221 struct nd_cmd_get_config_data_hdr)
223 #define ND_IOCTL_SET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_SET_CONFIG_DATA,\
224 struct nd_cmd_set_config_hdr)
226 #define ND_IOCTL_VENDOR _IOWR(ND_IOCTL, ND_CMD_VENDOR,\
227 struct nd_cmd_vendor_hdr)
229 #define ND_IOCTL_ARS_CAP _IOWR(ND_IOCTL, ND_CMD_ARS_CAP,\
230 struct nd_cmd_ars_cap)
232 #define ND_IOCTL_ARS_START _IOWR(ND_IOCTL, ND_CMD_ARS_START,\
233 struct nd_cmd_ars_start)
235 #define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL, ND_CMD_ARS_STATUS,\
236 struct nd_cmd_ars_status)
238 #define ND_IOCTL_CLEAR_ERROR _IOWR(ND_IOCTL, ND_CMD_CLEAR_ERROR,\
239 struct nd_cmd_clear_error)
241 #define ND_DEVICE_DIMM 1 /* nd_dimm: container for "config data" */
242 #define ND_DEVICE_REGION_PMEM 2 /* nd_region: (parent of PMEM namespaces) */
243 #define ND_DEVICE_REGION_BLK 3 /* nd_region: (parent of BLK namespaces) */
244 #define ND_DEVICE_NAMESPACE_IO 4 /* legacy persistent memory */
245 #define ND_DEVICE_NAMESPACE_PMEM 5 /* PMEM namespace (may alias with BLK) */
246 #define ND_DEVICE_NAMESPACE_BLK 6 /* BLK namespace (may alias with PMEM) */
247 #define ND_DEVICE_DAX_PMEM 7 /* Device DAX interface to pmem */
249 enum nd_driver_flags {
250 ND_DRIVER_DIMM = 1 << ND_DEVICE_DIMM,
251 ND_DRIVER_REGION_PMEM = 1 << ND_DEVICE_REGION_PMEM,
252 ND_DRIVER_REGION_BLK = 1 << ND_DEVICE_REGION_BLK,
253 ND_DRIVER_NAMESPACE_IO = 1 << ND_DEVICE_NAMESPACE_IO,
254 ND_DRIVER_NAMESPACE_PMEM = 1 << ND_DEVICE_NAMESPACE_PMEM,
255 ND_DRIVER_NAMESPACE_BLK = 1 << ND_DEVICE_NAMESPACE_BLK,
256 ND_DRIVER_DAX_PMEM = 1 << ND_DEVICE_DAX_PMEM,
260 ND_MIN_NAMESPACE_SIZE = 0x00400000,
264 ARS_STATUS_MASK = 0x0000FFFF,
265 ARS_EXT_STATUS_SHIFT = 16,
271 * is a wrapper to a quasi pass thru interface for invoking firmware
272 * associated with nvdimms.
276 * nd_family corresponds to the firmware (e.g. DSM) interface.
278 * nd_command are the function index advertised by the firmware.
280 * nd_size_in is the size of the input parameters being passed to firmware
284 * nd_fw_size is the size of the data firmware wants to return for
285 * the call. If nd_fw_size is greater than size of nd_size_out, only
286 * the first nd_size_out bytes are returned.
290 __u64 nd_family; /* family of commands */
292 __u32 nd_size_in; /* INPUT: size of input args */
293 __u32 nd_size_out; /* INPUT: size of payload */
294 __u32 nd_reserved2[9]; /* reserved must be zero */
295 __u32 nd_fw_size; /* OUTPUT: size fw wants to return */
296 unsigned char nd_payload[]; /* Contents of call */
299 /* These NVDIMM families represent pre-standardization command sets */
300 #define NVDIMM_FAMILY_INTEL 0
301 #define NVDIMM_FAMILY_HPE1 1
302 #define NVDIMM_FAMILY_HPE2 2
303 #define NVDIMM_FAMILY_MSFT 3
305 #define ND_IOCTL_CALL _IOWR(ND_IOCTL, ND_CMD_CALL,\
308 #endif /* __NDCTL_H__ */