Fields in the tm_buf Structure
The tm_buf structure contains certain fields used to pass a received data buffer from the SCSI adapter device driver to the SCSI device driver. Other fields are used to pass returned status back to the SCSI device driver. After processing the data, the tm_buf structure is passed back from the SCSI device driver to the SCSI adapter device driver to allow the buffer to be reused.
The tm_buf structure is defined in the /usr/include/sys/scsi.h file and contains the following fields:
Note: Reserved fields must not be modified by the SCSI device driver,
unless noted otherwise. Nonreserved fields can be modified, except
where noted otherwise.
- The tm_correlator field is an optional field for the SCSI device driver. This field is a copy of the field with the same name that was passed by the SCSI device driver in the SCIOSTARTTGT ioctl. The SCSI device driver should use this field to speed the search for the target-mode device instance the tm_buf structure is associated with. Alternatively, the SCSI device driver can combine the tm_buf.user_id and tm_buf.adap_devno fields to find the associated device.
- The adap_devno field is the device major and minor numbers
of the adapter instance on which this target mode device is defined.
This field can be used to find the particular target-mode instance
the tm_buf structure is associated with. Note: The SCSI device driver must not modify this field.
- The data_addr field is the kernel space address where the data begins for this buffer.
- The data_len field is the length of valid data in the buffer starting at the tm_buf.data_addr location in memory.
- The user_flag field is a set of bit flags that can be
set to communicate information about this data buffer to the SCSI
device driver. Except where noted, one or more of the following flags
can be set:
- TM_HASDATA
- Set to indicate a valid tm_buf structure
- TM_MORE_DATA
- Set if more data is coming (that is, more tm_buf structures) for a particular send command. This is only possible for adapters that support spanning the send command data across multiple receive buffers. This flag cannot be used with the TM_ERROR flag.
- TM_ERROR
- Set if any error occurred on a particular send command. This flag cannot be used with the TM_MORE_DATA flag.
- The user_id field is set to the SCSI ID of the initiator
that sent the data to this target mode instance. If more than one
adapter is used for target mode in this system, this ID might not
be unique. Therefore, this field must be used in combination with
the tm_buf.adap_devno field to find the target-mode instance
this ID is associated with. Note: The SCSI device driver must not modify this field.
- The status_validity field contains the following bit
flag:
- SC_ADAPTER_ERROR
- Indicates the tm_buf.general_card_status is valid.
- The general_card_status field is a returned status field that gives a broad indication of the class of error encountered by the adapter. This field is valid when its status-validity bit is set in the tm_buf.status_validity field. The definition of this field is the same as that found in the sc_buf structure definition, except the SC_CMD_TIMEOUT value is not possible and is never returned for a target-mode transfer.
- The next field is a tm_buf pointer that is either null, meaning this is the only or last tm_buf structure, or else contains a non-null pointer to the next tm_buf structure.