/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
 */
#ifndef __ND_H__
#define __ND_H__
#include <linux/libnvdimm.h>
#include <linux/badblocks.h>
#include <linux/blkdev.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/ndctl.h>
#include <linux/types.h>
#include <linux/nd.h>
#include "label.h"

enum {
	/*
	 * Limits the maximum number of block apertures a dimm can
	 * support and is an input to the geometry/on-disk-format of a
	 * BTT instance
	 */
	ND_MAX_LANES = 256,
	INT_LBASIZE_ALIGNMENT = 64,
	NVDIMM_IO_ATOMIC = 1,
};

struct nvdimm_drvdata {
	struct device *dev;
	int nslabel_size;
	struct nd_cmd_get_config_size nsarea;
	void *data;
	bool cxl;
	int ns_current, ns_next;
	struct resource dpa;
	struct kref kref;
};

static inline const u8 *nsl_ref_name(struct nvdimm_drvdata *ndd,
				     struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return nd_label->cxl.name;
	return nd_label->efi.name;
}

static inline u8 *nsl_get_name(struct nvdimm_drvdata *ndd,
			       struct nd_namespace_label *nd_label, u8 *name)
{
	if (ndd->cxl)
		return memcpy(name, nd_label->cxl.name, NSLABEL_NAME_LEN);
	return memcpy(name, nd_label->efi.name, NSLABEL_NAME_LEN);
}

static inline u8 *nsl_set_name(struct nvdimm_drvdata *ndd,
			       struct nd_namespace_label *nd_label, u8 *name)
{
	if (!name)
		return NULL;
	if (ndd->cxl)
		return memcpy(nd_label->cxl.name, name, NSLABEL_NAME_LEN);
	return memcpy(nd_label->efi.name, name, NSLABEL_NAME_LEN);
}

static inline u32 nsl_get_slot(struct nvdimm_drvdata *ndd,
			       struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return __le32_to_cpu(nd_label->cxl.slot);
	return __le32_to_cpu(nd_label->efi.slot);
}

static inline void nsl_set_slot(struct nvdimm_drvdata *ndd,
				struct nd_namespace_label *nd_label, u32 slot)
{
	if (ndd->cxl)
		nd_label->cxl.slot = __cpu_to_le32(slot);
	else
		nd_label->efi.slot = __cpu_to_le32(slot);
}

static inline u64 nsl_get_checksum(struct nvdimm_drvdata *ndd,
				   struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return __le64_to_cpu(nd_label->cxl.checksum);
	return __le64_to_cpu(nd_label->efi.checksum);
}

static inline void nsl_set_checksum(struct nvdimm_drvdata *ndd,
				    struct nd_namespace_label *nd_label,
				    u64 checksum)
{
	if (ndd->cxl)
		nd_label->cxl.checksum = __cpu_to_le64(checksum);
	else
		nd_label->efi.checksum = __cpu_to_le64(checksum);
}

static inline u32 nsl_get_flags(struct nvdimm_drvdata *ndd,
				struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return __le32_to_cpu(nd_label->cxl.flags);
	return __le32_to_cpu(nd_label->efi.flags);
}

static inline void nsl_set_flags(struct nvdimm_drvdata *ndd,
				 struct nd_namespace_label *nd_label, u32 flags)
{
	if (ndd->cxl)
		nd_label->cxl.flags = __cpu_to_le32(flags);
	else
		nd_label->efi.flags = __cpu_to_le32(flags);
}

static inline u64 nsl_get_dpa(struct nvdimm_drvdata *ndd,
			      struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return __le64_to_cpu(nd_label->cxl.dpa);
	return __le64_to_cpu(nd_label->efi.dpa);
}

static inline void nsl_set_dpa(struct nvdimm_drvdata *ndd,
			       struct nd_namespace_label *nd_label, u64 dpa)
{
	if (ndd->cxl)
		nd_label->cxl.dpa = __cpu_to_le64(dpa);
	else
		nd_label->efi.dpa = __cpu_to_le64(dpa);
}

static inline u64 nsl_get_rawsize(struct nvdimm_drvdata *ndd,
				  struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return __le64_to_cpu(nd_label->cxl.rawsize);
	return __le64_to_cpu(nd_label->efi.rawsize);
}

