@@ -18,7 +18,6 @@ module D = Debug.Make(struct let name = "network_interface" end)
1818open D
1919
2020(* * {2 Helper functions} *)
21-
2221let service_name = " networkd"
2322let queue_name = ref (Xcp_service. common_prefix ^ service_name)
2423
@@ -325,6 +324,13 @@ module Interface_API(R : RPC) = struct
325324 [" Check interface existence" ]
326325 (debug_info_p @-> iface_name_p @-> returning result err)
327326
327+ let get_pci_bus_path =
328+ let result = Param. mk ~description: [" PCI bus path" ] Types. string in
329+ declare
330+ " Interface.get_pci_bus_path"
331+ [" Get PCI bus path of the interface" ]
332+ (debug_info_p @-> iface_name_p @-> returning result err)
333+
328334 let get_mac =
329335 let result = Param. mk ~description: [" MAC address" ] Types. string in
330336 declare
@@ -631,5 +637,63 @@ module Interface_API(R : RPC) = struct
631637 [" Remove site" ]
632638 (debug_info_p @-> site_p @-> returning unit_p err)
633639 end
634- end
635640
641+ module Sriov = struct
642+ type sriov_pci_t = {
643+ mac : string option ;
644+ vlan : int64 option ;
645+ rate : int64 option ;
646+ } [@@ deriving rpcty ]
647+
648+ type enable_action_result =
649+ | Modprobe_successful_requires_reboot
650+ | Modprobe_successful
651+ | Sysfs_successful
652+ [@@ deriving rpcty ]
653+
654+ type enable_result =
655+ | Ok of enable_action_result
656+ | Error of string
657+ [@@ deriving rpcty ]
658+
659+ type disable_result =
660+ | Ok
661+ | Error of string
662+ [@@ deriving rpcty ]
663+
664+ type config_error =
665+ | Config_vf_rate_not_supported
666+ | Unknown of string
667+ [@@ deriving rpcty ]
668+
669+ type config_result =
670+ | Ok
671+ | Error of config_error
672+ [@@ deriving rpcty ]
673+
674+ let iface_name_p = Param. mk ~name: " name" ~description: [" interface name" ] iface
675+
676+ let enable =
677+ let result_p = Param. mk ~description: [" SR-IOV enable result" ] enable_result in
678+ declare
679+ " Sriov.enable"
680+ [" Enable SR-IOV" ]
681+ (debug_info_p @-> iface_name_p @-> returning result_p err)
682+
683+ let disable =
684+ let result_p = Param. mk ~description: [" SR-IOV disable result" ] disable_result in
685+ declare
686+ " Sriov.disable"
687+ [" Disable SR-IOV" ]
688+ (debug_info_p @-> iface_name_p @-> returning result_p err)
689+
690+ let make_vf_config =
691+ let pci_address_p = Param. mk ~description: [" pci address" ] Xcp_pci. address in
692+ let vf_info_p = Param. mk ~description: [" vf info" ] sriov_pci_t in
693+ let result_t = Param. mk ~description: [" SR-IOV make vf configuration result" ] config_result in
694+ declare
695+ " Sriov.make_vf_config"
696+ [" Make SR-IOV vf config" ]
697+ (debug_info_p @-> pci_address_p @-> vf_info_p @-> returning result_t err)
698+ end
699+ end
0 commit comments