Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /* 
0003  *  Parallel SCSI (SPI) transport specific attributes exported to sysfs.
0004  *
0005  *  Copyright (c) 2003 Silicon Graphics, Inc.  All rights reserved.
0006  */
0007 #ifndef SCSI_TRANSPORT_SPI_H
0008 #define SCSI_TRANSPORT_SPI_H
0009 
0010 #include <linux/transport_class.h>
0011 #include <linux/mutex.h>
0012 
0013 struct scsi_transport_template;
0014 struct scsi_target;
0015 struct scsi_device;
0016 struct Scsi_Host;
0017 
0018 struct spi_transport_attrs {
0019     int period;     /* value in the PPR/SDTR command */
0020     int min_period;
0021     int offset;
0022     int max_offset;
0023     unsigned int width:1;   /* 0 - narrow, 1 - wide */
0024     unsigned int max_width:1;
0025     unsigned int iu:1;  /* Information Units enabled */
0026     unsigned int max_iu:1;
0027     unsigned int dt:1;  /* DT clocking enabled */
0028     unsigned int qas:1; /* Quick Arbitration and Selection enabled */
0029     unsigned int max_qas:1;
0030     unsigned int wr_flow:1; /* Write Flow control enabled */
0031     unsigned int rd_strm:1; /* Read streaming enabled */
0032     unsigned int rti:1; /* Retain Training Information */
0033     unsigned int pcomp_en:1;/* Precompensation enabled */
0034     unsigned int hold_mcs:1;/* Hold Margin Control Settings */
0035     unsigned int initial_dv:1; /* DV done to this target yet  */
0036     unsigned long flags;    /* flags field for drivers to use */
0037     /* Device Properties fields */
0038     unsigned int support_sync:1; /* synchronous support */
0039     unsigned int support_wide:1; /* wide support */
0040     unsigned int support_dt:1; /* allows DT phases */
0041     unsigned int support_dt_only; /* disallows ST phases */
0042     unsigned int support_ius; /* support Information Units */
0043     unsigned int support_qas; /* supports quick arbitration and selection */
0044     /* Private Fields */
0045     unsigned int dv_pending:1; /* Internal flag: DV Requested */
0046     unsigned int dv_in_progress:1;  /* Internal: DV started */
0047     struct mutex dv_mutex; /* semaphore to serialise dv */
0048 };
0049 
0050 enum spi_signal_type {
0051     SPI_SIGNAL_UNKNOWN = 1,
0052     SPI_SIGNAL_SE,
0053     SPI_SIGNAL_LVD,
0054     SPI_SIGNAL_HVD,
0055 };
0056 
0057 struct spi_host_attrs {
0058     enum spi_signal_type signalling;
0059 };
0060 
0061 /* accessor functions */
0062 #define spi_period(x)   (((struct spi_transport_attrs *)&(x)->starget_data)->period)
0063 #define spi_min_period(x) (((struct spi_transport_attrs *)&(x)->starget_data)->min_period)
0064 #define spi_offset(x)   (((struct spi_transport_attrs *)&(x)->starget_data)->offset)
0065 #define spi_max_offset(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_offset)
0066 #define spi_width(x)    (((struct spi_transport_attrs *)&(x)->starget_data)->width)
0067 #define spi_max_width(x) (((struct spi_transport_attrs *)&(x)->starget_data)->max_width)
0068 #define spi_iu(x)   (((struct spi_transport_attrs *)&(x)->starget_data)->iu)
0069 #define spi_max_iu(x)   (((struct spi_transport_attrs *)&(x)->starget_data)->max_iu)
0070 #define spi_dt(x)   (((struct spi_transport_attrs *)&(x)->starget_data)->dt)
0071 #define spi_qas(x)  (((struct spi_transport_attrs *)&(x)->starget_data)->qas)
0072 #define spi_max_qas(x)  (((struct spi_transport_attrs *)&(x)->starget_data)->max_qas)
0073 #define spi_wr_flow(x)  (((struct spi_transport_attrs *)&(x)->starget_data)->wr_flow)
0074 #define spi_rd_strm(x)  (((struct spi_transport_attrs *)&(x)->starget_data)->rd_strm)
0075 #define spi_rti(x)  (((struct spi_transport_attrs *)&(x)->starget_data)->rti)
0076 #define spi_pcomp_en(x) (((struct spi_transport_attrs *)&(x)->starget_data)->pcomp_en)
0077 #define spi_hold_mcs(x) (((struct spi_transport_attrs *)&(x)->starget_data)->hold_mcs)
0078 #define spi_initial_dv(x)   (((struct spi_transport_attrs *)&(x)->starget_data)->initial_dv)
0079 #define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending)
0080 
0081 #define spi_support_sync(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_sync)
0082 #define spi_support_wide(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_wide)
0083 #define spi_support_dt(x)   (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt)
0084 #define spi_support_dt_only(x)  (((struct spi_transport_attrs *)&(x)->starget_data)->support_dt_only)
0085 #define spi_support_ius(x)  (((struct spi_transport_attrs *)&(x)->starget_data)->support_ius)
0086 #define spi_support_qas(x)  (((struct spi_transport_attrs *)&(x)->starget_data)->support_qas)
0087 
0088 #define spi_flags(x)    (((struct spi_transport_attrs *)&(x)->starget_data)->flags)
0089 #define spi_signalling(h)   (((struct spi_host_attrs *)(h)->shost_data)->signalling)
0090 
0091 
0092 
0093 /* The functions by which the transport class and the driver communicate */
0094 struct spi_function_template {
0095     void    (*get_period)(struct scsi_target *);
0096     void    (*set_period)(struct scsi_target *, int);
0097     void    (*get_offset)(struct scsi_target *);
0098     void    (*set_offset)(struct scsi_target *, int);
0099     void    (*get_width)(struct scsi_target *);
0100     void    (*set_width)(struct scsi_target *, int);
0101     void    (*get_iu)(struct scsi_target *);
0102     void    (*set_iu)(struct scsi_target *, int);
0103     void    (*get_dt)(struct scsi_target *);
0104     void    (*set_dt)(struct scsi_target *, int);
0105     void    (*get_qas)(struct scsi_target *);
0106     void    (*set_qas)(struct scsi_target *, int);
0107     void    (*get_wr_flow)(struct scsi_target *);
0108     void    (*set_wr_flow)(struct scsi_target *, int);
0109     void    (*get_rd_strm)(struct scsi_target *);
0110     void    (*set_rd_strm)(struct scsi_target *, int);
0111     void    (*get_rti)(struct scsi_target *);
0112     void    (*set_rti)(struct scsi_target *, int);
0113     void    (*get_pcomp_en)(struct scsi_target *);
0114     void    (*set_pcomp_en)(struct scsi_target *, int);
0115     void    (*get_hold_mcs)(struct scsi_target *);
0116     void    (*set_hold_mcs)(struct scsi_target *, int);
0117     void    (*get_signalling)(struct Scsi_Host *);
0118     void    (*set_signalling)(struct Scsi_Host *, enum spi_signal_type);
0119     int (*deny_binding)(struct scsi_target *);
0120     /* The driver sets these to tell the transport class it
0121      * wants the attributes displayed in sysfs.  If the show_ flag
0122      * is not set, the attribute will be private to the transport
0123      * class */
0124     unsigned long   show_period:1;
0125     unsigned long   show_offset:1;
0126     unsigned long   show_width:1;
0127     unsigned long   show_iu:1;
0128     unsigned long   show_dt:1;
0129     unsigned long   show_qas:1;
0130     unsigned long   show_wr_flow:1;
0131     unsigned long   show_rd_strm:1;
0132     unsigned long   show_rti:1;
0133     unsigned long   show_pcomp_en:1;
0134     unsigned long   show_hold_mcs:1;
0135 };
0136 
0137 struct scsi_transport_template *spi_attach_transport(struct spi_function_template *);
0138 void spi_release_transport(struct scsi_transport_template *);
0139 void spi_schedule_dv_device(struct scsi_device *);
0140 void spi_dv_device(struct scsi_device *);
0141 void spi_display_xfer_agreement(struct scsi_target *);
0142 int spi_print_msg(const unsigned char *);
0143 int spi_populate_width_msg(unsigned char *msg, int width);
0144 int spi_populate_sync_msg(unsigned char *msg, int period, int offset);
0145 int spi_populate_ppr_msg(unsigned char *msg, int period, int offset, int width,
0146         int options);
0147 int spi_populate_tag_msg(unsigned char *msg, struct scsi_cmnd *cmd);
0148 
0149 #endif /* SCSI_TRANSPORT_SPI_H */