static inline void nsl_set_rawsize(struct nvdimm_drvdata *ndd,
				   struct nd_namespace_label *nd_label,
				   u64 rawsize)
{
	if (ndd->cxl)
		nd_label->cxl.rawsize = __cpu_to_le64(rawsize);
	else
		nd_label->efi.rawsize = __cpu_to_le64(rawsize);
}

static inline u64 nsl_get_isetcookie(struct nvdimm_drvdata *ndd,
				     struct nd_namespace_label *nd_label)
{
	/* WARN future refactor attempts that break this assumption */
	if (dev_WARN_ONCE(ndd->dev, ndd->cxl,
			  "CXL labels do not use the isetcookie concept\n"))
		return 0;
	return __le64_to_cpu(nd_label->efi.isetcookie);
}

static inline void nsl_set_isetcookie(struct nvdimm_drvdata *ndd,
				      struct nd_namespace_label *nd_label,
				      u64 isetcookie)
{
	if (!ndd->cxl)
		nd_label->efi.isetcookie = __cpu_to_le64(isetcookie);
}

static inline bool nsl_validate_isetcookie(struct nvdimm_drvdata *ndd,
					   struct nd_namespace_label *nd_label,
					   u64 cookie)
{
	/*
	 * Let the EFI and CXL validation comingle, where fields that
	 * don't matter to CXL always validate.
	 */
	if (ndd->cxl)
		return true;
	return cookie == __le64_to_cpu(nd_label->efi.isetcookie);
}

static inline u16 nsl_get_position(struct nvdimm_drvdata *ndd,
				   struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return __le16_to_cpu(nd_label->cxl.position);
	return __le16_to_cpu(nd_label->efi.position);
}

static inline void nsl_set_position(struct nvdimm_drvdata *ndd,
				    struct nd_namespace_label *nd_label,
				    u16 position)
{
	if (ndd->cxl)
		nd_label->cxl.position = __cpu_to_le16(position);
	else
		nd_label->efi.position = __cpu_to_le16(position);
}

static inline u16 nsl_get_nlabel(struct nvdimm_drvdata *ndd,
				 struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return 0;
	return __le16_to_cpu(nd_label->efi.nlabel);
}

static inline void nsl_set_nlabel(struct nvdimm_drvdata *ndd,
				  struct nd_namespace_label *nd_label,
				  u16 nlabel)
{
	if (!ndd->cxl)
		nd_label->efi.nlabel = __cpu_to_le16(nlabel);
}

static inline u16 nsl_get_nrange(struct nvdimm_drvdata *ndd,
				 struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return __le16_to_cpu(nd_label->cxl.nrange);
	return 1;
}

static inline void nsl_set_nrange(struct nvdimm_drvdata *ndd,
				  struct nd_namespace_label *nd_label,
				  u16 nrange)
{
	if (ndd->cxl)
		nd_label->cxl.nrange = __cpu_to_le16(nrange);
}

static inline u64 nsl_get_lbasize(struct nvdimm_drvdata *ndd,
				  struct nd_namespace_label *nd_label)
{
	/*
	 * Yes, for some reason the EFI labels convey a massive 64-bit
	 * lbasize, that got fixed for CXL.
	 */
	if (ndd->cxl)
		return __le16_to_cpu(nd_label->cxl.lbasize);
	return __le64_to_cpu(nd_label->efi.lbasize);
}

static inline void nsl_set_lbasize(struct nvdimm_drvdata *ndd,
				   struct nd_namespace_label *nd_label,
				   u64 lbasize)
{
	if (ndd->cxl)
		nd_label->cxl.lbasize = __cpu_to_le16(lbasize);
	else
		nd_label->efi.lbasize = __cpu_to_le64(lbasize);
}

static inline const uuid_t *nsl_get_uuid(struct nvdimm_drvdata *ndd,
					 struct nd_namespace_label *nd_label,
					 uuid_t *uuid)
{
	if (ndd->cxl)
		import_uuid(uuid, nd_label->cxl.uuid);
	else
		import_uuid(uuid, nd_label->efi.uuid);
	return uuid;
}

static inline const uuid_t *nsl_set_uuid(struct nvdimm_drvdata *ndd,
					 struct nd_namespace_label *nd_label,
					 const uuid_t *uuid)
{
	if (ndd->cxl)
		export_uuid(nd_label->cxl.uuid, uuid);
	else
		export_uuid(nd_label->efi.uuid, uuid);
	return uuid;
}

