test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH v1 0/4] add cloud filter suite
@ 2016-04-22  1:31 Marvin Liu
  2016-04-22  1:31 ` [dts] [PATCH v1 1/4] test_plans: add test plan for cloud filter feature Marvin Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Marvin Liu @ 2016-04-22  1:31 UTC (permalink / raw)
  To: dts

VxLAN technology require that certain traffic directed to PF while cloud
network traffic directed to VF. XL710 support this feature for further
processing from virutal switch.

Marvin Liu (4):
  test_plans: add test plan for cloud filter feature
  dep vxlan: add variable for vxlan port
  framework pmd_output: add function to retrieve testpmd output
  tests cloud filter: add test suite for cloud filter

 dep/vxlan.py                          |   3 +-
 framework/pmd_output.py               |   3 +
 test_plans/cloud_filter_test_plan.rst | 291 ++++++++++++++++++++++++
 tests/TestSuite_cloud_filter.py       | 414 ++++++++++++++++++++++++++++++++++
 4 files changed, 710 insertions(+), 1 deletion(-)
 create mode 100644 test_plans/cloud_filter_test_plan.rst
 create mode 100644 tests/TestSuite_cloud_filter.py

-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dts] [PATCH v1 1/4] test_plans: add test plan for cloud filter feature
  2016-04-22  1:31 [dts] [PATCH v1 0/4] add cloud filter suite Marvin Liu
@ 2016-04-22  1:31 ` Marvin Liu
  2016-04-22  1:31 ` [dts] [PATCH v1 2/4] dep vxlan: add variable for vxlan port Marvin Liu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Marvin Liu @ 2016-04-22  1:31 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

Cloud filter feature allow XL710 support classify VxLan/Geneve packets
and put those into a specified queue in VF for further processing from
virtual switch.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/test_plans/cloud_filter_test_plan.rst b/test_plans/cloud_filter_test_plan.rst
new file mode 100644
index 0000000..14db87b
--- /dev/null
+++ b/test_plans/cloud_filter_test_plan.rst
@@ -0,0 +1,291 @@
+.. Copyright (c) <2016> Intel Corporation
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in
+     the documentation and/or other materials provided with the
+     distribution.
+
+   - Neither the name of Intel Corporation nor the names of its
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+   OF THE POSSIBILITY OF SUCH DAMAGE.
+         
+=====================================
+ Cloud filter support through Ethtool
+=====================================
+This feature based on X710 to classify VxLan/Geneve packets and put those into
+a specified queue in VF for further processing from virtual switch.
+
+Prerequisites
+=============
+Cloud filter feature based on latest i40e out of tree driver. Should also
+update ethtool and XL710 firmware.
+	Ethtool version: 3.18
+	i40e driver: i40e-1.5.13_rc1
+	Kernel version: 4.2.2
+	Xl710 DA2 firmware: 5.02 0x80002282
+
+BIOS setting:
+	Enable VT-d and VT-x
+Kernel command line:
+	Enable Intel IOMMU with below arguments
+	intel_iommu=on iommu=pt
+	
+Create two VFs from kernel driver:
+	echo 2 > /sys/bus/pci/devices/0000\:82\:00.0/sriov_numvfs
+	ifconfig $PF_INTF up
+
+Add vxlan network interface based on PF device:
+	ip li add vxlan0 type vxlan id 1 group 239.1.1.1 local 127.0.0.1 dev $PF_INTF 
+	ifconfig vxlan0 up
+
+Allocate hugepage for dpdk:
+	echo 4096 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages	
+
+Bound vf device to igb_uio driver and start testpmd with multiple queues:
+	cd dpdk
+	modprobe uio
+	insmod  ./x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
+	./tools/dpdk_nic_bind.py --bind=igb_uio 82:02.0 82:02.1
+	./x86_64-native-linuxapp-gcc/app/testpmd -c ffff -n 4 -- -i --rxq=4 --txq=4 --disable-rss
+	testpmd> set nbcore 8
+	testpmd> set fwd rxonly
+	testpmd> set verbose 1
+	testpmd> start
+
+
+Test case: cloud filter rule(inner ip)
+---------------------------------------
+1. Add cloud filter with inner ip address rule.
+Flow type ip4 mean this rule only match inner destination ip address.
+User define field higher 32bit is all 0xf mean vni id is not in the rule.
+Lower 32bit is 1 mean packet will be forwarded to VF1.
+Action 3 mean packet will be redirected to queue 3.
+
+	ethtool -N $PF_INTF flow-type ip4 dst-ip 192.168.1.1 user-def 0xffffffff00000001 action 3 loc 1
+
+2. Send vxlan packet with inner mac matched rule
+	Ether()/IP()/UDP()/Vxlan()/Ether()/IP(dst="192.168.1.1")/UDP()/Raw('x' * 20)
+
+3. verify packet received by queue3 of VF1, verify packet type is correct
+
+	testpmd> port 1/queue 3: received 1 packets
+    src=00:00:00:00:00:00 - dst=00:00:00:00:09:00 - type=0x0800 - length=106 - nb_segs=1 
+	- (outer) L2 type: ETHER - (outer) L3 type: IPV4_EXT_UNKNOWN - (outer) L4 type: Unknown 
+	- Tunnel type: GRENAT - Inner L2 type: ETHER - Inner L3 type: IPV4_EXT_UNKNOWN - Inner L4 type: UDP
+	- VXLAN packet: packet type =24721, Destination UDP port =8472, VNI = 1 - Receive queue=0x3
+	
+Test case: cloud filter rule(inner mac)
+---------------------------------------
+1. Add cloud filter with Inner mac rule.
+Dst mac mask ff:ff:ff:ff:ff:ff mean outer mac address is not in the rule.
+Src mac mask 00:00:00:00:00:00 mean inner mac address is in the rule.
+User define field higher 32bit is all 0xf mean vni id is not in the rule.
+Lower 32bit is 1 mean packet will be forwarded to VF1.
+Action 3 mean packet will be redirected to queue 3.
+
+	ethtool -N $PF_INTF flow-type ether dst 00:00:00:00:00:00 m \
+	ff:ff:ff:ff:ff:ff src 00:00:00:00:09:00 m 00:00:00:00:00:00 \
+	user-def 0xffffffff00000001 action 3 loc 1	
+	
+2. Send vxlan packet with inner mac matched rule
+	Ether()/IP()/UDP()/Vxlan()/Ether(dst="00:00:00:00:09:00")/IP()/TCP()/Raw('x' * 20)
+
+3. verify packet received by queue3 of VF1, verify packet type is correct
+
+	testpmd> port 1/queue 3: received 1 packets
+	src=00:00:00:00:00:00 - dst=00:00:00:00:09:00 - type=0x0800 - length=120 - nb_segs=1 
+	- (outer) L2 type: ETHER - (outer) L3 type: IPV4_EXT_UNKNOWN - (outer) L4 type: Unknown 
+	- Tunnel type: GRENAT - Inner L2 type: ETHER - Inner L3 type: IPV4_EXT_UNKNOWN - Inner L4 type: TCP
+	- VXLAN packet: packet type =24721, Destination UDP port =8472, VNI = 0 - Receive queue=0x3	
+
+Test case: cloud filter rule(inner mac + outer mac + vni)
+---------------------------------------------------------
+1. Add cloud filter with Inner mac + outer mac + vni rule.
+Dst mac mask 00:00:00:00:00:00 mean outer mac address is in the rule.
+Src mac mask 00:00:00:00:00:00 mean inner mac address is in the rule.
+User define field higher 32bit is 0x1 mean vni match 1 is in the rule.
+Lower 32bit is 1 mean packet will be forwarded to VF1.
+Action 3 mean packet will be redirected to queue 3.
+
+	ethtool -N $PF_INTF flow-type ether dst 00:00:00:00:10:00 m \
+	00:00:00:00:00:00 src 00:00:00:00:09:00 m 00:00:00:00:00:00 \
+	user-def 0x100000001 action 3 loc 1	
+	
+2. Send vxlan packet with inner mac match rule
+	Ether(dst="00:00:00:00:10:00")/IP()/UDP()/Vxlan(vni=1)/Ether(dst="00:00:00:00:09:00")/IP()/TCP()/Raw('x' * 20)
+
+3. verify packet received by queue3 of VF1, verify packet type is correct
+
+	testpmd> port 1/queue 3: received 1 packets
+	src=00:00:00:00:00:00 - dst=00:00:00:00:09:00 - type=0x0800 - length=120 - nb_segs=1 
+	- (outer) L2 type: ETHER - (outer) L3 type: IPV4_EXT_UNKNOWN - (outer) L4 type: Unknown 
+	- Tunnel type: GRENAT - Inner L2 type: ETHER - Inner L3 type: IPV4_EXT_UNKNOWN - Inner L4 type: TCP
+	- VXLAN packet: packet type =24721, Destination UDP port =8472, VNI = 0 - Receive queue=0x3	
+	
+Test case: cloud filter rule(inner mac + inner vlan + vni)
+---------------------------------------------------------
+1. Add cloud filter with Inner mac + inner vlan + vni rule.
+Dst mac mask ff:ff:ff:ff:ff:ff mean outer mac address is not in the rule.
+Src mac mask 00:00:00:00:00:00 mean inner mac address is in the rule.
+Vlan 1 mean vlan match is in the rule.
+User define field higher 32bit is 0x1 mean vni match 1 is in the rule.
+Lower 32bit is 1 mean packet will be forwarded to VF1.
+Action 3 mean packet will be redirected to queue 3.
+
+	ethtool -N $PF_INTF flow-type ether dst 00:00:00:00:00:00 m \
+	ff:ff:ff:ff:ff:ff src 00:00:00:00:09:00 m 00:00:00:00:00:00 \
+	vlan 1 user-def 0x100000001 action 3 loc 1	
+	
+2. Send vxlan packet with inner mac match rule
+	Ether()/IP()/UDP()/Vxlan(vni=1)/Ether(dst="00:00:00:00:09:00")/Dot1Q(vlan=1)/IP()/TCP()/Raw('x' * 20)
+
+3. verify packet received by queue3 of VF1, verify packet type is correct
+
+	testpmd> port 1/queue 3: received 1 packets
+	src=00:00:00:00:00:00 - dst=00:00:00:00:09:00 - type=0x0800 - length=124 - nb_segs=1
+	- (outer) L2 type: ETHER - (outer) L3 type: IPV4_EXT_UNKNOWN - (outer) L4 type: Unknown
+	- Tunnel type: GRENAT - Inner L2 type: ETHER_VLAN - Inner L3 type: IPV4_EXT_UNKNOWN - Inner L4 type: TCP
+	- VXLAN packet: packet type =24721, Destination UDP port =8472, VNI = 1 - Receive queue=0x3
+
+Test case: cloud filter rule(inner mac + inner vlan)
+---------------------------------------------------------
+1. Add cloud filter with Inner mac + inner vlan rule.
+Dst mac mask ff:ff:ff:ff:ff:ff mean outer mac address is not in the rule.
+Src mac mask 00:00:00:00:00:00 mean inner mac address is in the rule.
+Vlan 1 mean vlan match is in the rule.
+User define field higher 32bit is all 0xf mean vni id is not in the rule.
+Lower 32bit is 1 mean packet will be forwarded to VF1.
+Action 3 mean packet will be redirected to queue 3.
+
+	ethtool -N $PF_INTF flow-type ether dst 00:00:00:00:00:00 m \
+	ff:ff:ff:ff:ff:ff src 00:00:00:00:09:00 m 00:00:00:00:00:00 \
+	vlan 1 user-def 0xffffffff00000001 action 3 loc 1	
+	
+2. Send vxlan packet with inner mac match rule
+	Ether()/IP()/UDP()/Vxlan(vni=1)/Ether(dst="00:00:00:00:09:00")/Dot1Q(vlan=1)/IP()/TCP()/Raw('x' * 20)
+
+3. verify packet received by queue3 of VF1, verify packet type is correct
+
+	testpmd> port 1/queue 3: received 1 packets
+	src=00:00:00:00:00:00 - dst=00:00:00:00:09:00 - type=0x0800 - length=124 - nb_segs=1
+	- (outer) L2 type: ETHER - (outer) L3 type: IPV4_EXT_UNKNOWN - (outer) L4 type: Unknown
+	- Tunnel type: GRENAT - Inner L2 type: ETHER_VLAN - Inner L3 type: IPV4_EXT_UNKNOWN - Inner L4 type: TCP
+	- VXLAN packet: packet type =24721, Destination UDP port =8472, VNI = 1 - Receive queue=0x3	
+
+Test case: Remove cloud filter rule 
+-----------------------------------
+Remove cloud filter rule in location 1.
+	ethtool -N $PF_INTF delete 1
+Dump rule and check there's no rule listed.
+	ethtool -n $PF_INTF
+	Total 0 rules
+Send packet match last rule.
+	Ether(dst not match PF&VF)/IP()/UDP()/Vxlan(vni=1)/Ether(dst="00:00:00:00:09:00")/Dot1Q(vlan=1)/IP()/TCP()/Raw('x' * 20)
+Check packet only received on PF device.
+
+Test case: Multiple cloud filter rules
+--------------------------------------
+1. Add cloud filter with Inner mac + inner vlan rule.
+Dst mac mask ff:ff:ff:ff:ff:ff mean outer mac address is not in the rule.
+Src mac mask 00:00:00:00:00:00 mean inner mac address is in the rule.
+Vlan 1 mean vlan match is in the rule.
+User define field higher 32bit is all 0xf mean vni id is not in the rule.
+Lower 32bit is 1 mean packet will be forwarded to VF1.
+Action 3 mean packet will be redirected to queue 3.
+
+	ethtool -N $PF_INTF flow-type ether dst 00:00:00:00:00:00 m \
+	ff:ff:ff:ff:ff:ff src 00:00:00:00:09:00 m 00:00:00:00:00:00 \
+	vlan 1 user-def 0xffffffff00000001 action 3 loc 1
+	
+2. Add another cloud filter with Inner mac + inner vlan rule.
+Dst mac mask ff:ff:ff:ff:ff:ff mean outer mac address is not in the rule.
+Src mac mask 00:00:00:00:00:00 mean inner mac address is in the rule.
+Vlan 2 mean vlan match is in the rule.
+User define field higher 32bit is all 0xf mean vni id is not in the rule.
+Lower 32bit is 0 mean packet will be forwarded to VF0.
+Action 3 mean packet will be redirected to queue 3.
+Locate 2 mean this rule will be added to index 2.
+
+	ethtool -N $PF_INTF flow-type ether dst 00:00:00:00:00:00 m \
+	ff:ff:ff:ff:ff:ff src 00:00:00:00:10:00 m 00:00:00:00:00:00 \
+	vlan 2 user-def 0xffffffff00000000 action 0 loc 2
+
+3. Dump cloud filter rules
+	ethtool -n $PF_INTF
+	64 RX rings available
+	Total 2 rules
+
+4. Send packet match rule 1
+	Ether()/IP()/UDP()/Vxlan(vni=1)/Ether(dst="00:00:00:00:09:00")/Dot1Q(vlan=1)/IP()/TCP()/Raw('x' * 20)
+
+5. verify packet received by queue3 of VF1, verify packet type is correct
+	testpmd> port 1/queue 3: received 1 packets
+	src=00:00:00:00:00:00 - dst=00:00:00:00:09:00 - type=0x0800 - length=124 - nb_segs=1 
+	- (outer) L2 type: ETHER - (outer) L3 type: IPV4_EXT_UNKNOWN - (outer) L4 type: Unknown 
+	- Tunnel type: GRENAT - Inner L2 type: ETHER_VLAN - Inner L3 type: IPV4_EXT_UNKNOWN - Inner L4 type: TCP
+	- VXLAN packet: packet type =24721, Destination UDP port =8472, VNI = 1 - Receive queue=0x3
+
+6. Send packet match rule 2
+	Ether()/IP()/UDP()/Vxlan(vni=1)/Ether(dst="00:00:00:00:10:00")/Dot1Q(vlan=2)/IP()/TCP()/Raw('x' * 20)
+
+7. verify packet received by queue3 of VF0, verify packet type is correct
+	testpmd> port 0/queue 3: received 1 packets
+	src=00:00:00:00:00:00 - dst=00:00:00:00:09:00 - type=0x0800 - length=124 - nb_segs=1
+	- (outer) L2 type: ETHER - (outer) L3 type: IPV4_EXT_UNKNOWN - (outer) L4 type: Unknown - Tunnel type: GRENAT
+	- Inner L2 type: ETHER_VLAN - Inner L3 type: IPV4_EXT_UNKNOWN - Inner L4 type: TCP
+	- VXLAN packet: packet type =24721, Destination UDP port =8472, VNI = 1 - Receive queue=0x3
+
+Test case: Bifurcated between kernel VF and dpdk VF
+---------------------------------------------------
+1. Add cloud filter with inner ip address rule.
+Flow type ip4 mean this rule only match inner destination ip address.
+User define field higher 32bit is all 0xf mean vni id is not in the rule.
+Lower 32bit is 1 mean packet will be forwarded to VF1.
+Action 3 mean packet will be redirected to queue 3.
+
+	ethtool -N $PF_INTF flow-type ip4 dst-ip 192.168.1.1 user-def 0xffffffff00000001 action 3 loc 1
+
+2. Add cloud filter with inner ip address rule.
+Flow type ip4 mean this rule only match inner destination ip address.
+User define field higher 32bit is all 0xf mean vni id is not in the rule.
+Lower 32bit is 0 mean packet will be forwarded to VF0.
+Action 0 mean packet will be redirected to queue 0.
+
+	ethtool -N $PF_INTF flow-type ip4 dst-ip 192.168.2.1 user-def 0xffffffff00000000 action 0 loc 2
+
+3. Send vxlan packet which matched first rule
+	Ether()/IP()/UDP()/Vxlan()/Ether()/IP(dst="192.168.1.1")/UDP()/Raw('x' * 20)
+	
+4. verify packet received by queue3 of VF1, verify packet type is correct
+
+	testpmd> port 1/queue 3: received 1 packets
+    src=00:00:00:00:00:00 - dst=00:00:00:00:09:00 - type=0x0800 - length=106 - nb_segs=1 
+	- (outer) L2 type: ETHER - (outer) L3 type: IPV4_EXT_UNKNOWN - (outer) L4 type: Unknown 
+	- Tunnel type: GRENAT - Inner L2 type: ETHER - Inner L3 type: IPV4_EXT_UNKNOWN - Inner L4 type: UDP
+	- VXLAN packet: packet type =24721, Destination UDP port =8472, VNI = 1 - Receive queue=0x3
+
+5. Send vxlan packet which matched second rule
+	Ether()/IP()/UDP()/Vxlan()/Ether()/IP(dst="192.168.2.1")/UDP()/Raw('x' * 20)
+	
+6. verify packet received by VF0, verify packet content is correct
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dts] [PATCH v1 2/4] dep vxlan: add variable for vxlan port
  2016-04-22  1:31 [dts] [PATCH v1 0/4] add cloud filter suite Marvin Liu
  2016-04-22  1:31 ` [dts] [PATCH v1 1/4] test_plans: add test plan for cloud filter feature Marvin Liu
