- if osi_layer == 'L2' or osi_layer == 'L3':
- (ret, _, _) = ssh.exec_command(
- "sudo sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
- "- version: 2\n"
- " interfaces: [\"{0}\",\"{1}\"]\n"
- " port_info:\n"
- " - dest_mac: [{2}]\n"
- " src_mac: [{3}]\n"
- " - dest_mac: [{4}]\n"
- " src_mac: [{5}]\n"
- "EOF'"\
- .format(if1_pci, if2_pci,
- "0x"+if1_adj_addr.replace(":", ",0x"),
- "0x"+if1_addr.replace(":", ",0x"),
- "0x"+if2_adj_addr.replace(":", ",0x"),
- "0x"+if2_addr.replace(":", ",0x")))
- elif osi_layer == 'L7':
- (ret, _, _) = ssh.exec_command(
- "sudo sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
- "- version: 2\n"
- " interfaces: [\"{0}\",\"{1}\"]\n"
- " port_info:\n"
- " - ip: [{2}]\n"
- " default_gw: [{3}]\n"
- " - ip: [{4}]\n"
- " default_gw: [{5}]\n"
- "EOF'"\
- .format(if1_pci, if2_pci,
- if1_addr, if1_adj_addr,
- if2_addr, if2_adj_addr))
+ master_thread_id, latency_thread_id, socket, threads = \
+ CpuUtils.get_affinity_trex(
+ self._node, tg_if1, tg_if2,
+ tg_dtc=Constants.TREX_CORE_COUNT)
+
+ if osi_layer in (u"L2", u"L3"):
+ dst_mac0 = f"0x{if1_adj_addr.replace(u':', u',0x')}"
+ src_mac0 = f"0x{if1_addr.replace(u':', u',0x')}"
+ dst_mac1 = f"0x{if2_adj_addr.replace(u':', u',0x')}"
+ src_mac1 = f"0x{if2_addr.replace(u':', u',0x')}"
+ exec_cmd_no_error(
+ self._node,
+ f"sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
+ f"- version: 2\n"
+ f" c: {len(threads)}\n"
+ f" limit_memory: {Constants.TREX_LIMIT_MEMORY}\n"
+ f" interfaces: [\"{if1_pci}\",\"{if2_pci}\"]\n"
+ f" port_info:\n"
+ f" - dest_mac: [{dst_mac0}]\n"
+ f" src_mac: [{src_mac0}]\n"
+ f" - dest_mac: [{dst_mac1}]\n"
+ f" src_mac: [{src_mac1}]\n"
+ f" platform :\n"
+ f" master_thread_id: {master_thread_id}\n"
+ f" latency_thread_id: {latency_thread_id}\n"
+ f" dual_if:\n"
+ f" - socket: {socket}\n"
+ f" threads: {threads}\n"
+ f"EOF'",
+ sudo=True, message=u"TRex config generation!"
+ )
+ elif osi_layer == u"L7":
+ exec_cmd_no_error(
+ self._node,
+ f"sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
+ f"- version: 2\n"
+ f" c: {len(threads)}\n"
+ f" limit_memory: {Constants.TREX_LIMIT_MEMORY}\n"
+ f" interfaces: [\"{if1_pci}\",\"{if2_pci}\"]\n"
+ f" port_info:\n"
+ f" - ip: [{if1_addr}]\n"
+ f" default_gw: [{if1_adj_addr}]\n"
+ f" - ip: [{if2_addr}]\n"
+ f" default_gw: [{if2_adj_addr}]\n"
+ f" platform :\n"
+ f" master_thread_id: {master_thread_id}\n"
+ f" latency_thread_id: {latency_thread_id}\n"
+ f" dual_if:\n"
+ f" - socket: {socket}\n"
+ f" threads: {threads}\n"
+ f"EOF'",
+ sudo=True, message=u"TRex config generation!"
+ )