diff options
author | Robert Wojciechowicz <robertx.wojciechowicz@intel.com> | 2015-12-09 10:07:38 +0000 |
---|---|---|
committer | Maryam Tahhan <maryam.tahhan@intel.com> | 2016-01-21 09:41:05 +0000 |
commit | 9a054248197bdaed71b32e9d9c0ac621bf89c1cd (patch) | |
tree | c186250f91e658845cd8f3a985517c33a9ba0220 /src/dpdk | |
parent | 7caf7a6be0fae6b341181b3e6286372e2e93b4b8 (diff) |
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 <robertx.wojciechowicz@intel.com>
Reviewed-by: Dino Simeon Madarang <dino.simeonx.madarang@intel.com>
Reviewed-by: Maryam Tahhan <maryam.tahhan@intel.com>
Reviewed-by: Brian Castelli <brian.castelli@spirent.com>
Diffstat (limited to 'src/dpdk')
-rw-r--r-- | src/dpdk/__init__.py | 2 | ||||
-rw-r--r-- | src/dpdk/testpmd_proc.py | 113 |
2 files changed, 115 insertions, 0 deletions
diff --git a/src/dpdk/__init__.py b/src/dpdk/__init__.py index 4be1e215..fdbc5414 100644 --- a/src/dpdk/__init__.py +++ b/src/dpdk/__init__.py @@ -19,3 +19,5 @@ and removing drivers and binding/unbinding NICs. """ from src.dpdk.dpdk import * +from src.dpdk.testpmd_proc import TestPMDProcess + diff --git a/src/dpdk/testpmd_proc.py b/src/dpdk/testpmd_proc.py new file mode 100644 index 00000000..990ef8da --- /dev/null +++ b/src/dpdk/testpmd_proc.py @@ -0,0 +1,113 @@ +# Copyright 2015 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. + +"""Class wrapper for controlling a TestPMD instance. + +Wraps ``testpmd`` process. +""" + +import os +import logging +import time +import pexpect + +from conf import settings +from tools import tasks + +_TESTPMD_PROMPT = 'Done' + +_TESTPMD_BIN = os.path.join( + settings.getValue('RTE_SDK'), settings.getValue('RTE_TARGET'), + 'app', 'testpmd') + +_LOG_FILE_VSWITCHD = os.path.join( + settings.getValue('LOG_DIR'), settings.getValue('LOG_FILE_VSWITCHD')) + +class TestPMDProcess(tasks.Process): + """Class wrapper for controlling a TestPMD instance. + + Wraps ``testpmd`` process. + """ + _logfile = _LOG_FILE_VSWITCHD + _proc_name = 'testpmd' + + def __init__(self, timeout=30, testpmd_args=None, expected_cmd=None): + """Initialise the wrapper with a specific start timeout and extra + parameters. + + :param timeout: Timeout to wait for application to start. + :param testpmd_args: Command line parameters for testpmd. + + :returns: None + """ + self._logger = logging.getLogger(__name__) + self._timeout = timeout + self._expect = expected_cmd + if not self._expect: + self._expect = _TESTPMD_PROMPT + testpmd_args = testpmd_args or [] + self._cmd = ['sudo', '-E', _TESTPMD_BIN] + testpmd_args + + # startup/shutdown + + def start(self): + """ Start ``testpmd`` instance. + + :returns: None + :raises: pexpect.EOF, pexpect.TIMEOUT + """ + + try: + super(TestPMDProcess, self).start() + self.relinquish() + except (pexpect.EOF, pexpect.TIMEOUT) as exc: + logging.error("TestPMD start failed.") + raise exc + + def kill(self, signal='-15', sleep=2): + """Kill ``testpmd`` instance if it is alive. + + :returns: None + """ + self._logger.info('Killing testpmd...') + + super(TestPMDProcess, self).kill(signal, sleep) + + # helper functions + + def send(self, cmd, delay=0): + """ + Send ``cmd`` with no wait. + + Useful for asynchronous commands. + + :param cmd: Command to send to guest. + :param timeout: Delay to wait after sending command before returning. + + :returns: None + """ + self._logger.debug(cmd) + self._child.sendline(cmd) + time.sleep(delay) + + def wait(self, msg=_TESTPMD_PROMPT, timeout=30): + """ + Wait for ``msg``. + + :param msg: Message to wait for from guest. + :param timeout: Time to wait for message. + + :returns: None + """ + self._child.expect(msg, timeout=timeout) |