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>
18 struct nd_cmd_dimm_flags {
21 } __attribute__((packed));
23 struct nd_cmd_get_config_size {
27 } __attribute__((packed));
29 struct nd_cmd_get_config_data_hdr {
34 } __attribute__((packed));
36 struct nd_cmd_set_config_hdr {
40 } __attribute__((packed));
42 struct nd_cmd_vendor_hdr {
46 } __attribute__((packed));
48 struct nd_cmd_vendor_tail {
52 } __attribute__((packed));
54 struct nd_cmd_ars_cap {
62 } __attribute__((packed));
64 struct nd_cmd_ars_start {
72 } __attribute__((packed));
74 struct nd_cmd_ars_status {
79 __u64 restart_address;
84 struct nd_ars_record {
89 } __attribute__((packed)) records[0];
90 } __attribute__((packed));
92 struct nd_cmd_clear_error {
98 } __attribute__((packed));
101 ND_CMD_IMPLEMENTED = 0,
105 ND_CMD_ARS_START = 2,
106 ND_CMD_ARS_STATUS = 3,
107 ND_CMD_CLEAR_ERROR = 4,
109 /* per-dimm commands */
111 ND_CMD_SMART_THRESHOLD = 2,
112 ND_CMD_DIMM_FLAGS = 3,
113 ND_CMD_GET_CONFIG_SIZE = 4,
114 ND_CMD_GET_CONFIG_DATA = 5,
115 ND_CMD_SET_CONFIG_DATA = 6,
116 ND_CMD_VENDOR_EFFECT_LOG_SIZE = 7,
117 ND_CMD_VENDOR_EFFECT_LOG = 8,
124 ND_ARS_PERSISTENT = 2,
125 ND_ARS_RETURN_PREV_DATA = 1 << 1,
126 ND_CONFIG_LOCKED = 1,
129 static __inline__ const char *nvdimm_bus_cmd_name(unsigned cmd)
132 case ND_CMD_ARS_CAP: return "ars_cap";
133 case ND_CMD_ARS_START: return "ars_start";
134 case ND_CMD_ARS_STATUS: return "ars_status";
135 case ND_CMD_CLEAR_ERROR: return "clear_error";
136 case ND_CMD_CALL: return "cmd_call";
137 default: return "unknown";
141 static __inline__ const char *nvdimm_cmd_name(unsigned cmd)
144 case ND_CMD_SMART: return "smart";
145 case ND_CMD_SMART_THRESHOLD: return "smart_thresh";
146 case ND_CMD_DIMM_FLAGS: return "flags";
147 case ND_CMD_GET_CONFIG_SIZE: return "get_size";
148 case ND_CMD_GET_CONFIG_DATA: return "get_data";
149 case ND_CMD_SET_CONFIG_DATA: return "set_data";
150 case ND_CMD_VENDOR_EFFECT_LOG_SIZE: return "effect_size";
151 case ND_CMD_VENDOR_EFFECT_LOG: return "effect_log";
152 case ND_CMD_VENDOR: return "vendor";
153 case ND_CMD_CALL: return "cmd_call";
154 default: return "unknown";
160 #define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS,\
161 struct nd_cmd_dimm_flags)
163 #define ND_IOCTL_GET_CONFIG_SIZE _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_SIZE,\
164 struct nd_cmd_get_config_size)
166 #define ND_IOCTL_GET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_DATA,\
167 struct nd_cmd_get_config_data_hdr)
169 #define ND_IOCTL_SET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_SET_CONFIG_DATA,\
170 struct nd_cmd_set_config_hdr)
172 #define ND_IOCTL_VENDOR _IOWR(ND_IOCTL, ND_CMD_VENDOR,\
173 struct nd_cmd_vendor_hdr)
175 #define ND_IOCTL_ARS_CAP _IOWR(ND_IOCTL, ND_CMD_ARS_CAP,\
176 struct nd_cmd_ars_cap)
178 #define ND_IOCTL_ARS_START _IOWR(ND_IOCTL, ND_CMD_ARS_START,\
179 struct nd_cmd_ars_start)
181 #define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL, ND_CMD_ARS_STATUS,\
182 struct nd_cmd_ars_status)
184 #define ND_IOCTL_CLEAR_ERROR _IOWR(ND_IOCTL, ND_CMD_CLEAR_ERROR,\
185 struct nd_cmd_clear_error)
187 #define ND_DEVICE_DIMM 1 /* nd_dimm: container for "config data" */
188 #define ND_DEVICE_REGION_PMEM 2 /* nd_region: (parent of PMEM namespaces) */
189 #define ND_DEVICE_REGION_BLK 3 /* nd_region: (parent of BLK namespaces) */
190 #define ND_DEVICE_NAMESPACE_IO 4 /* legacy persistent memory */
191 #define ND_DEVICE_NAMESPACE_PMEM 5 /* PMEM namespace (may alias with BLK) */
192 #define ND_DEVICE_NAMESPACE_BLK 6 /* BLK namespace (may alias with PMEM) */
193 #define ND_DEVICE_DAX_PMEM 7 /* Device DAX interface to pmem */
195 enum nd_driver_flags {
196 ND_DRIVER_DIMM = 1 << ND_DEVICE_DIMM,
197 ND_DRIVER_REGION_PMEM = 1 << ND_DEVICE_REGION_PMEM,
198 ND_DRIVER_REGION_BLK = 1 << ND_DEVICE_REGION_BLK,
199 ND_DRIVER_NAMESPACE_IO = 1 << ND_DEVICE_NAMESPACE_IO,
200 ND_DRIVER_NAMESPACE_PMEM = 1 << ND_DEVICE_NAMESPACE_PMEM,
201 ND_DRIVER_NAMESPACE_BLK = 1 << ND_DEVICE_NAMESPACE_BLK,
202 ND_DRIVER_DAX_PMEM = 1 << ND_DEVICE_DAX_PMEM,
206 ND_MIN_NAMESPACE_SIZE = PAGE_SIZE,
210 ARS_STATUS_MASK = 0x0000FFFF,
211 ARS_EXT_STATUS_SHIFT = 16,
217 * is a wrapper to a quasi pass thru interface for invoking firmware
218 * associated with nvdimms.
222 * nd_family corresponds to the firmware (e.g. DSM) interface.
224 * nd_command are the function index advertised by the firmware.
226 * nd_size_in is the size of the input parameters being passed to firmware
230 * nd_fw_size is the size of the data firmware wants to return for
231 * the call. If nd_fw_size is greater than size of nd_size_out, only
232 * the first nd_size_out bytes are returned.
236 __u64 nd_family; /* family of commands */
238 __u32 nd_size_in; /* INPUT: size of input args */
239 __u32 nd_size_out; /* INPUT: size of payload */
240 __u32 nd_reserved2[9]; /* reserved must be zero */
241 __u32 nd_fw_size; /* OUTPUT: size fw wants to return */
242 unsigned char nd_payload[]; /* Contents of call */
245 /* These NVDIMM families represent pre-standardization command sets */
246 #define NVDIMM_FAMILY_INTEL 0
247 #define NVDIMM_FAMILY_HPE1 1
248 #define NVDIMM_FAMILY_HPE2 2
249 #define NVDIMM_FAMILY_MSFT 3
250 #define NVDIMM_FAMILY_HYPERV 4
252 #define ND_IOCTL_CALL _IOWR(ND_IOCTL, ND_CMD_CALL,\
255 #endif /* __NDCTL_H__ */