// SPDX-License-Identifier: GPL-2.0
/*
 * configfs to configure the PCI endpoint
 *
 * Copyright (C) 2017 Texas Instruments
 * Author: Kishon Vijay Abraham I <kishon@ti.com>
 */

#include <linux/module.h>
#include <linux/idr.h>
#include <linux/slab.h>

#include <linux/pci-epc.h>
#include <linux/pci-epf.h>
#include <linux/pci-ep-cfs.h>

static DEFINE_IDR(functions_idr);
static DEFINE_MUTEX(functions_mutex);
static struct config_group *functions_group;
static struct config_group *controllers_group;

struct pci_epf_group {
	struct config_group group;
	struct config_group primary_epc_group;
	struct config_group secondary_epc_group;
	struct delayed_work cfs_work;
	struct pci_epf *epf;
	int index;
};

struct pci_epc_group {
	struct config_group group;
	struct pci_epc *epc;
	bool start;
};

static inline struct pci_epf_group *to_pci_epf_group(struct config_item *item)
{
	return container_of(to_config_group(item), struct pci_epf_group, group);
}

static inline struct pci_epc_group *to_pci_epc_group(struct config_item *item)
{
	return container_of(to_config_group(item), struct pci_epc_group, group);
}

static int pci_secondary_epc_epf_link(struct config_item *epf_item,
				      struct config_item *epc_item)
{
	int ret;
	struct pci_epf_group *epf_group = to_pci_epf_group(epf_item->ci_parent);
	struct pci_epc_group *epc_group = to_pci_epc_group(epc_item);
	struct pci_epc *epc = epc_group->epc;
	struct pci_epf *epf = epf_group->epf;

	ret = pci_epc_add_epf(epc, epf, SECONDARY_INTERFACE);
	if (ret)
		return ret;

	ret = pci_epf_bind(epf);
	if (ret) {
		pci_epc_remove_epf(epc, epf, SECONDARY_INTERFACE);
		return ret;
	}

	/* Send any pending EPC initialization complete to the EPF driver */
	pci_epc_notify_pending_init(epc, epf);

	return 0;
}

static void pci_secondary_epc_epf_unlink(struct config_item *epc_item,
					 struct config_item *epf_item)
{
	struct pci_epf_group *epf_group = to_pci_epf_group(epf_item->ci_parent);
	struct pci_epc_group *epc_group = to_pci_epc_group(epc_item);
	struct pci_epc *epc;
	struct pci_epf *epf;

	WARN_ON_ONCE(epc_group->start);

	epc = epc_group->epc;
	epf = epf_group->epf;
	pci_epf_unbind(epf);
	pci_epc_remove_epf(epc, epf, SECONDARY_INTERFACE);
}

static struct configfs_item_operations pci_secondary_epc_item_ops = {
	.allow_link	= pci_secondary_epc_epf_link,
	.drop_link	= pci_secondary_epc_epf_unlink,
};

static const struct config_item_type pci_secondary_epc_type = {
	.ct_item_ops	= &pci_secondary_epc_item_ops,
	.ct_owner	= THIS_MODULE,
};

static struct config_group
*pci_ep_cfs_add_secondary_group(struct pci_epf_group *epf_group)
{
	struct config_group *secondary_epc_group;

	secondary_epc_group = &epf_group->secondary_epc_group;
	config_group_init_type_name(secondary_epc_group, "secondary",
				    &pci_secondary_epc_type);
	configfs_register_group(&epf_group->group, secondary_epc_group);

	return secondary_epc_group;
}

static int pci_primary_epc_epf_link(struct config_item *epf_item,
				    struct config_item *epc_item)
{
	int ret;
	struct pci_epf_group *epf_group = to_pci_epf_group(epf_item->ci_parent);
	struct pci_epc_group *epc_group = to_pci_epc_group(epc_item);
	struct pci_epc *epc = epc_group->epc;
	struct pci_epf *epf = epf_group->epf;

	ret = pci_epc_add_epf(epc, epf, PRIMARY_INTERFACE);
	if (ret)
		return ret;

	ret = pci_epf_bind(epf);
	if (ret) {
		pci_epc_remove_epf(epc, epf, PRIMARY_INTERFACE);
		return ret;
	}

