From 466674c41326aa5765f18805a9dbc37a8df7918a Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Thu, 22 Sep 2022 15:50:29 +0200 Subject: [PATCH] fix: l3fwd config Flipping logic depends whether TG and DUT ports are reordered. # If TG and DUT ports are reordered -> flip # If TG reordered and DUT not reordered -> don't flip # If DUT reordered and TG not reordered -> don't flip # If DUT and TG not reordered -> flip Change-Id: I7202a17e03e48d112ed5b98e3ef0e3816ce50f14 Signed-off-by: Vratko Polak --- resources/libraries/bash/function/dpdk.sh | 19 --------------- resources/libraries/python/DPDK/L3fwdTest.py | 36 +++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/resources/libraries/bash/function/dpdk.sh b/resources/libraries/bash/function/dpdk.sh index f013683659..d579cfc444 100644 --- a/resources/libraries/bash/function/dpdk.sh +++ b/resources/libraries/bash/function/dpdk.sh @@ -96,17 +96,6 @@ function dpdk_compile () { # Configure generic build - the same used by VPP meson_options="${meson_options} -Dplatform=generic" - # Patch L3FWD. - sed_rxd="s/^#define RTE_TEST_RX_DESC_DEFAULT 128" - sed_rxd+="/#define RTE_TEST_RX_DESC_DEFAULT 1024/g" - sed_txd="s/^#define RTE_TEST_TX_DESC_DEFAULT 512" - sed_txd+="/#define RTE_TEST_TX_DESC_DEFAULT 1024/g" - sed_file="./main.c" - pushd examples/l3fwd || die "Pushd failed" - sed -i "${sed_rxd}" "${sed_file}" || die "Patch failed" - sed -i "${sed_txd}" "${sed_file}" || die "Patch failed" - popd || die "Popd failed" - # Compile using Meson and Ninja. meson ${meson_options} build || { die "Failed to compile DPDK!" @@ -201,7 +190,6 @@ function dpdk_l3fwd_compile () { # # Variables read: # - DPDK_DIR - Path to DPDK framework. - # - CSIT_DIR - Path to CSIT framework. # Functions called: # - die - Print to stderr and exit. @@ -209,14 +197,7 @@ function dpdk_l3fwd_compile () { pushd "${DPDK_DIR}" || die "Pushd failed" # Patch L3FWD. - sed_rxd="s/^#define RTE_TEST_RX_DESC_DEFAULT 128" - sed_rxd+="/#define RTE_TEST_RX_DESC_DEFAULT 2048/g" - sed_txd="s/^#define RTE_TEST_TX_DESC_DEFAULT 512" - sed_txd+="/#define RTE_TEST_TX_DESC_DEFAULT 2048/g" - sed_file="./main.c" pushd examples/l3fwd || die "Pushd failed" - sed -i "${sed_rxd}" "${sed_file}" || die "Patch failed" - sed -i "${sed_txd}" "${sed_file}" || die "Patch failed" chmod +x ${1} && source ${1} || die "Patch failed" popd || die "Popd failed" diff --git a/resources/libraries/python/DPDK/L3fwdTest.py b/resources/libraries/python/DPDK/L3fwdTest.py index 2ceeab2a51..265806c7e9 100644 --- a/resources/libraries/python/DPDK/L3fwdTest.py +++ b/resources/libraries/python/DPDK/L3fwdTest.py @@ -55,6 +55,7 @@ class L3fwdTest: """ cpu_count_int = dp_count_int = int(phy_cores) dp_cores = cpu_count_int+1 + tg_flip = topology_info[f"tg_if1_pci"] > topology_info[f"tg_if2_pci"] for node in nodes: if u"DUT" in node: compute_resource_info = CpuUtils.get_affinity_vswitch( @@ -76,7 +77,7 @@ class L3fwdTest: L3fwdTest.start_l3fwd( nodes, nodes[node], if1=if1, if2=if2, lcores_list=cpu_dp, nb_cores=dp_count_int, queue_nums=rxq_count_int, - jumbo_frames=jumbo_frames + jumbo_frames=jumbo_frames, tg_flip=tg_flip ) for node in nodes: if u"DUT" in node: @@ -88,7 +89,8 @@ class L3fwdTest: L3fwdTest.start_l3fwd( nodes, nodes[node], if1=if1, if2=if2, lcores_list=cpu_dp, nb_cores=dp_count_int, - queue_nums=rxq_count_int, jumbo_frames=jumbo_frames + queue_nums=rxq_count_int, jumbo_frames=jumbo_frames, + tg_flip=tg_flip ) else: message = f"Failed to start l3fwd at node {node}" @@ -97,10 +99,14 @@ class L3fwdTest: @staticmethod def start_l3fwd( nodes, node, if1, if2, lcores_list, nb_cores, queue_nums, - jumbo_frames): + jumbo_frames, tg_flip): """ Execute the l3fwd on the dut_node. + L3fwd uses default IP forwarding table, but sorts ports by API address. + When that does not match the traffic profile (depends on topology), + the only way to fix is is to latch and recompile l3fwd app. + :param nodes: All the nodes info in the topology file. :param node: DUT node. :param if1: The test link interface 1. @@ -110,6 +116,7 @@ class L3fwdTest: :param queue_nums: The queues number for the NIC :param jumbo_frames: Indication if the jumbo frames are used (True) or not (False). + :param tg_flip: Whether TG ports are reordered. :type nodes: dict :type node: dict :type if1: str @@ -118,10 +125,11 @@ class L3fwdTest: :type nb_cores: str :type queue_nums: str :type jumbo_frames: bool + :type tg_flip: bool """ if node[u"type"] == NodeType.DUT: adj_mac0, adj_mac1, if_pci0, if_pci1 = L3fwdTest.get_adj_mac( - nodes, node, if1, if2 + nodes, node, if1, if2, tg_flip ) lcores = [int(item) for item in lcores_list.split(u",")] @@ -184,18 +192,24 @@ class L3fwdTest: exec_cmd_no_error(node, command, timeout=1800, message=message) @staticmethod - def get_adj_mac(nodes, node, if1, if2): + def get_adj_mac(nodes, node, if1, if2, tg_flip): """ Get adjacency MAC addresses of the DUT node. + Interfaces are re-ordered according to PCI address, + but the need to patch and recompile also depends on TG port order. + "tg_flip" signals whether TG ports are reordered. + :param nodes: All the nodes info in the topology file. :param node: DUT node. :param if1: The test link interface 1. :param if2: The test link interface 2. + :param tg_flip: Whether tg ports are reordered. :type nodes: dict :type node: dict :type if1: str :type if2: str + :type tg_flip: bool :returns: Returns MAC addresses of adjacency DUT nodes and PCI addresses. :rtype: str @@ -205,9 +219,19 @@ class L3fwdTest: if_pci0 = Topology.get_interface_pci_addr(node, if_key0) if_pci1 = Topology.get_interface_pci_addr(node, if_key1) + # Flipping routes logic: + # If TG and DUT ports are reordered -> flip + # If TG reordered and DUT not reordered -> don't flip + # If DUT reordered and TG not reordered -> don't flip + # If DUT and TG not reordered -> flip + # Detect which is the port 0. - if min(if_pci0, if_pci1) != if_pci0: + dut_flip = if_pci0 > if_pci1 + if dut_flip: if_key0, if_key1 = if_key1, if_key0 + if tg_flip: + L3fwdTest.patch_l3fwd(node, u"patch_l3fwd_flip_routes") + elif not tg_flip: L3fwdTest.patch_l3fwd(node, u"patch_l3fwd_flip_routes") adj_node0, adj_if_key0 = Topology.get_adjacent_node_and_interface( -- 2.16.6