]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: remove "reg" and "enable" fields from PCI device.
authorIan Campbell <ian.campbell@citrix.com>
Thu, 31 Mar 2011 17:11:25 +0000 (18:11 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 31 Mar 2011 17:11:25 +0000 (18:11 +0100)
The structure of the BDF argument used with PCI passthrough related
hypercalls was taken from the structure of the PCI config_address
register (I/O port 0xCF8) which allows I/O mapped access to PCI
configuration space but these fields have no meaning in the context of
PCI passthrough configuration and hence do not need to be exposed via
libxl.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl.idl
tools/libxl/libxl_pci.c
tools/ocaml/libs/xl/xl_stubs.c

index 377417a8c88809b291bb6732075e16ea633f70b7..143a6cf12618563c65c7dcf1678c7a51b5e011b9 100644 (file)
@@ -243,11 +243,9 @@ libxl_device_net2 = Struct("device_net2", [
     ])
 
 libxl_device_pci = Struct("device_pci", [
-    ("reg",       uint8),
     ("func",      uint8),
     ("dev",       uint8),
     ("bus",       uint8),
-    ("enable",    bool),
     ("domain", unsigned_integer),
     ("vdevfn", unsigned_integer),
     ("vfunc_mask", unsigned_integer),
index d6d299bd7f45713b065292352a25bf6325d0d7f5..6001c6f06ffcf5983d37e749c565dc5105db8fea 100644 (file)
 #define PCI_BDF_SHORT          "%02x:%02x.%01x"
 #define PCI_BDF_VDEVFN         "%04x:%02x:%02x.%01x@%02x"
 
-static unsigned int pcidev_value(libxl_device_pci *pcidev)
+static unsigned int pcidev_encode_bdf(libxl_device_pci *pcidev)
 {
-    union {
-        unsigned int value;
-        struct {
-            unsigned int reserved1:2;
-            unsigned int reg:6;
-            unsigned int func:3;
-            unsigned int dev:5;
-            unsigned int bus:8;
-            unsigned int reserved2:7;
-            unsigned int enable:1;
-        }fields;
-    }u;
-
-    u.value = 0;
-    u.fields.reg = pcidev->reg;
-    u.fields.func = pcidev->func;
-    u.fields.dev = pcidev->dev;
-    u.fields.bus = pcidev->bus;
-    u.fields.enable = pcidev->enable;
-
-    return u.value;
+    unsigned int value;
+
+    value = 0;
+    value |= (pcidev->bus & 0xff) << 16;
+    value |= (pcidev->dev & 0x1f) << (8+3);
+    value |= (pcidev->func & 0x3) << (8+0);
+
+    return value;
 }
 
 static int pcidev_init(libxl_device_pci *pcidev, unsigned int domain,
@@ -711,7 +698,7 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, i
     }
 out:
     if (!libxl_is_stubdom(ctx, domid, NULL)) {
-        rc = xc_assign_device(ctx->xch, domid, pcidev_value(pcidev));
+        rc = xc_assign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev));
         if (rc < 0 && (hvm || errno != ENOSYS)) {
             LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_assign_device failed");
             return ERROR_FAIL;
@@ -938,7 +925,7 @@ out:
     }
 
     if (!libxl_is_stubdom(ctx, domid, NULL)) {
-        rc = xc_deassign_device(ctx->xch, domid, pcidev_value(pcidev));
+        rc = xc_deassign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev));
         if (rc < 0 && (hvm || errno != ENOSYS))
             LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_deassign_device failed");
     }
index b631e3da85ee9d32d574515437c25349105f2a9c..6c442ad818794eb60bf1c011e011cfad3b4b83e8 100644 (file)
@@ -288,11 +288,9 @@ static int device_pci_val(caml_gc *gc, libxl_device_pci *c_val, value v)
 
        /* FIXME: propagate API change to ocaml */
        u.value = Int_val(Field(v, 0));
-       c_val->reg = u.fields.reg;
        c_val->func = u.fields.func;
        c_val->dev = u.fields.dev;
        c_val->bus = u.fields.bus;
-       c_val->enable = u.fields.enable;
 
        c_val->domain = Int_val(Field(v, 1));
        c_val->vdevfn = Int_val(Field(v, 2));