Add dpdk max-simd-bitwidth configuration.
[csit.git] / resources / libraries / python / VppConfigGenerator.py
index 02f7cf7..b5f36c6 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -202,9 +202,23 @@ class VppConfigGenerator:
 
     def add_socksvr(self, socket=Constants.SOCKSVR_PATH):
         """Add socksvr configuration."""
-        path = ['socksvr', u"socket-name"]
+        path = [u"socksvr", u"socket-name"]
         self.add_config_item(self._nodeconfig, socket, path)
 
+    def add_graph_node_variant(self, variant=Constants.GRAPH_NODE_VARIANT):
+        """Add default graph node variant.
+
+        :param value: Graph node variant default value.
+        :type value: str
+        """
+        if variant == u"":
+            return
+        variant_list = [u"hsw", u"skx", u"icl"]
+        if variant not in variant_list:
+            raise ValueError("Invalid graph node variant value")
+        path = [u"node", u"default", u"variant"]
+        self.add_config_item(self._nodeconfig, variant, path)
+
     def add_api_segment_gid(self, value=u"vpp"):
         """Add API-SEGMENT gid configuration.
 
@@ -241,6 +255,15 @@ class VppConfigGenerator:
         path = [u"buffers", u"buffers-per-numa"]
         self.add_config_item(self._nodeconfig, value, path)
 
+    def add_buffers_default_data_size(self, value):
+        """Increase buffers data-size allocated.
+
+        :param value: Buffers data-size allocated.
+        :type value: int
+        """
+        path = [u"buffers", u"default data-size"]
+        self.add_config_item(self._nodeconfig, value, path)
+
     def add_dpdk_dev(self, *devices):
         """Add DPDK PCI device configuration.
 
@@ -295,26 +318,6 @@ class VppConfigGenerator:
             path = [u"dpdk", cryptodev_config]
             self.add_config_item(self._nodeconfig, u"", path)
 
-    def add_dpdk_eth_bond_dev(self, ethbond_id, mode, xmit_policy, *slaves):
-        """Add DPDK Eth_bond device configuration.
-
-        :param ethbond_id: Eth_bond device ID.
-        :param mode: Link bonding mode.
-        :param xmit_policy: Transmission policy.
-        :param slaves: PCI device(s) to be bonded (format xxxx:xx:xx.x).
-        :type ethbond_id: str or int
-        :type mode: str or int
-        :type xmit_policy: str
-        :type slaves: list
-        """
-        slaves_config = u"slave=" + u",slave=".join(
-            slave if pci_dev_check(slave) else u"" for slave in slaves
-        )
-        ethbond_config = f"vdev eth_bond{ethbond_id}," \
-            f"mode={mode}{slaves_config},xmit_policy={xmit_policy}"
-        path = [u"dpdk", ethbond_config]
-        self.add_config_item(self._nodeconfig, u"", path)
-
     def add_dpdk_dev_default_rxq(self, value):
         """Add DPDK dev default rxq configuration.
 
@@ -378,6 +381,22 @@ class VppConfigGenerator:
         path = [u"dpdk", u"uio-driver"]
         self.add_config_item(self._nodeconfig, value, path)
 
+    def add_dpdk_max_simd_bitwidth(self, variant=Constants.GRAPH_NODE_VARIANT):
+        """Add DPDK max-simd-bitwidth configuration.
+
+        :param value: Graph node variant default value.
+        :type value: str
+        """
+        if variant == u"icl":
+            value = 512
+        elif variant in [u"skx", u"hsw"]:
+            value = 256
+        else:
+            return
+
+        path = [u"dpdk", u"max-simd-bitwidth"]
+        self.add_config_item(self._nodeconfig, value, path)
+
     def add_cpu_main_core(self, value):
         """Add CPU main core configuration.
 
@@ -396,13 +415,22 @@ class VppConfigGenerator:
         path = [u"cpu", u"corelist-workers"]
         self.add_config_item(self._nodeconfig, value, path)
 
-    def add_heapsize(self, value):
-        """Add Heapsize configuration.
+    def add_main_heap_size(self, value):
+        """Add Main Heap Size configuration.
+
+        :param value: Amount of heap.
+        :type value: str
+        """
+        path = [u"memory", u"main-heap-size"]
+        self.add_config_item(self._nodeconfig, value, path)
+
+    def add_main_heap_page_size(self, value):
+        """Add Main Heap Page Size configuration.
 
