* [Qemu-devel] [PATCH 03/16] scsi: Return SAM status codes
@ 2010-11-18 14:46 Hannes Reinecke
2010-11-19 18:33 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Hannes Reinecke @ 2010-11-18 14:46 UTC (permalink / raw)
To: qemu-devel; +Cc: stefanha, nab, kraxel
The SCSI emulation is supposed to return status codes as defined
by SAM, not the linux ones which are shifted by one.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
hw/scsi-defs.h | 20 +++++++++++---------
hw/scsi-generic.c | 10 +++++-----
2 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h
index a4a3518..1473ecb 100644
--- a/hw/scsi-defs.h
+++ b/hw/scsi-defs.h
@@ -111,18 +111,20 @@
#define BLANK 0xa1
/*
- * Status codes
+ * SAM Status codes
*/
#define GOOD 0x00
-#define CHECK_CONDITION 0x01
-#define CONDITION_GOOD 0x02
-#define BUSY 0x04
-#define INTERMEDIATE_GOOD 0x08
-#define INTERMEDIATE_C_GOOD 0x0a
-#define RESERVATION_CONFLICT 0x0c
-#define COMMAND_TERMINATED 0x11
-#define QUEUE_FULL 0x14
+#define CHECK_CONDITION 0x02
+#define CONDITION_GOOD 0x04
+#define BUSY 0x08
+#define INTERMEDIATE_GOOD 0x10
+#define INTERMEDIATE_C_GOOD 0x14
+#define RESERVATION_CONFLICT 0x18
+#define COMMAND_TERMINATED 0x22
+#define TASK_SET_FULL 0x28
+#define ACA_ACTIVE 0x30
+#define TASK_ABORTED 0x40
#define STATUS_MASK 0x3e
diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c
index 7212091..9be1cca 100644
--- a/hw/scsi-generic.c
+++ b/hw/scsi-generic.c
@@ -96,17 +96,17 @@ static void scsi_command_complete(void *opaque, int ret)
s->senselen = r->io_header.sb_len_wr;
if (ret != 0)
- r->req.status = BUSY << 1;
+ r->req.status = BUSY;
else {
if (s->driver_status & SG_ERR_DRIVER_TIMEOUT) {
- r->req.status = BUSY << 1;
+ r->req.status = BUSY;
BADF("Driver Timeout\n");
} else if (r->io_header.status)
r->req.status = r->io_header.status;
else if (s->driver_status & SG_ERR_DRIVER_SENSE)
- r->req.status = CHECK_CONDITION << 1;
+ r->req.status = CHECK_CONDITION;
else
- r->req.status = GOOD << 1;
+ r->req.status = GOOD;
}
DPRINTF("Command complete 0x%p tag=0x%x status=%d\n",
r, r->req.tag, r->req.status);
@@ -333,7 +333,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
s->senselen = 7;
s->driver_status = SG_ERR_DRIVER_SENSE;
bus = scsi_bus_from_device(d);
- bus->complete(bus, SCSI_REASON_DONE, tag, CHECK_CONDITION << 1);
+ bus->complete(bus, SCSI_REASON_DONE, tag, CHECK_CONDITION);
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH 03/16] scsi: Return SAM status codes
2010-11-18 14:46 [Qemu-devel] [PATCH 03/16] scsi: Return SAM status codes Hannes Reinecke
@ 2010-11-19 18:33 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2010-11-19 18:33 UTC (permalink / raw)
To: Hannes Reinecke; +Cc: stefanha, qemu-devel, nab, kraxel
On Thu, Nov 18, 2010 at 03:46:32PM +0100, Hannes Reinecke wrote:
>
> The SCSI emulation is supposed to return status codes as defined
> by SAM, not the linux ones which are shifted by one.
When just looking at the patch the description is rather confusing as
all places touched were already returning the correct value by doing
the opencoded shift. Only a little grepping reveals that there are
lots of other incorrect uses, too. You might consider mentioning
this in the patch description.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-19 18:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-18 14:46 [Qemu-devel] [PATCH 03/16] scsi: Return SAM status codes Hannes Reinecke
2010-11-19 18:33 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).