X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FVppConfigGenerator.py;h=e1830147d8662e60c7d1ee05842befeada58a8f4;hp=437386d81d165900c65c6245ffe9d021bbe0f60b;hb=b6606e7625e308a66bdfb9d5a9c065b58e429a99;hpb=925b50c85a24b3c91031d09eeca19f17b4e01f2c diff --git a/resources/libraries/python/VppConfigGenerator.py b/resources/libraries/python/VppConfigGenerator.py index 437386d81d..e1830147d8 100644 --- a/resources/libraries/python/VppConfigGenerator.py +++ b/resources/libraries/python/VppConfigGenerator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2022 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: @@ -11,12 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""VPP Configuration File Generator library. - -TODO: Support initialization with default values, -so that we do not need to have block of 6 "Add Unix" commands -in 7 various places of CSIT code. -""" +"""VPP Configuration File Generator library.""" import re @@ -67,8 +62,6 @@ class VppConfigGenerator: self._vpp_logfile = u"/tmp/vpe.log" # VPP Startup config location self._vpp_startup_conf = u"/etc/vpp/startup.conf" - # VPP Startup config backup location - self._vpp_startup_conf_backup = None def set_node(self, node, node_key=None): """Set DUT node. @@ -86,22 +79,6 @@ class VppConfigGenerator: self._node = node self._node_key = node_key - def set_vpp_logfile(self, logfile): - """Set VPP logfile location. - - :param logfile: VPP logfile location. - :type logfile: str - """ - self._vpp_logfile = logfile - - def set_vpp_startup_conf_backup(self, backup=u"/etc/vpp/startup.backup"): - """Set VPP startup configuration backup. - - :param backup: VPP logfile location. - :type backup: str - """ - self._vpp_startup_conf_backup = backup - def get_config_str(self): """Get dumped startup configuration in VPP config format. @@ -176,6 +153,11 @@ class VppConfigGenerator: path = [u"unix", u"cli-listen"] self.add_config_item(self._nodeconfig, value, path) + def add_unix_cli_no_pager(self): + """Add UNIX cli-no-pager configuration.""" + path = [u"unix", u"cli-no-pager"] + self.add_config_item(self._nodeconfig, u"", path) + def add_unix_gid(self, value=u"vpp"): """Add UNIX gid configuration. @@ -275,20 +257,6 @@ class VppConfigGenerator: path = [u"dpdk", f"dev {device}"] self.add_config_item(self._nodeconfig, u"", path) - def add_dpdk_dev_parameter(self, device, parameter, value): - """Add parameter for DPDK device. - - :param device: PCI device (format xxxx:xx:xx.x). - :param parameter: Parameter name. - :param value: Parameter value. - :type device: str - :type parameter: str - :type value: str - """ - if pci_dev_check(device): - path = [u"dpdk", f"dev {device}", parameter] - self.add_config_item(self._nodeconfig, value, path) - def add_dpdk_cryptodev(self, count): """Add DPDK Crypto PCI device configuration. @@ -381,6 +349,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. @@ -417,6 +401,15 @@ class VppConfigGenerator: path = [u"memory", u"main-heap-page-size"] self.add_config_item(self._nodeconfig, value, path) + def add_default_hugepage_size(self, value=Constants.DEFAULT_HUGEPAGE_SIZE): + """Add Default Hugepage Size configuration. + + :param value: Hugepage size. + :type value: str + """ + path = [u"memory", u"default-hugepage-size"] + self.add_config_item(self._nodeconfig, value, path) + def add_api_trace(self): """Add API trace configuration.""" path = [u"api-trace", u"on"] @@ -440,6 +433,11 @@ class VppConfigGenerator: path = [u"ip6", u"heap-size"] self.add_config_item(self._nodeconfig, value, path) + def add_spd_flow_cache_ipv4_outbound(self): + """Add SPD flow cache for IP4 outbound traffic""" + path = [u"ipsec", u"ipv4-outbound-spd-flow-cache"] + self.add_config_item(self._nodeconfig, "on", path) + def add_statseg_size(self, value): """Add Stats Heap Size configuration. @@ -644,12 +642,6 @@ class VppConfigGenerator: if filename is None: filename = self._vpp_startup_conf - if self._vpp_startup_conf_backup is not None: - cmd = f"cp {self._vpp_startup_conf} {self._vpp_startup_conf_backup}" - exec_cmd_no_error( - self._node, cmd, sudo=True, message=u"Copy config file failed!" - ) - cmd = f"echo \"{self._vpp_config}\" | sudo tee {filename}" exec_cmd_no_error( self._node, cmd, message=u"Writing config file failed!" @@ -671,10 +663,3 @@ class VppConfigGenerator: VPPUtil.restart_vpp_service(self._node, self._node_key) if verify_vpp: VPPUtil.verify_vpp(self._node) - - def restore_config(self): - """Restore VPP startup.conf from backup.""" - cmd = f"cp {self._vpp_startup_conf_backup} {self._vpp_startup_conf}" - exec_cmd_no_error( - self._node, cmd, sudo=True, message=u"Copy config file failed!" - )