-        :param value: Amount of heapsize.
+        :param value: Heap page size.
         :type value: str
         """
-        path = [u"heapsize"]
+        path = [u"memory", u"main-heap-page-size"]
         self.add_config_item(self._nodeconfig, value, path)
 
     def add_api_trace(self):
@@ -428,22 +456,22 @@ class VppConfigGenerator:
         path = [u"ip6", u"heap-size"]
         self.add_config_item(self._nodeconfig, value, path)
 
-    def add_ip_heap_size(self, value):
-        """Add IP heap-size configuration.
+    def add_statseg_size(self, value):
+        """Add Stats Heap Size configuration.
 
-        :param value: IP Heapsize amount.
+        :param value: Stats heapsize amount.
         :type value: str
         """
-        path = [u"ip", u"heap-size"]
+        path = [u"statseg", u"size"]
         self.add_config_item(self._nodeconfig, value, path)
 
-    def add_statseg_size(self, value):
-        """Add stats segment heap size configuration.
+    def add_statseg_page_size(self, value):
+        """Add Stats Heap Page Size configuration.
 
         :param value: Stats heapsize amount.
         :type value: str
         """
-        path = [u"statseg", u"size"]
+        path = [u"statseg", u"page-size"]
         self.add_config_item(self._nodeconfig, value, path)
 
     def add_statseg_per_node_counters(self, value):
@@ -478,12 +506,35 @@ class VppConfigGenerator:
         self.add_config_item(self._nodeconfig, u"", path)
 
     def add_nat(self, value=u"deterministic"):
-        """Add NAT configuration.
+        """Add NAT mode configuration.
+
+        :param value: NAT mode.
+        :type value: str
+        """
+        path = [u"nat", value]
+        self.add_config_item(self._nodeconfig, u"", path)
+
+    def add_nat_max_translations_per_thread(self, value):
+        """Add NAT max. translations per thread number configuration.
 
         :param value: NAT mode.
         :type value: str
         """
-        path = [u"nat"]
+        path = [u"nat", u"max translations per thread"]
+        self.add_config_item(self._nodeconfig, value, path)
+
+    def add_nsim_poll_main_thread(self):
+        """Add NSIM poll-main-thread configuration."""
+        path = [u"nsim", u"poll-main-thread"]
+        self.add_config_item(self._nodeconfig, u"", path)
+
+    def add_tcp_congestion_control_algorithm(self, value=u"cubic"):
+        """Add TCP congestion control algorithm.
+
+        :param value: The congestion control algorithm to use. Example: cubic
+        :type value: str
+        """
+        path = [u"tcp", u"cc-algo"]
         self.add_config_item(self._nodeconfig, value, path)
 
     def add_tcp_preallocated_connections(self, value):
@@ -504,6 +555,16 @@ class VppConfigGenerator:
         path = [u"tcp", u"preallocated-half-open-connections"]
         self.add_config_item(self._nodeconfig, value, path)
 
+    def add_session_enable(self):
+        """Add session enable."""
+        path = [u"session", u"enable"]
+        self.add_config_item(self._nodeconfig, u"", path)
+
+    def add_session_event_queues_memfd_segment(self):
+        """Add session event queue memfd segment."""
+        path = [u"session", u"evt_qs_memfd_seg"]
+        self.add_config_item(self._nodeconfig, u"", path)
+
     def add_session_event_queue_length(self, value):
         """Add session event queue length.
 
@@ -513,6 +574,15 @@ class VppConfigGenerator:
         path = [u"session", u"event-queue-length"]
         self.add_config_item(self._nodeconfig, value, path)
 
+    def add_session_event_queues_segment_size(self, value):
+        """Add session event queue length.
+
+        :param value: Session event queue segment size.
+        :type value: str
+        """
+        path = [u"session", u"evt_qs_seg_size"]
+        self.add_config_item(self._nodeconfig, value, path)
+
     def add_session_preallocated_sessions(self, value):
         """Add the number of pre-allocated sessions.