linux/drivers/scsi/scsi_transport_spi.c

// SPDX-License-Identifier: GPL-2.0-or-later
/* 
 *  Parallel SCSI (SPI) transport specific attributes exported to sysfs.
 *
 *  Copyright (c) 2003 Silicon Graphics, Inc.  All rights reserved.
 *  Copyright (c) 2004, 2005 James Bottomley <[email protected]>
 */
#include <linux/ctype.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/workqueue.h>
#include <linux/blkdev.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
#include <linux/slab.h>
#include <linux/suspend.h>
#include <scsi/scsi.h>
#include "scsi_priv.h"
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_tcq.h>
#include <scsi/scsi_transport.h>
#include <scsi/scsi_transport_spi.h>

#define SPI_NUM_ATTRS
#define SPI_OTHER_ATTRS
#define SPI_HOST_ATTRS

#define SPI_MAX_ECHO_BUFFER_SIZE

#define DV_LOOPS
#define DV_TIMEOUT
#define DV_RETRIES

/* Our blacklist flags */
enum {};

/* blacklist table, modelled on scsi_devinfo.c */
static struct {} spi_static_device_list[] __initdata =;

/* Private data accessors (keep these out of the header file) */
#define spi_dv_in_progress(x)
#define spi_dv_mutex(x)

struct spi_internal {};

#define to_spi_internal(tmpl)

static const int ppr_to_ps[] =;
/* The PPR values at which you calculate the period in ns by multiplying
 * by 4 */
#define SPI_STATIC_PPR

static int sprint_frac(char *dest, int value, int denom)
{}

static int spi_execute(struct scsi_device *sdev, const void *cmd,
		       enum req_op op, void *buffer, unsigned int bufflen,
		       struct scsi_sense_hdr *sshdr)
{}

static struct {} signal_types[] =;

static inline const char *spi_signal_to_string(enum spi_signal_type type)
{}
static inline enum spi_signal_type spi_signal_to_value(const char *name)
{}

static int spi_host_setup(struct transport_container *tc, struct device *dev,
			  struct device *cdev)
{}

static int spi_host_configure(struct transport_container *tc,
			      struct device *dev,
			      struct device *cdev);

static DECLARE_TRANSPORT_CLASS(spi_host_class,
			       "spi_host",
			       spi_host_setup,
			       NULL,
			       spi_host_configure);

static int spi_host_match(struct attribute_container *cont,
			  struct device *dev)
{}

static int spi_target_configure(struct transport_container *tc,
				struct device *dev,
				struct device *cdev);

static int spi_device_configure(struct transport_container *tc,
				struct device *dev,
				struct device *cdev)
{}

static int spi_setup_transport_attrs(struct transport_container *tc,
				     struct device *dev,
				     struct device *cdev)
{}

#define spi_transport_show_simple(field, format_string)

#define spi_transport_store_simple(field, format_string)

#define spi_transport_show_function(field, format_string)

#define spi_transport_store_function(field, format_string)

#define spi_transport_store_max(field, format_string)

#define spi_transport_rd_attr(field, format_string)

#define spi_transport_simple_attr(field, format_string)

#define spi_transport_max_attr(field, format_string)

/* The Parallel SCSI Tranport Attributes: */
spi_transport_max_attr(offset, "%d\n");
spi_transport_max_attr(width, "%d\n");
spi_transport_max_attr(iu, "%d\n");
spi_transport_rd_attr(dt, "%d\n");
spi_transport_max_attr(qas, "%d\n");
spi_transport_rd_attr(wr_flow, "%d\n");
spi_transport_rd_attr(rd_strm, "%d\n");
spi_transport_rd_attr(rti, "%d\n");
spi_transport_rd_attr(pcomp_en, "%d\n");
spi_transport_rd_attr(hold_mcs, "%d\n");

/* we only care about the first child device that's a real SCSI device
 * so we return 1 to terminate the iteration when we find it */
static int child_iter(struct device *dev, void *data)
{}

