From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wyttt-0006Ix-Cr for qemu-devel@nongnu.org; Sun, 22 Jun 2014 22:22:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wyttc-0002du-83 for qemu-devel@nongnu.org; Sun, 22 Jun 2014 22:22:29 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:50695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wyttb-0002dB-Ey for qemu-devel@nongnu.org; Sun, 22 Jun 2014 22:22:12 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Jun 2014 12:22:06 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 4479D2CE8055 for ; Mon, 23 Jun 2014 12:22:04 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5N1xmOO52887556 for ; Mon, 23 Jun 2014 11:59:49 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s5N2M3Xq015578 for ; Mon, 23 Jun 2014 12:22:03 +1000 From: Gavin Shan Date: Mon, 23 Jun 2014 12:22:02 +1000 Message-Id: <1403490123-15969-3-git-send-email-gwshan@linux.vnet.ibm.com> In-Reply-To: <1403490123-15969-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1403490123-15969-1-git-send-email-gwshan@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v1 2/3] sPAPR: Implement sPAPRPHBClass::format_errinjct_cmd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aik@ozlabs.ru, qiudayu@linux.vnet.ibm.com, agraf@suse.de, Gavin Shan 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 --- 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