diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2011-03-31 18:11:25 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2011-03-31 18:11:25 +0100 |
commit | d1611204f32a705ca82611ddcb8d6549b244b313 (patch) | |
tree | ba9ffef593093b1c31a95363b8a0e07eef60c6e2 /tools/libxl/libxl_pci.c | |
parent | 28745ea9bb4d23765d3000188dd2f480952df237 (diff) | |
download | xen-d1611204f32a705ca82611ddcb8d6549b244b313.tar.gz xen-d1611204f32a705ca82611ddcb8d6549b244b313.tar.bz2 xen-d1611204f32a705ca82611ddcb8d6549b244b313.zip |
libxl: remove "reg" and "enable" fields from PCI device.
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>
Diffstat (limited to 'tools/libxl/libxl_pci.c')
-rw-r--r-- | tools/libxl/libxl_pci.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index d6d299bd7f..6001c6f06f 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -41,29 +41,16 @@ #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"); } |