@ 2016-04-22  1:31 ` Marvin Liu
  2016-04-22  1:32 ` [dts] [PATCH v1 3/4] framework pmd_output: add function to retrieve testpmd output Marvin Liu
  2016-04-22  1:32 ` [dts] [PATCH v1 4/4] tests cloud filter: add test suite for cloud filter Marvin Liu
  3 siblings, 0 replies; 5+ messages in thread
From: Marvin Liu @ 2016-04-22  1:31 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

Add this variable for related suites can retrieve this value.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/dep/vxlan.py b/dep/vxlan.py
index e50d4b4..8fc914b 100644
--- a/dep/vxlan.py
+++ b/dep/vxlan.py
@@ -11,6 +11,7 @@ from scapy.layers.l2 import Ether
 
 vxlanmagic = "0x8"
 
+VXLAN_PORT=4789
 
 class Vxlan(Packet):
     name = "Virtual eXtensible Local Area Network"
@@ -29,5 +30,5 @@ class Vxlan(Packet):
         return self.sprintf("VXLAN (vni=%VXLAN.vni%)")
 
 split_layers(UDP, DNS, sport=53)
-bind_layers(UDP, Vxlan, dport=4789)
+bind_layers(UDP, Vxlan, dport=VXLAN_PORT)
 bind_layers(Vxlan, Ether)
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dts] [PATCH v1 3/4] framework pmd_output: add function to retrieve testpmd output
  2016-04-22  1:31 [dts] [PATCH v1 0/4] add cloud filter suite Marvin Liu
  2016-04-22  1:31 ` [dts] [PATCH v1 1/4] test_plans: add test plan for cloud filter feature Marvin Liu
  2016-04-22  1:31 ` [dts] [PATCH v1 2/4] dep vxlan: add variable for vxlan port Marvin Liu
@ 2016-04-22  1:32 ` Marvin Liu
  2016-04-22  1:32 ` [dts] [PATCH v1 4/4] tests cloud filter: add test suite for cloud filter Marvin Liu
  3 siblings, 0 replies; 5+ messages in thread
From: Marvin Liu @ 2016-04-22  1:32 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/pmd_output.py b/framework/pmd_output.py
index df8db12..f8e6088 100644
--- a/framework/pmd_output.py
+++ b/framework/pmd_output.py
@@ -122,6 +122,9 @@ class PmdOutput():
         return self.dut.send_expect('%s' % pmd_cmd, expected, timeout=timeout,
                                     alt_session=alt_session)
 
+    def get_output(self, timeout=1):
+        return self.dut.get_session_output(timeout=timeout)
+
     def get_value_from_string(self, key_str, regx_str, string):
         """
         Get some values from the given string by the regular expression.
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dts] [PATCH v1 4/4] tests cloud filter: add test suite for cloud filter
  2016-04-22  1:31 [dts] [PATCH v1 0/4] add cloud filter suite Marvin Liu
                   ` (2 preceding siblings ...)
  2016-04-22  1:32 ` [dts] [PATCH v1 3/4] framework pmd_output: add function to retrieve testpmd output Marvin Liu
@ 2016-04-22  1:32 ` Marvin Liu
  3 siblings, 0 replies; 5+ messages in thread
