qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: qemu-ppc@nongnu.org
Cc: aik@ozlabs.ru, qemu-devel@nongnu.org, agraf@suse.de,
	alex.williamson@redhat.com, qiudayu@linux.vnet.ibm.com,
	Gavin Shan <gwshan@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v8 3/4] VFIO: Introduce helper vfio_pci_container_ioctl()
Date: Thu,  5 Jun 2014 16:53:40 +1000	[thread overview]
Message-ID: <1401951221-32613-4-git-send-email-gwshan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1401951221-32613-1-git-send-email-gwshan@linux.vnet.ibm.com>

The patch introduces helper function vfio_pci_container_ioctl() to
pass ioctl commands to the specified VFIO container that is identified
by IOMMU group id. On sPAPR platform, each container only has one
IOMMU group.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 hw/misc/vfio.c         | 31 +++++++++++++++++++++++++++++++
 include/hw/misc/vfio.h |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index 0796abf..999d97d 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -4310,3 +4310,34 @@ put_group_exit:
 
     return n;
 }
+
+int vfio_pci_container_ioctl(int iommu_group_id, int req, int opt)
+{
+    VFIOGroup *group;
+    int ret, fd = 0;
+
+    /* Search container's fd */
+    QLIST_FOREACH(group, &group_list, next) {
+        if (group->groupid == iommu_group_id) {
+            fd = group->container ? group->container->fd : 0;
+            break;
+        }
+    }
+
+    if (fd <= 0) {
+        return -ENOENT;
+    }
+
+    switch (req) {
+    case VFIO_EEH_PE_OP: {
+	struct vfio_eeh_pe_op op = { .argsz = sizeof(op), .op = opt };
+
+        ret = ioctl(fd, req, &op);
+        break;
+    }
+    default:
+        ret = -EINVAL;
+    }
+
+    return ret;
+}
diff --git a/include/hw/misc/vfio.h b/include/hw/misc/vfio.h
index 53ec665..dc92fae 100644
--- a/include/hw/misc/vfio.h
+++ b/include/hw/misc/vfio.h
@@ -30,4 +30,6 @@ static inline long vfio_kvm_notify(Notifier *n, unsigned request, void *data)
     return p.ret;
 }
 
+extern int vfio_pci_container_ioctl(int iommu_group_id, int req, int opt);
+
 #endif
-- 
1.8.3.2

  parent reply	other threads:[~2014-06-05  6:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05  6:53 [Qemu-devel] [PATCH v8 0/4] EEH Support for VFIO PCI Device Gavin Shan
2014-06-05  6:53 ` [Qemu-devel] [PATCH v8 1/4] sPAPR: Implement EEH RTAS calls Gavin Shan
2014-06-05 12:09   ` Alexander Graf
2014-06-06  0:59     ` Gavin Shan
2014-06-05  6:53 ` [Qemu-devel] [PATCH v8 2/4] headers: Update kernel header Gavin Shan
2014-06-05  6:53 ` Gavin Shan [this message]
2014-06-05 12:11   ` [Qemu-devel] [PATCH v8 3/4] VFIO: Introduce helper vfio_pci_container_ioctl() Alexander Graf
2014-06-06  1:00     ` Gavin Shan
2014-06-05 18:27   ` Alex Williamson
2014-06-06  1:05     ` Gavin Shan
2014-06-05  6:53 ` [Qemu-devel] [PATCH v8 4/4] sPAPR: Implement sPAPRPHBClass::eeh_handler Gavin Shan
2014-06-05 13:00   ` Alexander Graf
2014-06-05 13:13     ` Alexey Kardashevskiy
2014-06-05 12:12 ` [Qemu-devel] [PATCH v8 0/4] EEH Support for VFIO PCI Device Alexander Graf
2014-06-05 18:31   ` Alex Williamson

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=1401951221-32613-4-git-send-email-gwshan@linux.vnet.ibm.com \
    --to=gwshan@linux.vnet.ibm.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=alex.williamson@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).