	/* Send any pending EPC initialization complete to the EPF driver */
	pci_epc_notify_pending_init(epc, epf);

	return 0;
}

static void pci_primary_epc_epf_unlink(struct config_item *epc_item,
				       struct config_item *epf_item)
{
	struct pci_epf_group *epf_group = to_pci_epf_group(epf_item->ci_parent);
	struct pci_epc_group *epc_group = to_pci_epc_group(epc_item);
	struct pci_epc *epc;
	struct pci_epf *epf;

	WARN_ON_ONCE(epc_group->start);

	epc = epc_group->epc;
	epf = epf_group->epf;
	pci_epf_unbind(epf);
	pci_epc_remove_epf(epc, epf, PRIMARY_INTERFACE);
}

static struct configfs_item_operations pci_primary_epc_item_ops = {
	.allow_link	= pci_primary_epc_epf_link,
	.drop_link	= pci_primary_epc_epf_unlink,
};

static const struct config_item_type pci_primary_epc_type = {
	.ct_item_ops	= &pci_primary_epc_item_ops,
	.ct_owner	= THIS_MODULE,
};

static struct config_group
*pci_ep_cfs_add_primary_group(struct pci_epf_group *epf_group)
{
	struct config_group *primary_epc_group = &epf_group->primary_epc_group;

	config_group_init_type_name(primary_epc_group, "primary",
				    &pci_primary_epc_type);
	configfs_register_group(&epf_group->group, primary_epc_group);

	return primary_epc_group;
}

static ssize_t pci_epc_start_store(struct config_item *item, const char *page,
				   size_t len)
{
	int ret;
	bool start;
	struct pci_epc *epc;
	struct pci_epc_group *epc_group = to_pci_epc_group(item);

	epc = epc_group->epc;

	if (kstrtobool(page, &start) < 0)
		return -EINVAL;

	if (start == epc_group->start)
		return -EALREADY;

	if (!start) {
		pci_epc_stop(epc);
		epc_group->start = 0;
		return len;
	}

	ret = pci_epc_start(epc);
	if (ret) {
		dev_err(&epc->dev, "failed to start endpoint controller\n");
		return -EINVAL;
	}

	epc_group->start = start;

	return len;
}

static ssize_t pci_epc_start_show(struct config_item *item, char *page)
{
	return sysfs_emit(page, "%d\n", to_pci_epc_group(item)->start);
}

CONFIGFS_ATTR(pci_epc_, start);

static struct configfs_attribute *pci_epc_attrs[] = {
	&pci_epc_attr_start,
	NULL,
};

static int pci_epc_epf_link(struct config_item *epc_item,
			    struct config_item *epf_item)
{
	int ret;
	struct pci_epf_group *epf_group = to_pci_epf_group(epf_item);
	struct pci_epc_group *epc_group = to_pci_epc_group(epc_item);
	struct pci_epc *epc = epc_group->epc;
	struct pci_epf *epf = epf_group->epf;

	ret = pci_epc_add_epf(epc, epf, PRIMARY_INTERFACE);
	if (ret)
		return ret;

	ret = pci_epf_bind(epf);
	if (ret) {
		pci_epc_remove_epf(epc, epf, PRIMARY_INTERFACE);
		return ret;
	}

	/* Send any pending EPC initialization complete to the EPF driver */
	pci_epc_notify_pending_init(epc, epf);

	return 0;
}

static void pci_epc_epf_unlink(struct config_item *epc_item,
			       struct config_item *epf_item)
{
	struct pci_epc *epc;
	struct pci_epf *epf;
	struct pci_epf_group *epf_group = to_pci_epf_group(epf_item);
	struct pci_epc_group *epc_group = to_pci_epc_group(epc_item);

	WARN_ON_ONCE(epc_group->start);

	epc = epc_group->epc;
	epf = epf_group->epf;
	pci_epf_unbind(epf);
	pci_epc_remove_epf(epc, epf, PRIMARY_INTERFACE);
}

static struct configfs_item_operations pci_epc_item_ops = {
	.allow_link	= pci_epc_epf_link,
	.drop_link	= pci_epc_epf_unlink,
};

