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.ssh import exec_cmd_no_error
20 from resources.libraries.python.topology import NodeType
24 """Setup the DPDK for l2fwd performance test."""
27 def start_the_l2fwd_test(
28 node, cpu_cores, nb_cores, queue_nums, jumbo_frames,
29 rxq_size=1024, txq_size=1024):
31 Execute the l2fwd on the DUT node.
33 :param node: Will execute the l2fwd on this node.
34 :param cpu_cores: The DPDK run cores.
35 :param nb_cores: The cores number for the forwarding.
36 :param queue_nums: The queues number for the NIC.
37 :param jumbo_frames: Indication if the jumbo frames are used (True) or
39 :param rxq_size: RXQ size. Default=1024.
40 :param txq_size: TXQ size. Default=1024.
45 :type jumbo_frames: bool
48 :raises RuntimeError: If the script "run_l2fwd.sh" fails.
50 if node[u"type"] == NodeType.DUT:
51 jumbo = u"yes" if jumbo_frames else u"no"
52 command = f"{Constants.REMOTE_FW_DIR}/tests/dpdk/dpdk_scripts" \
53 f"/run_l2fwd.sh {cpu_cores} {nb_cores} {queue_nums} {jumbo} " \
54 f"{rxq_size} {txq_size}"
56 message = f"Failed to execute l2fwd test at node {node['host']}"
58 exec_cmd_no_error(node, command, timeout=1800, message=message)