aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-06-29 13:34:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-29 13:34:42 -0400
commit88793e5c774ec69351ef6b5200bb59f532e41bca (patch)
tree54c4be61777ea53fde892b71e795322c5227d16e /include/uapi/linux
parent1bc5e157ed2b4f5b206155fc772d860158acd201 (diff)
parent61031952f4c89dba1065f7a5b9419badb112554c (diff)
Merge tag 'libnvdimm-for-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm
Pull libnvdimm subsystem from Dan Williams: "The libnvdimm sub-system introduces, in addition to the libnvdimm-core, 4 drivers / enabling modules: NFIT: Instantiates an "nvdimm bus" with the core and registers memory devices (NVDIMMs) enumerated by the ACPI 6.0 NFIT (NVDIMM Firmware Interface table). After registering NVDIMMs the NFIT driver then registers "region" devices. A libnvdimm-region defines an access mode and the boundaries of persistent memory media. A region may span multiple NVDIMMs that are interleaved by the hardware memory controller. In turn, a libnvdimm-region can be carved into a "namespace" device and bound to the PMEM or BLK driver which will attach a Linux block device (disk) interface to the memory. PMEM: Initially merged in v4.1 this driver for contiguous spans of persistent memory address ranges is re-worked to drive PMEM-namespaces emitted by the libnvdimm-core. In this update the PMEM driver, on x86, gains the ability to assert that writes to persistent memory have been flushed all the way through the caches and buffers in the platform to persistent media. See memcpy_to_pmem() and wmb_pmem(). BLK: This new driver enables access to persistent memory media through "Block Data Windows" as defined by the NFIT. The primary difference of this driver to PMEM is that only a small window of persistent memory is mapped into system address space at any given point in time. Per-NVDIMM windows are reprogrammed at run time, per-I/O, to access different portions of the media. BLK-mode, by definition, does not support DAX. BTT: This is a library, optionally consumed by either PMEM or BLK, that converts a byte-accessible namespace into a disk with atomic sector update semantics (prevents sector tearing on crash or power loss). The sinister aspect of sector tearing is that most applications do not know they have a atomic sector dependency. At least today's disk's rarely ever tear sectors and if they do one almost certainly gets a CRC error on access. NVDIMMs will always tear and always silently. Until an application is audited to be robust in the presence of sector-tearing the usage of BTT is recommended. Thanks to: Ross Zwisler, Jeff Moyer, Vishal Verma, Christoph Hellwig, Ingo Molnar, Neil Brown, Boaz Harrosh, Robert Elliott, Matthew Wilcox, Andy Rudoff, Linda Knippers, Toshi Kani, Nicholas Moulin, Rafael Wysocki, and Bob Moore" * tag 'libnvdimm-for-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm: (33 commits) arch, x86: pmem api for ensuring durability of persistent memory updates libnvdimm: Add sysfs numa_node to NVDIMM devices libnvdimm: Set numa_node to NVDIMM devices acpi: Add acpi_map_pxm_to_online_node() libnvdimm, nfit: handle unarmed dimms, mark namespaces read-only pmem: flag pmem block devices as non-rotational libnvdimm: enable iostat pmem: make_request cleanups libnvdimm, pmem: fix up max_hw_sectors libnvdimm, blk: add support for blk integrity libnvdimm, btt: add support for blk integrity fs/block_dev.c: skip rw_page if bdev has integrity libnvdimm: Non-Volatile Devices tools/testing/nvdimm: libnvdimm unit test infrastructure libnvdimm, nfit, nd_blk: driver for BLK-mode access persistent memory nd_btt: atomic sector updates libnvdimm: infrastructure for btt devices libnvdimm: write blk label set libnvdimm: write pmem label set libnvdimm: blk labels and namespace instantiation ...
Diffstat (limited to 'include/uapi/linux')
-rw-r--r--include/uapi/linux/Kbuild1
-rw-r--r--include/uapi/linux/ndctl.h197
2 files changed, 198 insertions, 0 deletions
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index c1c23f19d4a2..1ff9942718fe 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -272,6 +272,7 @@ header-y += ncp_fs.h
272header-y += ncp.h 272header-y += ncp.h
273header-y += ncp_mount.h 273header-y += ncp_mount.h
274header-y += ncp_no.h 274header-y += ncp_no.h
275header-y += ndctl.h
275header-y += neighbour.h 276header-y += neighbour.h
276header-y += netconf.h 277header-y += netconf.h
277header-y += netdevice.h 278header-y += netdevice.h
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
new file mode 100644
index 000000000000..2b94ea2287bb
--- /dev/null
+++ b/include/uapi/linux/ndctl.h
@@ -0,0 +1,197 @@
1/*
2 * Copyright (c) 2014-2015, Intel Corporation.
3 *
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.
7 *
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
11 * more details.
12 */
13#ifndef __NDCTL_H__
14#define __NDCTL_H__
15
16#include <linux/types.h>
17
18struct nd_cmd_smart {
19 __u32 status;
20 __u8 data[128];
21} __packed;
22
23struct nd_cmd_smart_threshold {
24 __u32 status;
25 __u8 data[8];
26} __packed;
27
28struct nd_cmd_dimm_flags {
29 __u32 status;
30 __u32 flags;
31} __packed;
32
33struct nd_cmd_get_config_size {
34 __u32 status;
35 __u32 config_size;
36 __u32 max_xfer;
37} __packed;
38
39struct nd_cmd_get_config_data_hdr {
40 __u32 in_offset;
41 __u32 in_length;
42 __u32 status;
43 __u8 out_buf[0];
44} __packed;
45
46struct nd_cmd_set_config_hdr {
47 __u32 in_offset;
48 __u32 in_length;
49 __u8 in_buf[0];
50} __packed;
51
52struct nd_cmd_vendor_hdr {
53 __u32 opcode;
54 __u32 in_length;
55 __u8 in_buf[0];
56} __packed;
57
58struct nd_cmd_vendor_tail {
59 __u32 status;
60 __u32 out_length;
61 __u8 out_buf[0];
62} __packed;
63
64struct nd_cmd_ars_cap {
65 __u64 address;
66 __u64 length;
67 __u32 status;
68 __u32 max_ars_out;
69} __packed;
70
71struct nd_cmd_ars_start {
72 __u64 address;
73 __u64 length;
74 __u16 type;
75 __u8 reserved[6];
76 __u32 status;
77} __packed;
78
79struct nd_cmd_ars_status {
80 __u32 status;
81 __u32 out_length;
82 __u64 address;
83 __u64 length;
84 __u16 type;
85 __u32 num_records;
86 struct nd_ars_record {
87 __u32 handle;
88 __u32 flags;
89 __u64 err_address;
90 __u64 mask;
91 } __packed records[0];
92} __packed;
93
94enum {
95 ND_CMD_IMPLEMENTED = 0,
96
97 /* bus commands */
98 ND_CMD_ARS_CAP = 1,
99 ND_CMD_ARS_START = 2,
100 ND_CMD_ARS_STATUS = 3,
101
102 /* per-dimm commands */
103 ND_CMD_SMART = 1,
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,
111 ND_CMD_VENDOR = 9,
112};
113
114static inline const char *nvdimm_bus_cmd_name(unsigned cmd)
115{
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",
120 };
121
122 if (cmd < ARRAY_SIZE(names) && names[cmd])
123 return names[cmd];
124 return "unknown";
125}
126
127static inline const char *nvdimm_cmd_name(unsigned cmd)
128{
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",
139 };
140
141 if (cmd < ARRAY_SIZE(names) && names[cmd])
142 return names[cmd];
143 return "unknown";
144}
145
146#define ND_IOCTL 'N'
147
148#define ND_IOCTL_SMART _IOWR(ND_IOCTL, ND_CMD_SMART,\
149 struct nd_cmd_smart)
150
151#define ND_IOCTL_SMART_THRESHOLD _IOWR(ND_IOCTL, ND_CMD_SMART_THRESHOLD,\
152 struct nd_cmd_smart_threshold)
153
154#define ND_IOCTL_DIMM_FLAGS _IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS,\
155 struct nd_cmd_dimm_flags)
156
157#define ND_IOCTL_GET_CONFIG_SIZE _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_SIZE,\
158 struct nd_cmd_get_config_size)
159
160#define ND_IOCTL_GET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_DATA,\
161 struct nd_cmd_get_config_data_hdr)
162
163#define ND_IOCTL_SET_CONFIG_DATA _IOWR(ND_IOCTL, ND_CMD_SET_CONFIG_DATA,\
164 struct nd_cmd_set_config_hdr)
165
166#define ND_IOCTL_VENDOR _IOWR(ND_IOCTL, ND_CMD_VENDOR,\
167 struct nd_cmd_vendor_hdr)
168
169#define ND_IOCTL_ARS_CAP _IOWR(ND_IOCTL, ND_CMD_ARS_CAP,\
170 struct nd_cmd_ars_cap)
171
172#define ND_IOCTL_ARS_START _IOWR(ND_IOCTL, ND_CMD_ARS_START,\
173 struct nd_cmd_ars_start)
174
175#define ND_IOCTL_ARS_STATUS _IOWR(ND_IOCTL, ND_CMD_ARS_STATUS,\
176 struct nd_cmd_ars_status)
177
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) */
184
185enum 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,
192};
193
194enum {
195 ND_MIN_NAMESPACE_SIZE = 0x00400000,
196};
197#endif /* __NDCTL_H__ */