]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
configs/tools: Provide MSI parameters via config
authorJan Kiszka <jan.kiszka@siemens.com>
Mon, 28 Jul 2014 13:46:31 +0000 (15:46 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Sat, 23 Aug 2014 11:24:26 +0000 (13:24 +0200)
This avoids having to extract these MSI capabilities from hardware in
the hypervisor.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
configs/h87i.c
configs/pci-demo.c
configs/qemu-vm.c
hypervisor/include/jailhouse/cell-config.h
tools/jailhouse-config-create
tools/root-cell-config.c.tmpl

index 334ea153fd748dce1a2c3b002198180b8e65f905..756bb07cdee3888167006422392e482968721cfb 100644 (file)
@@ -149,6 +149,7 @@ struct {
                        .bdf = 0x8,
                        .caps_start = 1,
                        .num_caps = 4,
+                       .num_msi_vectors = 1,
                },
                /* PCIDevice: 00:02.0 */
                {
@@ -157,6 +158,7 @@ struct {
                        .bdf = 0x10,
                        .caps_start = 5,
                        .num_caps = 3,
+                       .num_msi_vectors = 1,
                },
                /* PCIDevice: 00:03.0 */
                {
@@ -165,6 +167,7 @@ struct {
                        .bdf = 0x18,
                        .caps_start = 8,
                        .num_caps = 3,
+                       .num_msi_vectors = 1,
                },
                /* PCIDevice: 00:14.0 */
                {
@@ -173,6 +176,8 @@ struct {
                        .bdf = 0xa0,
                        .caps_start = 11,
                        .num_caps = 2,
+                       .num_msi_vectors = 8,
+                       .msi_64bits = 1,
                },
                /* PCIDevice: 00:16.0 */
                {
@@ -181,6 +186,8 @@ struct {
                        .bdf = 0xb0,
                        .caps_start = 13,
                        .num_caps = 2,
+                       .num_msi_vectors = 1,
+                       .msi_64bits = 1,
                },
                /* PCIDevice: 00:19.0 */
                {
@@ -189,6 +196,8 @@ struct {
                        .bdf = 0xc8,
                        .caps_start = 15,
                        .num_caps = 3,
+                       .num_msi_vectors = 1,
+                       .msi_64bits = 1,
                },
                /* PCIDevice: 00:1a.0 */
                {
@@ -205,6 +214,8 @@ struct {
                        .bdf = 0xd8,
                        .caps_start = 21,
                        .num_caps = 3,
+                       .num_msi_vectors = 1,
+                       .msi_64bits = 1,
                },
                /* PCIDevice: 00:1d.0 */
                {
@@ -229,6 +240,7 @@ struct {
                        .bdf = 0xfa,
                        .caps_start = 24,
                        .num_caps = 3,
+                       .num_msi_vectors = 1,
                },
                /* PCIDevice: 00:1f.3 */
                {
index 42b3c50727ba95a4a6aa9431ccdde511c307fcbd..09b9447c47f0942f4d0e366de9261b7e611bb9f8 100644 (file)
@@ -79,6 +79,8 @@ struct {
                        .bdf = 0x00d8,
                        .caps_start = 0,
                        .num_caps = 1,
+                       .num_msi_vectors = 1,
+                       .msi_64bits = 1,
                },
        },
 
index 7ae2cec1769805c398ac741564535e78237c0e59..65367cb9ddbadcd2af996756b4e4c8a3531db4b6 100644 (file)
@@ -142,6 +142,8 @@ struct {
                        .bdf = 0x00fa,
                        .caps_start = 2,
                        .num_caps = 2,
+                       .num_msi_vectors = 1,
+                       .msi_64bits = 1,
                },
                { /* SMBus */
                        .type = JAILHOUSE_PCI_TYPE_DEVICE,
index f54d1635fbf1c5b6d8a8dbdc1cf1e93dbd61421a..2c6c68577c5f52419181b2ac358fef27b21bd7f9 100644 (file)
@@ -65,6 +65,9 @@ struct jailhouse_pci_device {
        __u16 bdf;
        __u16 caps_start;
        __u16 num_caps;
+       __u8 num_msi_vectors;
+       __u8 msi_64bits;
+       __u16 padding;
 } __attribute__((packed));
 
 #define JAILHOUSE_PCICAPS_WRITE                0x0001
index b318116d3ed4a9d4685913966524c768c0d0f53b..beb2acbea045dcbb0645edf2dec89b0ae8676a92 100755 (executable)
@@ -111,11 +111,12 @@ def input_listdir(dir, wildcards):
 
 
 class PCICapability:
-    def __init__(self, id, start, len, flags):
+    def __init__(self, id, start, len, flags, content):
         self.id = id
         self.start = start
         self.len = len
         self.flags = flags
+        self.content = content
         self.comments = []
 
     def __eq__(self, other):
@@ -163,7 +164,9 @@ class PCICapability:
                 # unknown/unhandled cap, mark its existence
                 len = 2
                 flags = PCICapability.RD
-            caps.append(PCICapability(id, cap, len, flags))
+            f.seek(cap + 2)
+            content = f.read(len - 2)
+            caps.append(PCICapability(id, cap, len, flags, content))
         return caps
 
 
@@ -177,6 +180,14 @@ class PCIDevice:
         self.caps = caps
         self.caps_start = 0
         self.num_caps = len(caps)
+        self.num_msi_vectors = 0
+        self.msi_64bits = 0
+        for c in caps:
+            if c.id in (0x05, 0x11):
+                msg_ctrl = struct.unpack('<H', c.content[:2])[0]
+                if c.id == 0x05:  # MSI
+                    self.num_msi_vectors = 1 << ((msg_ctrl >> 1) & 0x7)
+                    self.msi_64bits = (msg_ctrl >> 7) & 1
 
     def __str__(self):
         return 'PCIDevice: %02x:%02x.%x' % (self.bus, self.dev, self.fn)
index 962f7957caa13fa811c55d6a560ffcab1a68457d..fe85a5109162f3189c063dced99a20ed08f9e7cf 100644 (file)
@@ -109,6 +109,8 @@ struct {
                        .bdf = ${hex(d.bdf())},
                        .caps_start = ${d.caps_start},
                        .num_caps = ${d.num_caps},
+                       .num_msi_vectors = ${d.num_msi_vectors},
+                       .msi_64bits = ${d.msi_64bits},
                },
                % endfor
        },