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