From 9a054248197bdaed71b32e9d9c0ac621bf89c1cd Mon Sep 17 00:00:00 2001 From: Robert Wojciechowicz Date: Wed, 9 Dec 2015 10:07:38 +0000 Subject: Add testpmd as vswitch class The purpose of using testpmd instead of OVS is to get the baseline of the DUT when performing hardware offloading operations. There are supported different checksum calculation and txq flags settings. Change-Id: I93c9b45dcb31eaa1f610b7e061f3dd5936b0e6ec JIRA: VSPERF-193 Signed-off-by: Robert Wojciechowicz Reviewed-by: Dino Simeon Madarang Reviewed-by: Maryam Tahhan Reviewed-by: Brian Castelli --- tools/pkt_fwd/__init__.py | 19 +++++++++++ tools/pkt_fwd/pkt_fwd.py | 53 +++++++++++++++++++++++++++++ tools/pkt_fwd/testpmd.py | 87 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 tools/pkt_fwd/__init__.py create mode 100644 tools/pkt_fwd/pkt_fwd.py create mode 100644 tools/pkt_fwd/testpmd.py (limited to 'tools/pkt_fwd') diff --git a/tools/pkt_fwd/__init__.py b/tools/pkt_fwd/__init__.py new file mode 100644 index 00000000..91247e72 --- /dev/null +++ b/tools/pkt_fwd/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2016 Intel Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Packet forwarders package which contain: +- All relevant implementations of packet forwarders. +- Interface definition stored in "pkt_fwd" +""" diff --git a/tools/pkt_fwd/pkt_fwd.py b/tools/pkt_fwd/pkt_fwd.py new file mode 100644 index 00000000..2580ee1f --- /dev/null +++ b/tools/pkt_fwd/pkt_fwd.py @@ -0,0 +1,53 @@ +# Copyright 2016 Intel Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Abstract "packet forwarding" model. + +This is an abstract class for packet forwarders. +""" + +class IPktFwd(object): + """Interface class that is implemented by specific classes + of packet forwarders + """ + + def __enter__(self): + """Start the packet forwarder. + + Provide a context manager interface to the packet forwarders. + This simply calls the :func:`start` function. + """ + return self.start() + + def __exit__(self, type_, value, traceback): + """Stop the packet forwarder. + + Provide a context manager interface to the packet forwarders. + This simply calls the :func:`stop` function. + """ + self.stop() + + def start(self): + """Start the packet forwarder. + + :returns: None + """ + raise NotImplementedError('Please call an implementation.') + + def stop(self): + """Stop the packet forwarder. + + :returns: None + """ + raise NotImplementedError('Please call an implementation.') + diff --git a/tools/pkt_fwd/testpmd.py b/tools/pkt_fwd/testpmd.py new file mode 100644 index 00000000..d8ed8905 --- /dev/null +++ b/tools/pkt_fwd/testpmd.py @@ -0,0 +1,87 @@ +# Copyright 2016 Intel Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""VSPERF TestPMD implementation +""" + +import logging +import pexpect +from conf import settings +from src.dpdk import dpdk +from src.dpdk import TestPMDProcess +from tools.pkt_fwd.pkt_fwd import IPktFwd + +_LOGGER = logging.getLogger(__name__) +_VSWITCHD_CONST_ARGS = ['--', '-i'] + +class TestPMD(IPktFwd): + """TestPMD implementation (only phy2phy deployment is supported) + + This is wrapper for functionality implemented in ${DPDK}/app/test-pmd. + + The method docstrings document only considerations specific to this + implementation. For generic information of the nature of the methods, + see the interface definition. + """ + + _logger = logging.getLogger() + + def __init__(self): + vswitchd_args = settings.getValue('VSWITCHD_DPDK_ARGS') + vswitchd_args += _VSWITCHD_CONST_ARGS + vswitchd_args += settings.getValue('TESTPMD_ARGS') + + self._nports = len(settings.getValue('WHITELIST_NICS')) + self._fwdmode = settings.getValue('TESTPMD_FWD_MODE') + self._csum_layer = settings.getValue('TESTPMD_CSUM_LAYER') + self._csum_calc = settings.getValue('TESTPMD_CSUM_CALC') + self._csum_tunnel = settings.getValue('TESTPMD_CSUM_PARSE_TUNNEL') + + self._testpmd = TestPMDProcess(testpmd_args=vswitchd_args) + + def start(self): + """See IPktFwd for general description + + Activates testpmd. + """ + self._logger.info("Starting TestPMD...") + dpdk.init() + self._testpmd.start() + self._logger.info("TestPMD...Started.") + + self._testpmd.send('set fwd {}'.format(self._fwdmode), 1) + + for port in range(self._nports): + self._testpmd.send('csum set {} {} {}'.format( + self._csum_layer, self._csum_calc, port), 1) + self._testpmd.send('csum parse_tunnel {} {}'.format( + self._csum_tunnel, port), 1) + + self._testpmd.send('start', 1) + + def stop(self): + """See IPktFwd for general description + + Kills testpmd. + """ + try: + self._testpmd.send('stop') + self._testpmd.wait('Done.', 5) + self._testpmd.send('quit', 2) + self._testpmd.kill() + except pexpect.EOF: + pass + dpdk.cleanup() + + -- cgit 1.2.3-korg