9. Target Mode Target Mode functionality will be optional in the CAM environment. If a Target Mode function is specified by a CCB and this functionality is not provided by a particular implementation of CAM, then a CAM Status of Function Not Implemented shall be returned in the CCB. This function causes the HBA associated with the specified SCSI link to be set up so that it may be selected as a target i.e. when an HBA is operating in Target mode, it is responding to other HBAs on the same SCSI cable. The only difference between a target mode CCB and an initiator mode CCB is that it is desirable that the target CCB be issued and pending before the corresponding command is received from the initiator. Target Mode transfers use the same control block as used for the Execute SCSI I/O Function, except as noted in the following sections. The Function Codes for Target Mode operation are listed in Table 9-1. TABLE 9-1 TARGET MODE FUNCTION CODES /-----\ | Code| |--------------------------------------------\ | 10h | Wait For Selection | | 11h | Release SCSI Bus | | 12h | Get SCSI CDB | | 13h | Get Data | | 14h | Get Message | | 15h | Send Status | | 16h | Send Data | | 17h | Send Message | | 18h | Reselect | |19-1F| reserved | \--------------------------------------------/ 9.1 Wait For Selection The specified Target ID shall match that returned by the HBA Inquiry Function for the HBA. The specified LUN is the one enabled for selection, and if the HBA is to respond as a additional LUN, another Wait For Selection is required. The XPT shall hold this request until the specified Target ID and LUN is selected on the SCSI link specified by the Path ID field. The Identify MSG is automatically requested by the XPT in order to perform routing and verification. While the request is being held, the CAM Status field will be set to Request in Progress. TABLE 9-2 WAIT FOR SELECTION CCB /--------------\ |Offst|Size|Dir| |-----------------------------------------------------\ | | 2 | O | CAM Control Block Length | | | 1 | O | Function Code | | | 1 | I | CAM Status | | | 1 | I | SCSI Status | | | 1 | O | Path ID | | | 4 |I/O| CAM Flags | | | 1 | O | Target ID | | | 1 | O | Target LUN | | | 1 | I | Initiator ID | | | 4 | O | Callback on Completion | \-----------------------------------------------------/ In addition, the Disable Disconnect bit in the CAM Flags field will be used to indicate the state of the DiscPriv bit in the Identify message that was received from the initiator. If the DiscPriv bit was set, then the Disable Disconnect bit will be set, and vice versa. Also, the Initiator ID field will contain the SCSI ID of the Initiator that selected this target. If the LUNTAR bit (or any of the reserved bits) is set to 1, then the XPT/SIM will send a MESSAGE REJECT message back to the initiator. This function shall return non-zero CAM Status. - CAM Status of Request Completed Without Error indicates that the specified LUN has been selected. - CAM Status of CAM Busy indicates that there is currently a Wait For Selection function pending on the specified LUN. - CAM Status of Invalid Request indicates that there is currently a nexus established with an initiator that must be terminated, first. - CAM Status of Invalid Path ID indicates that the Path ID is invalid. - CAM Status of ATN Raised indicates that the initiator raised the ATN signal after the Identify MSG was received. - CAM Status of Invalid Target ID indicates that the Target ID does not match that used by the HBA specified by the Path ID field. - CAM Status of Invalid LUN indicates that the LUN specified is outside of the range zero to seven. - CAM Status of Function Not Implemented indicates that Target Mode is not supported by this implementation of CAM. 9.2 Release SCSI Bus The XPT shall release the SCSI bus, allowing it to go to a Bus Free state. Target Mode is then disabled for the specified Path ID, Target ID, and Target LUN. TABLE 9-3 RELEASE SCSI BUS CCB /--------------\ |Offst|Size|Dir| |-----------------------------------------------------\ | | 2 | O | CAM Control Block Length | | | 1 | O | Function Code | | | 1 | I | CAM Status | | | 1 | I | SCSI Status | | | 1 | O | Path ID | | | 4 | O | CAM Flags | | | 1 | O | Target ID | | | 1 | O | Target LUN | \-----------------------------------------------------/ This function shall return non-zero CAM Status. - CAM Status of Request Completed Without Error indicates that the Target has released the specified SCSI bus. - CAM Status of Invalid Path ID indicates that the Path ID is invalid. - CAM Status of Nexus Not Established indicates that an initiator has not selected the specified Target ID and Target LUN on the specified SCSI bus. - CAM Status of Invalid Target ID indicates that the Target ID does not match that used by the HBA specified by the Path ID field. - CAM Status of Invalid LUN indicates that the LUN specified is outside of the range zero to seven. - CAM Status of Function Not Implemented indicates that Target Mode is not supported by this implementation of CAM. 9.3 Get SCSI CDB It shall then request the SCSI CDB from the initiator and place it in the CDB field of the CCB. The CDB and CDB Length fields will be filled in by the XPT/SIM before the request completes. TABLE 9-4 GET SCSI CDB CCB /--------------\ |Offst|Size|Dir| |-----------------------------------------------------\ | | 2 | O | CAM Control Block Length | | | 1 | O | Function Code | | | 1 | I | CAM Status | | | 1 | I | SCSI Status | | | 1 | O | Path ID | | | 4 | O | CAM Flags | | | 1 | O | Target ID | | | 1 | O | Target LUN | | | 2 | I | CDB Length | | | 12 | I | CDB | | | 4 | O | Callback on Completion | \-----------------------------------------------------/ This function shall return non-zero CAM Status. - CAM Status of Request Completed Without Error indicates that the Target has successfully received the CDB. - CAM Status of ATN Raised indicates that the initiator raised the ATN signal during the Command Phase. The Command Phase completed successfully. - CAM Status of Nexus Not Established indicates that an initiator has not selected the specified Target ID and Target LUN on the specified SCSI bus. - CAM Status of Invalid Path ID indicates that the Path ID is invalid. - CAM Status of Invalid Target ID indicates that the Target ID does not match that used by the HBA specified by the Path ID field. - CAM Status of Invalid LUN indicates that the LUN specified is outside of the range zero to seven. - CAM Status of Function Not Implemented indicates that Target Mode is not supported by this implementation of CAM. 9.4 Get Data The XPT shall initiate a Data Out phase to transfer data from the current initiator into the specified data buffer. TABLE 9-5 GET DATA CCB /--------------\ |Offst|Size|Dir| |-----------------------------------------------------\ | | 2 | O | CAM Control Block Length | | | 1 | O | Function Code | | | 1 | I | CAM Status | | | 1 | I | SCSI Status | | | 1 | O | Path ID | | | 4 | O | CAM Flags | | | 1 | O | Target ID | | | 1 | O | Target LUN | | | 2 | O | SG List Length | | | 4 |I/O| Data Transfer Length | | | 4 | O | SG List/Data Buffer Pointer | | | 4 | O | Callback on Completion | \-----------------------------------------------------/ This function shall return non-zero CAM Status. - CAM Status of Request Completed Without Error indicates that the requested number of bytes has been received. - CAM Status of Invalid Path ID indicates that the Path ID is invalid. - CAM Status of Nexus Not Established indicates that an initiator has not selected the specified Target ID and Target LUN on the specified SCSI bus. - CAM Status of ATN Raised indicates that the initiator raised the ATN signal during the data transfer. The data transfer was completed successfully. - CAM Status of Invalid Target ID indicates that the Target ID does not match that used by the HBA specified by the Path ID field. - CAM Status of Invalid LUN indicates that the LUN specified is outside of the range zero to seven. - CAM Status of Function Not Implemented indicates that Target Mode is not supported by this implementation of CAM. 9.5 Get Message The XPT shall initiate a MSG Out phase to transfer data from the current initiator into the Message field. The number of MSG bytes transferred will be placed in the MSG Length field. TABLE 9-6 GET MESSAGE CCB /--------------\ |Offst|Size|Dir| |-----------------------------------------------------\ | | 2 | O | CAM Control Block Length | | | 1 | O | Function Code | | | 1 | I | CAM Status | | | 1 | I | SCSI Status | | | 1 | O | Path ID | | | 4 | O | CAM Flags | | | 1 | O | Target ID | | | 1 | O | Target LUN | | | 2 | I | MSG Length | | | 8 | I | Message | | | 4 | O | Callback on Completion | \-----------------------------------------------------/ This function shall return non-zero CAM Status. - CAM Status of Request Completed Without Error indicates that the message has been successfully received. - CAM Status of Invalid Path ID indicates that the Path ID is invalid. - CAM Status of Nexus Not Established indicates that an initiator has not selected the specified Target ID and Target LUN on the specified SCSI bus. - CAM Status of ATN Raised indicates that the initiator raised the ATN signal during the Message Out Phase. - CAM Status of Invalid Target ID indicates that the Target ID does not match that used by the HBA specified by the Path ID field. - CAM Status of Invalid LUN indicates that the LUN specified is outside of the range zero to seven. - CAM Status of Function Not Implemented indicates that Target Mode is not supported by this implementation of CAM. 9.6 Send Status The XPT shall send the status byte specified in the SCSI Status field to the current initiator. TABLE 9-7 SEND STATUS CCB /--------------\ |Offst|Size|Dir| |-----------------------------------------------------\ | | 2 | O | CAM Control Block Length | | | 1 | O | Function Code | | | 1 | I | CAM Status | | | 1 | O | SCSI Status | | | 1 | O | Path ID | | | 4 | O | CAM Flags | | | 1 | O | Target ID | | | 1 | O | Target LUN | | | 4 | O | Callback on Completion | \-----------------------------------------------------/ This function shall return non-zero CAM Status. - CAM Status of Request Completed Without Error indicates that the Status byte was successfully sent to the Initiator. - CAM Status of Invalid Path ID indicates that the Path ID is invalid. - CAM Status of Nexus Not Established indicates that an initiator has not selected the specified Target ID and Target LUN on the specified SCSI bus. - CAM Status of ATN Raised indicates that the initiator raised the ATN signal during the Status Phase. - CAM Status of Invalid Target ID indicates that the Target ID does not match that used by the HBA specified by the Path ID field. - CAM Status of Invalid LUN indicates that the LUN specified is outside of the range zero to seven. - CAM Status of Function Not Implemented indicates that Target Mode is not supported by this implementation of CAM. 9.7 Send Data The XPT shall initiate a Data IN phase to transfer data to the current initiator from the specified data buffer. TABLE 9-8 SEND DATA CCB /--------------\ |Offst|Size|Dir| |-----------------------------------------------------\ | | 2 | O | CAM Control Block Length | | | 1 | O | Function Code | | | 1 | I | CAM Status | | | 1 | I | SCSI Status | | | 1 | O | Path ID | | | 4 | O | CAM Flags | | | 1 | O | Target ID | | | 1 | O | Target LUN | | | 2 | O | SG List Length | | | 4 |I/O| Data Transfer Length | | | 4 | O | SG List/Data Buffer Pointer | | | 4 | O | Callback on Completion | \-----------------------------------------------------/ This function shall return non-zero CAM Status. - CAM Status of Request Completed Without Error indicates that the specified number of bytes has been sent. - CAM Status of Invalid Path ID indicates that the Path ID is invalid. - CAM Status of Nexus Not Established indicates that an initiator has not selected the specified Target ID and Target LUN on the specified SCSI bus. - CAM Status of ATN Raised indicates that the initiator raised the ATN signal during the data transfer. The data transfer was completed successfully. - CAM Status of Invalid Target ID indicates that the Target ID does not match that used by the HBA specified by the Path ID field. - CAM Status of Invalid LUN indicates that the LUN specified is outside of the range zero to seven. - CAM Status of Function Not Implemented indicates that Target Mode is not supported by this implementation of CAM. 9.8 Send Message The XPT shall send the bytes specified in the Message field to the current initiator. TABLE 9-9 SEND MESSAGE CCB /--------------\ |Offst|Size|Dir| |-----------------------------------------------------\ | | 2 | O | CAM Control Block Length | | | 1 | O | Function Code | | | 1 | I | CAM Status | | | 1 | I | SCSI Status | | | 1 | O | Path ID | | | 4 | O | CAM Flags | | | 1 | O | Target ID | | | 1 | O | Target LUN | | | 2 | O | MSG Length | | | 8 | O | Message | | | 4 | O | Callback on Completion | \-----------------------------------------------------/ This function shall return non-zero CAM Status. - CAM Status of Request Completed Without Error indicates that the supplied message bytes have been successfully sent to the Initiator. - CAM Status of Invalid Path ID indicates that the Path ID is invalid. - CAM Status of Nexus Not Established indicates that an initiator has not selected the specified Target ID and Target LUN on the specified SCSI bus. - CAM Status of ATN Raised indicates that the initiator raised the ATN signal during the Message In Phase. - CAM Status of Invalid Target ID indicates that the Target ID does not match that used by the HBA specified by the Path ID field. - CAM Status of Invalid LUN indicates that the LUN specified is outside of the range zero to seven. - CAM Status of Function Not Implemented indicates that Target Mode is not supported by this implementation of CAM. 9.9 Reselect The XPT shall reselect the specified initiator. TABLE 9-10 RESELECT CCB /--------------\ |Offst|Size|Dir| |-----------------------------------------------------\ | | 2 | O | CAM Control Block Length | | | 1 | O | Function Code | | | 1 | I | CAM Status | | | 1 | I | SCSI Status | | | 1 | O | Path ID | | | 4 | O | CAM Flags | | | 1 | O | Target ID | | | 1 | O | Target LUN | | | 1 | O | Initiator ID | | | 4 | O | Callback on Completion | \-----------------------------------------------------/ This function shall return non-zero CAM Status. - CAM Status of Request Completed Without Error indicates that the reselection was successfully performed. - CAM Status of Invalid Path ID indicates that the Path ID is invalid. - CAM Status of Nexus Not Established indicates that an initiator has not selected the specified Target ID and Target LUN on the specified SCSI bus. - CAM Status of ATN Raised indicates that the initiator raised the ATN signal during the reselection phase. - CAM Status of Invalid Target ID indicates that the Target ID does not match that used by the HBA specified by the Path ID field. - CAM Status of Invalid LUN indicates that the LUN specified is outside of the range zero to seven. - CAM Status of Invalid Initiator ID indicates that the specified Initiator ID is outside of the range zero to seven. - CAM Status of Function Not Implemented indicates that Target Mode is not supported by this implementation of CAM. IMPLEMENTOR'S NOTES 1) If a BUS DEVICE RESET message is the first message received after selection (checked for in the selection routines), or is received at any time (checked for in the routines that handle the Get Message function), then the XPT/SIM should perform the following: - for all LUNS: if any function is pending, give error status (SCSI Bus Reset Sent/Received) otherwise, set flag so that error status can be returned for the next function. Once the status has been returned, reset the flag. 2) The following are new CAM Status codes that must be assigned values. INVALID LUN - indicates that the specified LUN is outside the range of zero to seven. INVALID TARGET ID - indicates that the ID specified does not match the ID for the HBA specified by the Path ID. FUNCTION NOT IMPLEMENTED - indicates that the desired function is not implemented. NEXUS NOT ESTABLISHED - indicates that there is currently no connection established between the specified Target ID and Target LUN and any initiator. ATN RAISED - indicates that the ATN signal was raised by the initiator during the execution of this request. INVALID INITIATOR ID - indicates that the initiator ID specified is outside of the range of zero to seven. [IMPLEMENTOR'S NOTE: an implementor can also return this status if the target tries to reselect an initiator other than the one to which he was previously connected.] IMPLEMENTOR'S NOTES 3) XPT/SIM must handle the following: 1) If the target is selected and no "Wait For Selection" CCBs are queued at the XPT/SIM, then there is no need to respond to the selection. 2) If "Wait For Selection" CCBs are queued at the XPT/SIM, and an LUN is selected that does not have a "Wait For Selection" CCB pending, then the XPT/SIM must provide the following support: a) If an Inquiry command is sent to this LUN, then the XPT/SIM should respond with data that indicates "LUN Not Supported" as indicated in Section 6.5.3 of the SCSI-2 Draft Standard. b) If any other command (except Request Sense) is sent to this LUN, then the XPT/SIM should respond with a check condition. c) If a Request Sense command is sent to this LUN after a check condition is set, then the XPT/SIM should respond with sense data that indicates "Logical Unit Not Supported". See Section 6.5.3 of the SCSI-2 Draft Standard for further information.