e84a6165d385e19c394c44d71276eadc09259ef8
[vswitchperf.git] / conf / integration / 01b_dpdk_regression_tests.conf
1 # Copyright 2017-2018 Intel Corporation., Tieto
2 #
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
6 #
7 #   http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 # This file introduces a set of regression tests, which verify several DPDK features
16 # used internally by Open vSwitch. Tests can be used for verification of performance
17 # and correct functionality of upcoming DPDK and OVS releases and release candidates.
18
19 ############################################################
20 #
21 #  Generic configuration used by OVSDPDK testcases
22 #
23 ############################################################
24
25 # required to import path to the log file
26 from conf import settings
27
28 _OVSDPDK_1st_PMD_CORE = 4
29 _OVSDPDK_2nd_PMD_CORE = 5
30 # calculate PMD mask from core IDs configured above
31 _OVSDPDK_PMD_MASK_1_CORE = str(hex(1<<_OVSDPDK_1st_PMD_CORE))[2:]
32 _OVSDPDK_PMD_MASK_2_CORE = str(hex((1<<_OVSDPDK_1st_PMD_CORE) + (1<<_OVSDPDK_2nd_PMD_CORE))[2:])
33
34 _OVSDPDK_GUEST_5_CORES = [('7', '8', '9', '10', '11')]
35
36 # number of queues configured in OVS and GUEST
37 _OVSDPDK_MQ = '2'
38
39 # path to the log file
40 _RESULTS_PATH = settings.getValue('RESULTS_PATH')
41 name, ext = os.path.splitext(settings.getValue('LOG_FILE_VSWITCHD'))
42 log_file = "{name}_{uid}{ex}".format(name=name,uid=settings.getValue('LOG_TIMESTAMP'),ex=ext)
43 _OVSDPDK_VSWITCH_LOG = os.path.join(_RESULTS_PATH, log_file)
44
45 _OVSDPDK_HEADER_LEN = 18                # length of frame headers in bytes, it's used for calculation
46                                         # of payload size, i.e. payload = frame_size - header_len
47
48 _OVSDPDK_PKT_SIZES = (64,128,256,512,1024,1500)
49
50 INTEGRATION_TESTS = INTEGRATION_TESTS + [
51     ############################################################
52     #
53     #  DPDK NIC Support
54     #
55     ############################################################
56     {
57         "Name": "ovsdpdk_nic_p2p_single_pmd_unidir_cont",
58         "Deployment": "p2p",
59         "Description": "P2P with single PMD in OVS and unidirectional traffic.",
60         "vSwitch" : "OvsDpdkVhost",
61         "Parameters" : {
62             "TRAFFIC" : {
63                 "traffic_type" : "rfc2544_continuous",
64                 "frame_rate" : 100,
65                 'bidir' : 'False',
66             },
67             "TRAFFICGEN_PKT_SIZES" : _OVSDPDK_PKT_SIZES,
68             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_1_CORE,
69         },
70     },
71     {
72         "Name": "ovsdpdk_nic_p2p_single_pmd_bidir_cont",
73         "Deployment": "p2p",
74         "Description": "P2P with single PMD in OVS and bidirectional traffic.",
75         "vSwitch" : "OvsDpdkVhost",
76         "Parameters" : {
77             "TRAFFIC" : {
78                 "traffic_type" : "rfc2544_continuous",
79                 "frame_rate" : 100,
80                 'bidir' : 'True',
81             },
82             "TRAFFICGEN_PKT_SIZES" : _OVSDPDK_PKT_SIZES,
83             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_1_CORE,
84         },
85     },
86     {
87         "Name": "ovsdpdk_nic_p2p_two_pmd_bidir_cont",
88         "Deployment": "p2p",
89         "Description": "P2P with two PMDs in OVS and bidirectional traffic.",
90         "vSwitch" : "OvsDpdkVhost",
91         "Parameters" : {
92             "TRAFFIC" : {
93                 "traffic_type" : "rfc2544_continuous",
94                 "frame_rate" : 100,
95                 'bidir' : 'True',
96             },
97             "TRAFFICGEN_PKT_SIZES" : _OVSDPDK_PKT_SIZES,
98             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_2_CORE,
99         },
100     },
101     {
102         "Name": "ovsdpdk_nic_p2p_single_pmd_unidir_tput",
103         "Deployment": "p2p",
104         "Description": "P2P with single PMD in OVS and unidirectional traffic.",
105         "vSwitch" : "OvsDpdkVhost",
106         "Parameters" : {
107             "TRAFFIC" : {
108                 "traffic_type" : "rfc2544_throughput",
109                 'bidir' : 'False',
110             },
111             "TRAFFICGEN_PKT_SIZES" : _OVSDPDK_PKT_SIZES,
112             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_1_CORE,
113         },
114     },
115     {
116         "Name": "ovsdpdk_nic_p2p_single_pmd_bidir_tput",
117         "Deployment": "p2p",
118         "Description": "P2P with single PMD in OVS and bidirectional traffic.",
119         "vSwitch" : "OvsDpdkVhost",
120         "Parameters" : {
121             "TRAFFIC" : {
122                 "traffic_type" : "rfc2544_throughput",
123                 'bidir' : 'True',
124             },
125             "TRAFFICGEN_PKT_SIZES" : _OVSDPDK_PKT_SIZES,
126             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_1_CORE,
127         },
128     },
129     {
130         "Name": "ovsdpdk_nic_p2p_two_pmd_bidir_tput",
131         "Deployment": "p2p",
132         "Description": "P2P with two PMDs in OVS and bidirectional traffic.",
133         "vSwitch" : "OvsDpdkVhost",
134         "Parameters" : {
135             "TRAFFIC" : {
136                 "traffic_type" : "rfc2544_throughput",
137                 'bidir' : 'True',
138             },
139             "TRAFFICGEN_PKT_SIZES" : _OVSDPDK_PKT_SIZES,
140             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_2_CORE,
141         },
142     },
143     ############################################################
144     #
145     #  DPDK Hotplug Support
146     #
147     ############################################################
148     {
149         "Name": "ovsdpdk_hotplug_attach",
150         "Deployment": "clean",
151         "Description": "Ensure successful port-add after binding a device to igb_uio after ovs-vswitchd is launched.",
152         "vSwitch" : "OvsDpdkVhost",
153         "Parameters" : {
154             # suppress DPDK configuration, so physical interfaces are not bound to DPDK driver
155             'WHITELIST_NICS' : [],
156             'NICS' : [],
157         },
158         "TestSteps": [
159                         # restore original NICS configuration, so we can use add/del_phy_port
160                         ['settings', 'setValue', 'TEST_PARAMS', ''],
161                         # add DPDK port, but it should fail
162                         ['vswitch', 'add_switch', 'int_br0'],
163                         ['#port', 'vswitch', 'add_phy_port', 'int_br0'],
164                         # check, that DPDK port is not available and remove it
165                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show',
166                                                 '|Error attaching device.*$NICS[0]["pci"]'],
167                         # NOTE: it fails in case that NIC was already bound to DPDK driver
168                         ['tools', 'assert', 'len(#STEP[-1])'],
169                         ['vswitch', 'del_port', 'int_br0', '#STEP[port][0]'],
170                         # find out which DPDK driver is being used; it should be the last configured
171                         # DPDK module; optional path and .ko suffix must be removed
172                         ['tools', 'eval', '\'$TOOLS["dpdk_modules"][-1]\'.split("/")[-1].split(".")[0]'],
173                         # bind NIC to DPDK driver
174                         ['tools', 'exec_shell', 'sudo $TOOLS["bind-tool"] --bind #STEP[-1] $NICS[0]["pci"]'],
175                         # and check that DPDK port can be created without errors
176                         ['#port2', 'vswitch', 'add_phy_port', 'int_br0'],
177                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show',
178                                                 '|Error attaching device.*$NICS[0]["pci"]'],
179                         ['tools', 'assert', 'not len(#STEP[-1])'],
180                      ]
181     },
182     {
183         # Support of netdev-dpdk/detach has been removed from OVS, so testcase will fail with recent
184         # OVS/DPDK versions. There is an ongoing discussion about possible support of netdev-dpdk/detach
185         # in the future OVS versions.
186         # Test has been tested with:
187         #   OVS_TAG = 03d6399e618e4136c5da0be2b6f18f0b7d75b2bb
188         #   DPDK_TAG = v16.11
189         "Name": "ovsdpdk_hotplug_detach",
190         "Deployment": "clean",
191         "Description": "Same as ovsdpdk_hotplug_attach, but delete and detach the device after the hotplug. "
192                        "Note: Support of netdev-dpdk/detach has been removed from OVS, so testcase will fail "
193                        "with recent OVS/DPDK versions.",
194         "vSwitch" : "OvsDpdkVhost",
195         "Parameters" : {
196             # suppress DPDK configuration, so physical interfaces are not bound to DPDK driver
197             'WHITELIST_NICS' : [],
198             'NICS' : [],
199         },
200         "TestSteps": [
201                         # check if OVS supports netdev-dpdk/detach, fail otherwise
202                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] list-commands', '|netdev-dpdk\/detach'],
203                         ['tools', 'assert', 'len(#STEP[-1])'],
204                         # restore original NICS configuration, so we can use add/del_phy_port
205                         ['settings', 'setValue', 'TEST_PARAMS', ''],
206                         # find out which DPDK driver is being used; it should be the last configured
207                         # DPDK module; optional path and .ko suffix must be removed
208                         ['tools', 'eval', '\'$TOOLS["dpdk_modules"][-1]\'.split("/")[-1].split(".")[0]'],
209                         # bind NIC to DPDK driver
210                         ['tools', 'exec_shell', 'sudo $TOOLS["bind-tool"] --bind #STEP[-1] $NICS[0]["pci"]'],
211                         # and check that DPDK port can be created without errors
212                         ['vswitch', 'add_switch', 'int_br0'],
213                         ['#port', 'vswitch', 'add_phy_port', 'int_br0'],
214                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show',
215                                                 '|Error attaching device.*$NICS[0]["pci"]'],
216                         ['tools', 'assert', 'not len(#STEP[-1])'],
217                         # try to unbind port - should fail beause it is being used
218                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] netdev-dpdk/detach $NICS[0]["pci"] 2>&1; exit 0',
219                                                 '|Device.*$NICS[0]["pci"].*is being used by interface'],
220                         ['tools', 'assert', 'len(#STEP[-1])'],
221                         # delete port and unbind it - should succeed
222                         ['vswitch', 'del_port', 'int_br0', '#STEP[port][0]'],
223                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] netdev-dpdk/detach $NICS[0]["pci"]',
224                                                 '|Device.*$NICS[0]["pci"].*has been detached'],
225                         ['tools', 'assert', 'len(#STEP[-1])'],
226                         # try to add port again
227                         ['vswitch', 'add_phy_port', 'int_br0'],
228                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show',
229                                                 '|Error attaching device.*$NICS[0]["pci"]'],
230                         # it will work because auto attach was implemented into OVS
231                         ['tools', 'assert', 'not len(#STEP[-1])'],
232                         ['vswitch', 'del_switch', 'int_br0'],
233                      ]
234     },
235 ]
236
237 ############################################################
238 #
239 #  RX Checksum Support
240 #
241 ############################################################
242 # TCL script used for simulation of traffic with wrong CRC
243 _OVSDPDK_CRC_CRC_TCL = ''
244 _OVSDPDK_CRC_FRAME_LOSS = ''
245
246 _OVSDPDK_CRC_VERIFY_CRC = [
247     # use TCL script with tunneling protocols encap/decap support;
248     # it must be configured dynamically, otherwise it won't
249     # be possible to change it again below.
250     ['settings', 'setValue', 'TRAFFICGEN_IXNET_TCL_SCRIPT',
251      'ixnetrfc2544v2.tcl'],
252     # send traffic before IP or UDP header checksum is randomized
253     ['trafficgen', 'send_traffic', {}],
254     ['trafficgen', 'get_results'],
255     # packets should flow through OVS without frameloss (frame_rate is low)
256     ['tools', 'assert', 'float(#STEP[-1][0]["frame_loss_percent"]) == 0'],
257     # for 2nd run use TCL file with randomized checksum values
258     ['settings', 'setValue', 'TRAFFICGEN_IXNET_TCL_SCRIPT',
259      '$_OVSDPDK_CRC_CRC_TCL'],
260     ['trafficgen', 'send_traffic', {}],
261     ['trafficgen', 'get_results'],
262     # and verify that majority of frames but not all of them were lost
263     ['tools', 'assert', 'round(float(#STEP[-1][0]["frame_loss_percent"]),3) == $_OVSDPDK_CRC_FRAME_LOSS'],
264 ]
265
266 INTEGRATION_TESTS = INTEGRATION_TESTS + [
267     {
268         "Name": "ovsdpdk_checksum_l3",
269         "Deployment": "op2p",
270         "Description": "Test verifies RX IP header checksum (offloading) validation for tunneling protocols.",
271         "Tunnel Type": "vxlan",
272         "Tunnel Operation": "decapsulation",
273         "vSwitch" : "OvsDpdkVhost",
274         "Parameters" : {
275             "TRAFFICGEN" : "IxNet",
276             "TRAFFIC" : {
277                 "traffic_type" : "rfc2544_continuous",
278                 "frame_rate" : 20,
279                 'bidir' : 'False',
280             },
281             "TRAFFICGEN_DURATION" : 10,
282             "TRAFFICGEN_PKT_SIZES" : (64,)
283         },
284         "TestSteps": [
285                         # TCL file with randomized IP header checksum values
286                         ['settings', 'setValue', '_OVSDPDK_CRC_CRC_TCL',
287                          'ixnetrfc2544v2_random_ip_crc.tcl'],
288                         # IP checksum is a value between 0 and 65536, so only 1 of 65536
289                         # frames has correct CRC and all other frames will be dropped
290                         ['settings', 'setValue', '_OVSDPDK_CRC_FRAME_LOSS',
291                          round(100 - 1 / 65536 * 100, 3)],
292                     ] + _OVSDPDK_CRC_VERIFY_CRC
293     },
294     {
295         "Name": "ovsdpdk_checksum_l4",
296         "Deployment": "op2p",
297         "Description": "Test verifies RX UDP header checksum (offloading) validation for tunneling protocols.",
298         "Tunnel Type": "vxlan",
299         "Tunnel Operation": "decapsulation",
300         "vSwitch" : "OvsDpdkVhost",
301         "Parameters" : {
302             "TRAFFICGEN" : "IxNet",
303             "TRAFFIC" : {
304                 "traffic_type" : "rfc2544_continuous",
305                 "frame_rate" : 20,
306                 'bidir' : 'False',
307             },
308             "TRAFFICGEN_DURATION" : 10,
309             "TRAFFICGEN_PKT_SIZES" : (64,)
310         },
311         "TestSteps": [
312                         # TCL file with randomized UDP header checksum values
313                         ['settings', 'setValue', '_OVSDPDK_CRC_CRC_TCL',
314                          'ixnetrfc2544v2_random_udp_crc.tcl'],
315                         # UDP checksum can be disabled by value 0; so valid checksum
316                         # values are from 1 to 65535; It means that only one of 65535 frames
317                         # has correct checksum and all other frames will be dropped
318                         ['settings', 'setValue', '_OVSDPDK_CRC_FRAME_LOSS',
319                          round(100 - 1 / 65535 * 100, 3)],
320                     ] + _OVSDPDK_CRC_VERIFY_CRC
321     },
322     ############################################################
323     #
324     #  Flow Control Support
325     #
326     ############################################################
327     {
328         "Name": "ovsdpdk_flow_ctrl_rx",
329         "Deployment": "p2p",
330         "Description": "Test the rx flow control functionality of DPDK PHY ports.",
331         "vSwitch" : "OvsDpdkVhost",
332         "Parameters" : {
333             "TRAFFICGEN" : "IxNet",
334             "TRAFFIC" : {
335                 "traffic_type" : "rfc2544_continuous",
336                 "frame_rate" : 100,
337                 "flow_control" : True,
338                 'bidir' : 'True',
339             },
340             "TRAFFICGEN_DURATION" : 10,
341             "TRAFFICGEN_PKT_SIZES" : (64,)
342         },
343         "TestSteps": [
344                         # send traffic before flow control is applied
345                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show'],
346                         ['trafficgen', 'send_traffic', {}],
347                         ['trafficgen', 'get_results'],
348                         # frame loss with small packets should be detected
349                         ['tools', 'assert', '#STEP[-1][0]["frame_loss_percent"] > 10'],
350                         # delete phy ports so they can be created with flow control
351                         ['vswitch', 'del_flow', '$VSWITCH_BRIDGE_NAME', {}],
352                         ['vswitch', 'del_port', '$VSWITCH_BRIDGE_NAME', 'dpdk0'],
353                         ['vswitch', 'del_port', '$VSWITCH_BRIDGE_NAME', 'dpdk1'],
354                         # turn on flow control
355                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] add-port $VSWITCH_BRIDGE_NAME dpdk0 -- set Interface dpdk0 type=dpdk options:dpdk-devargs=$NICS[0]["pci"] options:rx-flow-ctrl=true'],
356                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] add-port $VSWITCH_BRIDGE_NAME dpdk1 -- set Interface dpdk1 type=dpdk options:dpdk-devargs=$NICS[1]["pci"] options:rx-flow-ctrl=true'],
357                         ['vswitch', 'add_flow', '$VSWITCH_BRIDGE_NAME', {'in_port': '3', 'actions': ['output:4'], 'idle_timeout': '0'}],
358                         ['vswitch', 'add_flow', '$VSWITCH_BRIDGE_NAME', {'in_port': '4', 'actions': ['output:3'], 'idle_timeout': '0'}],
359                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show'],
360                         ['trafficgen', 'send_traffic', {}],
361                         ['trafficgen', 'get_results'],
362                         # frame loss with flow control enabled should converge to 0%
363                         ['tools', 'assert', 'float(#STEP[-1][0]["frame_loss_percent"]) == 0'],
364                     ]
365     },
366     {
367         "Name": "ovsdpdk_flow_ctrl_rx_dynamic",
368         "Deployment": "p2p",
369         "Description": "Change the rx flow control support at run time and ensure the system honored the changes.",
370         "vSwitch" : "OvsDpdkVhost",
371         "Parameters" : {
372             "TRAFFICGEN" : "IxNet",
373             "TRAFFIC" : {
374                 "traffic_type" : "rfc2544_continuous",
375                 "frame_rate" : 100,
376                 "flow_control" : True,
377                 'bidir' : 'True',
378             },
379             "TRAFFICGEN_DURATION" : 10,
380             "TRAFFICGEN_PKT_SIZES" : (64,)
381         },
382         "TestSteps": [
383                         # send traffic before flow control is applied
384                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show'],
385                         ['trafficgen', 'send_traffic', {}],
386                         ['trafficgen', 'get_results'],
387                         # frame loss with small packets should be detected
388                         ['tools', 'assert', '#STEP[-1][0]["frame_loss_percent"] > 10'],
389                         # turn on flow control
390                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdk0 type=dpdk options:rx-flow-ctrl=true'],
391                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdk1 type=dpdk options:rx-flow-ctrl=true'],
392                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show'],
393                         ['trafficgen', 'send_traffic', {}],
394                         ['trafficgen', 'get_results'],
395                         # frame loss with flow control enabled should converge to 0%
396                         ['tools', 'assert', 'float(#STEP[-1][0]["frame_loss_percent"]) == 0'],
397                     ]
398     },
399     ############################################################
400     #
401     #  Multiqueue Support
402     #
403     ############################################################
404     {
405         "Name": "ovsdpdk_mq_p2p_rxqs",
406         "Deployment": "p2p",
407         "Description": "Setup rxqs on NIC port.",
408         "vSwitch" : "OvsDpdkVhost",
409         "Parameters" : {
410             "TRAFFIC" : {
411                 "traffic_type" : "rfc2544_continuous",
412                 "frame_rate" : 100,
413                 'bidir' : 'True',
414             },
415             "TRAFFICGEN_DURATION" : 1,
416             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_2_CORE,
417             "VSWITCH_DPDK_MULTI_QUEUES" : _OVSDPDK_MQ,
418         },
419         "TestSteps": [
420                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpif-netdev/pmd-rxq-show','|dpdk[01]\s+queue-id:\s+\d+'],
421                         # check that requested nr of queues was created on both NICs
422                         ['tools', 'assert', 'len(#STEP[-1])=={}'.format(int(_OVSDPDK_MQ)*2)],
423                     ]
424     },
425     {
426         "Name": "ovsdpdk_mq_p2p_rxqs_same_core_affinity",
427         "Deployment": "p2p",
428         "Description": "Affinitize rxqs to the same core.",
429         "vSwitch" : "OvsDpdkVhost",
430         "Parameters" : {
431             "TRAFFIC" : {
432                 "traffic_type" : "rfc2544_continuous",
433                 "frame_rate" : 100,
434                 'bidir' : 'True',
435             },
436             "TRAFFICGEN_DURATION" : 1,
437             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_2_CORE,
438             "VSWITCH_DPDK_MULTI_QUEUES" : _OVSDPDK_MQ,
439         },
440         "TestSteps": [
441                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"]  -- set Interface dpdk0 other_config:pmd-rxq-affinity="0:{},1:{}"'.format(_OVSDPDK_1st_PMD_CORE, _OVSDPDK_1st_PMD_CORE)],
442                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpif-netdev/pmd-rxq-show','|dpdk0\s+queue-id:\s+0'],
443                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpif-netdev/pmd-rxq-show','|dpdk0\s+queue-id:\s+1'],
444                         ['tools', 'assert', 'len(#STEP[-2])==1'],
445                         ['tools', 'assert', 'len(#STEP[-2])==1'],
446                     ]
447     },
448     {
449         "Name": "ovsdpdk_mq_p2p_rxqs_multi_core_affinity",
450         "Deployment": "p2p",
451         "Description": "Affinitize rxqs to separate cores.",
452         "vSwitch" : "OvsDpdkVhost",
453         "Parameters" : {
454             "TRAFFIC" : {
455                 "traffic_type" : "rfc2544_continuous",
456                 "frame_rate" : 100,
457                 'bidir' : 'True',
458             },
459             "TRAFFICGEN_DURATION" : 1,
460             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_2_CORE,
461             "VSWITCH_DPDK_MULTI_QUEUES" : _OVSDPDK_MQ,
462         },
463         "TestSteps": [
464                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"]  -- set Interface dpdk0 other_config:pmd-rxq-affinity="0:{},1:{}"'.format(_OVSDPDK_1st_PMD_CORE, _OVSDPDK_2nd_PMD_CORE)],
465                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpif-netdev/pmd-rxq-show','|dpdk0\s+queue-id:\s+0'],
466                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpif-netdev/pmd-rxq-show','|dpdk0\s+queue-id:\s+1'],
467                         ['tools', 'assert', 'len(#STEP[-2])==1'],
468                         ['tools', 'assert', 'len(#STEP[-2])==1'],
469                     ]
470     },
471     {
472         "Name" : "ovsdpdk_mq_pvp_rxqs",
473         "Deployment" : "clean",
474         "Description" : "Setup rxqs on vhost user port.",
475         "vSwitch" : "OvsDpdkVhost",
476         "VNF" : "QemuDpdkVhostUser",
477         "Parameters" : {
478             "VSWITCH_DPDK_MULTI_QUEUES" : _OVSDPDK_MQ,
479             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
480             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_1_CORE,
481             "GUEST_NIC_QUEUES" : [_OVSDPDK_MQ],
482             "GUEST_LOOPBACK" : ['clean'],
483         },
484         "TestSteps": STEP_VSWITCH_PVP_INIT +
485                      [
486                         ['tools', 'exec_shell', "sudo $TOOLS['ovs-appctl'] dpif-netdev/pmd-rxq-show",
487                          '|dpdkvhostuserclient0\s+queue-id:\s+\d'],
488                         ['tools', 'assert', 'len(#STEP[-1])==1'],
489                         ['vnf', 'start'],
490                         ['tools', 'exec_shell', "sudo $TOOLS['ovs-appctl'] dpif-netdev/pmd-rxq-show",
491                          '|dpdkvhostuserclient0\s+queue-id:\s+0'],
492                         ['tools', 'exec_shell', "sudo $TOOLS['ovs-appctl'] dpif-netdev/pmd-rxq-show",
493                          '|dpdkvhostuserclient0\s+queue-id:\s+1'],
494                         ['tools', 'assert', 'len(#STEP[-2])==1'],
495                         ['tools', 'assert', 'len(#STEP[-2])==1'],
496                         ['vnf', 'stop'],
497                      ] +
498                      STEP_VSWITCH_PVP_FINIT
499     },
500     {
501         "Name" : "ovsdpdk_mq_pvp_rxqs_linux_bridge",
502         "Deployment" : "clean",
503         "Description" : "Confirm traffic received over vhost RXQs with Linux virtio device in guest.",
504         "vSwitch" : "OvsDpdkVhost",
505         "VNF" : "QemuDpdkVhostUser",
506         "Parameters" : {
507             # configure 2 queues at both OVS and QEMU
508             "VSWITCH_DPDK_MULTI_QUEUES" : _OVSDPDK_MQ,
509             "GUEST_NIC_QUEUES" : [_OVSDPDK_MQ],
510             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_2_CORE,
511             "GUEST_LOOPBACK" : ['clean'],
512             "TRAFFICGEN_DURATION" : 5,
513             "TRAFFICGEN" : "IxNet",
514             "TRAFFIC" : {
515                 "bidir" : "false",
516                 "traffic_type" : "rfc2544_continuous",
517                 "multistream" : 6,
518                 "stream_type" : "L3",
519                 "frame_rate" : 1,
520                 'l2': {
521                     'srcmac': "00:00:07:00:0E:00",
522                     'dstmac': "00:00:00:00:00:01"
523                 },
524                 'l3': {
525                     'enabled': True,
526                     'proto': 'udp',
527                     'srcip': '6.6.6.6',
528                     'dstip': '1.1.1.1',
529                 },
530             }
531         },
532         "TestSteps": STEP_VSWITCH_PVP_INIT + [
533                         # one flow will sent data to the VM
534                         ['vswitch', 'add_flow', 'int_br0',
535                          {'in_port': '#STEP[1][1]', 'actions': ['output:#STEP[3][1]'], 'idle_timeout': '0'}],
536                         # second flow just forwards traffic to the traffic generator,
537                         # so send_traffic() will end with success
538                         ['vswitch', 'add_flow', 'int_br0',
539                          {'in_port': '#STEP[2][1]', 'actions': ['output:#STEP[1][1]'], 'idle_timeout': '0'}],
540                         ['vnf', 'start'],
541                         # configure two channels, so multiple cores could be used
542                         ['vnf', 'execute_and_wait', 'ethtool -L eth0 combined 2'],
543                         ['vnf', 'execute_and_wait', 'ethtool -l eth0', '|Combined:\s+2'],
544                         ['tools', 'assert', 'len(#STEP[-1])==2'],
545                         # traffic will be sent to several DST IPs so it can be
546                         # dispatched between channels; We have to insert routes
547                         # and ARPs, otherwise traffic will be dropped
548                         ['vnf', 'execute_and_wait', 'ifconfig eth0 5.5.5.1/24 up'],
549                         ['vnf', 'execute_and_wait', 'sysctl -w net.ipv4.ip_forward=1'],
550                         ['vnf', 'execute_and_wait', 'sysctl -w net.ipv4.conf.all.rp_filter=0'],
551                         ['vnf', 'execute_and_wait', 'ip route add 6.6.6.0/24 dev eth0'],
552                         ['vnf', 'execute_and_wait', 'route add default gw 6.6.6.6 eth0'],
553                         ['vnf', 'execute_and_wait', 'arp -s 6.6.6.6 00:00:07:00:0E:00'],
554                         ['vnf', 'execute_and_wait', 'ip route add 1.1.1.0/31 dev eth0'],
555                         ['vnf', 'execute_and_wait', 'route add default gw 1.1.1.1 eth0'],
556                         ['vnf', 'execute_and_wait', 'arp -s 1.1.1.1 DE:AD:BE:EF:CA:FA'],
557                         ['vnf', 'execute_and_wait', 'ip route add 1.1.1.2/31 dev eth0'],
558                         ['vnf', 'execute_and_wait', 'route add default gw 1.1.1.3 eth0'],
559                         ['vnf', 'execute_and_wait', 'arp -s 1.1.1.3 DE:AD:BE:EF:CA:FB'],
560                         ['vnf', 'execute_and_wait', 'ip route add 1.1.1.4/31 dev eth0'],
561                         ['vnf', 'execute_and_wait', 'route add default gw 1.1.1.5 eth0'],
562                         ['vnf', 'execute_and_wait', 'arp -s 1.1.1.5 DE:AD:BE:EF:CA:FC'],
563                         ['vnf', 'execute_and_wait', 'ip a'],
564
565                         ['trafficgen', 'send_traffic',{}],
566                         # check interrupts to verify that traffic was corectly dispatched...
567                         ['#result', 'vnf', 'execute_and_wait', 'cat /proc/interrupts',
568                          '|^\s*\d+:\s+(\d+)\s+(\d+).+virtio0-input'],
569                         # ...it means that two channels were created...
570                         ['tools', 'assert', 'len(#STEP[result])==2'],
571                         # ...and both channels processed data; Check that interrupt count is "much"
572                         # higher than 0 to eliminate impact of rogue interrupts.
573                         ['tools', 'assert', 'int(#STEP[result][0][0]) + int(#STEP[result][0][1]) > 1000'],
574                         ['tools', 'assert', 'int(#STEP[result][1][0]) + int(#STEP[result][1][1]) > 1000'],
575                         ['vnf', 'stop'],
576                      ]
577     },
578     {
579         "Name" : "ovsdpdk_mq_pvp_rxqs_testpmd",
580         "Deployment" : "clean",
581         "Description" : "Confirm traffic received over vhost RXQs with DPDK device in guest.",
582         "vSwitch" : "OvsDpdkVhost",
583         "VNF" : "QemuDpdkVhostUser",
584         "Parameters" : {
585             "TRAFFICGEN" : "IxNet",
586             # configure 2 queues at both OVS and QEMU
587             "VSWITCH_DPDK_MULTI_QUEUES" : _OVSDPDK_MQ,
588             "GUEST_NIC_QUEUES" : [_OVSDPDK_MQ],
589             "VSWITCH_PMD_CPU_MASK" : _OVSDPDK_PMD_MASK_2_CORE,
590             "GUEST_CORE_BINDING" : _OVSDPDK_GUEST_5_CORES,
591             "GUEST_LOOPBACK" : ['testpmd'],
592             # there must be separate CPU for each of RX/TX queues
593             "GUEST_SMP" : ['5'],
594             "GUEST_TESTPMD_PARAMS" : ['-c 0x1F -n 4 --socket-mem 512 -- '
595                                       '--burst=64 -i --nb-cores=4 '
596                                       '--rxq=2 --txq=2'],
597             "TRAFFICGEN_DURATION" : 5,
598             "TRAFFIC" : {
599                 "traffic_type" : "rfc2544_continuous",
600                 "multistream" : 3,
601                 "stream_type" : "L3",
602                 "frame_rate" : 1,
603                 "learning_frames" : False,
604                 'l3': {
605                     'enabled': True,
606                     'proto': 'udp',
607                     'srcip': '6.6.6.6',
608                     'dstip': '1.1.1.1',
609                 },
610             },
611             "GUEST_QUEUE_STATS_MAPPING" : ["rx 0 0 0",
612                                            "rx 0 1 1",
613                                            "rx 1 0 2",
614                                            "rx 1 1 3",
615                                            "tx 0 0 4",
616                                            "tx 0 1 5",
617                                            "tx 1 0 6",
618                                            "tx 1 1 7"
619                                           ]
620         },
621         "TestSteps": STEP_VSWITCH_PVP_FLOWS_INIT +
622                      [
623                         ['vnf', 'start'],
624                         ['tools', 'exec_shell', "sudo $TOOLS['ovs-appctl'] dpif-netdev/pmd-rxq-show",
625                          '|dpdk\w+\s+queue-id:\s+\d'],
626                         # there must be two standalone queue records for every interface (2x4)
627                         ['tools', 'assert', 'len(#STEP[-1])==8'],
628                         ['trafficgen', 'send_traffic', {}],
629
630                         # check that packets were received by both queues at both ports
631                         ['vnf', 'execute_and_wait', 'show port stats 0', 60, 'testpmd>',
632                          '|Stats reg  [01] RX-packets:\s+(\d+)'],
633                         ['tools', 'assert', '"0" not in #STEP[-1]'],
634                         # rx queue of 2nd port should be mapped to reg 2 and 3, but mapping might not work
635                         # so let us check that exactly two RX regs have non zero values
636                         ['vnf', 'execute_and_wait', 'show port stats 1', 60, 'testpmd>',
637                          '|Stats reg\s+\d+ RX-packets:\s+\d\d+'],
638                         ['tools', 'assert', 'len(#STEP[-1])==2'],
639                         # clean up
640                         ['vnf', 'stop'],
641                      ]
642     },
643     ############################################################
644     #
645     #  Vhost User
646     #
647     ############################################################
648     {
649         "Name": "ovsdpdk_vhostuser_client",
650         "Deployment": "pvp",
651         "Description": "Test vhost-user client mode",
652         "vSwitch" : "OvsDpdkVhost",
653         "VNF" : "QemuDpdkVhostUser",
654         "Parameters" : {
655             "TRAFFIC" : {
656                 "traffic_type" : "rfc2544_continuous",
657                 "frame_rate" : 100,
658                 'bidir' : 'True',
659             },
660             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
661             "TRAFFICGEN_DURATION" : 1,
662         },
663         "TestSteps": [
664                         # check that client ports are really used
665                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show',
666                                                 '|type.*dpdkvhostuserclient'],
667                         ['tools', 'assert', 'len(#STEP[-1])==2'],
668                         # send traffic manually, so TC will fail in case
669                         # that packets won't make it through
670                         ['trafficgen', 'send_traffic', {}],
671                      ],
672     },
673     {
674         "Name": "ovsdpdk_vhostuser_client_reconnect",
675         "Deployment": "pvp",
676         "Description": "Test vhost-user client mode reconnect feature",
677         "vSwitch" : "OvsDpdkVhost",
678         "VNF" : "QemuDpdkVhostUser",
679         "Parameters" : {
680             "TRAFFIC" : {
681                 "traffic_type" : "rfc2544_continuous",
682                 "frame_rate" : 100,
683                 'bidir' : 'True',
684             },
685             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
686             "TRAFFICGEN_DURATION" : 1,
687         },
688         "TestSteps": [
689                         # send traffic to verify correct PVP configuration
690                         ['trafficgen', 'send_traffic', {}],
691                         ['vswitch', 'dump_flows', '$VSWITCH_BRIDGE_NAME'],
692                         # restart vswitchd, ovsdb is kept untouched, so ovs configuration
693                         # (except flows) will be restored
694                         ['vswitch', 'restart'],
695                         ['vswitch', 'del_flow', '$VSWITCH_BRIDGE_NAME', {}],
696                         ['vswitch', 'dump_flows', '$VSWITCH_BRIDGE_NAME'],
697                         ['vswitch', 'add_flow', '$VSWITCH_BRIDGE_NAME', {'in_port': '1', 'actions': ['output:3'], 'idle_timeout': '0'}],
698                         ['vswitch', 'add_flow', '$VSWITCH_BRIDGE_NAME', {'in_port': '3', 'actions': ['output:1'], 'idle_timeout': '0'}],
699                         ['vswitch', 'add_flow', '$VSWITCH_BRIDGE_NAME', {'in_port': '2', 'actions': ['output:4'], 'idle_timeout': '0'}],
700                         ['vswitch', 'add_flow', '$VSWITCH_BRIDGE_NAME', {'in_port': '4', 'actions': ['output:2'], 'idle_timeout': '0'}],
701                         ['vswitch', 'dump_flows', '$VSWITCH_BRIDGE_NAME'],
702                         # send traffic to verify that OVS works correctly after restart
703                         ['trafficgen', 'send_traffic', {}],
704                      ],
705     },
706     {
707         "Name": "ovsdpdk_vhostuser_server",
708         "Deployment": "pvp",
709         "Description": "Test vhost-user server mode",
710         "vSwitch" : "OvsDpdkVhost",
711         "VNF" : "QemuDpdkVhostUser",
712         "Parameters" : {
713             "TRAFFIC" : {
714                 "traffic_type" : "rfc2544_continuous",
715                 "frame_rate" : 100,
716                 'bidir' : 'True',
717             },
718             "VSWITCH_VHOSTUSER_SERVER_MODE" : True,
719             "TRAFFICGEN_DURATION" : 1,
720         },
721         "TestSteps": [
722                         # check that server ports are really used
723                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show',
724                                                 '|type.*dpdkvhostuser$'],
725                         ['tools', 'assert', 'len(#STEP[-1])==2'],
726                         # send traffic manually, so TC will fail in case
727                         # that packets won't make it through
728                         ['trafficgen', 'send_traffic', {}],
729                      ],
730     },
731     {
732         "Name": "ovsdpdk_vhostuser_sock_dir",
733         "Deployment": "clean",
734         "Description": "Verify functionality of vhost-sock-dir flag",
735         "vSwitch" : "OvsDpdkVhost",
736         "Parameters" : {
737             "VSWITCH_VHOSTUSER_SERVER_MODE" : True,
738         },
739         "TestSteps": [
740                         ['vswitch', 'add_switch', '$VSWITCH_BRIDGE_NAME'],
741                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Open_vSwitch . '
742                          'other_config:vhost-sock-dir=test_dir'],
743                         # enforce vswitchd to read new configuration
744                         ['vswitch', 'restart'],
745                         ['tools', 'exec_shell', 'sudo mkdir $TOOLS["ovs_var_tmp"]/test_dir'],
746                         ['vswitch', 'add_vport', '$VSWITCH_BRIDGE_NAME'],
747                         ['tools', 'exec_shell', 'ls -1 $TOOLS["ovs_var_tmp"]/test_dir',
748                          '|dpdkvhostuser0'],
749                         ['tools', 'assert', 'len(#STEP[-1])'],
750                      ],
751     },
752 ]
753 ############################################################
754 #
755 #  Virtual Devices Support
756 #
757 ############################################################
758 _OVSDPDK_VDEV_ADD_NULL = [
759     ['vswitch', 'add_switch', 'int_br0'],
760     ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"]  add-port int_br0 null0 -- '
761      'set Interface null0 type=dpdk options:dpdk-devargs=eth_null0'],
762     ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show', '|dpdk-devargs=\S+eth_null0'],
763     ['tools', 'assert', 'len(#STEP[-1])==1'],
764 ]
765
766 _OVSDPDK_VDEV_ADD_AF_PACKET = [
767     # resore original NICS configuration, so we can use NICS dictionary
768     ['settings', 'setValue', 'TEST_PARAMS', ''],
769     # check if vsperf was able to read device name
770     ['tools', 'assert', 'str(\"$NICS[0]["device"]\") != \"None\"'],
771     ['tools', 'exec_shell', 'sudo ip link set dev $NICS[0]["device"] up'],
772     ['vswitch', 'add_switch', 'int_br0'],
773     ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"]  add-port int_br0 myeth0 -- '
774      'set Interface myeth0 type=dpdk options:dpdk-devargs=eth_af_packet0,iface=$NICS[0]["device"]'],
775     # check if device was created...
776     ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show', '|dpdk-devargs=\S+eth_af_packet0'],
777     ['tools', 'assert', 'len(#STEP[-1])==1'],
778     # ...without errors
779     ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show', '|Error attaching device'],
780     ['tools', 'assert', 'not len(#STEP[-1])'],
781 ]
782
783 INTEGRATION_TESTS = INTEGRATION_TESTS + [
784     {
785         "Name": "ovsdpdk_vdev_add_null_pmd",
786         "Deployment": "clean",
787         "Description": "Test addition of port using the null DPDK PMD driver.",
788         "vSwitch" : "OvsDpdkVhost",
789         "TestSteps": _OVSDPDK_VDEV_ADD_NULL
790     },
791     {
792         "Name": "ovsdpdk_vdev_del_null_pmd",
793         "Deployment": "clean",
794         "Description": "Test deletion of port using the null DPDK PMD driver.",
795         "vSwitch" : "OvsDpdkVhost",
796         "TestSteps": _OVSDPDK_VDEV_ADD_NULL + [
797                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"]  del-port null0'],
798                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show',
799                          '|dpdk-devargs=\S+eth_null0'],
800                         ['tools', 'assert', 'not len(#STEP[-1])'],
801                     ]
802     },
803     {
804         "Name": "ovsdpdk_vdev_add_af_packet_pmd",
805         "Deployment": "clean",
806         "Description": "Test addition of port using the af_packet DPDK PMD driver.",
807         "vSwitch" : "OvsDpdkVhost",
808         "Parameters" : {
809             # suppress DPDK configuration, so physical interfaces are not bound to DPDK driver
810             'WHITELIST_NICS' : [],
811             'NICS' : [],
812         },
813         "TestSteps": _OVSDPDK_VDEV_ADD_AF_PACKET
814     },
815     {
816         "Name": "ovsdpdk_vdev_del_af_packet_pmd",
817         "Deployment": "clean",
818         "Description": "Test deletion of port using the af_packet DPDK PMD driver.",
819         "vSwitch" : "OvsDpdkVhost",
820         "Parameters" : {
821             # suppress DPDK configuration, so physical interfaces are not bound to DPDK driver
822             'WHITELIST_NICS' : [],
823             'NICS' : [],
824         },
825         "TestSteps": _OVSDPDK_VDEV_ADD_AF_PACKET + [
826                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"]  del-port myeth0'],
827                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] show',
828                          '|dpdk-devargs=\S+eth_af_packet0'],
829                         ['tools', 'assert', 'not len(#STEP[-1])'],
830                     ]
831     },
832     ############################################################
833     #
834     #  NUMA Support
835     #
836     ############################################################
837     {
838         "Name": "ovsdpdk_numa",
839         "Deployment": "clean",
840         "Description": "Test vhost-user NUMA support. Vhostuser PMD threads should migrate "
841                        "to the same numa slot, where QEMU is executed.",
842         "vSwitch" : "OvsDpdkVhost",
843         "VNF" : "QemuDpdkVhostUser",
844         "Parameters" : {
845             # ensure that memory and cpus are available at both numa slots
846             "DPDK_SOCKET_MEM" : ['1024', '1024'],
847             "VSWITCH_PMD_CPU_MASK" : 'FFFFFE',
848             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
849             # traffic won't be send, so speed up VNF deployment
850             "GUEST_LOOPBACK" : ['clean']
851         },
852         "TestSteps": STEP_VSWITCH_PVP_INIT +
853             [
854                 # check that at least 2 numa slots are available
855                 ['tools', 'exec_shell', 'numactl -H', '|available: ([0-9]+)'],
856                 ['tools', 'assert', '#STEP[-1][0]>1'],
857                 # check that PMD thread serving dpdkvhostuserclient0 runs at NUMA slot 0
858                 ['tools', 'exec_shell', "sudo $TOOLS['ovs-appctl'] "
859                     "dpif-netdev/pmd-rxq-show | "
860                     "sed -e '/dpdkvhostuserclient0/,$d' | tac",
861                     '|pmd thread numa_id ([0-9])+'
862                 ],
863                 ['tools', 'assert', '#STEP[-1][0]==0'],
864                 # store last 2 cores from 2nd numa slot
865                 ['tools', 'exec_shell', 'numactl -H', '|node 1 cpus:.*\s+(\\d+) (\\d+)$'],
866                 # pin VNF to 2nd NUMA slot
867                 ['settings', 'setValue', 'GUEST_CORE_BINDING',
868                     [("#STEP[-1][0][0]", "#STEP[-1][0][1]")]
869                 ],
870                 ['vnf', 'start'],
871                 # ...and check that PMD thread serving dpdkvhostuserclient0
872                 # has migrated to NUMA slot 1
873                 ['tools', 'exec_shell', "sudo $TOOLS['ovs-appctl'] "
874                     "dpif-netdev/pmd-rxq-show | "
875                     "sed -e '/dpdkvhostuserclient0/,$d' | tac",
876                     '|pmd thread numa_id ([0-9])+'
877                 ],
878                 ['tools', 'assert', '#STEP[-1][0]==1'],
879                 ['vnf', 'stop'],
880             ] +
881             STEP_VSWITCH_PVP_FINIT
882     },
883     ############################################################
884     #
885     #  Jumbo Frame Support
886     #
887     ############################################################
888     {
889         "Name": "ovsdpdk_jumbo_increase_mtu_phy_port_ovsdb",
890         "Deployment": "clean",
891         "Description": "Ensure that the increased MTU for a DPDK physical port is updated in OVSDB.",
892         "vSwitch" : "OvsDpdkVhost",
893         "TestSteps": [
894                         ['vswitch', 'add_switch', 'int_br0'],
895                         ['vswitch', 'add_phy_port', 'int_br0'],
896                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
897                         ['tools', 'assert', 'int(#STEP[-1])==1500'],
898                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdk0 mtu_request=9000'],
899                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
900                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
901                     ]
902     },
903     {
904         "Name": "ovsdpdk_jumbo_increase_mtu_vport_ovsdb",
905         "Deployment": "clean",
906         "Description": "Ensure that the increased MTU for a DPDK vhost-user port is updated in OVSDB.",
907         "vSwitch" : "OvsDpdkVhost",
908         "Parameters" : {
909             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
910         },
911         "TestSteps": [
912                         ['vswitch', 'add_switch', 'int_br0'],
913                         ['vswitch', 'add_vport', 'int_br0'],
914                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdkvhostuserclient0 mtu'],
915                         ['tools', 'assert', 'int(#STEP[-1])==1500'],
916                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdkvhostuserclient0 mtu_request=9000'],
917                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdkvhostuserclient0 mtu'],
918                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
919                     ]
920     },
921     {
922         "Name": "ovsdpdk_jumbo_reduce_mtu_phy_port_ovsdb",
923         "Deployment": "clean",
924         "Description": "Ensure that the reduced MTU for a DPDK physical port is updated in OVSDB.",
925         "vSwitch" : "OvsDpdkVhost",
926         "Parameters" : {
927             "VSWITCH_JUMBO_FRAMES_ENABLED" : 'True',
928             "VSWITCH_JUMBO_FRAMES_SIZE" : 9000,
929         },
930         "TestSteps": [
931                         ['vswitch', 'add_switch', 'int_br0'],
932                         ['vswitch', 'add_phy_port', 'int_br0'],
933                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
934                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
935                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdk0 mtu_request=2000'],
936                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
937                         ['tools', 'assert', 'int(#STEP[-1])==2000'],
938                     ]
939     },
940     {
941         "Name": "ovsdpdk_jumbo_reduce_mtu_vport_ovsdb",
942         "Deployment": "clean",
943         "Description": "Ensure that the reduced MTU for a DPDK vhost-user port is updated in OVSDB.",
944         "vSwitch" : "OvsDpdkVhost",
945         "Parameters" : {
946             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
947             "VSWITCH_JUMBO_FRAMES_ENABLED" : 'True',
948             "VSWITCH_JUMBO_FRAMES_SIZE" : 9000,
949         },
950         "TestSteps": [
951                         ['vswitch', 'add_switch', 'int_br0'],
952                         ['vswitch', 'add_vport', 'int_br0'],
953                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdkvhostuserclient0 mtu'],
954                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
955                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdkvhostuserclient0 mtu_request=2000'],
956                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdkvhostuserclient0 mtu'],
957                         ['tools', 'assert', 'int(#STEP[-1])==2000'],
958                     ]
959     },
960     {
961         "Name": "ovsdpdk_jumbo_increase_mtu_phy_port_datapath",
962         "Deployment": "clean",
963         "Description": "Ensure that the MTU for a DPDK physical port is updated in the datapath itself when increased to a valid value.",
964         "vSwitch" : "OvsDpdkVhost",
965         "TestSteps": [
966                         ['vswitch', 'add_switch', 'int_br0'],
967                         ['vswitch', 'add_phy_port', 'int_br0'],
968                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpctl/show', '|mtu=1500'],
969                         ['tools', 'assert', 'len(#STEP[-1])==1'],
970                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdk0 mtu_request=9000'],
971                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpctl/show', '|mtu=9000'],
972                         ['tools', 'assert', 'len(#STEP[-1])==1'],
973                     ]
974     },
975     {
976         "Name": "ovsdpdk_jumbo_increase_mtu_vport_datapath",
977         "Deployment": "clean",
978         "Description": "Ensure that the MTU for a DPDK vhost-user port is updated in the datapath itself when increased to a valid value.",
979         "vSwitch" : "OvsDpdkVhost",
980         "Parameters" : {
981             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
982         },
983         "TestSteps": [
984                         ['vswitch', 'add_switch', 'int_br0'],
985                         ['vswitch', 'add_vport', 'int_br0'],
986                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpctl/show', '|mtu=1500'],
987                         ['tools', 'assert', 'len(#STEP[-1])==1'],
988                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdkvhostuserclient0 mtu_request=9000'],
989                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpctl/show', '|mtu=9000'],
990                         ['tools', 'assert', 'len(#STEP[-1])==1'],
991                     ]
992     },
993     {
994         "Name": "ovsdpdk_jumbo_reduce_mtu_phy_port_datapath",
995         "Deployment": "clean",
996         "Description": "Ensure that the MTU for a DPDK physical port is updated in the datapath itself when decreased to a valid value.",
997         "vSwitch" : "OvsDpdkVhost",
998         "Parameters" : {
999             "VSWITCH_JUMBO_FRAMES_ENABLED" : 'True',
1000             "VSWITCH_JUMBO_FRAMES_SIZE" : 9000,
1001         },
1002         "TestSteps": [
1003                         ['vswitch', 'add_switch', 'int_br0'],
1004                         ['vswitch', 'add_phy_port', 'int_br0'],
1005                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpctl/show', '|mtu=9000'],
1006                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1007                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdk0 mtu_request=2000'],
1008                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpctl/show', '|mtu=2000'],
1009                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1010                     ]
1011     },
1012     {
1013         "Name": "ovsdpdk_jumbo_reduce_mtu_vport_datapath",
1014         "Deployment": "clean",
1015         "Description": "Ensure that the MTU for a DPDK vhost-user port is updated in the datapath itself when decreased to a valid value.",
1016         "vSwitch" : "OvsDpdkVhost",
1017         "Parameters" : {
1018             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1019             "VSWITCH_JUMBO_FRAMES_ENABLED" : 'True',
1020             "VSWITCH_JUMBO_FRAMES_SIZE" : 9000,
1021         },
1022         "TestSteps": [
1023                         ['vswitch', 'add_switch', 'int_br0'],
1024                         ['vswitch', 'add_vport', 'int_br0'],
1025                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpctl/show', '|mtu=9000'],
1026                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1027                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdkvhostuserclient0 mtu_request=2000'],
1028                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] dpctl/show', '|mtu=2000'],
1029                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1030                     ]
1031     },
1032     {
1033         "Name": "ovsdpdk_jumbo_mtu_upper_bound_phy_port",
1034         "Deployment": "clean",
1035         "Description": "Verify that the upper bound limit is enforced for OvS DPDK Phy ports.",
1036         "vSwitch" : "OvsDpdkVhost",
1037         "TestSteps": [
1038                         ['vswitch', 'add_switch', 'int_br0'],
1039                         ['vswitch', 'add_phy_port', 'int_br0'],
1040                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdk0 mtu_request=9702'],
1041                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
1042                         ['tools', 'assert', 'int(#STEP[-1])==9702'],
1043                         # get line number of next log file entry
1044                         ['tools', 'exec_shell', 'echo $((1+`wc -l $_OVSDPDK_VSWITCH_LOG | cut -d" " -f1`))', '(\d+)'],
1045                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdk0 mtu_request=9711'],
1046                         # check vswitchd log file, that new MTU request was denied
1047                         ['tools', 'exec_shell', "sed -n '#STEP[-2][0],$ p' $_OVSDPDK_VSWITCH_LOG",
1048                          '|unsupported MTU 9711'],
1049                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
1050                         ['tools', 'assert', 'int(#STEP[-1])==9702'],
1051                     ]
1052     },
1053     {
1054         "Name": "ovsdpdk_jumbo_mtu_upper_bound_vport",
1055         "Deployment": "clean",
1056         "Description": "Verify that the upper bound limit is enforced for OvS DPDK vhost-user ports.",
1057         "vSwitch" : "OvsDpdkVhost",
1058         "Parameters" : {
1059             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1060         },
1061         "TestSteps": [
1062                         ['vswitch', 'add_switch', 'int_br0'],
1063                         ['vswitch', 'add_vport', 'int_br0'],
1064                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdkvhostuserclient0 mtu_request=9702'],
1065                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdkvhostuserclient0 mtu'],
1066                         ['tools', 'assert', 'int(#STEP[-1])==9702'],
1067                         # get line number of next log file entry
1068                         ['tools', 'exec_shell', 'echo $((1+`wc -l $_OVSDPDK_VSWITCH_LOG | cut -d" " -f1`))', '(\d+)'],
1069                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdkvhostuserclient0 mtu_request=9711'],
1070                         # check vswitchd log file, that new MTU request was denied
1071                         ['tools', 'exec_shell', "sed -n '#STEP[-2][0],$ p' $_OVSDPDK_VSWITCH_LOG",
1072                          '|unsupported MTU 9711'],
1073                         ['tools', 'assert', 'len(#STEP[-1])'],
1074                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdkvhostuserclient0 mtu'],
1075                         ['tools', 'assert', 'int(#STEP[-1])==9702'],
1076                     ]
1077     },
1078     {
1079         "Name": "ovsdpdk_jumbo_mtu_lower_bound_phy_port",
1080         "Deployment": "clean",
1081         "Description": "Verify that the lower bound limit is enforced for OvS DPDK Phy ports.",
1082         "vSwitch" : "OvsDpdkVhost",
1083         "TestSteps": [
1084                         ['vswitch', 'add_switch', 'int_br0'],
1085                         ['vswitch', 'add_phy_port', 'int_br0'],
1086                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdk0 mtu_request=68'],
1087                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
1088                         ['tools', 'assert', 'int(#STEP[-1])==68'],
1089                         # get line number of next log file entry
1090                         ['tools', 'exec_shell', 'echo $((1+`wc -l $_OVSDPDK_VSWITCH_LOG | cut -d" " -f1`))', '(\d+)'],
1091                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdk0 mtu_request=67'],
1092                         # check vswitchd log file, that new MTU request was denied
1093                         ['tools', 'exec_shell', "sed -n '#STEP[-2][0],$ p' $_OVSDPDK_VSWITCH_LOG",
1094                          '|unsupported MTU 67'],
1095                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
1096                         ['tools', 'assert', 'int(#STEP[-1])==68'],
1097                     ]
1098     },
1099     {
1100         "Name": "ovsdpdk_jumbo_mtu_lower_bound_vport",
1101         "Deployment": "clean",
1102         "Description": "Verify that the lower bound limit is enforced for OvS DPDK vhost-user ports.",
1103         "vSwitch" : "OvsDpdkVhost",
1104         "Parameters" : {
1105             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1106         },
1107         "TestSteps": [
1108                         ['vswitch', 'add_switch', 'int_br0'],
1109                         ['vswitch', 'add_vport', 'int_br0'],
1110                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdkvhostuserclient0 mtu_request=68'],
1111                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdkvhostuserclient0 mtu'],
1112                         ['tools', 'assert', 'int(#STEP[-1])==68'],
1113                         # get line number of next log file entry
1114                         ['tools', 'exec_shell', 'echo $((1+`wc -l $_OVSDPDK_VSWITCH_LOG | cut -d" " -f1`))', '(\d+)'],
1115                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set Interface dpdkvhostuserclient0 mtu_request=67'],
1116                         # check vswitchd log file, that new MTU request was denied
1117                         ['tools', 'exec_shell', "sed -n '#STEP[-2][0],$ p' $_OVSDPDK_VSWITCH_LOG",
1118                          '|unsupported MTU 67'],
1119                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdkvhostuserclient0 mtu'],
1120                         ['tools', 'assert', 'int(#STEP[-1])==68'],
1121                     ]
1122     },
1123     {
1124         "Name": "ovsdpdk_jumbo_p2p",
1125         "Deployment": "p2p",
1126         "Description": "Ensure that jumbo frames are received, processed and forwarded correctly by DPDK physical ports.",
1127         "vSwitch" : "OvsDpdkVhost",
1128         "Parameters" : {
1129             "TRAFFIC" : {
1130                 "traffic_type" : "rfc2544_continuous",
1131                 "frame_rate" : 100,
1132                 'bidir' : 'False',
1133                 'learning_frames' : False,
1134             },
1135             "TRAFFICGEN_PKT_SIZES" : (9018,),
1136             "VSWITCH_JUMBO_FRAMES_ENABLED" : 'True',
1137             "VSWITCH_JUMBO_FRAMES_SIZE" : 9000,
1138         },
1139         "TestSteps": [
1140                         # verify jumbo frame configuration
1141                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
1142                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
1143                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk1 mtu'],
1144                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
1145                         ['trafficgen', 'send_traffic', {}],
1146                         # check that jumbo frames were received by traffic generator
1147                         ['trafficgen', 'get_results'],
1148                         # i.e. (RX in Bytes/s) divide (RX frames/s) ~ 9018 Bytes
1149                         ['tools', 'assert', 'round(float(#STEP[-1][0]["throughput_rx_mbps"])*1000000/8 / '
1150                          'float(#STEP[-1][0]["throughput_rx_fps"]))==9018'],
1151                      ]
1152     },
1153 {
1154         "Name": "ovsdpdk_jumbo_pvp",
1155         "Deployment": "clean",
1156         "Description": "Ensure that jumbo frames are received, processed and forwarded correctly by DPDK vhost-user ports.",
1157         "vSwitch" : "OvsDpdkVhost",
1158         "VNF" : "QemuDpdkVhostUser",
1159         "Parameters" : {
1160             "TRAFFIC" : {
1161                 "traffic_type" : "rfc2544_continuous",
1162                 "frame_rate" : 100,
1163                 'bidir' : 'False',
1164                 'learning_frames' : False,
1165             },
1166             "TRAFFICGEN_PKT_SIZES" : (9018,),
1167             "VSWITCH_JUMBO_FRAMES_ENABLED" : 'True',
1168             "VSWITCH_JUMBO_FRAMES_SIZE" : 9000,
1169             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1170             "GUEST_LOOPBACK" : ['linux_bridge'],
1171             "GUEST_NIC_MERGE_BUFFERS_DISABLE" : [False],
1172         },
1173         "TestSteps": STEP_VSWITCH_PVP_FLOWS_INIT + [
1174                         # verify jumbo frame configuration
1175                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
1176                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
1177                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk1 mtu'],
1178                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
1179                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdkvhostuserclient0 mtu'],
1180                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
1181                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdkvhostuserclient1 mtu'],
1182                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
1183                         # VNF startup, MTU configuration
1184                         ['vnf', 'start'],
1185                         ['vnf', 'execute_and_wait', 'ifconfig eth0 mtu 9000'],
1186                         ['vnf', 'execute_and_wait', 'ifconfig eth1 mtu 9000'],
1187                         ['trafficgen', 'send_traffic', {}],
1188                         # check that jumbo frames were received by traffic generator
1189                         ['trafficgen', 'get_results'],
1190                         # i.e. (RX in Bytes/s) divide (RX frames/s) ~ 9018 Bytes
1191                         ['tools', 'assert', 'round(float(#STEP[-1][0]["throughput_rx_mbps"])*1000000/8 / '
1192                          'float(#STEP[-1][0]["throughput_rx_fps"]))==9018'],
1193                         ['vnf', 'stop'],
1194                    ] + STEP_VSWITCH_PVP_FLOWS_FINIT
1195     },
1196     {
1197         "Name": "ovsdpdk_jumbo_p2p_upper_bound",
1198         "Deployment": "p2p",
1199         "Description": "Ensure that jumbo frames above the configured Rx port's MTU are not accepted",
1200         "vSwitch" : "OvsDpdkVhost",
1201         "Parameters" : {
1202             "TRAFFIC" : {
1203                 "traffic_type" : "rfc2544_continuous",
1204                 "frame_rate" : 10,
1205                 'bidir' : 'False',
1206                 'learning_frames' : False,
1207             },
1208             "VSWITCH_JUMBO_FRAMES_ENABLED" : 'True',
1209             "VSWITCH_JUMBO_FRAMES_SIZE" : 9000,
1210         },
1211         "TestSteps": [
1212                         # set and verify jumbo frame support
1213                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk0 mtu'],
1214                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
1215                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] get Interface dpdk1 mtu'],
1216                         ['tools', 'assert', 'int(#STEP[-1])==9000'],
1217                         # set packetsize to 9018 and send traffic
1218                         ['settings', 'setValue', 'TRAFFICGEN_PKT_SIZES', (9018,)],
1219                         ['trafficgen', 'send_traffic', {}],
1220                         ['trafficgen', 'get_results'],
1221                         # all traffic should pass through (i.e. 0% frame loss)
1222                         ['tools', 'assert', 'float(#STEP[-1][0]["frame_loss_percent"])==0'],
1223                         # set packetsize to 9702 and send traffic
1224                         ['settings', 'setValue', 'TRAFFICGEN_PKT_SIZES', (9702,)],
1225                         # disable verification of send_traffic "!" prefix, otherwise vsperf
1226                         # will fail when 100% packet loss is detected
1227                         ['!trafficgen', 'send_traffic', {}],
1228                         ['trafficgen', 'get_results'],
1229                         # all traffic should be dropped
1230                         ['tools', 'assert', 'float(#STEP[-1][0]["frame_loss_percent"])==100'],
1231                      ]
1232     },
1233 ]
1234 ############################################################
1235 #
1236 #  Rate Limiting
1237 #
1238 ############################################################
1239 # default settings of limiter used in macros and tests
1240 _OVSDPDK_RATE_PORT = 'dpdk'
1241 _OVSDPDK_RATE_NICID = '0'
1242 _OVSDPDK_RATE_RATE = '10000'             # desired maximum rate of PAYLOAD carried by frames
1243 _OVSDPDK_RATE_BURST = '8000'
1244 _OVSDPDK_RATE_LIMITER_CREATED = 'True'   # set to False to verify that limiter was not created
1245
1246 _OVSDPDK_RATE_DEVIATION = '5'            # acceptable deviation from configured frame rate in %
1247 # Formula used for validation of rate settings.
1248 # Note: OVS parameter "ingress_policing_rate" configures maximum rate of payload in Kbps,
1249 # but traffic generator measures throughput in Mbps based on whole frames including headers.
1250 # Thus measured RX throughput value reported by traffic generator must be deducted by bit
1251 # rate consumed by frame header transmission.
1252 _OVSDPDK_RATE_CHECK = ('abs(1-float(#STEP[{}][{}]["throughput_rx_mbps"])*1000*'
1253                        '(1-$_OVSDPDK_HEADER_LEN/float(#STEP[{}][{}]["packet_size"]))'
1254                        '/float($_OVSDPDK_RATE_RATE))*100 < $_OVSDPDK_RATE_DEVIATION')
1255
1256 # macro will setup rate limiter at interface defined by _DPDK_RATE_PORT and
1257 # _DPDK_RATE_NICID; It will verify, that limiter was created by parsing
1258 # vswitchd log file. It will also check that proper limiter values are
1259 # set for given interface.
1260 _OVSDPDK_RATE_set_rate_limiter = [
1261     # get line number of next log file entry
1262     ['tools', 'exec_shell', 'echo $((1+`wc -l $_OVSDPDK_VSWITCH_LOG | cut -d" " -f1`))', '(\d+)'],
1263     ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] '
1264      'set Interface $_OVSDPDK_RATE_PORT$_OVSDPDK_RATE_NICID '
1265      'ingress_policing_burst=$_OVSDPDK_RATE_BURST '
1266      'ingress_policing_rate=$_OVSDPDK_RATE_RATE'],
1267     # verify that interface has correct rate limiter configuration
1268     ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] '
1269      'list interface $_OVSDPDK_RATE_PORT$_OVSDPDK_RATE_NICID',
1270      '(ingress_policing_\w+: \d+)'],
1271     ['tools', 'assert', '"ingress_policing_burst: $_OVSDPDK_RATE_BURST" in #STEP[-1]'],
1272     ['tools', 'assert', '"ingress_policing_rate: $_OVSDPDK_RATE_RATE" in #STEP[-2]'],
1273 ]
1274
1275 _OVSDPDK_RATE_set_rate_limiter_NIC0 = [
1276     ['settings', 'setValue', '_OVSDPDK_RATE_NICID', '0']
1277 ] + _OVSDPDK_RATE_set_rate_limiter
1278
1279 _OVSDPDK_RATE_set_rate_limiter_NIC1 = [
1280     ['settings', 'setValue', '_OVSDPDK_RATE_NICID', '1']
1281 ] + _OVSDPDK_RATE_set_rate_limiter
1282
1283 # macro will set different limiter values and sends traffic to verify proper
1284 # limiter functionality
1285 _OVSDPDK_RATE_confirm_multiple_rate_limit_setup = \
1286     _OVSDPDK_RATE_set_rate_limiter_NIC0 + _OVSDPDK_RATE_set_rate_limiter_NIC1 + [
1287         # by default rate limit is 10Mbits/s
1288         ['trafficgen', 'send_traffic', {}],
1289         ['trafficgen', 'get_results'],
1290         # check result and accept preconfigured deviation to the configured frame rate
1291         ['tools', 'assert', _OVSDPDK_RATE_CHECK.format("-1", "0", "-1", "0")],
1292         # set rate limit to 20Mbits/s
1293         ['settings', 'setValue', '_OVSDPDK_RATE_RATE', '20000']
1294      ] + _OVSDPDK_RATE_set_rate_limiter_NIC0 + _OVSDPDK_RATE_set_rate_limiter_NIC1 + [
1295         ['trafficgen', 'send_traffic', {}],
1296         ['trafficgen', 'get_results'],
1297         # check result and accept preconfigured deviation to the configured frame rate
1298         ['tools', 'assert', _OVSDPDK_RATE_CHECK.format("-1", "0", "-1", "0")],
1299         # set rate limit to 30Mbits/s
1300         ['settings', 'setValue', '_OVSDPDK_RATE_RATE', '30000']
1301      ] + _OVSDPDK_RATE_set_rate_limiter_NIC0 + _OVSDPDK_RATE_set_rate_limiter_NIC1 + [
1302         ['trafficgen', 'send_traffic', {}],
1303         ['trafficgen', 'get_results'],
1304         # check result and accept preconfigured deviation to the configured frame rate
1305         ['tools', 'assert', _OVSDPDK_RATE_CHECK.format("-1", "0", "-1", "0")],
1306         # disable rate limiter and verify unlimited speed
1307         ['settings', 'setValue', '_OVSDPDK_RATE_RATE', '0'],
1308         ['settings', 'setValue', '_OVSDPDK_RATE_BURST', '0'],
1309         ['settings', 'setValue', '_OVSDPDK_RATE_LIMITER_CREATED', 'False'],
1310      ] + _OVSDPDK_RATE_set_rate_limiter_NIC0 + _OVSDPDK_RATE_set_rate_limiter_NIC1 + [
1311         ['trafficgen', 'send_traffic', {}],
1312         # check that traffic rate is no longer limited
1313         ['trafficgen', 'get_results'],
1314         ['tools', 'assert', 'int(#STEP[-1][0]["throughput_rx_mbps"])>500'],
1315         ['vswitch', 'dump_flows', '$VSWITCH_BRIDGE_NAME'],
1316     ]
1317
1318 INTEGRATION_TESTS = INTEGRATION_TESTS + [
1319     {
1320         "Name": "ovsdpdk_rate_create_phy_port",
1321         "Deployment": "clean",
1322         "Description": "Ensure a rate limiting interface can be created on a physical DPDK port.",
1323         "vSwitch" : "OvsDpdkVhost",
1324         "TestSteps": [
1325                         ['vswitch', 'add_switch', 'int_br0'],
1326                         ['vswitch', 'add_phy_port', 'int_br0'],
1327                     ] + _OVSDPDK_RATE_set_rate_limiter
1328     },
1329     {
1330         "Name": "ovsdpdk_rate_delete_phy_port",
1331         "Deployment": "clean",
1332         "Description": "Ensure a rate limiting interface can be destroyed on a physical DPDK port.",
1333         "vSwitch" : "OvsDpdkVhost",
1334         "TestSteps": [
1335                         ['vswitch', 'add_switch', 'int_br0'],
1336                         ['vswitch', 'add_phy_port', 'int_br0'],
1337                     ] + _OVSDPDK_RATE_set_rate_limiter + [
1338                         ['settings', 'setValue', '_OVSDPDK_RATE_RATE', '0'],
1339                         ['settings', 'setValue', '_OVSDPDK_RATE_BURST', '0'],
1340                         ['settings', 'setValue', '_OVSDPDK_RATE_LIMITER_CREATED', 'False'],
1341                     ] + _OVSDPDK_RATE_set_rate_limiter
1342     },
1343     {
1344         "Name": "ovsdpdk_rate_create_vport",
1345         "Deployment": "clean",
1346         "Description": "Ensure a rate limiting interface can be created on a vhost-user port.",
1347         "vSwitch" : "OvsDpdkVhost",
1348         "Parameters" : {
1349             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1350             "_OVSDPDK_RATE_PORT" : 'dpdkvhostuserclient',
1351         },
1352         "TestSteps": [
1353                         ['vswitch', 'add_switch', 'int_br0'],
1354                         ['vswitch', 'add_vport', 'int_br0'],
1355                     ] + _OVSDPDK_RATE_set_rate_limiter
1356     },
1357     {
1358         "Name": "ovsdpdk_rate_delete_vport",
1359         "Deployment": "clean",
1360         "Description": "Ensure a rate limiting interface can be destroyed on a vhost-user port.",
1361         "vSwitch" : "OvsDpdkVhost",
1362         "Parameters" : {
1363             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1364             "_OVSDPDK_RATE_PORT" : 'dpdkvhostuserclient',
1365         },
1366         "TestSteps": [
1367                         ['vswitch', 'add_switch', 'int_br0'],
1368                         ['vswitch', 'add_vport', 'int_br0'],
1369                     ] + _OVSDPDK_RATE_set_rate_limiter + [
1370                         ['settings', 'setValue', '_OVSDPDK_RATE_RATE', '0'],
1371                         ['settings', 'setValue', '_OVSDPDK_RATE_BURST', '0'],
1372                         ['settings', 'setValue', '_OVSDPDK_RATE_LIMITER_CREATED', 'False'],
1373                     ] + _OVSDPDK_RATE_set_rate_limiter
1374     },
1375     {
1376         "Name": "ovsdpdk_rate_no_policing",
1377         "Deployment": "clean",
1378         "Description": "Ensure when a user attempts to create a rate limiting interface but is missing policing rate argument, no rate limitiner is created.",
1379         "vSwitch" : "OvsDpdkVhost",
1380         "Parameters" : {
1381             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1382             "_OVSDPDK_RATE_PORT" : 'dpdkvhostuserclient',
1383             "_OVSDPDK_RATE_RATE" : '0',
1384             "_OVSDPDK_RATE_BURST" : '1000',
1385             "_OVSDPDK_RATE_LIMITER_CREATED" : 'False',
1386         },
1387         "TestSteps": [
1388                         ['vswitch', 'add_switch', 'int_br0'],
1389                         ['vswitch', 'add_vport', 'int_br0'],
1390                     ] + _OVSDPDK_RATE_set_rate_limiter
1391     },
1392     {
1393         "Name": "ovsdpdk_rate_no_burst",
1394         "Deployment": "clean",
1395         "Description": "Ensure when a user attempts to create a rate limiting interface but is missing policing burst argument, rate limitiner is created.",
1396         "vSwitch" : "OvsDpdkVhost",
1397         "Parameters" : {
1398             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1399             "_OVSDPDK_RATE_PORT" : 'dpdkvhostuserclient',
1400             "_OVSDPDK_RATE_RATE" : '10000',
1401             "_OVSDPDK_RATE_BURST" : '0',
1402             "_OVSDPDK_RATE_LIMITER_CREATED" : 'True',
1403         },
1404         "TestSteps": [
1405                         ['vswitch', 'add_switch', 'int_br0'],
1406                         ['vswitch', 'add_vport', 'int_br0'],
1407                     ] + _OVSDPDK_RATE_set_rate_limiter
1408     },
1409     {
1410         "Name": "ovsdpdk_rate_p2p",
1411         "Deployment": "p2p",
1412         "Description": "Ensure when a user creates a rate limiting physical interface that the traffic is limited to the specified policer rate in a p2p setup.",
1413         "vSwitch" : "OvsDpdkVhost",
1414         "Parameters" : {
1415             "_OVSDPDK_RATE_PORT" : 'dpdk',
1416             "TRAFFIC" : {
1417                 "traffic_type" : "rfc2544_continuous",
1418                 "frame_rate" : 100,
1419                 'bidir' : 'False',
1420             },
1421         },
1422         "TestSteps": _OVSDPDK_RATE_confirm_multiple_rate_limit_setup
1423     },
1424     {
1425         "Name": "ovsdpdk_rate_pvp",
1426         "Deployment": "pvp",
1427         "Description": "Ensure when a user creates a rate limiting vHost User interface that the traffic is limited to the specified policer rate in a pvp setup.",
1428         "vSwitch" : "OvsDpdkVhost",
1429         "VNF" : "QemuDpdkVhostUser",
1430         "Parameters" : {
1431             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1432             "_OVSDPDK_RATE_PORT" : 'dpdkvhostuserclient',
1433             "TRAFFIC" : {
1434                 "traffic_type" : "rfc2544_continuous",
1435                 "frame_rate" : 100,
1436                 'bidir' : 'False',
1437             },
1438         },
1439         "TestSteps": _OVSDPDK_RATE_confirm_multiple_rate_limit_setup
1440     },
1441     {
1442         "Name": "ovsdpdk_rate_p2p_multi_pkt_sizes",
1443         "Deployment": "p2p",
1444         "Description": "Ensure that rate limiting works for various frame sizes.",
1445         "vSwitch" : "OvsDpdkVhost",
1446         "Parameters" : {
1447             "_OVSDPDK_RATE_PORT" : 'dpdk',
1448             "_OVSDPDK_RATE_RATE" : '10000',
1449             "TRAFFICGEN_PKT_SIZES" : _OVSDPDK_PKT_SIZES,
1450             "TRAFFIC" : {
1451                 "traffic_type" : "rfc2544_continuous",
1452                 "frame_rate" : 100,
1453                 'bidir' : 'False',
1454             },
1455         },
1456         "TestSteps": _OVSDPDK_RATE_set_rate_limiter_NIC0 + _OVSDPDK_RATE_set_rate_limiter_NIC1 + [
1457                         # dump rate limiter configuration of both NICs
1458                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] '
1459                          'list interface dpdk0'],
1460                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] '
1461                          'list interface dpdk1'],
1462                         ['trafficgen', 'send_traffic', {}],
1463                         ['#result', 'trafficgen', 'get_results'],
1464                         # check results and accept preconfigured deviation to the configured frame rates
1465                         ['tools', 'assert', _OVSDPDK_RATE_CHECK.format("result","0", "result","0")],
1466                         ['tools', 'assert', _OVSDPDK_RATE_CHECK.format("result","1", "result","1")],
1467                         ['tools', 'assert', _OVSDPDK_RATE_CHECK.format("result","2", "result","2")],
1468                         ['tools', 'assert', _OVSDPDK_RATE_CHECK.format("result","3", "result","3")],
1469                         ['tools', 'assert', _OVSDPDK_RATE_CHECK.format("result","4", "result","4")],
1470                     ],
1471     },
1472 ]
1473 ############################################################
1474 #
1475 #  Quality of Service
1476 #
1477 ############################################################
1478 # default settings of limiter used in macros and tests
1479 _OVSDPDK_QOS_PORT = 'dpdk'
1480 _OVSDPDK_QOS_NICID = '0'
1481 _OVSDPDK_QOS_CIR = '1250000'  # desired maximum rate of PAYLOAD carried by frames in BYTEs
1482 _OVSDPDK_QOS_CBS = '2048'
1483
1484 _OVSDPDK_QOS_DEVIATION = '5'            # acceptable deviation from configured frame rate in %
1485 # Formula used for validation of rate settings.
1486 # Note: OVS parameter "ingress_policing_rate" configures maximum rate of payload in Kbps,
1487 # but traffic generator measures throughput in Mbps based on whole frames including headers.
1488 # Thus measured RX throughput value reported by traffic generator must be deducted by bit
1489 # rate consumed by frame header transmission.
1490 _OVSDPDK_QOS_CHECK = ('abs(1-float(#STEP[{}][{}]["throughput_rx_mbps"])*1000000*'
1491                       '(1-$_OVSDPDK_HEADER_LEN/float(#STEP[{}][{}]["packet_size"]))'
1492                       '/float($_OVSDPDK_QOS_CIR*8))*100 < $_OVSDPDK_QOS_DEVIATION')
1493
1494
1495 # macro will setup QoS at interface defined by _OVSDPDK_QOS_PORT and
1496 # _OVSDPDK_QOS_NICID; It will verify, that QoS was created by parsing
1497 # vswitchd log file. It will also check that proper QoS values are
1498 # set for given interface.
1499 _OVSDPDK_QOS_set_qos = [
1500     # get line number of next log file entry
1501     ['tools', 'exec_shell', 'echo $((1+`wc -l $_OVSDPDK_VSWITCH_LOG | cut -d" " -f1`))', '(\d+)'],
1502
1503     # Crete QoS policy and check the returned policy ID
1504     ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] '
1505      'set port $_OVSDPDK_QOS_PORT$_OVSDPDK_QOS_NICID qos=@newqos -- '
1506      '--id=@newqos create qos type=egress-policer other-config:cir=$_OVSDPDK_QOS_CIR '
1507      'other-config:cbs=$_OVSDPDK_QOS_CBS','|\w{8}-\w{4}-\w{4}-\w{4}-\w{12}'],
1508     ['tools', 'assert', 'len(#STEP[-1])==1'],
1509
1510     # Check the QoS policy and attributes
1511     ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] -t ovs-vswitchd qos/show '
1512      '$_OVSDPDK_QOS_PORT$_OVSDPDK_QOS_NICID', '.+'],
1513     ['tools', 'assert', "'QoS: $_OVSDPDK_QOS_PORT$_OVSDPDK_QOS_NICID egress-policer' in #STEP[-1]"],
1514     ['tools', 'assert', "'cbs: $_OVSDPDK_QOS_CBS' in #STEP[-2]"],
1515     ['tools', 'assert', "'cir: $_OVSDPDK_QOS_CIR' in #STEP[-3]"],
1516 ]
1517
1518 _OVSDPDK_QOS_set_qos_NIC0 = [
1519     ['settings', 'setValue', '_OVSDPDK_QOS_NICID', '0']
1520 ] + _OVSDPDK_QOS_set_qos
1521
1522 _OVSDPDK_QOS_set_qos_NIC1 = [
1523     ['settings', 'setValue', '_OVSDPDK_QOS_NICID', '1']
1524 ] + _OVSDPDK_QOS_set_qos
1525
1526 # macro will set different limiter values and sends traffic to verify proper
1527 # QoS functionality
1528 _OVSDPDK_QOS_confirm_multiple_qos_setup = [
1529         # Create QoS policy with payload rate of 23*10^6 Bytes/s
1530         ['settings', 'setValue', '_OVSDPDK_QOS_CIR', '23000000']
1531      ] + _OVSDPDK_QOS_set_qos_NIC0 + _OVSDPDK_QOS_set_qos_NIC1 + [
1532         ['trafficgen', 'send_traffic', {}],
1533         ['trafficgen', 'get_results'],
1534         ['tools', 'assert', _OVSDPDK_QOS_CHECK.format("-1", "0", "-1", "0")],
1535         # Create QoS policy with payload rate of 46*10^6 Bytes/s
1536         ['settings', 'setValue', '_OVSDPDK_QOS_CIR', '46000000']
1537      ] + _OVSDPDK_QOS_set_qos_NIC0 + _OVSDPDK_QOS_set_qos_NIC1 + [
1538         ['trafficgen', 'send_traffic', {}],
1539         ['trafficgen', 'get_results'],
1540         ['tools', 'assert', _OVSDPDK_QOS_CHECK.format("-1", "0", "-1", "0")],
1541         # Create QoS policy with payload rate of 92*10^6 Bytes/s
1542         ['settings', 'setValue', '_OVSDPDK_QOS_CIR', '92000000']
1543      ] + _OVSDPDK_QOS_set_qos_NIC0 + _OVSDPDK_QOS_set_qos_NIC1 + [
1544         ['trafficgen', 'send_traffic', {}],
1545         ['trafficgen', 'get_results'],
1546         ['tools', 'assert', _OVSDPDK_QOS_CHECK.format("-1", "0", "-1", "0")],
1547      ]
1548
1549 INTEGRATION_TESTS = INTEGRATION_TESTS + [
1550     {
1551         "Name": "ovsdpdk_qos_create_phy_port",
1552         "Deployment": "clean",
1553         "Description": "Ensure a QoS policy can be created on a physical DPDK port",
1554         "vSwitch": "OvsDpdkVhost",
1555         "TestSteps": [
1556                         ['vswitch', 'add_switch', 'int_br0'],
1557                         ['vswitch', 'add_phy_port', 'int_br0'],
1558                     ] + _OVSDPDK_QOS_set_qos
1559     },
1560     {
1561         "Name": "ovsdpdk_qos_delete_phy_port",
1562         "Deployment": "clean",
1563         "Description": "Ensure an existing QoS policy can be destroyed on a physical DPDK port.",
1564         "vSwitch": "OvsDpdkVhost",
1565         "TestSteps": [
1566                         ['vswitch', 'add_switch', 'int_br0'],
1567                         ['vswitch', 'add_phy_port', 'int_br0'],
1568                      ] + _OVSDPDK_QOS_set_qos + [
1569                         # Destroy the QoS policy and check the attributes
1570                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] -- destroy QoS #STEP[1][0] -- clear Port #STEP[1][0] qos'],
1571                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] -t ovs-vswitchd qos/show #STEP[1][0]', 'QoS not configured on #STEP[1][0]'],
1572                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1573                      ]
1574     },
1575     {
1576         "Name": "ovsdpdk_qos_create_vport",
1577         "Deployment": "clean",
1578         "Description": "Ensure a QoS policy can be created on a virtual vhost user port.",
1579         "vSwitch": "OvsDpdkVhost",
1580         "Parameters" : {
1581             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1582             "_OVSDPDK_QOS_PORT" : 'dpdkvhostuserclient',
1583         },
1584         "TestSteps": [
1585                         ['vswitch', 'add_switch', 'int_br0'],
1586                         ['vswitch', 'add_vport', 'int_br0'],
1587                     ] + _OVSDPDK_QOS_set_qos
1588     },
1589     {
1590         "Name": "ovsdpdk_qos_delete_vport",
1591         "Deployment": "clean",
1592         "Description": "Ensure an existing QoS policy can be destroyed on a vhost user port.",
1593         "vSwitch": "OvsDpdkVhost",
1594         "Parameters" : {
1595             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1596             "_OVSDPDK_QOS_PORT" : 'dpdkvhostuserclient',
1597         },
1598         "TestSteps": [
1599                         ['vswitch', 'add_switch', 'int_br0'],
1600                         ['vswitch', 'add_vport', 'int_br0'],
1601                      ] + _OVSDPDK_QOS_set_qos + [
1602                         # Destroy the QoS policy and check the attributes
1603                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] -- destroy QoS #STEP[1][0] -- clear Port #STEP[1][0] qos'],
1604                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] -t ovs-vswitchd qos/show #STEP[1][0]', 'QoS not configured on #STEP[1][0]'],
1605                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1606                      ]
1607     },
1608     {
1609         "Name": "ovsdpdk_qos_create_no_cir",
1610         "Deployment": "clean",
1611         "Description": "Ensure that a QoS policy cannot be created if the egress policer cir argument is missing.",
1612         "vSwitch": "OvsDpdkVhost",
1613         "Parameters" : {},
1614         "TestSteps": [
1615                          # Setup switch,port and logs
1616                         ['vswitch', 'add_switch', '$VSWITCH_BRIDGE_NAME'],
1617                         ['vswitch', 'add_vport', '$VSWITCH_BRIDGE_NAME'],
1618                         ['#LOG_MARK', 'tools', 'exec_shell',
1619                          'echo $((1+`wc -l $_OVSDPDK_VSWITCH_LOG | cut -d" " -f1`))', '(\d+)'],
1620
1621                         # Crete QoS policy and check the returned policy ID
1622                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set port #STEP[1][0] qos=@newqos -- '
1623                          '--id=@newqos create qos type=egress-policer other-config:cbs=2048',
1624                          '\w{8}-\w{4}-\w{4}-\w{4}-\w{12}'],
1625                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1626
1627                         # Check the OVS logs
1628                         ['tools', 'exec_shell', "sed -n '#STEP[LOG_MARK][0],$ p' $_OVSDPDK_VSWITCH_LOG",
1629                          'Failed to set QoS type egress-policer on port #STEP[1][0]: Invalid argument'],
1630                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1631
1632                         # Check the attributes for vhost0
1633                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] -t ovs-vswitchd qos/show #STEP[1][0]',
1634                          'QoS not configured on #STEP[1][0]'],
1635                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1636                     ]
1637     },
1638     {
1639         "Name": "ovsdpdk_qos_create_no_cbs",
1640         "Deployment": "clean",
1641         "Description": "Ensure that a QoS policy cannot be created if the egress policer cbs argument is missing.",
1642         "vSwitch": "OvsDpdkVhost",
1643         "Parameters" : {},
1644         "TestSteps": [
1645                          # Setup switch,port and logs
1646                         ['vswitch', 'add_switch', '$VSWITCH_BRIDGE_NAME'],
1647                         ['vswitch', 'add_vport', '$VSWITCH_BRIDGE_NAME'],
1648                         ['#LOG_MARK', 'tools', 'exec_shell',
1649                          'echo $((1+`wc -l $_OVSDPDK_VSWITCH_LOG | cut -d" " -f1`))', '(\d+)'],
1650
1651                         # Crete QoS policy and check the returned policy ID
1652                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-vsctl"] set port #STEP[1][0] qos=@newqos -- '
1653                          '--id=@newqos create qos type=egress-policer other-config:cir=1250000',
1654                          '\w{8}-\w{4}-\w{4}-\w{4}-\w{12}'],
1655                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1656
1657                         # Check the OVS logs
1658                         ['tools', 'exec_shell', "sed -n '#STEP[LOG_MARK][0],$ p' $_OVSDPDK_VSWITCH_LOG",
1659                          'Failed to set QoS type egress-policer on port #STEP[1][0]: Invalid argument'],
1660                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1661
1662                         # Check the attributes for vhost0
1663                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-appctl"] -t ovs-vswitchd qos/show #STEP[1][0]',
1664                          'QoS not configured on #STEP[1][0]'],
1665                         ['tools', 'assert', 'len(#STEP[-1])==1'],
1666                     ]
1667     },
1668     {
1669         "Name": "ovsdpdk_qos_p2p",
1670         "Deployment": "p2p",
1671         "Description": "In a p2p setup, ensure when a QoS egress policer is created that the traffic is limited to the specified rate.",
1672         "vSwitch": "OvsDpdkVhost",
1673         "Parameters" : {
1674             "TRAFFIC" : {
1675                 "traffic_type" : "rfc2544_continuous",
1676                 "frame_rate" : 100,
1677                 'bidir' : 'False',
1678             },
1679         },
1680         "TestSteps": _OVSDPDK_QOS_confirm_multiple_qos_setup
1681     },
1682     {
1683         "Name": "ovsdpdk_qos_pvp",
1684         "Deployment": "pvp",
1685         "Description": "In a pvp setup, ensure when a QoS egress policer is created that the traffic is limited to the specified rate.",
1686         "vSwitch": "OvsDpdkVhost",
1687         "VNF" : "QemuDpdkVhostUser",
1688         "Parameters" : {
1689             "_OVSDPDK_QOS_PORT" : 'dpdkvhostuserclient',
1690             "VSWITCH_VHOSTUSER_SERVER_MODE" : False,
1691             "TRAFFIC" : {
1692                 "traffic_type" : "rfc2544_continuous",
1693                 "frame_rate" : 100,
1694                 'bidir' : 'False',
1695             },
1696         },
1697         "TestSteps": _OVSDPDK_QOS_confirm_multiple_qos_setup
1698     },
1699     ############################################################
1700     #
1701     #  Custom statistics
1702     #
1703     ############################################################
1704     {
1705         "Name": "ovsdpdk_custstat_check",
1706         "Deployment": "clean",
1707         "Description": "Test if custom statistics are supported.",
1708         "vSwitch" : "OvsDpdkVhost",
1709         "TestSteps": [
1710                         # enable custom statistics
1711                         ['vswitch', 'add_switch', 'int_br0', [
1712                                                   'protocols=OpenFlow10,OpenFlow11,OpenFlow12,'
1713                                                   'OpenFlow13,OpenFlow14,OpenFlow15']],
1714                         ['#port', 'vswitch', 'add_phy_port', 'int_br0'],
1715                         # check that custom statistics are available for given interface
1716                         ['tools', 'exec_shell', 'sudo $TOOLS["ovs-ofctl"] -O OpenFlow14 '
1717                                                 'dump-ports int_br0 #STEP[port][1]',
1718                                                 '|CUSTOM Statistics'],
1719                         ['tools', 'assert', 'len(#STEP[-1])'],
1720                         ['vswitch', 'del_port', 'int_br0', '#STEP[port][0]'],
1721                         ['vswitch', 'del_switch', 'int_br0'],
1722                     ]
1723     },
1724     {
1725         "Name": "ovsdpdk_custstat_rx_error",
1726         "Deployment": "clean",
1727         "Description": "Test bad ethernet CRC counter 'rx_crc_errors' exposed by custom statistics.",
1728         "vSwitch" : "OvsDpdkVhost",
1729         "Parameters" : {
1730             "OVS_OFCTL_ARGS" : [],
1731             "TRAFFICGEN" : "IxNet",
1732             "TRAFFIC" : {
1733                 "traffic_type" : "rfc2544_continuous",
1734                 "frame_rate" : 10,
1735             },
1736             "TRAFFICGEN_DURATION" : 10,
1737             "TRAFFICGEN_IXNET_TCL_SCRIPT" : "ixnetrfc2544_bad_l2_crc.tcl",
1738         },
1739         "TestSteps": [
1740                         # enable custom statistics
1741                         ['vswitch', 'add_switch', 'int_br0', [
1742                                                   'protocols=OpenFlow10,OpenFlow11,OpenFlow12,'
1743                                                   'OpenFlow13,OpenFlow14,OpenFlow15']],
1744                         ['#port1', 'vswitch', 'add_phy_port', 'int_br0'],
1745                         ['#port2', 'vswitch', 'add_phy_port', 'int_br0'],
1746                         ['vswitch', 'add_flow', 'int_br0', {'in_port': '1', 'actions': ['output:2']}],
1747                         ['vswitch', 'add_flow', 'int_br0', {'in_port': '2', 'actions': ['output:1']}],
1748                         ['#crc_old', 'tools', 'exec_shell', 'sudo $TOOLS["ovs-ofctl"] -O OpenFlow14 '
1749                                               'dump-ports int_br0 #STEP[port1][1]',
1750                                               '|rx_crc_errors=(\d+)'],
1751                         # frames will be dropped by NIC, so we have to suppress send_traffic validation
1752                         # to avoid test failure
1753                         ['!trafficgen', 'send_traffic', {}],
1754                         # check that custom statistics are available for given interface
1755                         ['#crc_new', 'tools', 'exec_shell', 'sudo $TOOLS["ovs-ofctl"] -O OpenFlow14 '
1756                                               'dump-ports int_br0 #STEP[port1][1]',
1757                                               '|rx_crc_errors=(\d+)'],
1758                         ['tools', 'assert', '#STEP[crc_new] > #STEP[crc_old]'],
1759                         # tear down the environment
1760                         ['vswitch', 'dump_flows', 'int_br0'],
1761                         ['vswitch', 'del_flow', 'int_br0', {}],
1762                         ['vswitch', 'del_port', 'int_br0', '#STEP[port1][0]'],
1763                         ['vswitch', 'del_port', 'int_br0', '#STEP[port2][0]'],
1764                         ['vswitch', 'del_switch', 'int_br0'],
1765                     ]
1766     },
1767 ]