fix(core): AWS BPS limit
[csit.git] / resources / libraries / python / VppConfigGenerator.py
index 9a11762..0628e8e 100644 (file)
@@ -21,7 +21,7 @@ from resources.libraries.python.topology import NodeType
 from resources.libraries.python.topology import Topology
 from resources.libraries.python.VPPUtil import VPPUtil
 
-__all__ = [u"VppConfigGenerator"]
+__all__ = ["VppConfigGenerator", "VppInitConfig"]
 
 
 def pci_dev_check(pci_dev):
@@ -259,12 +259,13 @@ class VppConfigGenerator:
         :param count: Number of HW crypto devices to add.
         :type count: int
         """
-        cryptodev = Topology.get_cryptodev(self._node)
-        for i in range(count):
-            cryptodev_config = re.sub(r"\d.\d$", f"1.{str(i)}", cryptodev)
-            path = [u"dpdk", f"dev {cryptodev_config}"]
-            self.add_config_item(self._nodeconfig, u"", path)
-        self.add_dpdk_uio_driver(u"vfio-pci")
+        cryptodevs = Topology.get_cryptodev(self._node)
+        for device in cryptodevs.values():
+            for i in range(int(count/len(cryptodevs))):
+                addr = re.sub(r"\d.\d$", f"0.{i+1}", device["pci_address"])
+                path = ["dpdk", f"dev {addr}"]
+                self.add_config_item(self._nodeconfig, "", path)
+        self.add_dpdk_uio_driver("vfio-pci")
 
     def add_dpdk_sw_cryptodev(self, sw_pmd_type, socket_id, count):
         """Add DPDK SW Crypto device configuration.
@@ -704,3 +705,40 @@ class VppConfigGenerator:
         VPPUtil.restart_vpp_service(self._node, self._node_key)
         if verify_vpp:
             VPPUtil.verify_vpp(self._node)
+
+
+class VppInitConfig:
+    """VPP Initial Configuration."""
+    @staticmethod
+    def init_vpp_startup_configuration_on_all_duts(nodes):
+        """Apply initial VPP startup configuration on all DUTs.
+
+        :param nodes: Nodes in the topology.
+        :type nodes: dict
+        """
+        huge_size = Constants.DEFAULT_HUGEPAGE_SIZE
+        for node in nodes.values():
+            if node[u"type"] == NodeType.DUT:
+                vpp_config = VppConfigGenerator()
+                vpp_config.set_node(node)
+                vpp_config.add_unix_log()
+                vpp_config.add_unix_cli_listen()
+                vpp_config.add_unix_cli_no_pager()
+                vpp_config.add_unix_gid()
+                vpp_config.add_unix_coredump()
+                vpp_config.add_socksvr(socket=Constants.SOCKSVR_PATH)
+                vpp_config.add_main_heap_size("2G")
+                vpp_config.add_main_heap_page_size(huge_size)
+                vpp_config.add_default_hugepage_size(huge_size)
+                vpp_config.add_statseg_size("2G")
+                vpp_config.add_statseg_page_size(huge_size)
+                vpp_config.add_statseg_per_node_counters("on")
+                vpp_config.add_plugin("disable", "default")
+                vpp_config.add_plugin("enable", "dpdk_plugin.so")
+                vpp_config.add_dpdk_dev(
+                    *[node["interfaces"][interface].get("pci_address") \
+                        for interface in node[u"interfaces"]]
+                )
+                vpp_config.add_ip6_hash_buckets(2000000)
+                vpp_config.add_ip6_heap_size("4G")
+                vpp_config.apply_config()