Re: [PATCH 000/117] Make better use of static type checking

Douglas Gilbert
2021-04-20T17:19:50Z

On 2021-04-20 12:12 p.m., Bart Van Assche wrote:
> On 4/19/21 11:04 PM, Hannes Reinecke wrote:
>> We should not try to preserve the split SCSI result value with its four
>> distinct fields.
>
> I don't think that we have the freedom to drop the four byte SCSI result
> entirely since multiple user space APIs use that data structure. The
> four-byte SCSI result value is embedded in the following user space API
> data structures (there may be others):
> * struct sg_io_v4, the SG_IO header includes the driver_status
> (driver_byte()), transport_status (host_byte()) and device_status
> (scsi_status & 0xff) (the message byte is not included).

The sg_io_v4 interface was specifically designed to _decouple_ the
user visible API from the kernel's 4-bytes-in-1-int representation.
So there are 4 levels of error reporting supported:
1) from the kernel front-end: yield an errno
2) from the driver (LLD): set driver_status
3) from the transport: set transport status
4) from the device (target or LU): set device_status

Those distinctions aren't that strict, there is some overlap (e.g.
timeouts). The sg version 3 interface (struct sg_io_hdr) is similar
but the names are less generic.

Can't remember if anyone every complained to me about not having
access to the message byte from SPI.

Doug Gilbert