Commit ce5c5d65 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Martin K. Petersen
parent d4d79340
...@@ -35,5 +35,6 @@ Linux SCSI Subsystem ...@@ -35,5 +35,6 @@ Linux SCSI Subsystem
scsi_eh scsi_eh
scsi_fc_transport scsi_fc_transport
scsi-generic scsi-generic
scsi_mid_low_api
scsi_transport_srp/figures scsi_transport_srp/figures
...@@ -5,7 +5,7 @@ SCSI EH ...@@ -5,7 +5,7 @@ SCSI EH
======= =======
This document describes SCSI midlayer error handling infrastructure. This document describes SCSI midlayer error handling infrastructure.
Please refer to Documentation/scsi/scsi_mid_low_api.txt for more Please refer to Documentation/scsi/scsi_mid_low_api.rst for more
information regarding SCSI midlayer. information regarding SCSI midlayer.
.. TABLE OF CONTENTS .. TABLE OF CONTENTS
......
Linux Kernel 2.6 series .. SPDX-License-Identifier: GPL-2.0
SCSI mid_level - lower_level driver interface
============================================= =============================================
SCSI mid_level - lower_level driver interface
=============================================
Introduction Introduction
============ ============
This document outlines the interface between the Linux SCSI mid level and This document outlines the interface between the Linux SCSI mid level and
SCSI lower level drivers. Lower level drivers (LLDs) are variously called SCSI lower level drivers. Lower level drivers (LLDs) are variously called
host bus adapter (HBA) drivers and host drivers (HD). A "host" in this host bus adapter (HBA) drivers and host drivers (HD). A "host" in this
context is a bridge between a computer IO bus (e.g. PCI or ISA) and a context is a bridge between a computer IO bus (e.g. PCI or ISA) and a
single SCSI initiator port on a SCSI transport. An "initiator" port single SCSI initiator port on a SCSI transport. An "initiator" port
...@@ -24,8 +26,8 @@ directory). ...@@ -24,8 +26,8 @@ directory).
For example, the aic7xxx LLD controls Adaptec SCSI parallel interface For example, the aic7xxx LLD controls Adaptec SCSI parallel interface
(SPI) controllers based on that company's 7xxx chip series. The aic7xxx (SPI) controllers based on that company's 7xxx chip series. The aic7xxx
LLD can be built into the kernel or loaded as a module. There can only be LLD can be built into the kernel or loaded as a module. There can only be
one aic7xxx LLD running in a Linux system but it may be controlling many one aic7xxx LLD running in a Linux system but it may be controlling many
HBAs. These HBAs might be either on PCI daughter-boards or built into HBAs. These HBAs might be either on PCI daughter-boards or built into
the motherboard (or both). Some aic7xxx based HBAs are dual controllers the motherboard (or both). Some aic7xxx based HBAs are dual controllers
and thus represent two hosts. Like most modern HBAs, each aic7xxx host and thus represent two hosts. Like most modern HBAs, each aic7xxx host
has its own PCI device address. [The one-to-one correspondence between has its own PCI device address. [The one-to-one correspondence between
...@@ -39,20 +41,20 @@ This version of the document roughly matches linux kernel version 2.6.8 . ...@@ -39,20 +41,20 @@ This version of the document roughly matches linux kernel version 2.6.8 .
Documentation Documentation
============= =============
There is a SCSI documentation directory within the kernel source tree, There is a SCSI documentation directory within the kernel source tree,
typically Documentation/scsi . Most documents are in plain typically Documentation/scsi . Most documents are in plain
(i.e. ASCII) text. This file is named scsi_mid_low_api.txt and can be (i.e. ASCII) text. This file is named scsi_mid_low_api.txt and can be
found in that directory. A more recent copy of this document may be found found in that directory. A more recent copy of this document may be found
at http://web.archive.org/web/20070107183357rn_1/sg.torque.net/scsi/. at http://web.archive.org/web/20070107183357rn_1/sg.torque.net/scsi/.
Many LLDs are documented there (e.g. aic7xxx.txt). The SCSI mid-level is Many LLDs are documented there (e.g. aic7xxx.txt). The SCSI mid-level is
briefly described in scsi.txt which contains a url to a document briefly described in scsi.txt which contains a url to a document
describing the SCSI subsystem in the lk 2.4 series. Two upper level describing the SCSI subsystem in the lk 2.4 series. Two upper level
drivers have documents in that directory: st.txt (SCSI tape driver) and drivers have documents in that directory: st.txt (SCSI tape driver) and
scsi-generic.txt (for the sg driver). scsi-generic.txt (for the sg driver).
Some documentation (or urls) for LLDs may be found in the C source code Some documentation (or urls) for LLDs may be found in the C source code
or in the same directory as the C source code. For example to find a url or in the same directory as the C source code. For example to find a url
about the USB mass storage driver see the about the USB mass storage driver see the
/usr/src/linux/drivers/usb/storage directory. /usr/src/linux/drivers/usb/storage directory.
Driver structure Driver structure
...@@ -62,7 +64,7 @@ the drivers/scsi directory. For example, a driver called "xyz" has a header ...@@ -62,7 +64,7 @@ the drivers/scsi directory. For example, a driver called "xyz" has a header
file "xyz.h" and a source file "xyz.c". [Actually there is no good reason file "xyz.h" and a source file "xyz.c". [Actually there is no good reason
why this couldn't all be in one file; the header file is superfluous.] Some why this couldn't all be in one file; the header file is superfluous.] Some
drivers that have been ported to several operating systems have more than drivers that have been ported to several operating systems have more than
two files. For example the aic7xxx driver has separate files for generic two files. For example the aic7xxx driver has separate files for generic
and OS-specific code (e.g. FreeBSD and Linux). Such drivers tend to have and OS-specific code (e.g. FreeBSD and Linux). Such drivers tend to have
their own directory under the drivers/scsi directory. their own directory under the drivers/scsi directory.
...@@ -80,10 +82,11 @@ to be hot plugged (and unplugged) during the lifetime of the LLD and will ...@@ -80,10 +82,11 @@ to be hot plugged (and unplugged) during the lifetime of the LLD and will
be referred to as the "hotplug" initialization model. The newer model is be referred to as the "hotplug" initialization model. The newer model is
preferred as it can handle both traditional SCSI equipment that is preferred as it can handle both traditional SCSI equipment that is
permanently connected as well as modern "SCSI" devices (e.g. USB or permanently connected as well as modern "SCSI" devices (e.g. USB or
IEEE 1394 connected digital cameras) that are hotplugged. Both IEEE 1394 connected digital cameras) that are hotplugged. Both
initialization models are discussed in the following sections. initialization models are discussed in the following sections.
An LLD interfaces to the SCSI subsystem several ways: An LLD interfaces to the SCSI subsystem several ways:
a) directly invoking functions supplied by the mid level a) directly invoking functions supplied by the mid level
b) passing a set of function pointers to a registration function b) passing a set of function pointers to a registration function
supplied by the mid level. The mid level will then invoke these supplied by the mid level. The mid level will then invoke these
...@@ -98,11 +101,11 @@ supplied functions" below. ...@@ -98,11 +101,11 @@ supplied functions" below.
Those functions in group b) are listed in a section entitled "Interface Those functions in group b) are listed in a section entitled "Interface
functions" below. Their function pointers are placed in the members of functions" below. Their function pointers are placed in the members of
"struct scsi_host_template", an instance of which is passed to "struct scsi_host_template", an instance of which is passed to
scsi_host_alloc() ** . Those interface functions that the LLD does not scsi_host_alloc() [#]_. Those interface functions that the LLD does not
wish to supply should have NULL placed in the corresponding member of wish to supply should have NULL placed in the corresponding member of
struct scsi_host_template. Defining an instance of struct struct scsi_host_template. Defining an instance of struct
scsi_host_template at file scope will cause NULL to be placed in function scsi_host_template at file scope will cause NULL to be placed in function
pointer members not explicitly initialized. pointer members not explicitly initialized.
Those usages in group c) should be handled with care, especially in a Those usages in group c) should be handled with care, especially in a
"hotplug" environment. LLDs should be aware of the lifetime of instances "hotplug" environment. LLDs should be aware of the lifetime of instances
...@@ -110,11 +113,11 @@ that are shared with the mid level and other layers. ...@@ -110,11 +113,11 @@ that are shared with the mid level and other layers.
All functions defined within an LLD and all data defined at file scope All functions defined within an LLD and all data defined at file scope
should be static. For example the slave_alloc() function in an LLD should be static. For example the slave_alloc() function in an LLD
called "xxx" could be defined as called "xxx" could be defined as
"static int xxx_slave_alloc(struct scsi_device * sdev) { /* code */ }" ``static int xxx_slave_alloc(struct scsi_device * sdev) { /* code */ }``
** the scsi_host_alloc() function is a replacement for the rather vaguely .. [#] the scsi_host_alloc() function is a replacement for the rather vaguely
named scsi_register() function in most situations. named scsi_register() function in most situations.
Hotplug initialization model Hotplug initialization model
...@@ -136,48 +139,47 @@ aware of an LLD when that LLD registers its first HBA. ...@@ -136,48 +139,47 @@ aware of an LLD when that LLD registers its first HBA.
At some later time, the LLD becomes aware of an HBA and what follows At some later time, the LLD becomes aware of an HBA and what follows
is a typical sequence of calls between the LLD and the mid level. is a typical sequence of calls between the LLD and the mid level.
This example shows the mid level scanning the newly introduced HBA for 3 This example shows the mid level scanning the newly introduced HBA for 3
scsi devices of which only the first 2 respond: scsi devices of which only the first 2 respond::
HBA PROBE: assume 2 SCSI devices found in scan HBA PROBE: assume 2 SCSI devices found in scan
LLD mid level LLD LLD mid level LLD
===-------------------=========--------------------===------ ===-------------------=========--------------------===------
scsi_host_alloc() --> scsi_host_alloc() -->
scsi_add_host() ----> scsi_add_host() ---->
scsi_scan_host() -------+ scsi_scan_host() -------+
| |
slave_alloc() slave_alloc()
slave_configure() --> scsi_change_queue_depth() slave_configure() --> scsi_change_queue_depth()
| |
slave_alloc() slave_alloc()
slave_configure() slave_configure()
| |
slave_alloc() *** slave_alloc() ***
slave_destroy() *** slave_destroy() ***
------------------------------------------------------------
*** For scsi devices that the mid level tries to scan but do not
respond, a slave_alloc(), slave_destroy() pair is called.
If the LLD wants to adjust the default queue settings, it can invoke If the LLD wants to adjust the default queue settings, it can invoke
scsi_change_queue_depth() in its slave_configure() routine. scsi_change_queue_depth() in its slave_configure() routine.
*** For scsi devices that the mid level tries to scan but do not
respond, a slave_alloc(), slave_destroy() pair is called.
When an HBA is being removed it could be as part of an orderly shutdown When an HBA is being removed it could be as part of an orderly shutdown
associated with the LLD module being unloaded (e.g. with the "rmmod" associated with the LLD module being unloaded (e.g. with the "rmmod"
command) or in response to a "hot unplug" indicated by sysfs()'s command) or in response to a "hot unplug" indicated by sysfs()'s
remove() callback being invoked. In either case, the sequence is the remove() callback being invoked. In either case, the sequence is the
same: same::
HBA REMOVE: assume 2 SCSI devices attached HBA REMOVE: assume 2 SCSI devices attached
LLD mid level LLD LLD mid level LLD
===----------------------=========-----------------===------ ===----------------------=========-----------------===------
scsi_remove_host() ---------+ scsi_remove_host() ---------+
| |
slave_destroy() slave_destroy()
slave_destroy() slave_destroy()
scsi_host_put() scsi_host_put()
------------------------------------------------------------
It may be useful for a LLD to keep track of struct Scsi_Host instances It may be useful for a LLD to keep track of struct Scsi_Host instances
(a pointer is returned by scsi_host_alloc()). Such instances are "owned" (a pointer is returned by scsi_host_alloc()). Such instances are "owned"
by the mid-level. struct Scsi_Host instances are freed from by the mid-level. struct Scsi_Host instances are freed from
...@@ -193,16 +195,15 @@ The hotplug concept may be extended to SCSI devices. Currently, when an ...@@ -193,16 +195,15 @@ The hotplug concept may be extended to SCSI devices. Currently, when an
HBA is added, the scsi_scan_host() function causes a scan for SCSI devices HBA is added, the scsi_scan_host() function causes a scan for SCSI devices
attached to the HBA's SCSI transport. On newer SCSI transports the HBA attached to the HBA's SCSI transport. On newer SCSI transports the HBA
may become aware of a new SCSI device _after_ the scan has completed. may become aware of a new SCSI device _after_ the scan has completed.
An LLD can use this sequence to make the mid level aware of a SCSI device: An LLD can use this sequence to make the mid level aware of a SCSI device::
SCSI DEVICE hotplug SCSI DEVICE hotplug
LLD mid level LLD LLD mid level LLD
===-------------------=========--------------------===------ ===-------------------=========--------------------===------
scsi_add_device() ------+ scsi_add_device() ------+
| |
slave_alloc() slave_alloc()
slave_configure() [--> scsi_change_queue_depth()] slave_configure() [--> scsi_change_queue_depth()]
------------------------------------------------------------
In a similar fashion, an LLD may become aware that a SCSI device has been In a similar fashion, an LLD may become aware that a SCSI device has been
removed (unplugged) or the connection to it has been interrupted. Some removed (unplugged) or the connection to it has been interrupted. Some
...@@ -210,15 +211,14 @@ existing SCSI transports (e.g. SPI) may not become aware that a SCSI ...@@ -210,15 +211,14 @@ existing SCSI transports (e.g. SPI) may not become aware that a SCSI
device has been removed until a subsequent SCSI command fails which will device has been removed until a subsequent SCSI command fails which will
probably cause that device to be set offline by the mid level. An LLD that probably cause that device to be set offline by the mid level. An LLD that
detects the removal of a SCSI device can instigate its removal from detects the removal of a SCSI device can instigate its removal from
upper layers with this sequence: upper layers with this sequence::
SCSI DEVICE hot unplug SCSI DEVICE hot unplug
LLD mid level LLD LLD mid level LLD
===----------------------=========-----------------===------ ===----------------------=========-----------------===------
scsi_remove_device() -------+ scsi_remove_device() -------+
| |
slave_destroy() slave_destroy()
------------------------------------------------------------
It may be useful for an LLD to keep track of struct scsi_device instances It may be useful for an LLD to keep track of struct scsi_device instances
(a pointer is passed as the parameter to slave_alloc() and (a pointer is passed as the parameter to slave_alloc() and
...@@ -237,10 +237,16 @@ where they do. ...@@ -237,10 +237,16 @@ where they do.
There are 3 reference counting functions of interest associated with There are 3 reference counting functions of interest associated with
struct Scsi_Host: struct Scsi_Host:
- scsi_host_alloc(): returns a pointer to new instance of struct
- scsi_host_alloc():
returns a pointer to new instance of struct
Scsi_Host which has its reference count ^^ set to 1 Scsi_Host which has its reference count ^^ set to 1
- scsi_host_get(): adds 1 to the reference count of the given instance
- scsi_host_put(): decrements 1 from the reference count of the given - scsi_host_get():
adds 1 to the reference count of the given instance
- scsi_host_put():
decrements 1 from the reference count of the given
instance. If the reference count reaches 0 then the given instance instance. If the reference count reaches 0 then the given instance
is freed is freed
...@@ -254,8 +260,10 @@ to bump its reference count. When it is finished with the pointer it can ...@@ -254,8 +260,10 @@ to bump its reference count. When it is finished with the pointer it can
use scsi_device_put() to decrement its reference count (and potentially use scsi_device_put() to decrement its reference count (and potentially
delete it). delete it).
^^ struct Scsi_Host actually has 2 reference counts which are manipulated .. Note::
in parallel by these functions.
struct Scsi_Host actually has 2 reference counts which are manipulated
in parallel by these functions.
Conventions Conventions
...@@ -263,17 +271,17 @@ Conventions ...@@ -263,17 +271,17 @@ Conventions
First, Linus Torvalds's thoughts on C coding style can be found in the First, Linus Torvalds's thoughts on C coding style can be found in the
Documentation/process/coding-style.rst file. Documentation/process/coding-style.rst file.
Next, there is a movement to "outlaw" typedefs introducing synonyms for Next, there is a movement to "outlaw" typedefs introducing synonyms for
struct tags. Both can be still found in the SCSI subsystem, but struct tags. Both can be still found in the SCSI subsystem, but
the typedefs have been moved to a single file, scsi_typedefs.h to the typedefs have been moved to a single file, scsi_typedefs.h to
make their future removal easier, for example: make their future removal easier, for example:
"typedef struct scsi_cmnd Scsi_Cmnd;" "typedef struct scsi_cmnd Scsi_Cmnd;"
Also, most C99 enhancements are encouraged to the extent they are supported Also, most C99 enhancements are encouraged to the extent they are supported
by the relevant gcc compilers. So C99 style structure and array by the relevant gcc compilers. So C99 style structure and array
initializers are encouraged where appropriate. Don't go too far, initializers are encouraged where appropriate. Don't go too far,
VLAs are not properly supported yet. An exception to this is the use of VLAs are not properly supported yet. An exception to this is the use of
"//" style comments; /*...*/ comments are still preferred in Linux. ``//`` style comments; ``/*...*/`` comments are still preferred in Linux.
Well written, tested and documented code, need not be re-formatted to Well written, tested and documented code, need not be re-formatted to
comply with the above conventions. For example, the aic7xxx driver comply with the above conventions. For example, the aic7xxx driver
...@@ -284,357 +292,358 @@ and Adaptec have their own coding conventions. ...@@ -284,357 +292,358 @@ and Adaptec have their own coding conventions.
Mid level supplied functions Mid level supplied functions
============================ ============================
These functions are supplied by the SCSI mid level for use by LLDs. These functions are supplied by the SCSI mid level for use by LLDs.
The names (i.e. entry points) of these functions are exported The names (i.e. entry points) of these functions are exported
so an LLD that is a module can access them. The kernel will so an LLD that is a module can access them. The kernel will
arrange for the SCSI mid level to be loaded and initialized before any LLD arrange for the SCSI mid level to be loaded and initialized before any LLD
is initialized. The functions below are listed alphabetically and their is initialized. The functions below are listed alphabetically and their
names all start with "scsi_". names all start with ``scsi_``.
Summary: Summary:
scsi_add_device - creates new scsi device (lu) instance
scsi_add_host - perform sysfs registration and set up transport class - scsi_add_device - creates new scsi device (lu) instance
scsi_change_queue_depth - change the queue depth on a SCSI device - scsi_add_host - perform sysfs registration and set up transport class
scsi_bios_ptable - return copy of block device's partition table - scsi_change_queue_depth - change the queue depth on a SCSI device
scsi_block_requests - prevent further commands being queued to given host - scsi_bios_ptable - return copy of block device's partition table
scsi_host_alloc - return a new scsi_host instance whose refcount==1 - scsi_block_requests - prevent further commands being queued to given host
scsi_host_get - increments Scsi_Host instance's refcount - scsi_host_alloc - return a new scsi_host instance whose refcount==1
scsi_host_put - decrements Scsi_Host instance's refcount (free if 0) - scsi_host_get - increments Scsi_Host instance's refcount
scsi_partsize - parse partition table into cylinders, heads + sectors - scsi_host_put - decrements Scsi_Host instance's refcount (free if 0)
scsi_register - create and register a scsi host adapter instance. - scsi_partsize - parse partition table into cylinders, heads + sectors
scsi_remove_device - detach and remove a SCSI device - scsi_register - create and register a scsi host adapter instance.
scsi_remove_host - detach and remove all SCSI devices owned by host - scsi_remove_device - detach and remove a SCSI device
scsi_report_bus_reset - report scsi _bus_ reset observed - scsi_remove_host - detach and remove all SCSI devices owned by host
scsi_scan_host - scan SCSI bus - scsi_report_bus_reset - report scsi _bus_ reset observed
scsi_track_queue_full - track successive QUEUE_FULL events - scsi_scan_host - scan SCSI bus
scsi_unblock_requests - allow further commands to be queued to given host - scsi_track_queue_full - track successive QUEUE_FULL events
scsi_unregister - [calls scsi_host_put()] - scsi_unblock_requests - allow further commands to be queued to given host
- scsi_unregister - [calls scsi_host_put()]
Details:
Details::
/**
* scsi_add_device - creates new scsi device (lu) instance /**
* @shost: pointer to scsi host instance * scsi_add_device - creates new scsi device (lu) instance
* @channel: channel number (rarely other than 0) * @shost: pointer to scsi host instance
* @id: target id number * @channel: channel number (rarely other than 0)
* @lun: logical unit number * @id: target id number
* * @lun: logical unit number
* Returns pointer to new struct scsi_device instance or *
* ERR_PTR(-ENODEV) (or some other bent pointer) if something is * Returns pointer to new struct scsi_device instance or
* wrong (e.g. no lu responds at given address) * ERR_PTR(-ENODEV) (or some other bent pointer) if something is
* * wrong (e.g. no lu responds at given address)
* Might block: yes *
* * Might block: yes
* Notes: This call is usually performed internally during a scsi *
* bus scan when an HBA is added (i.e. scsi_scan_host()). So it * Notes: This call is usually performed internally during a scsi
* should only be called if the HBA becomes aware of a new scsi * bus scan when an HBA is added (i.e. scsi_scan_host()). So it
* device (lu) after scsi_scan_host() has completed. If successful * should only be called if the HBA becomes aware of a new scsi
* this call can lead to slave_alloc() and slave_configure() callbacks * device (lu) after scsi_scan_host() has completed. If successful
* into the LLD. * this call can lead to slave_alloc() and slave_configure() callbacks
* * into the LLD.
* Defined in: drivers/scsi/scsi_scan.c *
**/ * Defined in: drivers/scsi/scsi_scan.c
struct scsi_device * scsi_add_device(struct Scsi_Host *shost, **/
unsigned int channel, struct scsi_device * scsi_add_device(struct Scsi_Host *shost,
unsigned int id, unsigned int lun) unsigned int channel,
unsigned int id, unsigned int lun)
/**
* scsi_add_host - perform sysfs registration and set up transport class /**
* @shost: pointer to scsi host instance * scsi_add_host - perform sysfs registration and set up transport class
* @dev: pointer to struct device of type scsi class * @shost: pointer to scsi host instance
* * @dev: pointer to struct device of type scsi class
* Returns 0 on success, negative errno of failure (e.g. -ENOMEM) *
* * Returns 0 on success, negative errno of failure (e.g. -ENOMEM)
* Might block: no *
* * Might block: no
* Notes: Only required in "hotplug initialization model" after a *
* successful call to scsi_host_alloc(). This function does not * Notes: Only required in "hotplug initialization model" after a
* scan the bus; this can be done by calling scsi_scan_host() or * successful call to scsi_host_alloc(). This function does not
* in some other transport-specific way. The LLD must set up * scan the bus; this can be done by calling scsi_scan_host() or
* the transport template before calling this function and may only * in some other transport-specific way. The LLD must set up
* access the transport class data after this function has been called. * the transport template before calling this function and may only
* * access the transport class data after this function has been called.
* Defined in: drivers/scsi/hosts.c *
**/ * Defined in: drivers/scsi/hosts.c
int scsi_add_host(struct Scsi_Host *shost, struct device * dev) **/
int scsi_add_host(struct Scsi_Host *shost, struct device * dev)
/**
* scsi_change_queue_depth - allow LLD to change queue depth on a SCSI device /**
* @sdev: pointer to SCSI device to change queue depth on * scsi_change_queue_depth - allow LLD to change queue depth on a SCSI device
* @tags Number of tags allowed if tagged queuing enabled, * @sdev: pointer to SCSI device to change queue depth on
* or number of commands the LLD can queue up * @tags Number of tags allowed if tagged queuing enabled,
* in non-tagged mode (as per cmd_per_lun). * or number of commands the LLD can queue up
* * in non-tagged mode (as per cmd_per_lun).
* Returns nothing *
* * Returns nothing
* Might block: no *
* * Might block: no
* Notes: Can be invoked any time on a SCSI device controlled by this *
* LLD. [Specifically during and after slave_configure() and prior to * Notes: Can be invoked any time on a SCSI device controlled by this
* slave_destroy().] Can safely be invoked from interrupt code. * LLD. [Specifically during and after slave_configure() and prior to
* * slave_destroy().] Can safely be invoked from interrupt code.
* Defined in: drivers/scsi/scsi.c [see source code for more notes] *
* * Defined in: drivers/scsi/scsi.c [see source code for more notes]
**/ *
int scsi_change_queue_depth(struct scsi_device *sdev, int tags) **/
int scsi_change_queue_depth(struct scsi_device *sdev, int tags)
/**
* scsi_bios_ptable - return copy of block device's partition table /**
* @dev: pointer to block device * scsi_bios_ptable - return copy of block device's partition table
* * @dev: pointer to block device
* Returns pointer to partition table, or NULL for failure *
* * Returns pointer to partition table, or NULL for failure
* Might block: yes *
* * Might block: yes
* Notes: Caller owns memory returned (free with kfree() ) *
* * Notes: Caller owns memory returned (free with kfree() )
* Defined in: drivers/scsi/scsicam.c *
**/ * Defined in: drivers/scsi/scsicam.c
unsigned char *scsi_bios_ptable(struct block_device *dev) **/
unsigned char *scsi_bios_ptable(struct block_device *dev)
/**
* scsi_block_requests - prevent further commands being queued to given host /**
* * scsi_block_requests - prevent further commands being queued to given host
* @shost: pointer to host to block commands on *
* * @shost: pointer to host to block commands on
* Returns nothing *
* * Returns nothing
* Might block: no *
* * Might block: no
* Notes: There is no timer nor any other means by which the requests *
* get unblocked other than the LLD calling scsi_unblock_requests(). * Notes: There is no timer nor any other means by which the requests
* * get unblocked other than the LLD calling scsi_unblock_requests().
* Defined in: drivers/scsi/scsi_lib.c *
**/ * Defined in: drivers/scsi/scsi_lib.c
void scsi_block_requests(struct Scsi_Host * shost) **/
void scsi_block_requests(struct Scsi_Host * shost)
/**
* scsi_host_alloc - create a scsi host adapter instance and perform basic /**
* initialization. * scsi_host_alloc - create a scsi host adapter instance and perform basic
* @sht: pointer to scsi host template * initialization.
* @privsize: extra bytes to allocate in hostdata array (which is the * @sht: pointer to scsi host template
* last member of the returned Scsi_Host instance) * @privsize: extra bytes to allocate in hostdata array (which is the
* * last member of the returned Scsi_Host instance)
* Returns pointer to new Scsi_Host instance or NULL on failure *
* * Returns pointer to new Scsi_Host instance or NULL on failure
* Might block: yes *
* * Might block: yes
* Notes: When this call returns to the LLD, the SCSI bus scan on *
* this host has _not_ yet been done. * Notes: When this call returns to the LLD, the SCSI bus scan on
* The hostdata array (by default zero length) is a per host scratch * this host has _not_ yet been done.
* area for the LLD's exclusive use. * The hostdata array (by default zero length) is a per host scratch
* Both associated refcounting objects have their refcount set to 1. * area for the LLD's exclusive use.
* Full registration (in sysfs) and a bus scan are performed later when * Both associated refcounting objects have their refcount set to 1.
* scsi_add_host() and scsi_scan_host() are called. * Full registration (in sysfs) and a bus scan are performed later when
* * scsi_add_host() and scsi_scan_host() are called.
* Defined in: drivers/scsi/hosts.c . *
**/ * Defined in: drivers/scsi/hosts.c .
struct Scsi_Host * scsi_host_alloc(struct scsi_host_template * sht, **/
int privsize) struct Scsi_Host * scsi_host_alloc(struct scsi_host_template * sht,
int privsize)
/**
* scsi_host_get - increment Scsi_Host instance refcount /**
* @shost: pointer to struct Scsi_Host instance * scsi_host_get - increment Scsi_Host instance refcount
* * @shost: pointer to struct Scsi_Host instance
* Returns nothing *
* * Returns nothing
* Might block: currently may block but may be changed to not block *
* * Might block: currently may block but may be changed to not block
* Notes: Actually increments the counts in two sub-objects *
* * Notes: Actually increments the counts in two sub-objects
* Defined in: drivers/scsi/hosts.c *
**/ * Defined in: drivers/scsi/hosts.c
void scsi_host_get(struct Scsi_Host *shost) **/
void scsi_host_get(struct Scsi_Host *shost)
/**
* scsi_host_put - decrement Scsi_Host instance refcount, free if 0 /**
* @shost: pointer to struct Scsi_Host instance * scsi_host_put - decrement Scsi_Host instance refcount, free if 0
* * @shost: pointer to struct Scsi_Host instance
* Returns nothing *
* * Returns nothing
* Might block: currently may block but may be changed to not block *
* * Might block: currently may block but may be changed to not block
* Notes: Actually decrements the counts in two sub-objects. If the *
* latter refcount reaches 0, the Scsi_Host instance is freed. * Notes: Actually decrements the counts in two sub-objects. If the
* The LLD need not worry exactly when the Scsi_Host instance is * latter refcount reaches 0, the Scsi_Host instance is freed.
* freed, it just shouldn't access the instance after it has balanced * The LLD need not worry exactly when the Scsi_Host instance is
* out its refcount usage. * freed, it just shouldn't access the instance after it has balanced
* * out its refcount usage.
* Defined in: drivers/scsi/hosts.c *
**/ * Defined in: drivers/scsi/hosts.c
void scsi_host_put(struct Scsi_Host *shost) **/
void scsi_host_put(struct Scsi_Host *shost)
/**
* scsi_partsize - parse partition table into cylinders, heads + sectors /**
* @buf: pointer to partition table * scsi_partsize - parse partition table into cylinders, heads + sectors
* @capacity: size of (total) disk in 512 byte sectors * @buf: pointer to partition table
* @cyls: outputs number of cylinders calculated via this pointer * @capacity: size of (total) disk in 512 byte sectors
* @hds: outputs number of heads calculated via this pointer * @cyls: outputs number of cylinders calculated via this pointer
* @secs: outputs number of sectors calculated via this pointer * @hds: outputs number of heads calculated via this pointer
* * @secs: outputs number of sectors calculated via this pointer
* Returns 0 on success, -1 on failure *
* * Returns 0 on success, -1 on failure
* Might block: no *
* * Might block: no
* Notes: Caller owns memory returned (free with kfree() ) *
* * Notes: Caller owns memory returned (free with kfree() )
* Defined in: drivers/scsi/scsicam.c *
**/ * Defined in: drivers/scsi/scsicam.c
int scsi_partsize(unsigned char *buf, unsigned long capacity, **/
unsigned int *cyls, unsigned int *hds, unsigned int *secs) int scsi_partsize(unsigned char *buf, unsigned long capacity,
unsigned int *cyls, unsigned int *hds, unsigned int *secs)
/**
* scsi_register - create and register a scsi host adapter instance. /**
* @sht: pointer to scsi host template * scsi_register - create and register a scsi host adapter instance.
* @privsize: extra bytes to allocate in hostdata array (which is the * @sht: pointer to scsi host template
* last member of the returned Scsi_Host instance) * @privsize: extra bytes to allocate in hostdata array (which is the
* * last member of the returned Scsi_Host instance)
* Returns pointer to new Scsi_Host instance or NULL on failure *
* * Returns pointer to new Scsi_Host instance or NULL on failure
* Might block: yes *
* * Might block: yes
* Notes: When this call returns to the LLD, the SCSI bus scan on *
* this host has _not_ yet been done. * Notes: When this call returns to the LLD, the SCSI bus scan on
* The hostdata array (by default zero length) is a per host scratch * this host has _not_ yet been done.
* area for the LLD. * The hostdata array (by default zero length) is a per host scratch
* * area for the LLD.
* Defined in: drivers/scsi/hosts.c . *
**/ * Defined in: drivers/scsi/hosts.c .
struct Scsi_Host * scsi_register(struct scsi_host_template * sht, **/
int privsize) struct Scsi_Host * scsi_register(struct scsi_host_template * sht,
int privsize)
/**
* scsi_remove_device - detach and remove a SCSI device /**
* @sdev: a pointer to a scsi device instance * scsi_remove_device - detach and remove a SCSI device
* * @sdev: a pointer to a scsi device instance
* Returns value: 0 on success, -EINVAL if device not attached *
* * Returns value: 0 on success, -EINVAL if device not attached
* Might block: yes *
* * Might block: yes
* Notes: If an LLD becomes aware that a scsi device (lu) has *
* been removed but its host is still present then it can request * Notes: If an LLD becomes aware that a scsi device (lu) has
* the removal of that scsi device. If successful this call will * been removed but its host is still present then it can request
* lead to the slave_destroy() callback being invoked. sdev is an * the removal of that scsi device. If successful this call will
* invalid pointer after this call. * lead to the slave_destroy() callback being invoked. sdev is an
* * invalid pointer after this call.
* Defined in: drivers/scsi/scsi_sysfs.c . *
**/ * Defined in: drivers/scsi/scsi_sysfs.c .
int scsi_remove_device(struct scsi_device *sdev) **/
int scsi_remove_device(struct scsi_device *sdev)
/**
* scsi_remove_host - detach and remove all SCSI devices owned by host /**
* @shost: a pointer to a scsi host instance * scsi_remove_host - detach and remove all SCSI devices owned by host
* * @shost: a pointer to a scsi host instance
* Returns value: 0 on success, 1 on failure (e.g. LLD busy ??) *
* * Returns value: 0 on success, 1 on failure (e.g. LLD busy ??)
* Might block: yes *
* * Might block: yes
* Notes: Should only be invoked if the "hotplug initialization *
* model" is being used. It should be called _prior_ to * Notes: Should only be invoked if the "hotplug initialization
* scsi_unregister(). * model" is being used. It should be called _prior_ to
* * scsi_unregister().
* Defined in: drivers/scsi/hosts.c . *
**/ * Defined in: drivers/scsi/hosts.c .
int scsi_remove_host(struct Scsi_Host *shost) **/
int scsi_remove_host(struct Scsi_Host *shost)
/**
* scsi_report_bus_reset - report scsi _bus_ reset observed /**
* @shost: a pointer to a scsi host involved * scsi_report_bus_reset - report scsi _bus_ reset observed
* @channel: channel (within) host on which scsi bus reset occurred * @shost: a pointer to a scsi host involved
* * @channel: channel (within) host on which scsi bus reset occurred
* Returns nothing *
* * Returns nothing
* Might block: no *
* * Might block: no
* Notes: This only needs to be called if the reset is one which *
* originates from an unknown location. Resets originated by the * Notes: This only needs to be called if the reset is one which
* mid level itself don't need to call this, but there should be * originates from an unknown location. Resets originated by the
* no harm. The main purpose of this is to make sure that a * mid level itself don't need to call this, but there should be
* CHECK_CONDITION is properly treated. * no harm. The main purpose of this is to make sure that a
* * CHECK_CONDITION is properly treated.
* Defined in: drivers/scsi/scsi_error.c . *
**/ * Defined in: drivers/scsi/scsi_error.c .
void scsi_report_bus_reset(struct Scsi_Host * shost, int channel) **/
void scsi_report_bus_reset(struct Scsi_Host * shost, int channel)
/**
* scsi_scan_host - scan SCSI bus /**
* @shost: a pointer to a scsi host instance * scsi_scan_host - scan SCSI bus
* * @shost: a pointer to a scsi host instance
* Might block: yes *
* * Might block: yes
* Notes: Should be called after scsi_add_host() *
* * Notes: Should be called after scsi_add_host()
* Defined in: drivers/scsi/scsi_scan.c *
**/ * Defined in: drivers/scsi/scsi_scan.c
void scsi_scan_host(struct Scsi_Host *shost) **/
void scsi_scan_host(struct Scsi_Host *shost)
/**
* scsi_track_queue_full - track successive QUEUE_FULL events on given /**
* device to determine if and when there is a need * scsi_track_queue_full - track successive QUEUE_FULL events on given
* to adjust the queue depth on the device. * device to determine if and when there is a need
* @sdev: pointer to SCSI device instance * to adjust the queue depth on the device.
* @depth: Current number of outstanding SCSI commands on this device, * @sdev: pointer to SCSI device instance
* not counting the one returned as QUEUE_FULL. * @depth: Current number of outstanding SCSI commands on this device,
* * not counting the one returned as QUEUE_FULL.
* Returns 0 - no change needed *
* >0 - adjust queue depth to this new depth * Returns 0 - no change needed
* -1 - drop back to untagged operation using host->cmd_per_lun * >0 - adjust queue depth to this new depth
* as the untagged command depth * -1 - drop back to untagged operation using host->cmd_per_lun
* * as the untagged command depth
* Might block: no *
* * Might block: no
* Notes: LLDs may call this at any time and we will do "The Right *
* Thing"; interrupt context safe. * Notes: LLDs may call this at any time and we will do "The Right
* * Thing"; interrupt context safe.
* Defined in: drivers/scsi/scsi.c . *
**/ * Defined in: drivers/scsi/scsi.c .
int scsi_track_queue_full(struct scsi_device *sdev, int depth) **/
int scsi_track_queue_full(struct scsi_device *sdev, int depth)
/**
* scsi_unblock_requests - allow further commands to be queued to given host /**
* * scsi_unblock_requests - allow further commands to be queued to given host
* @shost: pointer to host to unblock commands on *
* * @shost: pointer to host to unblock commands on
* Returns nothing *
* * Returns nothing
* Might block: no *
* * Might block: no
* Defined in: drivers/scsi/scsi_lib.c . *
**/ * Defined in: drivers/scsi/scsi_lib.c .
void scsi_unblock_requests(struct Scsi_Host * shost) **/
void scsi_unblock_requests(struct Scsi_Host * shost)
/**
* scsi_unregister - unregister and free memory used by host instance /**
* @shp: pointer to scsi host instance to unregister. * scsi_unregister - unregister and free memory used by host instance
* * @shp: pointer to scsi host instance to unregister.
* Returns nothing *
* * Returns nothing
* Might block: no *
* * Might block: no
* Notes: Should not be invoked if the "hotplug initialization *
* model" is being used. Called internally by exit_this_scsi_driver() * Notes: Should not be invoked if the "hotplug initialization
* in the "passive initialization model". Hence a LLD has no need to * model" is being used. Called internally by exit_this_scsi_driver()
* call this function directly. * in the "passive initialization model". Hence a LLD has no need to
* * call this function directly.
* Defined in: drivers/scsi/hosts.c . *
**/ * Defined in: drivers/scsi/hosts.c .
void scsi_unregister(struct Scsi_Host * shp) **/
void scsi_unregister(struct Scsi_Host * shp)
...@@ -645,9 +654,11 @@ Interface functions are supplied (defined) by LLDs and their function ...@@ -645,9 +654,11 @@ Interface functions are supplied (defined) by LLDs and their function
pointers are placed in an instance of struct scsi_host_template which pointers are placed in an instance of struct scsi_host_template which
is passed to scsi_host_alloc() [or scsi_register() / init_this_scsi_driver()]. is passed to scsi_host_alloc() [or scsi_register() / init_this_scsi_driver()].
Some are mandatory. Interface functions should be declared static. The Some are mandatory. Interface functions should be declared static. The
accepted convention is that driver "xyz" will declare its slave_configure() accepted convention is that driver "xyz" will declare its slave_configure()
function as: function as::
static int xyz_slave_configure(struct scsi_device * sdev); static int xyz_slave_configure(struct scsi_device * sdev);
and so forth for all interface functions listed below. and so forth for all interface functions listed below.
A pointer to this function should be placed in the 'slave_configure' member A pointer to this function should be placed in the 'slave_configure' member
...@@ -662,388 +673,389 @@ In some cases more detail is given in scsi_host.h than below. ...@@ -662,388 +673,389 @@ In some cases more detail is given in scsi_host.h than below.
The interface functions are listed below in alphabetical order. The interface functions are listed below in alphabetical order.
Summary: Summary:
bios_param - fetch head, sector, cylinder info for a disk
eh_timed_out - notify the host that a command timer expired - bios_param - fetch head, sector, cylinder info for a disk
eh_abort_handler - abort given command - eh_timed_out - notify the host that a command timer expired
eh_bus_reset_handler - issue SCSI bus reset - eh_abort_handler - abort given command
eh_device_reset_handler - issue SCSI device reset - eh_bus_reset_handler - issue SCSI bus reset
eh_host_reset_handler - reset host (host bus adapter) - eh_device_reset_handler - issue SCSI device reset
info - supply information about given host - eh_host_reset_handler - reset host (host bus adapter)
ioctl - driver can respond to ioctls - info - supply information about given host
proc_info - supports /proc/scsi/{driver_name}/{host_no} - ioctl - driver can respond to ioctls
queuecommand - queue scsi command, invoke 'done' on completion - proc_info - supports /proc/scsi/{driver_name}/{host_no}
slave_alloc - prior to any commands being sent to a new device - queuecommand - queue scsi command, invoke 'done' on completion
slave_configure - driver fine tuning for given device after attach - slave_alloc - prior to any commands being sent to a new device
slave_destroy - given device is about to be shut down - slave_configure - driver fine tuning for given device after attach
- slave_destroy - given device is about to be shut down
Details:
Details::
/**
* bios_param - fetch head, sector, cylinder info for a disk /**
* @sdev: pointer to scsi device context (defined in * bios_param - fetch head, sector, cylinder info for a disk
* include/scsi/scsi_device.h) * @sdev: pointer to scsi device context (defined in
* @bdev: pointer to block device context (defined in fs.h) * include/scsi/scsi_device.h)
* @capacity: device size (in 512 byte sectors) * @bdev: pointer to block device context (defined in fs.h)
* @params: three element array to place output: * @capacity: device size (in 512 byte sectors)
* params[0] number of heads (max 255) * @params: three element array to place output:
* params[1] number of sectors (max 63) * params[0] number of heads (max 255)
* params[2] number of cylinders * params[1] number of sectors (max 63)
* * params[2] number of cylinders
* Return value is ignored *
* * Return value is ignored
* Locks: none *
* * Locks: none
* Calling context: process (sd) *
* * Calling context: process (sd)
* Notes: an arbitrary geometry (based on READ CAPACITY) is used *
* if this function is not provided. The params array is * Notes: an arbitrary geometry (based on READ CAPACITY) is used
* pre-initialized with made up values just in case this function * if this function is not provided. The params array is
* doesn't output anything. * pre-initialized with made up values just in case this function
* * doesn't output anything.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
int bios_param(struct scsi_device * sdev, struct block_device *bdev, **/
sector_t capacity, int params[3]) int bios_param(struct scsi_device * sdev, struct block_device *bdev,
sector_t capacity, int params[3])
/**
* eh_timed_out - The timer for the command has just fired /**
* @scp: identifies command timing out * eh_timed_out - The timer for the command has just fired
* * @scp: identifies command timing out
* Returns: *
* * Returns:
* EH_HANDLED: I fixed the error, please complete the command *
* EH_RESET_TIMER: I need more time, reset the timer and * EH_HANDLED: I fixed the error, please complete the command
* begin counting again * EH_RESET_TIMER: I need more time, reset the timer and
* EH_NOT_HANDLED Begin normal error recovery * begin counting again
* * EH_NOT_HANDLED Begin normal error recovery
* *
* Locks: None held *
* * Locks: None held
* Calling context: interrupt *
* * Calling context: interrupt
* Notes: This is to give the LLD an opportunity to do local recovery. *
* This recovery is limited to determining if the outstanding command * Notes: This is to give the LLD an opportunity to do local recovery.
* will ever complete. You may not abort and restart the command from * This recovery is limited to determining if the outstanding command
* this callback. * will ever complete. You may not abort and restart the command from
* * this callback.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
int eh_timed_out(struct scsi_cmnd * scp) **/
int eh_timed_out(struct scsi_cmnd * scp)
/**
* eh_abort_handler - abort command associated with scp /**
* @scp: identifies command to be aborted * eh_abort_handler - abort command associated with scp
* * @scp: identifies command to be aborted
* Returns SUCCESS if command aborted else FAILED *
* * Returns SUCCESS if command aborted else FAILED
* Locks: None held *
* * Locks: None held
* Calling context: kernel thread *
* * Calling context: kernel thread
* Notes: If 'no_async_abort' is defined this callback *
* will be invoked from scsi_eh thread. No other commands * Notes: If 'no_async_abort' is defined this callback
* will then be queued on current host during eh. * will be invoked from scsi_eh thread. No other commands
* Otherwise it will be called whenever scsi_times_out() * will then be queued on current host during eh.
* is called due to a command timeout. * Otherwise it will be called whenever scsi_times_out()
* * is called due to a command timeout.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
int eh_abort_handler(struct scsi_cmnd * scp) **/
int eh_abort_handler(struct scsi_cmnd * scp)
/**
* eh_bus_reset_handler - issue SCSI bus reset /**
* @scp: SCSI bus that contains this device should be reset * eh_bus_reset_handler - issue SCSI bus reset
* * @scp: SCSI bus that contains this device should be reset
* Returns SUCCESS if command aborted else FAILED *
* * Returns SUCCESS if command aborted else FAILED
* Locks: None held *
* * Locks: None held
* Calling context: kernel thread *
* * Calling context: kernel thread
* Notes: Invoked from scsi_eh thread. No other commands will be *
* queued on current host during eh. * Notes: Invoked from scsi_eh thread. No other commands will be
* * queued on current host during eh.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
int eh_bus_reset_handler(struct scsi_cmnd * scp) **/
int eh_bus_reset_handler(struct scsi_cmnd * scp)
/**
* eh_device_reset_handler - issue SCSI device reset /**
* @scp: identifies SCSI device to be reset * eh_device_reset_handler - issue SCSI device reset
* * @scp: identifies SCSI device to be reset
* Returns SUCCESS if command aborted else FAILED *
* * Returns SUCCESS if command aborted else FAILED
* Locks: None held *
* * Locks: None held
* Calling context: kernel thread *
* * Calling context: kernel thread
* Notes: Invoked from scsi_eh thread. No other commands will be *
* queued on current host during eh. * Notes: Invoked from scsi_eh thread. No other commands will be
* * queued on current host during eh.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
int eh_device_reset_handler(struct scsi_cmnd * scp) **/
int eh_device_reset_handler(struct scsi_cmnd * scp)
/**
* eh_host_reset_handler - reset host (host bus adapter) /**
* @scp: SCSI host that contains this device should be reset * eh_host_reset_handler - reset host (host bus adapter)
* * @scp: SCSI host that contains this device should be reset
* Returns SUCCESS if command aborted else FAILED *
* * Returns SUCCESS if command aborted else FAILED
* Locks: None held *
* * Locks: None held
* Calling context: kernel thread *
* * Calling context: kernel thread
* Notes: Invoked from scsi_eh thread. No other commands will be *
* queued on current host during eh. * Notes: Invoked from scsi_eh thread. No other commands will be
* With the default eh_strategy in place, if none of the _abort_, * queued on current host during eh.
* _device_reset_, _bus_reset_ or this eh handler function are * With the default eh_strategy in place, if none of the _abort_,
* defined (or they all return FAILED) then the device in question * _device_reset_, _bus_reset_ or this eh handler function are
* will be set offline whenever eh is invoked. * defined (or they all return FAILED) then the device in question
* * will be set offline whenever eh is invoked.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
int eh_host_reset_handler(struct scsi_cmnd * scp) **/
int eh_host_reset_handler(struct scsi_cmnd * scp)
/**
* info - supply information about given host: driver name plus data /**
* to distinguish given host * info - supply information about given host: driver name plus data
* @shp: host to supply information about * to distinguish given host
* * @shp: host to supply information about
* Return ASCII null terminated string. [This driver is assumed to *
* manage the memory pointed to and maintain it, typically for the * Return ASCII null terminated string. [This driver is assumed to
* lifetime of this host.] * manage the memory pointed to and maintain it, typically for the
* * lifetime of this host.]
* Locks: none *
* * Locks: none
* Calling context: process *
* * Calling context: process
* Notes: Often supplies PCI or ISA information such as IO addresses *
* and interrupt numbers. If not supplied struct Scsi_Host::name used * Notes: Often supplies PCI or ISA information such as IO addresses
* instead. It is assumed the returned information fits on one line * and interrupt numbers. If not supplied struct Scsi_Host::name used
* (i.e. does not included embedded newlines). * instead. It is assumed the returned information fits on one line
* The SCSI_IOCTL_PROBE_HOST ioctl yields the string returned by this * (i.e. does not included embedded newlines).
* function (or struct Scsi_Host::name if this function is not * The SCSI_IOCTL_PROBE_HOST ioctl yields the string returned by this
* available). * function (or struct Scsi_Host::name if this function is not
* In a similar manner, init_this_scsi_driver() outputs to the console * available).
* each host's "info" (or name) for the driver it is registering. * In a similar manner, init_this_scsi_driver() outputs to the console
* Also if proc_info() is not supplied, the output of this function * each host's "info" (or name) for the driver it is registering.
* is used instead. * Also if proc_info() is not supplied, the output of this function
* * is used instead.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
const char * info(struct Scsi_Host * shp) **/
const char * info(struct Scsi_Host * shp)
/**
* ioctl - driver can respond to ioctls /**
* @sdp: device that ioctl was issued for * ioctl - driver can respond to ioctls
* @cmd: ioctl number * @sdp: device that ioctl was issued for
* @arg: pointer to read or write data from. Since it points to * @cmd: ioctl number
* user space, should use appropriate kernel functions * @arg: pointer to read or write data from. Since it points to
* (e.g. copy_from_user() ). In the Unix style this argument * user space, should use appropriate kernel functions
* can also be viewed as an unsigned long. * (e.g. copy_from_user() ). In the Unix style this argument
* * can also be viewed as an unsigned long.
* Returns negative "errno" value when there is a problem. 0 or a *
* positive value indicates success and is returned to the user space. * Returns negative "errno" value when there is a problem. 0 or a
* * positive value indicates success and is returned to the user space.
* Locks: none *
* * Locks: none
* Calling context: process *
* * Calling context: process
* Notes: The SCSI subsystem uses a "trickle down" ioctl model. *
* The user issues an ioctl() against an upper level driver * Notes: The SCSI subsystem uses a "trickle down" ioctl model.
* (e.g. /dev/sdc) and if the upper level driver doesn't recognize * The user issues an ioctl() against an upper level driver
* the 'cmd' then it is passed to the SCSI mid level. If the SCSI * (e.g. /dev/sdc) and if the upper level driver doesn't recognize
* mid level does not recognize it, then the LLD that controls * the 'cmd' then it is passed to the SCSI mid level. If the SCSI
* the device receives the ioctl. According to recent Unix standards * mid level does not recognize it, then the LLD that controls
* unsupported ioctl() 'cmd' numbers should return -ENOTTY. * the device receives the ioctl. According to recent Unix standards
* * unsupported ioctl() 'cmd' numbers should return -ENOTTY.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
int ioctl(struct scsi_device *sdp, int cmd, void *arg) **/
int ioctl(struct scsi_device *sdp, int cmd, void *arg)
/**
* proc_info - supports /proc/scsi/{driver_name}/{host_no} /**
* @buffer: anchor point to output to (0==writeto1_read0) or fetch from * proc_info - supports /proc/scsi/{driver_name}/{host_no}
* (1==writeto1_read0). * @buffer: anchor point to output to (0==writeto1_read0) or fetch from
* @start: where "interesting" data is written to. Ignored when * (1==writeto1_read0).
* 1==writeto1_read0. * @start: where "interesting" data is written to. Ignored when
* @offset: offset within buffer 0==writeto1_read0 is actually * 1==writeto1_read0.
* interested in. Ignored when 1==writeto1_read0 . * @offset: offset within buffer 0==writeto1_read0 is actually
* @length: maximum (or actual) extent of buffer * interested in. Ignored when 1==writeto1_read0 .
* @host_no: host number of interest (struct Scsi_Host::host_no) * @length: maximum (or actual) extent of buffer
* @writeto1_read0: 1 -> data coming from user space towards driver * @host_no: host number of interest (struct Scsi_Host::host_no)
* (e.g. "echo some_string > /proc/scsi/xyz/2") * @writeto1_read0: 1 -> data coming from user space towards driver
* 0 -> user what data from this driver * (e.g. "echo some_string > /proc/scsi/xyz/2")
* (e.g. "cat /proc/scsi/xyz/2") * 0 -> user what data from this driver
* * (e.g. "cat /proc/scsi/xyz/2")
* Returns length when 1==writeto1_read0. Otherwise number of chars *
* output to buffer past offset. * Returns length when 1==writeto1_read0. Otherwise number of chars
* * output to buffer past offset.
* Locks: none held *
* * Locks: none held
* Calling context: process *
* * Calling context: process
* Notes: Driven from scsi_proc.c which interfaces to proc_fs. proc_fs *
* support can now be configured out of the scsi subsystem. * Notes: Driven from scsi_proc.c which interfaces to proc_fs. proc_fs
* * support can now be configured out of the scsi subsystem.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
int proc_info(char * buffer, char ** start, off_t offset, **/
int length, int host_no, int writeto1_read0) int proc_info(char * buffer, char ** start, off_t offset,
int length, int host_no, int writeto1_read0)
/**
* queuecommand - queue scsi command, invoke scp->scsi_done on completion /**
* @shost: pointer to the scsi host object * queuecommand - queue scsi command, invoke scp->scsi_done on completion
* @scp: pointer to scsi command object * @shost: pointer to the scsi host object
* * @scp: pointer to scsi command object
* Returns 0 on success. *
* * Returns 0 on success.
* If there's a failure, return either: *
* * If there's a failure, return either:
* SCSI_MLQUEUE_DEVICE_BUSY if the device queue is full, or *
* SCSI_MLQUEUE_HOST_BUSY if the entire host queue is full * SCSI_MLQUEUE_DEVICE_BUSY if the device queue is full, or
* * SCSI_MLQUEUE_HOST_BUSY if the entire host queue is full
* On both of these returns, the mid-layer will requeue the I/O *
* * On both of these returns, the mid-layer will requeue the I/O
* - if the return is SCSI_MLQUEUE_DEVICE_BUSY, only that particular *
* device will be paused, and it will be unpaused when a command to * - if the return is SCSI_MLQUEUE_DEVICE_BUSY, only that particular
* the device returns (or after a brief delay if there are no more * device will be paused, and it will be unpaused when a command to
* outstanding commands to it). Commands to other devices continue * the device returns (or after a brief delay if there are no more
* to be processed normally. * outstanding commands to it). Commands to other devices continue
* * to be processed normally.
* - if the return is SCSI_MLQUEUE_HOST_BUSY, all I/O to the host *
* is paused and will be unpaused when any command returns from * - if the return is SCSI_MLQUEUE_HOST_BUSY, all I/O to the host
* the host (or after a brief delay if there are no outstanding * is paused and will be unpaused when any command returns from
* commands to the host). * the host (or after a brief delay if there are no outstanding
* * commands to the host).
* For compatibility with earlier versions of queuecommand, any *
* other return value is treated the same as * For compatibility with earlier versions of queuecommand, any
* SCSI_MLQUEUE_HOST_BUSY. * other return value is treated the same as
* * SCSI_MLQUEUE_HOST_BUSY.
* Other types of errors that are detected immediately may be *
* flagged by setting scp->result to an appropriate value, * Other types of errors that are detected immediately may be
* invoking the scp->scsi_done callback, and then returning 0 * flagged by setting scp->result to an appropriate value,
* from this function. If the command is not performed * invoking the scp->scsi_done callback, and then returning 0
* immediately (and the LLD is starting (or will start) the given * from this function. If the command is not performed
* command) then this function should place 0 in scp->result and * immediately (and the LLD is starting (or will start) the given
* return 0. * command) then this function should place 0 in scp->result and
* * return 0.
* Command ownership. If the driver returns zero, it owns the *
* command and must take responsibility for ensuring the * Command ownership. If the driver returns zero, it owns the
* scp->scsi_done callback is executed. Note: the driver may * command and must take responsibility for ensuring the
* call scp->scsi_done before returning zero, but after it has * scp->scsi_done callback is executed. Note: the driver may
* called scp->scsi_done, it may not return any value other than * call scp->scsi_done before returning zero, but after it has
* zero. If the driver makes a non-zero return, it must not * called scp->scsi_done, it may not return any value other than
* execute the command's scsi_done callback at any time. * zero. If the driver makes a non-zero return, it must not
* * execute the command's scsi_done callback at any time.
* Locks: up to and including 2.6.36, struct Scsi_Host::host_lock *
* held on entry (with "irqsave") and is expected to be * Locks: up to and including 2.6.36, struct Scsi_Host::host_lock
* held on return. From 2.6.37 onwards, queuecommand is * held on entry (with "irqsave") and is expected to be
* called without any locks held. * held on return. From 2.6.37 onwards, queuecommand is
* * called without any locks held.
* Calling context: in interrupt (soft irq) or process context *
* * Calling context: in interrupt (soft irq) or process context
* Notes: This function should be relatively fast. Normally it *
* will not wait for IO to complete. Hence the scp->scsi_done * Notes: This function should be relatively fast. Normally it
* callback is invoked (often directly from an interrupt service * will not wait for IO to complete. Hence the scp->scsi_done
* routine) some time after this function has returned. In some * callback is invoked (often directly from an interrupt service
* cases (e.g. pseudo adapter drivers that manufacture the * routine) some time after this function has returned. In some
* response to a SCSI INQUIRY) the scp->scsi_done callback may be * cases (e.g. pseudo adapter drivers that manufacture the
* invoked before this function returns. If the scp->scsi_done * response to a SCSI INQUIRY) the scp->scsi_done callback may be
* callback is not invoked within a certain period the SCSI mid * invoked before this function returns. If the scp->scsi_done
* level will commence error processing. If a status of CHECK * callback is not invoked within a certain period the SCSI mid
* CONDITION is placed in "result" when the scp->scsi_done * level will commence error processing. If a status of CHECK
* callback is invoked, then the LLD driver should perform * CONDITION is placed in "result" when the scp->scsi_done
* autosense and fill in the struct scsi_cmnd::sense_buffer * callback is invoked, then the LLD driver should perform
* array. The scsi_cmnd::sense_buffer array is zeroed prior to * autosense and fill in the struct scsi_cmnd::sense_buffer
* the mid level queuing a command to an LLD. * array. The scsi_cmnd::sense_buffer array is zeroed prior to
* * the mid level queuing a command to an LLD.
* Defined in: LLD *
**/ * Defined in: LLD
int queuecommand(struct Scsi_Host *shost, struct scsi_cmnd * scp) **/
int queuecommand(struct Scsi_Host *shost, struct scsi_cmnd * scp)
/**
* slave_alloc - prior to any commands being sent to a new device /**
* (i.e. just prior to scan) this call is made * slave_alloc - prior to any commands being sent to a new device
* @sdp: pointer to new device (about to be scanned) * (i.e. just prior to scan) this call is made
* * @sdp: pointer to new device (about to be scanned)
* Returns 0 if ok. Any other return is assumed to be an error and *
* the device is ignored. * Returns 0 if ok. Any other return is assumed to be an error and
* * the device is ignored.
* Locks: none *
* * Locks: none
* Calling context: process *
* * Calling context: process
* Notes: Allows the driver to allocate any resources for a device *
* prior to its initial scan. The corresponding scsi device may not * Notes: Allows the driver to allocate any resources for a device
* exist but the mid level is just about to scan for it (i.e. send * prior to its initial scan. The corresponding scsi device may not
* and INQUIRY command plus ...). If a device is found then * exist but the mid level is just about to scan for it (i.e. send
* slave_configure() will be called while if a device is not found * and INQUIRY command plus ...). If a device is found then
* slave_destroy() is called. * slave_configure() will be called while if a device is not found
* For more details see the include/scsi/scsi_host.h file. * slave_destroy() is called.
* * For more details see the include/scsi/scsi_host.h file.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
int slave_alloc(struct scsi_device *sdp) **/
int slave_alloc(struct scsi_device *sdp)
/**
* slave_configure - driver fine tuning for given device just after it /**
* has been first scanned (i.e. it responded to an * slave_configure - driver fine tuning for given device just after it
* INQUIRY) * has been first scanned (i.e. it responded to an
* @sdp: device that has just been attached * INQUIRY)
* * @sdp: device that has just been attached
* Returns 0 if ok. Any other return is assumed to be an error and *
* the device is taken offline. [offline devices will _not_ have * Returns 0 if ok. Any other return is assumed to be an error and
* slave_destroy() called on them so clean up resources.] * the device is taken offline. [offline devices will _not_ have
* * slave_destroy() called on them so clean up resources.]
* Locks: none *
* * Locks: none
* Calling context: process *
* * Calling context: process
* Notes: Allows the driver to inspect the response to the initial *
* INQUIRY done by the scanning code and take appropriate action. * Notes: Allows the driver to inspect the response to the initial
* For more details see the include/scsi/scsi_host.h file. * INQUIRY done by the scanning code and take appropriate action.
* * For more details see the include/scsi/scsi_host.h file.
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
int slave_configure(struct scsi_device *sdp) **/
int slave_configure(struct scsi_device *sdp)
/**
* slave_destroy - given device is about to be shut down. All /**
* activity has ceased on this device. * slave_destroy - given device is about to be shut down. All
* @sdp: device that is about to be shut down * activity has ceased on this device.
* * @sdp: device that is about to be shut down
* Returns nothing *
* * Returns nothing
* Locks: none *
* * Locks: none
* Calling context: process *
* * Calling context: process
* Notes: Mid level structures for given device are still in place *
* but are about to be torn down. Any per device resources allocated * Notes: Mid level structures for given device are still in place
* by this driver for given device should be freed now. No further * but are about to be torn down. Any per device resources allocated
* commands will be sent for this sdp instance. [However the device * by this driver for given device should be freed now. No further
* could be re-attached in the future in which case a new instance * commands will be sent for this sdp instance. [However the device
* of struct scsi_device would be supplied by future slave_alloc() * could be re-attached in the future in which case a new instance
* and slave_configure() calls.] * of struct scsi_device would be supplied by future slave_alloc()
* * and slave_configure() calls.]
* Optionally defined in: LLD *
**/ * Optionally defined in: LLD
void slave_destroy(struct scsi_device *sdp) **/
void slave_destroy(struct scsi_device *sdp)
...@@ -1051,24 +1063,31 @@ Data Structures ...@@ -1051,24 +1063,31 @@ Data Structures
=============== ===============
struct scsi_host_template struct scsi_host_template
------------------------- -------------------------
There is one "struct scsi_host_template" instance per LLD ***. It is There is one "struct scsi_host_template" instance per LLD [#]_. It is
typically initialized as a file scope static in a driver's header file. That typically initialized as a file scope static in a driver's header file. That
way members that are not explicitly initialized will be set to 0 or NULL. way members that are not explicitly initialized will be set to 0 or NULL.
Member of interest: Member of interest:
name - name of driver (may contain spaces, please limit to
name
- name of driver (may contain spaces, please limit to
less than 80 characters) less than 80 characters)
proc_name - name used in "/proc/scsi/<proc_name>/<host_no>" and
proc_name
- name used in "/proc/scsi/<proc_name>/<host_no>" and
by sysfs in one of its "drivers" directories. Hence by sysfs in one of its "drivers" directories. Hence
"proc_name" should only contain characters acceptable "proc_name" should only contain characters acceptable
to a Unix file name. to a Unix file name.
(*queuecommand)() - primary callback that the mid level uses to inject
``(*queuecommand)()``
- primary callback that the mid level uses to inject
SCSI commands into an LLD. SCSI commands into an LLD.
The structure is defined and commented in include/scsi/scsi_host.h The structure is defined and commented in include/scsi/scsi_host.h
*** In extreme situations a single driver may have several instances .. [#] In extreme situations a single driver may have several instances
if it controls several different classes of hardware (e.g. an LLD if it controls several different classes of hardware (e.g. an LLD
that handles both ISA and PCI cards and has a separate instance of that handles both ISA and PCI cards and has a separate instance of
struct scsi_host_template for each class). struct scsi_host_template for each class).
struct Scsi_Host struct Scsi_Host
---------------- ----------------
...@@ -1078,42 +1097,58 @@ with "struct scsi_host_template". When a new struct Scsi_Host instance ...@@ -1078,42 +1097,58 @@ with "struct scsi_host_template". When a new struct Scsi_Host instance
is created (in scsi_host_alloc() in hosts.c) those common members are is created (in scsi_host_alloc() in hosts.c) those common members are
initialized from the driver's struct scsi_host_template instance. Members initialized from the driver's struct scsi_host_template instance. Members
of interest: of interest:
host_no - system wide unique number that is used for identifying
host_no
- system wide unique number that is used for identifying
this host. Issued in ascending order from 0. this host. Issued in ascending order from 0.
can_queue - must be greater than 0; do not send more than can_queue can_queue
- must be greater than 0; do not send more than can_queue
commands to the adapter. commands to the adapter.
this_id - scsi id of host (scsi initiator) or -1 if not known this_id
sg_tablesize - maximum scatter gather elements allowed by host. - scsi id of host (scsi initiator) or -1 if not known
sg_tablesize
- maximum scatter gather elements allowed by host.
Set this to SG_ALL or less to avoid chained SG lists. Set this to SG_ALL or less to avoid chained SG lists.
Must be at least 1. Must be at least 1.
max_sectors - maximum number of sectors (usually 512 bytes) allowed max_sectors
- maximum number of sectors (usually 512 bytes) allowed
in a single SCSI command. The default value of 0 leads in a single SCSI command. The default value of 0 leads
to a setting of SCSI_DEFAULT_MAX_SECTORS (defined in to a setting of SCSI_DEFAULT_MAX_SECTORS (defined in
scsi_host.h) which is currently set to 1024. So for a scsi_host.h) which is currently set to 1024. So for a
disk the maximum transfer size is 512 KB when max_sectors disk the maximum transfer size is 512 KB when max_sectors
is not defined. Note that this size may not be sufficient is not defined. Note that this size may not be sufficient
for disk firmware uploads. for disk firmware uploads.
cmd_per_lun - maximum number of commands that can be queued on devices cmd_per_lun
- maximum number of commands that can be queued on devices
controlled by the host. Overridden by LLD calls to controlled by the host. Overridden by LLD calls to
scsi_change_queue_depth(). scsi_change_queue_depth().
unchecked_isa_dma - 1=>only use bottom 16 MB of ram (ISA DMA addressing unchecked_isa_dma
- 1=>only use bottom 16 MB of ram (ISA DMA addressing
restriction), 0=>can use full 32 bit (or better) DMA restriction), 0=>can use full 32 bit (or better) DMA
address space address space
no_async_abort - 1=>Asynchronous aborts are not supported no_async_abort
0=>Timed-out commands will be aborted asynchronously - 1=>Asynchronous aborts are not supported
hostt - pointer to driver's struct scsi_host_template from which - 0=>Timed-out commands will be aborted asynchronously
hostt
- pointer to driver's struct scsi_host_template from which
this struct Scsi_Host instance was spawned this struct Scsi_Host instance was spawned
hostt->proc_name - name of LLD. This is the driver name that sysfs uses hostt->proc_name
transportt - pointer to driver's struct scsi_transport_template instance - name of LLD. This is the driver name that sysfs uses
transportt
- pointer to driver's struct scsi_transport_template instance
(if any). FC and SPI transports currently supported. (if any). FC and SPI transports currently supported.
sh_list - a double linked list of pointers to all struct Scsi_Host sh_list
- a double linked list of pointers to all struct Scsi_Host
instances (currently ordered by ascending host_no) instances (currently ordered by ascending host_no)
my_devices - a double linked list of pointers to struct scsi_device my_devices
- a double linked list of pointers to struct scsi_device
instances that belong to this host. instances that belong to this host.
hostdata[0] - area reserved for LLD at end of struct Scsi_Host. Size hostdata[0]
- area reserved for LLD at end of struct Scsi_Host. Size
is set by the second argument (named 'xtr_bytes') to is set by the second argument (named 'xtr_bytes') to
scsi_host_alloc() or scsi_register(). scsi_host_alloc() or scsi_register().
vendor_id - a unique value that identifies the vendor supplying vendor_id
- a unique value that identifies the vendor supplying
the LLD for the Scsi_Host. Used most often in validating the LLD for the Scsi_Host. Used most often in validating
vendor-specific message requests. Value consists of an vendor-specific message requests. Value consists of an
identifier type and a vendor-specific value. identifier type and a vendor-specific value.
...@@ -1136,26 +1171,35 @@ commands become queued against the LLD than are indicated by ...@@ -1136,26 +1171,35 @@ commands become queued against the LLD than are indicated by
scsi_change_queue_depth() (or struct Scsi_Host::cmd_per_lun). There will scsi_change_queue_depth() (or struct Scsi_Host::cmd_per_lun). There will
be at least one instance of struct scsi_cmnd available for each SCSI device. be at least one instance of struct scsi_cmnd available for each SCSI device.
Members of interest: Members of interest:
cmnd - array containing SCSI command
cmnd_len - length (in bytes) of SCSI command cmnd
sc_data_direction - direction of data transfer in data phase. See - array containing SCSI command
"enum dma_data_direction" in include/linux/dma-mapping.h cmnd_len
request_bufflen - number of data bytes to transfer (0 if no data phase) - length (in bytes) of SCSI command
use_sg - ==0 -> no scatter gather list, hence transfer data sc_data_direction
- direction of data transfer in data phase. See
"enum dma_data_direction" in include/linux/dma-mapping.h
request_bufflen
- number of data bytes to transfer (0 if no data phase)
use_sg
- ==0 -> no scatter gather list, hence transfer data
to/from request_buffer to/from request_buffer
- >0 -> scatter gather list (actually an array) in - >0 -> scatter gather list (actually an array) in
request_buffer with use_sg elements request_buffer with use_sg elements
request_buffer - either contains data buffer or scatter gather list request_buffer
- either contains data buffer or scatter gather list
depending on the setting of use_sg. Scatter gather depending on the setting of use_sg. Scatter gather
elements are defined by 'struct scatterlist' found elements are defined by 'struct scatterlist' found
in include/linux/scatterlist.h . in include/linux/scatterlist.h .
done - function pointer that should be invoked by LLD when the done
- function pointer that should be invoked by LLD when the
SCSI command is completed (successfully or otherwise). SCSI command is completed (successfully or otherwise).
Should only be called by an LLD if the LLD has accepted Should only be called by an LLD if the LLD has accepted
the command (i.e. queuecommand() returned or will return the command (i.e. queuecommand() returned or will return
0). The LLD may invoke 'done' prior to queuecommand() 0). The LLD may invoke 'done' prior to queuecommand()
finishing. finishing.
result - should be set by LLD prior to calling 'done'. A value result
- should be set by LLD prior to calling 'done'. A value
of 0 implies a successfully completed command (and all of 0 implies a successfully completed command (and all
data (if any) has been transferred to or from the SCSI data (if any) has been transferred to or from the SCSI
target device). 'result' is a 32 bit unsigned integer that target device). 'result' is a 32 bit unsigned integer that
...@@ -1163,7 +1207,8 @@ Members of interest: ...@@ -1163,7 +1207,8 @@ Members of interest:
in the LSB. See include/scsi/scsi.h status_byte(), in the LSB. See include/scsi/scsi.h status_byte(),
msg_byte(), host_byte() and driver_byte() macros and msg_byte(), host_byte() and driver_byte() macros and
related constants. related constants.
sense_buffer - an array (maximum size: SCSI_SENSE_BUFFERSIZE bytes) that sense_buffer
- an array (maximum size: SCSI_SENSE_BUFFERSIZE bytes) that
should be written when the SCSI status (LSB of 'result') should be written when the SCSI status (LSB of 'result')
is set to CHECK_CONDITION (2). When CHECK_CONDITION is is set to CHECK_CONDITION (2). When CHECK_CONDITION is
set, if the top nibble of sense_buffer[0] has the value 7 set, if the top nibble of sense_buffer[0] has the value 7
...@@ -1173,9 +1218,11 @@ Members of interest: ...@@ -1173,9 +1218,11 @@ Members of interest:
retrieve the sense buffer. The latter strategy is error retrieve the sense buffer. The latter strategy is error
prone in the presence of command queuing so the LLD should prone in the presence of command queuing so the LLD should
always "auto-sense". always "auto-sense".
device - pointer to scsi_device object that this command is device
- pointer to scsi_device object that this command is
associated with. associated with.
resid - an LLD should set this signed integer to the requested resid
- an LLD should set this signed integer to the requested
transfer length (i.e. 'request_bufflen') less the number transfer length (i.e. 'request_bufflen') less the number
of bytes that are actually transferred. 'resid' is of bytes that are actually transferred. 'resid' is
preset to 0 so an LLD can ignore it if it cannot detect preset to 0 so an LLD can ignore it if it cannot detect
...@@ -1183,7 +1230,8 @@ Members of interest: ...@@ -1183,7 +1230,8 @@ Members of interest:
should set 'resid' prior to invoking 'done'. The most should set 'resid' prior to invoking 'done'. The most
interesting case is data transfers from a SCSI target interesting case is data transfers from a SCSI target
device (e.g. READs) that underrun. device (e.g. READs) that underrun.
underflow - LLD should place (DID_ERROR << 16) in 'result' if underflow
- LLD should place (DID_ERROR << 16) in 'result' if
actual number of bytes transferred is less than this actual number of bytes transferred is less than this
figure. Not many LLDs implement this check and some that figure. Not many LLDs implement this check and some that
do just output an error message to the log rather than do just output an error message to the log rather than
...@@ -1196,10 +1244,13 @@ when such data transfers have sense keys of MEDIUM ERROR and HARDWARE ERROR ...@@ -1196,10 +1244,13 @@ when such data transfers have sense keys of MEDIUM ERROR and HARDWARE ERROR
(and possibly RECOVERED ERROR). In these cases if a LLD is in doubt how much (and possibly RECOVERED ERROR). In these cases if a LLD is in doubt how much
data has been received then the safest approach is to indicate no bytes have data has been received then the safest approach is to indicate no bytes have
been received. For example: to indicate that no valid data has been received been received. For example: to indicate that no valid data has been received
a LLD might use these helpers: a LLD might use these helpers::
scsi_set_resid(SCpnt, scsi_bufflen(SCpnt)); scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
where 'SCpnt' is a pointer to a scsi_cmnd object. To indicate only three 512 where 'SCpnt' is a pointer to a scsi_cmnd object. To indicate only three 512
bytes blocks has been received 'resid' could be set like this: bytes blocks has been received 'resid' could be set like this::
scsi_set_resid(SCpnt, scsi_bufflen(SCpnt) - (3 * 512)); scsi_set_resid(SCpnt, scsi_bufflen(SCpnt) - (3 * 512));
The scsi_cmnd structure is defined in include/scsi/scsi_cmnd.h The scsi_cmnd structure is defined in include/scsi/scsi_cmnd.h
...@@ -1207,8 +1258,8 @@ The scsi_cmnd structure is defined in include/scsi/scsi_cmnd.h ...@@ -1207,8 +1258,8 @@ The scsi_cmnd structure is defined in include/scsi/scsi_cmnd.h
Locks Locks
===== =====
Each struct Scsi_Host instance has a spin_lock called struct Each struct Scsi_Host instance has a spin_lock called struct
Scsi_Host::default_lock which is initialized in scsi_host_alloc() [found in Scsi_Host::default_lock which is initialized in scsi_host_alloc() [found in
hosts.c]. Within the same function the struct Scsi_Host::host_lock pointer hosts.c]. Within the same function the struct Scsi_Host::host_lock pointer
is initialized to point at default_lock. Thereafter lock and unlock is initialized to point at default_lock. Thereafter lock and unlock
operations performed by the mid level use the struct Scsi_Host::host_lock operations performed by the mid level use the struct Scsi_Host::host_lock
...@@ -1222,13 +1273,14 @@ Autosense (or auto-sense) is defined in the SAM-2 document as "the ...@@ -1222,13 +1273,14 @@ Autosense (or auto-sense) is defined in the SAM-2 document as "the
automatic return of sense data to the application client coincident automatic return of sense data to the application client coincident
with the completion of a SCSI command" when a status of CHECK CONDITION with the completion of a SCSI command" when a status of CHECK CONDITION
occurs. LLDs should perform autosense. This should be done when the LLD occurs. LLDs should perform autosense. This should be done when the LLD
detects a CHECK CONDITION status by either: detects a CHECK CONDITION status by either:
a) instructing the SCSI protocol (e.g. SCSI Parallel Interface (SPI)) a) instructing the SCSI protocol (e.g. SCSI Parallel Interface (SPI))
to perform an extra data in phase on such responses to perform an extra data in phase on such responses
b) or, the LLD issuing a REQUEST SENSE command itself b) or, the LLD issuing a REQUEST SENSE command itself
Either way, when a status of CHECK CONDITION is detected, the mid level Either way, when a status of CHECK CONDITION is detected, the mid level
decides whether the LLD has performed autosense by checking struct decides whether the LLD has performed autosense by checking struct
scsi_cmnd::sense_buffer[0] . If this byte has an upper nibble of 7 (or 0xf) scsi_cmnd::sense_buffer[0] . If this byte has an upper nibble of 7 (or 0xf)
then autosense is assumed to have taken place. If it has another value (and then autosense is assumed to have taken place. If it has another value (and
this byte is initialized to 0 before each command) then the mid level will this byte is initialized to 0 before each command) then the mid level will
...@@ -1242,7 +1294,7 @@ to perform autosense. ...@@ -1242,7 +1294,7 @@ to perform autosense.
Changes since lk 2.4 series Changes since lk 2.4 series
=========================== ===========================
io_request_lock has been replaced by several finer grained locks. The lock io_request_lock has been replaced by several finer grained locks. The lock
relevant to LLDs is struct Scsi_Host::host_lock and there is relevant to LLDs is struct Scsi_Host::host_lock and there is
one per SCSI host. one per SCSI host.
...@@ -1250,9 +1302,9 @@ The older error handling mechanism has been removed. This means the ...@@ -1250,9 +1302,9 @@ The older error handling mechanism has been removed. This means the
LLD interface functions abort() and reset() have been removed. LLD interface functions abort() and reset() have been removed.
The struct scsi_host_template::use_new_eh_code flag has been removed. The struct scsi_host_template::use_new_eh_code flag has been removed.
In the 2.4 series the SCSI subsystem configuration descriptions were In the 2.4 series the SCSI subsystem configuration descriptions were
aggregated with the configuration descriptions from all other Linux aggregated with the configuration descriptions from all other Linux
subsystems in the Documentation/Configure.help file. In the 2.6 series, subsystems in the Documentation/Configure.help file. In the 2.6 series,
the SCSI subsystem now has its own (much smaller) drivers/scsi/Kconfig the SCSI subsystem now has its own (much smaller) drivers/scsi/Kconfig
file that contains both configuration and help information. file that contains both configuration and help information.
...@@ -1265,16 +1317,18 @@ to support it. ...@@ -1265,16 +1317,18 @@ to support it.
Credits Credits
======= =======
The following people have contributed to this document: The following people have contributed to this document:
Mike Anderson <andmike at us dot ibm dot com>
James Bottomley <James dot Bottomley at hansenpartnership dot com> - Mike Anderson <andmike at us dot ibm dot com>
Patrick Mansfield <patmans at us dot ibm dot com> - James Bottomley <James dot Bottomley at hansenpartnership dot com>
Christoph Hellwig <hch at infradead dot org> - Patrick Mansfield <patmans at us dot ibm dot com>
Doug Ledford <dledford at redhat dot com> - Christoph Hellwig <hch at infradead dot org>
Andries Brouwer <Andries dot Brouwer at cwi dot nl> - Doug Ledford <dledford at redhat dot com>
Randy Dunlap <rdunlap at xenotime dot net> - Andries Brouwer <Andries dot Brouwer at cwi dot nl>
Alan Stern <stern at rowland dot harvard dot edu> - Randy Dunlap <rdunlap at xenotime dot net>
- Alan Stern <stern at rowland dot harvard dot edu>
Douglas Gilbert Douglas Gilbert
dgilbert at interlog dot com dgilbert at interlog dot com
21st September 2004 21st September 2004
...@@ -12,7 +12,7 @@ use Getopt::Long qw(:config no_auto_abbrev); ...@@ -12,7 +12,7 @@ use Getopt::Long qw(:config no_auto_abbrev);
# to mention a past documentation file, for example, to give credits for # to mention a past documentation file, for example, to give credits for
# the original work. # the original work.
my %false_positives = ( my %false_positives = (
"Documentation/scsi/scsi_mid_low_api.txt" => "Documentation/Configure.help", "Documentation/scsi/scsi_mid_low_api.rst" => "Documentation/Configure.help",
"drivers/vhost/vhost.c" => "Documentation/virtual/lguest/lguest.c", "drivers/vhost/vhost.c" => "Documentation/virtual/lguest/lguest.c",
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment