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

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