static inline bool nsl_uuid_equal(struct nvdimm_drvdata *ndd,
				  struct nd_namespace_label *nd_label,
				  const uuid_t *uuid)
{
	uuid_t tmp;

	if (ndd->cxl)
		import_uuid(&tmp, nd_label->cxl.uuid);
	else
		import_uuid(&tmp, nd_label->efi.uuid);
	return uuid_equal(&tmp, uuid);
}

static inline const u8 *nsl_uuid_raw(struct nvdimm_drvdata *ndd,
				     struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return nd_label->cxl.uuid;
	return nd_label->efi.uuid;
}

bool nsl_validate_type_guid(struct nvdimm_drvdata *ndd,
			    struct nd_namespace_label *nd_label, guid_t *guid);
enum nvdimm_claim_class nsl_get_claim_class(struct nvdimm_drvdata *ndd,
					    struct nd_namespace_label *nd_label);

struct nd_region_data {
	int ns_count;
	int ns_active;
	unsigned int hints_shift;
	void __iomem *flush_wpq[];
};

static inline void __iomem *ndrd_get_flush_wpq(struct nd_region_data *ndrd,
		int dimm, int hint)
{
	unsigned int num = 1 << ndrd->hints_shift;
	unsigned int mask = num - 1;

	return ndrd->flush_wpq[dimm * num + (hint & mask)];
}

static inline void ndrd_set_flush_wpq(struct nd_region_data *ndrd, int dimm,
		int hint, void __iomem *flush)
{
	unsigned int num = 1 << ndrd->hints_shift;
	unsigned int mask = num - 1;

	ndrd->flush_wpq[dimm * num + (hint & mask)] = flush;
}

static inline struct nd_namespace_index *to_namespace_index(
		struct nvdimm_drvdata *ndd, int i)
{
	if (i < 0)
		return NULL;

	return ndd->data + sizeof_namespace_index(ndd) * i;
}

static inline struct nd_namespace_index *to_current_namespace_index(
		struct nvdimm_drvdata *ndd)
{
	return to_namespace_index(ndd, ndd->ns_current);
}

static inline struct nd_namespace_index *to_next_namespace_index(
		struct nvdimm_drvdata *ndd)
{
	return to_namespace_index(ndd, ndd->ns_next);
}

unsigned sizeof_namespace_label(struct nvdimm_drvdata *ndd);

#define efi_namespace_label_has(ndd, field) \
	(!ndd->cxl && offsetof(struct nvdimm_efi_label, field) \
		< sizeof_namespace_label(ndd))

