Framework: Bump DPDK 20.08
[csit.git] / resources / libraries / python / DPDK / TestpmdTest.py
1 # Copyright (c) 2020 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 """This module implements functionality which sets L2 forwarding for DPDK on
15 DUT nodes.
16 """
17
18 from resources.libraries.python.Constants import Constants
19 from resources.libraries.python.DpdkUtil import DpdkUtil
20 from resources.libraries.python.ssh import exec_cmd_no_error
21 from resources.libraries.python.topology import NodeType, Topology
22
23
24 class TestpmdTest:
25     """Setup the DPDK for testpmd performance test."""
26
27     @staticmethod
28     def start_testpmd(
29             node, if1, if2, lcores_list, nb_cores, queue_nums,
30             jumbo_frames, rxq_size=1024, txq_size=1024):
31         """
32         Execute the testpmd on the DUT node.
33
34         :param node: DUT node.
35         :param if1: The test link interface 1.
36         :param if2: The test link interface 2.
37         :param lcores_list: The DPDK run cores.
38         :param nb_cores: The cores number for the forwarding.
39         :param queue_nums: The queues number for the NIC.
40         :param jumbo_frames: Indication if the jumbo frames are used (True) or
41             not (False).
42         :param rxq_size: RXQ size. Default=1024.
43         :param txq_size: TXQ size. Default=1024.
44         :type node: dict
45         :type if1: str
46         :type if2: str
47         :type lcores_list: str
48         :type nb_cores: str
49         :type queue_nums: str
50         :type jumbo_frames: bool
51         :type rxq_size: int
52         :type txq_size: int
53         :raises RuntimeError: If the script "run_testpmd.sh" fails.
54         """
55         if node[u"type"] == NodeType.DUT:
56             if_pci0 = Topology.get_interface_pci_addr(node, if1)
57             if_pci1 = Topology.get_interface_pci_addr(node, if2)
58
59             pmd_max_pkt_len = u"9200" if jumbo_frames else u"1518"
60             testpmd_args = DpdkUtil.get_testpmd_args(
61                 eal_corelist=f"1,{lcores_list}",
62                 eal_driver=False,
63                 eal_pci_whitelist0=if_pci0,
64                 eal_pci_whitelist1=if_pci1,
65                 eal_in_memory=True,
66                 pmd_num_mbufs=16384,
67                 pmd_fwd_mode=u"io",
68                 pmd_nb_ports=u"2",
69                 pmd_portmask=u"0x3",
70                 pmd_max_pkt_len=pmd_max_pkt_len,
71                 pmd_mbuf_size=u"16384",
72                 pmd_rxd=rxq_size,
73                 pmd_txd=txq_size,
74                 pmd_rxq=queue_nums,
75                 pmd_txq=queue_nums,
76                 pmd_nb_cores=nb_cores,
77                 pmd_disable_link_check=True,
78                 pmd_auto_start=True,
79                 pmd_numa=True
80             )
81
82             command = f"{Constants.REMOTE_FW_DIR}/{Constants.RESOURCES_LIB_SH}"\
83                 f"/entry/run_testpmd.sh \"{testpmd_args}\""
84             message = f"Failed to execute testpmd at node {node['host']}"
85             exec_cmd_no_error(node, command, timeout=1800, message=message)