static ssize_t
store_spi_revalidate(struct device *dev, struct device_attribute *attr,
		     const char *buf, size_t count)
{}
static DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);

/* Translate the period into ns according to the current spec
 * for SDTR/PPR messages */
static int period_to_str(char *buf, int period)
{}

static ssize_t
show_spi_transport_period_helper(char *buf, int period)
{}

static ssize_t
store_spi_transport_period_helper(struct device *dev, const char *buf,
				  size_t count, int *periodp)
{}

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

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

static DEVICE_ATTR(period, S_IRUGO,
		   show_spi_transport_period,
		   store_spi_transport_period);

static ssize_t
show_spi_transport_min_period(struct device *cdev,
			      struct device_attribute *attr, char *buf)
{}

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


static DEVICE_ATTR(min_period, S_IRUGO,
		   show_spi_transport_min_period,
		   store_spi_transport_min_period);


static ssize_t show_spi_host_signalling(struct device *cdev,
					struct device_attribute *attr,
					char *buf)
{}
static ssize_t store_spi_host_signalling(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf, size_t count)
{}
static DEVICE_ATTR(signalling, S_IRUGO,
		   show_spi_host_signalling,
		   store_spi_host_signalling);

static ssize_t show_spi_host_width(struct device *cdev,
				      struct device_attribute *attr,
				      char *buf)
{}
static DEVICE_ATTR(host_width, S_IRUGO,
		   show_spi_host_width, NULL);

static ssize_t show_spi_host_hba_id(struct device *cdev,
				    struct device_attribute *attr,
				    char *buf)
{}
static DEVICE_ATTR(hba_id, S_IRUGO,
		   show_spi_host_hba_id, NULL);

#define DV_SET(x, y)

enum spi_compare_returns {};


/* This is for read/write Domain Validation:  If the device supports
 * an echo buffer, we do read/write tests to it */
static enum spi_compare_returns
spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,
			  u8 *ptr, const int retries)
{}

/* This is for the simplest form of Domain Validation: a read test
 * on the inquiry data from the device */
static enum spi_compare_returns
spi_dv_device_compare_inquiry(struct scsi_device *sdev, u8 *buffer,
			      u8 *ptr, const int retries)
{}

static enum spi_compare_returns
spi_dv_retrain(struct scsi_device *sdev, u8 *buffer, u8 *ptr,
	       enum spi_compare_returns 
	       (*compare_fn)(struct scsi_device *, u8 *, u8 *, int))
{}

static int
spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer)
{}

static void
spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer)
{}


/**	spi_dv_device - Do Domain Validation on the device
 *	@sdev:		scsi device to validate
 *
 *	Performs the domain validation on the given device in the
 *	current execution thread.  Since DV operations may sleep,
 *	the current thread must have user context.  Also no SCSI
 *	related locks that would deadlock I/O issued by the DV may
 *	be held.
 */
void
spi_dv_device(struct scsi_device *sdev)
{}
EXPORT_SYMBOL();

struct work_queue_wrapper {};

static void
spi_dv_device_work_wrapper(struct work_struct *work)
{}


/**
 *	spi_schedule_dv_device - schedule domain validation to occur on the device
 *	@sdev:	The device to validate
 *
 *	Identical to spi_dv_device() above, except that the DV will be
 *	scheduled to occur in a workqueue later.  All memory allocations
 *	are atomic, so may be called from any context including those holding
 *	SCSI locks.
 */
void
spi_schedule_dv_device(struct scsi_device *sdev)
{}
EXPORT_SYMBOL();

/**
 * spi_display_xfer_agreement - Print the current target transfer agreement
 * @starget: The target for which to display the agreement
 *
 * Each SPI port is required to maintain a transfer agreement for each
 * other port on the bus.  This function prints a one-line summary of
 * the current agreement; more detailed information is available in sysfs.
 */
void spi_display_xfer_agreement(struct scsi_target *starget)
{}
EXPORT_SYMBOL();

