aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2016-04-28 19:23:43 -0400
committerDan Williams <dan.j.williams@intel.com>2016-04-28 19:59:06 -0400
commit31eca76ba2fc988bf88f16fcf763a0ec4068cd30 (patch)
tree7b7f359ac8340576842350708cd4de5b84bbf53a /include/uapi/linux
parente3654eca70d63704c94a60a2aafc0b3c7b46a00b (diff)
nfit, libnvdimm: limited/whitelisted dimm command marshaling mechanism
There are currently 4 known similar but incompatible definitions of the command sets that can be sent to an NVDIMM through ACPI. It is also clear that future platform generations (ACPI or not) will continue to revise and extend the DIMM command set as new devices and use cases arrive. It is obviously untenable to continue to proliferate divergence of these command definitions, and to that end a standardization process has begun to provide for a unified specification. However, that leaves a problem about what to do with this first generation where vendors are already shipping divergence. The Linux kernel can support these initial diverged platforms without giving platform-firmware free reign to continue to diverge and compound kernel maintenance overhead. The kernel implementation can encourage standardization in two ways: 1/ Require that any function code that userspace wants to send be explicitly white-listed in the implementation. For ACPI this means function codes marked as supported by acpi_check_dsm() may only be invoked if they appear in the white-list. A function must be publicly documented before it is added to the white-list. 2/ The above restrictions can be trivially bypassed by using the "vendor-specific" payload command. However, since vendor-specific commands are by definition not publicly documented and have the potential to corrupt the kernel's view of the dimm state, we provide a toggle to disable vendor-specific operations. Enabling undefined behavior is a policy decision that can be made by the platform owner and encourages firmware implementations to choose public over private command implementations. Based on an initial patch from Jerry Hoemann Cc: Jerry Hoemann <jerry.hoemann@hpe.com> Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'include/uapi/linux')
-rw-r--r--include/uapi/linux/ndctl.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 7cc28ab05b87..45daa0be5ff9 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -125,6 +125,7 @@ enum {
125 ND_CMD_VENDOR_EFFECT_LOG_SIZE = 7, 125 ND_CMD_VENDOR_EFFECT_LOG_SIZE = 7,
126 ND_CMD_VENDOR_EFFECT_LOG = 8, 126 ND_CMD_VENDOR_EFFECT_LOG = 8,
127 ND_CMD_VENDOR = 9, 127 ND_CMD_VENDOR = 9,
128 ND_CMD_CALL = 10,
128}; 129};
129 130
130enum { 131enum {
@@ -158,6 +159,7 @@ static inline const char *nvdimm_cmd_name(unsigned cmd)
158 [ND_CMD_VENDOR_EFFECT_LOG_SIZE] = "effect_size", 159 [ND_CMD_VENDOR_EFFECT_LOG_SIZE] = "effect_size",
159 [ND_CMD_VENDOR_EFFECT_LOG] = "effect_log", 160 [ND_CMD_VENDOR_EFFECT_LOG] = "effect_log",
160 [ND_CMD_VENDOR] = "vendor", 161 [ND_CMD_VENDOR] = "vendor",
162 [ND_CMD_CALL] = "cmd_call",
161 }; 163 };
162 164
163 if (cmd < ARRAY_SIZE(names) && names[cmd]) 165 if (cmd < ARRAY_SIZE(names) && names[cmd])
@@ -224,4 +226,44 @@ enum ars_masks {
224 ARS_STATUS_MASK = 0x0000FFFF, 226 ARS_STATUS_MASK = 0x0000FFFF,
225 ARS_EXT_STATUS_SHIFT = 16, 227 ARS_EXT_STATUS_SHIFT = 16,
226}; 228};
229
230/*
231 * struct nd_cmd_pkg
232 *
233 * is a wrapper to a quasi pass thru interface for invoking firmware
234 * associated with nvdimms.
235 *
236 * INPUT PARAMETERS
237 *
238 * nd_family corresponds to the firmware (e.g. DSM) interface.
239 *
240 * nd_command are the function index advertised by the firmware.
241 *
242 * nd_size_in is the size of the input parameters being passed to firmware
243 *
244 * OUTPUT PARAMETERS
245 *
246 * nd_fw_size is the size of the data firmware wants to return for
247 * the call. If nd_fw_size is greater than size of nd_size_out, only
248 * the first nd_size_out bytes are returned.
249 */
250
251struct nd_cmd_pkg {
252 __u64 nd_family; /* family of commands */
253 __u64 nd_command;
254 __u32 nd_size_in; /* INPUT: size of input args */
255 __u32 nd_size_out; /* INPUT: size of payload */
256 __u32 nd_reserved2[9]; /* reserved must be zero */
257 __u32 nd_fw_size; /* OUTPUT: size fw wants to return */
258 unsigned char nd_payload[]; /* Contents of call */
259};
260
261/* These NVDIMM families represent pre-standardization command sets */
262#define NVDIMM_FAMILY_INTEL 0
263#define NVDIMM_FAMILY_HPE1 1
264#define NVDIMM_FAMILY_HPE2 2
265
266#define ND_IOCTL_CALL _IOWR(ND_IOCTL, ND_CMD_CALL,\
267 struct nd_cmd_pkg)
268
227#endif /* __NDCTL_H__ */ 269#endif /* __NDCTL_H__ */