1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
# Copyright (c) 2017-2019 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.
---
schema: yardstick:task:0.1
scenarios:
- type: NSPerf
traffic_profile: ../../traffic_profiles/ipv4_throughput-{{ num_vnfs }}.yaml
topology: vfw-tg-topology-multi-port-{{ num_vnfs }}.yaml
nodes:
tg__0: trafficgen_0.yardstick
vnf__0: vnf_0.yardstick
options:
framesize:
uplink: {{ flow.pkt_size.uplink }}
downlink: {{ flow.pkt_size.downlink # Copyright 2017 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 VPP implementation using DPDK and vhostuser vports
"""
import logging
import os
import copy
import re
import pexpect
from src.dpdk import dpdk
from conf import settings as S
from vswitches.vswitch import IVSwitch
from tools import tasks
# pylint: disable=too-many-public-methods
class VppDpdkVhost(IVSwitch, tasks.Process):
""" VPP with DPDK support
"""
_proc_name = 'vpp'
_bridge_idx_counter = 100
def __init__(self):
"""See IVswitch for general description
"""
self._logfile = os.path.join(S.getValue('LOG_DIR'),
S.getValue('LOG_FILE_VPP'))
self._logger = logging.getLogger(__name__)
self._expect = r'vpp#'
self._timeout = 30
self._vswitch_args = []
self._cmd = []
self._cmd_template = ['sudo', '-E', S.getValue('TOOLS')['vpp']]
self._stamp = None
self._logger = logging.getLogger(__name__)
self._phy_ports = []
self._virt_ports = []
self._switches = {}
# configure DPDK NICs
tmp_args = copy.deepcopy(S.getValue('VSWITCH_VPP_ARGS'))
if 'dpdk' not in tmp_args:
tmp_args['dpdk'] = []
# override socket-mem settings
for tmp_arg in tmp_args['dpdk']:
if tmp_arg.startswith('socket-mem'):
tmp_args['dpdk'].remove(tmp_arg)
tmp_args['dpdk'].append('socket-mem ' +
','.join(S.getValue('DPDK_SOCKET_MEM')))
for nic in S.getValue('NICS'):
tmp_args['dpdk'].append("dev {}".format(nic['pci']))
self._vswitch_args = self._process_vpp_args(tmp_args)
def _get_nic_info(self, key='Name'):
"""Read NIC info from VPP and return NIC details in a dictionary
indexed by given ``key``
:param key: Name of the key to be used for indexing result dictionary
:returns: Dictionary with NIC infos including their PCI addresses
"""
result = {}
output = self.run_vppctl(['show', 'hardware', 'brief'])
# parse output and store basic info about NICS
ifaces = output[0].split('\n')
keys = ifaces[0].split()
keys.append('Pci')
keyidx = keys.index(key)
for iface in ifaces[1:]:
tmpif = iface.split()
# get PCI address of given interface
output = self.run_vppctl(['show', 'hardware', tmpif[1], 'detail'])
match = re.search(r'pci address:\s*([\d:\.]+)', output[0])
if match:
# normalize PCI address, e.g. 0000:05:10.01 => 0000:05:10.1
tmp_pci = match.group(1).split('.')
tmp_pci[1] = str(int(tmp_pci[1]))
tmpif.append('.'.join(tmp_pci))
else:
tmpif.append(None)
# store only NICs with reasonable index
if tmpif[keyidx] is not None:
result[tmpif[keyidx]] = dict(zip(keys, tmpif))
return result
def _process_vpp_args(self, args):
"""Produce VPP CLI args from input dictionary ``args``
"""
cli_args = []
for cfg_key in args:
cli_args.append(cfg_key)
cli_args.append("{{ {} }}".format(' '.join(args[cfg_key])))
self._logger.debug("VPP CLI args: %s", cli_args)
return cli_args
def start(self):
"""Activates DPDK kernel modules and starts VPP
:raises: pexpect.EOF, pexpect.TIMEOUT
"""
dpdk.init()
self._logger.info("Starting VPP...")
self._cmd = self._cmd_template + self._vswitch_args
try:
tasks.Process.start(self)
self.relinquish()
except (pexpect.EOF, pexpect.TIMEOUT) as exc:
logging.error("Exception during VPP start.")
raise exc
self._logger.info("VPP...Started.")
def stop(self):
"""See IVswitch for general description
Kills VPP and removes DPDK kernel modules.
"""
self._logger.info("Terminating VPP...")
self.kill()
self._logger.info("VPP...Terminated.")
dpdk.cleanup()
def kill(self, signal='-15', sleep=10):
"""See IVswitch for general description
Kills ``vpp``
"""
# try to get VPP pid
output = self.run_vppctl(['show', 'version', 'verbose'])
match = re.search(r'Current PID:\s*([0-9]+)', output[0])
if match:
vpp_pid = match.group(1)
tasks.terminate_task(vpp_pid, logger=self._logger)
# in case, that pid was not detected or sudo envelope
# has not been terminated yet
tasks.Process.kill(self, signal, sleep)
def add_switch(self, switch_name, dummy_params=None):
"""See IVswitch for general description
"""
if switch_name in self._switches:
self._logger.warning("switch %s already exists...", switch_name)
else:
self._switches[switch_name] = self._bridge_idx_counter
self._bridge_idx_counter += 1
def del_switch(self, switch_name):
"""See IVswitch for general description
"""
if switch_name in self._switches:
del self._switches[switch_name]
def add_phy_port(self, dummy_switch_name):
"""See IVswitch for general description
:raises: RuntimeError
"""
# get list of physical interfaces with PCI addresses
vpp_nics = self._get_nic_info(key='Pci')
# check if there are any NICs left
if len(self._phy_ports) >= len(S.getValue('NICS')):
raise RuntimeError('All available NICs are already configured!')
nic = S.getValue('NICS')[len(self._phy_ports)]
if not nic['pci'] in vpp_nics:
raise RuntimeError('VPP cannot access nic with PCI address: {}'.format(nic['pci']))
nic_name = vpp_nics[nic['pci']]['Name']
self._phy_ports.append(nic_name)
self.run_vppctl(['set', 'int', 'state', nic_name, 'up'])
return (nic_name, vpp_nics[nic['pci']]['Idx'])
def add_vport(self, dummy_switch_name):
"""See IVswitch for general description
"""
socket_name = S.getValue('TOOLS')['ovs_var_tmp'] + 'dpdkvhostuser' + str(len(self._virt_ports))
output = self.run_vppctl(['create', 'vhost-user', 'socket', socket_name, 'server'] +
S.getValue('VSWITCH_VPP_VHOSTUSER_ARGS'))
nic_name = output[0]
self._virt_ports.append(nic_name)
self.run_vppctl(['set', 'int', 'state', nic_name, 'up'])
return (nic_name, None)
def del_port(self, switch_name, port_name):
"""See IVswitch for general description
"""
if port_name in self._phy_ports:
self.run_vppctl(['set', 'int', 'state', port_name, 'down'])
self._phy_ports.remove(port_name)
elif port_name in self._virt_ports:
self.run_vppctl(['set', 'int', 'state', port_name, 'down'])
self.run_vppctl(['delete', 'vhost-user', port_name])
self._virt_ports.remove(port_name)
else:
self._logger.warning("Port %s is not configured.", port_name)
def add_l2patch(self, port1, port2, bidir=False):
"""Create l2patch connection between given ports
"""
self.run_vppctl(['test', 'l2patch', 'rx', port1, 'tx', port2])
if bidir:
self.run_vppctl(['test', 'l2patch', 'rx', port2, 'tx', port1])
def add_xconnect(self, port1, port2, bidir=False):
"""Create l2patch connection between given ports
"""
self.run_vppctl(['set', 'interface', 'l2', 'xconnect', port1, port2])
if bidir:
self.run_vppctl(['set', 'interface', 'l2', 'xconnect', port2, port1])
def add_bridge(self, switch_name, port1, port2, dummy_bidir=False):
"""Add given ports to bridge ``switch_name``
"""
self.run_vppctl(['set', 'interface', 'l2', 'bridge', port1,
str(self._switches[switch_name])])
self.run_vppctl(['set', 'interface', 'l2', 'bridge', port2,
str(self._switches[switch_name])])
def add_connection(self, switch_name, port1, port2, bidir=False):
"""See IVswitch for general description
:raises: RuntimeError
"""
mode = S.getValue('VSWITCH_VPP_L2_CONNECT_MODE')
if mode == 'l2patch':
self.add_l2patch(port1, port2, bidir)
elif mode == 'xconnect':
self.add_xconnect(port1, port2, bidir)
elif mode == 'bridge':
self.add_bridge(switch_name, port1, port2)
else:
raise RuntimeError('VPP: Unsupported l2 connection mode detected %s', mode)
def del_l2patch(self, port1, port2, bidir=False):
"""Remove l2patch connection between given ports
:param port1: port to be used in connection
:param port2: port to be used in connection
:param bidir: switch between uni and bidirectional traffic
"""
self.run_vppctl(['test', 'l2patch', 'rx', port1, 'tx', port2, 'del'])
if bidir:
self.run_vppctl(['test', 'l2patch', 'rx', port2, 'tx', port1, 'del'])
def del_xconnect(self, dummy_port1, dummy_port2, dummy_bidir=False):
"""Remove xconnect connection between given ports
"""
self._logger.warning('VPP: Removal of l2 xconnect is not implemented.')
def del_bridge(self, dummy_switch_name, dummy_port1, dummy_port2):
"""Remove given ports from the bridge
"""
self._logger.warning('VPP: Removal of interfaces from bridge is not implemented.')
def del_connection(self, switch_name, port1, port2, bidir=False):
"""See IVswitch for general description
:raises: RuntimeError
"""
mode = S.getValue('VSWITCH_VPP_L2_CONNECT_MODE')
if mode == 'l2patch':
self.del_l2patch(port1, port2, bidir)
elif mode == 'xconnect':
self.del_xconnect(port1, port2, bidir)
elif mode == 'bridge':
self.del_bridge(switch_name, port1, port2)
else:
raise RuntimeError('VPP: Unsupported l2 connection mode detected %s', mode)
def dump_l2patch(self):
"""Dump l2patch connections
"""
self.run_vppctl(['show', 'l2patch'])
def dump_xconnect(self):
"""Dump l2 xconnect connections
"""
self._logger.warning("VPP: Dump of l2 xconnections is not supported.")
def dump_bridge(self, switch_name):
"""Show bridge details
:param switch_name: switch on which to operate
"""
self.run_vppctl(['show', 'bridge-domain', str(self._switches[switch_name]), 'int'])
def dump_connections(self, switch_name):
"""See IVswitch for general description
:raises: RuntimeError
"""
mode = S.getValue('VSWITCH_VPP_L2_CONNECT_MODE')
if mode == 'l2patch':
self.dump_l2patch()
elif mode == 'xconnect':
self.dump_xconnect()
elif mode == 'bridge':
self.dump_bridge(switch_name)
else:
raise RuntimeError('VPP: Unsupported l2 connection mode detected %s', mode)
def run_vppctl(self, args, check_error=False):
"""Run ``vppctl`` with supplied arguments.
:param args: Arguments to pass to ``vppctl``
:param check_error: Throw exception on error
:return: None
"""
cmd = ['sudo', S.getValue('TOOLS')['vppctl']] + args
return tasks.run_task(cmd, self._logger, 'Running vppctl...', check_error)
#
# Validate methods
#
def validate_add_switch(self, dummy_result, switch_name, dummy_params=None):
"""Validate - Create a new logical switch with no ports
"""
return switch_name in self._switches
def validate_del_switch(self, dummy_result, switch_name):
"""Validate removal of switch
"""
return not self.validate_add_switch(dummy_result, switch_name)
def validate_add_phy_port(self, result, dummy_switch_name):
""" Validate that physical port was added to bridge.
"""
return result[0] in self._phy_ports
def validate_add_vport(self, result, dummy_switch_name):
""" Validate that virtual port was added to bridge.
"""
return result[0] in self._virt_ports
def validate_del_port(self, dummy_result, dummy_switch_name, port_name):
""" Validate that port_name was removed from bridge.
"""
return not (port_name in self._phy_ports or port_name in self._virt_ports)
# pylint: disable=no-self-use
def validate_run_vppctl(self, result, dummy_args, dummy_check_error=False):
"""validate execution of ``vppctl`` with supplied arguments.
"""
# there shouldn't be any stderr
return not result[1]
#
# Non implemented methods
#
def add_flow(self, switch_name, flow, cache='off'):
"""See IVswitch for general description
"""
raise NotImplementedError()
def del_flow(self, switch_name, flow=None):
"""See IVswitch for general description
"""
raise NotImplementedError()
def dump_flows(self, switch_name):
"""See IVswitch for general description
"""
raise NotImplementedError()
def add_route(self, switch_name, network, destination):
"""See IVswitch for general description
"""
raise NotImplementedError()
def set_tunnel_arp(self, ip_addr, mac_addr, switch_name):
"""See IVswitch for general description
"""
raise NotImplementedError()
def add_tunnel_port(self, switch_name, remote_ip, tunnel_type='vxlan', params=None):
"""See IVswitch for general description
"""
raise NotImplementedError()
def get_ports(self, switch_name):
"""See IVswitch for general description
"""
raise NotImplementedError()
|