static const struct config_item_type pci_epc_type = {
	.ct_item_ops	= &pci_epc_item_ops,
	.ct_attrs	= pci_epc_attrs,
	.ct_owner	= THIS_MODULE,
};

struct config_group *pci_ep_cfs_add_epc_group(const char *name)
{
	int ret;
	struct pci_epc *epc;
	struct config_group *group;
	struct pci_epc_group *epc_group;

	epc_group = kzalloc(sizeof(*epc_group), GFP_KERNEL);
	if (!epc_group) {
		ret = -ENOMEM;
		goto err;
	}

	group = &epc_group->group;

	config_group_init_type_name(group, name, &pci_epc_type);
	ret = configfs_register_group(controllers_group, group);
	if (ret) {
		pr_err("failed to register configfs group for %s\n", name);
		goto err_register_group;
	}

	epc = pci_epc_get(name);
	if (IS_ERR(epc)) {
		ret = PTR_ERR(epc);
		goto err_epc_get;
	}

	epc_group->epc = epc;

	return group;

err_epc_get:
	configfs_unregister_group(group);

err_register_group:
	kfree(epc_group);

err:
	return ERR_PTR(ret);
}
EXPORT_SYMBOL(pci_ep_cfs_add_epc_group);

void pci_ep_cfs_remove_epc_group(struct config_group *group)
{
	struct pci_epc_group *epc_group;

	if (!group)
		return;

	epc_group = container_of(group, struct pci_epc_group, group);
	pci_epc_put(epc_group->epc);
	configfs_unregister_group(&epc_group->group);
	kfree(epc_group);
}
EXPORT_SYMBOL(pci_ep_cfs_remove_epc_group);

#define PCI_EPF_HEADER_R(_name)						       \
static ssize_t pci_epf_##_name##_show(struct config_item *item,	char *page)    \
{									       \
	struct pci_epf *epf = to_pci_epf_group(item)->epf;		       \
	if (WARN_ON_ONCE(!epf->header))					       \
		return -EINVAL;						       \
	return sysfs_emit(page, "0x%04x\n", epf->header->_name);	       \
}

#define PCI_EPF_HEADER_W_u32(_name)					       \
static ssize_t pci_epf_##_name##_store(struct config_item *item,	       \
				       const char *page, size_t len)	       \
{									       \
	u32 val;							       \
	struct pci_epf *epf = to_pci_epf_group(item)->epf;		       \
	if (WARN_ON_ONCE(!epf->header))					       \
		return -EINVAL;						       \
	if (kstrtou32(page, 0, &val) < 0)				       \
		return -EINVAL;						       \
	epf->header->_name = val;					       \
	return len;							       \
}

#define PCI_EPF_HEADER_W_u16(_name)					       \
static ssize_t pci_epf_##_name##_store(struct config_item *item,	       \
				       const char *page, size_t len)	       \
{									       \
	u16 val;							       \
	struct pci_epf *epf = to_pci_epf_group(item)->epf;		       \
	if (WARN_ON_ONCE(!epf->header))					       \
		return -EINVAL;						       \
	if (kstrtou16(page, 0, &val) < 0)				       \
		return -EINVAL;						       \
	epf->header->_name = val;					       \
	return len;							       \
}

#define PCI_EPF_HEADER_W_u8(_name)					       \
static ssize_t pci_epf_##_name##_store(struct config_item *item,	       \
				       const char *page, size_t len)	       \
{									       \
	u8 val;								       \
	struct pci_epf *epf = to_pci_epf_group(item)->epf;		       \
	if (WARN_ON_ONCE(!epf->header))					       \
		return -EINVAL;						       \
	if (kstrtou8(page, 0, &val) < 0)				       \
		return -EINVAL;						       \
	epf->header->_name = val;					       \
	return len;							       \
}

static ssize_t pci_epf_msi_interrupts_store(struct config_item *item,
					    const char *page, size_t len)
{
	u8 val;

	if (kstrtou8(page, 0, &val) < 0)
		return -EINVAL;

	to_pci_epf_group(item)->epf->msi_interrupts = val;

	return len;
}

