root/drivers/scsi/hosts.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  *      hosts.h Copyright (C) 1992 Drew Eckhardt 
   3  *      mid to low-level SCSI driver interface header by        
   4  *              Drew Eckhardt 
   5  *
   6  *      <drew@colorado.edu>
   7  *
   8  *       Modified by Eric Youngdale eric@tantalus.nrl.navy.mil to
   9  *       add scatter-gather, multiple outstanding request, and other
  10  *       enhancements.
  11  * 
  12  *      Further modified by Eric Youngdale to support multiple host adapters
  13  *      of the same type.
  14  */
  15 
  16 #ifndef _HOSTS_H
  17 #define _HOSTS_H
  18 
  19 /*
  20         $Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/hosts.h,v 1.3 1993/09/24 12:21:00 drew Exp drew $
  21 */
  22 
  23 
  24 /* It is senseless to set SG_ALL any higher than this - the performance
  25    does not get any better, and it wastes memory */
  26 #define SG_NONE 0
  27 #define SG_ALL 0xff
  28 
  29 #define DISABLE_CLUSTERING 0
  30 #define ENABLE_CLUSTERING 1
  31 
  32 /* The various choices mean:
  33    NONE: Self evident.  Host adapter is not capable of scatter-gather.
  34    ALL:  Means that the host adapter module can do scatter-gather,
  35          and that there is no limit to the size of the table to which
  36          we scatter/gather data.
  37   Anything else:  Indicates the maximum number of chains that can be
  38         used in one scatter-gather request.
  39 */
  40 
  41 /*
  42         The Scsi_Host_Template type has all that is needed to interface with a SCSI
  43         host in a device independent matter.  There is one entry for each different
  44         type of host adapter that is supported on the system.
  45 */
  46 
  47 typedef struct scsi_disk Disk;
  48 
  49 typedef struct  SHT
  50         {
  51 
  52           /* Used with loadable modules so we can construct a linked list. */
  53           struct SHT * next;
  54 
  55           /* Used with loadable modules so that we know when it is safe to unload */
  56           int * usage_count;
  57 
  58         /*
  59                 The name pointer is a pointer to the name of the SCSI
  60                 device detected.
  61         */
  62 
  63         char *name;
  64 
  65         /*
  66                 The detect function shall return non zero on detection,
  67                 indicating the number of host adapters of this particular
  68                 type were found.  It should also
  69                 initialize all data necessary for this particular
  70                 SCSI driver.  It is passed the host number, so this host
  71                 knows where the first entry is in the scsi_hosts[] array.
  72 
  73                 Note that the detect routine MUST not call any of the mid level
  74                 functions to queue commands because things are not guaranteed
  75                 to be set up yet.  The detect routine can send commands to
  76                 the host adapter as long as the program control will not be
  77                 passed to scsi.c in the processing of the command.  Note
  78                 especially that scsi_malloc/scsi_free must not be called.
  79         */
  80 
  81         int (* detect)(struct SHT *); 
  82 
  83           /* Used with loadable modules to unload the host structures.  Note:
  84            there is a default action built into the modules code which may
  85            be sufficient for most host adapters.  Thus you may not have to supply
  86            this at all. */
  87         int (*release)(struct Scsi_Host *);
  88         /*
  89                 The info function will return whatever useful
  90                 information the developer sees fit.  If not provided, then
  91                 the name field will be used instead.
  92         */
  93 
  94         const char *(* info)(struct Scsi_Host *);
  95 
  96         /*
  97                 The command function takes a target, a command (this is a SCSI 
  98                 command formatted as per the SCSI spec, nothing strange), a 
  99                 data buffer pointer, and data buffer length pointer.  The return
 100                 is a status int, bit fielded as follows : 
 101                 Byte    What
 102                 0       SCSI status code
 103                 1       SCSI 1 byte message
 104                 2       host error return.
 105                 3       mid level error return
 106         */
 107 
 108         int (* command)(Scsi_Cmnd *);
 109 
 110         /*
 111                 The QueueCommand function works in a similar manner
 112                 to the command function.  It takes an additional parameter,
 113                 void (* done)(int host, int code) which is passed the host 
 114                 # and exit result when the command is complete.  
 115                 Host number is the POSITION IN THE hosts array of THIS
 116                 host adapter.
 117         */
 118 
 119         int (* queuecommand)(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
 120 
 121         /*
 122                 Since the mid level driver handles time outs, etc, we want to 
 123                 be able to abort the current command.  Abort returns 0 if the 
 124                 abortion was successful.  The field SCpnt->abort reason
 125                 can be filled in with the appropriate reason why we wanted
 126                 the abort in the first place, and this will be used
 127                 in the mid-level code instead of the host_byte().
 128                 If non-zero, the code passed to it 
 129                 will be used as the return code, otherwise 
 130                 DID_ABORT  should be returned.
 131 
 132                 Note that the scsi driver should "clean up" after itself, 
 133                 resetting the bus, etc.  if necessary. 
 134         */
 135 
 136         int (* abort)(Scsi_Cmnd *);
 137 
 138         /*
 139                 The reset function will reset the SCSI bus.  Any executing 
 140                 commands should fail with a DID_RESET in the host byte.
 141                 The Scsi_Cmnd  is passed so that the reset routine can figure
 142                 out which host adapter should be reset, and also which command
 143                 within the command block was responsible for the reset in
 144                 the first place.  Some hosts do not implement a reset function,
 145                 and these hosts must call scsi_request_sense(SCpnt) to keep
 146                 the command alive.
 147         */ 
 148 
 149         int (* reset)(Scsi_Cmnd *);
 150         /*
 151                 This function is used to select synchronous communications,
 152                 which will result in a higher data throughput.  Not implemented
 153                 yet.
 154         */ 
 155 
 156         int (* slave_attach)(int, int);
 157         /*
 158                 This function determines the bios parameters for a given
 159                 harddisk.  These tend to be numbers that are made up by
 160                 the host adapter.  Parameters:
 161                 size, device number, list (heads, sectors, cylinders)
 162         */ 
 163 
 164         int (* bios_param)(Disk *, int, int []);
 165         
 166         /*
 167                 This determines if we will use a non-interrupt driven
 168                 or an interrupt driven scheme,  It is set to the maximum number
 169                 of simultaneous commands a given host adapter will accept.
 170         */
 171         int can_queue;
 172 
 173         /*
 174                 In many instances, especially where disconnect / reconnect are 
 175                 supported, our host also has an ID on the SCSI bus.  If this is 
 176                 the case, then it must be reserved.  Please set this_id to -1 if
 177                 your setup is in single initiator mode, and the host lacks an 
 178                 ID.
 179         */
 180         
 181         int this_id;
 182 
 183         /*
 184                 This determines the degree to which the host adapter is capable
 185                 of scatter-gather.
 186         */
 187 
 188         short unsigned int sg_tablesize;
 189 
 190         /*
 191           True if this host adapter can make good use of linked commands.
 192           This will allow more than one command to be queued to a given
 193           unit on a given host.  Set this to the maximum number of command
 194           blocks to be provided for each device.  Set this to 1 for one
 195           command block per lun, 2 for two, etc.  Do not set this to 0.
 196           You should make sure that the host adapter will do the right thing
 197           before you try setting this above 1.
 198          */
 199 
 200         short cmd_per_lun;
 201         /*
 202                 present contains counter indicating how many boards of this
 203                 type were found when we did the scan.
 204         */
 205 
 206         unsigned char present;  
 207         /*
 208           true if this host adapter uses unchecked DMA onto an ISA bus.
 209         */
 210         unsigned unchecked_isa_dma:1;
 211         /*
 212           true if this host adapter can make good use of clustering.
 213           I originally thought that if the tablesize was large that it
 214           was a waste of CPU cycles to prepare a cluster list, but
 215           it works out that the Buslogic is faster if you use a smaller
 216           number of segments (i.e. use clustering).  I guess it is
 217           inefficient.
 218         */
 219         unsigned use_clustering:1;
 220         } Scsi_Host_Template;
 221 
 222 /*
 223         The scsi_hosts array is the array containing the data for all 
 224         possible <supported> scsi hosts.   This is similar to the
 225         Scsi_Host_Template, except that we have one entry for each
 226         actual physical host adapter on the system, stored as a linked
 227         list.  Note that if there are 2 aha1542 boards, then there will
 228         be two Scsi_Host entries, but only 1 Scsi_Host_Template entries.
 229 */
 230 
 231 struct Scsi_Host
 232         {
 233                 struct Scsi_Host * next;
 234                 unsigned short extra_bytes;
 235                 volatile unsigned char host_busy;
 236                 char host_no;  /* Used for IOCTL_GET_IDLUN */
 237                 int last_reset;
 238                 struct wait_queue *host_wait;
 239                 Scsi_Cmnd *host_queue; 
 240                 Scsi_Host_Template * hostt;
 241 
 242                 /* Pointer to a circularly linked list - this indicates the hosts
 243                    that should be locked out of performing I/O while we have an active
 244                    command on this host. */
 245                 struct Scsi_Host * block;
 246                 unsigned wish_block:1;
 247 
 248                 /* These parameters should be set by the detect routine */
 249                 unsigned char *base;
 250                 unsigned int io_port;
 251                 unsigned char n_io_port;
 252                 unsigned char irq;
 253                 unsigned char dma_channel;
 254 
 255                 /*
 256                   Set these if there are conflicts between memory
 257                   in the < 1mb region and regions at 16mb multiples.
 258                   The address must be on a page boundary.
 259                 */
 260                 unsigned long forbidden_addr;
 261                 unsigned long forbidden_size;
 262 
 263                 /*
 264                   The rest can be copied from the template, or specifically
 265                   initialized, as required.
 266                 */
 267                 
 268                 int this_id;
 269                 int can_queue;
 270                 short cmd_per_lun;
 271                 short unsigned int sg_tablesize;
 272                 unsigned unchecked_isa_dma:1;
 273                 /*
 274                    True if this host was loaded as a loadable module
 275                 */
 276                 unsigned loaded_as_module:1;
 277                 
 278                 int hostdata[0];  /* Used for storage of host specific stuff */
 279         };
 280 
 281 extern struct Scsi_Host * scsi_hostlist;
 282 extern struct Scsi_Device_Template * scsi_devicelist;
 283 
 284 extern Scsi_Host_Template * scsi_hosts;
 285 
 286 /*
 287         scsi_init initializes the scsi hosts.
 288 */
 289 
 290 
 291 /* We use these goofy things because the MM is not set up when we init
 292    the scsi subsystem.  By using these functions we can write code that
 293    looks normal.  Also, it makes it possible to use the same code for a
 294    loadable module. */
 295 
 296 extern void * scsi_init_malloc(unsigned int size, int priority);
 297 extern void scsi_init_free(char * ptr, unsigned int size);
 298 
 299 void scan_scsis (struct Scsi_Host * shpnt);
 300 
 301 extern int next_scsi_host;
 302 
 303 extern int scsi_loadable_module_flag;
 304 unsigned int scsi_init(void);
 305 extern struct Scsi_Host * scsi_register(Scsi_Host_Template *, int j);
 306 extern void scsi_unregister(struct Scsi_Host * i);
 307 extern int scsicam_bios_param (Disk *, int, int *);
 308 
 309 #define BLANK_HOST {"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
 310 
 311 struct Scsi_Device_Template
 312 {
 313   struct Scsi_Device_Template * next;
 314   char * name;
 315   char * tag;
 316   unsigned char scsi_type;
 317   unsigned char major;
 318   unsigned char nr_dev;  /* Number currently attached */
 319   unsigned char dev_noticed; /* Number of devices detected. */
 320   unsigned char dev_max; /* Current size of arrays */
 321   unsigned blk:1;  /* 0 if character device */
 322   int (*detect)(Scsi_Device *); /* Returns 1 if we can attach this device */
 323   void (*init)(void);  /* Sizes arrays based upon number of devices detected */
 324   void (*finish)(void);  /* Perform initialization after attachment */
 325   int (*attach)(Scsi_Device *); /* Attach devices to arrays */
 326   void (*detach)(Scsi_Device *);
 327 };
 328 
 329 extern struct Scsi_Device_Template sd_template;
 330 extern struct Scsi_Device_Template st_template;
 331 extern struct Scsi_Device_Template sr_template;
 332 extern struct Scsi_Device_Template sg_template;
 333 
 334 int scsi_register_device(struct Scsi_Device_Template * sdpnt);
 335 
 336 /* These are used by loadable modules */
 337 extern int scsi_register_module(int, void *);
 338 extern void scsi_unregister_module(int, void *);
 339 
 340 /* The different types of modules that we can load and unload */
 341 #define MODULE_SCSI_HA 1
 342 #define MODULE_SCSI_CONST 2
 343 #define MODULE_SCSI_IOCTL 3
 344 #define MODULE_SCSI_DEV 4
 345 
 346 
 347 /*
 348  * This is an ugly hack.  If we expect to be able to load devices at run time, we need
 349  * to leave extra room in some of the data structures.  Doing a realloc to enlarge
 350  * the structures would be riddled with race conditions, so until a better solution 
 351  * is discovered, we use this crude approach
 352  */
 353 #define SD_EXTRA_DEVS 2
 354 #define ST_EXTRA_DEVS 2
 355 #define SR_EXTRA_DEVS 2
 356 #define SG_EXTRA_DEVS (SD_EXTRA_DEVS + SR_EXTRA_DEVS + ST_EXTRA_DEVS)
 357 
 358 #endif
 359 /*
 360  * Overrides for Emacs so that we follow Linus's tabbing style.
 361  * Emacs will notice this stuff at the end of the file and automatically
 362  * adjust the settings for this buffer only.  This must remain at the end
 363  * of the file.
 364  * ---------------------------------------------------------------------------
 365  * Local variables:
 366  * c-indent-level: 8
 367  * c-brace-imaginary-offset: 0
 368  * c-brace-offset: -8
 369  * c-argdecl-indent: 8
 370  * c-label-offset: -8
 371  * c-continued-statement-offset: 8
 372  * c-continued-brace-offset: 0
 373  * End:
 374  */

/* [previous][next][first][last][top][bottom][index][help] */