~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/nd.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/nd.h (Version linux-6.12-rc7) and /include/linux/nd.h (Version linux-5.15.171)


  1 /* SPDX-License-Identifier: GPL-2.0-only */         1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*                                                  2 /*
  3  * Copyright(c) 2013-2015 Intel Corporation. A      3  * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
  4  */                                                 4  */
  5 #ifndef __LINUX_ND_H__                              5 #ifndef __LINUX_ND_H__
  6 #define __LINUX_ND_H__                              6 #define __LINUX_ND_H__
  7 #include <linux/fs.h>                               7 #include <linux/fs.h>
  8 #include <linux/ndctl.h>                            8 #include <linux/ndctl.h>
  9 #include <linux/device.h>                           9 #include <linux/device.h>
 10 #include <linux/badblocks.h>                       10 #include <linux/badblocks.h>
 11 #include <linux/perf_event.h>                  << 
 12                                                    11 
 13 enum nvdimm_event {                                12 enum nvdimm_event {
 14         NVDIMM_REVALIDATE_POISON,                  13         NVDIMM_REVALIDATE_POISON,
 15         NVDIMM_REVALIDATE_REGION,                  14         NVDIMM_REVALIDATE_REGION,
 16 };                                                 15 };
 17                                                    16 
 18 enum nvdimm_claim_class {                          17 enum nvdimm_claim_class {
 19         NVDIMM_CCLASS_NONE,                        18         NVDIMM_CCLASS_NONE,
 20         NVDIMM_CCLASS_BTT,                         19         NVDIMM_CCLASS_BTT,
 21         NVDIMM_CCLASS_BTT2,                        20         NVDIMM_CCLASS_BTT2,
 22         NVDIMM_CCLASS_PFN,                         21         NVDIMM_CCLASS_PFN,
 23         NVDIMM_CCLASS_DAX,                         22         NVDIMM_CCLASS_DAX,
 24         NVDIMM_CCLASS_UNKNOWN,                     23         NVDIMM_CCLASS_UNKNOWN,
 25 };                                                 24 };
 26                                                    25 
 27 #define NVDIMM_EVENT_VAR(_id)  event_attr_##_i << 
 28 #define NVDIMM_EVENT_PTR(_id)  (&event_attr_## << 
 29                                                << 
 30 #define NVDIMM_EVENT_ATTR(_name, _id)          << 
 31         PMU_EVENT_ATTR(_name, NVDIMM_EVENT_VAR << 
 32                         nvdimm_events_sysfs_sh << 
 33                                                << 
 34 /* Event attribute array index */              << 
 35 #define NVDIMM_PMU_FORMAT_ATTR  0              << 
 36 #define NVDIMM_PMU_EVENT_ATTR   1              << 
 37 #define NVDIMM_PMU_CPUMASK_ATTR 2              << 
 38 #define NVDIMM_PMU_NULL_ATTR    3              << 
 39                                                << 
 40 /**                                            << 
 41  * struct nvdimm_pmu - data structure for nvdi << 
 42  * @pmu: pmu data structure for nvdimm perform << 
 43  * @dev: nvdimm device pointer.                << 
 44  * @cpu: designated cpu for counter access.    << 
 45  * @node: node for cpu hotplug notifier link.  << 
 46  * @cpuhp_state: state for cpu hotplug notific << 
 47  * @arch_cpumask: cpumask to get designated cp << 
 48  */                                            << 
 49 struct nvdimm_pmu {                            << 
 50         struct pmu pmu;                        << 
 51         struct device *dev;                    << 
 52         int cpu;                               << 
 53         struct hlist_node node;                << 
 54         enum cpuhp_state cpuhp_state;          << 
 55         /* cpumask provided by arch/platform s << 
 56         struct cpumask arch_cpumask;           << 
 57 };                                             << 
 58                                                << 
 59 struct platform_device;                        << 
 60                                                << 
 61 #ifdef CONFIG_PERF_EVENTS                      << 
 62 extern ssize_t nvdimm_events_sysfs_show(struct << 
 63                                         struct << 
 64                                         char * << 
 65                                                << 
 66 int register_nvdimm_pmu(struct nvdimm_pmu *nvd << 
 67 void unregister_nvdimm_pmu(struct nvdimm_pmu * << 
 68                                                << 
 69 #else                                          << 
 70 static inline int register_nvdimm_pmu(struct n << 
 71 {                                              << 
 72         return -ENXIO;                         << 
 73 }                                              << 
 74                                                << 
 75 static inline void unregister_nvdimm_pmu(struc << 
 76 #endif                                         << 
 77                                                << 
 78 struct nd_device_driver {                          26 struct nd_device_driver {
 79         struct device_driver drv;                  27         struct device_driver drv;
 80         unsigned long type;                        28         unsigned long type;
 81         int (*probe)(struct device *dev);          29         int (*probe)(struct device *dev);
 82         void (*remove)(struct device *dev);        30         void (*remove)(struct device *dev);
 83         void (*shutdown)(struct device *dev);      31         void (*shutdown)(struct device *dev);
 84         void (*notify)(struct device *dev, enu     32         void (*notify)(struct device *dev, enum nvdimm_event event);
 85 };                                                 33 };
 86                                                    34 
 87 #define to_nd_device_driver(__drv)      contai !!  35 static inline struct nd_device_driver *to_nd_device_driver(
                                                   >>  36                 struct device_driver *drv)
                                                   >>  37 {
                                                   >>  38         return container_of(drv, struct nd_device_driver, drv);
                                                   >>  39 };
 88                                                    40 
 89 /**                                                41 /**
 90  * struct nd_namespace_common - core infrastru     42  * struct nd_namespace_common - core infrastructure of a namespace
 91  * @force_raw: ignore other personalities for      43  * @force_raw: ignore other personalities for the namespace (e.g. btt)
 92  * @dev: device model node                         44  * @dev: device model node
 93  * @claim: when set a another personality has      45  * @claim: when set a another personality has taken ownership of the namespace
 94  * @claim_class: restrict claim type to a give     46  * @claim_class: restrict claim type to a given class
 95  * @rw_bytes: access the raw namespace capacit     47  * @rw_bytes: access the raw namespace capacity with byte-aligned transfers
 96  */                                                48  */
 97 struct nd_namespace_common {                       49 struct nd_namespace_common {
 98         int force_raw;                             50         int force_raw;
 99         struct device dev;                         51         struct device dev;
100         struct device *claim;                      52         struct device *claim;
101         enum nvdimm_claim_class claim_class;       53         enum nvdimm_claim_class claim_class;
102         int (*rw_bytes)(struct nd_namespace_co     54         int (*rw_bytes)(struct nd_namespace_common *, resource_size_t offset,
103                         void *buf, size_t size     55                         void *buf, size_t size, int rw, unsigned long flags);
104 };                                                 56 };
105                                                    57 
106 static inline struct nd_namespace_common *to_n     58 static inline struct nd_namespace_common *to_ndns(struct device *dev)
107 {                                                  59 {
108         return container_of(dev, struct nd_nam     60         return container_of(dev, struct nd_namespace_common, dev);
109 }                                                  61 }
110                                                    62 
111 /**                                                63 /**
112  * struct nd_namespace_io - device representat     64  * struct nd_namespace_io - device representation of a persistent memory range
113  * @dev: namespace device created by the nd re     65  * @dev: namespace device created by the nd region driver
114  * @res: struct resource conversion of a NFIT      66  * @res: struct resource conversion of a NFIT SPA table
115  * @size: cached resource_size(@res) for fast      67  * @size: cached resource_size(@res) for fast path size checks
116  * @addr: virtual address to access the namesp     68  * @addr: virtual address to access the namespace range
117  * @bb: badblocks list for the namespace range     69  * @bb: badblocks list for the namespace range
118  */                                                70  */
119 struct nd_namespace_io {                           71 struct nd_namespace_io {
120         struct nd_namespace_common common;         72         struct nd_namespace_common common;
121         struct resource res;                       73         struct resource res;
122         resource_size_t size;                      74         resource_size_t size;
123         void *addr;                                75         void *addr;
124         struct badblocks bb;                       76         struct badblocks bb;
125 };                                                 77 };
126                                                    78 
127 /**                                                79 /**
128  * struct nd_namespace_pmem - namespace device     80  * struct nd_namespace_pmem - namespace device for dimm-backed interleaved memory
129  * @nsio: device and system physical address r     81  * @nsio: device and system physical address range to drive
130  * @lbasize: logical sector size for the names     82  * @lbasize: logical sector size for the namespace in block-device-mode
131  * @alt_name: namespace name supplied in the d     83  * @alt_name: namespace name supplied in the dimm label
132  * @uuid: namespace name supplied in the dimm      84  * @uuid: namespace name supplied in the dimm label
133  * @id: ida allocated id                           85  * @id: ida allocated id
134  */                                                86  */
135 struct nd_namespace_pmem {                         87 struct nd_namespace_pmem {
136         struct nd_namespace_io nsio;               88         struct nd_namespace_io nsio;
137         unsigned long lbasize;                     89         unsigned long lbasize;
138         char *alt_name;                            90         char *alt_name;
139         uuid_t *uuid;                          !!  91         u8 *uuid;
140         int id;                                    92         int id;
141 };                                                 93 };
142                                                    94 
                                                   >>  95 /**
                                                   >>  96  * struct nd_namespace_blk - namespace for dimm-bounded persistent memory
                                                   >>  97  * @alt_name: namespace name supplied in the dimm label
                                                   >>  98  * @uuid: namespace name supplied in the dimm label
                                                   >>  99  * @id: ida allocated id
                                                   >> 100  * @lbasize: blk namespaces have a native sector size when btt not present
                                                   >> 101  * @size: sum of all the resource ranges allocated to this namespace
                                                   >> 102  * @num_resources: number of dpa extents to claim
                                                   >> 103  * @res: discontiguous dpa extents for given dimm
                                                   >> 104  */
                                                   >> 105 struct nd_namespace_blk {
                                                   >> 106         struct nd_namespace_common common;
                                                   >> 107         char *alt_name;
                                                   >> 108         u8 *uuid;
                                                   >> 109         int id;
                                                   >> 110         unsigned long lbasize;
                                                   >> 111         resource_size_t size;
                                                   >> 112         int num_resources;
                                                   >> 113         struct resource **res;
                                                   >> 114 };
                                                   >> 115 
143 static inline struct nd_namespace_io *to_nd_na    116 static inline struct nd_namespace_io *to_nd_namespace_io(const struct device *dev)
144 {                                                 117 {
145         return container_of(dev, struct nd_nam    118         return container_of(dev, struct nd_namespace_io, common.dev);
146 }                                                 119 }
147                                                   120 
148 static inline struct nd_namespace_pmem *to_nd_    121 static inline struct nd_namespace_pmem *to_nd_namespace_pmem(const struct device *dev)
149 {                                                 122 {
150         struct nd_namespace_io *nsio = to_nd_n    123         struct nd_namespace_io *nsio = to_nd_namespace_io(dev);
151                                                   124 
152         return container_of(nsio, struct nd_na    125         return container_of(nsio, struct nd_namespace_pmem, nsio);
                                                   >> 126 }
                                                   >> 127 
                                                   >> 128 static inline struct nd_namespace_blk *to_nd_namespace_blk(const struct device *dev)
                                                   >> 129 {
                                                   >> 130         return container_of(dev, struct nd_namespace_blk, common.dev);
153 }                                                 131 }
154                                                   132 
155 /**                                               133 /**
156  * nvdimm_read_bytes() - synchronously read by    134  * nvdimm_read_bytes() - synchronously read bytes from an nvdimm namespace
157  * @ndns: device to read                          135  * @ndns: device to read
158  * @offset: namespace-relative starting offset    136  * @offset: namespace-relative starting offset
159  * @buf: buffer to fill                           137  * @buf: buffer to fill
160  * @size: transfer length                         138  * @size: transfer length
161  *                                                139  *
162  * @buf is up-to-date upon return from this ro    140  * @buf is up-to-date upon return from this routine.
163  */                                               141  */
164 static inline int nvdimm_read_bytes(struct nd_    142 static inline int nvdimm_read_bytes(struct nd_namespace_common *ndns,
165                 resource_size_t offset, void *    143                 resource_size_t offset, void *buf, size_t size,
166                 unsigned long flags)              144                 unsigned long flags)
167 {                                                 145 {
168         return ndns->rw_bytes(ndns, offset, bu    146         return ndns->rw_bytes(ndns, offset, buf, size, READ, flags);
169 }                                                 147 }
170                                                   148 
171 /**                                               149 /**
172  * nvdimm_write_bytes() - synchronously write     150  * nvdimm_write_bytes() - synchronously write bytes to an nvdimm namespace
173  * @ndns: device to write                         151  * @ndns: device to write
174  * @offset: namespace-relative starting offset    152  * @offset: namespace-relative starting offset
175  * @buf: buffer to drain                          153  * @buf: buffer to drain
176  * @size: transfer length                         154  * @size: transfer length
177  *                                                155  *
178  * NVDIMM Namepaces disks do not implement sec    156  * NVDIMM Namepaces disks do not implement sectors internally.  Depending on
179  * the @ndns, the contents of @buf may be in c    157  * the @ndns, the contents of @buf may be in cpu cache, platform buffers,
180  * or on backing memory media upon return from    158  * or on backing memory media upon return from this routine.  Flushing
181  * to media is handled internal to the @ndns d    159  * to media is handled internal to the @ndns driver, if at all.
182  */                                               160  */
183 static inline int nvdimm_write_bytes(struct nd    161 static inline int nvdimm_write_bytes(struct nd_namespace_common *ndns,
184                 resource_size_t offset, void *    162                 resource_size_t offset, void *buf, size_t size,
185                 unsigned long flags)              163                 unsigned long flags)
186 {                                                 164 {
187         return ndns->rw_bytes(ndns, offset, bu    165         return ndns->rw_bytes(ndns, offset, buf, size, WRITE, flags);
188 }                                                 166 }
189                                                   167 
190 #define MODULE_ALIAS_ND_DEVICE(type) \            168 #define MODULE_ALIAS_ND_DEVICE(type) \
191         MODULE_ALIAS("nd:t" __stringify(type)     169         MODULE_ALIAS("nd:t" __stringify(type) "*")
192 #define ND_DEVICE_MODALIAS_FMT "nd:t%d"           170 #define ND_DEVICE_MODALIAS_FMT "nd:t%d"
193                                                   171 
194 struct nd_region;                                 172 struct nd_region;
195 void nvdimm_region_notify(struct nd_region *nd    173 void nvdimm_region_notify(struct nd_region *nd_region, enum nvdimm_event event);
196 int __must_check __nd_driver_register(struct n    174 int __must_check __nd_driver_register(struct nd_device_driver *nd_drv,
197                 struct module *module, const c    175                 struct module *module, const char *mod_name);
198 static inline void nd_driver_unregister(struct    176 static inline void nd_driver_unregister(struct nd_device_driver *drv)
199 {                                                 177 {
200         driver_unregister(&drv->drv);             178         driver_unregister(&drv->drv);
201 }                                                 179 }
202 #define nd_driver_register(driver) \              180 #define nd_driver_register(driver) \
203         __nd_driver_register(driver, THIS_MODU    181         __nd_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
204 #define module_nd_driver(driver) \                182 #define module_nd_driver(driver) \
205         module_driver(driver, nd_driver_regist    183         module_driver(driver, nd_driver_register, nd_driver_unregister)
206 #endif /* __LINUX_ND_H__ */                       184 #endif /* __LINUX_ND_H__ */
207                                                   185 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php