static ssize_t pci_epf_msi_interrupts_show(struct config_item *item,
					   char *page)
{
	return sysfs_emit(page, "%d\n",
			  to_pci_epf_group(item)->epf->msi_interrupts);
}

static ssize_t pci_epf_msix_interrupts_store(struct config_item *item,
					     const char *page, size_t len)
{
	u16 val;

	if (kstrtou16(page, 0, &val) < 0)
		return -EINVAL;

	to_pci_epf_group(item)->epf->msix_interrupts = val;

	return len;
}

static ssize_t pci_epf_msix_interrupts_show(struct config_item *item,
					    char *page)
{
	return sysfs_emit(page, "%d\n",
			  to_pci_epf_group(item)->epf->msix_interrupts);
}

PCI_EPF_HEADER_R(vendorid)
PCI_EPF_HEADER_W_u16(vendorid)

PCI_EPF_HEADER_R(deviceid)
PCI_EPF_HEADER_W_u16(deviceid)

PCI_EPF_HEADER_R(revid)
PCI_EPF_HEADER_W_u8(revid)

PCI_EPF_HEADER_R(progif_code)
PCI_EPF_HEADER_W_u8(progif_code)

PCI_EPF_HEADER_R(subclass_code)
PCI_EPF_HEADER_W_u8(subclass_code)

PCI_EPF_HEADER_R(baseclass_code)
PCI_EPF_HEADER_W_u8(baseclass_code)

PCI_EPF_HEADER_R(cache_line_size)
PCI_EPF_HEADER_W_u8(cache_line_size)

PCI_EPF_HEADER_R(subsys_vendor_id)
PCI_EPF_HEADER_W_u16(subsys_vendor_id)

PCI_EPF_HEADER_R(subsys_id)
PCI_EPF_HEADER_W_u16(subsys_id)

PCI_EPF_HEADER_R(interrupt_pin)
PCI_EPF_HEADER_W_u8(interrupt_pin)

CONFIGFS_ATTR(pci_epf_, vendorid);
CONFIGFS_ATTR(pci_epf_, deviceid);
CONFIGFS_ATTR(pci_epf_, revid);
CONFIGFS_ATTR(pci_epf_, progif_code);
CONFIGFS_ATTR(pci_epf_, subclass_code);
CONFIGFS_ATTR(pci_epf_, baseclass_code);
CONFIGFS_ATTR(pci_epf_, cache_line_size);
CONFIGFS_ATTR(pci_epf_, subsys_vendor_id);
CONFIGFS_ATTR(pci_epf_, subsys_id);
CONFIGFS_ATTR(pci_epf_, interrupt_pin);
CONFIGFS_ATTR(pci_epf_, msi_interrupts);
CONFIGFS_ATTR(pci_epf_, msix_interrupts);

static struct configfs_attribute *pci_epf_attrs[] = {
	&pci_epf_attr_vendorid,
	&pci_epf_attr_deviceid,
	&pci_epf_attr_revid,
	&pci_epf_attr_progif_code,
	&pci_epf_attr_subclass_code,
	&pci_epf_attr_baseclass_code,
	&pci_epf_attr_cache_line_size,
	&pci_epf_attr_subsys_vendor_id,
	&pci_epf_attr_subsys_id,
	&pci_epf_attr_interrupt_pin,
	&pci_epf_attr_msi_interrupts,
	&pci_epf_attr_msix_interrupts,
	NULL,
};

static int pci_epf_vepf_link(struct config_item *epf_pf_item,
			     struct config_item *epf_vf_item)
{
	struct pci_epf_group *epf_vf_group = to_pci_epf_group(epf_vf_item);
	struct pci_epf_group *epf_pf_group = to_pci_epf_group(epf_pf_item);
	struct pci_epf *epf_pf = epf_pf_group->epf;
	struct pci_epf *epf_vf = epf_vf_group->epf;

	return pci_epf_add_vepf(epf_pf, epf_vf);
}

static void pci_epf_vepf_unlink(struct config_item *epf_pf_item,
				struct config_item *epf_vf_item)
{
	struct pci_epf_group *epf_vf_group = to_pci_epf_group(epf_vf_item);
	struct pci_epf_group *epf_pf_group = to_pci_epf_group(epf_pf_item);
	struct pci_epf *epf_pf = epf_pf_group->epf;
	struct pci_epf *epf_vf = epf_vf_group->epf;