#define nd_dbg_dpa(r, d, res, fmt, arg...) \
	dev_dbg((r) ? &(r)->dev : (d)->dev, "%s: %.13s: %#llx @ %#llx " fmt, \
		(r) ? dev_name((d)->dev) : "", res ? res->name : "null", \
		(unsigned long long) (res ? resource_size(res) : 0), \
		(unsigned long long) (res ? res->start : 0), ##arg)

#define for_each_dpa_resource(ndd, res) \
	for (res = (ndd)->dpa.child; res; res = res->sibling)

#define for_each_dpa_resource_safe(ndd, res, next) \
	for (res = (ndd)->dpa.child, next = res ? res->sibling : NULL; \
			res; res = next, next = next ? next->sibling : NULL)

struct nd_percpu_lane {
	int count;
	spinlock_t lock;
};

enum nd_label_flags {
	ND_LABEL_REAP,
};
struct nd_label_ent {
	struct list_head list;
	unsigned long flags;
	struct nd_namespace_label *label;
};

enum nd_mapping_lock_class {
	ND_MAPPING_CLASS0,
	ND_MAPPING_UUID_SCAN,
};

struct nd_mapping {
	struct nvdimm *nvdimm;
	u64 start;
	u64 size;
	int position;
	struct list_head labels;
	struct mutex lock;
	/*
	 * @ndd is for private use at region enable / disable time for
	 * get_ndd() + put_ndd(), all other nd_mapping to ndd
	 * conversions use to_ndd() which respects enabled state of the
	 * nvdimm.
	 */
	struct nvdimm_drvdata *ndd;
};

struct nd_region {
	struct device dev;
	struct ida ns_ida;
	struct ida btt_ida;
	struct ida pfn_ida;
	struct ida dax_ida;
	unsigned long flags;
	struct device *ns_seed;
	struct device *btt_seed;
	struct device *pfn_seed;
	struct device *dax_seed;
	unsigned long align;
	u16 ndr_mappings;
	u64 ndr_size;
	u64 ndr_start;
	int id, num_lanes, ro, numa_node, target_node;
	void *provider_data;
	struct kernfs_node *bb_state;
	struct badblocks bb;
	struct nd_interleave_set *nd_set;
	struct nd_percpu_lane __percpu *lane;
	int (*flush)(struct nd_region *nd_region, struct bio *bio);
	struct nd_mapping mapping[] __counted_by(ndr_mappings);
};

static inline bool nsl_validate_nlabel(struct nd_region *nd_region,
				       struct nvdimm_drvdata *ndd,
				       struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return true;
	return nsl_get_nlabel(ndd, nd_label) == nd_region->ndr_mappings;
}

/*
 * Lookup next in the repeating sequence of 01, 10, and 11.
 */
static inline unsigned nd_inc_seq(unsigned seq)
{
	static const unsigned next[] = { 0, 2, 3, 1 };

	return next[seq & 3];
}

struct btt;
struct nd_btt {
	struct device dev;
	struct nd_namespace_common *ndns;
	struct btt *btt;
	unsigned long lbasize;
	u64 size;
	uuid_t *uuid;
	int id;
	int initial_offset;
	u16 version_major;
	u16 version_minor;
};

enum nd_pfn_mode {
	PFN_MODE_NONE,
	PFN_MODE_RAM,
	PFN_MODE_PMEM,
};

struct nd_pfn {
	int id;
	uuid_t *uuid;
	struct device dev;
	unsigned long align;
	unsigned long npfns;
	enum nd_pfn_mode mode;
	struct nd_pfn_sb *pfn_sb;
	struct nd_namespace_common *ndns;
};

struct nd_dax {
	struct nd_pfn nd_pfn;
};

static inline u32 nd_info_block_reserve(void)
{
	return ALIGN(SZ_8K, PAGE_SIZE);
}

enum nd_async_mode {
	ND_SYNC,
	ND_ASYNC,
};

void wait_nvdimm_bus_probe_idle(struct device *dev);
void nd_device_register(struct device *dev);
void nd_device_unregister(struct device *dev, enum nd_async_mode mode);
void nd_device_notify(struct device *dev, enum nvdimm_event event);
int nd_uuid_store(struct device *dev, uuid_t **uuid_out, const char *buf,
		size_t len);
ssize_t nd_size_select_show(unsigned long current_size,
		const unsigned long *supported, char *buf);
ssize_t nd_size_select_store(struct device *dev, const char *buf,
		unsigned long *current_size, const unsigned long *supported);
int __init nvdimm_init(void);
int __init nd_region_init(void);
int __init nd_label_init(void);
void nvdimm_exit(void);
void nd_region_exit(void);
struct nvdimm;
extern const struct attribute_group nd_device_attribute_group;
extern const struct attribute_group nd_numa_attribute_group;
extern const struct attribute_group *nvdimm_bus_attribute_groups[];
struct nvdimm_drvdata *to_ndd(struct nd_mapping *nd_mapping);
int nvdimm_check_config_data(struct device *dev);
int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd);
int nvdimm_init_config_data(struct nvdimm_drvdata *ndd);
int nvdimm_get_config_data(struct nvdimm_drvdata *ndd, void *buf,
			   size_t offset, size_t len);
int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset,
		void *buf, size_t len);
long nvdimm_clear_poison(struct device *dev, phys_addr_t phys,
		unsigned int len);
void nvdimm_set_labeling(struct device *dev);
void nvdimm_set_locked(struct device *dev);
void nvdimm_clear_locked(struct device *dev);
int nvdimm_security_setup_events(struct device *dev);
#if IS_ENABLED(CONFIG_NVDIMM_KEYS)
int nvdimm_security_unlock(struct device *dev);
#else
static inline int nvdimm_security_unlock(struct device *dev)
{
	return 0;
}
#endif
struct nd_btt *to_nd_btt(struct device *dev);

struct nd_gen_sb {
	char reserved[SZ_4K - 8];
	__le64 checksum;
};

u64 nd_sb_checksum(struct nd_gen_sb *sb);
#if IS_ENABLED(CONFIG_BTT)
int nd_btt_probe(struct device *dev, struct nd_namespace_common *ndns);
bool is_nd_btt(struct device *dev);
struct device *nd_btt_create(struct nd_region *nd_region);
#else
static inline int nd_btt_probe(struct device *dev,
		struct nd_namespace_common *ndns)
{
	return -ENODEV;
}