int spi_populate_width_msg(unsigned char *msg, int width)
{}
EXPORT_SYMBOL_GPL();

int spi_populate_sync_msg(unsigned char *msg, int period, int offset)
{}
EXPORT_SYMBOL_GPL();

int spi_populate_ppr_msg(unsigned char *msg, int period, int offset,
		int width, int options)
{}
EXPORT_SYMBOL_GPL();

/**
 * spi_populate_tag_msg - place a tag message in a buffer
 * @msg:	pointer to the area to place the tag
 * @cmd:	pointer to the scsi command for the tag
 *
 * Notes:
 *	designed to create the correct type of tag message for the 
 *	particular request.  Returns the size of the tag message.
 *	May return 0 if TCQ is disabled for this device.
 **/
int spi_populate_tag_msg(unsigned char *msg, struct scsi_cmnd *cmd)
{}
EXPORT_SYMBOL_GPL();

#ifdef CONFIG_SCSI_CONSTANTS
static const char * const one_byte_msgs[] =;

static const char * const two_byte_msgs[] =;

static const char * const extended_msgs[] =;

static void print_nego(const unsigned char *msg, int per, int off, int width)
{}

static void print_ptr(const unsigned char *msg, int msb, const char *desc)
{}

int spi_print_msg(const unsigned char *msg)
{}
EXPORT_SYMBOL();

#else  /* ifndef CONFIG_SCSI_CONSTANTS */

int spi_print_msg(const unsigned char *msg)
{
	int len = 1, i;

	if (msg[0] == EXTENDED_MESSAGE) {
		len = 2 + msg[1];
		if (len == 2)
			len += 256;
		for (i = 0; i < len; ++i)
			printk("%02x ", msg[i]);
	/* Identify */
	} else if (msg[0] & 0x80) {
		printk("%02x ", msg[0]);
	/* Normal One byte */
	} else if ((msg[0] < 0x1f) || (msg[0] == 0x55)) {
		printk("%02x ", msg[0]);
	/* Two byte */
	} else if (msg[0] <= 0x2f) {
		printk("%02x %02x", msg[0], msg[1]);
		len = 2;
	} else 
		printk("%02x ", msg[0]);
	return len;
}
EXPORT_SYMBOL(spi_print_msg);
#endif /* ! CONFIG_SCSI_CONSTANTS */

static int spi_device_match(struct attribute_container *cont,
			    struct device *dev)
{}

static int spi_target_match(struct attribute_container *cont,
			    struct device *dev)
{}

static DECLARE_TRANSPORT_CLASS(spi_transport_class,
			       "spi_transport",
			       spi_setup_transport_attrs,
			       NULL,
			       spi_target_configure);

static DECLARE_ANON_TRANSPORT_CLASS(spi_device_class,
				    spi_device_match,
				    spi_device_configure);

static struct attribute *host_attributes[] =;

static struct attribute_group host_attribute_group =;

static int spi_host_configure(struct transport_container *tc,
			      struct device *dev,
			      struct device *cdev)
{}

/* returns true if we should be showing the variable.  Also
 * overloads the return by setting 1<<1 if the attribute should
 * be writeable */
#define TARGET_ATTRIBUTE_HELPER(name)

static umode_t target_attribute_is_visible(struct kobject *kobj,
					  struct attribute *attr, int i)
{}

static struct attribute *target_attributes[] =;

static struct attribute_group target_attribute_group =;

static int spi_target_configure(struct transport_container *tc,
				struct device *dev,
				struct device *cdev)
{}

struct scsi_transport_template *
spi_attach_transport(struct spi_function_template *ft)
{}
EXPORT_SYMBOL();

void spi_release_transport(struct scsi_transport_template *t)
{}
EXPORT_SYMBOL();

static __init int spi_transport_init(void)
{}

static void __exit spi_transport_exit(void)
{}

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

module_init();
module_exit(spi_transport_exit);