linux/drivers/scsi/fcoe/fcoe_sysfs.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright(c) 2011 - 2012 Intel Corporation. All rights reserved.
 *
 * Maintained at www.Open-FCoE.org
 */

#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/etherdevice.h>
#include <linux/ctype.h>
#include <linux/string.h>

#include <scsi/fcoe_sysfs.h>
#include <scsi/libfcoe.h>

/*
 * OK to include local libfcoe.h for debug_logging, but cannot include
 * <scsi/libfcoe.h> otherwise non-netdev based fcoe solutions would have
 * have to include more than fcoe_sysfs.h.
 */
#include "libfcoe.h"

static atomic_t ctlr_num;
static atomic_t fcf_num;

/*
 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
 * should insulate the loss of a fcf.
 */
static unsigned int fcoe_fcf_dev_loss_tmo =;  /* seconds */

module_param_named(fcf_dev_loss_tmo, fcoe_fcf_dev_loss_tmo,
		   uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC();

/*
 * These are used by the fcoe_*_show_function routines, they
 * are intentionally placed in the .c file as they're not intended
 * for use throughout the code.
 */
#define fcoe_ctlr_id(x)
#define fcoe_ctlr_work_q_name(x)
#define fcoe_ctlr_work_q(x)
#define fcoe_ctlr_devloss_work_q_name(x)
#define fcoe_ctlr_devloss_work_q(x)
#define fcoe_ctlr_mode(x)
#define fcoe_ctlr_fcf_dev_loss_tmo(x)
#define fcoe_ctlr_link_fail(x)
#define fcoe_ctlr_vlink_fail(x)
#define fcoe_ctlr_miss_fka(x)
#define fcoe_ctlr_symb_err(x)
#define fcoe_ctlr_err_block(x)
#define fcoe_ctlr_fcs_error(x)
#define fcoe_ctlr_enabled(x)
#define fcoe_fcf_state(x)
#define fcoe_fcf_fabric_name(x)
#define fcoe_fcf_switch_name(x)
#define fcoe_fcf_fc_map(x)
#define fcoe_fcf_vfid(x)
#define fcoe_fcf_mac(x)
#define fcoe_fcf_priority(x)
#define fcoe_fcf_fka_period(x)
#define fcoe_fcf_dev_loss_tmo(x)
#define fcoe_fcf_selected(x)
#define fcoe_fcf_vlan_id(x)

/*
 * dev_loss_tmo attribute
 */
static int fcoe_str_to_dev_loss(const char *buf, unsigned long *val)
{}

static int fcoe_fcf_set_dev_loss_tmo(struct fcoe_fcf_device *fcf,
				     unsigned long val)
{}

#define FCOE_DEVICE_ATTR(_prefix, _name, _mode, _show, _store)

#define fcoe_ctlr_show_function(field, format_string, sz, cast)

#define fcoe_fcf_show_function(field, format_string, sz, cast)

#define fcoe_ctlr_private_show_function(field, format_string, sz, cast)

#define fcoe_fcf_private_show_function(field, format_string, sz, cast)

#define fcoe_ctlr_private_rd_attr(field, format_string, sz)

#define fcoe_ctlr_rd_attr(field, format_string, sz)

#define fcoe_fcf_rd_attr(field, format_string, sz)

#define fcoe_fcf_private_rd_attr(field, format_string, sz)

#define fcoe_ctlr_private_rd_attr_cast(field, format_string, sz, cast)

#define fcoe_fcf_private_rd_attr_cast(field, format_string, sz, cast)

#define fcoe_enum_name_search(title, table_type, table)

static const char * const fip_conn_type_names[] =;
fcoe_enum_name_search(ctlr_mode, fip_conn_type, fip_conn_type_names)

static char *fcf_state_names[] =;
fcoe_enum_name_search(fcf_state, fcf_state, fcf_state_names)
#define FCOE_FCF_STATE_MAX_NAMELEN

static ssize_t show_fcf_state(struct device *dev,
			      struct device_attribute *attr,
			      char *buf)
{}
static FCOE_DEVICE_ATTR(fcf, state, S_IRUGO, show_fcf_state, NULL);

#define FCOE_MAX_MODENAME_LEN
static ssize_t show_ctlr_mode(struct device *dev,
			      struct device_attribute *attr,
			      char *buf)
{}

static ssize_t store_ctlr_mode(struct device *dev,
			       struct device_attribute *attr,
			       const char *buf, size_t count)
{}

static FCOE_DEVICE_ATTR(ctlr, mode, S_IRUGO | S_IWUSR,
			show_ctlr_mode, store_ctlr_mode);

static ssize_t store_ctlr_enabled(struct device *dev,
				  struct device_attribute *attr,
				  const char *buf, size_t count)
{}

static char *ctlr_enabled_state_names[] =;
fcoe_enum_name_search(ctlr_enabled_state, ctlr_enabled_state,
		      ctlr_enabled_state_names)
#define FCOE_CTLR_ENABLED_MAX_NAMELEN

static ssize_t show_ctlr_enabled_state(struct device *dev,
				       struct device_attribute *attr,
				       char *buf)
{}

static FCOE_DEVICE_ATTR(ctlr, enabled, S_IRUGO | S_IWUSR,
			show_ctlr_enabled_state,
			store_ctlr_enabled);

static ssize_t store_ctlr_fip_resp(struct device *dev,
			      struct device_attribute *attr,
			      const char *buf, size_t count)
{}

static ssize_t show_ctlr_fip_resp(struct device *dev,
				  struct device_attribute *attr,
				  char *buf)
{}

static FCOE_DEVICE_ATTR(ctlr, fip_vlan_responder, S_IRUGO | S_IWUSR,
			show_ctlr_fip_resp,
			store_ctlr_fip_resp);

static ssize_t
fcoe_ctlr_var_store(u32 *var, const char *buf, size_t count)
{}

static ssize_t store_ctlr_r_a_tov(struct device *dev,
				  struct device_attribute *attr,
				  const char *buf, size_t count)
{}

static ssize_t show_ctlr_r_a_tov(struct device *dev,
				 struct device_attribute *attr,
				 char *buf)
{}

static FCOE_DEVICE_ATTR(ctlr, r_a_tov, S_IRUGO | S_IWUSR,
			show_ctlr_r_a_tov, store_ctlr_r_a_tov);

static ssize_t store_ctlr_e_d_tov(struct device *dev,
				  struct device_attribute *attr,
				  const char *buf, size_t count)
{}

static ssize_t show_ctlr_e_d_tov(struct device *dev,
				 struct device_attribute *attr,
				 char *buf)
{}

static FCOE_DEVICE_ATTR(ctlr, e_d_tov, S_IRUGO | S_IWUSR,
			show_ctlr_e_d_tov, store_ctlr_e_d_tov);

static ssize_t
store_private_fcoe_ctlr_fcf_dev_loss_tmo(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf, size_t count)
{}
fcoe_ctlr_private_show_function(fcf_dev_loss_tmo, "%d\n", 20, );
static FCOE_DEVICE_ATTR(ctlr, fcf_dev_loss_tmo, S_IRUGO | S_IWUSR,
			show_fcoe_ctlr_device_fcf_dev_loss_tmo,
			store_private_fcoe_ctlr_fcf_dev_loss_tmo);

/* Link Error Status Block (LESB) */
fcoe_ctlr_rd_attr();
fcoe_ctlr_rd_attr();
fcoe_ctlr_rd_attr();
fcoe_ctlr_rd_attr();
fcoe_ctlr_rd_attr();
fcoe_ctlr_rd_attr();

fcoe_fcf_private_rd_attr_cast();
fcoe_fcf_private_rd_attr_cast();
fcoe_fcf_private_rd_attr();
fcoe_fcf_private_rd_attr();
fcoe_fcf_private_rd_attr();
fcoe_fcf_private_rd_attr();
fcoe_fcf_private_rd_attr();
fcoe_fcf_rd_attr();
fcoe_fcf_rd_attr();

fcoe_fcf_private_show_function()
static ssize_t
store_fcoe_fcf_dev_loss_tmo(struct device *dev, struct device_attribute *attr,
			    const char *buf, size_t count)
{}
static FCOE_DEVICE_ATTR(fcf, dev_loss_tmo, S_IRUGO | S_IWUSR,
			show_fcoe_fcf_device_dev_loss_tmo,
			store_fcoe_fcf_dev_loss_tmo);

static struct attribute *fcoe_ctlr_lesb_attrs[] =;

static struct attribute_group fcoe_ctlr_lesb_attr_group =;

static struct attribute *fcoe_ctlr_attrs[] =;

static struct attribute_group fcoe_ctlr_attr_group =;

static const struct attribute_group *fcoe_ctlr_attr_groups[] =;

static struct attribute *fcoe_fcf_attrs[] =;

static struct attribute_group fcoe_fcf_attr_group =;

static const struct attribute_group *fcoe_fcf_attr_groups[] =;

static const struct bus_type fcoe_bus_type;

static int fcoe_bus_match(struct device *dev,
			  const struct device_driver *drv)
{}

/**
 * fcoe_ctlr_device_release() - Release the FIP ctlr memory
 * @dev: Pointer to the FIP ctlr's embedded device
 *
 * Called when the last FIP ctlr reference is released.
 */
static void fcoe_ctlr_device_release(struct device *dev)
{}

/**
 * fcoe_fcf_device_release() - Release the FIP fcf memory
 * @dev: Pointer to the fcf's embedded device
 *
 * Called when the last FIP fcf reference is released.
 */
static void fcoe_fcf_device_release(struct device *dev)
{}

static const struct device_type fcoe_ctlr_device_type =;

static const struct device_type fcoe_fcf_device_type =;

static ssize_t ctlr_create_store(const struct bus_type *bus, const char *buf,
				 size_t count)
{}
static BUS_ATTR_WO(ctlr_create);

static ssize_t ctlr_destroy_store(const struct bus_type *bus, const char *buf,
				  size_t count)
{}
static BUS_ATTR_WO(ctlr_destroy);

static struct attribute *fcoe_bus_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct bus_type fcoe_bus_type =;

/**
 * fcoe_ctlr_device_flush_work() - Flush a FIP ctlr's workqueue
 * @ctlr: Pointer to the FIP ctlr whose workqueue is to be flushed
 */
static void fcoe_ctlr_device_flush_work(struct fcoe_ctlr_device *ctlr)
{}

/**
 * fcoe_ctlr_device_queue_work() - Schedule work for a FIP ctlr's workqueue
 * @ctlr: Pointer to the FIP ctlr who owns the devloss workqueue
 * @work:   Work to queue for execution
 *
 * Return value:
 *	1 on success / 0 already queued / < 0 for error
 */
static int fcoe_ctlr_device_queue_work(struct fcoe_ctlr_device *ctlr,
				       struct work_struct *work)
{}

/**
 * fcoe_ctlr_device_flush_devloss() - Flush a FIP ctlr's devloss workqueue
 * @ctlr: Pointer to FIP ctlr whose workqueue is to be flushed
 */
static void fcoe_ctlr_device_flush_devloss(struct fcoe_ctlr_device *ctlr)
{}

/**
 * fcoe_ctlr_device_queue_devloss_work() - Schedule work for a FIP ctlr's devloss workqueue
 * @ctlr: Pointer to the FIP ctlr who owns the devloss workqueue
 * @work:   Work to queue for execution
 * @delay:  jiffies to delay the work queuing
 *
 * Return value:
 *	1 on success / 0 already queued / < 0 for error
 */
static int fcoe_ctlr_device_queue_devloss_work(struct fcoe_ctlr_device *ctlr,
					       struct delayed_work *work,
					       unsigned long delay)
{}

static int fcoe_fcf_device_match(struct fcoe_fcf_device *new,
				 struct fcoe_fcf_device *old)
{}

/**
 * fcoe_ctlr_device_add() - Add a FIP ctlr to sysfs
 * @parent:    The parent device to which the fcoe_ctlr instance
 *             should be attached
 * @f:         The LLD's FCoE sysfs function template pointer
 * @priv_size: Size to be allocated with the fcoe_ctlr_device for the LLD
 *
 * This routine allocates a FIP ctlr object with some additional memory
 * for the LLD. The FIP ctlr is initialized, added to sysfs and then
 * attributes are added to it.
 */
struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
				    struct fcoe_sysfs_function_template *f,
				    int priv_size)
{}
EXPORT_SYMBOL_GPL();

