http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / kernel / linux / Documentation / DocBook / scsidrivers.tmpl
1 <!-- -*- sgml -*- -->
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN"[]>
3
4 <book id="scsidrivers">
5  <bookinfo>
6   <title>SCSI Subsystem Interfaces</title>
7   
8   <authorgroup>
9    <author>
10     <firstname>Douglas</firstname>
11     <surname>Gilbert</surname>
12     <affiliation>
13      <address>
14       <email>dgilbert@interlog.com</email>
15      </address>
16     </affiliation>
17    </author>
18   </authorgroup>
19   <pubdate>2003-08-11</pubdate>
20
21   <copyright>
22    <year>2002</year>
23    <year>2003</year>
24    <holder>Douglas Gilbert</holder>
25   </copyright>
26
27   <legalnotice>
28    <para>
29      This documentation is free software; you can redistribute
30      it and/or modify it under the terms of the GNU General Public
31      License as published by the Free Software Foundation; either
32      version 2 of the License, or (at your option) any later
33      version.
34    </para>
35       
36    <para>
37      This program is distributed in the hope that it will be
38      useful, but WITHOUT ANY WARRANTY; without even the implied
39      warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
40      See the GNU General Public License for more details.
41    </para>
42       
43    <para>
44      You should have received a copy of the GNU General Public
45      License along with this program; if not, write to the Free
46      Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
47      MA 02111-1307 USA
48    </para>
49       
50    <para>
51      For more details see the file COPYING in the source
52      distribution of Linux.
53    </para>
54   </legalnotice>
55
56  </bookinfo>
57
58 <toc></toc>
59
60   <chapter id="intro">
61       <title>Introduction</title>
62   <para>
63 This document outlines the interface between the Linux scsi mid level
64 and lower level drivers. Lower level drivers are variously called HBA
65 (host bus adapter) drivers, host drivers (HD) or pseudo adapter drivers.
66 The latter alludes to the fact that a lower level driver may be a
67 bridge to another IO subsystem (and the "ide-scsi" driver is an example
68 of this). There can be many lower level drivers active in a running
69 system, but only one per hardware type. For example, the aic7xxx driver
70 controls adaptec controllers based on the 7xxx chip series. Most lower
71 level drivers can control one or more scsi hosts (a.k.a. scsi initiators).
72   </para>
73 <para>
74 This document can been found in an ASCII text file in the linux kernel 
75 source: <filename>Documentation/scsi/scsi_mid_low_api.txt</filename> .
76 It currently hold a little more information than this document. The
77 <filename>drivers/scsi/hosts.h</filename> and <filename>
78 drivers/scsi/scsi.h</filename> headers contain descriptions of members
79 of important structures for the scsi subsystem.
80 </para>
81   </chapter>
82
83   <chapter id="driver-struct">
84       <title>Driver structure</title>
85   <para>
86 Traditionally a lower level driver for the scsi subsystem has been
87 at least two files in the drivers/scsi directory. For example, a
88 driver called "xyz" has a header file "xyz.h" and a source file
89 "xyz.c". [Actually there is no good reason why this couldn't all
90 be in one file.] Some drivers that have been ported to several operating
91 systems (e.g. aic7xxx which has separate  files for generic and
92 OS-specific code) have more than two files. Such drivers tend to have
93 their own directory under the drivers/scsi directory.
94   </para>
95   <para>
96 scsi_module.c is normally included at the end of a lower
97 level driver. For it to work a declaration like this is needed before
98 it is included:
99 <programlisting>
100     static Scsi_Host_Template driver_template = DRIVER_TEMPLATE;
101     /* DRIVER_TEMPLATE should contain pointers to supported interface
102        functions. Scsi_Host_Template is defined hosts.h */
103     #include "scsi_module.c"
104 </programlisting>
105   </para>
106   <para>
107 The scsi_module.c assumes the name "driver_template" is appropriately
108 defined. It contains 2 functions:
109 <orderedlist>
110 <listitem><para>
111      init_this_scsi_driver() called during builtin and module driver
112      initialization: invokes mid level's scsi_register_host()
113 </para></listitem>
114 <listitem><para>
115      exit_this_scsi_driver() called during closedown: invokes
116      mid level's scsi_unregister_host()
117 </para></listitem>
118 </orderedlist>
119   </para>
120 <para>
121 When a new, lower level driver is being added to Linux, the following 
122 files (all found in the drivers/scsi directory) will need some attention: 
123 Makefile, Config.help and Config.in . It is probably best to look at what 
124 an existing lower level driver does in this regard.
125 </para>
126   </chapter>
127
128   <chapter id="intfunctions">
129      <title>Interface Functions</title>
130 !EDocumentation/scsi/scsi_mid_low_api.txt
131   </chapter>
132
133   <chapter id="locks">
134      <title>Locks</title>
135 <para>
136 Each Scsi_Host instance has a spin_lock called Scsi_Host::default_lock
137 which is initialized in scsi_register() [found in hosts.c]. Within the
138 same function the Scsi_Host::host_lock pointer is initialized to point
139 at default_lock with the scsi_assign_lock() function. Thereafter
140 lock and unlock operations performed by the mid level use the
141 Scsi_Host::host_lock pointer.
142 </para>
143 <para>
144 Lower level drivers can override the use of Scsi_Host::default_lock by
145 using scsi_assign_lock(). The earliest opportunity to do this would
146 be in the detect() function after it has invoked scsi_register(). It
147 could be replaced by a coarser grain lock (e.g. per driver) or a
148 lock of equal granularity (i.e. per host). Using finer grain locks
149 (e.g. per scsi device) may be possible by juggling locks in
150 queuecommand().
151 </para>
152   </chapter>
153
154   <chapter id="changes">
155      <title>Changes since lk 2.4 series</title>
156 <para>
157 io_request_lock has been replaced by several finer grained locks. The lock
158 relevant to lower level drivers is Scsi_Host::host_lock and there is one
159 per scsi host.
160 </para>
161 <para>
162 The older error handling mechanism has been removed. This means the
163 lower level interface functions abort() and reset() have been removed.
164 </para>
165 <para>
166 In the 2.4 series the scsi subsystem configuration descriptions were
167 aggregated with the configuration descriptions from all other Linux
168 subsystems in the Documentation/Configure.help file. In the 2.5 series,
169 the scsi subsystem now has its own (much smaller) drivers/scsi/Config.help
170 file.
171 </para>
172   </chapter>
173
174   <chapter id="credits">
175      <title>Credits</title>
176 <para>
177 The following people have contributed to this document:
178 <orderedlist>
179 <listitem><para>
180 Mike Anderson <email>andmike@us.ibm.com</email>
181 </para></listitem>
182 <listitem><para>
183 James Bottomley <email>James.Bottomley@steeleye.com</email>
184 </para></listitem>
185 <listitem><para>
186 Patrick Mansfield <email>patmans@us.ibm.com</email>
187 </para></listitem>
188 </orderedlist>
189 </para>
190   </chapter>
191
192 </book>