+ guest_dir = self.engine.container.mnt[0].split(u":")[1]
+
+ if chain_topology == u"chain":
+ self._configure_vpp_chain_l2xc(
+ mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2,
+ guest_dir=guest_dir, **kwargs
+ )
+ elif chain_topology == u"cross_horiz":
+ self._configure_vpp_cross_horiz(
+ mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2,
+ guest_dir=guest_dir, **kwargs
+ )
+ elif chain_topology == u"chain_functional":
+ self._configure_vpp_chain_functional(
+ mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2,
+ guest_dir=guest_dir, **kwargs
+ )
+ elif chain_topology == u"chain_ip4":
+ self._configure_vpp_chain_ip4(
+ mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2,
+ guest_dir=guest_dir, **kwargs
+ )
+ elif chain_topology == u"pipeline_ip4":
+ self._configure_vpp_pipeline_ip4(
+ mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2,
+ guest_dir=guest_dir, **kwargs
+ )
+ else:
+ raise RuntimeError(
+ f"Container topology {chain_topology} not implemented"
+ )
+
+ def _configure_vpp_chain_l2xc(self, **kwargs):
+ """Configure VPP in chain topology with l2xc.
+
+ :param kwargs: Named parameters.
+ :param kwargs: dict
+ """
+ self.engine.create_vpp_startup_config()
+ self.engine.create_vpp_exec_config(
+ u"memif_create_chain_l2xc.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).
+
+ :param kwargs: Named parameters.
+ :param kwargs: dict
+ """
+ if u"DUT1" in self.engine.container.name:
+ if_pci = Topology.get_interface_pci_addr(
+ self.engine.container.node, kwargs[u"dut1_if"])
+ if_name = Topology.get_interface_name(
+ self.engine.container.node, kwargs[u"dut1_if"])
+ if u"DUT2" in self.engine.container.name:
+ if_pci = Topology.get_interface_pci_addr(
+ self.engine.container.node, kwargs[u"dut2_if"])
+ if_name = Topology.get_interface_name(
+ self.engine.container.node, kwargs[u"dut2_if"])
+ self.engine.create_vpp_startup_config_dpdk_dev(if_pci)
+ self.engine.create_vpp_exec_config(
+ u"memif_create_cross_horizon.exec",
+ mid1=kwargs[u"mid1"], sid1=kwargs[u"sid1"], if_name=if_name,
+ socket1=f"{kwargs[u'guest_dir']}/memif-"
+ f"{self.engine.container.name}-{kwargs[u'sid1']}"
+ )
+
+ def _configure_vpp_chain_functional(self, **kwargs):
+ """Configure VPP in chain topology with l2xc (functional).
+
+ :param kwargs: Named parameters.
+ :param kwargs: dict
+ """
+ self.engine.create_vpp_startup_config_func_dev()
+ self.engine.create_vpp_exec_config(
+ u"memif_create_chain_functional.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']}",
+ rx_mode=u"interrupt"
+ )
+
+ def _configure_vpp_chain_ip4(self, **kwargs):
+ """Configure VPP in chain topology with ip4.
+
+ :param kwargs: Named parameters.
+ :param kwargs: dict
+ """
+ self.engine.create_vpp_startup_config()
+
+ vif1_mac = kwargs[u"tg_if1_mac"] \
+ if (kwargs[u"mid1"] - 1) % kwargs[u"nodes"] + 1 == 1 \
+ else f"52:54:00:00:{(kwargs[u'mid1'] - 1):02X}:02"
+ vif2_mac = kwargs[u"tg_if2_mac"] \
+ if (kwargs[u"mid2"] - 1) % kwargs[u"nodes"] + 1 == kwargs[u"nodes"]\
+ else f"52:54:00:00:{(kwargs['mid2'] + 1):02X}:01"
+ self.engine.create_vpp_exec_config(
+ u"memif_create_chain_ip4.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']}",
+ mac1=f"52:54:00:00:{kwargs[u'mid1']:02X}:01",
+ mac2=f"52:54:00:00:{kwargs[u'mid2']:02X}:02",
+ vif1_mac=vif1_mac, vif2_mac=vif2_mac
+ )
+
+ def _configure_vpp_pipeline_ip4(self, **kwargs):
+ """Configure VPP in pipeline topology with ip4.
+
+ :param kwargs: Named parameters.
+ :param kwargs: dict
+ """
+ self.engine.create_vpp_startup_config()
+ node = (kwargs[u"mid1"] - 1) % kwargs[u"nodes"] + 1
+ mid1 = kwargs[u"mid1"]
+ mid2 = kwargs[u"mid2"]
+ role1 = u"master"
+ role2 = u"master" if node in (kwargs[u"nodes"], 1) else u"slave"
+ kwargs[u"mid2"] = kwargs[u"mid2"] if node in (kwargs[u"nodes"], 1) \
+ else kwargs[u"mid2"] + 1
+ vif1_mac = kwargs[u"tg_if1_mac"] \
+ if (kwargs[u"mid1"] - 1) % kwargs[u"nodes"] + 1 == 1 \
+ else f"52:54:00:00:{(kwargs[u'mid1'] - 1):02X}:02"
+ vif2_mac = kwargs[u"tg_if2_mac"] \
+ if (kwargs[u"mid2"] - 1) % kwargs[u"nodes"] + 1 == kwargs[u"nodes"]\
+ else f"52:54:00:00:{(kwargs[u'mid2'] + 1):02X}:01"
+ socket1 = f"{kwargs[u'guest_dir']}/memif-{self.engine.container.name}-"\
+ f"{kwargs[u'sid1']}" if node == 1 \
+ else f"{kwargs[u'guest_dir']}/memif-pipe-{kwargs[u'mid1']}"
+ socket2 = f"{kwargs[u'guest_dir']}/memif-{self.engine.container.name}-"\
+ f"{kwargs[u'sid2']}" \
+ if node == 1 and kwargs[u"nodes"] == 1 or node == kwargs[u"nodes"] \
+ else f"{kwargs[u'guest_dir']}/memif-pipe-{kwargs[u'mid2']}"
+
+ self.engine.create_vpp_exec_config(
+ u"memif_create_pipeline_ip4.exec",
+ mid1=kwargs[u"mid1"], mid2=kwargs[u"mid2"],
+ sid1=kwargs[u"sid1"], sid2=kwargs[u"sid2"],
+ socket1=socket1, socket2=socket2, role1=role1, role2=role2,
+ mac1=f"52:54:00:00:{mid1:02X}:01",
+ mac2=f"52:54:00:00:{mid2:02X}:02",
+ vif1_mac=vif1_mac, vif2_mac=vif2_mac
+ )