	pci_epf_remove_vepf(epf_pf, epf_vf);
}

static void pci_epf_release(struct config_item *item)
{
	struct pci_epf_group *epf_group = to_pci_epf_group(item);

	mutex_lock(&functions_mutex);
	idr_remove(&functions_idr, epf_group->index);
	mutex_unlock(&functions_mutex);
	pci_epf_destroy(epf_group->epf);
	kfree(epf_group);
}

static struct configfs_item_operations pci_epf_ops = {
	.allow_link		= pci_epf_vepf_link,
	.drop_link		= pci_epf_vepf_unlink,
	.release		= pci_epf_release,
};

static const struct config_item_type pci_epf_type = {
	.ct_item_ops	= &pci_epf_ops,
	.ct_attrs	= pci_epf_attrs,
	.ct_owner	= THIS_MODULE,
};

/**
 * pci_epf_type_add_cfs() - Help function drivers to expose function specific
 *                          attributes in configfs
 * @epf: the EPF device that has to be configured using configfs
 * @group: the parent configfs group (corresponding to entries in
 *         pci_epf_device_id)
 *
 * Invoke to expose function specific attributes in configfs.
 *
 * Return: A pointer to a config_group structure or NULL if the function driver
 * does not have anything to expose (attributes configured by user) or if
 * the function driver does not implement the add_cfs() method.
 *
 * Returns an error pointer if this function is called for an unbound EPF device
 * or if the EPF driver add_cfs() method fails.
 */
static struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf,
						 struct config_group *group)
{
	struct config_group *epf_type_group;

	if (!epf->driver) {
		dev_err(&epf->dev, "epf device not bound to driver\n");
		return ERR_PTR(-ENODEV);
	}

	if (!epf->driver->ops->add_cfs)
		return NULL;

	mutex_lock(&epf->lock);
	epf_type_group = epf->driver->ops->add_cfs(epf, group);
	mutex_unlock(&epf->lock);

	return epf_type_group;
}

static void pci_ep_cfs_add_type_group(struct pci_epf_group *epf_group)
{
	struct config_group *group;

	group = pci_epf_type_add_cfs(epf_group->epf, &epf_group->group);
	if (!group)
		return;

	if (IS_ERR(group)) {
		dev_err(&epf_group->epf->dev,
			"failed to create epf type specific attributes\n");
		return;
	}

	configfs_register_group(&epf_group->group, group);
}

static void pci_epf_cfs_work(struct work_struct *work)
{
	struct pci_epf_group *epf_group;
	struct config_group *group;

	epf_group = container_of(work, struct pci_epf_group, cfs_work.work);
	group = pci_ep_cfs_add_primary_group(epf_group);
	if (IS_ERR(group)) {
		pr_err("failed to create 'primary' EPC interface\n");
		return;
	}

	group = pci_ep_cfs_add_secondary_group(epf_group);
	if (IS_ERR(group)) {
		pr_err("failed to create 'secondary' EPC interface\n");
		return;
	}

	pci_ep_cfs_add_type_group(epf_group);
}

static struct config_group *pci_epf_make(struct config_group *group,
					 const char *name)
{
	struct pci_epf_group *epf_group;
	struct pci_epf *epf;
	char *epf_name;
	int index, err;

	epf_group = kzalloc(sizeof(*epf_group), GFP_KERNEL);
	if (!epf_group)
		return ERR_PTR(-ENOMEM);

	mutex_lock(&functions_mutex);
	index = idr_alloc(&functions_idr, epf_group, 0, 0, GFP_KERNEL);
	mutex_unlock(&functions_mutex);
	if (index < 0) {
		err = index;
		goto free_group;
	}

	epf_group->index = index;

	config_group_init_type_name(&epf_group->group, name, &pci_epf_type);

	epf_name = kasprintf(GFP_KERNEL, "%s.%d",
			     group->cg_item.ci_name, epf_group->index);
	if (!epf_name) {
		err = -ENOMEM;
		goto remove_idr;
	}

	epf = pci_epf_create(epf_name);
	if (IS_ERR(epf)) {
		pr_err("failed to create endpoint function device\n");
		err = -EINVAL;
		goto free_name;
	}

	epf->group = &epf_group->group;
	epf_group->epf = epf;

	kfree(epf_name);

	INIT_DELAYED_WORK(&epf_group->cfs_work, pci_epf_cfs_work);
	queue_delayed_work(system_wq, &epf_group->cfs_work,
			   msecs_to_jiffies(1));

	return &epf_group->group;

free_name:
	kfree(epf_name);

remove_idr:
	mutex_lock(&functions_mutex);
	idr_remove(&functions_idr, epf_group->index);
	mutex_unlock(&functions_mutex);

free_group:
	kfree(epf_group);

	return ERR_PTR(err);
}

