|
|
2. Data Structures
2.0 Introduction
Before it is possible to explain how the actual SCSI subsystem works, it is essential that you first understand some of the key data structures which are used all throughout the subsystem. The purpose of this section of the document is to explain what those structures are, and then explain in detail what the structure elements are used for. The other sections of the Linux SCSI documentation will be linked to this section, as appropriate. In addition to explaining the purpose of each element of the structure, it is also important to mention exactly who should be allowed to use it. When originally designed, the data structures were intended to be quasi-object-oriented. Given that the Linux kernel is compiled with the C compiler instead of C++, we have to fake it to some degree - one unfortunate side effect of this is that there is no way to declare private members of the class, and in addition it isn't possible to declare private member functions which are not globally accessible. Complicating this is the fact that some structure elements are created on behalf of different sections of the SCSI subsystem. For example, some elements may be used entirely by the low-level drivers and not touched anywhere else. Other elements might be used by the mid-level, and shouldn't be touched elsewhere. At some point, it might be a good idea to try and split some of these structures to group out the elements by who is allowed to use them - in the mean time, this documentation will have to suffice. Alternatively, some of the structure elements in the structures created on behalf of low-level drivers should be abstracted into something like a hostdata pointer which one of the structures already has. Another factor is that some fields in the structures are used by obsolete parts of the SCSI subsystem, and could in principle be removed once those obsolete portions of the subsystem have been removed. 2.1 HostTheScsi_Host structure is used to describe each
instance of a host adapter on the system. In other words, if you have two
Adaptec 1542 cards in your machine, there will be two instances of Scsi_Host,
one for each.
The 2.1.1 Structure definition
2.1.2 Element descriptions
2.1.2.1 Scsi_Host::next
All instances of 2.1.2.2 Scsi_Host::host_queueThe 2.1.2.3 Scsi_Host::pending_commandsThe 2.1.2.4 Scsi_Host::ehandlerThe 2.1.2.5 Scsi_Host::eh_waitTheeh_wait field is used internally by the error
handler thread, and is a semaphore that is used to indicate that there is work
(i.e. some command has failed).
2.1.2.6 Scsi_Host::eh_notifyTheeh_notify field is used internally by the error
handler thread, and is a semaphore that is used at the time of thread startup or
shutdown for proper synchronization.
2.1.2.7 Scsi_Host::eh_actionTheeh_action field is used internally by the error
handler thread, and is a semaphore that is used during error recovery. The
typical use is so that the error handler thread can wait until an interrupt
indicates that some requested action (command abort, for example) is completed.
2.1.2.8 Scsi_Host::eh_activeThe 2.1.2.9 Scsi_Host::host_waitThe 2.1.2.10 Scsi_Host::hosttThe 2.1.2.11 Scsi_Host::host_activeThis is used by the broken SCSI_BLOCK feature to indicate the host in the block list that is currently active. This field should not be used by low-level drivers. 2.1.2.12 Scsi_Host::host_busyThis field indicates the number of 2.1.2.13 Scsi_Host::host_failedThis field is the number of busy commands which have failed. By failed we mean that they require the error handler thread to take some corrective action. This field should not be used by low-level drivers. 2.1.2.14 Scsi_Host::extra_bytesThis field indicates the number of bytes allocated in the 2.1.2.15 Scsi_Host::host_noThis is the host number for this host. 2.1.2.16 Scsi_Host::last_resetThis is the time of the last reset for this host. This field is only used by the old error handling code, and will go away eventually. 2.1.2.17 Scsi_Host::max_idThis is the maximum SCSI ID for devices attached to this bus. This will typically be either 8 or 16, where the default value is 8. This is mainly used when we scan the bus so that we can bound the search. 2.1.2.18 Scsi_Host::max_lunThis is the maximum SCSI LUN for devices attached to this bus. This will typically be 8, but hosts can adjust this as required. This is mainly used when we scan the bus so that we can bound the search. 2.1.2.19 Scsi_Host::max_channelThis is the maximum channel for devices attached to this bus. Hosts that only support one channel will leave this field set to the default value of 0. This is mainly used when we scan the bus so that we can bound the search. 2.1.2.20 Scsi_Host::block
This field is used by the broken SCSI_BLOCK feature - typically this will be a circularly linked of hosts that desire the "blocked" feature. The element points to a circularly linked list of 2.1.2.21 Scsi_Host::wish_blockThis field is set by low-level drivers that perform ISA DMA.
By setting this field to TRUE, the host is requesting that it be added to the 2.1.2.22 Scsi_Host::baseThis field is set by low-level drivers, and is the base address for memory mapped I/O. This field is here as a convenience to low-level drivers that require this - it isn't used by the middle or upper layers. 2.1.2.23 Scsi_Host::io_portThis field is set by low-level drivers, and is the base
io_port used by this host. This field is here as a convenience to low-level
drivers that require this - it isn't used by the middle or upper layers, with
one exception. At the time of module unload, and if the driver hasn't specified
a 2.1.2.24 Scsi_Host::n_io_portThis field is set by low-level drivers, and is the number of I/O ports used by this host. This field is here as a convenience to low-level drivers that require this - it isn't used by the middle or upper layers, with the one exception noted above. 2.1.2.25 Scsi_Host::dma_channelThis field is set by low-level drivers, and is the dma channel
number used by this host. This field is here as a convenience to low-level
drivers that require this - it isn't used by the middle or upper layers, with
one exception. At the time of module unload, and if the driver hasn't specified
a 2.1.2.26 Scsi_Host::irqThis field is set by low-level drivers, and is the IRQ number
used by this host. This field is here as a convenience to low-level drivers that
require this - it isn't used by the middle or upper layers, with one exception.
At the time of module unload, and if the driver hasn't specified a 2.1.2.27 Scsi_Host::unique_idThe theory is that low-level drivers were supposed to set this
field to be a unique ID of some sort - this could be used as required by user
level programs that need to somehow identify the host. An example might case
where users want to generate SVr4 style device names. Unfortunately very few
drivers ever bother to set this to anything meaningful, and the user community
has instead adopted the 2.1.2.28 Scsi_Host::this_idThis is the SCSI ID of the host adapter itself. This value is initialized from the host template, but low-level drivers are free to modify it as required. This field is only used during the bus scan so that we don't try and send commands out on the bus for the host adapter itself. 2.1.2.29 Scsi_Host::can_queueThis is the maximum number of commands that this host can have active on the bus at any given time. This is initialized from the host template, and can be modified as required by the low-level driver. 2.1.2.30 Scsi_Host::cmd_per_lunThis is the maximum number of outstanding commands per lun that are allowed at one time. This field is initialized from the host template, and can be modified as required by the low-level driver. Hosts that don't support tagged queueing will always set this to 1. 2.1.2.31 Scsi_Host::sg_tablesizeFor hosts that support scatter-gather I/O (nearly all do), this is the maximum size of the scatter-gather table that the host can deal with. Hosts that don't support scatter-gather will typically set this to 0. This field is initialized from the host template, but can be modified as required by the low-level driver. 2.1.2.32 Scsi_Host::in_recoveryIn the event that the host uses the new error recovery code, this flag will be set when there errors that require the error handler thread take action of some sort. 2.1.2.33 Scsi_Host::unchecked_isa_dmaThis flag is set if the host uses ISA DMA. Typically this is used to decide whether bounce buffers should be allocated for the I/O request. This field is initialized from the host template, and can be modified as required by the low-level driver. 2.1.2.34 Scsi_Host::use_clusteringThis flag indicates that we should attempt to cluster blocks in an I/O request into larger blocks. Typically this is a win in the event that the host has a limited scatter-gather table size. This is initialized from the host template, but can be modified as required by the low-level driver. 2.1.2.35 Scsi_Host::loaded_as_moduleThis flag is set if the host is present as result of being loaded as a module. The flag is clear if the low-level driver was compiled into the kernel. 2.1.2.36 Scsi_Host::host_blockedThis flag is set if the host adapter rejected a command (host
busy, device busy). The basic purpose is to make sure we don't try and send
other commands to the host until the rejected commands have completed. See the 2.1.2.37 Scsi_Host::select_queue_depthsThis is a function pointer into the low-level driver which is used to adjust the data structures for the low-level driver as required to prepare for tagged queueing. FIXME - this needs to be moved to the host template. 2.1.2.38 Scsi_Host::hostdataThis field is used so that hosts can define host-specific
data. The 2.2 Host template
The The 2.2.1 Structure definition
2.2.2 Element descriptions
2.2.2.1 Scsi_Host_Template::nextThis element is used for chaining the 2.2.2.2 Scsi_Host_Template::moduleThis element is used when the associated low-level driver is
loaded as a module - this will point to the variable "__this_module"
in this case. Otherwise it is a NULL pointer. The main reason we need this is so
that the 2.2.2.3 Scsi_Host_Template::proc_dirThis entry is used to describe the directory entry underneath /proc/scsi that will be used for this host adapter. By holding a pointer to the structure here, it is possible for the SCSI core to sweep through all of the loaded drivers and build the actual /proc/scsi directory. 2.2.2.4 Scsi_Host_Template::proc_infoThis entry is an entrypoint into the low-level driver which is used to generate the file contents for files underneath /proc/scsi/driver/hostno, where driver is the driver name (established through the proc_dir entry above), and hostno is the host number. Drivers are not required to supply anything here, however if the default NULL pvalue is used, there isn't any useful information available from the host entry in /proc/scsi. 2.2.2.5 Scsi_Host_Template::nameThis is the name of the driver. This is for informational
purposes only and is displayed at boot time. The name can also be obtained by
querying a device with the IOCTL_PROBE_HOST ioctl. Also note that if the In retrospect, it is silly to have two fields that provide the same information. The info method is more general, and thus at some point in the future this interface should go away. 2.2.2.6 Scsi_Host_Template::detectThis is the entrypoint that is called either at boot time or at the time of module load to probe for the presence of a board which the driver itself can drive. 2.2.2.7 Scsi_Host_Template::releaseThis is the entrypoint which is called at the time of module unload. The purpose is to allow the driver to release whatever resources it may have allocated. It is possible, but not recommended to omit this entrypoint -
the It is possible that at some point in the future, it will be mandatory for drivers to supply this entrypoint for them to be used in a modular fashion. 2.2.2.8 Scsi_Host_Template::infoThis field is an entrypoint into the driver which represents
an alternate method of determining the name of the scsi driver. The 2.2.2.9 Scsi_Host_Template::ioctlThis entrypoint is used for direct ioctl calls in the event that the ioctl code does not apply to the device. 2.2.2.10 Scsi_Host_Template::commandThis entrypoint is used for sending commands to the low-level
driver. This flavor of the interface is depreciated, and should rarely be used.
The only case where this is the appropriate interface to use would be in the
case of a driver for a card that has no interrupt capability, and where the
driver must instead poll the card at regular intervals. There is only one such
driver that I know of - a peculiar parallel port scsi adapter. If it weren't for
this one oddball case, this entrypoint would probably be removed entirely. In
all other cases, drivers should instead use the 2.2.2.11 Scsi_Host_Template::queuecommandThis is the normal entrypoint by which a low-level driver receives a command that should be queued to the specified device. The command is not guaranteed to be complete when the function returns - in fact, it would tend to be a rarity for the command to be complete when this interface returns. 2.2.2.12 Scsi_Host_Template::eh_strategy_handlerThis is the entrypoint that is used by the error handler thread to actually perform error recovery. If this is NULL, a default function is used instead - the default should be sufficient for most situations, but the capability is present for drivers to override it if they wish. This entrypoint only needs to be specified in the event that the new error handling is in use. 2.2.2.13 Scsi_Host_Template::eh_abort_handlerThis is the entrypoint that is called by the default error handler function during error recovery. This entry point should attempt to abort the command, if possible. This entrypoint only has meaning if the new error handling is in use. 2.2.2.14 Scsi_Host_Template::eh_device_reset_handlerThis is the entrypoint that is called by the default error handler function during error recovery. This entry point should attempt to perform a device reset, if possible. This entrypoint only has meaning if the new error handling is in use. 2.2.2.15 Scsi_Host_Template::eh_bus_reset_handlerThis is the entrypoint that is called by the default error handler function during error recovery. This entry point should attempt to perform a bus reset, if possible. This entrypoint only has meaning if the new error handling is in use. 2.2.2.16 Scsi_Host_Template::eh_host_reset_handlerThis is the entrypoint that is called by the default error handler function during error recovery. This entry point should attempt to reset the host adapter, if possible. This entrypoint only has meaning if the new error handling is in use. 2.2.2.17 Scsi_Host_Template::abortThis is the entrypoint that is used by the old error recovery code in order to attempt a SCSI abort. The old error recovery code is obsolete and will be removed from the kernel once no drivers use it, and once this happens, this field will be removed from the structure. 2.2.2.18 Scsi_Host_Template::resetThis is the entrypoint that is used by the old error recovery code in order to attempt a SCSI reset. The old error recovery code is obsolete and will be removed from the kernel once no drivers use it, and once this happens, this field will be removed from the structure. 2.2.2.19 Scsi_Host_Template::slave_attachThis entrypoint is not used, and the field may be removed at some point in the future. 2.2.2.20 Scsi_Host_Template::bios_paramThis entrypoint can be used to obtain the C/H/S for a disk drive. Typically this information is of interest to bootloaders (such as lilo), and perhaps also by programs which would wish to modify the partition table. The C/H/S information that is returned by this function *MUST* return identical information to what the BIOS on the board would return - this is the only way that a bootloader will be able to load the correct files. 2.2.2.21 Scsi_Host_Template::can_queueThis field specifies the maximum number of active SCSI
commands which the driver is capable of handling at the same time. This
represents a default value which can be overridden in the 2.2.2.22 Scsi_Host_Template::this_idThis field specifies the SCSI ID of the host adapter itself.
This represents a default value which can be overridden in the 2.2.2.23 Scsi_Host_Template::sg_tablesizeThis field specifies the maximum size of a scatter-gather list. Some host adapters have hardware limits to the size of the table - in this case the limit must be specified here. In the event that there is no upper bound in the driver for the size of the scatter-gather table, then a value of SG_ALL can be specified. Host adapters that don't support scatter-gather must specify 0. Please note that I/O performance for drivers that do not support scatter-gather is absolutely horrible. 2.2.2.24 Scsi_Host_Template::cmd_per_lunThis field specifies the maximum number of outstanding commands that can be specified per logical unit. Before the days of tagged queueing it didn't make a whole lot of sense to set this above 1. For host adapters that specify a select_queue_depths() function, the value specified here might not be used at all. The place where this setting comes into play is where the 2.2.2.25 Scsi_Host_Template::presentThis field indicates how many of this type of card were found to be present on the machine. 2.2.2.26 Scsi_Host_Template::unchecked_isa_dmaBoolean value set to TRUE in the event that the card uses DMA over the ISA bus to perform I/O. When true, there are cases where we need to allocate bounce buffers prior to scheduling an I/O request. 2.2.2.27 Scsi_Host_Template::use_clusteringBoolean value set to TRUE in the event that it is a win to try and merge requests for adjacent blocks of memory into larger requests. This is usually a big win for host adapters with a limited maximum scatter-gather table size. 2.2.2.28 Scsi_Host_Template::use_new_eh_codeBoolean value set to TRUE if this host adapter is prepared to use the new error handling code. 2.2.2.29 Scsi_Host_Template::emulatedBoolean value set to TRUE for emulated SCSI host adapters. ATAPI is the only driver which should set this field. 2.3 DeviceThe Any device (such as a CD changer) that responds to multiple LUNs will be treated a separate instances of independent devices. These structures are allocated at the time the bus is scanned. 2.3.1 Structure definition
2.3.2 Element descriptions2.3.2.1 Scsi_Device::nextPointer used to maintain forward links in the doubly linked list of all devices attached to a given host adapter. 2.3.2.2 Scsi_Device::prevPointer used to maintain reverse links in the doubly linked list of all devices attached to a given host adapter. 2.3.2.3 Scsi_Device::device_waitThis field is used in the event that we need to wait for a
free 2.3.2.4 Scsi_Device::hostPointer to the instance of 2.3.2.5 Scsi_Device::device_busyUsage counter representing the number of commands that have been received by the middle layer and for which the upper layer is waiting for a response. 2.3.2.6 Scsi_Device::scsi_request_fnThis entrypoint is a hack, pure and simple. The basic problem is that an ioctl may have blocked normal disk I/O, and once the ioctl is done, we need to jumpstart the normal disk queue to ensure that the request is queued immediately. This will undoubtably go away in the Linux 2.3 timeframe. 2.3.2.7 Scsi_Device::device_queueThis field points to the head of a linked list of 2.3.2.8 Scsi_Device::idThe SCSI ID for this device. 2.3.2.9 Scsi_Device::lunThe SCSI logical unit number for this device. 2.3.2.10 Scsi_Device::channelThe SCSI channel number for this device. This will always be 0 for devices attached to host adapters that only have a single channel. 2.3.2.11 Scsi_Device::manufacturerThis field is unused. 2.3.2.12 Scsi_Device::attachedThe number of upper level drivers that have attached to this device. Normally at most 2 (generics, plus one other). 2.3.2.13 Scsi_Device::access_countNumber of open file descriptors for this device. This is mainly used so that we know when to lock and unlock the door for removable media. 2.3.2.14 Scsi_Device::hostdataThis is a 2.3.2.15 Scsi_Device::typeThe type of the device (i.e. TYPE_DISK, TYPE_SCANNER, etc). See table 7-17 in the SCSI standards for the values that this can take. 2.3.2.16 Scsi_Device::scsi_levelSet based upon INQUIRY data to be SCSI_1, SCSI_1_CCS, SCSI_2, or SCSI_UNKNOWN. 2.3.2.17 Scsi_Device::vendorThe manufacturer ID, as returned from the INQUIRY command. 2.3.2.18 Scsi_Device::modelThe model number, as returned from the INQUIRY command. 2.3.2.19 Scsi_Device::revThe firmware revision level, as returned from the INQUIRY command. 2.3.2.20 Scsi_Device::current_tagNot 100% sure on this one. I believe the purpose of this is to track how many tagged commands have been issued without a ORDERED_QUEUE_TAG (basically to flush the queue of any pending commands). 2.3.2.21 Scsi_Device::sync_min_periodNot 100% sure on this one. I believe that this is used to keep track of synchronous I/O characteristics of this device. 2.3.2.22 Scsi_Device::sync_max_offsetNot 100% sure on this one. I believe that this is used to keep track of synchronous I/O characteristics of this device. 2.3.2.23 Scsi_Device::queue_depthThe maximum tagged queue depth for this device. The default value is the maximum number of commands per lun for the host itself, and can be overridden by the select_queue_depths() function associated with the host. 2.3.2.24 Scsi_Device::onlineBoolean value indicating the device is online. Devices can be taken offline during error recovery in the event that the device is completely toasted. 2.3.2.25 Scsi_Device::writeableBoolean value that indicates whether the device is writable. Initialized from the INQUIRY data. 2.3.2.26 Scsi_Device::removableBoolean value that indicates whether the device is removable. Initialized from the INQUIRY data. 2.3.2.27 Scsi_Device::randomBoolean value that indicates whether the device is random-access. Initialized from the INQUIRY data. 2.3.2.28 Scsi_Device::has_cmdblocksBoolean flag that indicates whether we have allocated 2.3.2.29 Scsi_Device::changedBoolean flag that indicates that a media change has taken place. This may cause buffers to be flushed, to remove bogus cached data. 2.3.2.30 Scsi_Device::busyBoolean value to indicate that the device is busy with something or another (usually rereading partition table). This really needs to be changed to a spinlock instead. 2.3.2.31 Scsi_Device::lockableBoolean that indicates that it is possible to lock the door of a device that has removable media. 2.3.2.32 Scsi_Device::borkenBoolean flag that indicates we shouldn't attempt synchronous transfers. 2.3.2.33 Scsi_Device::tagged_supportedBoolean that indicates that tagged queuing is supported for this device. 2.3.2.34 Scsi_Device::tagged_queueBoolean that indicates that tagged queuing is enabled for this device. Can be turned on and off with ioctls. 2.3.2.35 Scsi_Device::disconnectThis device is capable of disconnect. Any device that doesn't answer this one yes should be treated carefully. 2.3.2.36 Scsi_Device::soft_resetBoolean value which indicates that this device uses the soft reset option. 2.3.2.37 Scsi_Device::syncCannot tell for sure. This might be used to indicate that we can do sync transfers, or that we have already checked to see if the device supports sync transfers. Only a small handful of drivers use this. 2.3.2.38 Scsi_Device::wideCannot tell for sure. This might be used to indicate that we can do wide transfers, or that we have already checked to see if the device supports wide transfers. Only a small handful of drivers use this. 2.3.2.39 Scsi_Device::single_lunAnother hack. If this boolean value is set, we only allow a single outstanding command to this SCSI Id, and block commands to other luns until the one that is outstanding is complete. Mainly of use for things like changers, where you would thrash the thing by trying to access devices on different luns at the same time. 2.3.2.40 Scsi_Device::was_resetIndicates that the device was reset. For removable devices, it means we need to relock the door, as it will no longer be locked. 2.3.2.41 Scsi_Device::expecting_cc_uaIndicates that we are expecting a CHECK_CONDITION/UNIT_ATTENTION as result of a reset. 2.3.2.42 Scsi_Device::device_blockedBoolean flag that is part of the SCSI_BLOCK hack. As far as I can tell, this is never set to TRUE, and as a result it can be removed. 2.4 Device templateThe There is no direct mapping between a Many of the elements of this structure are required abstractions to make modules possible. The fundamental issue is that adding or removing a low-level driver will add/remove new devices to the kernel which in turn must be driven by the upper level drivers. We needed an abstraction of the upper level drivers to make it possible for module load/unload of low-level drivers to do the proper attach/detach. 2.4.1 Structure definition
2.4.2 Element descriptions
2.4.2.1 Scsi_Device_Template::nextUsed for linking together all 2.4.2.2 Scsi_Device_Template::nameASCII Description of the type of device. For example, "disk", "tape". 2.4.2.3 Scsi_Device_Template::tagCanonical ASCII name of the device. For example, "sd", or "st". 2.4.2.4 Scsi_Device_Template::moduleThis element is used when the associated upper-level driver is
loaded as a module - this will point to the variable "__this_module"
in this case. Otherwise it is a NULL pointer. The main reason we need this is so
that the 2.4.2.5 Scsi_Device_Template::scsi_typeThe SCSI type for devices that this driver will handle. For example, TYPE_DISK, TYPE_TAPE. Note - as far as I can tell this isn't used for anything. It would probably be wise to remove this field at some later date. 2.4.2.6 Scsi_Device_Template::majorThe major number which this driver will be responsible for. 2.4.2.7 Scsi_Device_Template::nr_devThe number of physical devices that are attached to the driver. 2.4.2.8 Scsi_Device_Template::dev_noticedDuring the bus scan phase, all detected devices are passed to
the detect interface, which decides whether the driver is capable of handling
the device in question. The 2.4.2.9 Scsi_Device_Template::dev_maxThis field indicates the absolute maximum number of devices that this driver is capable of driving. As a practical matter, this indicates the allocation size of some of the internal data structures. 2.4.2.10 Scsi_Device_Template::blkBoolean flag which indicates whether this driver is for a block device or for a character device. 2.4.2.11 Scsi_Device_Template::detectThis interface is used at the time of bus scan. A This function will only be called at either boot time, or when SCSI modules are being loaded. 2.4.2.12 Scsi_Device_Template::initThis function is called once the bus scan is complete, and we
have knowledge of the total number of devices that the driver will need to drive
in the Most of the internal data structures are tables that are
indexed into by the minor number to obtain the size of the device, blocksize, a
pointer to the This function will only be called at either boot time, or when SCSI modules are being loaded. 2.4.2.13 Scsi_Device_Template::finishThis interface is called once all of the devices are fully
attached. This has the job of initializing the internal data structures that
were allocated by the 2.4.2.14 Scsi_Device_Template::attachAfter the bus scan, and after the 2.4.2.15 Scsi_Device_Template::detachThis interface is used in the event that a low-level driver module is being unloaded, and we need to disconnect the physical devices from the upper level drivers. 2.5 Command
The There are a number of fields in the structure that are present purely as a convenience for low-level drivers. This should be recoded at some point, and use an abstract hostdata element at the end to contain the host-specific data. These structures are all allocated at the time of bus scan (or shortly thereafter). For each device, we look at the queue depth for the device (or the maximum number of commands per lun) and allocate up to this number. At runtime allocation and deallocation of these structures doesn't involve any communication with the memory manager. We simply look through the list and find a command block that is not in use and return it. When we free a block, we merely set the flag saying the command block is not in use. 2.5.1 Structure definition
2.5.2 Element descriptions2.5.2.1 Scsi_Cmnd::hostPointer to the 2.5.2.2 Scsi_Cmnd::stateIndicates the current status of this command block. It can take one of these values:
2.5.2.3 Scsi_Cmnd::ownerIndicates what part of the SCSI subsystem currently owns the command block. It can take one of the following values:
2.5.2.4 Scsi_Cmnd::devicePointer to the 2.5.2.5 Scsi_Cmnd::nextUsed to link together 2.5.2.6 Scsi_Cmnd::reset_chainThis field is used only by the BusLogic driver. Ask Leonard what it is used for. This should be abstracted into a hostdata field. 2.5.2.7 Scsi_Cmnd::eh_stateThis field is used by the error handler to record the internal state. It can currently take one of three values:
This field should not be used by low-level drivers, although I
notice that some low-level drivers are attempting to use this. If a low-level
driver needs to know why a command has failed, the 2.5.2.8 Scsi_Cmnd::doneThe 2.5.2.9 Scsi_Cmnd::serial_numberA sequence number for the command. Each new command that comes
through will have a unique sequence number. Note - the 2.5.2.10 Scsi_Cmnd::serial_number_at_timeoutWhen a command times out, the serial number is saved in this field. This can be of use if the command might have later completed before error recovery had started, however in the new error handling code this should not be a problem. 2.5.2.11 Scsi_Cmnd::retriesThe number of times we have retried the command. Only used during error recovery. 2.5.2.12 Scsi_Cmnd::allowedThe maximum number of retries allowed during error recovery. 2.5.2.13 Scsi_Cmnd::timeout_per_commandThe amount of time (in jiffies) that we will wait before we decide that a command has timed out. 2.5.2.14 Scsi_Cmnd::timeout_totalThis field is unused and should be removed from the structure. 2.5.2.15 Scsi_Cmnd::timeoutThis field is unused and should be removed from the structure. 2.5.2.16 Scsi_Cmnd::internal_timeoutThis field is used by the old error handling code to keep track of the current state of the command. Once the old error handling code is gone, this field can be removed. 2.5.2.17 Scsi_Cmnd::bh_nextThis field is used for the linked list of commands that are in the queue for the bottom half handler. 2.5.2.18 Scsi_Cmnd::targetThe SCSI ID of the device. This is somewhat redundant, in that we can also get the same information from device->id. 2.5.2.19 Scsi_Cmnd::lunThe SCSI logical unit number of the device. This is somewhat redundant, in that we can also get the same information from device->lun. 2.5.2.20 Scsi_Cmnd::channelThe channel number for the device. This is somewhat redundant, in that we can also get the same information from device->channel. 2.5.2.21 Scsi_Cmnd::cmd_lenThe length (number of bytes) of the SCSI command. Typically either 6, 10, or 12. 2.5.2.22 Scsi_Cmnd::old_cmd_lenSaved copy of the command length. Used during error recovery, as we sometimes need to issue other commands (REQUEST_SENSE, or TEST_UNIT_READY) before we finally retry the command itself. 2.5.2.23 Scsi_Cmnd::cmndThe SCSI command that needs to be sent to the device. This is normally initialized by the upper layer, however error recovery sometimes modifies the field. As far as low-level drivers are concerned, this is the command that the driver needs to try and run. 2.5.2.24 Scsi_Cmnd::request_bufflenThis is the saved buffer length associated with the request.
This is a copy of the 2.5.2.25 Scsi_Cmnd::eh_timeoutTimer structure used by error recovery. Should not be manipulated by low-level drivers. 2.5.2.26 Scsi_Cmnd::request_bufferThis is the saved buffer pointer associated with the request.
This will either point to the actual buffer, or in the event that scatter-gather
is in use it will point to the the scatter-gather table. This is a copy of the 2.5.2.27 Scsi_Cmnd::data_cmndThis is a saved copy of the 2.5.2.28 Scsi_Cmnd::old_use_sgThis is a saved copy of 2.5.2.29 Scsi_Cmnd::use_sgThis field indicates whether the command should use
scatter-gather or not. If 0, it means that the 2.5.2.30 Scsi_Cmnd::sglist_lenAmount of memory allocated for the scatter-gather list. Needed so that we know how much memory to free, when it comes time to release it. 2.5.2.31 Scsi_Cmnd::abort_reasonUsed by the old error handling code - indicates the reason that we are tring to abort a command. Either DID_TIME_OUT, or DID_RESET. 2.5.2.32 Scsi_Cmnd::bufflenIndicates the number of data bytes to be transferred by the I/O request. 2.5.2.33 Scsi_Cmnd::bufferIndicates the buffer to be used for the data transfer. In the event that scatter-gather is in use, this field indicates the address of the scatter-gather table. 2.5.2.34 Scsi_Cmnd::underflowIndicates the minimum number of bytes for data transfer - useful for underflow detection. Very few drivers actually use this. It is considered an error if fewer bytes than this are transferred. Set by the upper-level. 2.5.2.35 Scsi_Cmnd::transfersizeAmount of data that we are guaranteed to transfer with each SCSI transfer (between disconnect/reconnects). Usually the sector size. Generally only really dumb drivers need to worry about this. 2.5.2.36 Scsi_Cmnd::requestA copy of the request structure that this command is processing. This is useful during final post-processing when we need to mark buffers uptodate. 2.5.2.37 Scsi_Cmnd::sense_bufferIn the event of errors, this buffer contains the sense data. 2.5.2.38 Scsi_Cmnd::flagsThis is only used by the old error handling code, and indicates additional information about the command. Allowable values are:
2.5.2.39 Scsi_Cmnd::host_waitFor commands in the 2.5.2.40 Scsi_Cmnd::device_waitFor commands in the 2.5.2.41 Scsi_Cmnd::this_countIn theory this field should be the number of sectors being transferred. In practice it isn't used, and thus this field should be removed to simplify the code. It was supposed to be the number of 512 byte sectors. For larger sector sizes, it is just a multiplier. For devices with smaller sector sizes (256 bytes), it currently appears as if it will be impossible to request odd numbers of sectors. 2.5.2.42 Scsi_Cmnd::scsi_doneThis field holds the completion routine in the SCSI middle layer. In all cases, the function scsi_done() in the middle layer is this function, and thus it seems a little silly to obscure things in this way. This field shouldn't be removed until the rewrite of the upper layer is complete for Linux 2.3. 2.5.2.43 Scsi_Cmnd::SCpThis field is a pointer to a 2.5.2.44 Scsi_Cmnd::host_scribbleThis field is used as a pointer to a scratchpad area that low-level drivers can use as they wish. 2.5.2.45 Scsi_Cmnd::resultLow-level drivers will fill in this field with the status of the command prior to calling the mid-level completion routine. The status consists of the status_byte, the msg_byte, the host_byte, and the driver_byte.
2.5.2.46 Scsi_Cmnd::tagNot 100% sure on this one. I believe the purpose of this is to track how many tagged commands have been issued without a ORDERED_QUEUE_TAG (basically to flush the queue of any pending commands). 2.5.2.47 Scsi_Cmnd::pidA sort of sequence number for the command. Each new command
that comes through will have a unique pid. Note - the 2.6 Pointer2.6.1 Structure definition
2.6.2 Element descriptions2.6.2.1 Scsi_Pointer::ptr2.6.2.2 Scsi_Pointer::this_residual2.6.2.3 Scsi_Pointer::buffer2.6.2.4 Scsi_Pointer::buffers_residual2.6.2.5 Scsi_Pointer::Status2.6.2.6 Scsi_Pointer::Message2.6.2.7 Scsi_Pointer::have_data_in2.6.2.8 Scsi_Pointer::sent_command2.6.2.9 Scsi_Pointer::phase
If you have comments or suggestions, you can email me by clicking here Last updated: 4/99. |