Displaying 8 results from an estimated 8 matches for "scsi_build_sense".
2009 Oct 27
0
[PATCH 4/4] megasas: Add SCSI command emulation
...rection = SG_DXFER_NONE;
+ }
+ cmd->hdr.sbp = cmd->sense;
+ cmd->hdr.mx_sb_len = cmd->sense_len;
- ret = bdrv_ioctl(cmd->lun->bdrv, SG_IO, &cmd->hdr);
- if (ret) {
- DPRINTF("SCSI pthru dev %x lun %x failed with %d\n",
- target, lun, errno);
- sense_len = scsi_build_sense(cmd->sense, SENSE_IO_ERROR);
- cmd->sge_size = 0;
- scsi_status = SAM_STAT_CHECK_CONDITION;
- } else if (cmd->hdr.status) {
- sense_len = cmd->hdr.sb_len_wr;
- scsi_status = cmd->hdr.status;
- cmd->sge_size = cmd->hdr.dxfer_len;
- scsi_status = SAM_STAT_CHECK_CONDITION;
+ re...
2009 Oct 27
0
[PATCH 4/4] megasas: Add SCSI command emulation
...rection = SG_DXFER_NONE;
+ }
+ cmd->hdr.sbp = cmd->sense;
+ cmd->hdr.mx_sb_len = cmd->sense_len;
- ret = bdrv_ioctl(cmd->lun->bdrv, SG_IO, &cmd->hdr);
- if (ret) {
- DPRINTF("SCSI pthru dev %x lun %x failed with %d\n",
- target, lun, errno);
- sense_len = scsi_build_sense(cmd->sense, SENSE_IO_ERROR);
- cmd->sge_size = 0;
- scsi_status = SAM_STAT_CHECK_CONDITION;
- } else if (cmd->hdr.status) {
- sense_len = cmd->hdr.sb_len_wr;
- scsi_status = cmd->hdr.status;
- cmd->sge_size = cmd->hdr.dxfer_len;
- scsi_status = SAM_STAT_CHECK_CONDITION;
+ re...
2009 Oct 27
0
[PATCH 1/4] Add 'raid' interface class
...fine SCSI_DMA_BUF_SIZE 131072
#define SCSI_MAX_INQUIRY_LEN 256
+#define SCSI_SENSE_LEN 18
#define SCSI_REQ_STATUS_RETRY 0x01
@@ -136,6 +137,22 @@ static SCSIRequest *scsi_find_request(SCSIDiskState *s, uint32_t tag)
return r;
}
+/* Helper function to build a sense block */
+int32_t scsi_build_sense(uint8_t *sense_buf, uint32_t sense)
+{
+ memset(sense_buf, 0, SCSI_SENSE_LEN);
+ if (!sense)
+ return 0;
+
+ sense_buf[0] = 0xf0; /* current, fixed format */
+ sense_buf[2] = (sense >> 16) & 0x0F;
+ sense_buf[7] = 10;
+ sense_buf[12] = (sense >> 8 ) & 0xF...
2009 Oct 27
0
[PATCH 1/4] Add 'raid' interface class
...fine SCSI_DMA_BUF_SIZE 131072
#define SCSI_MAX_INQUIRY_LEN 256
+#define SCSI_SENSE_LEN 18
#define SCSI_REQ_STATUS_RETRY 0x01
@@ -136,6 +137,22 @@ static SCSIRequest *scsi_find_request(SCSIDiskState *s, uint32_t tag)
return r;
}
+/* Helper function to build a sense block */
+int32_t scsi_build_sense(uint8_t *sense_buf, uint32_t sense)
+{
+ memset(sense_buf, 0, SCSI_SENSE_LEN);
+ if (!sense)
+ return 0;
+
+ sense_buf[0] = 0xf0; /* current, fixed format */
+ sense_buf[2] = (sense >> 16) & 0x0F;
+ sense_buf[7] = 10;
+ sense_buf[12] = (sense >> 8 ) & 0xF...
2009 Oct 27
1
[PATCH 2/4] megasas: LSI MegaRAID SAS HBA emulation
...unt(cmd->pa);
+ cdb_len = megasas_frame_get(cmd->pa, CDB_LEN);
+ megasas_map_sense(cmd);
+
+ if (cdb_len > 16) {
+ DPRINTF("SCSI %s dev %x/%x invalid cdb len %d\n",
+ (fcmd == MFI_CMD_PD_SCSI_IO) ? "PD" : "LD",
+ target, lun, cdb_len);
+ sense_len = scsi_build_sense(cmd->sense, SENSE_INVALID_OPCODE);
+ megasas_unmap_sense(cmd, sense_len);
+ megasas_frame_set_scsi_status(cmd->pa, SAM_STAT_CHECK_CONDITION);
+ return MFI_STAT_SCSI_DONE_WITH_ERROR;
+ }
+
+ cpu_physical_memory_read(cmd->pa + 0x20, (uint8_t *)cdb, 16);
+
+ /* The current Qemu infra...
2009 Oct 27
1
[PATCH 2/4] megasas: LSI MegaRAID SAS HBA emulation
...unt(cmd->pa);
+ cdb_len = megasas_frame_get(cmd->pa, CDB_LEN);
+ megasas_map_sense(cmd);
+
+ if (cdb_len > 16) {
+ DPRINTF("SCSI %s dev %x/%x invalid cdb len %d\n",
+ (fcmd == MFI_CMD_PD_SCSI_IO) ? "PD" : "LD",
+ target, lun, cdb_len);
+ sense_len = scsi_build_sense(cmd->sense, SENSE_INVALID_OPCODE);
+ megasas_unmap_sense(cmd, sense_len);
+ megasas_frame_set_scsi_status(cmd->pa, SAM_STAT_CHECK_CONDITION);
+ return MFI_STAT_SCSI_DONE_WITH_ERROR;
+ }
+
+ cpu_physical_memory_read(cmd->pa + 0x20, (uint8_t *)cdb, 16);
+
+ /* The current Qemu infra...
2009 Oct 27
2
[PATCH 3/4] scsi-disk: Factor out SCSI command emulation
...E;
+ }
+ return r->iov;
+}
+
static SCSIRequest *scsi_find_request(SCSIDiskState *s, uint32_t tag)
{
SCSIRequest *r;
@@ -137,12 +148,11 @@ static SCSIRequest *scsi_find_request(SCSIDiskState *s, uint32_t tag)
return r;
}
-/* Helper function to build a sense block */
int32_t scsi_build_sense(uint8_t *sense_buf, uint32_t sense)
{
memset(sense_buf, 0, SCSI_SENSE_LEN);
if (!sense)
- return 0;
+ return 0;
sense_buf[0] = 0xf0; /* current, fixed format */
sense_buf[2] = (sense >> 16) & 0x0F;
@@ -154,15 +164,19 @@ int32_t scsi_build_sense(uint8_t *sense_...
2009 Oct 27
2
[PATCH 3/4] scsi-disk: Factor out SCSI command emulation
...E;
+ }
+ return r->iov;
+}
+
static SCSIRequest *scsi_find_request(SCSIDiskState *s, uint32_t tag)
{
SCSIRequest *r;
@@ -137,12 +148,11 @@ static SCSIRequest *scsi_find_request(SCSIDiskState *s, uint32_t tag)
return r;
}
-/* Helper function to build a sense block */
int32_t scsi_build_sense(uint8_t *sense_buf, uint32_t sense)
{
memset(sense_buf, 0, SCSI_SENSE_LEN);
if (!sense)
- return 0;
+ return 0;
sense_buf[0] = 0xf0; /* current, fixed format */
sense_buf[2] = (sense >> 16) & 0x0F;
@@ -154,15 +164,19 @@ int32_t scsi_build_sense(uint8_t *sense_...