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 #define SG_NONE 0 25 #define SG_ALL 0x7fff 26 27 #define DISABLE_CLUSTERING 0 28 #define ENABLE_CLUSTERING 1 29 30 /* The various choices mean: 31 NONE: Self evident. Host adapter is not capable of scatter-gather. 32 ALL: Means that the host adapter module can do scatter-gather, 33 and that there is no limit to the size of the table to which 34 we scatter/gather data. 35 Anything else: Indicates the maximum number of chains that can be 36 used in one scatter-gather request. 37 */ 38 39 /* 40 The Scsi_Host_Template type has all that is needed to interface with a SCSI 41 host in a device independant matter. There is one entry for each different 42 type of host adapter that is supported on the system. 43 */ 44 45 typedef struct 46 { 47 /* 48 The name pointer is a pointer to the name of the SCSI 49 device detected. 50 */ 51 52 char *name; 53 54 /* 55 The detect function shall return non zero on detection, 56 indicating the number of host adapters of this particular 57 type were found. It should also 58 initialize all data necessary for this particular 59 SCSI driver. It is passed the host number, so this host 60 knows where the first entry is in the scsi_hosts[] array. 61 62 Note that the detect routine MUST not call any of the mid level 63 functions to queue commands because things are not guaranteed 64 to be set up yet. The detect routine can send commands to 65 the host adapter as long as the program control will not be 66 passed to scsi.c in the processesing of the command. Note 67 especially that scsi_malloc/scsi_free must not be called. 68 */ 69 70 int (* detect)(int); 71 72 /* 73 The info function will return whatever useful 74 information the developer sees fit. 75 */ 76 77 const char *(* info)(void); 78 79 /* 80 The command function takes a target, a command (this is a SCSI 81 command formatted as per the SCSI spec, nothing strange), a 82 data buffer pointer, and data buffer length pointer. The return 83 is a status int, bit fielded as follows : 84 Byte What 85 0 SCSI status code 86 1 SCSI 1 byte message 87 2 host error return. 88 3 mid level error return 89 */ 90 91 int (* command)(Scsi_Cmnd *); 92 93 /* 94 The QueueCommand function works in a similar manner 95 to the command function. It takes an additional parameter, 96 void (* done)(int host, int code) which is passed the host 97 # and exit result when the command is complete. 98 Host number is the POSITION IN THE hosts array of THIS 99 host adapter. 100 */ 101 102 int (* queuecommand)(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 103 104 /* 105 Since the mid level driver handles time outs, etc, we want to 106 be able to abort the current command. Abort returns 0 if the 107 abortion was successful. The field SCpnt->abort reason 108 can be filled in with the appropriate reason why we wanted 109 the abort in the first place, and this will be used 110 in the mid-level code instead of the host_byte(). 111 If non-zero, the code passed to it 112 will be used as the return code, otherwise 113 DID_ABORT should be returned. 114 115 Note that the scsi driver should "clean up" after itself, 116 resetting the bus, etc. if necessary. 117 */ 118 119 int (* abort)(Scsi_Cmnd *); 120 121 /* 122 The reset function will reset the SCSI bus. Any executing 123 commands should fail with a DID_RESET in the host byte. 124 The Scsi_Cmnd is passed so that the reset routine can figure 125 out which host adapter should be reset, and also which command 126 within the command block was responsible for the reset in 127 the first place. Some hosts do not implement a reset function, 128 and these hosts must call scsi_request_sense(SCpnt) to keep 129 the command alive. 130 */ 131 132 int (* reset)(Scsi_Cmnd *); 133 /* 134 This function is used to select synchronous communications, 135 which will result in a higher data throughput. Not implemented 136 yet. 137 */ 138 139 int (* slave_attach)(int, int); 140 /* 141 This function determines the bios parameters for a given 142 harddisk. These tend to be numbers that are made up by 143 the host adapter. Parameters: 144 size, device number, list (heads, sectors, cylinders) 145 */ 146 147 int (* bios_param)(int, int, int []); 148 149 /* 150 This determines if we will use a non-interrupt driven 151 or an interrupt driven scheme, It is set to the maximum number 152 of simulataneous commands a given host adapter will accept. 153 */ 154 int can_queue; 155 156 /* 157 In many instances, especially where disconnect / reconnect are 158 supported, our host also has an ID on the SCSI bus. If this is 159 the case, then it must be reserved. Please set this_id to -1 if 160 your settup is in single initiator mode, and the host lacks an 161 ID. 162 */ 163 164 int this_id; 165 166 /* 167 This determines the degree to which the host adapter is capable 168 of scatter-gather. 169 */ 170 171 short unsigned int sg_tablesize; 172 173 /* 174 True if this host adapter can make good use of linked commands. 175 This will allow more than one command to be queued to a given 176 unit on a given host. Set this to the maximum number of command 177 blocks to be provided for each device. Set this to 1 for one 178 command block per lun, 2 for two, etc. Do not set this to 0. 179 You should make sure that the host adapter will do the right thing 180 before you try setting this above 1. 181 */ 182 183 short cmd_per_lun; 184 /* 185 present contains counter indicating how many boards of this 186 type were found when we did the scan. 187 */ 188 189 unsigned char present; 190 /* 191 true if this host adapter uses unchecked DMA onto an ISA bus. 192 */ 193 unsigned unchecked_isa_dma:1; 194 /* 195 true if this host adapter can make good use of clustering. 196 I originally thought that if the tablesize was large that it 197 was a waste of CPU cycles to prepare a cluster list, but 198 it works out that the Buslogic is faster if you use a smaller 199 number of segments (i.e. use clustering). I guess it is 200 inefficient. 201 */ 202 unsigned use_clustering:1; 203 } Scsi_Host_Template; 204 205 /* 206 The scsi_hosts array is the array containing the data for all 207 possible <supported> scsi hosts. This is similar to the 208 Scsi_Host_Template, except that we have one entry for each 209 actual physical host adapter on the system, stored as a linked 210 list. Note that if there are 2 aha1542 boards, then there will 211 be two Scsi_Host entries, but only 1 Scsi_Host_Template entries. 212 */ 213 214 struct Scsi_Host 215 { 216 struct Scsi_Host * next; 217 volatile unsigned char host_busy; 218 char host_no; /* Used for IOCTL_GET_IDLUN */ 219 int last_reset; 220 struct wait_queue *host_wait; 221 Scsi_Cmnd *host_queue; 222 Scsi_Host_Template * hostt; 223 224 /* These parameters should be set by the detect routine */ 225 unsigned char *base; 226 short unsigned int io_port; 227 unsigned char irq; 228 unsigned char dma_channel; 229 /* 230 The rest can be copied from the template, or specifically 231 initialized, as required. 232 */ 233 234 int this_id; 235 short unsigned int sg_tablesize; 236 unsigned unchecked_isa_dma:1; 237 int hostdata[0]; /* Used for storage of host specific stuff */ 238 }; 239 240 extern struct Scsi_Host * scsi_hostlist; 241 242 extern Scsi_Host_Template scsi_hosts[]; 243 244 /* 245 scsi_init initializes the scsi hosts. 246 */ 247 248 249 unsigned int scsi_init(unsigned long memory_start,unsigned long memory_end); 250 extern struct Scsi_Host * scsi_register(int i, int j); 251 extern void scsi_unregister(struct Scsi_Host * i, int j); 252 253 #define BLANK_HOST {"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 254 #endif