none
Variable length CDBs and extended CDBs (XCDB) RRS feed

  • Question

  • How can I send a variable length or extended CDB to a SCSI device?  Both the SCSI_PASS_THROUGH and SCSI_PASS_THROUGH_DIRECT structures declare the CDB element as 16 bytes.  I have searched the documentation and I did not find any references to CDBs larger than 16 bytes.



    Wednesday, April 6, 2011 8:02 PM

Answers

  • Because CDB's are FIXED length of 6, 10, 12, 16, or 32. You specify the size of the CDB, mostly by the SCSI command you use which defines variants for the size of CDB to use. As to using pass through one of the parameters in the pass through data structure you set up is the LENGTH of the CDB. 32 byte CDBs require a higher end HBA, such as an LSI 6GB SAS controller.
    Gary G. Little NanoTelesis Systems, LLC
    Thursday, April 7, 2011 12:49 AM
  • Got it. Mark or Don may may pop in with another answer, but I doubt you're going to do this with a standard SCSI pass through structure. Given an HBA with that capability such as an LSI SAS controller your other alternative is the IOCTL_SCSI_MINIPORT. You'll need to contact the OEM for your HBA to acquire information you will need to fill in the SRB_IO_CONTROL structure, but using it you will be able to send any CDB, any SIZE CDB, to the HBA that is supported by that HBA. Like SCSI pass through all IO is synchronous, limited to 64K block sizes, and unlike standard pass through there is not a _DIRECT variant, so all data buffers are offsets from SRB_IO_CONTROL.


    Gary G. Little NanoTelesis Systems, LLC
    • Marked as answer by xanthochroid1 Thursday, April 5, 2012 12:31 AM
    Thursday, April 7, 2011 6:16 PM

All replies

  • Because CDB's are FIXED length of 6, 10, 12, 16, or 32. You specify the size of the CDB, mostly by the SCSI command you use which defines variants for the size of CDB to use. As to using pass through one of the parameters in the pass through data structure you set up is the LENGTH of the CDB. 32 byte CDBs require a higher end HBA, such as an LSI 6GB SAS controller.
    Gary G. Little NanoTelesis Systems, LLC
    Thursday, April 7, 2011 12:49 AM
  • SCSI Primary Commands - 4 defines a variable length CDB format with a one-byte field for additional CDB length that effectively allows up to 252 additional bytes; and SPC-4 also defines an extended CDB (XCDB) that provides a 2 byte field for the length.  Even for the fixed length of 32 the SPTI structures in ntddscsi.h do not allow for more than 16 bytes in the CDB e.g.,

    typedef struct _SCSI_PASS_THROUGH_DIRECT {
        USHORT Length;
        UCHAR ScsiStatus;
        UCHAR PathId;
        UCHAR TargetId;
        UCHAR Lun;
        UCHAR CdbLength;
        UCHAR SenseInfoLength;
        UCHAR DataIn;
        ULONG DataTransferLength;
        ULONG TimeOutValue;
        PVOID DataBuffer;
        ULONG SenseInfoOffset;
        UCHAR Cdb[16];
    }SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;

    So my question, more specifically, is; what IOCTL code and structure do I use in the DeviceIoControl call to pass a variable length DATA_IN CDB to a SCSI device?
    Thursday, April 7, 2011 2:03 AM
  • The IOCTL would be an IOCT_SCSI_PASS_THROUGH variant. You define a CDB, plug it into the fields of the SCSI_PASS_THROUGH_DIRECT structure and pass it to DeviceIoControl. Works fine. I do that hundreds of time a day in the code I am currently developing.

    CDB length is dependent upon the SCSI command used; e.g. MODE(6), MODE(10). Specifically, 04h is the FORMAT UNIT command defined in the January 2011 SBC. The CDB and CDB length are both defined in the SCSI pass through structure. The CDB will contain the transfer length of the data, and the starting logical block address of the media. The command referenced, at least in my January 2011 copy of the SCSI specs from the T-10 committee, defines command 04h as the FORMAT UNIT command, and looking at the command description I see it defined as a 6 byte CDB. SCSI_PASS_THROUGH_DIRECT is going to use a 6, 10, 12, or 16 byte CDB, again depending upon the SCSI command, with the 16 byte CDB requiring an HBA that supports that CDB size.

    SCSI is an initiator/target protocol that is dependent upon the initiator to do anything. The initiator requests N bytes to be transferred to or from the target and the target is going to transfer N bytes. Period. If it can't then a CHECK CONDITION is going to be generated and a sense buffer returned with SCSI status set appropriately.


    Gary G. Little NanoTelesis Systems, LLC
    Thursday, April 7, 2011 12:40 PM
  • First of all, thank you for your interest, I do appreciate that you are trying to help.  However, I am not having difficulty with the fixed length CDB format.  Please refer to section 4.3.3 of the T-10 spec for a description of the variable length CDB format.  I cannot use the standard SCSI_PASS_THROUGH_DIRECT structure without over-running the UCHAR Cdb[16] buffer.  I was hoping to find a documented method, if it exists, for sending CDBs in excess of 16 bytes (my need is for up to 68 bytes).
    Thursday, April 7, 2011 5:04 PM
  • Got it. Mark or Don may may pop in with another answer, but I doubt you're going to do this with a standard SCSI pass through structure. Given an HBA with that capability such as an LSI SAS controller your other alternative is the IOCTL_SCSI_MINIPORT. You'll need to contact the OEM for your HBA to acquire information you will need to fill in the SRB_IO_CONTROL structure, but using it you will be able to send any CDB, any SIZE CDB, to the HBA that is supported by that HBA. Like SCSI pass through all IO is synchronous, limited to 64K block sizes, and unlike standard pass through there is not a _DIRECT variant, so all data buffers are offsets from SRB_IO_CONTROL.


    Gary G. Little NanoTelesis Systems, LLC
    • Marked as answer by xanthochroid1 Thursday, April 5, 2012 12:31 AM
    Thursday, April 7, 2011 6:16 PM