qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Hannes Reinecke <hare@suse.de>,
	Andreas Faerber <afaerber@suse.de>,
	Nic Bellinger <nab@linux-iscsi.org>,
	Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [PATCH 02/13] megasas: fixup MFI_DCMD_LD_LIST_QUERY
Date: Wed, 29 Oct 2014 13:00:05 +0100	[thread overview]
Message-ID: <1414584016-25888-3-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1414584016-25888-1-git-send-email-hare@suse.de>

The MFI_DCMD_LD_LIST_QUERY function is using a different format than
MFI_DCMD_LD_LIST, so we need to implement it differently.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 hw/scsi/megasas.c | 37 ++++++++++++++++++++++++++++++++++---
 hw/scsi/mfi.h     |  7 +++++++
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index eedc992..9b9f2d3 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -1124,15 +1124,46 @@ static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd)
 static int megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd)
 {
     uint16_t flags;
+    struct mfi_ld_targetid_list info;
+    size_t dcmd_size = sizeof(info), resid;
+    uint32_t num_ld_disks = 0, max_ld_disks = s->fw_luns;
+    BusChild *kid;
 
     /* mbox0 contains flags */
     flags = le16_to_cpu(cmd->frame->dcmd.mbox[0]);
     trace_megasas_dcmd_ld_list_query(cmd->index, flags);
-    if (flags == MR_LD_QUERY_TYPE_ALL ||
-        flags == MR_LD_QUERY_TYPE_EXPOSED_TO_HOST) {
-        return megasas_dcmd_ld_get_list(s, cmd);
+    if (flags != MR_LD_QUERY_TYPE_ALL &&
+        flags != MR_LD_QUERY_TYPE_EXPOSED_TO_HOST) {
+        max_ld_disks = 0;
+    }
+
+    memset(&info, 0, dcmd_size);
+    if (cmd->iov_size < 12) {
+        trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size,
+                                            dcmd_size);
+        return MFI_STAT_INVALID_PARAMETER;
+    }
+    dcmd_size = sizeof(uint32_t) * 2 + 3;
+
+    if (megasas_is_jbod(s)) {
+        max_ld_disks = 0;
     }
+    QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
+        SCSIDevice *sdev = DO_UPCAST(SCSIDevice, qdev, kid->child);
 
+        if (num_ld_disks >= max_ld_disks) {
+            break;
+        }
+        info.targetid[num_ld_disks] = sdev->lun;
+        num_ld_disks++;
+        dcmd_size++;
+    }
+    info.ld_count = cpu_to_le32(num_ld_disks);
+    info.size = dcmd_size;
+    trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks);
+
+    resid = dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg);
+    cmd->iov_size = dcmd_size - resid;
     return MFI_STAT_OK;
 }
 
diff --git a/hw/scsi/mfi.h b/hw/scsi/mfi.h
index a3034f6..5050ce4 100644
--- a/hw/scsi/mfi.h
+++ b/hw/scsi/mfi.h
@@ -1111,6 +1111,13 @@ struct mfi_ld_list {
     } ld_list[MFI_MAX_LD];
 } QEMU_PACKED;
 
+struct mfi_ld_targetid_list {
+    uint32_t size;
+    uint32_t ld_count;
+    uint8_t pad[3];
+    uint8_t targetid[MFI_MAX_LD];
+} QEMU_PACKED;
+
 enum mfi_ld_access {
     MFI_LD_ACCESS_RW =          0,
     MFI_LD_ACCSSS_RO =          2,
-- 
1.8.4.5

  parent reply	other threads:[~2014-10-29 12:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29 12:00 [Qemu-devel] [PATCHv2 00/13] megasas: gen2 emulation and MSI-X fixes Hannes Reinecke
2014-10-29 12:00 ` [Qemu-devel] [PATCH 01/13] scsi: Rename scsi_cdb_length() to scsi_xfer_length() Hannes Reinecke
2014-10-29 12:00 ` Hannes Reinecke [this message]
2014-10-29 12:00 ` [Qemu-devel] [PATCH 03/13] megasas: simplify trace event messages Hannes Reinecke
2014-10-29 12:00 ` [Qemu-devel] [PATCH 04/13] megasas: fixup device mapping Hannes Reinecke
2014-10-29 12:00 ` [Qemu-devel] [PATCH 05/13] megasas: add MegaRAID SAS 2108 emulation Hannes Reinecke
2014-10-31 17:08   ` Paolo Bonzini
2014-10-31 17:30     ` Hannes Reinecke
2014-10-31 17:31       ` Paolo Bonzini
2014-10-31 17:32         ` Hannes Reinecke
2014-10-29 12:00 ` [Qemu-devel] [PATCH 06/13] megasas: Fix typo in megasas_dcmd_ld_get_list() Hannes Reinecke
2014-10-29 12:00 ` [Qemu-devel] [PATCH 07/13] megasas: Decode register names Hannes Reinecke
2014-10-29 12:00 ` [Qemu-devel] [PATCH 08/13] megasas: Clear unit attention on initial reset Hannes Reinecke
2014-10-29 12:00 ` [Qemu-devel] [PATCH 09/13] megasas: Ignore duplicate init_firmware commands Hannes Reinecke
2014-10-29 12:00 ` [Qemu-devel] [PATCH 10/13] megasas: Implement DCMD_CLUSTER_RESET_LD Hannes Reinecke
2014-10-29 12:54   ` Paolo Bonzini
2014-10-29 13:23     ` Hannes Reinecke
2014-10-29 13:28       ` Paolo Bonzini
2014-10-29 12:00 ` [Qemu-devel] [PATCH 11/13] megasas: Update queue logging Hannes Reinecke
2014-10-29 12:00 ` [Qemu-devel] [PATCH 12/13] megasas: Rework frame queueing algorithm Hannes Reinecke
2014-10-29 12:00 ` [Qemu-devel] [PATCH 13/13] megasas: Fixup MSI-X handling Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1414584016-25888-3-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=nab@linux-iscsi.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).