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:
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 """This module implements functionality which sets L2 forwarding for DPDK on
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
25 """Setup the DPDK for testpmd performance test."""
29 node, if1, if2, lcores_list, nb_cores, queue_nums,
30 jumbo_frames, rxq_size=1024, txq_size=1024):
32 Execute the testpmd on the DUT node.
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
42 :param rxq_size: RXQ size. Default=1024.
43 :param txq_size: TXQ size. Default=1024.
47 :type lcores_list: str
50 :type jumbo_frames: bool
53 :raises RuntimeError: If the script "run_testpmd.sh" fails.
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)
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}",
63 eal_pci_whitelist0=if_pci0,
64 eal_pci_whitelist1=if_pci1,
70 pmd_max_pkt_len=pmd_max_pkt_len,
71 pmd_mbuf_size=u"16384",
76 pmd_nb_cores=nb_cores,
77 pmd_disable_link_check=True,
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)