Skip to content

Commit

Permalink
CP-25798: Factoring out PCI address to common lib
Browse files Browse the repository at this point in the history
Signed-off-by: Cheng Zhang <cheng.zhang@citrix.com>
  • Loading branch information
cheng-z authored and krizex committed Jan 11, 2018
1 parent 144fa27 commit 7b7fac1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
3 changes: 2 additions & 1 deletion lib/jbuild
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let runtime_coverage_enabled, coverage_dep =
else
"disabled.ml", ""

let rewriters = ["ppx_deriving_rpc"]
let rewriters = ["ppx_deriving_rpc"; "ppx_sexp_conv"]
let flags = flags rewriters

let () = Printf.ksprintf Jbuild_plugin.V1.send {|
Expand All @@ -55,6 +55,7 @@ let () = Printf.ksprintf Jbuild_plugin.V1.send {|
fd-send-recv
message_switch.unix
ppx_deriving_rpc
ppx_sexp_conv
re
rpclib
rpclib.xml
Expand Down
17 changes: 17 additions & 0 deletions lib/xcp_pci.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
open Sexplib.Std

type address = {
domain: int;
bus: int;
dev: int;
fn: int;
}
[@@deriving sexp, rpc]

let address_of_string str =
Scanf.sscanf str "%04x:%02x:%02x.%02x"
(fun domain bus dev fn -> {domain; bus; dev; fn})

let string_of_address address =
Printf.sprintf "%04x:%02x:%02x.%01x"
address.domain address.bus address.dev address.fn
10 changes: 1 addition & 9 deletions xen/xenops_interface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,7 @@ module Network = struct
end

module Pci = struct
include Xenops_types.Pci

let address_of_string str =
Scanf.sscanf str "%04x:%02x:%02x.%02x"
(fun domain bus dev fn -> {domain; bus; dev; fn})

let string_of_address address =
Printf.sprintf "%04x:%02x:%02x.%01x"
address.domain address.bus address.dev address.fn
include Xcp_pci

type id = string * string

Expand Down
18 changes: 4 additions & 14 deletions xen/xenops_types.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
open Sexplib.Std
open Xcp_pci

module TopLevel = struct
type power_state =
Expand All @@ -14,33 +15,22 @@ module TopLevel = struct
[@@deriving sexp, rpc]
end

module Pci = struct
type address = {
domain: int;
bus: int;
dev: int;
fn: int;
}
[@@deriving sexp, rpc]

end

module Vgpu = struct
type gvt_g = {
physical_pci_address: Pci.address option; (* unused; promoted to Vgpu.t *)
physical_pci_address: address option; (* unused; promoted to Vgpu.t *)
low_gm_sz: int64;
high_gm_sz: int64;
fence_sz: int64;
monitor_config_file: string option;
} [@@deriving sexp, rpc]

type nvidia = {
physical_pci_address: Pci.address option; (* unused; promoted to Vgpu.t *)
physical_pci_address: address option; (* unused; promoted to Vgpu.t *)
config_file: string;
} [@@deriving sexp, rpc]

type mxgpu = {
physical_function: Pci.address option; (* unused; promoted to Vgpu.t *)
physical_function: address option; (* unused; promoted to Vgpu.t *)
vgpus_per_pgpu: int64;
framebufferbytes: int64;
} [@@deriving sexp, rpc]
Expand Down

0 comments on commit 7b7fac1

Please sign in to comment.