Commit 29687512c0b084957112cc2c0743ce34cd0d5055
1 parent
8816624222
Exists in
master
and in
7 other branches
[SCSI] fix up documentation for change in ->queuecommand to lockless calling
The current doc still says we call it with the host lock held, which is going to cause confusion. Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Showing 1 changed file with 31 additions and 28 deletions Inline Diff
Documentation/scsi/scsi_mid_low_api.txt
1 | Linux Kernel 2.6 series | 1 | Linux Kernel 2.6 series |
2 | SCSI mid_level - lower_level driver interface | 2 | SCSI mid_level - lower_level driver interface |
3 | ============================================= | 3 | ============================================= |
4 | 4 | ||
5 | Introduction | 5 | Introduction |
6 | ============ | 6 | ============ |
7 | This document outlines the interface between the Linux SCSI mid level and | 7 | This document outlines the interface between the Linux SCSI mid level and |
8 | SCSI lower level drivers. Lower level drivers (LLDs) are variously called | 8 | SCSI lower level drivers. Lower level drivers (LLDs) are variously called |
9 | host bus adapter (HBA) drivers and host drivers (HD). A "host" in this | 9 | host bus adapter (HBA) drivers and host drivers (HD). A "host" in this |
10 | context is a bridge between a computer IO bus (e.g. PCI or ISA) and a | 10 | context is a bridge between a computer IO bus (e.g. PCI or ISA) and a |
11 | single SCSI initiator port on a SCSI transport. An "initiator" port | 11 | single SCSI initiator port on a SCSI transport. An "initiator" port |
12 | (SCSI terminology, see SAM-3 at http://www.t10.org) sends SCSI commands | 12 | (SCSI terminology, see SAM-3 at http://www.t10.org) sends SCSI commands |
13 | to "target" SCSI ports (e.g. disks). There can be many LLDs in a running | 13 | to "target" SCSI ports (e.g. disks). There can be many LLDs in a running |
14 | system, but only one per hardware type. Most LLDs can control one or more | 14 | system, but only one per hardware type. Most LLDs can control one or more |
15 | SCSI HBAs. Some HBAs contain multiple hosts. | 15 | SCSI HBAs. Some HBAs contain multiple hosts. |
16 | 16 | ||
17 | In some cases the SCSI transport is an external bus that already has | 17 | In some cases the SCSI transport is an external bus that already has |
18 | its own subsystem in Linux (e.g. USB and ieee1394). In such cases the | 18 | its own subsystem in Linux (e.g. USB and ieee1394). In such cases the |
19 | SCSI subsystem LLD is a software bridge to the other driver subsystem. | 19 | SCSI subsystem LLD is a software bridge to the other driver subsystem. |
20 | Examples are the usb-storage driver (found in the drivers/usb/storage | 20 | Examples are the usb-storage driver (found in the drivers/usb/storage |
21 | directory) and the ieee1394/sbp2 driver (found in the drivers/ieee1394 | 21 | directory) and the ieee1394/sbp2 driver (found in the drivers/ieee1394 |
22 | directory). | 22 | directory). |
23 | 23 | ||
24 | For example, the aic7xxx LLD controls Adaptec SCSI parallel interface | 24 | For example, the aic7xxx LLD controls Adaptec SCSI parallel interface |
25 | (SPI) controllers based on that company's 7xxx chip series. The aic7xxx | 25 | (SPI) controllers based on that company's 7xxx chip series. The aic7xxx |
26 | LLD can be built into the kernel or loaded as a module. There can only be | 26 | LLD can be built into the kernel or loaded as a module. There can only be |
27 | one aic7xxx LLD running in a Linux system but it may be controlling many | 27 | one aic7xxx LLD running in a Linux system but it may be controlling many |
28 | HBAs. These HBAs might be either on PCI daughter-boards or built into | 28 | HBAs. These HBAs might be either on PCI daughter-boards or built into |
29 | the motherboard (or both). Some aic7xxx based HBAs are dual controllers | 29 | the motherboard (or both). Some aic7xxx based HBAs are dual controllers |
30 | and thus represent two hosts. Like most modern HBAs, each aic7xxx host | 30 | and thus represent two hosts. Like most modern HBAs, each aic7xxx host |
31 | has its own PCI device address. [The one-to-one correspondence between | 31 | has its own PCI device address. [The one-to-one correspondence between |
32 | a SCSI host and a PCI device is common but not required (e.g. with | 32 | a SCSI host and a PCI device is common but not required (e.g. with |
33 | ISA or MCA adapters).] | 33 | ISA or MCA adapters).] |
34 | 34 | ||
35 | The SCSI mid level isolates an LLD from other layers such as the SCSI | 35 | The SCSI mid level isolates an LLD from other layers such as the SCSI |
36 | upper layer drivers and the block layer. | 36 | upper layer drivers and the block layer. |
37 | 37 | ||
38 | This version of the document roughly matches linux kernel version 2.6.8 . | 38 | This version of the document roughly matches linux kernel version 2.6.8 . |
39 | 39 | ||
40 | Documentation | 40 | Documentation |
41 | ============= | 41 | ============= |
42 | There is a SCSI documentation directory within the kernel source tree, | 42 | There is a SCSI documentation directory within the kernel source tree, |
43 | typically Documentation/scsi . Most documents are in plain | 43 | typically Documentation/scsi . Most documents are in plain |
44 | (i.e. ASCII) text. This file is named scsi_mid_low_api.txt and can be | 44 | (i.e. ASCII) text. This file is named scsi_mid_low_api.txt and can be |
45 | found in that directory. A more recent copy of this document may be found | 45 | found in that directory. A more recent copy of this document may be found |
46 | at http://web.archive.org/web/20070107183357rn_1/sg.torque.net/scsi/. | 46 | at http://web.archive.org/web/20070107183357rn_1/sg.torque.net/scsi/. |
47 | Many LLDs are documented there (e.g. aic7xxx.txt). The SCSI mid-level is | 47 | Many LLDs are documented there (e.g. aic7xxx.txt). The SCSI mid-level is |
48 | briefly described in scsi.txt which contains a url to a document | 48 | briefly described in scsi.txt which contains a url to a document |
49 | describing the SCSI subsystem in the lk 2.4 series. Two upper level | 49 | describing the SCSI subsystem in the lk 2.4 series. Two upper level |
50 | drivers have documents in that directory: st.txt (SCSI tape driver) and | 50 | drivers have documents in that directory: st.txt (SCSI tape driver) and |
51 | scsi-generic.txt (for the sg driver). | 51 | scsi-generic.txt (for the sg driver). |
52 | 52 | ||
53 | Some documentation (or urls) for LLDs may be found in the C source code | 53 | Some documentation (or urls) for LLDs may be found in the C source code |
54 | or in the same directory as the C source code. For example to find a url | 54 | or in the same directory as the C source code. For example to find a url |
55 | about the USB mass storage driver see the | 55 | about the USB mass storage driver see the |
56 | /usr/src/linux/drivers/usb/storage directory. | 56 | /usr/src/linux/drivers/usb/storage directory. |
57 | 57 | ||
58 | The Linux kernel source Documentation/DocBook/scsidrivers.tmpl file | 58 | The Linux kernel source Documentation/DocBook/scsidrivers.tmpl file |
59 | refers to this file. With the appropriate DocBook tool-set, this permits | 59 | refers to this file. With the appropriate DocBook tool-set, this permits |
60 | users to generate html, ps and pdf renderings of information within this | 60 | users to generate html, ps and pdf renderings of information within this |
61 | file (e.g. the interface functions). | 61 | file (e.g. the interface functions). |
62 | 62 | ||
63 | Driver structure | 63 | Driver structure |
64 | ================ | 64 | ================ |
65 | Traditionally an LLD for the SCSI subsystem has been at least two files in | 65 | Traditionally an LLD for the SCSI subsystem has been at least two files in |
66 | the drivers/scsi directory. For example, a driver called "xyz" has a header | 66 | the drivers/scsi directory. For example, a driver called "xyz" has a header |
67 | file "xyz.h" and a source file "xyz.c". [Actually there is no good reason | 67 | file "xyz.h" and a source file "xyz.c". [Actually there is no good reason |
68 | why this couldn't all be in one file; the header file is superfluous.] Some | 68 | why this couldn't all be in one file; the header file is superfluous.] Some |
69 | drivers that have been ported to several operating systems have more than | 69 | drivers that have been ported to several operating systems have more than |
70 | two files. For example the aic7xxx driver has separate files for generic | 70 | two files. For example the aic7xxx driver has separate files for generic |
71 | and OS-specific code (e.g. FreeBSD and Linux). Such drivers tend to have | 71 | and OS-specific code (e.g. FreeBSD and Linux). Such drivers tend to have |
72 | their own directory under the drivers/scsi directory. | 72 | their own directory under the drivers/scsi directory. |
73 | 73 | ||
74 | When a new LLD is being added to Linux, the following files (found in the | 74 | When a new LLD is being added to Linux, the following files (found in the |
75 | drivers/scsi directory) will need some attention: Makefile and Kconfig . | 75 | drivers/scsi directory) will need some attention: Makefile and Kconfig . |
76 | It is probably best to study how existing LLDs are organized. | 76 | It is probably best to study how existing LLDs are organized. |
77 | 77 | ||
78 | As the 2.5 series development kernels evolve into the 2.6 series | 78 | As the 2.5 series development kernels evolve into the 2.6 series |
79 | production series, changes are being introduced into this interface. An | 79 | production series, changes are being introduced into this interface. An |
80 | example of this is driver initialization code where there are now 2 models | 80 | example of this is driver initialization code where there are now 2 models |
81 | available. The older one, similar to what was found in the lk 2.4 series, | 81 | available. The older one, similar to what was found in the lk 2.4 series, |
82 | is based on hosts that are detected at HBA driver load time. This will be | 82 | is based on hosts that are detected at HBA driver load time. This will be |
83 | referred to the "passive" initialization model. The newer model allows HBAs | 83 | referred to the "passive" initialization model. The newer model allows HBAs |
84 | to be hot plugged (and unplugged) during the lifetime of the LLD and will | 84 | to be hot plugged (and unplugged) during the lifetime of the LLD and will |
85 | be referred to as the "hotplug" initialization model. The newer model is | 85 | be referred to as the "hotplug" initialization model. The newer model is |
86 | preferred as it can handle both traditional SCSI equipment that is | 86 | preferred as it can handle both traditional SCSI equipment that is |
87 | permanently connected as well as modern "SCSI" devices (e.g. USB or | 87 | permanently connected as well as modern "SCSI" devices (e.g. USB or |
88 | IEEE 1394 connected digital cameras) that are hotplugged. Both | 88 | IEEE 1394 connected digital cameras) that are hotplugged. Both |
89 | initialization models are discussed in the following sections. | 89 | initialization models are discussed in the following sections. |
90 | 90 | ||
91 | An LLD interfaces to the SCSI subsystem several ways: | 91 | An LLD interfaces to the SCSI subsystem several ways: |
92 | a) directly invoking functions supplied by the mid level | 92 | a) directly invoking functions supplied by the mid level |
93 | b) passing a set of function pointers to a registration function | 93 | b) passing a set of function pointers to a registration function |
94 | supplied by the mid level. The mid level will then invoke these | 94 | supplied by the mid level. The mid level will then invoke these |
95 | functions at some point in the future. The LLD will supply | 95 | functions at some point in the future. The LLD will supply |
96 | implementations of these functions. | 96 | implementations of these functions. |
97 | c) direct access to instances of well known data structures maintained | 97 | c) direct access to instances of well known data structures maintained |
98 | by the mid level | 98 | by the mid level |
99 | 99 | ||
100 | Those functions in group a) are listed in a section entitled "Mid level | 100 | Those functions in group a) are listed in a section entitled "Mid level |
101 | supplied functions" below. | 101 | supplied functions" below. |
102 | 102 | ||
103 | Those functions in group b) are listed in a section entitled "Interface | 103 | Those functions in group b) are listed in a section entitled "Interface |
104 | functions" below. Their function pointers are placed in the members of | 104 | functions" below. Their function pointers are placed in the members of |
105 | "struct scsi_host_template", an instance of which is passed to | 105 | "struct scsi_host_template", an instance of which is passed to |
106 | scsi_host_alloc() ** . Those interface functions that the LLD does not | 106 | scsi_host_alloc() ** . Those interface functions that the LLD does not |
107 | wish to supply should have NULL placed in the corresponding member of | 107 | wish to supply should have NULL placed in the corresponding member of |
108 | struct scsi_host_template. Defining an instance of struct | 108 | struct scsi_host_template. Defining an instance of struct |
109 | scsi_host_template at file scope will cause NULL to be placed in function | 109 | scsi_host_template at file scope will cause NULL to be placed in function |
110 | pointer members not explicitly initialized. | 110 | pointer members not explicitly initialized. |
111 | 111 | ||
112 | Those usages in group c) should be handled with care, especially in a | 112 | Those usages in group c) should be handled with care, especially in a |
113 | "hotplug" environment. LLDs should be aware of the lifetime of instances | 113 | "hotplug" environment. LLDs should be aware of the lifetime of instances |
114 | that are shared with the mid level and other layers. | 114 | that are shared with the mid level and other layers. |
115 | 115 | ||
116 | All functions defined within an LLD and all data defined at file scope | 116 | All functions defined within an LLD and all data defined at file scope |
117 | should be static. For example the slave_alloc() function in an LLD | 117 | should be static. For example the slave_alloc() function in an LLD |
118 | called "xxx" could be defined as | 118 | called "xxx" could be defined as |
119 | "static int xxx_slave_alloc(struct scsi_device * sdev) { /* code */ }" | 119 | "static int xxx_slave_alloc(struct scsi_device * sdev) { /* code */ }" |
120 | 120 | ||
121 | ** the scsi_host_alloc() function is a replacement for the rather vaguely | 121 | ** the scsi_host_alloc() function is a replacement for the rather vaguely |
122 | named scsi_register() function in most situations. The scsi_register() | 122 | named scsi_register() function in most situations. The scsi_register() |
123 | and scsi_unregister() functions remain to support legacy LLDs that use | 123 | and scsi_unregister() functions remain to support legacy LLDs that use |
124 | the passive initialization model. | 124 | the passive initialization model. |
125 | 125 | ||
126 | 126 | ||
127 | Hotplug initialization model | 127 | Hotplug initialization model |
128 | ============================ | 128 | ============================ |
129 | In this model an LLD controls when SCSI hosts are introduced and removed | 129 | In this model an LLD controls when SCSI hosts are introduced and removed |
130 | from the SCSI subsystem. Hosts can be introduced as early as driver | 130 | from the SCSI subsystem. Hosts can be introduced as early as driver |
131 | initialization and removed as late as driver shutdown. Typically a driver | 131 | initialization and removed as late as driver shutdown. Typically a driver |
132 | will respond to a sysfs probe() callback that indicates an HBA has been | 132 | will respond to a sysfs probe() callback that indicates an HBA has been |
133 | detected. After confirming that the new device is one that the LLD wants | 133 | detected. After confirming that the new device is one that the LLD wants |
134 | to control, the LLD will initialize the HBA and then register a new host | 134 | to control, the LLD will initialize the HBA and then register a new host |
135 | with the SCSI mid level. | 135 | with the SCSI mid level. |
136 | 136 | ||
137 | During LLD initialization the driver should register itself with the | 137 | During LLD initialization the driver should register itself with the |
138 | appropriate IO bus on which it expects to find HBA(s) (e.g. the PCI bus). | 138 | appropriate IO bus on which it expects to find HBA(s) (e.g. the PCI bus). |
139 | This can probably be done via sysfs. Any driver parameters (especially | 139 | This can probably be done via sysfs. Any driver parameters (especially |
140 | those that are writable after the driver is loaded) could also be | 140 | those that are writable after the driver is loaded) could also be |
141 | registered with sysfs at this point. The SCSI mid level first becomes | 141 | registered with sysfs at this point. The SCSI mid level first becomes |
142 | aware of an LLD when that LLD registers its first HBA. | 142 | aware of an LLD when that LLD registers its first HBA. |
143 | 143 | ||
144 | At some later time, the LLD becomes aware of an HBA and what follows | 144 | At some later time, the LLD becomes aware of an HBA and what follows |
145 | is a typical sequence of calls between the LLD and the mid level. | 145 | is a typical sequence of calls between the LLD and the mid level. |
146 | This example shows the mid level scanning the newly introduced HBA for 3 | 146 | This example shows the mid level scanning the newly introduced HBA for 3 |
147 | scsi devices of which only the first 2 respond: | 147 | scsi devices of which only the first 2 respond: |
148 | 148 | ||
149 | HBA PROBE: assume 2 SCSI devices found in scan | 149 | HBA PROBE: assume 2 SCSI devices found in scan |
150 | LLD mid level LLD | 150 | LLD mid level LLD |
151 | ===-------------------=========--------------------===------ | 151 | ===-------------------=========--------------------===------ |
152 | scsi_host_alloc() --> | 152 | scsi_host_alloc() --> |
153 | scsi_add_host() ----> | 153 | scsi_add_host() ----> |
154 | scsi_scan_host() -------+ | 154 | scsi_scan_host() -------+ |
155 | | | 155 | | |
156 | slave_alloc() | 156 | slave_alloc() |
157 | slave_configure() --> scsi_adjust_queue_depth() | 157 | slave_configure() --> scsi_adjust_queue_depth() |
158 | | | 158 | | |
159 | slave_alloc() | 159 | slave_alloc() |
160 | slave_configure() | 160 | slave_configure() |
161 | | | 161 | | |
162 | slave_alloc() *** | 162 | slave_alloc() *** |
163 | slave_destroy() *** | 163 | slave_destroy() *** |
164 | ------------------------------------------------------------ | 164 | ------------------------------------------------------------ |
165 | 165 | ||
166 | If the LLD wants to adjust the default queue settings, it can invoke | 166 | If the LLD wants to adjust the default queue settings, it can invoke |
167 | scsi_adjust_queue_depth() in its slave_configure() routine. | 167 | scsi_adjust_queue_depth() in its slave_configure() routine. |
168 | 168 | ||
169 | *** For scsi devices that the mid level tries to scan but do not | 169 | *** For scsi devices that the mid level tries to scan but do not |
170 | respond, a slave_alloc(), slave_destroy() pair is called. | 170 | respond, a slave_alloc(), slave_destroy() pair is called. |
171 | 171 | ||
172 | When an HBA is being removed it could be as part of an orderly shutdown | 172 | When an HBA is being removed it could be as part of an orderly shutdown |
173 | associated with the LLD module being unloaded (e.g. with the "rmmod" | 173 | associated with the LLD module being unloaded (e.g. with the "rmmod" |
174 | command) or in response to a "hot unplug" indicated by sysfs()'s | 174 | command) or in response to a "hot unplug" indicated by sysfs()'s |
175 | remove() callback being invoked. In either case, the sequence is the | 175 | remove() callback being invoked. In either case, the sequence is the |
176 | same: | 176 | same: |
177 | 177 | ||
178 | HBA REMOVE: assume 2 SCSI devices attached | 178 | HBA REMOVE: assume 2 SCSI devices attached |
179 | LLD mid level LLD | 179 | LLD mid level LLD |
180 | ===----------------------=========-----------------===------ | 180 | ===----------------------=========-----------------===------ |
181 | scsi_remove_host() ---------+ | 181 | scsi_remove_host() ---------+ |
182 | | | 182 | | |
183 | slave_destroy() | 183 | slave_destroy() |
184 | slave_destroy() | 184 | slave_destroy() |
185 | scsi_host_put() | 185 | scsi_host_put() |
186 | ------------------------------------------------------------ | 186 | ------------------------------------------------------------ |
187 | 187 | ||
188 | It may be useful for a LLD to keep track of struct Scsi_Host instances | 188 | It may be useful for a LLD to keep track of struct Scsi_Host instances |
189 | (a pointer is returned by scsi_host_alloc()). Such instances are "owned" | 189 | (a pointer is returned by scsi_host_alloc()). Such instances are "owned" |
190 | by the mid-level. struct Scsi_Host instances are freed from | 190 | by the mid-level. struct Scsi_Host instances are freed from |
191 | scsi_host_put() when the reference count hits zero. | 191 | scsi_host_put() when the reference count hits zero. |
192 | 192 | ||
193 | Hot unplugging an HBA that controls a disk which is processing SCSI | 193 | Hot unplugging an HBA that controls a disk which is processing SCSI |
194 | commands on a mounted file system is an interesting situation. Reference | 194 | commands on a mounted file system is an interesting situation. Reference |
195 | counting logic is being introduced into the mid level to cope with many | 195 | counting logic is being introduced into the mid level to cope with many |
196 | of the issues involved. See the section on reference counting below. | 196 | of the issues involved. See the section on reference counting below. |
197 | 197 | ||
198 | 198 | ||
199 | The hotplug concept may be extended to SCSI devices. Currently, when an | 199 | The hotplug concept may be extended to SCSI devices. Currently, when an |
200 | HBA is added, the scsi_scan_host() function causes a scan for SCSI devices | 200 | HBA is added, the scsi_scan_host() function causes a scan for SCSI devices |
201 | attached to the HBA's SCSI transport. On newer SCSI transports the HBA | 201 | attached to the HBA's SCSI transport. On newer SCSI transports the HBA |
202 | may become aware of a new SCSI device _after_ the scan has completed. | 202 | may become aware of a new SCSI device _after_ the scan has completed. |
203 | An LLD can use this sequence to make the mid level aware of a SCSI device: | 203 | An LLD can use this sequence to make the mid level aware of a SCSI device: |
204 | 204 | ||
205 | SCSI DEVICE hotplug | 205 | SCSI DEVICE hotplug |
206 | LLD mid level LLD | 206 | LLD mid level LLD |
207 | ===-------------------=========--------------------===------ | 207 | ===-------------------=========--------------------===------ |
208 | scsi_add_device() ------+ | 208 | scsi_add_device() ------+ |
209 | | | 209 | | |
210 | slave_alloc() | 210 | slave_alloc() |
211 | slave_configure() [--> scsi_adjust_queue_depth()] | 211 | slave_configure() [--> scsi_adjust_queue_depth()] |
212 | ------------------------------------------------------------ | 212 | ------------------------------------------------------------ |
213 | 213 | ||
214 | In a similar fashion, an LLD may become aware that a SCSI device has been | 214 | In a similar fashion, an LLD may become aware that a SCSI device has been |
215 | removed (unplugged) or the connection to it has been interrupted. Some | 215 | removed (unplugged) or the connection to it has been interrupted. Some |
216 | existing SCSI transports (e.g. SPI) may not become aware that a SCSI | 216 | existing SCSI transports (e.g. SPI) may not become aware that a SCSI |
217 | device has been removed until a subsequent SCSI command fails which will | 217 | device has been removed until a subsequent SCSI command fails which will |
218 | probably cause that device to be set offline by the mid level. An LLD that | 218 | probably cause that device to be set offline by the mid level. An LLD that |
219 | detects the removal of a SCSI device can instigate its removal from | 219 | detects the removal of a SCSI device can instigate its removal from |
220 | upper layers with this sequence: | 220 | upper layers with this sequence: |
221 | 221 | ||
222 | SCSI DEVICE hot unplug | 222 | SCSI DEVICE hot unplug |
223 | LLD mid level LLD | 223 | LLD mid level LLD |
224 | ===----------------------=========-----------------===------ | 224 | ===----------------------=========-----------------===------ |
225 | scsi_remove_device() -------+ | 225 | scsi_remove_device() -------+ |
226 | | | 226 | | |
227 | slave_destroy() | 227 | slave_destroy() |
228 | ------------------------------------------------------------ | 228 | ------------------------------------------------------------ |
229 | 229 | ||
230 | It may be useful for an LLD to keep track of struct scsi_device instances | 230 | It may be useful for an LLD to keep track of struct scsi_device instances |
231 | (a pointer is passed as the parameter to slave_alloc() and | 231 | (a pointer is passed as the parameter to slave_alloc() and |
232 | slave_configure() callbacks). Such instances are "owned" by the mid-level. | 232 | slave_configure() callbacks). Such instances are "owned" by the mid-level. |
233 | struct scsi_device instances are freed after slave_destroy(). | 233 | struct scsi_device instances are freed after slave_destroy(). |
234 | 234 | ||
235 | 235 | ||
236 | Passive initialization model | 236 | Passive initialization model |
237 | ============================ | 237 | ============================ |
238 | These older LLDs include a file called "scsi_module.c" [yes the ".c" is a | 238 | These older LLDs include a file called "scsi_module.c" [yes the ".c" is a |
239 | little surprising] in their source code. For that file to work an | 239 | little surprising] in their source code. For that file to work an |
240 | instance of struct scsi_host_template with the name "driver_template" | 240 | instance of struct scsi_host_template with the name "driver_template" |
241 | needs to be defined. Here is a typical code sequence used in this model: | 241 | needs to be defined. Here is a typical code sequence used in this model: |
242 | static struct scsi_host_template driver_template = { | 242 | static struct scsi_host_template driver_template = { |
243 | ... | 243 | ... |
244 | }; | 244 | }; |
245 | #include "scsi_module.c" | 245 | #include "scsi_module.c" |
246 | 246 | ||
247 | The scsi_module.c file contains two functions: | 247 | The scsi_module.c file contains two functions: |
248 | - init_this_scsi_driver() which is executed when the LLD is | 248 | - init_this_scsi_driver() which is executed when the LLD is |
249 | initialized (i.e. boot time or module load time) | 249 | initialized (i.e. boot time or module load time) |
250 | - exit_this_scsi_driver() which is executed when the LLD is shut | 250 | - exit_this_scsi_driver() which is executed when the LLD is shut |
251 | down (i.e. module unload time) | 251 | down (i.e. module unload time) |
252 | Note: since these functions are tagged with __init and __exit qualifiers | 252 | Note: since these functions are tagged with __init and __exit qualifiers |
253 | an LLD should not call them explicitly (since the kernel does that). | 253 | an LLD should not call them explicitly (since the kernel does that). |
254 | 254 | ||
255 | Here is an example of an initialization sequence when two hosts are | 255 | Here is an example of an initialization sequence when two hosts are |
256 | detected (so detect() returns 2) and the SCSI bus scan on each host | 256 | detected (so detect() returns 2) and the SCSI bus scan on each host |
257 | finds 1 SCSI device (and a second device does not respond). | 257 | finds 1 SCSI device (and a second device does not respond). |
258 | 258 | ||
259 | LLD mid level LLD | 259 | LLD mid level LLD |
260 | ===----------------------=========-----------------===------ | 260 | ===----------------------=========-----------------===------ |
261 | init_this_scsi_driver() ----+ | 261 | init_this_scsi_driver() ----+ |
262 | | | 262 | | |
263 | detect() -----------------+ | 263 | detect() -----------------+ |
264 | | | | 264 | | | |
265 | | scsi_register() | 265 | | scsi_register() |
266 | | scsi_register() | 266 | | scsi_register() |
267 | | | 267 | | |
268 | slave_alloc() | 268 | slave_alloc() |
269 | slave_configure() --> scsi_adjust_queue_depth() | 269 | slave_configure() --> scsi_adjust_queue_depth() |
270 | slave_alloc() *** | 270 | slave_alloc() *** |
271 | slave_destroy() *** | 271 | slave_destroy() *** |
272 | | | 272 | | |
273 | slave_alloc() | 273 | slave_alloc() |
274 | slave_configure() | 274 | slave_configure() |
275 | slave_alloc() *** | 275 | slave_alloc() *** |
276 | slave_destroy() *** | 276 | slave_destroy() *** |
277 | ------------------------------------------------------------ | 277 | ------------------------------------------------------------ |
278 | 278 | ||
279 | The mid level invokes scsi_adjust_queue_depth() with tagged queuing off and | 279 | The mid level invokes scsi_adjust_queue_depth() with tagged queuing off and |
280 | "cmd_per_lun" for that host as the queue length. These settings can be | 280 | "cmd_per_lun" for that host as the queue length. These settings can be |
281 | overridden by a slave_configure() supplied by the LLD. | 281 | overridden by a slave_configure() supplied by the LLD. |
282 | 282 | ||
283 | *** For scsi devices that the mid level tries to scan but do not | 283 | *** For scsi devices that the mid level tries to scan but do not |
284 | respond, a slave_alloc(), slave_destroy() pair is called. | 284 | respond, a slave_alloc(), slave_destroy() pair is called. |
285 | 285 | ||
286 | Here is an LLD shutdown sequence: | 286 | Here is an LLD shutdown sequence: |
287 | 287 | ||
288 | LLD mid level LLD | 288 | LLD mid level LLD |
289 | ===----------------------=========-----------------===------ | 289 | ===----------------------=========-----------------===------ |
290 | exit_this_scsi_driver() ----+ | 290 | exit_this_scsi_driver() ----+ |
291 | | | 291 | | |
292 | slave_destroy() | 292 | slave_destroy() |
293 | release() --> scsi_unregister() | 293 | release() --> scsi_unregister() |
294 | | | 294 | | |
295 | slave_destroy() | 295 | slave_destroy() |
296 | release() --> scsi_unregister() | 296 | release() --> scsi_unregister() |
297 | ------------------------------------------------------------ | 297 | ------------------------------------------------------------ |
298 | 298 | ||
299 | An LLD need not define slave_destroy() (i.e. it is optional). | 299 | An LLD need not define slave_destroy() (i.e. it is optional). |
300 | 300 | ||
301 | The shortcoming of the "passive initialization model" is that host | 301 | The shortcoming of the "passive initialization model" is that host |
302 | registration and de-registration are (typically) tied to LLD initialization | 302 | registration and de-registration are (typically) tied to LLD initialization |
303 | and shutdown. Once the LLD is initialized then a new host that appears | 303 | and shutdown. Once the LLD is initialized then a new host that appears |
304 | (e.g. via hotplugging) cannot easily be added without a redundant | 304 | (e.g. via hotplugging) cannot easily be added without a redundant |
305 | driver shutdown and re-initialization. It may be possible to write an LLD | 305 | driver shutdown and re-initialization. It may be possible to write an LLD |
306 | that uses both initialization models. | 306 | that uses both initialization models. |
307 | 307 | ||
308 | 308 | ||
309 | Reference Counting | 309 | Reference Counting |
310 | ================== | 310 | ================== |
311 | The Scsi_Host structure has had reference counting infrastructure added. | 311 | The Scsi_Host structure has had reference counting infrastructure added. |
312 | This effectively spreads the ownership of struct Scsi_Host instances | 312 | This effectively spreads the ownership of struct Scsi_Host instances |
313 | across the various SCSI layers which use them. Previously such instances | 313 | across the various SCSI layers which use them. Previously such instances |
314 | were exclusively owned by the mid level. LLDs would not usually need to | 314 | were exclusively owned by the mid level. LLDs would not usually need to |
315 | directly manipulate these reference counts but there may be some cases | 315 | directly manipulate these reference counts but there may be some cases |
316 | where they do. | 316 | where they do. |
317 | 317 | ||
318 | There are 3 reference counting functions of interest associated with | 318 | There are 3 reference counting functions of interest associated with |
319 | struct Scsi_Host: | 319 | struct Scsi_Host: |
320 | - scsi_host_alloc(): returns a pointer to new instance of struct | 320 | - scsi_host_alloc(): returns a pointer to new instance of struct |
321 | Scsi_Host which has its reference count ^^ set to 1 | 321 | Scsi_Host which has its reference count ^^ set to 1 |
322 | - scsi_host_get(): adds 1 to the reference count of the given instance | 322 | - scsi_host_get(): adds 1 to the reference count of the given instance |
323 | - scsi_host_put(): decrements 1 from the reference count of the given | 323 | - scsi_host_put(): decrements 1 from the reference count of the given |
324 | instance. If the reference count reaches 0 then the given instance | 324 | instance. If the reference count reaches 0 then the given instance |
325 | is freed | 325 | is freed |
326 | 326 | ||
327 | The Scsi_device structure has had reference counting infrastructure added. | 327 | The Scsi_device structure has had reference counting infrastructure added. |
328 | This effectively spreads the ownership of struct Scsi_device instances | 328 | This effectively spreads the ownership of struct Scsi_device instances |
329 | across the various SCSI layers which use them. Previously such instances | 329 | across the various SCSI layers which use them. Previously such instances |
330 | were exclusively owned by the mid level. See the access functions declared | 330 | were exclusively owned by the mid level. See the access functions declared |
331 | towards the end of include/scsi/scsi_device.h . If an LLD wants to keep | 331 | towards the end of include/scsi/scsi_device.h . If an LLD wants to keep |
332 | a copy of a pointer to a Scsi_device instance it should use scsi_device_get() | 332 | a copy of a pointer to a Scsi_device instance it should use scsi_device_get() |
333 | to bump its reference count. When it is finished with the pointer it can | 333 | to bump its reference count. When it is finished with the pointer it can |
334 | use scsi_device_put() to decrement its reference count (and potentially | 334 | use scsi_device_put() to decrement its reference count (and potentially |
335 | delete it). | 335 | delete it). |
336 | 336 | ||
337 | ^^ struct Scsi_Host actually has 2 reference counts which are manipulated | 337 | ^^ struct Scsi_Host actually has 2 reference counts which are manipulated |
338 | in parallel by these functions. | 338 | in parallel by these functions. |
339 | 339 | ||
340 | 340 | ||
341 | Conventions | 341 | Conventions |
342 | =========== | 342 | =========== |
343 | First, Linus Torvalds's thoughts on C coding style can be found in the | 343 | First, Linus Torvalds's thoughts on C coding style can be found in the |
344 | Documentation/CodingStyle file. | 344 | Documentation/CodingStyle file. |
345 | 345 | ||
346 | Next, there is a movement to "outlaw" typedefs introducing synonyms for | 346 | Next, there is a movement to "outlaw" typedefs introducing synonyms for |
347 | struct tags. Both can be still found in the SCSI subsystem, but | 347 | struct tags. Both can be still found in the SCSI subsystem, but |
348 | the typedefs have been moved to a single file, scsi_typedefs.h to | 348 | the typedefs have been moved to a single file, scsi_typedefs.h to |
349 | make their future removal easier, for example: | 349 | make their future removal easier, for example: |
350 | "typedef struct scsi_cmnd Scsi_Cmnd;" | 350 | "typedef struct scsi_cmnd Scsi_Cmnd;" |
351 | 351 | ||
352 | Also, most C99 enhancements are encouraged to the extent they are supported | 352 | Also, most C99 enhancements are encouraged to the extent they are supported |
353 | by the relevant gcc compilers. So C99 style structure and array | 353 | by the relevant gcc compilers. So C99 style structure and array |
354 | initializers are encouraged where appropriate. Don't go too far, | 354 | initializers are encouraged where appropriate. Don't go too far, |
355 | VLAs are not properly supported yet. An exception to this is the use of | 355 | VLAs are not properly supported yet. An exception to this is the use of |
356 | "//" style comments; /*...*/ comments are still preferred in Linux. | 356 | "//" style comments; /*...*/ comments are still preferred in Linux. |
357 | 357 | ||
358 | Well written, tested and documented code, need not be re-formatted to | 358 | Well written, tested and documented code, need not be re-formatted to |
359 | comply with the above conventions. For example, the aic7xxx driver | 359 | comply with the above conventions. For example, the aic7xxx driver |
360 | comes to Linux from FreeBSD and Adaptec's own labs. No doubt FreeBSD | 360 | comes to Linux from FreeBSD and Adaptec's own labs. No doubt FreeBSD |
361 | and Adaptec have their own coding conventions. | 361 | and Adaptec have their own coding conventions. |
362 | 362 | ||
363 | 363 | ||
364 | Mid level supplied functions | 364 | Mid level supplied functions |
365 | ============================ | 365 | ============================ |
366 | These functions are supplied by the SCSI mid level for use by LLDs. | 366 | These functions are supplied by the SCSI mid level for use by LLDs. |
367 | The names (i.e. entry points) of these functions are exported | 367 | The names (i.e. entry points) of these functions are exported |
368 | so an LLD that is a module can access them. The kernel will | 368 | so an LLD that is a module can access them. The kernel will |
369 | arrange for the SCSI mid level to be loaded and initialized before any LLD | 369 | arrange for the SCSI mid level to be loaded and initialized before any LLD |
370 | is initialized. The functions below are listed alphabetically and their | 370 | is initialized. The functions below are listed alphabetically and their |
371 | names all start with "scsi_". | 371 | names all start with "scsi_". |
372 | 372 | ||
373 | Summary: | 373 | Summary: |
374 | scsi_activate_tcq - turn on tag command queueing | 374 | scsi_activate_tcq - turn on tag command queueing |
375 | scsi_add_device - creates new scsi device (lu) instance | 375 | scsi_add_device - creates new scsi device (lu) instance |
376 | scsi_add_host - perform sysfs registration and set up transport class | 376 | scsi_add_host - perform sysfs registration and set up transport class |
377 | scsi_adjust_queue_depth - change the queue depth on a SCSI device | 377 | scsi_adjust_queue_depth - change the queue depth on a SCSI device |
378 | scsi_bios_ptable - return copy of block device's partition table | 378 | scsi_bios_ptable - return copy of block device's partition table |
379 | scsi_block_requests - prevent further commands being queued to given host | 379 | scsi_block_requests - prevent further commands being queued to given host |
380 | scsi_deactivate_tcq - turn off tag command queueing | 380 | scsi_deactivate_tcq - turn off tag command queueing |
381 | scsi_host_alloc - return a new scsi_host instance whose refcount==1 | 381 | scsi_host_alloc - return a new scsi_host instance whose refcount==1 |
382 | scsi_host_get - increments Scsi_Host instance's refcount | 382 | scsi_host_get - increments Scsi_Host instance's refcount |
383 | scsi_host_put - decrements Scsi_Host instance's refcount (free if 0) | 383 | scsi_host_put - decrements Scsi_Host instance's refcount (free if 0) |
384 | scsi_partsize - parse partition table into cylinders, heads + sectors | 384 | scsi_partsize - parse partition table into cylinders, heads + sectors |
385 | scsi_register - create and register a scsi host adapter instance. | 385 | scsi_register - create and register a scsi host adapter instance. |
386 | scsi_remove_device - detach and remove a SCSI device | 386 | scsi_remove_device - detach and remove a SCSI device |
387 | scsi_remove_host - detach and remove all SCSI devices owned by host | 387 | scsi_remove_host - detach and remove all SCSI devices owned by host |
388 | scsi_report_bus_reset - report scsi _bus_ reset observed | 388 | scsi_report_bus_reset - report scsi _bus_ reset observed |
389 | scsi_scan_host - scan SCSI bus | 389 | scsi_scan_host - scan SCSI bus |
390 | scsi_track_queue_full - track successive QUEUE_FULL events | 390 | scsi_track_queue_full - track successive QUEUE_FULL events |
391 | scsi_unblock_requests - allow further commands to be queued to given host | 391 | scsi_unblock_requests - allow further commands to be queued to given host |
392 | scsi_unregister - [calls scsi_host_put()] | 392 | scsi_unregister - [calls scsi_host_put()] |
393 | 393 | ||
394 | 394 | ||
395 | Details: | 395 | Details: |
396 | 396 | ||
397 | /** | 397 | /** |
398 | * scsi_activate_tcq - turn on tag command queueing ("ordered" task attribute) | 398 | * scsi_activate_tcq - turn on tag command queueing ("ordered" task attribute) |
399 | * @sdev: device to turn on TCQ for | 399 | * @sdev: device to turn on TCQ for |
400 | * @depth: queue depth | 400 | * @depth: queue depth |
401 | * | 401 | * |
402 | * Returns nothing | 402 | * Returns nothing |
403 | * | 403 | * |
404 | * Might block: no | 404 | * Might block: no |
405 | * | 405 | * |
406 | * Notes: Eventually, it is hoped depth would be the maximum depth | 406 | * Notes: Eventually, it is hoped depth would be the maximum depth |
407 | * the device could cope with and the real queue depth | 407 | * the device could cope with and the real queue depth |
408 | * would be adjustable from 0 to depth. | 408 | * would be adjustable from 0 to depth. |
409 | * | 409 | * |
410 | * Defined (inline) in: include/scsi/scsi_tcq.h | 410 | * Defined (inline) in: include/scsi/scsi_tcq.h |
411 | **/ | 411 | **/ |
412 | void scsi_activate_tcq(struct scsi_device *sdev, int depth) | 412 | void scsi_activate_tcq(struct scsi_device *sdev, int depth) |
413 | 413 | ||
414 | 414 | ||
415 | /** | 415 | /** |
416 | * scsi_add_device - creates new scsi device (lu) instance | 416 | * scsi_add_device - creates new scsi device (lu) instance |
417 | * @shost: pointer to scsi host instance | 417 | * @shost: pointer to scsi host instance |
418 | * @channel: channel number (rarely other than 0) | 418 | * @channel: channel number (rarely other than 0) |
419 | * @id: target id number | 419 | * @id: target id number |
420 | * @lun: logical unit number | 420 | * @lun: logical unit number |
421 | * | 421 | * |
422 | * Returns pointer to new struct scsi_device instance or | 422 | * Returns pointer to new struct scsi_device instance or |
423 | * ERR_PTR(-ENODEV) (or some other bent pointer) if something is | 423 | * ERR_PTR(-ENODEV) (or some other bent pointer) if something is |
424 | * wrong (e.g. no lu responds at given address) | 424 | * wrong (e.g. no lu responds at given address) |
425 | * | 425 | * |
426 | * Might block: yes | 426 | * Might block: yes |
427 | * | 427 | * |
428 | * Notes: This call is usually performed internally during a scsi | 428 | * Notes: This call is usually performed internally during a scsi |
429 | * bus scan when an HBA is added (i.e. scsi_scan_host()). So it | 429 | * bus scan when an HBA is added (i.e. scsi_scan_host()). So it |
430 | * should only be called if the HBA becomes aware of a new scsi | 430 | * should only be called if the HBA becomes aware of a new scsi |
431 | * device (lu) after scsi_scan_host() has completed. If successful | 431 | * device (lu) after scsi_scan_host() has completed. If successful |
432 | * this call can lead to slave_alloc() and slave_configure() callbacks | 432 | * this call can lead to slave_alloc() and slave_configure() callbacks |
433 | * into the LLD. | 433 | * into the LLD. |
434 | * | 434 | * |
435 | * Defined in: drivers/scsi/scsi_scan.c | 435 | * Defined in: drivers/scsi/scsi_scan.c |
436 | **/ | 436 | **/ |
437 | struct scsi_device * scsi_add_device(struct Scsi_Host *shost, | 437 | struct scsi_device * scsi_add_device(struct Scsi_Host *shost, |
438 | unsigned int channel, | 438 | unsigned int channel, |
439 | unsigned int id, unsigned int lun) | 439 | unsigned int id, unsigned int lun) |
440 | 440 | ||
441 | 441 | ||
442 | /** | 442 | /** |
443 | * scsi_add_host - perform sysfs registration and set up transport class | 443 | * scsi_add_host - perform sysfs registration and set up transport class |
444 | * @shost: pointer to scsi host instance | 444 | * @shost: pointer to scsi host instance |
445 | * @dev: pointer to struct device of type scsi class | 445 | * @dev: pointer to struct device of type scsi class |
446 | * | 446 | * |
447 | * Returns 0 on success, negative errno of failure (e.g. -ENOMEM) | 447 | * Returns 0 on success, negative errno of failure (e.g. -ENOMEM) |
448 | * | 448 | * |
449 | * Might block: no | 449 | * Might block: no |
450 | * | 450 | * |
451 | * Notes: Only required in "hotplug initialization model" after a | 451 | * Notes: Only required in "hotplug initialization model" after a |
452 | * successful call to scsi_host_alloc(). This function does not | 452 | * successful call to scsi_host_alloc(). This function does not |
453 | * scan the bus; this can be done by calling scsi_scan_host() or | 453 | * scan the bus; this can be done by calling scsi_scan_host() or |
454 | * in some other transport-specific way. The LLD must set up | 454 | * in some other transport-specific way. The LLD must set up |
455 | * the transport template before calling this function and may only | 455 | * the transport template before calling this function and may only |
456 | * access the transport class data after this function has been called. | 456 | * access the transport class data after this function has been called. |
457 | * | 457 | * |
458 | * Defined in: drivers/scsi/hosts.c | 458 | * Defined in: drivers/scsi/hosts.c |
459 | **/ | 459 | **/ |
460 | int scsi_add_host(struct Scsi_Host *shost, struct device * dev) | 460 | int scsi_add_host(struct Scsi_Host *shost, struct device * dev) |
461 | 461 | ||
462 | 462 | ||
463 | /** | 463 | /** |
464 | * scsi_adjust_queue_depth - allow LLD to change queue depth on a SCSI device | 464 | * scsi_adjust_queue_depth - allow LLD to change queue depth on a SCSI device |
465 | * @sdev: pointer to SCSI device to change queue depth on | 465 | * @sdev: pointer to SCSI device to change queue depth on |
466 | * @tagged: 0 - no tagged queuing | 466 | * @tagged: 0 - no tagged queuing |
467 | * MSG_SIMPLE_TAG - simple tagged queuing | 467 | * MSG_SIMPLE_TAG - simple tagged queuing |
468 | * MSG_ORDERED_TAG - ordered tagged queuing | 468 | * MSG_ORDERED_TAG - ordered tagged queuing |
469 | * @tags Number of tags allowed if tagged queuing enabled, | 469 | * @tags Number of tags allowed if tagged queuing enabled, |
470 | * or number of commands the LLD can queue up | 470 | * or number of commands the LLD can queue up |
471 | * in non-tagged mode (as per cmd_per_lun). | 471 | * in non-tagged mode (as per cmd_per_lun). |
472 | * | 472 | * |
473 | * Returns nothing | 473 | * Returns nothing |
474 | * | 474 | * |
475 | * Might block: no | 475 | * Might block: no |
476 | * | 476 | * |
477 | * Notes: Can be invoked any time on a SCSI device controlled by this | 477 | * Notes: Can be invoked any time on a SCSI device controlled by this |
478 | * LLD. [Specifically during and after slave_configure() and prior to | 478 | * LLD. [Specifically during and after slave_configure() and prior to |
479 | * slave_destroy().] Can safely be invoked from interrupt code. Actual | 479 | * slave_destroy().] Can safely be invoked from interrupt code. Actual |
480 | * queue depth change may be delayed until the next command is being | 480 | * queue depth change may be delayed until the next command is being |
481 | * processed. See also scsi_activate_tcq() and scsi_deactivate_tcq(). | 481 | * processed. See also scsi_activate_tcq() and scsi_deactivate_tcq(). |
482 | * | 482 | * |
483 | * Defined in: drivers/scsi/scsi.c [see source code for more notes] | 483 | * Defined in: drivers/scsi/scsi.c [see source code for more notes] |
484 | * | 484 | * |
485 | **/ | 485 | **/ |
486 | void scsi_adjust_queue_depth(struct scsi_device * sdev, int tagged, | 486 | void scsi_adjust_queue_depth(struct scsi_device * sdev, int tagged, |
487 | int tags) | 487 | int tags) |
488 | 488 | ||
489 | 489 | ||
490 | /** | 490 | /** |
491 | * scsi_bios_ptable - return copy of block device's partition table | 491 | * scsi_bios_ptable - return copy of block device's partition table |
492 | * @dev: pointer to block device | 492 | * @dev: pointer to block device |
493 | * | 493 | * |
494 | * Returns pointer to partition table, or NULL for failure | 494 | * Returns pointer to partition table, or NULL for failure |
495 | * | 495 | * |
496 | * Might block: yes | 496 | * Might block: yes |
497 | * | 497 | * |
498 | * Notes: Caller owns memory returned (free with kfree() ) | 498 | * Notes: Caller owns memory returned (free with kfree() ) |
499 | * | 499 | * |
500 | * Defined in: drivers/scsi/scsicam.c | 500 | * Defined in: drivers/scsi/scsicam.c |
501 | **/ | 501 | **/ |
502 | unsigned char *scsi_bios_ptable(struct block_device *dev) | 502 | unsigned char *scsi_bios_ptable(struct block_device *dev) |
503 | 503 | ||
504 | 504 | ||
505 | /** | 505 | /** |
506 | * scsi_block_requests - prevent further commands being queued to given host | 506 | * scsi_block_requests - prevent further commands being queued to given host |
507 | * | 507 | * |
508 | * @shost: pointer to host to block commands on | 508 | * @shost: pointer to host to block commands on |
509 | * | 509 | * |
510 | * Returns nothing | 510 | * Returns nothing |
511 | * | 511 | * |
512 | * Might block: no | 512 | * Might block: no |
513 | * | 513 | * |
514 | * Notes: There is no timer nor any other means by which the requests | 514 | * Notes: There is no timer nor any other means by which the requests |
515 | * get unblocked other than the LLD calling scsi_unblock_requests(). | 515 | * get unblocked other than the LLD calling scsi_unblock_requests(). |
516 | * | 516 | * |
517 | * Defined in: drivers/scsi/scsi_lib.c | 517 | * Defined in: drivers/scsi/scsi_lib.c |
518 | **/ | 518 | **/ |
519 | void scsi_block_requests(struct Scsi_Host * shost) | 519 | void scsi_block_requests(struct Scsi_Host * shost) |
520 | 520 | ||
521 | 521 | ||
522 | /** | 522 | /** |
523 | * scsi_deactivate_tcq - turn off tag command queueing | 523 | * scsi_deactivate_tcq - turn off tag command queueing |
524 | * @sdev: device to turn off TCQ for | 524 | * @sdev: device to turn off TCQ for |
525 | * @depth: queue depth (stored in sdev) | 525 | * @depth: queue depth (stored in sdev) |
526 | * | 526 | * |
527 | * Returns nothing | 527 | * Returns nothing |
528 | * | 528 | * |
529 | * Might block: no | 529 | * Might block: no |
530 | * | 530 | * |
531 | * Defined (inline) in: include/scsi/scsi_tcq.h | 531 | * Defined (inline) in: include/scsi/scsi_tcq.h |
532 | **/ | 532 | **/ |
533 | void scsi_deactivate_tcq(struct scsi_device *sdev, int depth) | 533 | void scsi_deactivate_tcq(struct scsi_device *sdev, int depth) |
534 | 534 | ||
535 | 535 | ||
536 | /** | 536 | /** |
537 | * scsi_host_alloc - create a scsi host adapter instance and perform basic | 537 | * scsi_host_alloc - create a scsi host adapter instance and perform basic |
538 | * initialization. | 538 | * initialization. |
539 | * @sht: pointer to scsi host template | 539 | * @sht: pointer to scsi host template |
540 | * @privsize: extra bytes to allocate in hostdata array (which is the | 540 | * @privsize: extra bytes to allocate in hostdata array (which is the |
541 | * last member of the returned Scsi_Host instance) | 541 | * last member of the returned Scsi_Host instance) |
542 | * | 542 | * |
543 | * Returns pointer to new Scsi_Host instance or NULL on failure | 543 | * Returns pointer to new Scsi_Host instance or NULL on failure |
544 | * | 544 | * |
545 | * Might block: yes | 545 | * Might block: yes |
546 | * | 546 | * |
547 | * Notes: When this call returns to the LLD, the SCSI bus scan on | 547 | * Notes: When this call returns to the LLD, the SCSI bus scan on |
548 | * this host has _not_ yet been done. | 548 | * this host has _not_ yet been done. |
549 | * The hostdata array (by default zero length) is a per host scratch | 549 | * The hostdata array (by default zero length) is a per host scratch |
550 | * area for the LLD's exclusive use. | 550 | * area for the LLD's exclusive use. |
551 | * Both associated refcounting objects have their refcount set to 1. | 551 | * Both associated refcounting objects have their refcount set to 1. |
552 | * Full registration (in sysfs) and a bus scan are performed later when | 552 | * Full registration (in sysfs) and a bus scan are performed later when |
553 | * scsi_add_host() and scsi_scan_host() are called. | 553 | * scsi_add_host() and scsi_scan_host() are called. |
554 | * | 554 | * |
555 | * Defined in: drivers/scsi/hosts.c . | 555 | * Defined in: drivers/scsi/hosts.c . |
556 | **/ | 556 | **/ |
557 | struct Scsi_Host * scsi_host_alloc(struct scsi_host_template * sht, | 557 | struct Scsi_Host * scsi_host_alloc(struct scsi_host_template * sht, |
558 | int privsize) | 558 | int privsize) |
559 | 559 | ||
560 | 560 | ||
561 | /** | 561 | /** |
562 | * scsi_host_get - increment Scsi_Host instance refcount | 562 | * scsi_host_get - increment Scsi_Host instance refcount |
563 | * @shost: pointer to struct Scsi_Host instance | 563 | * @shost: pointer to struct Scsi_Host instance |
564 | * | 564 | * |
565 | * Returns nothing | 565 | * Returns nothing |
566 | * | 566 | * |
567 | * Might block: currently may block but may be changed to not block | 567 | * Might block: currently may block but may be changed to not block |
568 | * | 568 | * |
569 | * Notes: Actually increments the counts in two sub-objects | 569 | * Notes: Actually increments the counts in two sub-objects |
570 | * | 570 | * |
571 | * Defined in: drivers/scsi/hosts.c | 571 | * Defined in: drivers/scsi/hosts.c |
572 | **/ | 572 | **/ |
573 | void scsi_host_get(struct Scsi_Host *shost) | 573 | void scsi_host_get(struct Scsi_Host *shost) |
574 | 574 | ||
575 | 575 | ||
576 | /** | 576 | /** |
577 | * scsi_host_put - decrement Scsi_Host instance refcount, free if 0 | 577 | * scsi_host_put - decrement Scsi_Host instance refcount, free if 0 |
578 | * @shost: pointer to struct Scsi_Host instance | 578 | * @shost: pointer to struct Scsi_Host instance |
579 | * | 579 | * |
580 | * Returns nothing | 580 | * Returns nothing |
581 | * | 581 | * |
582 | * Might block: currently may block but may be changed to not block | 582 | * Might block: currently may block but may be changed to not block |
583 | * | 583 | * |
584 | * Notes: Actually decrements the counts in two sub-objects. If the | 584 | * Notes: Actually decrements the counts in two sub-objects. If the |
585 | * latter refcount reaches 0, the Scsi_Host instance is freed. | 585 | * latter refcount reaches 0, the Scsi_Host instance is freed. |
586 | * The LLD need not worry exactly when the Scsi_Host instance is | 586 | * The LLD need not worry exactly when the Scsi_Host instance is |
587 | * freed, it just shouldn't access the instance after it has balanced | 587 | * freed, it just shouldn't access the instance after it has balanced |
588 | * out its refcount usage. | 588 | * out its refcount usage. |
589 | * | 589 | * |
590 | * Defined in: drivers/scsi/hosts.c | 590 | * Defined in: drivers/scsi/hosts.c |
591 | **/ | 591 | **/ |
592 | void scsi_host_put(struct Scsi_Host *shost) | 592 | void scsi_host_put(struct Scsi_Host *shost) |
593 | 593 | ||
594 | 594 | ||
595 | /** | 595 | /** |
596 | * scsi_partsize - parse partition table into cylinders, heads + sectors | 596 | * scsi_partsize - parse partition table into cylinders, heads + sectors |
597 | * @buf: pointer to partition table | 597 | * @buf: pointer to partition table |
598 | * @capacity: size of (total) disk in 512 byte sectors | 598 | * @capacity: size of (total) disk in 512 byte sectors |
599 | * @cyls: outputs number of cylinders calculated via this pointer | 599 | * @cyls: outputs number of cylinders calculated via this pointer |
600 | * @hds: outputs number of heads calculated via this pointer | 600 | * @hds: outputs number of heads calculated via this pointer |
601 | * @secs: outputs number of sectors calculated via this pointer | 601 | * @secs: outputs number of sectors calculated via this pointer |
602 | * | 602 | * |
603 | * Returns 0 on success, -1 on failure | 603 | * Returns 0 on success, -1 on failure |
604 | * | 604 | * |
605 | * Might block: no | 605 | * Might block: no |
606 | * | 606 | * |
607 | * Notes: Caller owns memory returned (free with kfree() ) | 607 | * Notes: Caller owns memory returned (free with kfree() ) |
608 | * | 608 | * |
609 | * Defined in: drivers/scsi/scsicam.c | 609 | * Defined in: drivers/scsi/scsicam.c |
610 | **/ | 610 | **/ |
611 | int scsi_partsize(unsigned char *buf, unsigned long capacity, | 611 | int scsi_partsize(unsigned char *buf, unsigned long capacity, |
612 | unsigned int *cyls, unsigned int *hds, unsigned int *secs) | 612 | unsigned int *cyls, unsigned int *hds, unsigned int *secs) |
613 | 613 | ||
614 | 614 | ||
615 | /** | 615 | /** |
616 | * scsi_register - create and register a scsi host adapter instance. | 616 | * scsi_register - create and register a scsi host adapter instance. |
617 | * @sht: pointer to scsi host template | 617 | * @sht: pointer to scsi host template |
618 | * @privsize: extra bytes to allocate in hostdata array (which is the | 618 | * @privsize: extra bytes to allocate in hostdata array (which is the |
619 | * last member of the returned Scsi_Host instance) | 619 | * last member of the returned Scsi_Host instance) |
620 | * | 620 | * |
621 | * Returns pointer to new Scsi_Host instance or NULL on failure | 621 | * Returns pointer to new Scsi_Host instance or NULL on failure |
622 | * | 622 | * |
623 | * Might block: yes | 623 | * Might block: yes |
624 | * | 624 | * |
625 | * Notes: When this call returns to the LLD, the SCSI bus scan on | 625 | * Notes: When this call returns to the LLD, the SCSI bus scan on |
626 | * this host has _not_ yet been done. | 626 | * this host has _not_ yet been done. |
627 | * The hostdata array (by default zero length) is a per host scratch | 627 | * The hostdata array (by default zero length) is a per host scratch |
628 | * area for the LLD. | 628 | * area for the LLD. |
629 | * | 629 | * |
630 | * Defined in: drivers/scsi/hosts.c . | 630 | * Defined in: drivers/scsi/hosts.c . |
631 | **/ | 631 | **/ |
632 | struct Scsi_Host * scsi_register(struct scsi_host_template * sht, | 632 | struct Scsi_Host * scsi_register(struct scsi_host_template * sht, |
633 | int privsize) | 633 | int privsize) |
634 | 634 | ||
635 | 635 | ||
636 | /** | 636 | /** |
637 | * scsi_remove_device - detach and remove a SCSI device | 637 | * scsi_remove_device - detach and remove a SCSI device |
638 | * @sdev: a pointer to a scsi device instance | 638 | * @sdev: a pointer to a scsi device instance |
639 | * | 639 | * |
640 | * Returns value: 0 on success, -EINVAL if device not attached | 640 | * Returns value: 0 on success, -EINVAL if device not attached |
641 | * | 641 | * |
642 | * Might block: yes | 642 | * Might block: yes |
643 | * | 643 | * |
644 | * Notes: If an LLD becomes aware that a scsi device (lu) has | 644 | * Notes: If an LLD becomes aware that a scsi device (lu) has |
645 | * been removed but its host is still present then it can request | 645 | * been removed but its host is still present then it can request |
646 | * the removal of that scsi device. If successful this call will | 646 | * the removal of that scsi device. If successful this call will |
647 | * lead to the slave_destroy() callback being invoked. sdev is an | 647 | * lead to the slave_destroy() callback being invoked. sdev is an |
648 | * invalid pointer after this call. | 648 | * invalid pointer after this call. |
649 | * | 649 | * |
650 | * Defined in: drivers/scsi/scsi_sysfs.c . | 650 | * Defined in: drivers/scsi/scsi_sysfs.c . |
651 | **/ | 651 | **/ |
652 | int scsi_remove_device(struct scsi_device *sdev) | 652 | int scsi_remove_device(struct scsi_device *sdev) |
653 | 653 | ||
654 | 654 | ||
655 | /** | 655 | /** |
656 | * scsi_remove_host - detach and remove all SCSI devices owned by host | 656 | * scsi_remove_host - detach and remove all SCSI devices owned by host |
657 | * @shost: a pointer to a scsi host instance | 657 | * @shost: a pointer to a scsi host instance |
658 | * | 658 | * |
659 | * Returns value: 0 on success, 1 on failure (e.g. LLD busy ??) | 659 | * Returns value: 0 on success, 1 on failure (e.g. LLD busy ??) |
660 | * | 660 | * |
661 | * Might block: yes | 661 | * Might block: yes |
662 | * | 662 | * |
663 | * Notes: Should only be invoked if the "hotplug initialization | 663 | * Notes: Should only be invoked if the "hotplug initialization |
664 | * model" is being used. It should be called _prior_ to | 664 | * model" is being used. It should be called _prior_ to |
665 | * scsi_unregister(). | 665 | * scsi_unregister(). |
666 | * | 666 | * |
667 | * Defined in: drivers/scsi/hosts.c . | 667 | * Defined in: drivers/scsi/hosts.c . |
668 | **/ | 668 | **/ |
669 | int scsi_remove_host(struct Scsi_Host *shost) | 669 | int scsi_remove_host(struct Scsi_Host *shost) |
670 | 670 | ||
671 | 671 | ||
672 | /** | 672 | /** |
673 | * scsi_report_bus_reset - report scsi _bus_ reset observed | 673 | * scsi_report_bus_reset - report scsi _bus_ reset observed |
674 | * @shost: a pointer to a scsi host involved | 674 | * @shost: a pointer to a scsi host involved |
675 | * @channel: channel (within) host on which scsi bus reset occurred | 675 | * @channel: channel (within) host on which scsi bus reset occurred |
676 | * | 676 | * |
677 | * Returns nothing | 677 | * Returns nothing |
678 | * | 678 | * |
679 | * Might block: no | 679 | * Might block: no |
680 | * | 680 | * |
681 | * Notes: This only needs to be called if the reset is one which | 681 | * Notes: This only needs to be called if the reset is one which |
682 | * originates from an unknown location. Resets originated by the | 682 | * originates from an unknown location. Resets originated by the |
683 | * mid level itself don't need to call this, but there should be | 683 | * mid level itself don't need to call this, but there should be |
684 | * no harm. The main purpose of this is to make sure that a | 684 | * no harm. The main purpose of this is to make sure that a |
685 | * CHECK_CONDITION is properly treated. | 685 | * CHECK_CONDITION is properly treated. |
686 | * | 686 | * |
687 | * Defined in: drivers/scsi/scsi_error.c . | 687 | * Defined in: drivers/scsi/scsi_error.c . |
688 | **/ | 688 | **/ |
689 | void scsi_report_bus_reset(struct Scsi_Host * shost, int channel) | 689 | void scsi_report_bus_reset(struct Scsi_Host * shost, int channel) |
690 | 690 | ||
691 | 691 | ||
692 | /** | 692 | /** |
693 | * scsi_scan_host - scan SCSI bus | 693 | * scsi_scan_host - scan SCSI bus |
694 | * @shost: a pointer to a scsi host instance | 694 | * @shost: a pointer to a scsi host instance |
695 | * | 695 | * |
696 | * Might block: yes | 696 | * Might block: yes |
697 | * | 697 | * |
698 | * Notes: Should be called after scsi_add_host() | 698 | * Notes: Should be called after scsi_add_host() |
699 | * | 699 | * |
700 | * Defined in: drivers/scsi/scsi_scan.c | 700 | * Defined in: drivers/scsi/scsi_scan.c |
701 | **/ | 701 | **/ |
702 | void scsi_scan_host(struct Scsi_Host *shost) | 702 | void scsi_scan_host(struct Scsi_Host *shost) |
703 | 703 | ||
704 | 704 | ||
705 | /** | 705 | /** |
706 | * scsi_track_queue_full - track successive QUEUE_FULL events on given | 706 | * scsi_track_queue_full - track successive QUEUE_FULL events on given |
707 | * device to determine if and when there is a need | 707 | * device to determine if and when there is a need |
708 | * to adjust the queue depth on the device. | 708 | * to adjust the queue depth on the device. |
709 | * @sdev: pointer to SCSI device instance | 709 | * @sdev: pointer to SCSI device instance |
710 | * @depth: Current number of outstanding SCSI commands on this device, | 710 | * @depth: Current number of outstanding SCSI commands on this device, |
711 | * not counting the one returned as QUEUE_FULL. | 711 | * not counting the one returned as QUEUE_FULL. |
712 | * | 712 | * |
713 | * Returns 0 - no change needed | 713 | * Returns 0 - no change needed |
714 | * >0 - adjust queue depth to this new depth | 714 | * >0 - adjust queue depth to this new depth |
715 | * -1 - drop back to untagged operation using host->cmd_per_lun | 715 | * -1 - drop back to untagged operation using host->cmd_per_lun |
716 | * as the untagged command depth | 716 | * as the untagged command depth |
717 | * | 717 | * |
718 | * Might block: no | 718 | * Might block: no |
719 | * | 719 | * |
720 | * Notes: LLDs may call this at any time and we will do "The Right | 720 | * Notes: LLDs may call this at any time and we will do "The Right |
721 | * Thing"; interrupt context safe. | 721 | * Thing"; interrupt context safe. |
722 | * | 722 | * |
723 | * Defined in: drivers/scsi/scsi.c . | 723 | * Defined in: drivers/scsi/scsi.c . |
724 | **/ | 724 | **/ |
725 | int scsi_track_queue_full(struct scsi_device *sdev, int depth) | 725 | int scsi_track_queue_full(struct scsi_device *sdev, int depth) |
726 | 726 | ||
727 | 727 | ||
728 | /** | 728 | /** |
729 | * scsi_unblock_requests - allow further commands to be queued to given host | 729 | * scsi_unblock_requests - allow further commands to be queued to given host |
730 | * | 730 | * |
731 | * @shost: pointer to host to unblock commands on | 731 | * @shost: pointer to host to unblock commands on |
732 | * | 732 | * |
733 | * Returns nothing | 733 | * Returns nothing |
734 | * | 734 | * |
735 | * Might block: no | 735 | * Might block: no |
736 | * | 736 | * |
737 | * Defined in: drivers/scsi/scsi_lib.c . | 737 | * Defined in: drivers/scsi/scsi_lib.c . |
738 | **/ | 738 | **/ |
739 | void scsi_unblock_requests(struct Scsi_Host * shost) | 739 | void scsi_unblock_requests(struct Scsi_Host * shost) |
740 | 740 | ||
741 | 741 | ||
742 | /** | 742 | /** |
743 | * scsi_unregister - unregister and free memory used by host instance | 743 | * scsi_unregister - unregister and free memory used by host instance |
744 | * @shp: pointer to scsi host instance to unregister. | 744 | * @shp: pointer to scsi host instance to unregister. |
745 | * | 745 | * |
746 | * Returns nothing | 746 | * Returns nothing |
747 | * | 747 | * |
748 | * Might block: no | 748 | * Might block: no |
749 | * | 749 | * |
750 | * Notes: Should not be invoked if the "hotplug initialization | 750 | * Notes: Should not be invoked if the "hotplug initialization |
751 | * model" is being used. Called internally by exit_this_scsi_driver() | 751 | * model" is being used. Called internally by exit_this_scsi_driver() |
752 | * in the "passive initialization model". Hence a LLD has no need to | 752 | * in the "passive initialization model". Hence a LLD has no need to |
753 | * call this function directly. | 753 | * call this function directly. |
754 | * | 754 | * |
755 | * Defined in: drivers/scsi/hosts.c . | 755 | * Defined in: drivers/scsi/hosts.c . |
756 | **/ | 756 | **/ |
757 | void scsi_unregister(struct Scsi_Host * shp) | 757 | void scsi_unregister(struct Scsi_Host * shp) |
758 | 758 | ||
759 | 759 | ||
760 | 760 | ||
761 | 761 | ||
762 | Interface Functions | 762 | Interface Functions |
763 | =================== | 763 | =================== |
764 | Interface functions are supplied (defined) by LLDs and their function | 764 | Interface functions are supplied (defined) by LLDs and their function |
765 | pointers are placed in an instance of struct scsi_host_template which | 765 | pointers are placed in an instance of struct scsi_host_template which |
766 | is passed to scsi_host_alloc() [or scsi_register() / init_this_scsi_driver()]. | 766 | is passed to scsi_host_alloc() [or scsi_register() / init_this_scsi_driver()]. |
767 | Some are mandatory. Interface functions should be declared static. The | 767 | Some are mandatory. Interface functions should be declared static. The |
768 | accepted convention is that driver "xyz" will declare its slave_configure() | 768 | accepted convention is that driver "xyz" will declare its slave_configure() |
769 | function as: | 769 | function as: |
770 | static int xyz_slave_configure(struct scsi_device * sdev); | 770 | static int xyz_slave_configure(struct scsi_device * sdev); |
771 | and so forth for all interface functions listed below. | 771 | and so forth for all interface functions listed below. |
772 | 772 | ||
773 | A pointer to this function should be placed in the 'slave_configure' member | 773 | A pointer to this function should be placed in the 'slave_configure' member |
774 | of a "struct scsi_host_template" instance. A pointer to such an instance | 774 | of a "struct scsi_host_template" instance. A pointer to such an instance |
775 | should be passed to the mid level's scsi_host_alloc() [or scsi_register() / | 775 | should be passed to the mid level's scsi_host_alloc() [or scsi_register() / |
776 | init_this_scsi_driver()]. | 776 | init_this_scsi_driver()]. |
777 | 777 | ||
778 | The interface functions are also described in the include/scsi/scsi_host.h | 778 | The interface functions are also described in the include/scsi/scsi_host.h |
779 | file immediately above their definition point in "struct scsi_host_template". | 779 | file immediately above their definition point in "struct scsi_host_template". |
780 | In some cases more detail is given in scsi_host.h than below. | 780 | In some cases more detail is given in scsi_host.h than below. |
781 | 781 | ||
782 | The interface functions are listed below in alphabetical order. | 782 | The interface functions are listed below in alphabetical order. |
783 | 783 | ||
784 | Summary: | 784 | Summary: |
785 | bios_param - fetch head, sector, cylinder info for a disk | 785 | bios_param - fetch head, sector, cylinder info for a disk |
786 | detect - detects HBAs this driver wants to control | 786 | detect - detects HBAs this driver wants to control |
787 | eh_timed_out - notify the host that a command timer expired | 787 | eh_timed_out - notify the host that a command timer expired |
788 | eh_abort_handler - abort given command | 788 | eh_abort_handler - abort given command |
789 | eh_bus_reset_handler - issue SCSI bus reset | 789 | eh_bus_reset_handler - issue SCSI bus reset |
790 | eh_device_reset_handler - issue SCSI device reset | 790 | eh_device_reset_handler - issue SCSI device reset |
791 | eh_host_reset_handler - reset host (host bus adapter) | 791 | eh_host_reset_handler - reset host (host bus adapter) |
792 | info - supply information about given host | 792 | info - supply information about given host |
793 | ioctl - driver can respond to ioctls | 793 | ioctl - driver can respond to ioctls |
794 | proc_info - supports /proc/scsi/{driver_name}/{host_no} | 794 | proc_info - supports /proc/scsi/{driver_name}/{host_no} |
795 | queuecommand - queue scsi command, invoke 'done' on completion | 795 | queuecommand - queue scsi command, invoke 'done' on completion |
796 | release - release all resources associated with given host | 796 | release - release all resources associated with given host |
797 | slave_alloc - prior to any commands being sent to a new device | 797 | slave_alloc - prior to any commands being sent to a new device |
798 | slave_configure - driver fine tuning for given device after attach | 798 | slave_configure - driver fine tuning for given device after attach |
799 | slave_destroy - given device is about to be shut down | 799 | slave_destroy - given device is about to be shut down |
800 | 800 | ||
801 | 801 | ||
802 | Details: | 802 | Details: |
803 | 803 | ||
804 | /** | 804 | /** |
805 | * bios_param - fetch head, sector, cylinder info for a disk | 805 | * bios_param - fetch head, sector, cylinder info for a disk |
806 | * @sdev: pointer to scsi device context (defined in | 806 | * @sdev: pointer to scsi device context (defined in |
807 | * include/scsi/scsi_device.h) | 807 | * include/scsi/scsi_device.h) |
808 | * @bdev: pointer to block device context (defined in fs.h) | 808 | * @bdev: pointer to block device context (defined in fs.h) |
809 | * @capacity: device size (in 512 byte sectors) | 809 | * @capacity: device size (in 512 byte sectors) |
810 | * @params: three element array to place output: | 810 | * @params: three element array to place output: |
811 | * params[0] number of heads (max 255) | 811 | * params[0] number of heads (max 255) |
812 | * params[1] number of sectors (max 63) | 812 | * params[1] number of sectors (max 63) |
813 | * params[2] number of cylinders | 813 | * params[2] number of cylinders |
814 | * | 814 | * |
815 | * Return value is ignored | 815 | * Return value is ignored |
816 | * | 816 | * |
817 | * Locks: none | 817 | * Locks: none |
818 | * | 818 | * |
819 | * Calling context: process (sd) | 819 | * Calling context: process (sd) |
820 | * | 820 | * |
821 | * Notes: an arbitrary geometry (based on READ CAPACITY) is used | 821 | * Notes: an arbitrary geometry (based on READ CAPACITY) is used |
822 | * if this function is not provided. The params array is | 822 | * if this function is not provided. The params array is |
823 | * pre-initialized with made up values just in case this function | 823 | * pre-initialized with made up values just in case this function |
824 | * doesn't output anything. | 824 | * doesn't output anything. |
825 | * | 825 | * |
826 | * Optionally defined in: LLD | 826 | * Optionally defined in: LLD |
827 | **/ | 827 | **/ |
828 | int bios_param(struct scsi_device * sdev, struct block_device *bdev, | 828 | int bios_param(struct scsi_device * sdev, struct block_device *bdev, |
829 | sector_t capacity, int params[3]) | 829 | sector_t capacity, int params[3]) |
830 | 830 | ||
831 | 831 | ||
832 | /** | 832 | /** |
833 | * detect - detects HBAs this driver wants to control | 833 | * detect - detects HBAs this driver wants to control |
834 | * @shtp: host template for this driver. | 834 | * @shtp: host template for this driver. |
835 | * | 835 | * |
836 | * Returns number of hosts this driver wants to control. 0 means no | 836 | * Returns number of hosts this driver wants to control. 0 means no |
837 | * suitable hosts found. | 837 | * suitable hosts found. |
838 | * | 838 | * |
839 | * Locks: none held | 839 | * Locks: none held |
840 | * | 840 | * |
841 | * Calling context: process [invoked from init_this_scsi_driver()] | 841 | * Calling context: process [invoked from init_this_scsi_driver()] |
842 | * | 842 | * |
843 | * Notes: First function called from the SCSI mid level on this | 843 | * Notes: First function called from the SCSI mid level on this |
844 | * driver. Upper level drivers (e.g. sd) may not (yet) be present. | 844 | * driver. Upper level drivers (e.g. sd) may not (yet) be present. |
845 | * For each host found, this method should call scsi_register() | 845 | * For each host found, this method should call scsi_register() |
846 | * [see hosts.c]. | 846 | * [see hosts.c]. |
847 | * | 847 | * |
848 | * Defined in: LLD (required if "passive initialization mode" is used, | 848 | * Defined in: LLD (required if "passive initialization mode" is used, |
849 | * not invoked in "hotplug initialization mode") | 849 | * not invoked in "hotplug initialization mode") |
850 | **/ | 850 | **/ |
851 | int detect(struct scsi_host_template * shtp) | 851 | int detect(struct scsi_host_template * shtp) |
852 | 852 | ||
853 | 853 | ||
854 | /** | 854 | /** |
855 | * eh_timed_out - The timer for the command has just fired | 855 | * eh_timed_out - The timer for the command has just fired |
856 | * @scp: identifies command timing out | 856 | * @scp: identifies command timing out |
857 | * | 857 | * |
858 | * Returns: | 858 | * Returns: |
859 | * | 859 | * |
860 | * EH_HANDLED: I fixed the error, please complete the command | 860 | * EH_HANDLED: I fixed the error, please complete the command |
861 | * EH_RESET_TIMER: I need more time, reset the timer and | 861 | * EH_RESET_TIMER: I need more time, reset the timer and |
862 | * begin counting again | 862 | * begin counting again |
863 | * EH_NOT_HANDLED Begin normal error recovery | 863 | * EH_NOT_HANDLED Begin normal error recovery |
864 | * | 864 | * |
865 | * | 865 | * |
866 | * Locks: None held | 866 | * Locks: None held |
867 | * | 867 | * |
868 | * Calling context: interrupt | 868 | * Calling context: interrupt |
869 | * | 869 | * |
870 | * Notes: This is to give the LLD an opportunity to do local recovery. | 870 | * Notes: This is to give the LLD an opportunity to do local recovery. |
871 | * This recovery is limited to determining if the outstanding command | 871 | * This recovery is limited to determining if the outstanding command |
872 | * will ever complete. You may not abort and restart the command from | 872 | * will ever complete. You may not abort and restart the command from |
873 | * this callback. | 873 | * this callback. |
874 | * | 874 | * |
875 | * Optionally defined in: LLD | 875 | * Optionally defined in: LLD |
876 | **/ | 876 | **/ |
877 | int eh_timed_out(struct scsi_cmnd * scp) | 877 | int eh_timed_out(struct scsi_cmnd * scp) |
878 | 878 | ||
879 | 879 | ||
880 | /** | 880 | /** |
881 | * eh_abort_handler - abort command associated with scp | 881 | * eh_abort_handler - abort command associated with scp |
882 | * @scp: identifies command to be aborted | 882 | * @scp: identifies command to be aborted |
883 | * | 883 | * |
884 | * Returns SUCCESS if command aborted else FAILED | 884 | * Returns SUCCESS if command aborted else FAILED |
885 | * | 885 | * |
886 | * Locks: None held | 886 | * Locks: None held |
887 | * | 887 | * |
888 | * Calling context: kernel thread | 888 | * Calling context: kernel thread |
889 | * | 889 | * |
890 | * Notes: Invoked from scsi_eh thread. No other commands will be | 890 | * Notes: Invoked from scsi_eh thread. No other commands will be |
891 | * queued on current host during eh. | 891 | * queued on current host during eh. |
892 | * | 892 | * |
893 | * Optionally defined in: LLD | 893 | * Optionally defined in: LLD |
894 | **/ | 894 | **/ |
895 | int eh_abort_handler(struct scsi_cmnd * scp) | 895 | int eh_abort_handler(struct scsi_cmnd * scp) |
896 | 896 | ||
897 | 897 | ||
898 | /** | 898 | /** |
899 | * eh_bus_reset_handler - issue SCSI bus reset | 899 | * eh_bus_reset_handler - issue SCSI bus reset |
900 | * @scp: SCSI bus that contains this device should be reset | 900 | * @scp: SCSI bus that contains this device should be reset |
901 | * | 901 | * |
902 | * Returns SUCCESS if command aborted else FAILED | 902 | * Returns SUCCESS if command aborted else FAILED |
903 | * | 903 | * |
904 | * Locks: None held | 904 | * Locks: None held |
905 | * | 905 | * |
906 | * Calling context: kernel thread | 906 | * Calling context: kernel thread |
907 | * | 907 | * |
908 | * Notes: Invoked from scsi_eh thread. No other commands will be | 908 | * Notes: Invoked from scsi_eh thread. No other commands will be |
909 | * queued on current host during eh. | 909 | * queued on current host during eh. |
910 | * | 910 | * |
911 | * Optionally defined in: LLD | 911 | * Optionally defined in: LLD |
912 | **/ | 912 | **/ |
913 | int eh_bus_reset_handler(struct scsi_cmnd * scp) | 913 | int eh_bus_reset_handler(struct scsi_cmnd * scp) |
914 | 914 | ||
915 | 915 | ||
916 | /** | 916 | /** |
917 | * eh_device_reset_handler - issue SCSI device reset | 917 | * eh_device_reset_handler - issue SCSI device reset |
918 | * @scp: identifies SCSI device to be reset | 918 | * @scp: identifies SCSI device to be reset |
919 | * | 919 | * |
920 | * Returns SUCCESS if command aborted else FAILED | 920 | * Returns SUCCESS if command aborted else FAILED |
921 | * | 921 | * |
922 | * Locks: None held | 922 | * Locks: None held |
923 | * | 923 | * |
924 | * Calling context: kernel thread | 924 | * Calling context: kernel thread |
925 | * | 925 | * |
926 | * Notes: Invoked from scsi_eh thread. No other commands will be | 926 | * Notes: Invoked from scsi_eh thread. No other commands will be |
927 | * queued on current host during eh. | 927 | * queued on current host during eh. |
928 | * | 928 | * |
929 | * Optionally defined in: LLD | 929 | * Optionally defined in: LLD |
930 | **/ | 930 | **/ |
931 | int eh_device_reset_handler(struct scsi_cmnd * scp) | 931 | int eh_device_reset_handler(struct scsi_cmnd * scp) |
932 | 932 | ||
933 | 933 | ||
934 | /** | 934 | /** |
935 | * eh_host_reset_handler - reset host (host bus adapter) | 935 | * eh_host_reset_handler - reset host (host bus adapter) |
936 | * @scp: SCSI host that contains this device should be reset | 936 | * @scp: SCSI host that contains this device should be reset |
937 | * | 937 | * |
938 | * Returns SUCCESS if command aborted else FAILED | 938 | * Returns SUCCESS if command aborted else FAILED |
939 | * | 939 | * |
940 | * Locks: None held | 940 | * Locks: None held |
941 | * | 941 | * |
942 | * Calling context: kernel thread | 942 | * Calling context: kernel thread |
943 | * | 943 | * |
944 | * Notes: Invoked from scsi_eh thread. No other commands will be | 944 | * Notes: Invoked from scsi_eh thread. No other commands will be |
945 | * queued on current host during eh. | 945 | * queued on current host during eh. |
946 | * With the default eh_strategy in place, if none of the _abort_, | 946 | * With the default eh_strategy in place, if none of the _abort_, |
947 | * _device_reset_, _bus_reset_ or this eh handler function are | 947 | * _device_reset_, _bus_reset_ or this eh handler function are |
948 | * defined (or they all return FAILED) then the device in question | 948 | * defined (or they all return FAILED) then the device in question |
949 | * will be set offline whenever eh is invoked. | 949 | * will be set offline whenever eh is invoked. |
950 | * | 950 | * |
951 | * Optionally defined in: LLD | 951 | * Optionally defined in: LLD |
952 | **/ | 952 | **/ |
953 | int eh_host_reset_handler(struct scsi_cmnd * scp) | 953 | int eh_host_reset_handler(struct scsi_cmnd * scp) |
954 | 954 | ||
955 | 955 | ||
956 | /** | 956 | /** |
957 | * info - supply information about given host: driver name plus data | 957 | * info - supply information about given host: driver name plus data |
958 | * to distinguish given host | 958 | * to distinguish given host |
959 | * @shp: host to supply information about | 959 | * @shp: host to supply information about |
960 | * | 960 | * |
961 | * Return ASCII null terminated string. [This driver is assumed to | 961 | * Return ASCII null terminated string. [This driver is assumed to |
962 | * manage the memory pointed to and maintain it, typically for the | 962 | * manage the memory pointed to and maintain it, typically for the |
963 | * lifetime of this host.] | 963 | * lifetime of this host.] |
964 | * | 964 | * |
965 | * Locks: none | 965 | * Locks: none |
966 | * | 966 | * |
967 | * Calling context: process | 967 | * Calling context: process |
968 | * | 968 | * |
969 | * Notes: Often supplies PCI or ISA information such as IO addresses | 969 | * Notes: Often supplies PCI or ISA information such as IO addresses |
970 | * and interrupt numbers. If not supplied struct Scsi_Host::name used | 970 | * and interrupt numbers. If not supplied struct Scsi_Host::name used |
971 | * instead. It is assumed the returned information fits on one line | 971 | * instead. It is assumed the returned information fits on one line |
972 | * (i.e. does not included embedded newlines). | 972 | * (i.e. does not included embedded newlines). |
973 | * The SCSI_IOCTL_PROBE_HOST ioctl yields the string returned by this | 973 | * The SCSI_IOCTL_PROBE_HOST ioctl yields the string returned by this |
974 | * function (or struct Scsi_Host::name if this function is not | 974 | * function (or struct Scsi_Host::name if this function is not |
975 | * available). | 975 | * available). |
976 | * In a similar manner, init_this_scsi_driver() outputs to the console | 976 | * In a similar manner, init_this_scsi_driver() outputs to the console |
977 | * each host's "info" (or name) for the driver it is registering. | 977 | * each host's "info" (or name) for the driver it is registering. |
978 | * Also if proc_info() is not supplied, the output of this function | 978 | * Also if proc_info() is not supplied, the output of this function |
979 | * is used instead. | 979 | * is used instead. |
980 | * | 980 | * |
981 | * Optionally defined in: LLD | 981 | * Optionally defined in: LLD |
982 | **/ | 982 | **/ |
983 | const char * info(struct Scsi_Host * shp) | 983 | const char * info(struct Scsi_Host * shp) |
984 | 984 | ||
985 | 985 | ||
986 | /** | 986 | /** |
987 | * ioctl - driver can respond to ioctls | 987 | * ioctl - driver can respond to ioctls |
988 | * @sdp: device that ioctl was issued for | 988 | * @sdp: device that ioctl was issued for |
989 | * @cmd: ioctl number | 989 | * @cmd: ioctl number |
990 | * @arg: pointer to read or write data from. Since it points to | 990 | * @arg: pointer to read or write data from. Since it points to |
991 | * user space, should use appropriate kernel functions | 991 | * user space, should use appropriate kernel functions |
992 | * (e.g. copy_from_user() ). In the Unix style this argument | 992 | * (e.g. copy_from_user() ). In the Unix style this argument |
993 | * can also be viewed as an unsigned long. | 993 | * can also be viewed as an unsigned long. |
994 | * | 994 | * |
995 | * Returns negative "errno" value when there is a problem. 0 or a | 995 | * Returns negative "errno" value when there is a problem. 0 or a |
996 | * positive value indicates success and is returned to the user space. | 996 | * positive value indicates success and is returned to the user space. |
997 | * | 997 | * |
998 | * Locks: none | 998 | * Locks: none |
999 | * | 999 | * |
1000 | * Calling context: process | 1000 | * Calling context: process |
1001 | * | 1001 | * |
1002 | * Notes: The SCSI subsystem uses a "trickle down" ioctl model. | 1002 | * Notes: The SCSI subsystem uses a "trickle down" ioctl model. |
1003 | * The user issues an ioctl() against an upper level driver | 1003 | * The user issues an ioctl() against an upper level driver |
1004 | * (e.g. /dev/sdc) and if the upper level driver doesn't recognize | 1004 | * (e.g. /dev/sdc) and if the upper level driver doesn't recognize |
1005 | * the 'cmd' then it is passed to the SCSI mid level. If the SCSI | 1005 | * the 'cmd' then it is passed to the SCSI mid level. If the SCSI |
1006 | * mid level does not recognize it, then the LLD that controls | 1006 | * mid level does not recognize it, then the LLD that controls |
1007 | * the device receives the ioctl. According to recent Unix standards | 1007 | * the device receives the ioctl. According to recent Unix standards |
1008 | * unsupported ioctl() 'cmd' numbers should return -ENOTTY. | 1008 | * unsupported ioctl() 'cmd' numbers should return -ENOTTY. |
1009 | * | 1009 | * |
1010 | * Optionally defined in: LLD | 1010 | * Optionally defined in: LLD |
1011 | **/ | 1011 | **/ |
1012 | int ioctl(struct scsi_device *sdp, int cmd, void *arg) | 1012 | int ioctl(struct scsi_device *sdp, int cmd, void *arg) |
1013 | 1013 | ||
1014 | 1014 | ||
1015 | /** | 1015 | /** |
1016 | * proc_info - supports /proc/scsi/{driver_name}/{host_no} | 1016 | * proc_info - supports /proc/scsi/{driver_name}/{host_no} |
1017 | * @buffer: anchor point to output to (0==writeto1_read0) or fetch from | 1017 | * @buffer: anchor point to output to (0==writeto1_read0) or fetch from |
1018 | * (1==writeto1_read0). | 1018 | * (1==writeto1_read0). |
1019 | * @start: where "interesting" data is written to. Ignored when | 1019 | * @start: where "interesting" data is written to. Ignored when |
1020 | * 1==writeto1_read0. | 1020 | * 1==writeto1_read0. |
1021 | * @offset: offset within buffer 0==writeto1_read0 is actually | 1021 | * @offset: offset within buffer 0==writeto1_read0 is actually |
1022 | * interested in. Ignored when 1==writeto1_read0 . | 1022 | * interested in. Ignored when 1==writeto1_read0 . |
1023 | * @length: maximum (or actual) extent of buffer | 1023 | * @length: maximum (or actual) extent of buffer |
1024 | * @host_no: host number of interest (struct Scsi_Host::host_no) | 1024 | * @host_no: host number of interest (struct Scsi_Host::host_no) |
1025 | * @writeto1_read0: 1 -> data coming from user space towards driver | 1025 | * @writeto1_read0: 1 -> data coming from user space towards driver |
1026 | * (e.g. "echo some_string > /proc/scsi/xyz/2") | 1026 | * (e.g. "echo some_string > /proc/scsi/xyz/2") |
1027 | * 0 -> user what data from this driver | 1027 | * 0 -> user what data from this driver |
1028 | * (e.g. "cat /proc/scsi/xyz/2") | 1028 | * (e.g. "cat /proc/scsi/xyz/2") |
1029 | * | 1029 | * |
1030 | * Returns length when 1==writeto1_read0. Otherwise number of chars | 1030 | * Returns length when 1==writeto1_read0. Otherwise number of chars |
1031 | * output to buffer past offset. | 1031 | * output to buffer past offset. |
1032 | * | 1032 | * |
1033 | * Locks: none held | 1033 | * Locks: none held |
1034 | * | 1034 | * |
1035 | * Calling context: process | 1035 | * Calling context: process |
1036 | * | 1036 | * |
1037 | * Notes: Driven from scsi_proc.c which interfaces to proc_fs. proc_fs | 1037 | * Notes: Driven from scsi_proc.c which interfaces to proc_fs. proc_fs |
1038 | * support can now be configured out of the scsi subsystem. | 1038 | * support can now be configured out of the scsi subsystem. |
1039 | * | 1039 | * |
1040 | * Optionally defined in: LLD | 1040 | * Optionally defined in: LLD |
1041 | **/ | 1041 | **/ |
1042 | int proc_info(char * buffer, char ** start, off_t offset, | 1042 | int proc_info(char * buffer, char ** start, off_t offset, |
1043 | int length, int host_no, int writeto1_read0) | 1043 | int length, int host_no, int writeto1_read0) |
1044 | 1044 | ||
1045 | 1045 | ||
1046 | /** | 1046 | /** |
1047 | * queuecommand - queue scsi command, invoke 'done' on completion | 1047 | * queuecommand - queue scsi command, invoke scp->scsi_done on completion |
1048 | * @shost: pointer to the scsi host object | ||
1048 | * @scp: pointer to scsi command object | 1049 | * @scp: pointer to scsi command object |
1049 | * @done: function pointer to be invoked on completion | ||
1050 | * | 1050 | * |
1051 | * Returns 0 on success. | 1051 | * Returns 0 on success. |
1052 | * | 1052 | * |
1053 | * If there's a failure, return either: | 1053 | * If there's a failure, return either: |
1054 | * | 1054 | * |
1055 | * SCSI_MLQUEUE_DEVICE_BUSY if the device queue is full, or | 1055 | * SCSI_MLQUEUE_DEVICE_BUSY if the device queue is full, or |
1056 | * SCSI_MLQUEUE_HOST_BUSY if the entire host queue is full | 1056 | * SCSI_MLQUEUE_HOST_BUSY if the entire host queue is full |
1057 | * | 1057 | * |
1058 | * On both of these returns, the mid-layer will requeue the I/O | 1058 | * On both of these returns, the mid-layer will requeue the I/O |
1059 | * | 1059 | * |
1060 | * - if the return is SCSI_MLQUEUE_DEVICE_BUSY, only that particular | 1060 | * - if the return is SCSI_MLQUEUE_DEVICE_BUSY, only that particular |
1061 | * device will be paused, and it will be unpaused when a command to | 1061 | * device will be paused, and it will be unpaused when a command to |
1062 | * the device returns (or after a brief delay if there are no more | 1062 | * the device returns (or after a brief delay if there are no more |
1063 | * outstanding commands to it). Commands to other devices continue | 1063 | * outstanding commands to it). Commands to other devices continue |
1064 | * to be processed normally. | 1064 | * to be processed normally. |
1065 | * | 1065 | * |
1066 | * - if the return is SCSI_MLQUEUE_HOST_BUSY, all I/O to the host | 1066 | * - if the return is SCSI_MLQUEUE_HOST_BUSY, all I/O to the host |
1067 | * is paused and will be unpaused when any command returns from | 1067 | * is paused and will be unpaused when any command returns from |
1068 | * the host (or after a brief delay if there are no outstanding | 1068 | * the host (or after a brief delay if there are no outstanding |
1069 | * commands to the host). | 1069 | * commands to the host). |
1070 | * | 1070 | * |
1071 | * For compatibility with earlier versions of queuecommand, any | 1071 | * For compatibility with earlier versions of queuecommand, any |
1072 | * other return value is treated the same as | 1072 | * other return value is treated the same as |
1073 | * SCSI_MLQUEUE_HOST_BUSY. | 1073 | * SCSI_MLQUEUE_HOST_BUSY. |
1074 | * | 1074 | * |
1075 | * Other types of errors that are detected immediately may be | 1075 | * Other types of errors that are detected immediately may be |
1076 | * flagged by setting scp->result to an appropriate value, | 1076 | * flagged by setting scp->result to an appropriate value, |
1077 | * invoking the 'done' callback, and then returning 0 from this | 1077 | * invoking the scp->scsi_done callback, and then returning 0 |
1078 | * function. If the command is not performed immediately (and the | 1078 | * from this function. If the command is not performed |
1079 | * LLD is starting (or will start) the given command) then this | 1079 | * immediately (and the LLD is starting (or will start) the given |
1080 | * function should place 0 in scp->result and return 0. | 1080 | * command) then this function should place 0 in scp->result and |
1081 | * return 0. | ||
1081 | * | 1082 | * |
1082 | * Command ownership. If the driver returns zero, it owns the | 1083 | * Command ownership. If the driver returns zero, it owns the |
1083 | * command and must take responsibility for ensuring the 'done' | 1084 | * command and must take responsibility for ensuring the |
1084 | * callback is executed. Note: the driver may call done before | 1085 | * scp->scsi_done callback is executed. Note: the driver may |
1085 | * returning zero, but after it has called done, it may not | 1086 | * call scp->scsi_done before returning zero, but after it has |
1086 | * return any value other than zero. If the driver makes a | 1087 | * called scp->scsi_done, it may not return any value other than |
1087 | * non-zero return, it must not execute the command's done | 1088 | * zero. If the driver makes a non-zero return, it must not |
1088 | * callback at any time. | 1089 | * execute the command's scsi_done callback at any time. |
1089 | * | 1090 | * |
1090 | * Locks: struct Scsi_Host::host_lock held on entry (with "irqsave") | 1091 | * Locks: up to and including 2.6.36, struct Scsi_Host::host_lock |
1091 | * and is expected to be held on return. | 1092 | * held on entry (with "irqsave") and is expected to be |
1093 | * held on return. From 2.6.37 onwards, queuecommand is | ||
1094 | * called without any locks held. | ||
1092 | * | 1095 | * |
1093 | * Calling context: in interrupt (soft irq) or process context | 1096 | * Calling context: in interrupt (soft irq) or process context |
1094 | * | 1097 | * |
1095 | * Notes: This function should be relatively fast. Normally it will | 1098 | * Notes: This function should be relatively fast. Normally it |
1096 | * not wait for IO to complete. Hence the 'done' callback is invoked | 1099 | * will not wait for IO to complete. Hence the scp->scsi_done |
1097 | * (often directly from an interrupt service routine) some time after | 1100 | * callback is invoked (often directly from an interrupt service |
1098 | * this function has returned. In some cases (e.g. pseudo adapter | 1101 | * routine) some time after this function has returned. In some |
1099 | * drivers that manufacture the response to a SCSI INQUIRY) | 1102 | * cases (e.g. pseudo adapter drivers that manufacture the |
1100 | * the 'done' callback may be invoked before this function returns. | 1103 | * response to a SCSI INQUIRY) the scp->scsi_done callback may be |
1101 | * If the 'done' callback is not invoked within a certain period | 1104 | * invoked before this function returns. If the scp->scsi_done |
1102 | * the SCSI mid level will commence error processing. | 1105 | * callback is not invoked within a certain period the SCSI mid |
1103 | * If a status of CHECK CONDITION is placed in "result" when the | 1106 | * level will commence error processing. If a status of CHECK |
1104 | * 'done' callback is invoked, then the LLD driver should | 1107 | * CONDITION is placed in "result" when the scp->scsi_done |
1105 | * perform autosense and fill in the struct scsi_cmnd::sense_buffer | 1108 | * callback is invoked, then the LLD driver should perform |
1109 | * autosense and fill in the struct scsi_cmnd::sense_buffer | ||
1106 | * array. The scsi_cmnd::sense_buffer array is zeroed prior to | 1110 | * array. The scsi_cmnd::sense_buffer array is zeroed prior to |
1107 | * the mid level queuing a command to an LLD. | 1111 | * the mid level queuing a command to an LLD. |
1108 | * | 1112 | * |
1109 | * Defined in: LLD | 1113 | * Defined in: LLD |
1110 | **/ | 1114 | **/ |
1111 | int queuecommand(struct scsi_cmnd * scp, | 1115 | int queuecommand(struct Scsi_Host *shost, struct scsi_cmnd * scp) |
1112 | void (*done)(struct scsi_cmnd *)) | ||
1113 | 1116 | ||
1114 | 1117 | ||
1115 | /** | 1118 | /** |
1116 | * release - release all resources associated with given host | 1119 | * release - release all resources associated with given host |
1117 | * @shp: host to be released. | 1120 | * @shp: host to be released. |
1118 | * | 1121 | * |
1119 | * Return value ignored (could soon be a function returning void). | 1122 | * Return value ignored (could soon be a function returning void). |
1120 | * | 1123 | * |
1121 | * Locks: none held | 1124 | * Locks: none held |
1122 | * | 1125 | * |
1123 | * Calling context: process | 1126 | * Calling context: process |
1124 | * | 1127 | * |
1125 | * Notes: Invoked from scsi_module.c's exit_this_scsi_driver(). | 1128 | * Notes: Invoked from scsi_module.c's exit_this_scsi_driver(). |
1126 | * LLD's implementation of this function should call | 1129 | * LLD's implementation of this function should call |
1127 | * scsi_unregister(shp) prior to returning. | 1130 | * scsi_unregister(shp) prior to returning. |
1128 | * Only needed for old-style host templates. | 1131 | * Only needed for old-style host templates. |
1129 | * | 1132 | * |
1130 | * Defined in: LLD (required in "passive initialization model", | 1133 | * Defined in: LLD (required in "passive initialization model", |
1131 | * should not be defined in hotplug model) | 1134 | * should not be defined in hotplug model) |
1132 | **/ | 1135 | **/ |
1133 | int release(struct Scsi_Host * shp) | 1136 | int release(struct Scsi_Host * shp) |
1134 | 1137 | ||
1135 | 1138 | ||
1136 | /** | 1139 | /** |
1137 | * slave_alloc - prior to any commands being sent to a new device | 1140 | * slave_alloc - prior to any commands being sent to a new device |
1138 | * (i.e. just prior to scan) this call is made | 1141 | * (i.e. just prior to scan) this call is made |
1139 | * @sdp: pointer to new device (about to be scanned) | 1142 | * @sdp: pointer to new device (about to be scanned) |
1140 | * | 1143 | * |
1141 | * Returns 0 if ok. Any other return is assumed to be an error and | 1144 | * Returns 0 if ok. Any other return is assumed to be an error and |
1142 | * the device is ignored. | 1145 | * the device is ignored. |
1143 | * | 1146 | * |
1144 | * Locks: none | 1147 | * Locks: none |
1145 | * | 1148 | * |
1146 | * Calling context: process | 1149 | * Calling context: process |
1147 | * | 1150 | * |
1148 | * Notes: Allows the driver to allocate any resources for a device | 1151 | * Notes: Allows the driver to allocate any resources for a device |
1149 | * prior to its initial scan. The corresponding scsi device may not | 1152 | * prior to its initial scan. The corresponding scsi device may not |
1150 | * exist but the mid level is just about to scan for it (i.e. send | 1153 | * exist but the mid level is just about to scan for it (i.e. send |
1151 | * and INQUIRY command plus ...). If a device is found then | 1154 | * and INQUIRY command plus ...). If a device is found then |
1152 | * slave_configure() will be called while if a device is not found | 1155 | * slave_configure() will be called while if a device is not found |
1153 | * slave_destroy() is called. | 1156 | * slave_destroy() is called. |
1154 | * For more details see the include/scsi/scsi_host.h file. | 1157 | * For more details see the include/scsi/scsi_host.h file. |
1155 | * | 1158 | * |
1156 | * Optionally defined in: LLD | 1159 | * Optionally defined in: LLD |
1157 | **/ | 1160 | **/ |
1158 | int slave_alloc(struct scsi_device *sdp) | 1161 | int slave_alloc(struct scsi_device *sdp) |
1159 | 1162 | ||
1160 | 1163 | ||
1161 | /** | 1164 | /** |
1162 | * slave_configure - driver fine tuning for given device just after it | 1165 | * slave_configure - driver fine tuning for given device just after it |
1163 | * has been first scanned (i.e. it responded to an | 1166 | * has been first scanned (i.e. it responded to an |
1164 | * INQUIRY) | 1167 | * INQUIRY) |
1165 | * @sdp: device that has just been attached | 1168 | * @sdp: device that has just been attached |
1166 | * | 1169 | * |
1167 | * Returns 0 if ok. Any other return is assumed to be an error and | 1170 | * Returns 0 if ok. Any other return is assumed to be an error and |
1168 | * the device is taken offline. [offline devices will _not_ have | 1171 | * the device is taken offline. [offline devices will _not_ have |
1169 | * slave_destroy() called on them so clean up resources.] | 1172 | * slave_destroy() called on them so clean up resources.] |
1170 | * | 1173 | * |
1171 | * Locks: none | 1174 | * Locks: none |
1172 | * | 1175 | * |
1173 | * Calling context: process | 1176 | * Calling context: process |
1174 | * | 1177 | * |
1175 | * Notes: Allows the driver to inspect the response to the initial | 1178 | * Notes: Allows the driver to inspect the response to the initial |
1176 | * INQUIRY done by the scanning code and take appropriate action. | 1179 | * INQUIRY done by the scanning code and take appropriate action. |
1177 | * For more details see the include/scsi/scsi_host.h file. | 1180 | * For more details see the include/scsi/scsi_host.h file. |
1178 | * | 1181 | * |
1179 | * Optionally defined in: LLD | 1182 | * Optionally defined in: LLD |
1180 | **/ | 1183 | **/ |
1181 | int slave_configure(struct scsi_device *sdp) | 1184 | int slave_configure(struct scsi_device *sdp) |
1182 | 1185 | ||
1183 | 1186 | ||
1184 | /** | 1187 | /** |
1185 | * slave_destroy - given device is about to be shut down. All | 1188 | * slave_destroy - given device is about to be shut down. All |
1186 | * activity has ceased on this device. | 1189 | * activity has ceased on this device. |
1187 | * @sdp: device that is about to be shut down | 1190 | * @sdp: device that is about to be shut down |
1188 | * | 1191 | * |
1189 | * Returns nothing | 1192 | * Returns nothing |
1190 | * | 1193 | * |
1191 | * Locks: none | 1194 | * Locks: none |
1192 | * | 1195 | * |
1193 | * Calling context: process | 1196 | * Calling context: process |
1194 | * | 1197 | * |
1195 | * Notes: Mid level structures for given device are still in place | 1198 | * Notes: Mid level structures for given device are still in place |
1196 | * but are about to be torn down. Any per device resources allocated | 1199 | * but are about to be torn down. Any per device resources allocated |
1197 | * by this driver for given device should be freed now. No further | 1200 | * by this driver for given device should be freed now. No further |
1198 | * commands will be sent for this sdp instance. [However the device | 1201 | * commands will be sent for this sdp instance. [However the device |
1199 | * could be re-attached in the future in which case a new instance | 1202 | * could be re-attached in the future in which case a new instance |
1200 | * of struct scsi_device would be supplied by future slave_alloc() | 1203 | * of struct scsi_device would be supplied by future slave_alloc() |
1201 | * and slave_configure() calls.] | 1204 | * and slave_configure() calls.] |
1202 | * | 1205 | * |
1203 | * Optionally defined in: LLD | 1206 | * Optionally defined in: LLD |
1204 | **/ | 1207 | **/ |
1205 | void slave_destroy(struct scsi_device *sdp) | 1208 | void slave_destroy(struct scsi_device *sdp) |
1206 | 1209 | ||
1207 | 1210 | ||
1208 | 1211 | ||
1209 | Data Structures | 1212 | Data Structures |
1210 | =============== | 1213 | =============== |
1211 | struct scsi_host_template | 1214 | struct scsi_host_template |
1212 | ------------------------- | 1215 | ------------------------- |
1213 | There is one "struct scsi_host_template" instance per LLD ***. It is | 1216 | There is one "struct scsi_host_template" instance per LLD ***. It is |
1214 | typically initialized as a file scope static in a driver's header file. That | 1217 | typically initialized as a file scope static in a driver's header file. That |
1215 | way members that are not explicitly initialized will be set to 0 or NULL. | 1218 | way members that are not explicitly initialized will be set to 0 or NULL. |
1216 | Member of interest: | 1219 | Member of interest: |
1217 | name - name of driver (may contain spaces, please limit to | 1220 | name - name of driver (may contain spaces, please limit to |
1218 | less than 80 characters) | 1221 | less than 80 characters) |
1219 | proc_name - name used in "/proc/scsi/<proc_name>/<host_no>" and | 1222 | proc_name - name used in "/proc/scsi/<proc_name>/<host_no>" and |
1220 | by sysfs in one of its "drivers" directories. Hence | 1223 | by sysfs in one of its "drivers" directories. Hence |
1221 | "proc_name" should only contain characters acceptable | 1224 | "proc_name" should only contain characters acceptable |
1222 | to a Unix file name. | 1225 | to a Unix file name. |
1223 | (*queuecommand)() - primary callback that the mid level uses to inject | 1226 | (*queuecommand)() - primary callback that the mid level uses to inject |
1224 | SCSI commands into an LLD. | 1227 | SCSI commands into an LLD. |
1225 | The structure is defined and commented in include/scsi/scsi_host.h | 1228 | The structure is defined and commented in include/scsi/scsi_host.h |
1226 | 1229 | ||
1227 | *** In extreme situations a single driver may have several instances | 1230 | *** In extreme situations a single driver may have several instances |
1228 | if it controls several different classes of hardware (e.g. an LLD | 1231 | if it controls several different classes of hardware (e.g. an LLD |
1229 | that handles both ISA and PCI cards and has a separate instance of | 1232 | that handles both ISA and PCI cards and has a separate instance of |
1230 | struct scsi_host_template for each class). | 1233 | struct scsi_host_template for each class). |
1231 | 1234 | ||
1232 | struct Scsi_Host | 1235 | struct Scsi_Host |
1233 | ---------------- | 1236 | ---------------- |
1234 | There is one struct Scsi_Host instance per host (HBA) that an LLD | 1237 | There is one struct Scsi_Host instance per host (HBA) that an LLD |
1235 | controls. The struct Scsi_Host structure has many members in common | 1238 | controls. The struct Scsi_Host structure has many members in common |
1236 | with "struct scsi_host_template". When a new struct Scsi_Host instance | 1239 | with "struct scsi_host_template". When a new struct Scsi_Host instance |
1237 | is created (in scsi_host_alloc() in hosts.c) those common members are | 1240 | is created (in scsi_host_alloc() in hosts.c) those common members are |
1238 | initialized from the driver's struct scsi_host_template instance. Members | 1241 | initialized from the driver's struct scsi_host_template instance. Members |
1239 | of interest: | 1242 | of interest: |
1240 | host_no - system wide unique number that is used for identifying | 1243 | host_no - system wide unique number that is used for identifying |
1241 | this host. Issued in ascending order from 0. | 1244 | this host. Issued in ascending order from 0. |
1242 | can_queue - must be greater than 0; do not send more than can_queue | 1245 | can_queue - must be greater than 0; do not send more than can_queue |
1243 | commands to the adapter. | 1246 | commands to the adapter. |
1244 | this_id - scsi id of host (scsi initiator) or -1 if not known | 1247 | this_id - scsi id of host (scsi initiator) or -1 if not known |
1245 | sg_tablesize - maximum scatter gather elements allowed by host. | 1248 | sg_tablesize - maximum scatter gather elements allowed by host. |
1246 | 0 implies scatter gather not supported by host | 1249 | 0 implies scatter gather not supported by host |
1247 | max_sectors - maximum number of sectors (usually 512 bytes) allowed | 1250 | max_sectors - maximum number of sectors (usually 512 bytes) allowed |
1248 | in a single SCSI command. The default value of 0 leads | 1251 | in a single SCSI command. The default value of 0 leads |
1249 | to a setting of SCSI_DEFAULT_MAX_SECTORS (defined in | 1252 | to a setting of SCSI_DEFAULT_MAX_SECTORS (defined in |
1250 | scsi_host.h) which is currently set to 1024. So for a | 1253 | scsi_host.h) which is currently set to 1024. So for a |
1251 | disk the maximum transfer size is 512 KB when max_sectors | 1254 | disk the maximum transfer size is 512 KB when max_sectors |
1252 | is not defined. Note that this size may not be sufficient | 1255 | is not defined. Note that this size may not be sufficient |
1253 | for disk firmware uploads. | 1256 | for disk firmware uploads. |
1254 | cmd_per_lun - maximum number of commands that can be queued on devices | 1257 | cmd_per_lun - maximum number of commands that can be queued on devices |
1255 | controlled by the host. Overridden by LLD calls to | 1258 | controlled by the host. Overridden by LLD calls to |
1256 | scsi_adjust_queue_depth(). | 1259 | scsi_adjust_queue_depth(). |
1257 | unchecked_isa_dma - 1=>only use bottom 16 MB of ram (ISA DMA addressing | 1260 | unchecked_isa_dma - 1=>only use bottom 16 MB of ram (ISA DMA addressing |
1258 | restriction), 0=>can use full 32 bit (or better) DMA | 1261 | restriction), 0=>can use full 32 bit (or better) DMA |
1259 | address space | 1262 | address space |
1260 | use_clustering - 1=>SCSI commands in mid level's queue can be merged, | 1263 | use_clustering - 1=>SCSI commands in mid level's queue can be merged, |
1261 | 0=>disallow SCSI command merging | 1264 | 0=>disallow SCSI command merging |
1262 | hostt - pointer to driver's struct scsi_host_template from which | 1265 | hostt - pointer to driver's struct scsi_host_template from which |
1263 | this struct Scsi_Host instance was spawned | 1266 | this struct Scsi_Host instance was spawned |
1264 | hostt->proc_name - name of LLD. This is the driver name that sysfs uses | 1267 | hostt->proc_name - name of LLD. This is the driver name that sysfs uses |
1265 | transportt - pointer to driver's struct scsi_transport_template instance | 1268 | transportt - pointer to driver's struct scsi_transport_template instance |
1266 | (if any). FC and SPI transports currently supported. | 1269 | (if any). FC and SPI transports currently supported. |
1267 | sh_list - a double linked list of pointers to all struct Scsi_Host | 1270 | sh_list - a double linked list of pointers to all struct Scsi_Host |
1268 | instances (currently ordered by ascending host_no) | 1271 | instances (currently ordered by ascending host_no) |
1269 | my_devices - a double linked list of pointers to struct scsi_device | 1272 | my_devices - a double linked list of pointers to struct scsi_device |
1270 | instances that belong to this host. | 1273 | instances that belong to this host. |
1271 | hostdata[0] - area reserved for LLD at end of struct Scsi_Host. Size | 1274 | hostdata[0] - area reserved for LLD at end of struct Scsi_Host. Size |
1272 | is set by the second argument (named 'xtr_bytes') to | 1275 | is set by the second argument (named 'xtr_bytes') to |
1273 | scsi_host_alloc() or scsi_register(). | 1276 | scsi_host_alloc() or scsi_register(). |
1274 | vendor_id - a unique value that identifies the vendor supplying | 1277 | vendor_id - a unique value that identifies the vendor supplying |
1275 | the LLD for the Scsi_Host. Used most often in validating | 1278 | the LLD for the Scsi_Host. Used most often in validating |
1276 | vendor-specific message requests. Value consists of an | 1279 | vendor-specific message requests. Value consists of an |
1277 | identifier type and a vendor-specific value. | 1280 | identifier type and a vendor-specific value. |
1278 | See scsi_netlink.h for a description of valid formats. | 1281 | See scsi_netlink.h for a description of valid formats. |
1279 | 1282 | ||
1280 | The scsi_host structure is defined in include/scsi/scsi_host.h | 1283 | The scsi_host structure is defined in include/scsi/scsi_host.h |
1281 | 1284 | ||
1282 | struct scsi_device | 1285 | struct scsi_device |
1283 | ------------------ | 1286 | ------------------ |
1284 | Generally, there is one instance of this structure for each SCSI logical unit | 1287 | Generally, there is one instance of this structure for each SCSI logical unit |
1285 | on a host. Scsi devices connected to a host are uniquely identified by a | 1288 | on a host. Scsi devices connected to a host are uniquely identified by a |
1286 | channel number, target id and logical unit number (lun). | 1289 | channel number, target id and logical unit number (lun). |
1287 | The structure is defined in include/scsi/scsi_device.h | 1290 | The structure is defined in include/scsi/scsi_device.h |
1288 | 1291 | ||
1289 | struct scsi_cmnd | 1292 | struct scsi_cmnd |
1290 | ---------------- | 1293 | ---------------- |
1291 | Instances of this structure convey SCSI commands to the LLD and responses | 1294 | Instances of this structure convey SCSI commands to the LLD and responses |
1292 | back to the mid level. The SCSI mid level will ensure that no more SCSI | 1295 | back to the mid level. The SCSI mid level will ensure that no more SCSI |
1293 | commands become queued against the LLD than are indicated by | 1296 | commands become queued against the LLD than are indicated by |
1294 | scsi_adjust_queue_depth() (or struct Scsi_Host::cmd_per_lun). There will | 1297 | scsi_adjust_queue_depth() (or struct Scsi_Host::cmd_per_lun). There will |
1295 | be at least one instance of struct scsi_cmnd available for each SCSI device. | 1298 | be at least one instance of struct scsi_cmnd available for each SCSI device. |
1296 | Members of interest: | 1299 | Members of interest: |
1297 | cmnd - array containing SCSI command | 1300 | cmnd - array containing SCSI command |
1298 | cmnd_len - length (in bytes) of SCSI command | 1301 | cmnd_len - length (in bytes) of SCSI command |
1299 | sc_data_direction - direction of data transfer in data phase. See | 1302 | sc_data_direction - direction of data transfer in data phase. See |
1300 | "enum dma_data_direction" in include/linux/dma-mapping.h | 1303 | "enum dma_data_direction" in include/linux/dma-mapping.h |
1301 | request_bufflen - number of data bytes to transfer (0 if no data phase) | 1304 | request_bufflen - number of data bytes to transfer (0 if no data phase) |
1302 | use_sg - ==0 -> no scatter gather list, hence transfer data | 1305 | use_sg - ==0 -> no scatter gather list, hence transfer data |
1303 | to/from request_buffer | 1306 | to/from request_buffer |
1304 | - >0 -> scatter gather list (actually an array) in | 1307 | - >0 -> scatter gather list (actually an array) in |
1305 | request_buffer with use_sg elements | 1308 | request_buffer with use_sg elements |
1306 | request_buffer - either contains data buffer or scatter gather list | 1309 | request_buffer - either contains data buffer or scatter gather list |
1307 | depending on the setting of use_sg. Scatter gather | 1310 | depending on the setting of use_sg. Scatter gather |
1308 | elements are defined by 'struct scatterlist' found | 1311 | elements are defined by 'struct scatterlist' found |
1309 | in include/asm/scatterlist.h . | 1312 | in include/asm/scatterlist.h . |
1310 | done - function pointer that should be invoked by LLD when the | 1313 | done - function pointer that should be invoked by LLD when the |
1311 | SCSI command is completed (successfully or otherwise). | 1314 | SCSI command is completed (successfully or otherwise). |
1312 | Should only be called by an LLD if the LLD has accepted | 1315 | Should only be called by an LLD if the LLD has accepted |
1313 | the command (i.e. queuecommand() returned or will return | 1316 | the command (i.e. queuecommand() returned or will return |
1314 | 0). The LLD may invoke 'done' prior to queuecommand() | 1317 | 0). The LLD may invoke 'done' prior to queuecommand() |
1315 | finishing. | 1318 | finishing. |
1316 | result - should be set by LLD prior to calling 'done'. A value | 1319 | result - should be set by LLD prior to calling 'done'. A value |
1317 | of 0 implies a successfully completed command (and all | 1320 | of 0 implies a successfully completed command (and all |
1318 | data (if any) has been transferred to or from the SCSI | 1321 | data (if any) has been transferred to or from the SCSI |
1319 | target device). 'result' is a 32 bit unsigned integer that | 1322 | target device). 'result' is a 32 bit unsigned integer that |
1320 | can be viewed as 4 related bytes. The SCSI status value is | 1323 | can be viewed as 4 related bytes. The SCSI status value is |
1321 | in the LSB. See include/scsi/scsi.h status_byte(), | 1324 | in the LSB. See include/scsi/scsi.h status_byte(), |
1322 | msg_byte(), host_byte() and driver_byte() macros and | 1325 | msg_byte(), host_byte() and driver_byte() macros and |
1323 | related constants. | 1326 | related constants. |
1324 | sense_buffer - an array (maximum size: SCSI_SENSE_BUFFERSIZE bytes) that | 1327 | sense_buffer - an array (maximum size: SCSI_SENSE_BUFFERSIZE bytes) that |
1325 | should be written when the SCSI status (LSB of 'result') | 1328 | should be written when the SCSI status (LSB of 'result') |
1326 | is set to CHECK_CONDITION (2). When CHECK_CONDITION is | 1329 | is set to CHECK_CONDITION (2). When CHECK_CONDITION is |
1327 | set, if the top nibble of sense_buffer[0] has the value 7 | 1330 | set, if the top nibble of sense_buffer[0] has the value 7 |
1328 | then the mid level will assume the sense_buffer array | 1331 | then the mid level will assume the sense_buffer array |
1329 | contains a valid SCSI sense buffer; otherwise the mid | 1332 | contains a valid SCSI sense buffer; otherwise the mid |
1330 | level will issue a REQUEST_SENSE SCSI command to | 1333 | level will issue a REQUEST_SENSE SCSI command to |
1331 | retrieve the sense buffer. The latter strategy is error | 1334 | retrieve the sense buffer. The latter strategy is error |
1332 | prone in the presence of command queuing so the LLD should | 1335 | prone in the presence of command queuing so the LLD should |
1333 | always "auto-sense". | 1336 | always "auto-sense". |
1334 | device - pointer to scsi_device object that this command is | 1337 | device - pointer to scsi_device object that this command is |
1335 | associated with. | 1338 | associated with. |
1336 | resid - an LLD should set this signed integer to the requested | 1339 | resid - an LLD should set this signed integer to the requested |
1337 | transfer length (i.e. 'request_bufflen') less the number | 1340 | transfer length (i.e. 'request_bufflen') less the number |
1338 | of bytes that are actually transferred. 'resid' is | 1341 | of bytes that are actually transferred. 'resid' is |
1339 | preset to 0 so an LLD can ignore it if it cannot detect | 1342 | preset to 0 so an LLD can ignore it if it cannot detect |
1340 | underruns (overruns should be rare). If possible an LLD | 1343 | underruns (overruns should be rare). If possible an LLD |
1341 | should set 'resid' prior to invoking 'done'. The most | 1344 | should set 'resid' prior to invoking 'done'. The most |
1342 | interesting case is data transfers from a SCSI target | 1345 | interesting case is data transfers from a SCSI target |
1343 | device device (i.e. READs) that underrun. | 1346 | device device (i.e. READs) that underrun. |
1344 | underflow - LLD should place (DID_ERROR << 16) in 'result' if | 1347 | underflow - LLD should place (DID_ERROR << 16) in 'result' if |
1345 | actual number of bytes transferred is less than this | 1348 | actual number of bytes transferred is less than this |
1346 | figure. Not many LLDs implement this check and some that | 1349 | figure. Not many LLDs implement this check and some that |
1347 | do just output an error message to the log rather than | 1350 | do just output an error message to the log rather than |
1348 | report a DID_ERROR. Better for an LLD to implement | 1351 | report a DID_ERROR. Better for an LLD to implement |
1349 | 'resid'. | 1352 | 'resid'. |
1350 | 1353 | ||
1351 | The scsi_cmnd structure is defined in include/scsi/scsi_cmnd.h | 1354 | The scsi_cmnd structure is defined in include/scsi/scsi_cmnd.h |
1352 | 1355 | ||
1353 | 1356 | ||
1354 | Locks | 1357 | Locks |
1355 | ===== | 1358 | ===== |
1356 | Each struct Scsi_Host instance has a spin_lock called struct | 1359 | Each struct Scsi_Host instance has a spin_lock called struct |
1357 | Scsi_Host::default_lock which is initialized in scsi_host_alloc() [found in | 1360 | Scsi_Host::default_lock which is initialized in scsi_host_alloc() [found in |
1358 | hosts.c]. Within the same function the struct Scsi_Host::host_lock pointer | 1361 | hosts.c]. Within the same function the struct Scsi_Host::host_lock pointer |
1359 | is initialized to point at default_lock. Thereafter lock and unlock | 1362 | is initialized to point at default_lock. Thereafter lock and unlock |
1360 | operations performed by the mid level use the struct Scsi_Host::host_lock | 1363 | operations performed by the mid level use the struct Scsi_Host::host_lock |
1361 | pointer. Previously drivers could override the host_lock pointer but | 1364 | pointer. Previously drivers could override the host_lock pointer but |
1362 | this is not allowed anymore. | 1365 | this is not allowed anymore. |
1363 | 1366 | ||
1364 | 1367 | ||
1365 | Autosense | 1368 | Autosense |
1366 | ========= | 1369 | ========= |
1367 | Autosense (or auto-sense) is defined in the SAM-2 document as "the | 1370 | Autosense (or auto-sense) is defined in the SAM-2 document as "the |
1368 | automatic return of sense data to the application client coincident | 1371 | automatic return of sense data to the application client coincident |
1369 | with the completion of a SCSI command" when a status of CHECK CONDITION | 1372 | with the completion of a SCSI command" when a status of CHECK CONDITION |
1370 | occurs. LLDs should perform autosense. This should be done when the LLD | 1373 | occurs. LLDs should perform autosense. This should be done when the LLD |
1371 | detects a CHECK CONDITION status by either: | 1374 | detects a CHECK CONDITION status by either: |
1372 | a) instructing the SCSI protocol (e.g. SCSI Parallel Interface (SPI)) | 1375 | a) instructing the SCSI protocol (e.g. SCSI Parallel Interface (SPI)) |
1373 | to perform an extra data in phase on such responses | 1376 | to perform an extra data in phase on such responses |
1374 | b) or, the LLD issuing a REQUEST SENSE command itself | 1377 | b) or, the LLD issuing a REQUEST SENSE command itself |
1375 | 1378 | ||
1376 | Either way, when a status of CHECK CONDITION is detected, the mid level | 1379 | Either way, when a status of CHECK CONDITION is detected, the mid level |
1377 | decides whether the LLD has performed autosense by checking struct | 1380 | decides whether the LLD has performed autosense by checking struct |
1378 | scsi_cmnd::sense_buffer[0] . If this byte has an upper nibble of 7 (or 0xf) | 1381 | scsi_cmnd::sense_buffer[0] . If this byte has an upper nibble of 7 (or 0xf) |
1379 | then autosense is assumed to have taken place. If it has another value (and | 1382 | then autosense is assumed to have taken place. If it has another value (and |
1380 | this byte is initialized to 0 before each command) then the mid level will | 1383 | this byte is initialized to 0 before each command) then the mid level will |
1381 | issue a REQUEST SENSE command. | 1384 | issue a REQUEST SENSE command. |
1382 | 1385 | ||
1383 | In the presence of queued commands the "nexus" that maintains sense | 1386 | In the presence of queued commands the "nexus" that maintains sense |
1384 | buffer data from the command that failed until a following REQUEST SENSE | 1387 | buffer data from the command that failed until a following REQUEST SENSE |
1385 | may get out of synchronization. This is why it is best for the LLD | 1388 | may get out of synchronization. This is why it is best for the LLD |
1386 | to perform autosense. | 1389 | to perform autosense. |
1387 | 1390 | ||
1388 | 1391 | ||
1389 | Changes since lk 2.4 series | 1392 | Changes since lk 2.4 series |
1390 | =========================== | 1393 | =========================== |
1391 | io_request_lock has been replaced by several finer grained locks. The lock | 1394 | io_request_lock has been replaced by several finer grained locks. The lock |
1392 | relevant to LLDs is struct Scsi_Host::host_lock and there is | 1395 | relevant to LLDs is struct Scsi_Host::host_lock and there is |
1393 | one per SCSI host. | 1396 | one per SCSI host. |
1394 | 1397 | ||
1395 | The older error handling mechanism has been removed. This means the | 1398 | The older error handling mechanism has been removed. This means the |
1396 | LLD interface functions abort() and reset() have been removed. | 1399 | LLD interface functions abort() and reset() have been removed. |
1397 | The struct scsi_host_template::use_new_eh_code flag has been removed. | 1400 | The struct scsi_host_template::use_new_eh_code flag has been removed. |
1398 | 1401 | ||
1399 | In the 2.4 series the SCSI subsystem configuration descriptions were | 1402 | In the 2.4 series the SCSI subsystem configuration descriptions were |
1400 | aggregated with the configuration descriptions from all other Linux | 1403 | aggregated with the configuration descriptions from all other Linux |
1401 | subsystems in the Documentation/Configure.help file. In the 2.6 series, | 1404 | subsystems in the Documentation/Configure.help file. In the 2.6 series, |
1402 | the SCSI subsystem now has its own (much smaller) drivers/scsi/Kconfig | 1405 | the SCSI subsystem now has its own (much smaller) drivers/scsi/Kconfig |
1403 | file that contains both configuration and help information. | 1406 | file that contains both configuration and help information. |
1404 | 1407 | ||
1405 | struct SHT has been renamed to struct scsi_host_template. | 1408 | struct SHT has been renamed to struct scsi_host_template. |
1406 | 1409 | ||
1407 | Addition of the "hotplug initialization model" and many extra functions | 1410 | Addition of the "hotplug initialization model" and many extra functions |
1408 | to support it. | 1411 | to support it. |
1409 | 1412 | ||
1410 | 1413 | ||
1411 | Credits | 1414 | Credits |
1412 | ======= | 1415 | ======= |
1413 | The following people have contributed to this document: | 1416 | The following people have contributed to this document: |
1414 | Mike Anderson <andmike at us dot ibm dot com> | 1417 | Mike Anderson <andmike at us dot ibm dot com> |
1415 | James Bottomley <James dot Bottomley at hansenpartnership dot com> | 1418 | James Bottomley <James dot Bottomley at hansenpartnership dot com> |
1416 | Patrick Mansfield <patmans at us dot ibm dot com> | 1419 | Patrick Mansfield <patmans at us dot ibm dot com> |
1417 | Christoph Hellwig <hch at infradead dot org> | 1420 | Christoph Hellwig <hch at infradead dot org> |
1418 | Doug Ledford <dledford at redhat dot com> | 1421 | Doug Ledford <dledford at redhat dot com> |
1419 | Andries Brouwer <Andries dot Brouwer at cwi dot nl> | 1422 | Andries Brouwer <Andries dot Brouwer at cwi dot nl> |
1420 | Randy Dunlap <rdunlap at xenotime dot net> | 1423 | Randy Dunlap <rdunlap at xenotime dot net> |
1421 | Alan Stern <stern at rowland dot harvard dot edu> | 1424 | Alan Stern <stern at rowland dot harvard dot edu> |
1422 | 1425 | ||
1423 | 1426 | ||
1424 | Douglas Gilbert | 1427 | Douglas Gilbert |
1425 | dgilbert at interlog dot com | 1428 | dgilbert at interlog dot com |