X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FVppConfigGenerator.py;h=65a19b221174a898cbb936aaccc412a81259b6dd;hb=8370201a402ff92bb0f2c617e9e2b6c61ffbaf1c;hp=c338368ff432146b369b51b8ba2e97c3578aedb1;hpb=f27f09b9a3997710844b662c882505f783b56934;p=csit.git diff --git a/resources/libraries/python/VppConfigGenerator.py b/resources/libraries/python/VppConfigGenerator.py index c338368ff4..65a19b2211 100644 --- a/resources/libraries/python/VppConfigGenerator.py +++ b/resources/libraries/python/VppConfigGenerator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Cisco and/or its affiliates. +# Copyright (c) 2024 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: @@ -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): @@ -58,8 +58,6 @@ class VppConfigGenerator: self._vpp_config = u"" # VPP Service name self._vpp_service_name = u"vpp" - # VPP Logfile location - self._vpp_logfile = u"/tmp/vpe.log" # VPP Startup config location self._vpp_startup_conf = u"/etc/vpp/startup.conf" @@ -133,15 +131,13 @@ class VppConfigGenerator: if level >= 0: self._vpp_config += f"{level * indent}}}\n" - def add_unix_log(self, value=None): + def add_unix_log(self, value="/var/log/vpp/vpp.log"): """Add UNIX log configuration. :param value: Log file. :type value: str """ path = [u"unix", u"log"] - if value is None: - value = self._vpp_logfile self.add_config_item(self._nodeconfig, value, path) def add_unix_cli_listen(self, value=u"/run/vpp/cli.sock"): @@ -153,6 +149,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. @@ -252,32 +253,23 @@ 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): + def add_dpdk_cryptodev(self, count, num_rx_queues=1): """Add DPDK Crypto PCI device configuration. :param count: Number of HW crypto devices to add. + :param num_rx_queues: Number of RX queues per QAT interface. :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") + :type num_rx_queues: int + """ + cryptodevs = Topology.get_cryptodev(self._node) + for device in cryptodevs.values(): + for i in range(int(count/len(cryptodevs))): + numvfs = device["numvfs"] + computed = f"{(i+1)//numvfs}.{(i+1)%numvfs}" + addr = re.sub(r"\d.\d$", computed, device["pci_address"]) + path = ["dpdk", f"dev {addr}", "num-rx-queues"] + self.add_config_item(self._nodeconfig, num_rx_queues, 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. @@ -442,10 +434,50 @@ 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""" + def add_ipsec_spd_flow_cache_ipv4_inbound(self, value): + """Add IPsec spd flow cache for IP4 inbound. + + :param value: "on" to enable spd flow cache. + :type value: str + """ + path = [u"ipsec", u"ipv4-inbound-spd-flow-cache"] + self.add_config_item(self._nodeconfig, value, path) + + def add_ipsec_spd_flow_cache_ipv4_outbound(self, value): + """Add IPsec spd flow cache for IP4 outbound. + + :param value: "on" to enable spd flow cache. + :type value: str + """ path = [u"ipsec", u"ipv4-outbound-spd-flow-cache"] - self.add_config_item(self._nodeconfig, "on", path) + self.add_config_item(self._nodeconfig, value, path) + + def add_ipsec_spd_fast_path_ipv4_inbound(self, value): + """Add IPsec spd fast path for IP4 inbound. + + :param value: "on" to enable spd fast path. + :type value: str + """ + path = [u"ipsec", u"ipv4-inbound-spd-fast-path"] + self.add_config_item(self._nodeconfig, value, path) + + def add_ipsec_spd_fast_path_ipv4_outbound(self, value): + """Add IPsec spd fast path for IP4 outbound. + + :param value: "on" to enable spd fast path. + :type value: str + """ + path = [u"ipsec", u"ipv4-outbound-spd-fast-path"] + self.add_config_item(self._nodeconfig, value, path) + + def add_ipsec_spd_fast_path_num_buckets(self, value): + """Add num buckets for IPsec spd fast path. + + :param value: Number of buckets. + :type value: int + """ + path = [u"ipsec", u"spd-fast-path-num-buckets"] + self.add_config_item(self._nodeconfig, value, path) def add_statseg_size(self, value): """Add Stats Heap Size configuration. @@ -551,6 +583,11 @@ class VppConfigGenerator: path = [u"session", u"enable"] self.add_config_item(self._nodeconfig, u"", path) + def add_session_app_socket_api(self): + """Use session app socket api.""" + path = [u"session", u"use-app-socket-api"] + 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"] @@ -637,6 +674,16 @@ class VppConfigGenerator: path = [u"session", u"local-endpoints-table-memory"] self.add_config_item(self._nodeconfig, value, path) + def add_dma_dev(self, devices): + """Add DMA devices configuration. + + :param devices: DMA devices or work queues. + :type devices: list + """ + for device in devices: + path = [u"dsa", f"dev {device}"] + self.add_config_item(self._nodeconfig, u"", path) + def write_config(self, filename=None): """Generate and write VPP startup configuration to file. @@ -672,3 +719,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()