* [PATCH 0 of 2] libxl: PCI passthrough interface changes @ 2011-03-24 11:49 Ian Campbell 2011-03-24 11:49 ` [PATCH 1 of 2] libxl: remove "reg" and "enable" fields from PCI device Ian Campbell 2011-03-24 11:49 ` [PATCH 2 of 2] tools: ocaml: xl: propagate simplfied libxl interface to PCI BDFs to bindings Ian Campbell 0 siblings, 2 replies; 5+ messages in thread From: Ian Campbell @ 2011-03-24 11:49 UTC (permalink / raw) To: xen-devel; +Cc: Ian Campbell Drop some unused fields from the libxl_device_pci, they are not relevant in the context of PCI passthrough. Propagate interface change from 22166:251694a87f1d to the ocaml bindings, removing a FIXME. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1 of 2] libxl: remove "reg" and "enable" fields from PCI device 2011-03-24 11:49 [PATCH 0 of 2] libxl: PCI passthrough interface changes Ian Campbell @ 2011-03-24 11:49 ` Ian Campbell 2011-03-24 11:49 ` [PATCH 2 of 2] tools: ocaml: xl: propagate simplfied libxl interface to PCI BDFs to bindings Ian Campbell 1 sibling, 0 replies; 5+ messages in thread From: Ian Campbell @ 2011-03-24 11:49 UTC (permalink / raw) To: xen-devel; +Cc: Ian Campbell # HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1300967090 0 # Node ID 3462e0f1f0c1efe035f4d1d24d3659431a6c62c0 # Parent 5bf43a02350bd32c5da0782334132d49a181e41b 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> diff -r 5bf43a02350b -r 3462e0f1f0c1 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Thu Mar 24 11:44:50 2011 +0000 +++ b/tools/libxl/libxl.idl Thu Mar 24 11:44:50 2011 +0000 @@ -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), diff -r 5bf43a02350b -r 3462e0f1f0c1 tools/libxl/libxl_pci.c --- a/tools/libxl/libxl_pci.c Thu Mar 24 11:44:50 2011 +0000 +++ b/tools/libxl/libxl_pci.c Thu Mar 24 11:44:50 2011 +0000 @@ -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; + unsigned int value; - 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; + value = 0; + value |= (pcidev->bus & 0xff) << 16; + value |= (pcidev->dev & 0x1f) << (8+3); + value |= (pcidev->func & 0x3) << (8+0); - return u.value; + 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, uin } 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"); } diff -r 5bf43a02350b -r 3462e0f1f0c1 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Thu Mar 24 11:44:50 2011 +0000 +++ b/tools/ocaml/libs/xl/xl_stubs.c Thu Mar 24 11:44:50 2011 +0000 @@ -288,11 +288,9 @@ static int device_pci_val(caml_gc *gc, l /* 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)); ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2 of 2] tools: ocaml: xl: propagate simplfied libxl interface to PCI BDFs to bindings 2011-03-24 11:49 [PATCH 0 of 2] libxl: PCI passthrough interface changes Ian Campbell 2011-03-24 11:49 ` [PATCH 1 of 2] libxl: remove "reg" and "enable" fields from PCI device Ian Campbell @ 2011-03-24 11:49 ` Ian Campbell 1 sibling, 0 replies; 5+ messages in thread From: Ian Campbell @ 2011-03-24 11:49 UTC (permalink / raw) To: xen-devel; +Cc: Ian Campbell # HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1300967090 0 # Node ID b92430e690860cfac8f243ee9cff47351ad6fbbb # Parent 3462e0f1f0c1efe035f4d1d24d3659431a6c62c0 tools: ocaml: xl: propagate simplfied libxl interface to PCI BDFs to bindings. 22166:251694a87f1d changed the libxl interface to remove the need for users to understand BDF encoding but did not propagate the change to the ocaml bindings. Do that now. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 3462e0f1f0c1 -r b92430e69086 tools/ocaml/libs/xl/xl.ml --- a/tools/ocaml/libs/xl/xl.ml Thu Mar 24 11:44:50 2011 +0000 +++ b/tools/ocaml/libs/xl/xl.ml Thu Mar 24 11:44:50 2011 +0000 @@ -145,7 +145,9 @@ type vfb_info = type pci_info = { - v : int; (* domain * bus * dev * func multiplexed *) + func : int; + dev : int; + bus : int; domain : int; vdevfn : int; msitranslate : bool; diff -r 3462e0f1f0c1 -r b92430e69086 tools/ocaml/libs/xl/xl.mli --- a/tools/ocaml/libs/xl/xl.mli Thu Mar 24 11:44:50 2011 +0000 +++ b/tools/ocaml/libs/xl/xl.mli Thu Mar 24 11:44:50 2011 +0000 @@ -145,7 +145,9 @@ type vfb_info = type pci_info = { - v : int; (* domain * bus * dev * func multiplexed *) + func : int; + dev : int; + bus : int; domain : int; vdevfn : int; msitranslate : bool; diff -r 3462e0f1f0c1 -r b92430e69086 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Thu Mar 24 11:44:50 2011 +0000 +++ b/tools/ocaml/libs/xl/xl_stubs.c Thu Mar 24 11:44:50 2011 +0000 @@ -272,30 +272,16 @@ static int device_vfb_val(caml_gc *gc, l static int device_pci_val(caml_gc *gc, libxl_device_pci *c_val, value v) { - 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; CAMLparam1(v); - /* FIXME: propagate API change to ocaml */ - u.value = Int_val(Field(v, 0)); - c_val->func = u.fields.func; - c_val->dev = u.fields.dev; - c_val->bus = u.fields.bus; + c_val->func = Int_val(Field(v, 0)); + c_val->dev = Int_val(Field(v, 1)); + c_val->bus = Int_val(Field(v, 2)); - c_val->domain = Int_val(Field(v, 1)); - c_val->vdevfn = Int_val(Field(v, 2)); - c_val->msitranslate = Bool_val(Field(v, 3)); - c_val->power_mgmt = Bool_val(Field(v, 4)); + c_val->domain = Int_val(Field(v, 3)); + c_val->vdevfn = Int_val(Field(v, 4)); + c_val->msitranslate = Bool_val(Field(v, 5)); + c_val->power_mgmt = Bool_val(Field(v, 6)); CAMLreturn(0); } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 0 of 2] tools: libxl: fixup PCI BDF interface (REPOST) @ 2011-03-31 11:01 Ian Campbell 2011-03-31 11:01 ` [PATCH 1 of 2] libxl: remove "reg" and "enable" fields from PCI device Ian Campbell 0 siblings, 1 reply; 5+ messages in thread From: Ian Campbell @ 2011-03-31 11:01 UTC (permalink / raw) To: xen-devel; +Cc: Ian Campbell Drop some unused fields from the libxl_device_pci, they are not relevant in the context of PCI passthrough. Propagate interface change from 22166:251694a87f1d to the ocaml bindings, removing a FIXME. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1 of 2] libxl: remove "reg" and "enable" fields from PCI device 2011-03-31 11:01 [PATCH 0 of 2] tools: libxl: fixup PCI BDF interface (REPOST) Ian Campbell @ 2011-03-31 11:01 ` Ian Campbell 0 siblings, 0 replies; 5+ messages in thread From: Ian Campbell @ 2011-03-31 11:01 UTC (permalink / raw) To: xen-devel; +Cc: Ian Campbell # HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1301569030 -3600 # Node ID cb7f41afe07f8734a515dd30454e6701df755ec1 # Parent 4dea5e15e3463475fbed120882cfd9261b0182ea 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> diff -r 4dea5e15e346 -r cb7f41afe07f tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Thu Mar 31 11:57:09 2011 +0100 +++ b/tools/libxl/libxl.idl Thu Mar 31 11:57:10 2011 +0100 @@ -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), diff -r 4dea5e15e346 -r cb7f41afe07f tools/libxl/libxl_pci.c --- a/tools/libxl/libxl_pci.c Thu Mar 31 11:57:09 2011 +0100 +++ b/tools/libxl/libxl_pci.c Thu Mar 31 11:57:10 2011 +0100 @@ -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; + unsigned int value; - 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; + value = 0; + value |= (pcidev->bus & 0xff) << 16; + value |= (pcidev->dev & 0x1f) << (8+3); + value |= (pcidev->func & 0x3) << (8+0); - return u.value; + 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, uin } 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"); } diff -r 4dea5e15e346 -r cb7f41afe07f tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Thu Mar 31 11:57:09 2011 +0100 +++ b/tools/ocaml/libs/xl/xl_stubs.c Thu Mar 31 11:57:10 2011 +0100 @@ -288,11 +288,9 @@ static int device_pci_val(caml_gc *gc, l /* 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)); ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 0 of 2] tools: libxl: fixup PCI BDF interface @ 2011-03-21 16:13 Ian Campbell 2011-03-21 16:13 ` [PATCH 1 of 2] libxl: remove "reg" and "enable" fields from PCI device Ian Campbell 0 siblings, 1 reply; 5+ messages in thread From: Ian Campbell @ 2011-03-21 16:13 UTC (permalink / raw) To: xen-devel; +Cc: Ian Campbell The libxl interface for PCI devices includes a couple of fields which are not useful in this context, remove them. libxl exposes the PCI BDF as individual numbers and takes care of encoding it internally, this change was not propagated to the ocaml bindings at the time so do it now. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1 of 2] libxl: remove "reg" and "enable" fields from PCI device 2011-03-21 16:13 [PATCH 0 of 2] tools: libxl: fixup PCI BDF interface Ian Campbell @ 2011-03-21 16:13 ` Ian Campbell 0 siblings, 0 replies; 5+ messages in thread From: Ian Campbell @ 2011-03-21 16:13 UTC (permalink / raw) To: xen-devel; +Cc: Ian Campbell # HG changeset patch # User Ian Campbell <ian.campbell@citrix.com> # Date 1300721950 0 # Node ID 3c0d44a0d9a3f8adcc2e43a6610fc0fe5b012b3a # Parent 0e6e8b0d4dc1020ee9757121c83cb05da55f3cca libxl: remove "reg" and "enable" fields from PCI device. These are defined as part of the PCI config_address register (I/O port 0xCF8) which allows I/O mapped access to PCI configuration space but have no meaning in the context of PCI passthrough configuration. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> diff -r 0e6e8b0d4dc1 -r 3c0d44a0d9a3 tools/libxl/libxl.idl --- a/tools/libxl/libxl.idl Mon Mar 21 14:42:27 2011 +0000 +++ b/tools/libxl/libxl.idl Mon Mar 21 15:39:10 2011 +0000 @@ -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), diff -r 0e6e8b0d4dc1 -r 3c0d44a0d9a3 tools/libxl/libxl_pci.c --- a/tools/libxl/libxl_pci.c Mon Mar 21 14:42:27 2011 +0000 +++ b/tools/libxl/libxl_pci.c Mon Mar 21 15:39:10 2011 +0000 @@ -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; + unsigned int value; - 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; + value = 0; + value |= (pcidev->bus & 0xff) << 16; + value |= (pcidev->dev & 0x1f) << (8+3); + value |= (pcidev->func & 0x3) << (8+0); - return u.value; + 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, uin } 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"); } diff -r 0e6e8b0d4dc1 -r 3c0d44a0d9a3 tools/ocaml/libs/xl/xl_stubs.c --- a/tools/ocaml/libs/xl/xl_stubs.c Mon Mar 21 14:42:27 2011 +0000 +++ b/tools/ocaml/libs/xl/xl_stubs.c Mon Mar 21 15:39:10 2011 +0000 @@ -288,11 +288,9 @@ static int device_pci_val(caml_gc *gc, l /* 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)); ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-03-31 11:01 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-03-24 11:49 [PATCH 0 of 2] libxl: PCI passthrough interface changes Ian Campbell 2011-03-24 11:49 ` [PATCH 1 of 2] libxl: remove "reg" and "enable" fields from PCI device Ian Campbell 2011-03-24 11:49 ` [PATCH 2 of 2] tools: ocaml: xl: propagate simplfied libxl interface to PCI BDFs to bindings Ian Campbell -- strict thread matches above, loose matches on Subject: below -- 2011-03-31 11:01 [PATCH 0 of 2] tools: libxl: fixup PCI BDF interface (REPOST) Ian Campbell 2011-03-31 11:01 ` [PATCH 1 of 2] libxl: remove "reg" and "enable" fields from PCI device Ian Campbell 2011-03-21 16:13 [PATCH 0 of 2] tools: libxl: fixup PCI BDF interface Ian Campbell 2011-03-21 16:13 ` [PATCH 1 of 2] libxl: remove "reg" and "enable" fields from PCI device Ian Campbell
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).