[7772] in linux-scsi channel archive
Re: different definitions for status codes
daemon@ATHENA.MIT.EDU (Douglas Gilbert)
Thu Dec 30 09:13:42 1999
Message-ID: <386B6696.5C11935A@interlog.com>
Date: Thu, 30 Dec 1999 09:05:10 -0500
From: Douglas Gilbert <dgilbert@interlog.com>
MIME-Version: 1.0
To: Raju K V <raju.kurunkad@wipro.com>, linux-scsi@vger.rutgers.edu
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Raju K V wrote:
>
> hi,
>
> I have noticed that the status codes definitions in
> linux/include/scsi/scsi.h are right shifted by 1 bit.
>
> examples:
>
> In linux:
>
> #define COMMAND_TERMINATED 0x11
>
> In solaris(x86):
>
> #define STATUS_TERMINATED 0x22
>
> SCSI-II protocol:
>
> R R 1 0 0 0 1 R COMMAND TERMINATED
>
> Any reason for this?
This is a strange quirk of the Linux scsi sub-system.
The scsi status byte has 5 bits specified by the
standard and 3 reserved bits (bits 0, 6 and 7).
A lot of scsi code assumes the reserved bits will always
be zero but this is not safe. Some people come up with
horrible hacks to get around masking off those bits.
My favourite is:
if (scsi_status & 0x02)
for picking up either CHECK CONDITION or COMMAND TERMINATED.
[A future scsi standard could break a lot of code
if it used that bit in a new status code.]
So the definition of the masked_status (as it is called in
my version 3 sg driver which provides both) is:
masked_status == ((scsi_status & 0x3e) >> 1)
The rationale is that more sensible equality tests can be
done on masked_status than with the more error prone
scsi_status.
There probably should be a note about this in the
include/scsi.h header.
Doug Gilbert
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.rutgers.edu