qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aik@ozlabs.ru, qiudayu@linux.vnet.ibm.com, agraf@suse.de,
	Gavin Shan <gwshan@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v1 2/3] sPAPR: Implement sPAPRPHBClass::format_errinjct_cmd
Date: Mon, 23 Jun 2014 12:22:02 +1000	[thread overview]
Message-ID: <1403490123-15969-3-git-send-email-gwshan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1403490123-15969-1-git-send-email-gwshan@linux.vnet.ibm.com>

The patch implements sPAPRPHBClass::format_errinjct_cmd to do the
address translation (BUID+PE number to IOMMU group ID) and then
come up with the formatted string for PCI error injection.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 hw/ppc/spapr_pci_vfio.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
index 0a1e902..1f9f0bf 100644
--- a/hw/ppc/spapr_pci_vfio.c
+++ b/hw/ppc/spapr_pci_vfio.c
@@ -227,6 +227,24 @@ static int spapr_phb_vfio_eeh_handler(sPAPRPHBState *sphb, int req, int opt)
                                 VFIO_EEH_PE_OP, &op);
 }
 
+static char *format_errinjct_cmd(sPAPRPHBState *sphb, sPAPRErrInjctIOA *ioa)
+{
+    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
+    char *pstr = NULL;
+
+    /* Invalid IOMMU group ID ? */
+    if (svphb->iommugroupid == -1) {
+        goto out;
+    }
+
+    /* Formatted string */
+    pstr = g_strdup_printf("%x:%lx:%lx:%x:%x",
+                           ioa->ei_token, ioa->addr, ioa->mask,
+                           svphb->iommugroupid, ioa->func);
+out:
+    return pstr;
+}
+
 static void spapr_phb_vfio_reset(DeviceState *qdev)
 {
     /* Do nothing */
@@ -241,6 +259,7 @@ static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data)
     dc->reset = spapr_phb_vfio_reset;
     spc->finish_realize = spapr_phb_vfio_finish_realize;
     spc->eeh_handler = spapr_phb_vfio_eeh_handler;
+    spc->format_errinjct_cmd = format_errinjct_cmd;
 }
 
 static const TypeInfo spapr_phb_vfio_info = {
-- 
1.8.3.2

  parent reply	other threads:[~2014-06-23  2:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23  2:22 [Qemu-devel] [PATCH v1 0/3] Support PCI Error Injection Gavin Shan
2014-06-23  2:22 ` [Qemu-devel] [PATCH v1 1/3] sPAPR: Implement PCI error injection RTAS calls Gavin Shan
2014-06-23 16:18   ` Alexander Graf
2014-06-23 21:03     ` Benjamin Herrenschmidt
2014-06-23 21:13       ` Alexander Graf
2014-06-24  0:14         ` Gavin Shan
2014-06-24  0:58     ` Gavin Shan
2014-06-23  2:22 ` Gavin Shan [this message]
2014-06-23  2:22 ` [Qemu-devel] [PATCH v1 3/3] sPAPR: Export RTAS property <ibm, errinjct-tokens> Gavin Shan

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=1403490123-15969-3-git-send-email-gwshan@linux.vnet.ibm.com \
    --to=gwshan@linux.vnet.ibm.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qiudayu@linux.vnet.ibm.com \
    /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).