static inline bool is_nd_btt(struct device *dev)
{
	return false;
}

static inline struct device *nd_btt_create(struct nd_region *nd_region)
{
	return NULL;
}
#endif

struct nd_pfn *to_nd_pfn(struct device *dev);
#if IS_ENABLED(CONFIG_NVDIMM_PFN)

#define MAX_NVDIMM_ALIGN	4

int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns);
bool is_nd_pfn(struct device *dev);
struct device *nd_pfn_create(struct nd_region *nd_region);
struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
		struct nd_namespace_common *ndns);
int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig);
extern const struct attribute_group *nd_pfn_attribute_groups[];
#else
static inline int nd_pfn_probe(struct device *dev,
		struct nd_namespace_common *ndns)
{
	return -ENODEV;
}

static inline bool is_nd_pfn(struct device *dev)
{
	return false;
}

static inline struct device *nd_pfn_create(struct nd_region *nd_region)
{
	return NULL;
}

static inline int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig)
{
	return -ENODEV;
}
#endif

struct nd_dax *to_nd_dax(struct device *dev);
#if IS_ENABLED(CONFIG_NVDIMM_DAX)
int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns);
bool is_nd_dax(const struct device *dev);
struct device *nd_dax_create(struct nd_region *nd_region);
#else
static inline int nd_dax_probe(struct device *dev,
		struct nd_namespace_common *ndns)
{
	return -ENODEV;
}

static inline bool is_nd_dax(const struct device *dev)
{
	return false;
}

static inline struct device *nd_dax_create(struct nd_region *nd_region)
{
	return NULL;
}
#endif

int nd_region_to_nstype(struct nd_region *nd_region);
int nd_region_register_namespaces(struct nd_region *nd_region, int *err);
u64 nd_region_interleave_set_cookie(struct nd_region *nd_region,
		struct nd_namespace_index *nsindex);
u64 nd_region_interleave_set_altcookie(struct nd_region *nd_region);
void nvdimm_bus_lock(struct device *dev);
void nvdimm_bus_unlock(struct device *dev);
bool is_nvdimm_bus_locked(struct device *dev);
void nvdimm_check_and_set_ro(struct gendisk *disk);
void nvdimm_drvdata_release(struct kref *kref);
void put_ndd(struct nvdimm_drvdata *ndd);
int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd);
void nvdimm_free_dpa(struct nvdimm_drvdata *ndd, struct resource *res);
struct resource *nvdimm_allocate_dpa(struct nvdimm_drvdata *ndd,
		struct nd_label_id *label_id, resource_size_t start,
		resource_size_t n);
resource_size_t nvdimm_namespace_capacity(struct nd_namespace_common *ndns);
bool nvdimm_namespace_locked(struct nd_namespace_common *ndns);
struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev);
int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns);
int nvdimm_namespace_detach_btt(struct nd_btt *nd_btt);
const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns,
		char *name);
unsigned int pmem_sector_size(struct nd_namespace_common *ndns);
struct range;
void nvdimm_badblocks_populate(struct nd_region *nd_region,
		struct badblocks *bb, const struct range *range);
int devm_namespace_enable(struct device *dev, struct nd_namespace_common *ndns,
		resource_size_t size);
void devm_namespace_disable(struct device *dev,
		struct nd_namespace_common *ndns);
#if IS_ENABLED(CONFIG_ND_CLAIM)
/* max struct page size independent of kernel config */
#define MAX_STRUCT_PAGE_SIZE 64
int nvdimm_setup_pfn(struct nd_pfn *nd_pfn, struct dev_pagemap *pgmap);
#else
static inline int nvdimm_setup_pfn(struct nd_pfn *nd_pfn,
				   struct dev_pagemap *pgmap)
{
	return -ENXIO;
}
#endif
int nd_region_activate(struct nd_region *nd_region);
static inline bool is_bad_pmem(struct badblocks *bb, sector_t sector,
		unsigned int len)
{
	if (bb->count) {
		sector_t first_bad;
		int num_bad;

		return !!badblocks_check(bb, sector, len / 512, &first_bad,
				&num_bad);
	}

	return false;
}
const uuid_t *nd_dev_to_uuid(struct device *dev);
bool pmem_should_map_pages(struct device *dev);
#endif /* __ND_H__ */
