1 # Copyright 2016-2017 Intel Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 """VSPERF TestPMD implementation
20 from conf import settings
21 from src.dpdk import dpdk
22 from src.dpdk import TestPMDProcess
23 from tools.pkt_fwd.pkt_fwd import IPktFwd
25 _LOGGER = logging.getLogger(__name__)
26 _VSWITCHD_CONST_ARGS = ['--', '-i']
27 _TESTPMD_PVP_CONST_ARGS = ['--vdev', 'net_vhost0,iface=/tmp/dpdkvhostuser0',
28 '--vdev', 'net_vhost1,iface=/tmp/dpdkvhostuser1',]
30 class TestPMD(IPktFwd):
31 """TestPMD implementation (only phy2phy deployment is supported)
33 This is wrapper for functionality implemented in ${DPDK}/app/test-pmd.
35 The method docstrings document only considerations specific to this
36 implementation. For generic information of the nature of the methods,
37 see the interface definition.
40 _logger = logging.getLogger()
42 def __init__(self, guest=False):
43 vswitchd_args = settings.getValue('VSWITCHD_DPDK_ARGS')
45 vswitchd_args += _TESTPMD_PVP_CONST_ARGS
46 vswitchd_args += _VSWITCHD_CONST_ARGS
47 vswitchd_args += settings.getValue('TESTPMD_ARGS')
49 self._nports = len(settings.getValue('NICS'))
50 self._fwdmode = settings.getValue('TESTPMD_FWD_MODE')
51 self._csum_layer = settings.getValue('TESTPMD_CSUM_LAYER')
52 self._csum_calc = settings.getValue('TESTPMD_CSUM_CALC')
53 self._csum_tunnel = settings.getValue('TESTPMD_CSUM_PARSE_TUNNEL')
55 self._testpmd = TestPMDProcess(testpmd_args=vswitchd_args)
58 """See IPktFwd for general description
62 self._logger.info("Starting TestPMD...")
65 self._logger.info("TestPMD...Started.")
67 self._testpmd.send('set fwd {}'.format(self._fwdmode), 1)
69 for port in range(self._nports):
70 self._testpmd.send('csum set {} {} {}'.format(
71 self._csum_layer, self._csum_calc, port), 1)
72 self._testpmd.send('csum parse_tunnel {} {}'.format(
73 self._csum_tunnel, port), 1)
75 self._testpmd.send('start', 1)
77 def start_for_guest(self):
78 """See IPktFwd for general description
80 Activates testpmd for guest config
82 self._logger.info("Starting TestPMD for one guest...")
85 self._logger.info("TestPMD...Started.")
86 self._testpmd.send('set portlist 0,2,1,3')
88 self._testpmd.send('start', 1)
91 """See IPktFwd for general description
96 self._testpmd.send('stop')
97 self._testpmd.wait('Done.', 5)
98 self._testpmd.send('quit', 2)