+
+ def compute_circular_topology(self, nodes, filter_list=None, nic_pfs=1):
+ """Return computed circular path.
+
+ :param nodes: Nodes to append to the path.
+ :param filter_list: Filter criteria list.
+ :param nic_pfs: Number of PF of NIC.
+ :type nodes: dict
+ :type filter_list: list of strings
+ :type path_count: int
+ :returns: Topology information dictionary.
+ :rtype: dict
+ """
+ t_dict = dict()
+ duts = [key for key in nodes if u"DUT" in key]
+ t_dict[u"duts"] = duts
+ t_dict[u"duts_count"] = len(duts)
+ t_dict[u"int"] = u"pf"
+
+ for idx in range(0, nic_pfs // 2):
+ self.append_node(nodes[u"TG"])
+ for dut in duts:
+ self.append_node(nodes[dut], filter_list=filter_list)
+ self.append_node(nodes[u"TG"])
+ self.compute_path(always_same_link=False)
+
+ n_idx = 0
+ t_idx = 1
+ d_idx = 0
+ while True:
+ interface, node = self.next_interface()
+ if not interface:
+ break
+ if node[u"type"] == u"TG":
+ n_pfx = f"TG"
+ p_pfx = f"pf{t_idx}"
+ i_pfx = f"if{t_idx}"
+ n_idx = 0
+ t_idx = t_idx + 1
+ else:
+ n_pfx = f"DUT{n_idx // 2 + 1}"
+ p_pfx = f"pf{d_idx % 2 + t_idx - 1}"
+ i_pfx = f"if{d_idx % 2 + t_idx - 1}"
+ n_idx = n_idx + 1
+ d_idx = d_idx + 1
+
+ t_dict[f"{n_pfx}"] = node
+ t_dict[f"{n_pfx}_{p_pfx}"] = [interface]
+ t_dict[f"{n_pfx}_{p_pfx}_mac"] = \
+ [Topology.get_interface_mac(node, interface)]
+ t_dict[f"{n_pfx}_{p_pfx}_vlan"] = \
+ [Topology.get_interface_vlan(node, interface)]
+ t_dict[f"{n_pfx}_{p_pfx}_pci"] = \
+ [Topology.get_interface_pci_addr(node, interface)]
+ t_dict[f"{n_pfx}_{p_pfx}_ip4_addr"] = \
+ [Topology.get_interface_ip4(node, interface)]
+ t_dict[f"{n_pfx}_{p_pfx}_ip4_prefix"] = \
+ [Topology.get_interface_ip4_prefix_length(node, interface)]
+ if f"{n_pfx}_pf_pci" not in t_dict:
+ t_dict[f"{n_pfx}_pf_pci"] = []
+ t_dict[f"{n_pfx}_pf_pci"].append(
+ Topology.get_interface_pci_addr(node, interface))
+ if f"{n_pfx}_pf_keys" not in t_dict:
+ t_dict[f"{n_pfx}_pf_keys"] = []
+ t_dict[f"{n_pfx}_pf_keys"].append(interface)
+ # Backward compatibility below
+ t_dict[f"{n_pfx.lower()}_{i_pfx}"] = interface
+ t_dict[f"{n_pfx.lower()}_{i_pfx}_mac"] = \
+ Topology.get_interface_mac(node, interface)
+ t_dict[f"{n_pfx.lower()}_{i_pfx}_pci"] = \
+ Topology.get_interface_pci_addr(node, interface)
+ t_dict[f"{n_pfx.lower()}_{i_pfx}_ip4_addr"] = \
+ Topology.get_interface_ip4(node, interface)
+ t_dict[f"{n_pfx.lower()}_{i_pfx}_ip4_prefix"] = \
+ Topology.get_interface_ip4_prefix_length(node, interface)
+
+ self.clear_path()
+ return t_dict