static void pci_epf_drop(struct config_group *group, struct config_item *item)
{
	config_item_put(item);
}

static struct configfs_group_operations pci_epf_group_ops = {
	.make_group     = &pci_epf_make,
	.drop_item      = &pci_epf_drop,
};

static const struct config_item_type pci_epf_group_type = {
	.ct_group_ops	= &pci_epf_group_ops,
	.ct_owner	= THIS_MODULE,
};

struct config_group *pci_ep_cfs_add_epf_group(const char *name)
{
	struct config_group *group;

	group = configfs_register_default_group(functions_group, name,
						&pci_epf_group_type);
	if (IS_ERR(group))
		pr_err("failed to register configfs group for %s function\n",
		       name);

	return group;
}
EXPORT_SYMBOL(pci_ep_cfs_add_epf_group);

void pci_ep_cfs_remove_epf_group(struct config_group *group)
{
	if (IS_ERR_OR_NULL(group))
		return;

	configfs_unregister_default_group(group);
}
EXPORT_SYMBOL(pci_ep_cfs_remove_epf_group);

static const struct config_item_type pci_functions_type = {
	.ct_owner	= THIS_MODULE,
};

static const struct config_item_type pci_controllers_type = {
	.ct_owner	= THIS_MODULE,
};

static const struct config_item_type pci_ep_type = {
	.ct_owner	= THIS_MODULE,
};

static struct configfs_subsystem pci_ep_cfs_subsys = {
	.su_group = {
		.cg_item = {
			.ci_namebuf = "pci_ep",
			.ci_type = &pci_ep_type,
		},
	},
	.su_mutex = __MUTEX_INITIALIZER(pci_ep_cfs_subsys.su_mutex),
};

static int __init pci_ep_cfs_init(void)
{
	int ret;
	struct config_group *root = &pci_ep_cfs_subsys.su_group;

	config_group_init(root);

	ret = configfs_register_subsystem(&pci_ep_cfs_subsys);
	if (ret) {
		pr_err("Error %d while registering subsystem %s\n",
		       ret, root->cg_item.ci_namebuf);
		goto err;
	}

	functions_group = configfs_register_default_group(root, "functions",
							  &pci_functions_type);
	if (IS_ERR(functions_group)) {
		ret = PTR_ERR(functions_group);
		pr_err("Error %d while registering functions group\n",
		       ret);
		goto err_functions_group;
	}

	controllers_group =
		configfs_register_default_group(root, "controllers",
						&pci_controllers_type);
	if (IS_ERR(controllers_group)) {
		ret = PTR_ERR(controllers_group);
		pr_err("Error %d while registering controllers group\n",
		       ret);
		goto err_controllers_group;
	}

	return 0;

err_controllers_group:
	configfs_unregister_default_group(functions_group);

err_functions_group:
	configfs_unregister_subsystem(&pci_ep_cfs_subsys);

err:
	return ret;
}
module_init(pci_ep_cfs_init);

static void __exit pci_ep_cfs_exit(void)
{
	configfs_unregister_default_group(controllers_group);
	configfs_unregister_default_group(functions_group);
	configfs_unregister_subsystem(&pci_ep_cfs_subsys);
}
module_exit(pci_ep_cfs_exit);

MODULE_DESCRIPTION("PCI EP CONFIGFS");
MODULE_AUTHOR("Kishon Vijay Abraham I <kishon@ti.com>");
