- container_cnt = len(self.containers)
- mod = container_cnt/dut_cnt
-
- 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(vat_template_file, 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))
+ mod = len(self.containers)/dut_cnt
+ 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()
+ c_name = self.engine.container.name
+ guest_dir = self.engine.container.mnt[0].split(':')[1]
+ self.engine.create_vpp_exec_config(
+ container_vat_template,
+ mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2,
+ socket1='{dir}/memif-{c_name}-{sid}'.
+ format(c_name=c_name, sid=sid1, dir=guest_dir),
+ socket2='{dir}/memif-{c_name}-{sid}'.
+ format(c_name=c_name, sid=sid2, dir=guest_dir))
+ 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
+ try:
+ dut1_if = kwargs['dut1_if']
+ except KeyError:
+ raise AttributeError('Missing dut1_if parameter.')
+ try:
+ dut2_if = kwargs['dut2_if']
+ except KeyError:
+ raise AttributeError('Missing dut2_if parameter.')
+ self.engine.container = self.containers[container]
+ c_name = self.engine.container.name
+ guest_dir = self.engine.container.mnt[0].split(':')[1]
+ 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='{dir}/memif-{c_name}-{sid}'.
+ format(c_name=c_name, sid=sid1, dir=guest_dir))
+ elif chain_topology == 'chain_functional':
+ 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
+ memif_rx_mode = 'interrupt'
+ self.engine.container = self.containers[container]
+ self.engine.create_vpp_startup_config_func_dev()
+ c_name = self.engine.container.name
+ guest_dir = self.engine.container.mnt[0].split(':')[1]
+ self.engine.create_vpp_exec_config(
+ container_vat_template,
+ mid1=mid1, mid2=mid2, sid1=sid1, sid2=sid2,
+ socket1='{dir}/memif-{c_name}-{sid}'.
+ format(c_name=c_name, sid=sid1, dir=guest_dir),
+ socket2='{dir}/memif-{c_name}-{sid}'.
+ format(c_name=c_name, sid=sid2, dir=guest_dir),
+ rx_mode=memif_rx_mode)
+ else:
+ raise RuntimeError('Container topology {topology} not implemented'.
+ format(topology=chain_topology))