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_TEMP_VALID (1 << 1)
25 #define ND_SMART_SPARES_VALID (1 << 2)
26 #define ND_SMART_ALARM_VALID (1 << 3)
27 #define ND_SMART_USED_VALID (1 << 4)
28 #define ND_SMART_SHUTDOWN_VALID (1 << 5)
29 #define ND_SMART_VENDOR_VALID (1 << 6)
30 #define ND_SMART_TEMP_TRIP (1 << 0)
31 #define ND_SMART_SPARE_TRIP (1 << 1)
32 #define ND_SMART_NON_CRITICAL_HEALTH (1 << 0)
33 #define ND_SMART_CRITICAL_HEALTH (1 << 1)
34 #define ND_SMART_FATAL_HEALTH (1 << 2)
36 struct nd_smart_payload
{
47 __u8 vendor_data
[108];
50 struct nd_cmd_smart_threshold
{
55 struct nd_smart_threshold_payload
{
62 struct nd_cmd_dimm_flags
{
67 struct nd_cmd_get_config_size
{
73 struct nd_cmd_get_config_data_hdr
{
80 struct nd_cmd_set_config_hdr
{
86 struct nd_cmd_vendor_hdr
{
92 struct nd_cmd_vendor_tail
{
98 struct nd_cmd_ars_cap
{
103 __u32 clear_err_unit
;
107 struct nd_cmd_ars_start
{
117 struct nd_cmd_ars_status
{
122 __u64 restart_address
;
123 __u64 restart_length
;
127 struct nd_ars_record
{
132 } __packed records
[0];
135 struct nd_cmd_clear_error
{
144 ND_CMD_IMPLEMENTED
= 0,
148 ND_CMD_ARS_START
= 2,
149 ND_CMD_ARS_STATUS
= 3,
150 ND_CMD_CLEAR_ERROR
= 4,
152 /* per-dimm commands */
154 ND_CMD_SMART_THRESHOLD
= 2,
155 ND_CMD_DIMM_FLAGS
= 3,
156 ND_CMD_GET_CONFIG_SIZE
= 4,
157 ND_CMD_GET_CONFIG_DATA
= 5,
158 ND_CMD_SET_CONFIG_DATA
= 6,
159 ND_CMD_VENDOR_EFFECT_LOG_SIZE
= 7,
160 ND_CMD_VENDOR_EFFECT_LOG
= 8,
167 ND_ARS_PERSISTENT
= 2,
170 static inline const char *nvdimm_bus_cmd_name(unsigned cmd
)
172 static const char * const names
[] = {
173 [ND_CMD_ARS_CAP
] = "ars_cap",
174 [ND_CMD_ARS_START
] = "ars_start",
175 [ND_CMD_ARS_STATUS
] = "ars_status",
176 [ND_CMD_CLEAR_ERROR
] = "clear_error",
179 if (cmd
< ARRAY_SIZE(names
) && names
[cmd
])
184 static inline const char *nvdimm_cmd_name(unsigned cmd
)
186 static const char * const names
[] = {
187 [ND_CMD_SMART
] = "smart",
188 [ND_CMD_SMART_THRESHOLD
] = "smart_thresh",
189 [ND_CMD_DIMM_FLAGS
] = "flags",
190 [ND_CMD_GET_CONFIG_SIZE
] = "get_size",
191 [ND_CMD_GET_CONFIG_DATA
] = "get_data",
192 [ND_CMD_SET_CONFIG_DATA
] = "set_data",
193 [ND_CMD_VENDOR_EFFECT_LOG_SIZE
] = "effect_size",
194 [ND_CMD_VENDOR_EFFECT_LOG
] = "effect_log",
195 [ND_CMD_VENDOR
] = "vendor",
196 [ND_CMD_CALL
] = "cmd_call",
199 if (cmd
< ARRAY_SIZE(names
) && names
[cmd
])
206 #define ND_IOCTL_SMART _IOWR(ND_IOCTL, ND_CMD_SMART,\
209 #define ND_IOCTL_SMART_THRESHOLD _IOWR(ND_IOCTL, ND_CMD_SMART_THRESHOLD,\
210 struct nd_cmd_smart_threshold)
212 #define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS,\
213 struct nd_cmd_dimm_flags)
215 #define ND_IOCTL_GET_CONFIG_SIZE _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_SIZE,\
216 struct nd_cmd_get_config_size)
218 #define ND_IOCTL_GET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_DATA,\
219 struct nd_cmd_get_config_data_hdr)
221 #define ND_IOCTL_SET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_SET_CONFIG_DATA,\
222 struct nd_cmd_set_config_hdr)
224 #define ND_IOCTL_VENDOR _IOWR(ND_IOCTL, ND_CMD_VENDOR,\
225 struct nd_cmd_vendor_hdr)
227 #define ND_IOCTL_ARS_CAP _IOWR(ND_IOCTL, ND_CMD_ARS_CAP,\
228 struct nd_cmd_ars_cap)
230 #define ND_IOCTL_ARS_START _IOWR(ND_IOCTL, ND_CMD_ARS_START,\
231 struct nd_cmd_ars_start)
233 #define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL, ND_CMD_ARS_STATUS,\
234 struct nd_cmd_ars_status)
236 #define ND_IOCTL_CLEAR_ERROR _IOWR(ND_IOCTL, ND_CMD_CLEAR_ERROR,\
237 struct nd_cmd_clear_error)
239 #define ND_DEVICE_DIMM 1 /* nd_dimm: container for "config data" */
240 #define ND_DEVICE_REGION_PMEM 2 /* nd_region: (parent of PMEM namespaces) */
241 #define ND_DEVICE_REGION_BLK 3 /* nd_region: (parent of BLK namespaces) */
242 #define ND_DEVICE_NAMESPACE_IO 4 /* legacy persistent memory */
243 #define ND_DEVICE_NAMESPACE_PMEM 5 /* PMEM namespace (may alias with BLK) */
244 #define ND_DEVICE_NAMESPACE_BLK 6 /* BLK namespace (may alias with PMEM) */
245 #define ND_DEVICE_DAX_PMEM 7 /* Device DAX interface to pmem */
247 enum nd_driver_flags
{
248 ND_DRIVER_DIMM
= 1 << ND_DEVICE_DIMM
,
249 ND_DRIVER_REGION_PMEM
= 1 << ND_DEVICE_REGION_PMEM
,
250 ND_DRIVER_REGION_BLK
= 1 << ND_DEVICE_REGION_BLK
,
251 ND_DRIVER_NAMESPACE_IO
= 1 << ND_DEVICE_NAMESPACE_IO
,
252 ND_DRIVER_NAMESPACE_PMEM
= 1 << ND_DEVICE_NAMESPACE_PMEM
,
253 ND_DRIVER_NAMESPACE_BLK
= 1 << ND_DEVICE_NAMESPACE_BLK
,
254 ND_DRIVER_DAX_PMEM
= 1 << ND_DEVICE_DAX_PMEM
,
258 ND_MIN_NAMESPACE_SIZE
= 0x00400000,
262 ARS_STATUS_MASK
= 0x0000FFFF,
263 ARS_EXT_STATUS_SHIFT
= 16,
269 * is a wrapper to a quasi pass thru interface for invoking firmware
270 * associated with nvdimms.
274 * nd_family corresponds to the firmware (e.g. DSM) interface.
276 * nd_command are the function index advertised by the firmware.
278 * nd_size_in is the size of the input parameters being passed to firmware
282 * nd_fw_size is the size of the data firmware wants to return for
283 * the call. If nd_fw_size is greater than size of nd_size_out, only
284 * the first nd_size_out bytes are returned.
288 __u64 nd_family
; /* family of commands */
290 __u32 nd_size_in
; /* INPUT: size of input args */
291 __u32 nd_size_out
; /* INPUT: size of payload */
292 __u32 nd_reserved2
[9]; /* reserved must be zero */
293 __u32 nd_fw_size
; /* OUTPUT: size fw wants to return */
294 unsigned char nd_payload
[]; /* Contents of call */
297 /* These NVDIMM families represent pre-standardization command sets */
298 #define NVDIMM_FAMILY_INTEL 0
299 #define NVDIMM_FAMILY_HPE1 1
300 #define NVDIMM_FAMILY_HPE2 2
301 #define NVDIMM_FAMILY_MSFT 3
303 #define ND_IOCTL_CALL _IOWR(ND_IOCTL, ND_CMD_CALL,\
306 #endif /* __NDCTL_H__ */