/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright(c) 2013-2015 Intel Corporation. All rights reserved. */ #ifndef __LABEL_H__ #define __LABEL_H__ #include <linux/ndctl.h> #include <linux/sizes.h> #include <linux/uuid.h> #include <linux/io.h> enum { … }; /** * struct nd_namespace_index - label set superblock * @sig: NAMESPACE_INDEX\0 * @flags: placeholder * @labelsize: log2 size (v1 labels 128 bytes v2 labels 256 bytes) * @seq: sequence number for this index * @myoff: offset of this index in label area * @mysize: size of this index struct * @otheroff: offset of other index * @labeloff: offset of first label slot * @nslot: total number of label slots * @major: label area major version * @minor: label area minor version * @checksum: fletcher64 of all fields * @free: bitmap, nlabel bits * * The size of free[] is rounded up so the total struct size is a * multiple of NSINDEX_ALIGN bytes. Any bits this allocates beyond * nlabel bits must be zero. */ struct nd_namespace_index { … }; /** * struct cxl_region_label - CXL 2.0 Table 211 * @type: uuid identifying this label format (region) * @uuid: uuid for the region this label describes * @flags: NSLABEL_FLAG_UPDATING (all other flags reserved) * @nlabel: 1 per interleave-way in the region * @position: this label's position in the set * @dpa: start address in device-local capacity for this label * @rawsize: size of this label's contribution to region * @hpa: mandatory system physical address to map this region * @slot: slot id of this label in label area * @ig: interleave granularity (1 << @ig) * 256 bytes * @align: alignment in SZ_256M blocks * @reserved: reserved * @checksum: fletcher64 sum of this label */ struct cxl_region_label { … }; /** * struct nvdimm_efi_label - namespace superblock * @uuid: UUID per RFC 4122 * @name: optional name (NULL-terminated) * @flags: see NSLABEL_FLAG_* * @nlabel: num labels to describe this ns * @position: labels position in set * @isetcookie: interleave set cookie * @lbasize: LBA size in bytes or 0 for pmem * @dpa: DPA of NVM range on this DIMM * @rawsize: size of namespace * @slot: slot of this label in label area * @align: physical address alignment of the namespace * @reserved: reserved * @type_guid: copy of struct acpi_nfit_system_address.range_guid * @abstraction_guid: personality id (btt, btt2, fsdax, devdax....) * @reserved2: reserved * @checksum: fletcher64 sum of this object */ struct nvdimm_efi_label { … }; /** * struct nvdimm_cxl_label - CXL 2.0 Table 212 * @type: uuid identifying this label format (namespace) * @uuid: uuid for the namespace this label describes * @name: friendly name for the namespace * @flags: NSLABEL_FLAG_UPDATING (all other flags reserved) * @nrange: discontiguous namespace support * @position: this label's position in the set * @dpa: start address in device-local capacity for this label * @rawsize: size of this label's contribution to namespace * @slot: slot id of this label in label area * @align: alignment in SZ_256M blocks * @region_uuid: host interleave set identifier * @abstraction_uuid: personality driver for this namespace * @lbasize: address geometry for disk-like personalities * @reserved: reserved * @checksum: fletcher64 sum of this label */ struct nvdimm_cxl_label { … }; struct nd_namespace_label { … }; #define NVDIMM_BTT_GUID … #define NVDIMM_BTT2_GUID … #define NVDIMM_PFN_GUID … #define NVDIMM_DAX_GUID … #define CXL_REGION_UUID … #define CXL_NAMESPACE_UUID … /** * struct nd_label_id - identifier string for dpa allocation * @id: "pmem-<namespace uuid>" */ struct nd_label_id { … }; /* * If the 'best' index is invalid, so is the 'next' index. Otherwise, * the next index is MOD(index+1, 2) */ static inline int nd_label_next_nsindex(int index) { … } struct nvdimm_drvdata; int nd_label_data_init(struct nvdimm_drvdata *ndd); size_t sizeof_namespace_index(struct nvdimm_drvdata *ndd); int nd_label_active_count(struct nvdimm_drvdata *ndd); struct nd_namespace_label *nd_label_active(struct nvdimm_drvdata *ndd, int n); u32 nd_label_alloc_slot(struct nvdimm_drvdata *ndd); bool nd_label_free_slot(struct nvdimm_drvdata *ndd, u32 slot); u32 nd_label_nfree(struct nvdimm_drvdata *ndd); struct nd_region; struct nd_namespace_pmem; int nd_pmem_namespace_label_update(struct nd_region *nd_region, struct nd_namespace_pmem *nspm, resource_size_t size); #endif /* __LABEL_H__ */