/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright(c) 2013-2015 Intel Corporation. All rights reserved. */ #ifndef __LINUX_ND_H__ #define __LINUX_ND_H__ #include <linux/fs.h> #include <linux/ndctl.h> #include <linux/device.h> #include <linux/badblocks.h> #include <linux/perf_event.h> enum nvdimm_event { … }; enum nvdimm_claim_class { … }; #define NVDIMM_EVENT_VAR(_id) … #define NVDIMM_EVENT_PTR(_id) … #define NVDIMM_EVENT_ATTR(_name, _id) … /* Event attribute array index */ #define NVDIMM_PMU_FORMAT_ATTR … #define NVDIMM_PMU_EVENT_ATTR … #define NVDIMM_PMU_CPUMASK_ATTR … #define NVDIMM_PMU_NULL_ATTR … /** * struct nvdimm_pmu - data structure for nvdimm perf driver * @pmu: pmu data structure for nvdimm performance stats. * @dev: nvdimm device pointer. * @cpu: designated cpu for counter access. * @node: node for cpu hotplug notifier link. * @cpuhp_state: state for cpu hotplug notification. * @arch_cpumask: cpumask to get designated cpu for counter access. */ struct nvdimm_pmu { … }; struct platform_device; #ifdef CONFIG_PERF_EVENTS extern ssize_t nvdimm_events_sysfs_show(struct device *dev, struct device_attribute *attr, char *page); int register_nvdimm_pmu(struct nvdimm_pmu *nvdimm, struct platform_device *pdev); void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu); #else static inline int register_nvdimm_pmu(struct nvdimm_pmu *nvdimm, struct platform_device *pdev) { return -ENXIO; } static inline void unregister_nvdimm_pmu(struct nvdimm_pmu *nd_pmu) { } #endif struct nd_device_driver { … }; #define to_nd_device_driver(__drv) … /** * struct nd_namespace_common - core infrastructure of a namespace * @force_raw: ignore other personalities for the namespace (e.g. btt) * @dev: device model node * @claim: when set a another personality has taken ownership of the namespace * @claim_class: restrict claim type to a given class * @rw_bytes: access the raw namespace capacity with byte-aligned transfers */ struct nd_namespace_common { … }; static inline struct nd_namespace_common *to_ndns(struct device *dev) { … } /** * struct nd_namespace_io - device representation of a persistent memory range * @dev: namespace device created by the nd region driver * @res: struct resource conversion of a NFIT SPA table * @size: cached resource_size(@res) for fast path size checks * @addr: virtual address to access the namespace range * @bb: badblocks list for the namespace range */ struct nd_namespace_io { … }; /** * struct nd_namespace_pmem - namespace device for dimm-backed interleaved memory * @nsio: device and system physical address range to drive * @lbasize: logical sector size for the namespace in block-device-mode * @alt_name: namespace name supplied in the dimm label * @uuid: namespace name supplied in the dimm label * @id: ida allocated id */ struct nd_namespace_pmem { … }; static inline struct nd_namespace_io *to_nd_namespace_io(const struct device *dev) { … } static inline struct nd_namespace_pmem *to_nd_namespace_pmem(const struct device *dev) { … } /** * nvdimm_read_bytes() - synchronously read bytes from an nvdimm namespace * @ndns: device to read * @offset: namespace-relative starting offset * @buf: buffer to fill * @size: transfer length * * @buf is up-to-date upon return from this routine. */ static inline int nvdimm_read_bytes(struct nd_namespace_common *ndns, resource_size_t offset, void *buf, size_t size, unsigned long flags) { … } /** * nvdimm_write_bytes() - synchronously write bytes to an nvdimm namespace * @ndns: device to write * @offset: namespace-relative starting offset * @buf: buffer to drain * @size: transfer length * * NVDIMM Namepaces disks do not implement sectors internally. Depending on * the @ndns, the contents of @buf may be in cpu cache, platform buffers, * or on backing memory media upon return from this routine. Flushing * to media is handled internal to the @ndns driver, if at all. */ static inline int nvdimm_write_bytes(struct nd_namespace_common *ndns, resource_size_t offset, void *buf, size_t size, unsigned long flags) { … } #define MODULE_ALIAS_ND_DEVICE(type) … #define ND_DEVICE_MODALIAS_FMT … struct nd_region; void nvdimm_region_notify(struct nd_region *nd_region, enum nvdimm_event event); int __must_check __nd_driver_register(struct nd_device_driver *nd_drv, struct module *module, const char *mod_name); static inline void nd_driver_unregister(struct nd_device_driver *drv) { … } #define nd_driver_register(driver) … #define module_nd_driver(driver) … #endif /* __LINUX_ND_H__ */