From: Marvin Liu @ 2016-04-22  1:32 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

This suite include two cases:
test_cloud_filter will validate cloud filter offload of XL710.
test_bifurcated_driver will validate dpdk and kernel driver can cowork
with cloud filter rules.

Cloud filter required special i40e driver and kernel version, more
details please reference to test plan.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/tests/TestSuite_cloud_filter.py b/tests/TestSuite_cloud_filter.py
new file mode 100644
index 0000000..6480bbe
--- /dev/null
+++ b/tests/TestSuite_cloud_filter.py
@@ -0,0 +1,414 @@
+"""
+DPDK Test suite.
+
+Test IPv4 fragmentation features in DPDK.
+
+"""
+
+import dts
+import string
+import re
+import time
+import os
+from test_case import TestCase
+from pmd_output import PmdOutput
+from settings import HEADER_SIZE
+from packet import Packet, load_pcapfile
+
+from scapy.layers.inet import UDP, IP
+from scapy.packet import split_layers, bind_layers
+
+from vxlan import Vxlan
+from vxlan import VXLAN_PORT
+
+CLOUD_PORT = 8472
+split_layers(UDP, Vxlan, dport=VXLAN_PORT)
+bind_layers(UDP, Vxlan, dport=CLOUD_PORT)
+
+#
+#
+# Test class.
+#
+
+
+class CloudFilterConfig(object):
+
+    """
+    Module for config/verify cloud filter rule
+    """
+
+    RULE_TYPE = [
+        'iip', 'imac', 'omac+imac+vni', 'imac+ivlan+vni', 'imac+ivlan']
+
+    def __init__(self, test_case, pf_intf=""):
+        self.case = test_case
+        # make sure pf existed
+        out = self.case.dut.send_expect(
+            'ifconfig %s' % pf_intf, "#", alt_session=True)
+        self.case.verify("Device not found" not in out,
+                         "Cloud filter need PF interface!!!")
+        self.pf_intf = pf_intf
+        self.pkt = Packet()
+
+    def config_rule(self, **kwargs):
+        """
+        Configure cloud filter rule settings, must check rule format
+        """
+        self.rule_idx = 1
+        self.case.verify(
+            'type' in kwargs, "Cloud filter rule must configure filter type")
+        rule_type = kwargs['type']
+        self.case.verify(
+            rule_type in self.RULE_TYPE, "Cloud filter rule type not correct")
+        self.case.verify(
+            'vf' in kwargs, "Cloud filter rule must configure device!!!")
+        self.case.verify(
+            'queue' in kwargs, "Cloud filter rule must configure queue index")
+        if 'loc' in kwargs:
+            self.rule_idx = kwargs['loc']
+
+        self.cf_rule = {}
+        self.cf_rule['type'] = rule_type
+        self.cf_rule['vf'] = kwargs['vf']
+        self.cf_rule['queue'] = kwargs['queue']
+
+        required_args = rule_type.split('+')
+        for required_arg in required_args:
+            self.case.verify(required_arg in kwargs,
+                             "Argument for [%s] missing!!!" % required_arg)
+            self.cf_rule[required_arg] = kwargs[required_arg]
+
+        if 'ivlan' in self.cf_rule:
+            self.pkt.assign_layers(['ether', 'ipv4', 'udp',
+                                    'vxlan', 'inner_mac', 'inner_vlan',
+                                    'inner_ipv4', 'inner_tcp', 'raw'])
+        else:
+            self.pkt.assign_layers(['ether', 'ipv4', 'udp',
+                                    'vxlan', 'inner_mac',
+                                    'inner_ipv4', 'inner_tcp', 'raw'])
+
+    def ethtool_add(self):
+        """
+        Add cloud filter rule by ethtool and return rule index
+        """
+        ip_fmt = "ethtool -N %(PF)s flow-type ip4 dst-ip %(IP)s user-def " + \
+            "%(VNI_VF)s action %(QUEUE)d loc %(ID)d"
+        ether_fmt = "ethtool -N %(PF)s flow-type ether dst %(OMAC)s m " + \
+            "%(OMASK)s src %(IMAC)s m %(IMASK)s user-def %(VNI_VF)s " + \
+            "action %(QUEUE)d loc %(ID)d"
+
+        # generate user define field
+        vni_vf = '0x'
+        if 'vni' in self.cf_rule:
+            vni_str = hex(self.cf_rule['vni'])[2:]
+        else:
+            vni_str = 'ffffffff'  # without vni
+        vni_vf += vni_str
+        vf_str = "%08x" % self.cf_rule['vf']
+        vni_vf += vf_str
+
+        if 'omac' in self.cf_rule:
+            omac_str = self.cf_rule['omac']
+            omac_mask = '00:00:00:00:00:00'
+        else:
+            omac_str = '00:00:00:00:00:00'
+            omac_mask = 'ff:ff:ff:ff:ff:ff'
+
+        if 'imac' in self.cf_rule:
+            imac_str = self.cf_rule['imac']
+            imac_mask = '00:00:00:00:00:00'
+        else:
+            imac_str = '00:00:00:00:00:00'
+            imac_mask = 'ff:ff:ff:ff:ff:ff'
+
+        if 'iip' in self.cf_rule:
+            ip_str = self.cf_rule['iip']
+
+        if self.cf_rule['type'] == 'iip':
+            ethtool_cmd = ip_fmt % {'PF': self.pf_intf,
+                                    'IP': ip_str,
+                                    'VNI_VF': vni_vf,
+                                    'QUEUE': self.cf_rule['queue'],
+                                    'ID': self.rule_idx}
+        else:
+            ethtool_cmd = ether_fmt % {'PF': self.pf_intf,
+                                       'OMAC': omac_str,
+                                       'OMASK': omac_mask,
+                                       'IMAC': imac_str,
+                                       'IMASK': imac_mask,
+                                       'VNI_VF': vni_vf,
+                                       'QUEUE': self.cf_rule['queue'],
+                                       'ID': self.rule_idx}
+
+        print ethtool_cmd
+        out = self.case.dut.send_expect(ethtool_cmd, "# ", alt_session=True)
+        self.case.verify("ethtool" not in out, "Add cloud filter failed!!!")
+
+        return self.rule_idx
+
+    def ethtool_delete(self):
+        """
+        Delete cloud filter rule by index and return whether success
+        """
+        self.case.dut.send_expect("ethtool -N %s delete %d" % (self.pf_intf,
+                                                               self.rule_idx),
+                                  "# ", alt_session=True)
+
+    def ethtool_dumprule(self):
+        """
+        Dump cloud filter rule according to index value
+        """
+        pass
+
+    def transmit_packet(self, match=True):
+        """
+        Send packet match or not matched cloud filter rules
+        """
+        if match:
+            if 'iip' in self.cf_rule.keys():
+                self.pkt.config_layer(
+                    'inner_ipv4', {'dst': self.cf_rule['iip']})
+            if 'imac' in self.cf_rule.keys():
+                self.pkt.config_layer(
+                    'inner_mac', {'dst': self.cf_rule['imac']})
+            if 'omac' in self.cf_rule.keys():
+                self.pkt.config_layer('ether', {'dst': self.cf_rule['omac']})
+            if 'ivlan' in self.cf_rule.keys():
+                self.pkt.config_layer(
+                    'inner_vlan', {'vlan': self.cf_rule['ivlan']})
+            if 'vni' in self.cf_rule.keys():
+                self.pkt.config_layer('vxlan', {'vni': self.cf_rule['vni']})
+
+        self.pkt.config_layer('raw', {'payload': ['01'] * 18})
+        self.pkt.send_pkt(tx_port=self.case.tester_intf)
+
+
+class TestCloudFilter(TestCase):
+
+    def set_up_all(self):
+        """
+        vxlan Prerequisites
+        """
+        # this feature only enable in FVL now
+        self.verify(self.nic in ["fortville_eagle", "fortville_spirit",
+                                 "fortville_spirit_single"],
+                    "Cloud filter only supported by Fortville")
+        # Based on h/w type, choose how many ports to use
+        self.dut_ports = self.dut.get_ports()
+
+        # Verify that enough ports are available
+        self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
+
+        # required setting test environment
+        self.env_done = False
+        self.vf_queues = 4
+
+    def setup_vf_env(self):
+        """
+        Create testing environment with 2VFs generated from PF
+        """
+        if self.env_done:
+            return
+
+        # get PF interface name and opposite tester interface name
+        self.pf_port = self.dut_ports[0]
+        self.bind_nics_driver([self.pf_port], driver="i40e")
+        self.pf_intf = self.dut.ports_info[self.pf_port]['intf']
+        tester_port = self.tester.get_local_port(self.pf_port)
+        self.tester_intf = self.tester.get_interface(tester_port)
+        pf_numa = self.dut.get_numa_id(self.pf_port)
+
+        self.dut.generate_sriov_vfs_by_port(self.pf_port, 2, driver="default")
+
+        # enable vxlan on PF
+        self.dut.send_expect("ip li add vxlan0 type vxlan id 1 group " +
+                             "239.1.1.1 local 127.0.0.1 dev %s" % self.pf_intf,
+                             "# ")
+        self.dut.send_expect("ifconfig vxlan0 up", "# ")
+
+        self.vf_port0 = self.dut.ports_info[self.pf_port]['vfs_port'][0]
+        self.vf_port1 = self.dut.ports_info[self.pf_port]['vfs_port'][1]
+
+        # bind one vf device to dpdk
+        self.vf_port0.bind_driver(driver='igb_uio')
+        self.vf_intf = self.vf_port0.intf_name
+        self.vf_port1.bind_driver(driver='i40evf')
+
+        # bind vf0 to igb_uio and start testpmd
+        core_num = self.vf_queues + 1
+        cores = "1S/%dC/1T" % core_num
+
+        self.pmdout = PmdOutput(self.dut)
+        self.pmdout.start_testpmd(
+            cores, "--rxq=%d --txq=%d --portmask=0x1" %
+            (self.vf_queues, self.vf_queues), socket=pf_numa)
+
+        # rxonly and verbose enabled
+        self.pmdout.execute_cmd("set nbcore %d" % self.vf_queues)
+        self.pmdout.execute_cmd("set fwd rxonly")
+        self.pmdout.execute_cmd("set verbose 1")
+        self.pmdout.execute_cmd("start")
+
+        self.env_done = True
+
+    def destroy_vf_env(self):
+
+        if getattr(self, 'pmd_output', None):
+            self.dut.kill_all()
+
+        if getattr(self, 'pf_port', None):
+            self.dut.destroy_sriov_vfs_by_port(self.pf_port)
+            self.bind_nics_driver([self.pf_port], driver="igb_uio")
+
+        self.env_done = False
+
+    def bind_nics_driver(self, ports, driver=""):
+        # modprobe vfio driver
+        if driver == "vfio-pci":
+            for port in ports:
+                netdev = self.dut.ports_info[port]['port']
+                driver = netdev.get_nic_driver()
+                if driver != 'vfio-pci':
+                    netdev.bind_driver(driver='vfio-pci')
+
+        elif driver == "igb_uio":
+            # igb_uio should insmod as default, no need to check
+            for port in ports:
+                netdev = self.dut.ports_info[port]['port']
+                driver = netdev.get_nic_driver()
+                if driver != 'igb_uio':
+                    netdev.bind_driver(driver='igb_uio')
+        else:
+            for port in ports:
+                netdev = self.dut.ports_info[port]['port']
+                driver_now = netdev.get_nic_driver()
+                if driver == "":
+                    driver = netdev.default_driver
+                if driver != driver_now:
+                    netdev.bind_driver(driver=driver)
+
+    def send_and_verify(self, cloud_cfg=None, dpdk=True):
+        """
+        Send packet match cloud filter rule and verify packet received
+        """
+        if dpdk:
+            cloud_cfg.transmit_packet()
+            out = self.pmdout.get_output()
+            queue = cloud_cfg.cf_rule['queue']
+            self.verify("queue %d" %
+                        queue in out, "Vxlan not received in queue %d" % queue)
+            self.verify("VXLAN packet" in out, "Vxlan packet not detected")
+            self.verify("Inner L4 type: TCP" in out,
+                        "Vxlan inner L4 type not detected")
+            if 'vni' in cloud_cfg.cf_rule.keys():
+                vni = cloud_cfg.cf_rule['vni']
+                self.verify("VNI = %d" %
+                            vni in out, "Vxlan vni value not correct")
+            if 'ivlan' in cloud_cfg.cf_rule.keys():
+                self.verify("Inner L2 type: ETHER_VLAN" in out,
+                            "Vxlan inner vlan not detected")
+        else:
+            # packet recevied on dut VF device
+            tmp_file = '/tmp/cloud_filter_%s.pcap' % self.vf_intf
+            sniff_cmd = ('tcpdump -w ' + tmp_file +
+                         ' -i {0} 2>tcpdump_{0}.out &').format(self.vf_intf)
+            rm_cmd = 'rm -f ' + tmp_file
+            self.dut.send_expect(rm_cmd, '#', alt_session=True)
+            self.dut.send_expect(sniff_cmd, '#', alt_session=True)
+            # wait for interface promisc enable
+            time.sleep(2)
+            cloud_cfg.transmit_packet()
+            self.dut.send_expect('killall tcpdump', '#', alt_session=True)
+            # wait for pcap file saved
+            time.sleep(2)
+            # copy pcap to tester and then analyze
+            self.dut.session.copy_file_from(tmp_file)
+            pkts = load_pcapfile(
+                filename="cloud_filter_%s.pcap" % self.vf_intf)
+            self.verify(
+                len(pkts) == 1, "%d packet recevied on kernel VF" % len(pkts))
+            cap_pkt = pkts[0].pktgen.pkt
+            try:
+                dport = cap_pkt[UDP].dport
+                self.verify(dport == CLOUD_PORT,
+                            "Captured packet is not vxlan packet")
+                inner_ip = cap_pkt[Vxlan][IP].dst
+                self.verify(inner_ip == cloud_cfg.cf_rule['iip'],
+                            "Inner ip not matched")
+            except:
+                print "Kernel VF captured packet not match rule"
+                raise
+
+    def test_cloud_filter(self):
+        """
+        Verify dpdk work with linux driver added cloud filter rule
+        """
+        # setting for cloud filter rule
+        queue = self.vf_queues - 1
+        vni = 1
+        vlan = 1
+        # add cloud filter rule
+        rules = [
+            {'type': 'iip', 'iip': '192.168.1.1',
+             'vf': 0, 'queue': queue, 'loc': 1},
+            {'type': 'imac', 'imac': '00:00:00:00:09:00',
+             'vf': 0, 'queue': queue, 'loc': 1},
+            {'type': 'omac+imac+vni', 'omac': '00:00:00:00:10:00',
+             'imac': '00:00:00:00:09:00', 'vni': vni, 'vf': 0, 'queue': queue,
+             'loc': 1},
+            {'type': 'imac+ivlan+vni', 'imac': '00:00:00:00:09:00',
+             'ivlan': vlan, 'vni': vni, 'vf': 0, 'queue': queue, 'loc': 1},
+            {'type': 'imac+ivlan', 'imac': '00:00:00:00:09:00',
+             'ivlan': vlan, 'vf': 0, 'queue': queue, 'loc': 1},
+        ]
+        cf_cfg = CloudFilterConfig(self, self.pf_intf)
+        for rule in rules:
+            cf_cfg.config_rule(**rule)
+            cf_cfg.ethtool_add()
+
+            self.send_and_verify(cf_cfg)
+
+            cf_cfg.ethtool_delete()
+
+    def test_bifurcated_driver(self):
+        """
+        Verify bifurcated driver work with dpdk VF and kernel VF
+        """
+        rules = [
+            {'type': 'iip', 'iip': '192.168.1.1', 'vf': 0,
+             'queue': self.vf_queues - 1, 'loc': 1},
+            {'type': 'iip', 'iip': '192.168.2.1', 'vf': 1, 'queue': 0,
+             'loc': 2}]
+
+        dpdk_cfg = CloudFilterConfig(self, self.pf_intf)
+        # fdir rule for dpdk VF
+        dpdk_cfg.config_rule(**rules[0])
+        dpdk_cfg.ethtool_add()
+        self.send_and_verify(dpdk_cfg)
+        # fdir rule for kernel VF
+        kernel_cfg = CloudFilterConfig(self, self.pf_intf)
+        kernel_cfg.config_rule(**rules[1])
+        kernel_cfg.ethtool_add()
+        self.send_and_verify(kernel_cfg, dpdk=False)
+
+        pass
+
+    def set_up(self):
+        """
+        Run before each test case.
+        """
+        self.setup_vf_env()
+        pass
+
+    def tear_down(self):
+        """
+        Run after each test case.
+        """
+        pass
+
+    def tear_down_all(self):
+        """
+        Run after each test suite.
+        """
+        self.destroy_vf_env()
+        pass
-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-22  1:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-22  1:31 [dts] [PATCH v1 0/4] add cloud filter suite Marvin Liu
2016-04-22  1:31 ` [dts] [PATCH v1 1/4] test_plans: add test plan for cloud filter feature Marvin Liu
2016-04-22  1:31 ` [dts] [PATCH v1 2/4] dep vxlan: add variable for vxlan port Marvin Liu
2016-04-22  1:32 ` [dts] [PATCH v1 3/4] framework pmd_output: add function to retrieve testpmd output Marvin Liu
2016-04-22  1:32 ` [dts] [PATCH v1 4/4] tests cloud filter: add test suite for cloud filter Marvin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).