-# 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:
dut_cnt = len(
Counter(
[
- self.containers[container].node[u"host"]
- for container in self.containers
+ f"{container.node['host']}{container.node['port']}"
+ for container in self.containers.values()
]
)
)
self._configure_vpp_chain_ipsec(
mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2,
guest_dir=guest_dir, nf_instance=idx, **kwargs)
+ elif chain_topology == u"chain_dma":
+ self._configure_vpp_chain_dma(
+ mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2,
+ guest_dir=guest_dir, **kwargs
+ )
else:
raise RuntimeError(
f"Container topology {chain_topology} not implemented"
f"{self.engine.container.name}-{kwargs[u'sid2']}"
)
+ def _configure_vpp_chain_dma(self, **kwargs):
+ """Configure VPP in chain topology with l2xc (dma).
+
+ :param kwargs: Named parameters.
+ :type kwargs: dict
+ """
+ dma_wqs = kwargs[f"dma_wqs"]
+ self.engine.create_vpp_startup_config_dma(dma_wqs)
+
+ self.engine.create_vpp_exec_config(
+ u"memif_create_chain_dma.exec",
+ mid1=kwargs[u"mid1"], mid2=kwargs[u"mid2"],
+ sid1=kwargs[u"sid1"], sid2=kwargs[u"sid2"],
+ socket1=f"{kwargs[u'guest_dir']}/memif-"
+ f"{self.engine.container.name}-{kwargs[u'sid1']}",
+ socket2=f"{kwargs[u'guest_dir']}/memif-"
+ f"{self.engine.container.name}-{kwargs[u'sid2']}"
+ )
+
def _configure_vpp_cross_horiz(self, **kwargs):
"""Configure VPP in cross horizontal topology (single memif).
def start_vpp(self, verify=True):
"""Start VPP inside a container."""
self.execute(
- u"setsid /usr/bin/vpp -c /etc/vpp/startup.conf "
- u">/tmp/vppd.log 2>&1 < /dev/null &")
+ u"/usr/bin/vpp -c /etc/vpp/startup.conf")
topo_instance = BuiltIn().get_library_instance(
u"resources.libraries.python.topology.Topology"
)
+ topo_instance.add_new_socket(
+ self.container.node,
+ SocketType.CLI,
+ self.container.name,
+ self.container.cli_socket,
+ )
topo_instance.add_new_socket(
self.container.node,
SocketType.PAPI,
# Execute puts the command into single quotes,
# so inner arguments are enclosed in qouble quotes here.
self.execute(
- u'vppctl show pci 2>&1 | '
+ u'/usr/bin/vppctl show pci 2>&1 | '
u'fgrep -v "Connection refused" | '
u'fgrep -v "No such file or directory"'
)
vpp_config = VppConfigGenerator()
vpp_config.set_node(self.container.node)
vpp_config.add_unix_cli_listen()
- vpp_config.add_unix_nodaemon()
vpp_config.add_unix_exec(u"/tmp/running.exec")
vpp_config.add_socksvr(socket=Constants.SOCKSVR_PATH)
if cpuset_cpus:
f'echo "{vpp_config.get_config_str()}" | tee /etc/vpp/startup.conf'
)
+ def create_vpp_startup_config_dma(self, dma_devices):
+ """Create startup configuration of VPP DMA.
+
+ :param dma_devices: DMA devices list.
+ :type dma_devices: list
+ """
+ vpp_config = self.create_base_vpp_startup_config()
+ vpp_config.add_plugin(u"enable", u"dma_intel_plugin.so")
+ vpp_config.add_dma_dev(dma_devices)
+
+ # Apply configuration
+ self.execute(u"mkdir -p /etc/vpp/")
+ self.execute(
+ f'echo "{vpp_config.get_config_str()}" | tee /etc/vpp/startup.conf'
+ )
+
def create_vpp_exec_config(self, template_file, **kwargs):
"""Create VPP exec configuration on container.
:type name: str
:raises RuntimeError: If applying cgroup settings via cgset failed.
"""
- ret, _, _ = self.container.ssh.exec_command_sudo(
- u"cgset -r cpuset.cpu_exclusive=0 /"
- )
- if int(ret) != 0:
- raise RuntimeError(u"Failed to apply cgroup settings.")
-
- ret, _, _ = self.container.ssh.exec_command_sudo(
- u"cgset -r cpuset.mem_exclusive=0 /"
- )
- if int(ret) != 0:
- raise RuntimeError(u"Failed to apply cgroup settings.")
-
ret, _, _ = self.container.ssh.exec_command_sudo(
f"cgcreate -g cpuset:/{name}"
)
raise RuntimeError(u"Failed to copy cgroup settings from root.")
ret, _, _ = self.container.ssh.exec_command_sudo(
- f"cgset -r cpuset.cpu_exclusive=0 /{name}"
+ f"cgset -r cpuset.cpus=0 /{name}"
)
if int(ret) != 0:
raise RuntimeError(u"Failed to apply cgroup settings.")
ret, _, _ = self.container.ssh.exec_command_sudo(
- f"cgset -r cpuset.mem_exclusive=0 /{name}"
+ f"cgset -r cpuset.mems=0 /{name}"
)
if int(ret) != 0:
raise RuntimeError(u"Failed to apply cgroup settings.")
else u"amd64"
image = self.container.image if self.container.image \
- else f"-d ubuntu -r focal -a {target_arch}"
+ else f"-d ubuntu -r jammy -a {target_arch}"
cmd = f"lxc-create -t download --name {self.container.name} " \
f"-- {image} --no-validate"
if self.container.mnt else u""
cmd = f"docker run --privileged --detach --interactive --tty --rm " \
- f"--cgroup-parent docker {cpuset_cpus} {cpuset_mems} {publish} " \
- f"{env} {volume} --name {self.container.name} " \
+ f"--cgroup-parent docker.slice {cpuset_cpus} {cpuset_mems} " \
+ f"{publish} {env} {volume} --name {self.container.name} " \
f"{self.container.image} {command}"
ret, _, _ = self.container.ssh.exec_command_sudo(cmd)
path = f"/tmp/vpp_sockets/{value}"
self.__dict__[u"socket_dir"] = path
self.__dict__[u"api_socket"] = f"{path}/api.sock"
+ self.__dict__[u"cli_socket"] = f"{path}/cli.sock"
self.__dict__[u"stats_socket"] = f"{path}/stats.sock"
self.__dict__[attr] = value
else: