diff options
| author | James Bottomley <jejb@jet.(none)> | 2003-06-29 12:43:18 -0500 |
|---|---|---|
| committer | James Bottomley <jejb@jet.(none)> | 2003-06-29 12:43:18 -0500 |
| commit | e71fcd543765e3f06433c46304f043aa81526970 (patch) | |
| tree | 47b3464a2e874e1e61bb132e2135370c8a72f5a0 /Documentation | |
| parent | 947af82fbbc5aebdc1072f1e5571996ec86e7859 (diff) | |
| parent | fa8ecc35308a82c6fd4f01eaaf8da052f30486ef (diff) | |
Merge jet.(none):/home1/jejb/BK/scsi-misc-2.5
into jet.(none):/home1/jejb/BK/scsi-for-linus-2.5
Diffstat (limited to 'Documentation')
| -rw-r--r-- | Documentation/scsi/scsi_mid_low_api.txt | 820 |
1 files changed, 428 insertions, 392 deletions
diff --git a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt index 7b4de9233552..93b045fc16e0 100644 --- a/Documentation/scsi/scsi_mid_low_api.txt +++ b/Documentation/scsi/scsi_mid_low_api.txt @@ -22,24 +22,26 @@ has its own PCI device address. [The one-to-one correspondence between a SCSI host and a PCI device is common but not required (e.g. with ISA or MCA adapters).] -This version of the document roughly matches linux kernel version 2.5.68 . -This document can be found in the Linux kernel source Documentation/scsi -directory and is called scsi_mid_low_api.txt . A more recent copy may -be found at http://www.torque.net/scsi/scsi_mid_low_api.txt.gz . +The SCSI mid level isolates a LLD from other layers such as the SCSI +upper layer drivers and the block layer. + +This version of the document roughly matches linux kernel version 2.5.73 . Documentation ============= -There is a SCSI documentation directory within the kernel source tree. -That directory is typically /usr/src/linux/Documentation/scsi . Most -documents are in plain (i.e. ASCII) text. This file can be found in that -directory, named scsi_mid_low_api.txt . Many LLDs are documented there -(e.g. aic7xxx.txt). The SCSI mid-level is briefly described in scsi.txt -(with a url to a document 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 scsi-generic.txt (for the sg driver). - -Some documentation (or urls) for LLDs may be in the C source code or -in the same directory as the C source code. For example to find a url +There is a SCSI documentation directory within the kernel source tree, +typically /usr/src/linux/Documentation/scsi . Most documents are in plain +(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 +at http://www.torque.net/scsi/scsi_mid_low_api.txt.gz . +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 +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 +scsi-generic.txt (for the sg driver). + +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 about the USB mass storage driver see the /usr/src/linux/drivers/usb/storage directory. @@ -69,12 +71,12 @@ initialization code where there are now 2 models available. The older one, similar to what was found in the lk 2.4 series, is based on hosts that are detected at HBA driver load time. This will be referred to the "passive" initialization model. The newer model allows HBAs to be -hotplugged (and unplugged) while the driver is loaded and will 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 preferred as it can handle both traditional SCSI equipment that is -permanently connected as well as modern "SCSI" usb-storage devices -(e.g. digital cameras) that are hotplugged. Both initialization models -are discussed in the following sections. +permanently connected as well as modern "SCSI" devices (e.g. USB or +IEEE 1394 connected digital cameras) that are hotplugged. Both +initialization models are discussed in the following sections. A LLD interfaces to the SCSI subsystem several ways: a) directly invoking functions supplied by the mid level @@ -90,21 +92,27 @@ supplied functions" below. Those functions in group b) are listed in a section entitled "Interface functions" below. Their function pointers are placed in the members of -"struct SHT", an instance of which is passed to scsi_register() [or -scsi_register_host() in the passive initialization model]. Those interface -functions that are not mandatory and that the LLD does not wish to supply -should have NULL placed in the corresponding member of struct SHT. -[Defining an instance of struct SHT at file scope will cause NULL to be -placed in function pointer members not explicitly initialized.] +"struct scsi_host_template", an instance of which is passed to +scsi_host_alloc() ** . Those interface functions that the LLD does not +wish to supply should have NULL placed in the corresponding member of +struct scsi_host_template. Defining an instance of struct +scsi_host_template at file scope will cause NULL to be placed in function + pointer members not explicitly initialized. -Those instances in group c) are slowly being removed as they tend to be -"racy" especially in a hotplug environment. +Those usages in group c) should be handled with care, especially in a +"hotplug" environment. LLDs should be aware of the lifetime of instances +that are shared with the mid level and other layers. All functions defined within a LLD and all data defined at file scope should be static. For example the slave_alloc() function in a LLD called "xxx" could be defined as "static int xxx_slave_alloc(struct scsi_device * sdev) { /* code */ }" +** the scsi_host_alloc() function is a replacement for the rather vaguely +named scsi_register() function in most situations. The scsi_register() +and scsi_unregister() functions remain to support legacy LLDs that use +the passive initialization model. + Hotplug initialization model ============================ @@ -116,13 +124,6 @@ detected. After confirming that the new device is one that the LLD wants to control, the LLD will initialize the HBA and then register a new host with the SCSI mid level. -Hot unplugging a HBA that controls a disk which is processing SCSI -commands on a mounted file system is an ugly situation. Issues with -this scenario are still being worked through. The primary concern is -the stability of the kernel (specifically the block and SCSI subsystems) -since the effected disk can be "cleaned up" the next time it is seen. -In the sysfs model, a remove() callback indicates a HBA has disappeared. - During LLD initialization the driver should register itself with the appropriate IO bus on which it expects to find HBA(s) (e.g. the PCI bus). This can probably be done via sysfs. Any driver parameters (especially @@ -135,145 +136,198 @@ 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 scsi devices of which only the first 2 respond: -[HBA PROBE] + HBA PROBE: assume 2 SCSI devices found in scan LLD mid level LLD ---- --------- --- -scsi_register() --> +===-------------------=========--------------------===------ +scsi_host_alloc() --> scsi_add_host() --------+ | - slave_alloc() + slave_alloc() slave_configure() --> scsi_adjust_queue_depth() - | - slave_alloc() + | + slave_alloc() slave_configure() - | - slave_alloc() ** - slave_destroy() ** + | + slave_alloc() *** + slave_destroy() *** +------------------------------------------------------------ If the LLD wants to adjust the default queue settings, it can invoke scsi_adjust_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. +*** For scsi devices that the mid level tries to scan but do not + respond, a slave_alloc(), slave_destroy() pair is called. -Here is the corresponding sequence when a host (HBA) is being -removed: +When a HBA is being removed is could as part of an orderly shutdown +associated with the LLD module being unloaded (e.g. with the "rmmod" +command) or in response to a "hot unplug" indicated by sysfs()'s +remove() callback being invoked. In either case, the sequence is the +same: -[HBA REMOVE] + HBA REMOVE: assume 2 SCSI devices attached LLD mid level LLD ---- --------- --- +===----------------------=========-----------------===------ scsi_remove_host() ---------+ | slave_destroy() slave_destroy() - release() --> scsi_unregister() - -It is practical for a LLD to keep track of struct Scsi_Host instances -(a pointer is returned by scsi_register() ) and struct scsi_device -instances (a pointer is passed as the parameter to slave_alloc() and -slave_configure() ). Both classes of instances are "owned" by the -mid-level. struct scsi_device instances are freed after slave_destroy(). -struct Scsi_Host instances are freed within scsi_unregister(). - -TODO: -Descriptions, are the following correct? -[DEVICE hotplug] +scsi_host_put() +------------------------------------------------------------ + +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" +by the mid-level. struct Scsi_Host instances are freed from +scsi_host_put() when the reference count hits zero. + +Hot unplugging a HBA that controls a disk which is processing SCSI +commands on a mounted file system is an interesting situation. Reference +counting logic is being introduced into the mid level to cope with many +of the issues involved. See the section on reference counting below. + + +The hotplug concept may be extended to SCSI devices. Currently, when a +HBA is added, the scsi_add_host() function causes a scan for SCSI devices +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. +A LLD can use this sequence to make the mid level aware of a SCSI device: + + SCSI DEVICE hotplug LLD mid level LLD ---- --------- --- +===-------------------=========--------------------===------ scsi_add_device() ------+ | - slave_alloc() + slave_alloc() slave_configure() [--> scsi_adjust_queue_depth()] +------------------------------------------------------------ -[DEVICE unplug] +In a similar fashion, a LLD may become aware that a SCSI device has been +removed (unplugged) or the connection to it has been interrupted. Some +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 +probably cause that device to be set offline by the mid level. A LLD that +detects the removal of a SCSI device can instigate its removal from +upper layers with this sequence: + + SCSI DEVICE hot unplug LLD mid level LLD ---- --------- --- +===----------------------=========-----------------===------ scsi_set_device_offline() scsi_remove_device() -------+ | slave_destroy() +------------------------------------------------------------ +It may be useful for a LLD to keep track of struct scsi_device instances +(a pointer is passed as the parameter to slave_alloc() and +slave_configure() callbacks). Such instances are "owned" by the mid-level. +struct scsi_device instances are freed after slave_destroy(). Passive initialization model ============================ -LLD initialization (both built-in and module) and shutdown are "wired -up" by passing function pointers to the module_init() and module_exit() -macros respectively. In this model the function identified by "module_init" -must call scsi_register_host() and the function identified by "module_exit" -must call scsi_unregister_host(). -Most LLDs inherited from the lk 2.4 series include a file called -"scsi_module.c" [yes the ".c" is a little surprising] in their -source code. For that file to work a declaration like this is needed before -it is included: - static struct SHT driver_template = DRIVER_TEMPLATE; +These older LLDs include a file called "scsi_module.c" [yes the ".c" is a +little surprising] in their source code. For that file to work an +instance of struct scsi_host_template with the name "driver_template" +needs to be defined. Here is a typical code sequence used in this model: + static struct scsi_host_template driver_template = { + ... + }; #include "scsi_module.c" -In this case "DRIVER_TEMPLATE" is defined to be a structure initializer -that is placed in the driver header file by convention. It contains -pointers to supported interface functions and other values. +The scsi_module.c file contains two functions: + - init_this_scsi_driver() which is executed when the LLD is + initialized (i.e. boot time or module load time) + - exit_this_scsi_driver() which is executed when the LLD is shut + down (i.e. module unload time) +Note: since these functions are tagged with __init and __exit qualifiers +a LLD should not call them explicitly (since the kernel does that). Here is an example of an initialization sequence when two hosts are detected (so detect() returns 2) and the SCSI bus scan on each host finds 1 SCSI device (and a second device does not respond). LLD mid level LLD ---- --------- --- -scsi_register_host() -------+ +===----------------------=========-----------------===------ +init_this_scsi_driver() ----+ | detect() -----------------+ | | | scsi_register() | scsi_register() | - slave_alloc() + slave_alloc() slave_configure() --> scsi_adjust_queue_depth() - slave_alloc() ** - slave_destroy() ** + slave_alloc() *** + slave_destroy() *** | - slave_alloc() + slave_alloc() slave_configure() - slave_alloc() ** - slave_destroy() ** + slave_alloc() *** + slave_destroy() *** +------------------------------------------------------------ The mid level invokes scsi_adjust_queue_depth() with tagged queuing off and "cmd_per_lun" for that host as the queue length. These settings can be overridden by a slave_configure() supplied by the LLD. -** For scsi devices that the mid level tries to scan but do not - respond, a slave_alloc(), slave_destroy() pair is called. +*** For scsi devices that the mid level tries to scan but do not + respond, a slave_alloc(), slave_destroy() pair is called. Here is a LLD shutdown sequence: LLD mid level LLD ---- --------- --- -scsi_unregister_host() -----+ +===----------------------=========-----------------===------ +exit_this_scsi_driver() ----+ | slave_destroy() release() --> scsi_unregister() | slave_destroy() release() --> scsi_unregister() +------------------------------------------------------------ -slave_destroy() is optional. +A LLD need not define slave_destroy() (i.e. it is optional). The shortcoming of the "passive initialization model" is that host registration and de-registration are (typically) tied to LLD initialization and shutdown. Once the LLD is initialized then a new host that appears (e.g. via hotplugging) cannot easily be added without a redundant -driver shutdown and re-initialization. +driver shutdown and re-initialization. It may be possible to write a LLD +that uses both initialization models. + + +Reference Counting +================== +The Scsi_Host structure has had reference counting infrastructure added. +This effectively spreads the ownership of struct Scsi_Host instances +across the various SCSI layers which use them. Previously such instances +were exclusively owned by the mid level. LLDs would not usually need to +directly manipulate these reference counts but there may be some cases +where they do. + +There are 3 reference counting functions of interest associated with +struct Scsi_Host: + - scsi_host_alloc(): returns a pointer to new instance of struct + 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 + instance. If the reference count reaches 0 then the given instance + is freed + +^^ struct Scsi_Host actually has 2 reference counts which are manipulated +in parallel by these functions. Conventions =========== -First, Linus's thoughts on C coding can be found in the file -Documentation/CodingStyle . +First, Linus Torvald's thoughts on C coding style can be found in the +Documentation/CodingStyle file. Next, there is a movement to "outlaw" typedefs introducing synonyms for -struct tags. Both can be still found in the SCSI subsystem, for example: -"typedef struct SHT { ...} Scsi_Host_Template;" in hosts.h . In this -case "struct SHT" is preferred to "Scsi_Host_Template". [The poor naming -example was chosen with malevolent intent.] +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 +make their future removal easier, for example: +"typedef struct scsi_host_template Scsi_Host_Template;" Also, C99 enhancements are encouraged to the extent they are supported by the relevant gcc compilers. So "//" style comments are encouraged @@ -304,9 +358,11 @@ Summary: scsi_bios_ptable - return copy of block device's partition table scsi_block_requests - prevent further commands being queued to given host scsi_delete_timer - cancel timer on a SCSI command. + scsi_host_alloc - return a new scsi_host instance whose refcount==1 + scsi_host_get - increments Scsi_Host instance's refcount + scsi_host_put - decrements Scsi_Host instance's refcount (free if 0) scsi_partsize - parse partition table into cylinders, heads + sectors scsi_register - create and register a scsi host adapter instance. - scsi_register_host - register a low level host driver scsi_remove_device - detach and remove a SCSI device scsi_remove_host - detach and remove all SCSI devices owned by host scsi_report_bus_reset - report scsi _bus_ reset observed @@ -316,8 +372,8 @@ Summary: scsi_to_sbus_dma_dir - convert SCSI subsystem direction flag to SBUS scsi_track_queue_full - track successive QUEUE_FULL events scsi_unblock_requests - allow further commands to be queued to given host - scsi_unregister - unregister and free memory used by host instance - scsi_unregister_host - unregister a low level host adapter driver + scsi_unregister - [calls scsi_host_put()] + Details: @@ -329,17 +385,17 @@ Details: * @lun: logical unit number * * Returns pointer to new struct scsi_device instance or - * ERR_PTR(-ENODEV) (or some other bent pointer) if something is - * 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) * - * Notes: This call is usually performed internally during a scsi - * bus scan when a HBA is added (i.e. scsi_add_host()). So it - * should only be called if the HBA becomes aware of a new scsi - * device (lu) after scsi_add_host() has completed. If successful - * this call we lead to slave_alloc() and slave_configure() callbacks - * into the LLD. + * Notes: This call is usually performed internally during a scsi + * bus scan when a HBA is added (i.e. scsi_add_host()). So it + * should only be called if the HBA becomes aware of a new scsi + * device (lu) after scsi_add_host() has completed. If successful + * this call we 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, @@ -353,10 +409,10 @@ struct scsi_device * scsi_add_device(struct Scsi_Host *shost, * * Returns 0 on success, negative errno of failure (e.g. -ENOMEM) * - * Notes: Only required in "hotplug initialization model" after a - * successful call to scsi_register(). + * Notes: Only required in "hotplug initialization model" after a + * successful call to scsi_host_alloc(). * - * Defined in: drivers/scsi/hosts.c + * Defined in: drivers/scsi/hosts.c **/ int scsi_add_host(struct Scsi_Host *shost, struct device * dev) @@ -369,40 +425,40 @@ int scsi_add_host(struct Scsi_Host *shost, struct device * dev) * * Returns nothing * - * Notes: Each scsi command has its own timer, and as it is added - * to the queue, we set up the timer. When the command completes, + * Notes: Each scsi command has its own timer, and as it is added + * to the queue, we set up the timer. When the command completes, * we cancel the timer. A LLD can use this function to change - * the existing timeout value. + * the existing timeout value. * - * Defined in: drivers/scsi/scsi_error.c + * Defined in: drivers/scsi/scsi_error.c **/ -void scsi_add_timer(Scsi_Cmnd *scmd, int timeout, void (*complete) - (Scsi_Cmnd *)) +void scsi_add_timer(struct scsi_cmnd *scmd, int timeout, + void (*complete)(struct scsi_cmnd *)) /** * scsi_adjust_queue_depth - change the queue depth on a SCSI device - * @SDpnt: pointer to SCSI device to change queue depth on - * @tagged: 0 - no tagged queuing - * MSG_SIMPLE_TAG - simple (unordered) tagged queuing - * MSG_ORDERED_TAG - ordered tagged queuing - * @tags Number of tags allowed if tagged queuing enabled, - * or number of commands the LLD can queue up - * in non-tagged mode (as per cmd_per_lun). + * @SDpnt: pointer to SCSI device to change queue depth on + * @tagged: 0 - no tagged queuing + * MSG_SIMPLE_TAG - simple (unordered) tagged queuing + * MSG_ORDERED_TAG - ordered tagged queuing + * @tags Number of tags allowed if tagged queuing enabled, + * or number of commands the LLD can queue up + * in non-tagged mode (as per cmd_per_lun). * - * Returns nothing + * Returns nothing * - * Notes: Can be invoked any time on a SCSI device controlled by this - * LLD. [Specifically during and after slave_configure() and prior to - * slave_destroy().] Can safely be invoked from interrupt code. Actual - * queue depth change may be delayed until the next command is being - * processed. + * Notes: Can be invoked any time on a SCSI device controlled by this + * LLD. [Specifically during and after slave_configure() and prior to + * slave_destroy().] Can safely be invoked from interrupt code. Actual + * queue depth change may be delayed until the next command is being + * processed. * - * Defined in: drivers/scsi/scsi.c [see source code for more notes] + * Defined in: drivers/scsi/scsi.c [see source code for more notes] * **/ void scsi_adjust_queue_depth(struct scsi_device * SDpnt, int tagged, - int num_tags) + int num_tags) /** @@ -419,13 +475,13 @@ void scsi_assign_lock(struct Scsi_Host *shost, spinlock_t *lock) /** * scsi_bios_ptable - return copy of block device's partition table - * @dev: pointer to block device + * @dev: pointer to block device * - * Returns pointer to partition table, or NULL for failure + * Returns pointer to partition table, or NULL for failure * - * 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) @@ -435,12 +491,12 @@ unsigned char *scsi_bios_ptable(struct block_device *dev) * * @SHpnt: pointer to host to block commands on * - * Returns nothing + * Returns nothing * - * 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 * SHpnt) @@ -450,15 +506,64 @@ void scsi_block_requests(struct Scsi_Host * SHpnt) * @scmd: pointer to scsi command instance * * Returns 1 if able to cancel timer else 0 (i.e. too late or already - * cancelled). + * cancelled). + * + * Notes: All commands issued by upper levels already have a timeout + * associated with them. A LLD can use this function to cancel the + * timer. + * + * Defined in: drivers/scsi/scsi_error.c + **/ +int scsi_delete_timer(struct scsi_cmnd *scmd) + + +/** + * scsi_host_alloc - create and register a scsi host adapter instance. + * @shost_tp: pointer to scsi host template + * @xtr_bytes: 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 + * + * Notes: When this call returns to the LLDD, the SCSI bus scan on + * this host has _not_ yet been done. + * The hostdata array (by default zero length) is a per host scratch + * area for the LLD. + * Both associated refcounting objects have there refcount set to 1. + * + * Defined in: drivers/scsi/hosts.c . + **/ +struct Scsi_Host * scsi_host_alloc(struct scsi_host_template *, int xtr_bytes) + + +/** + * scsi_host_get - increment Scsi_Host instance refcount + * @shost: pointer to struct Scsi_Host instance + * + * Returns nothing + * + * Notes: Actually increments the counts in two sub-objects + * + * Defined in: drivers/scsi/hosts.c + **/ +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 + * + * Returns nothing * - * Notes: All commands issued by upper levels already have a timeout - * associated with them. A LLD can use this function to cancel the - * timer. + * Notes: Actually decrements the counts in two sub-objects. If the + * latter refcount reaches 0, the Scsi_Host instance is freed. + * The LLD need not worry exactly when the Scsi_Host instance is + * freed, it just shouldn't access the instance after it has balanced + * out its refcount usage. * - * Defined in: drivers/scsi/scsi_error.c + * Defined in: drivers/scsi/hosts.c **/ -int scsi_delete_timer(Scsi_Cmnd *scmd) +void scsi_host_put(struct Scsi_Host *shost) /** @@ -469,11 +574,11 @@ int scsi_delete_timer(Scsi_Cmnd *scmd) * @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 * - * 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) @@ -483,51 +588,33 @@ int scsi_partsize(unsigned char *buf, unsigned long capacity, * scsi_register - create and register a scsi host adapter instance. * @shost_tp: pointer to scsi host template * @xtr_bytes: extra bytes to allocate in hostdata array (which is the - * last member of the returned Scsi_Host instance) + * last member of the returned Scsi_Host instance) * * Returns pointer to new Scsi_Host instance or NULL on failure * - * Notes: When this call returns to the LLDD, the SCSI bus scan on - * this host has _not_ yet been done. - * The hostdata array (by default zero length) is a per host scratch - * area for the LLD. - * - * Defined in: drivers/scsi/hosts.c . - **/ -struct Scsi_Host * scsi_register(struct SHT *, int xtr_bytes) - - -/** - * scsi_register_host - register a low level host driver - * @shost_tp: pointer to a scsi host driver template - * - * Returns 0 on Success, 1 on failure - * - * Notes: Should only be invoked if the "passive initialization - * model" is being used. Notice this is a _driver_ rather than - * HBA registration function. Most older drivers call this - * function by including the scsi_module.c file. - * This function is deprecated, use the "hotplug initialization - * model" instead. + * Notes: When this call returns to the LLDD, the SCSI bus scan on + * this host has _not_ yet been done. + * 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 . **/ -int scsi_register_host(Scsi_Host_Template *shost_tp) +struct Scsi_Host * scsi_register(struct scsi_host_template *, int xtr_bytes) /** * 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 * * Notes: If a LLD becomes aware that a scsi device (lu) has - * been removed but its host is still present then it can request - * the removal of that scsi device. If successful this call will - * lead to the slave_destroy() callback being invoked. sdev is an - * invalid pointer after this call. + * been removed but its host is still present then it can request + * the removal of that scsi device. If successful this call will + * lead to the slave_destroy() callback being invoked. sdev is an + * invalid pointer after this call. * - * Defined in: drivers/scsi/scsi_scan.c . + * Defined in: drivers/scsi/scsi_scan.c . **/ int scsi_remove_device(struct scsi_device *sdev) @@ -536,13 +623,13 @@ 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 * - * Returns value: 0 on success, 1 on failure (e.g. LLD busy ??) + * Returns value: 0 on success, 1 on failure (e.g. LLD busy ??) * * Notes: Should only be invoked if the "hotplug initialization - * model" is being used. It should be called _prior_ to - * 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) @@ -552,15 +639,15 @@ int scsi_remove_host(struct Scsi_Host *shost) * @shost: a pointer to a scsi host involved * @channel: channel (within) host on which scsi bus reset occurred * - * Returns nothing + * Returns nothing * * Notes: This only needs to be called if the reset is one which - * originates from an unknown location. Resets originated by the - * mid level itself don't need to call this, but there should be - * no harm. The main purpose of this is to make sure that a - * CHECK_CONDITION is properly treated. + * originates from an unknown location. Resets originated by the + * mid level itself don't need to call this, but there should be + * no harm. The main purpose of this is to make sure that a + * CHECK_CONDITION is properly treated. * - * Defined in: drivers/scsi/scsi_lib.c . + * Defined in: drivers/scsi/scsi_lib.c . **/ void scsi_report_bus_reset(struct Scsi_Host * shost, int channel) @@ -570,7 +657,7 @@ void scsi_report_bus_reset(struct Scsi_Host * shost, int channel) * @shost: a pointer to a scsi host instance * @pdev: pointer to device instance to assign * - * Returns nothing + * Returns nothing * * Defined in: drivers/scsi/hosts.h . **/ @@ -581,13 +668,13 @@ void scsi_set_device(struct Scsi_Host * shost, struct device * dev) * scsi_set_device_offline - set device offline then flush its queue * @sdev: a pointer to a scsi device instance to be set offline * - * Returns nothing + * Returns nothing * * Notes: Commands that are currently active on the scsi device have - * their timers cancelled and are transferred to the host's - * "eh" list for cancellation. + * their timers cancelled and are transferred to the host's + * "eh" list for cancellation. - * Defined in: drivers/scsi/scsi.c . + * Defined in: drivers/scsi/scsi.c . **/ void scsi_set_device_offline(struct scsi_device * sdev) @@ -596,10 +683,10 @@ void scsi_set_device_offline(struct scsi_device * sdev) * scsi_to_pci_dma_dir - convert SCSI subsystem direction flag to PCI * @scsi_data_direction: SCSI subsystem direction flag * - * Returns PCI_DMA_TODEVICE given SCSI_DATA_WRITE, - * PCI_DMA_FROMDEVICE given SCSI_DATA_READ - * PCI_DMA_BIDIRECTIONAL given SCSI_DATA_UNKNOWN - * else returns PCI_DMA_NONE + * Returns PCI_DMA_TODEVICE given SCSI_DATA_WRITE, + * PCI_DMA_FROMDEVICE given SCSI_DATA_READ + * PCI_DMA_BIDIRECTIONAL given SCSI_DATA_UNKNOWN + * else returns PCI_DMA_NONE * * Defined in: drivers/scsi/scsi.h . **/ @@ -610,10 +697,10 @@ int scsi_to_pci_dma_dir(unsigned char scsi_data_direction) * scsi_to_sbus_dma_dir - convert SCSI subsystem direction flag to SBUS * @scsi_data_direction: SCSI subsystem direction flag * - * Returns SBUS_DMA_TODEVICE given SCSI_DATA_WRITE, - * SBUS_DMA_FROMDEVICE given SCSI_DATA_READ - * SBUS_DMA_BIDIRECTIONAL given SCSI_DATA_UNKNOWN - * else returns SBUS_DMA_NONE + * Returns SBUS_DMA_TODEVICE given SCSI_DATA_WRITE, + * SBUS_DMA_FROMDEVICE given SCSI_DATA_READ + * SBUS_DMA_BIDIRECTIONAL given SCSI_DATA_UNKNOWN + * else returns SBUS_DMA_NONE * * Defined in: drivers/scsi/scsi.h . **/ @@ -622,21 +709,21 @@ int scsi_to_sbus_dma_dir(unsigned char scsi_data_direction) /** * scsi_track_queue_full - track successive QUEUE_FULL events on given - * device to determine if and when there is a need - * to adjust the queue depth on the device. + * device to determine if and when there is a need + * to adjust the queue depth on the device. * @SDptr: pointer to SCSI device instance * @depth: Current number of outstanding SCSI commands on this device, - * not counting the one returned as QUEUE_FULL. + * not counting the one returned as QUEUE_FULL. * * Returns 0 - no change needed - * >0 - adjust queue depth to this new depth - * -1 - drop back to untagged operation using host->cmd_per_lun - * as the untagged command depth + * >0 - adjust queue depth to this new depth + * -1 - drop back to untagged operation using host->cmd_per_lun + * as the untagged command depth * * Notes: LLDs may call this at any time and we will do "The Right - * Thing"; interrupt context safe. + * Thing"; interrupt context safe. * - * Defined in: drivers/scsi/scsi.c . + * Defined in: drivers/scsi/scsi.c . **/ int scsi_track_queue_full(Scsi_Device *SDptr, int depth) @@ -646,70 +733,48 @@ int scsi_track_queue_full(Scsi_Device *SDptr, int depth) * * @SHpnt: pointer to host to unblock commands on * - * Returns nothing + * Returns nothing * - * Defined in: drivers/scsi/scsi_lib.c . + * Defined in: drivers/scsi/scsi_lib.c . **/ void scsi_unblock_requests(struct Scsi_Host * SHpnt) /** * scsi_unregister - unregister and free memory used by host instance - * @shp: pointer to scsi host instance to unregister. + * @shp: pointer to scsi host instance to unregister. * - * Returns nothing + * Returns nothing * * Notes: Should only be invoked if the "hotplug initialization - * model" is being used. It should be called _after_ - * scsi_remove_host(). The shp pointer is invalid after this call. + * model" is being used. It should be called _after_ + * scsi_remove_host(). The shp pointer is invalid after this call. * - * Defined in: drivers/scsi/hosts.c . + * Defined in: drivers/scsi/hosts.c . **/ void scsi_unregister(struct Scsi_Host * shp) -/** - * scsi_unregister_host - unregister a low level host adapter driver - * @shost_tp: scsi host template to unregister. - * - * Returns 0 on Success, 1 on Failure - * - * Notes: Should only be invoked if the "passive initialization - * model" is being used. Notice this is a _driver_ rather than - * HBA deregistration function. So if there are multiple HBAs - * associated with the given template, they are each removed. Most - * older drivers call this function by including the scsi_module.c - * file. This function is deprecated, use the "hotplug initialization - * model" instead. - * - * Defined in: drivers/scsi/hosts.c . - **/ -int scsi_unregister_host(Scsi_Host_Template *shost_tp) - Interface Functions =================== -Interface functions are supplied (defined) by LLDs and -their function pointers are placed in an instance of struct SHT which -is passed to scsi_register() [or scsi_register_host()]. Some -are mandatory. Interface functions should be declared static. The +Interface functions are supplied (defined) by LLDs and their function +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()]. +Some are mandatory. Interface functions should be declared static. The accepted convention is that driver "xyz" will declare its slave_configure() function as: static int xyz_slave_configure(struct scsi_device * sdev); A pointer to this function should be placed in the 'slave_configure' member -of a "struct SHT" instance. A pointer to such an instance should -passed to the mid level's scsi_register() [or scsi_register_host()]. +of a "struct scsi_host_template" instance. A pointer to such an instance +should passed to the mid level's scsi_host_alloc() [or scsi_register() / +init_this_scsi_driver()]. The interface functions are also described in the hosts.h file immediately -above their definition point in "struct SHT". In some cases more detail -is given in hosts.h than below. - -Those interface functions marked "Required: yes" must be implemented -by the LLD and a pointer to that function must be placed in the driver's -"struct SHT" instance. Interface functions marked "Required: no" need not -be implemented. +above their definition point in "struct scsi_host_template". In some cases +more detail is given in hosts.h than below. The interface functions are listed below in alphabetical order. @@ -731,13 +796,14 @@ Summary: slave_configure - driver fine tuning for given device after attach slave_destroy - given device is about to be shut down + Details: /** * bios_param - fetch head, sector, cylinder info for a disk * @sdev: pointer to scsi device context (defined in scsi.h) * @bdev: pointer to block device context (defined in fs.h) - * @capacity: device size (in 512 byte sectors) + * @capacity: device size (in 512 byte sectors) * @params: three element array to place output: * params[0] number of heads (max 255) * params[1] number of sectors (max 63) @@ -745,8 +811,6 @@ Details: * * Return value is ignored * - * Required: no - * * Locks: none * * Notes: an arbitrary geometry (based on READ CAPACITY) is used @@ -754,10 +818,10 @@ Details: * pre-initialized with made up values just in case this function * doesn't output anything. * - * Defined in: LLD + * Optionally defined in: LLD **/ int bios_param(struct scsi_device * sdev, struct block_device *bdev, - sector_t capacity, int params[3]); + sector_t capacity, int params[3]) /** @@ -768,18 +832,16 @@ Details: * host_byte, driver_byte (status_byte is in the lsb). A value of * 0 is an unqualified success. * - * Required: if struct Scsi_Host::can_queue can ever by cleared (zero) - * then this function is required. - * * Locks: struct Scsi_Host::host_lock held on entry (with "irqsave") * and is expected to be held on return. * * Notes: Drivers tend to be dropping support for this function and * supporting queuecommand() instead. * - * Defined in: LLD + * Defined in: LLD (if struct Scsi_Host::can_queue can ever by cleared + * (zero) then this function is required) **/ - int command(struct scsi_cmnd * scp); + int command(struct scsi_cmnd * scp) /** @@ -789,9 +851,6 @@ Details: * Returns number of hosts this driver wants to control. 0 means no * suitable hosts found. * - * Required: yes, if "passive initialization mode" is used - * [in "hotplug initialization mode" it is not invoked] - * * Locks: none held * * Notes: First function called from the SCSI mid level on this @@ -799,9 +858,10 @@ Details: * For each host found, this method should call scsi_register() * [see hosts.c]. * - * Defined in: LLD + * Defined in: LLD (required if "passive initialization mode" is used, + * not invoked in "hotplug initialization mode") **/ - int detect(struct SHT * shtp); + int detect(struct scsi_host_template * shtp) /** @@ -810,17 +870,15 @@ Details: * * Returns SUCCESS if command aborted else FAILED * - * Required: no - * * Locks: struct Scsi_Host::host_lock held (with irqsave) on entry - * and assumed to be held on return. + * and assumed to be held on return. * * Notes: Invoked from scsi_eh thread. No other commands will be * queued on current host during eh. * - * Defined in: LLD + * Optionally defined in: LLD **/ - int eh_abort_handler(struct scsi_cmnd * scp); + int eh_abort_handler(struct scsi_cmnd * scp) /** @@ -829,17 +887,15 @@ Details: * * Returns SUCCESS if command aborted else FAILED * - * Required: no - * * Locks: struct Scsi_Host::host_lock held (with irqsave) on entry - * and assumed to be held on return. + * and assumed to be held on return. * * Notes: Invoked from scsi_eh thread. No other commands will be * queued on current host during eh. * - * 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) /** @@ -848,17 +904,15 @@ Details: * * Returns SUCCESS if command aborted else FAILED * - * Required: no - * * Locks: struct Scsi_Host::host_lock held (with irqsave) on entry - * and assumed to be held on return. + * and assumed to be held on return. * * Notes: Invoked from scsi_eh thread. No other commands will be * queued on current host during eh. * - * 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) /** @@ -867,10 +921,8 @@ Details: * * Returns SUCCESS if command aborted else FAILED * - * Required: no - * * Locks: struct Scsi_Host::host_lock held (with irqsave) on entry - * and assumed to be held on return. + * and assumed to be held on return. * * Notes: Invoked from scsi_eh thread. No other commands will be * queued on current host during eh. @@ -879,9 +931,9 @@ Details: * defined (or they all return FAILED) then the device in question * will be set offline whenever eh is invoked. * - * 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) /** @@ -890,16 +942,14 @@ Details: * * Returns TRUE if host unjammed, else FALSE. * - * Required: no - * * Locks: none * - * Notes: Invoked from scsi_eh thread. Driver supplied alternate to + * Notes: Invoked from scsi_eh thread. LLD supplied alternate to * scsi_unjam_host() found in scsi_error.c * - * Defined in: LLD + * Optionally defined in: LLD **/ - int eh_strategy_handler(struct Scsi_Host * shp); + int eh_strategy_handler(struct Scsi_Host * shp) /** @@ -911,8 +961,6 @@ Details: * manage the memory pointed to and maintain it, typically for the * lifetime of this host.] * - * Required: no - * * Locks: none * * Notes: Often supplies PCI or ISA information such as IO addresses @@ -921,15 +969,15 @@ Details: * (i.e. does not included embedded newlines). * The SCSI_IOCTL_PROBE_HOST ioctl yields the string returned by this * function (or struct Scsi_Host::name if this function is not - * available). - * In a similar manner, scsi_register_host() outputs to the console + * available). + * In a similar manner, init_this_scsi_driver() outputs to the console * each host's "info" (or name) for the driver it is registering. * Also if proc_info() is not supplied, the output of this function * is used instead. * - * Defined in: LLD + * Optionally defined in: LLD **/ - const char * info(struct Scsi_Host * shp); + const char * info(struct Scsi_Host * shp) /** @@ -944,8 +992,6 @@ Details: * Returns negative "errno" value when there is a problem. 0 or a * positive value indicates success and is returned to the user space. * - * Required: no - * * Locks: none * * Notes: The SCSI subsystem uses a "trickle down" ioctl model. @@ -958,11 +1004,11 @@ Details: * However the mid level returns -EINVAL for unrecognized 'cmd' * numbers when this function is not supplied by the driver. * Unfortunately some applications expect -EINVAL and react badly - * when -ENOTTY is returned; stick with -EINVAL. + * when -ENOTTY is returned; stick with -EINVAL. * - * 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) /** @@ -983,16 +1029,14 @@ Details: * Returns length when 1==writeto1_read0. Otherwise number of chars * output to buffer past offset. * - * Required: no - * * Locks: none held * * Notes: Driven from scsi_proc.c which interfaces to proc_fs * - * Defined in: LLD + * Optionally defined in: LLD **/ -int proc_info(char * buffer, char ** start, off_t offset, - int length, int hostno, int writeto1_read0); + int proc_info(char * buffer, char ** start, off_t offset, + int length, int hostno, int writeto1_read0) /** @@ -1000,13 +1044,10 @@ int proc_info(char * buffer, char ** start, off_t offset, * @scp: pointer to scsi command object * @done: function pointer to be invoked on completion * - * Returns 1 if the adapter (host) is busy, else returns 0. One - * reason for an adapter to be busy is that the number - * of outstanding queued commands is already equal to - * struct Scsi_Host::can_queue . - * - * Required: if struct Scsi_Host::can_queue is ever non-zero - * then this function is required. + * Returns 0 on success and 1 if the LLD or the HBA is busy (i.e. run + * out of resources to queue further commands). Other types of errors + * are flagged by setting struct scsi_cmnd:result to an appropriate + * value, invoking the 'done' callback, and then returning 0. * * Locks: struct Scsi_Host::host_lock held on entry (with "irqsave") * and is expected to be held on return. @@ -1024,14 +1065,15 @@ int proc_info(char * buffer, char ** start, off_t offset, * this case, it should be placed in scp->result before this function * returns. * If a status of CHECK CONDITION is placed in "result" when the - * 'done' callback is invoked, then the LLD driver should - * perform autosense and fill in the struct scsi_cmnd::sense_buffer - * array. + * 'done' callback is invoked, then the LLD driver should + * perform autosense and fill in the struct scsi_cmnd::sense_buffer + * array. * - * Defined in: LLD + * Defined in: LLD (required if if struct Scsi_Host::can_queue is ever + * non-zero) **/ int queuecommand(struct scsi_cmnd * scp, - void (*done)(struct scsi_cmnd *)); + void (*done)(struct scsi_cmnd *)) /** @@ -1040,100 +1082,91 @@ int proc_info(char * buffer, char ** start, off_t offset, * * Return value ignored (could soon be a function returning void). * - * Required: yes (see notes) - * * Locks: none held * - * Notes: Invoked from mid level's scsi_unregister_host(). + * Notes: Invoked from scsi_module.c's exit_this_scsi_driver(). * LLD's implementation of this function should call - * scsi_unregister(shp) prior to returning. - * If not supplied mid-level [in hosts.c] supplies its own - * implementation (see scsi_host_legacy_release()) which is for old - * ISA adapters so it is best not to use it. + * scsi_unregister(shp) prior to returning. + * Only needed for old-style host templates. * - * Defined in: LLD + * Defined in: LLD (required in "passive initialization model", + * should not be defined in hotplug model) **/ - int release(struct Scsi_Host * shp); + int release(struct Scsi_Host * shp) /** - * 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 + * (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. - * - * Required: no + * the device is ignored. * * Locks: none * * Notes: Allows the driver to allocate any resources for a device - * prior to its initial scan. The corresponding scsi device may not - * exist but the mid level is just about to scan for it (i.e. send - * and INQUIRY command plus ...). If a device is found then - * slave_configure() will be called while if a device is not found - * slave_destroy() is called. + * prior to its initial scan. The corresponding scsi device may not + * exist but the mid level is just about to scan for it (i.e. send + * and INQUIRY command plus ...). If a device is found then + * slave_configure() will be called while if a device is not found + * slave_destroy() is called. * For more details see the hosts.h file. * - * 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 - * INQUIRY) + * has been first scanned (i.e. it responded to an + * 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 - * slave_destroy() called on them so clean up resources.] - * - * Required: no + * the device is taken offline. [offline devices will _not_ have + * slave_destroy() called on them so clean up resources.] * * Locks: none * * Notes: Allows the driver to inspect the response to the initial - * INQUIRY done by the scanning code and take appropriate action. - * For more details see the hosts.h file. + * INQUIRY done by the scanning code and take appropriate action. + * For more details see the hosts.h file. * - * 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. + * activity has ceased on this device. * @sdp: device that is about to be shut down * * Returns nothing * - * Required: no - * * Locks: none * * Notes: Mid level structures for given device are still in place - * but are about to be torn down. Any per device resources allocated - * by this driver for given device should be freed now. No further - * commands will be sent for this sdp instance. [However the device - * could be re-attached in the future in which case a new instance - * of struct scsi_device would be supplied by future slave_alloc() - * and slave_configure() calls.] - * - * Defined in: LLD + * but are about to be torn down. Any per device resources allocated + * by this driver for given device should be freed now. No further + * commands will be sent for this sdp instance. [However the device + * could be re-attached in the future in which case a new instance + * of struct scsi_device would be supplied by future slave_alloc() + * and slave_configure() calls.] + * + * Optionally defined in: LLD **/ - void slave_destroy(struct scsi_device *sdp); + void slave_destroy(struct scsi_device *sdp) Data Structures =============== -struct SHT ----------- -There is one "struct SHT" instance per LLD ***. It is +struct scsi_host_template +------------------------- +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 way members that are not explicitly initialized will be set to 0 or NULL. Member of interest: @@ -1143,22 +1176,23 @@ Member of interest: by sysfs in one of its "drivers" directories. Hence "proc_name" should only contain characters acceptable to a Unix file name. - (*release)() - should be defined by all LLDs as the default (legacy) - implementation is only appropriate for ISA adapters). + (*queuecommand)() - primary callback that the mid level uses to inject + SCSI commands into a LLD. The structure is defined and commented in hosts.h *** In extreme situations a single driver may have several instances - if it controls several different classes of hardware (e.g. the - advansys driver handles both ISA and PCI cards and has a separate - instance of struct SHT for each). + if it controls several different classes of hardware (e.g. a LLD + that handles both ISA and PCI cards and has a separate instance of + struct scsi_host_template for each class). struct Scsi_Host ---------------- There is one struct Scsi_Host instance per host (HBA) that a LLD controls. The struct Scsi_Host structure has many members in common -with "struct SHT". When a new struct Scsi_Host instance is created (in -scsi_register() in hosts.c) those common members are initialized from -the driver's struct SHT instance. Members of interest: +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 +initialized from the driver's struct scsi_host_template instance. Members +of interest: host_no - system wide unique number that is used for identifying this host. Issued in ascending order from 0 (and the positioning can be influenced by the scsihosts @@ -1172,7 +1206,7 @@ the driver's struct SHT instance. Members of interest: in a single SCSI command. 0 implies no maximum. cmd_per_lun - maximum number of command that can be queued on devices controlled by the host. Overridden by LLD calls to - scsi_adjust_queue_depth(). + scsi_adjust_queue_depth(). unchecked_isa_dma - 1->only use bottom 16 MB of ram (ISA DMA addressing restriction), 0->can use full 32 bit (or better) DMA address space @@ -1180,22 +1214,22 @@ the driver's struct SHT instance. Members of interest: 0->disallow SCSI command merging highmem_io - 1->can DMA in to or out of high memory, 0->use bounce buffers if data is in high memory - hostt - pointer to driver's struct SHT from which this - struct Scsi_Host instance was spawned + hostt - pointer to driver's struct scsi_host_template from which + this struct Scsi_Host instance was spawned sh_list - a double linked list of pointers to all struct Scsi_Host instances (currently ordered by ascending host_no) 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 is set by the second argument (named 'xtr_bytes') to - scsi_register(). + scsi_host_alloc() or scsi_register(). The structure is defined in hosts.h struct scsi_device ------------------ Generally, there is one instance of this structure for each SCSI logical unit -on a host. Scsi devices are uniquely identified within a host by bus number, -cahnnel number, target id and logical unit number (lun). +on a host. Scsi devices connected to a host are uniquely identified by a +channel number, target id and logical unit number (lun). The structure is defined in scsi.h struct scsi_cmnd @@ -1211,7 +1245,7 @@ The structure is defined in scsi.h Locks ===== Each struct Scsi_Host instance has a spin_lock called struct -Scsi_Host::default_lock which is initialized in scsi_register() [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 is initialized to point at default_lock with the scsi_assign_lock() function. Thereafter lock and unlock operations performed by the mid level use the @@ -1236,11 +1270,12 @@ detects a CHECK CONDITION status by either: to perform an extra data in phase on such responses b) or, the LLD issuing a REQUEST SENSE command itself -Either way, the mid level 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) 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 issue a REQUEST SENSE command. +Either way, when a status of CHECK CONDITION is detected, the mid level +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) +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 +issue a REQUEST SENSE command. In the presence of queued commands the "nexus" that maintains sense buffer data from the command that failed until a following REQUEST SENSE @@ -1256,7 +1291,7 @@ one per SCSI host. The older error handling mechanism has been removed. This means the LLD interface functions abort() and reset() have been removed. -The struct SHT::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 aggregated with the configuration descriptions from all other Linux @@ -1264,9 +1299,10 @@ subsystems in the Documentation/Configure.help file. In the 2.5 series, the SCSI subsystem now has its own (much smaller) drivers/scsi/Config.help file. -Addition of slave_alloc(), slave_configure() and slave_destroy(). +struct SHT has been renamed to struct scsi_host_template. -Addition of the "hotplug initialization model". +Addition of the "hotplug initialization model" and many extra functions +to support it. Credits @@ -1275,11 +1311,11 @@ The following people have contributed to this document: Mike Anderson <andmike@us.ibm.com> James Bottomley <James.Bottomley@steeleye.com> Patrick Mansfield <patmans@us.ibm.com> - Christoph Hellwig <hch@infradead.org> - Doug Ledford <dledford@redhat.com> + Christoph Hellwig <hch@infradead.org> + Doug Ledford <dledford@redhat.com> Andries Brouwer <Andries.Brouwer@cwi.nl> Douglas Gilbert dgilbert@interlog.com -29th April 2003 +18th June 2003 |
