1 # Copyright (c) 2018 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.ssh import SSH
19 from resources.libraries.python.constants import Constants
20 from resources.libraries.python.topology import NodeType, Topology
23 class L2fwdTest(object):
24 """Setup the DPDK for l2fwd performance test."""
27 def start_the_l2fwd_test(dut_node, cpu_cores, nb_cores, queue_nums,
30 Execute the l2fwd on the dut_node.
32 :param dut_node: Will execute the l2fwd on this node.
33 :param cpu_cores: The DPDK run cores.
34 :param nb_cores: The cores number for the forwarding.
35 :param queue_nums: The queues number for the NIC.
36 :param jumbo_frames: Are jumbo frames used or not.
41 :type jumbo_frames: str
43 :raises RuntimeError: If the script "run_l2fwd.sh" fails.
45 if dut_node['type'] == NodeType.DUT:
49 arch = Topology.get_node_arch(dut_node)
50 cmd = '{fwdir}/tests/dpdk/dpdk_scripts/run_l2fwd.sh {cpu_cores} ' \
51 '{nb_cores} {queues} {jumbo} {arch}'.\
52 format(fwdir=Constants.REMOTE_FW_DIR, cpu_cores=cpu_cores,
53 nb_cores=nb_cores, queues=queue_nums,
54 jumbo=jumbo_frames, arch=arch)
56 ret_code, _, _ = ssh.exec_command_sudo(cmd, timeout=600)
58 raise RuntimeError('Failed to execute l2fwd test at node '
59 '{name}'.format(name=dut_node['host']))