@@ -188,7 +188,8 @@ module Sysfs = struct
188188 try
189189 let devpath = getpath name " device" in
190190 let driver_link = Unix. readlink (devpath ^ " /driver" ) in
191- (* filter out symlinks under device/driver which look like /../../../devices/xen-backend/vif- *)
191+ (* filter out symlinks under device/driver which look like
192+ /../../../devices/xen-backend/vif- *)
192193 not
193194 (List. mem " xen-backend"
194195 (Astring.String. cuts ~empty: false ~sep: " /" driver_link))
@@ -239,8 +240,8 @@ module Sysfs = struct
239240 Result. Error
240241 (Fail_to_get_driver_name , " Failed to get driver name for: " ^ dev)
241242
242- (* * Returns the features bitmap for the driver for [dev].
243- * The features bitmap is a set of NETIF_F_ flags supported by its driver. *)
243+ (* * Returns the features bitmap for the driver for [dev]. The features bitmap
244+ is a set of NETIF_F_ flags supported by its driver. *)
244245 let get_features dev =
245246 try Some (int_of_string (read_one_line (getpath dev " features" )))
246247 with _ -> None
@@ -274,9 +275,11 @@ module Sysfs = struct
274275 let ifaces = list () in
275276 List. filter (fun name -> Sys. file_exists (getpath name " bridge" )) ifaces
276277
277- (* * Returns (speed, duplex) for a given network interface: int megabits/s, Duplex.
278- * The units of speed are specified in pif_record in xen-api/xapi/records.ml.
279- * Note: these data are present in sysfs from kernel 2.6.33. *)
278+ (* * Returns (speed, duplex) for a given network interface: int megabits/s,
279+ Duplex. The units of speed are specified in pif_record in
280+ xen-api/xapi/records.ml.
281+
282+ Note: these data are present in sysfs from kernel 2.6.33. *)
280283 let get_status name =
281284 let speed =
282285 getpath name " speed" |> fun p ->
@@ -653,7 +656,8 @@ module Ip = struct
653656 with _ ->
654657 Result. Error (Fail_to_set_vf_vlan , " Failed to set VF VLAN for: " ^ dev)
655658
656- (* We know some NICs do not support config VF Rate, so will explicitly tell XAPI this error*)
659+ (* We know some NICs do not support config VF Rate, so will explicitly tell
660+ XAPI this error*)
657661 let set_vf_rate dev index rate =
658662 try
659663 debug " Setting VF rate for dev: %s, index: %d, rate: %d" dev index rate ;
@@ -670,9 +674,10 @@ module Linux_bonding = struct
670674 debug " Loading bonding driver" ;
671675 try
672676 ignore (call_script modprobe [" bonding" ]) ;
673- (* is_bond_device() uses the contents of sysfs_bonding_masters to work out which devices
674- * have already been created. Unfortunately the driver creates "bond0" automatically at
675- * modprobe init. Get rid of this now or our accounting will go wrong. *)
677+ (* is_bond_device() uses the contents of sysfs_bonding_masters to work out
678+ which devices have already been created. Unfortunately the driver
679+ creates "bond0" automatically at modprobe init. Get rid of this now or
680+ our accounting will go wrong. *)
676681 Sysfs. write_one_line bonding_masters " -bond0"
677682 with _ -> error " Failed to load bonding driver"
678683
@@ -822,8 +827,8 @@ module Linux_bonding = struct
822827 debug " Current bond properties: %s"
823828 (String. concat " , "
824829 (List. map (fun (k , v ) -> k ^ " =" ^ v) current_props)) ;
825- (* Find out which properties are known, but different from the current state,
826- * and only continue if there is at least one of those. *)
830+ (* Find out which properties are known, but different from the current
831+ state, and only continue if there is at least one of those. *)
827832 let props_to_update =
828833 List. filter
829834 (fun (prop , value ) ->
@@ -986,7 +991,8 @@ end = struct
986991 (* dhclient is not running, so we need to start it. *)
987992 ignore (start ~ipv6 interface options)
988993 else
989- (* dhclient is running - if the config has changed, update the config file and restart. *)
994+ (* dhclient is running - if the config has changed, update the config file
995+ and restart. *)
990996 let current_conf = read_conf_file ~ipv6 interface in
991997 let new_conf = generate_conf ~ipv6 interface options in
992998 if current_conf <> Some new_conf then (
@@ -1251,13 +1257,13 @@ module Ovs = struct
12511257 with _ -> warn " Failed to set max-idle=%d on OVS" t
12521258
12531259 let handle_vlan_bug_workaround override bridge =
1254- (* This is a list of drivers that do support VLAN tx or rx acceleration, but
1255- * to which the VLAN bug workaround should not be applied. This could be
1256- * because these are known-good drivers (that is, they do not have any of
1257- * the bugs that the workaround avoids) or because the VLAN bug workaround
1258- * will not work for them and may cause other problems.
1259- *
1260- * This is a very short list because few drivers have been tested. *)
1260+ (* This is a list of drivers that do support VLAN tx or rx acceleration,
1261+ but to which the VLAN bug workaround should not be applied. This could
1262+ be because these are known-good drivers (that is, they do not have any
1263+ of the bugs that the workaround avoids) or because the VLAN bug
1264+ workaround will not work for them and may cause other problems.
1265+
1266+ This is a very short list because few drivers have been tested. *)
12611267 let no_vlan_workaround_drivers = [" bonding" ] in
12621268 let phy_interfaces =
12631269 try
@@ -1357,7 +1363,9 @@ module Ovs = struct
13571363 (fun vif -> Astring.String. is_prefix ~affix: " vif" vif)
13581364 bvifs
13591365 in
1360- (* The vifs may be large. However considering current XS limit of 1000VM*7NIC/VM + 800VLANs, the buffer of CLI should be sufficient for lots of vifxxxx.xx *)
1366+ (* The vifs may be large. However considering current XS limit of
1367+ 1000VM*7NIC/VM + 800VLANs, the buffer of CLI should be sufficient for
1368+ lots of vifxxxx.xx *)
13611369 fork_script ! inject_igmp_query_script
13621370 ([
13631371 " --no-check-snooping-toggle"
@@ -1493,14 +1501,16 @@ module Ovs = struct
14931501 let del_old_arg =
14941502 let real_bridge_exists () =
14951503 try
1496- (* `ovs-vsctl br-to-parent <name>` returns <name> if <name> is a current " real" bridge *)
1504+ (* `ovs-vsctl br-to-parent <name>` returns <name> if <name> is a
1505+ current " real" bridge *)
14971506 vsctl ~log:false [" br- to - parent" ; name] |> String.trim = name
14981507 with _ -> false
14991508 in
15001509 if vlan <> None && real_bridge_exists () then
1501- (* This is to handle the case that a " real" bridge (not a " fake" VLAN bridge)
1502- already exists, while we need to create a VLAN bridge with the same name.
1503- The bridge will be destroyed and recreated, and the interfaces on it are put back. *)
1510+ (* This is to handle the case that a " real" bridge (not a " fake" VLAN
1511+ bridge) already exists, while we need to create a VLAN bridge with
1512+ the same name. The bridge will be destroyed and recreated, and the
1513+ interfaces on it are put back. *)
15041514 [" -- " ; " -- if - exists" ; " del- br" ; name]
15051515 else
15061516 []
@@ -1882,19 +1892,19 @@ module Modprobe = struct
18821892 ( Fail_to_write_modprobe_cfg
18831893 , " Failed to write modprobe configuration file for: " ^ driver )
18841894
1885- (*
1886- For a igb driver, the module config file will be at path `/etc/modprobe.d/igb.conf`
1887- The module config file is like:
1888- # VFs-param: max_vfs
1889- # VFs-maxvfs-by-default: 7
1890- # VFs-maxvfs-by-user:
1891- options igb max_vfs=7,7
1892-
1893- Example of calls:
1894- "igb" -> "VFs-param" -> Some "max_vfs"
1895- "igb" -> "VFs-maxvfs-by-default" -> Some "7"
1896- "igb" -> "VFs-maxvfs-by-user" -> None
1897- "igb" -> "Not existed comments" -> None
1895+ (* For a igb driver, the module config file will be at path
1896+ `/etc/modprobe.d/igb.conf`
1897+
1898+ The module config file is like:
1899+ # VFs-param: max_vfs
1900+ # VFs-maxvfs-by-default: 7
1901+ # VFs-maxvfs-by-user: options igb max_vfs=7,7
1902+
1903+ Example of calls:
1904+ "igb" -> "VFs-param" -> Some "max_vfs"
1905+ "igb" -> "VFs-maxvfs-by-default" -> Some "7"
1906+ "igb" -> "VFs-maxvfs-by-user" -> None
1907+ "igb" -> "Not existed comments" -> None
18981908 *)
18991909 let get_config_from_comments driver =
19001910 try
@@ -1917,11 +1927,12 @@ module Modprobe = struct
19171927 Some (String. trim k, String. trim v))
19181928 with _ -> []
19191929
1920- (* this function not returning None means that the driver doesn't suppport sysfs.
1921- If a driver doesn't support sysfs, then we add VF_param into its driver modprobe
1922- configuration. Therefore, from XAPI's perspective, if Modprobe.get_vf_param is
1923- not None, the driver definitely should use modprobe other than sysfs,
1924- and if Modprobe.get_vf_param is None, we just simple try sysfs. *)
1930+ (* this function not returning None means that the driver doesn't suppport
1931+ sysfs. If a driver doesn't support sysfs, then we add VF_param into its
1932+ driver modprobe configuration. Therefore, from XAPI's perspective, if
1933+ Modprobe.get_vf_param is not None, the driver definitely should use
1934+ modprobe other than sysfs, and if Modprobe.get_vf_param is None, we just
1935+ simple try sysfs. *)
19251936 let get_vf_param config =
19261937 try Some (List. assoc " VFs-param" config) with _ -> None
19271938
@@ -1946,11 +1957,11 @@ module Modprobe = struct
19461957 let config_sriov driver vf_param maxvfs =
19471958 let open Rresult.R.Infix in
19481959 Modinfo. is_param_array driver vf_param >> = fun is_array ->
1949- (* To enable SR-IOV via modprobe configuration, we first determine if the driver requires
1950- in the configuration an array like `options igb max_vfs=7,7,7,7` or a single value
1951- like `options igb max_vfs=7`. If an array is required, this repeat times equals to
1952- the number of devices with the same driver.
1953- *)
1960+ (* To enable SR-IOV via modprobe configuration, we first determine if the
1961+ driver requires in the configuration an array like `options igb
1962+ max_vfs=7,7,7,7` or a single value like `options igb max_vfs=7`. If an
1963+ array is required, this repeat times equals to the number of devices with
1964+ the same driver. *)
19541965 let repeat =
19551966 if is_array then Sysfs. get_dev_nums_with_same_driver driver else 1
19561967 in
@@ -1969,7 +1980,8 @@ module Modprobe = struct
19691980 let parse_single_line s =
19701981 let parse_driver_options s =
19711982 match Astring.String. cut ~sep: " =" s with
1972- (* has SR-IOV configuration but the max_vfs is exactly what we want to set, so no changes and return s *)
1983+ (* has SR-IOV configuration but the max_vfs is exactly what we want to
1984+ set, so no changes and return s *)
19731985 | Some (k , v ) when k = vf_param && v = option ->
19741986 has_probe_conf := true ;
19751987 s
0 commit comments