3

I'm developing a SCSI target software (and I'm new to SCSI) and I need to return correct sense data to tell initiator, that its request didn't go through because data were protected from writing. I'm looking at the piece of table from T10.org, describing these codes:

ASC/   .  .  .  .  .
ASCQ   DTLPWROMAEBKVF  Description
27/00  DT  WRO   BK    WRITE PROTECTED
27/01  DT  WRO   BK    HARDWARE WRITE PROTECTED
27/02  DT  WRO   BK    LOGICAL UNIT SOFTWARE WRITE PROTECTED
27/03   T   R          ASSOCIATED WRITE PROTECT
27/04   T   R          PERSISTENT WRITE PROTECT
27/05   T   R          PERMANENT WRITE PROTECT
27/06       R       F  CONDITIONAL WRITE PROTECT
27/07  D         B     SPACE ALLOCATION FAILED WRITE PROTECT

What's the meaning of these various ASCQ codes? I couldn't find any explanations anywhere. Three or four words like "PERSISTENT WRITE PROTECT" is a max what I can find. I'd like to know something like "if you have a situation like this, then you need to use ASCQ = that".

HEKTO
  • 3,876
  • 2
  • 24
  • 45

3 Answers3

3

There is no right and wrong in this area, there are some basic guidelines that you can glean by seeing what ASC/ASCQ codes are returned with different sense keys for normal disks. Hitachi are the best about documenting these in open documentation.

The only thing that is really important to get right is the Sense Key, the ASC/ASCQ is nice to have but its only importance is for you. When a customer calls you and tells you "I did this and got that error code, what does it mean?" You need to be able to help him. That's the only real importance of these codes.

Baruch Even
  • 2,581
  • 1
  • 17
  • 23
  • 1
    Baruch has the best answer. One area where the ASC/ASCQ can come into play programmatically is determining stuff like if the medium is ejected, or not formatted, and potentially acting on it. But, even on good days, different vendors won't really agree on when to return those, and you'll just get a NOT READY or MEDIUM ERROR sense key. Mostly, the uses of ASC/ASCQ are peppered throughout the specifications. You get to discover them one at a time. :) – Mike Andrews Apr 22 '15 at 14:48
2

There's a list of these codes here on the T10.org website under the page titled: SCSI ASC/ASCQ Assignments.

This page also describes their purpose, titled: SCSI Additional Sense Data.

SCSI Additional Sense Data takes the form of two value encoded bytes in the sense data, typically returned by the REQUEST SENSE command. The additional sense code (ASC) byte indicates information about the error exception reported in the sense key field. The additional sense code qualifier (ASCQ) indicates detailed information related to the additional sense code. See the clause describing the REQUEST SENSE command in the SCSI Primary Commands - 4 (SPC-4) draft standard (or later) for more information about sense data.

Descriptions of the assigned ASC and ASCQ values and their coded meanings are organized in tables that are sorted numerically based on the ASC/ASCQ values or alphabetically based on the text describing the error or exception indicated by the ASC/ASCQ pair. An explanation of the ASC/ASCQ table format is available if you are unfamiliar with these tables.

Additionally I'd take a look at the Wikipedia page topic titled: Key Code Qualifier, which had this to say about these codes.

Key Code Qualifier is an error-code returned by a SCSI device. When a SCSI target device returns a check condition in response to a command, the initiator usually then issues a SCSI Request Sense command. This process is part of a SCSI protocol called Contingent Allegiance Condition. The target will respond to the Request Sense command with a set of SCSI sense data which includes three fields giving increasing levels of detail about the error:

  • K - sense key - 4 bits, (byte 2 of Fixed sense data format)
  • C - additional sense code (ASC) - 8 bits, (byte 12 of Fixed sense data format)
  • Q - additional sense code qualifier (ASCQ) - 8 bits, (byte 13 of Fixed sense data format)

The initiator can take action based on just the K field which indicates if the error is minor or major. However all three fields are usually logically combined into a 20 bit field called Key Code Qualifier or KCQ. The specification for the target device will define the list of possible KCQ values. In practice there are many KCQ values which are common between different SCSI device types and different SCSI device vendors. Common values are listed below, you should consult your hardware specific documentation as well.

slm
  • 15,396
  • 12
  • 109
  • 124
  • Sorry to say, these pages contain only three or four words per ASC/ASCQ, but I needed more detailed explanation (actually I've copied a part of a page from T10.org to my question). – HEKTO Apr 23 '14 at 22:19
  • @AlekseyYakovlev - see update and let me know if the edit helps. – slm Apr 23 '14 at 23:16
0

In very simple terms , ASCQ codes are typically present in Response frames from SCSI target devices . ASCQ code describes additional sense data or typically known as reasons for certain condition occurred in the device.