2 * Copyright (c) 2014-2015, 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 struct nd_cmd_smart_threshold {
28 struct nd_cmd_dimm_flags {
33 struct nd_cmd_get_config_size {
39 struct nd_cmd_get_config_data_hdr {
46 struct nd_cmd_set_config_hdr {
52 struct nd_cmd_vendor_hdr {
58 struct nd_cmd_vendor_tail {
64 struct nd_cmd_ars_cap {
71 struct nd_cmd_ars_start {
79 struct nd_cmd_ars_status {
86 struct nd_ars_record {
91 } __packed records[0];
95 ND_CMD_IMPLEMENTED = 0,
100 ND_CMD_ARS_STATUS = 3,
102 /* per-dimm commands */
104 ND_CMD_SMART_THRESHOLD = 2,
105 ND_CMD_DIMM_FLAGS = 3,
106 ND_CMD_GET_CONFIG_SIZE = 4,
107 ND_CMD_GET_CONFIG_DATA = 5,
108 ND_CMD_SET_CONFIG_DATA = 6,
109 ND_CMD_VENDOR_EFFECT_LOG_SIZE = 7,
110 ND_CMD_VENDOR_EFFECT_LOG = 8,
114 static inline const char *nvdimm_bus_cmd_name(unsigned cmd)
116 static const char * const names[] = {
117 [ND_CMD_ARS_CAP] = "ars_cap",
118 [ND_CMD_ARS_START] = "ars_start",
119 [ND_CMD_ARS_STATUS] = "ars_status",
122 if (cmd < ARRAY_SIZE(names) && names[cmd])
127 static inline const char *nvdimm_cmd_name(unsigned cmd)
129 static const char * const names[] = {
130 [ND_CMD_SMART] = "smart",
131 [ND_CMD_SMART_THRESHOLD] = "smart_thresh",
132 [ND_CMD_DIMM_FLAGS] = "flags",
133 [ND_CMD_GET_CONFIG_SIZE] = "get_size",
134 [ND_CMD_GET_CONFIG_DATA] = "get_data",
135 [ND_CMD_SET_CONFIG_DATA] = "set_data",
136 [ND_CMD_VENDOR_EFFECT_LOG_SIZE] = "effect_size",
137 [ND_CMD_VENDOR_EFFECT_LOG] = "effect_log",
138 [ND_CMD_VENDOR] = "vendor",
141 if (cmd < ARRAY_SIZE(names) && names[cmd])
148 #define ND_IOCTL_SMART _IOWR(ND_IOCTL, ND_CMD_SMART,\
151 #define ND_IOCTL_SMART_THRESHOLD _IOWR(ND_IOCTL, ND_CMD_SMART_THRESHOLD,\
152 struct nd_cmd_smart_threshold)
154 #define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS,\
155 struct nd_cmd_dimm_flags)
157 #define ND_IOCTL_GET_CONFIG_SIZE _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_SIZE,\
158 struct nd_cmd_get_config_size)
160 #define ND_IOCTL_GET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_DATA,\
161 struct nd_cmd_get_config_data_hdr)
163 #define ND_IOCTL_SET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_SET_CONFIG_DATA,\
164 struct nd_cmd_set_config_hdr)
166 #define ND_IOCTL_VENDOR _IOWR(ND_IOCTL, ND_CMD_VENDOR,\
167 struct nd_cmd_vendor_hdr)
169 #define ND_IOCTL_ARS_CAP _IOWR(ND_IOCTL, ND_CMD_ARS_CAP,\
170 struct nd_cmd_ars_cap)
172 #define ND_IOCTL_ARS_START _IOWR(ND_IOCTL, ND_CMD_ARS_START,\
173 struct nd_cmd_ars_start)
175 #define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL, ND_CMD_ARS_STATUS,\
176 struct nd_cmd_ars_status)
178 #define ND_DEVICE_DIMM 1 /* nd_dimm: container for "config data" */
179 #define ND_DEVICE_REGION_PMEM 2 /* nd_region: (parent of PMEM namespaces) */
180 #define ND_DEVICE_REGION_BLK 3 /* nd_region: (parent of BLK namespaces) */
181 #define ND_DEVICE_NAMESPACE_IO 4 /* legacy persistent memory */
182 #define ND_DEVICE_NAMESPACE_PMEM 5 /* PMEM namespace (may alias with BLK) */
183 #define ND_DEVICE_NAMESPACE_BLK 6 /* BLK namespace (may alias with PMEM) */
185 enum nd_driver_flags {
186 ND_DRIVER_DIMM = 1 << ND_DEVICE_DIMM,
187 ND_DRIVER_REGION_PMEM = 1 << ND_DEVICE_REGION_PMEM,
188 ND_DRIVER_REGION_BLK = 1 << ND_DEVICE_REGION_BLK,
189 ND_DRIVER_NAMESPACE_IO = 1 << ND_DEVICE_NAMESPACE_IO,
190 ND_DRIVER_NAMESPACE_PMEM = 1 << ND_DEVICE_NAMESPACE_PMEM,
191 ND_DRIVER_NAMESPACE_BLK = 1 << ND_DEVICE_NAMESPACE_BLK,
195 ND_MIN_NAMESPACE_SIZE = 0x00400000,
197 #endif /* __NDCTL_H__ */