/**
 * fcoe_ctlr_device_delete() - Delete a FIP ctlr and its subtree from sysfs
 * @ctlr: A pointer to the ctlr to be deleted
 *
 * Deletes a FIP ctlr and any fcfs attached
 * to it. Deleting fcfs will cause their childen
 * to be deleted as well.
 *
 * The ctlr is detached from sysfs and it's resources
 * are freed (work q), but the memory is not freed
 * until its last reference is released.
 *
 * This routine expects no locks to be held before
 * calling.
 *
 * TODO: Currently there are no callbacks to clean up LLD data
 * for a fcoe_fcf_device. LLDs must keep this in mind as they need
 * to clean up each of their LLD data for all fcoe_fcf_device before
 * calling fcoe_ctlr_device_delete.
 */
void fcoe_ctlr_device_delete(struct fcoe_ctlr_device *ctlr)
{}
EXPORT_SYMBOL_GPL();

/**
 * fcoe_fcf_device_final_delete() - Final delete routine
 * @work: The FIP fcf's embedded work struct
 *
 * It is expected that the fcf has been removed from
 * the FIP ctlr's list before calling this routine.
 */
static void fcoe_fcf_device_final_delete(struct work_struct *work)
{}

/**
 * fip_timeout_deleted_fcf() - Delete a fcf when the devloss timer fires
 * @work: The FIP fcf's embedded work struct
 *
 * Removes the fcf from the FIP ctlr's list of fcfs and
 * queues the final deletion.
 */
static void fip_timeout_deleted_fcf(struct work_struct *work)
{}

/**
 * fcoe_fcf_device_delete() - Delete a FIP fcf
 * @fcf: Pointer to the fcf which is to be deleted
 *
 * Queues the FIP fcf on the devloss workqueue
 *
 * Expects the ctlr_attrs mutex to be held for fcf
 * state change.
 */
void fcoe_fcf_device_delete(struct fcoe_fcf_device *fcf)
{}
EXPORT_SYMBOL_GPL();

/**
 * fcoe_fcf_device_add() - Add a FCoE sysfs fcoe_fcf_device to the system
 * @ctlr:    The fcoe_ctlr_device that will be the fcoe_fcf_device parent
 * @new_fcf: A temporary FCF used for lookups on the current list of fcfs
 *
 * Expects to be called with the ctlr->lock held
 */
struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
					    struct fcoe_fcf_device *new_fcf)
{}
EXPORT_SYMBOL_GPL();

int __init fcoe_sysfs_setup(void)
{}

void __exit fcoe_sysfs_teardown(void)
{}