WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 4 of 6] ats: Add new ATS helper functions

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 4 of 6] ats: Add new ATS helper functions
From: Wei Wang <wei.wang2@xxxxxxx>
Date: Tue, 25 Oct 2011 15:07:36 +0200
Delivery-date: Tue, 25 Oct 2011 06:09:23 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1319548052@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1319548052@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.9.3
# HG changeset patch
# User Wei Wang <wei.wang2@xxxxxxx>
# Date 1319472696 -7200
# Node ID 3dc5e805d9142cbe1074610879e258b6fab43409
# Parent  18088bd3e8f6c16b7aef3d8652f2b9878117fcd5
ats: Add new ATS helper functions

Signed-off-by Wei Wang <wei.wang2@xxxxxxx>

diff -r 18088bd3e8f6 -r 3dc5e805d914 xen/drivers/passthrough/x86/ats.c
--- a/xen/drivers/passthrough/x86/ats.c Mon Oct 24 18:11:32 2011 +0200
+++ b/xen/drivers/passthrough/x86/ats.c Mon Oct 24 18:11:36 2011 +0200
@@ -138,3 +138,42 @@ void disable_ats_device(int seg, int bus
                 seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
 }
 
+int pci_ats_enabled(int seg, int bus, int devfn)
+{
+    u32 value;
+    int pos;
+
+    pos = pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS);
+    BUG_ON(!pos);
+
+    value = pci_conf_read16(seg, bus, PCI_SLOT(devfn),
+                            PCI_FUNC(devfn), pos + ATS_REG_CTL);
+    return value & ATS_ENABLE;
+}
+
+int pci_ats_device(int seg, int bus, int devfn)
+{
+    if ( !ats_enabled )
+        return 0;
+
+    if ( !pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS) )
+        return 0;
+
+    return 1;
+}
+
+struct pci_ats_dev* get_ats_device(int seg, int bus, int devfn)
+{
+    struct pci_ats_dev *pdev;
+
+    if ( !pci_ats_device(seg, bus, devfn) )
+        return NULL;
+
+    list_for_each_entry ( pdev, &ats_devices, list )
+    {
+        if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn )
+            return pdev;
+    }
+
+    return NULL;
+}
diff -r 18088bd3e8f6 -r 3dc5e805d914 xen/drivers/passthrough/x86/ats.h
--- a/xen/drivers/passthrough/x86/ats.h Mon Oct 24 18:11:32 2011 +0200
+++ b/xen/drivers/passthrough/x86/ats.h Mon Oct 24 18:11:36 2011 +0200
@@ -34,5 +34,8 @@ extern bool_t ats_enabled;
 
 int enable_ats_device(int seg, int bus, int devfn);
 void disable_ats_device(int seg, int bus, int devfn);
+int pci_ats_enabled(int seg, int bus, int devfn);
+int pci_ats_device(int seg, int bus, int devfn);
+struct pci_ats_dev* get_ats_device(int seg, int bus, int devfn);
 
 #endif /* _X86_ATS_H_ */


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel