From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 3E84258C3 for ; Mon, 1 Jun 2015 11:23:07 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 01 Jun 2015 02:23:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,531,1427785200"; d="scan'208";a="738611512" Received: from pgsmsx101.gar.corp.intel.com ([10.221.44.78]) by orsmga002.jf.intel.com with ESMTP; 01 Jun 2015 02:23:05 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by PGSMSX101.gar.corp.intel.com (10.221.44.78) with Microsoft SMTP Server (TLS) id 14.3.224.2; Mon, 1 Jun 2015 17:23:02 +0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.23]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.180]) with mapi id 14.03.0224.002; Mon, 1 Jun 2015 17:23:00 +0800 From: "Liu, Yong" To: "Fu, JingguoX" , "dts@dpdk.org" Thread-Topic: [dts] [DTS][PATCH 1/2] pmd rss reta: add rss reta suite Thread-Index: AQHQmeyBow9eKVigIEaU4z08ci5QP52XZTbg Date: Mon, 1 Jun 2015 09:23:00 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E10E3683E@SHSMSX103.ccr.corp.intel.com> References: <1432889398-25470-1-git-send-email-jingguox.fu@intel.com> In-Reply-To: <1432889398-25470-1-git-send-email-jingguox.fu@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "Fu, JingguoX" Subject: Re: [dts] [DTS][PATCH 1/2] pmd rss reta: add rss reta suite X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jun 2015 09:23:08 -0000 Thanks, applied in 1.1 branch. > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Jingguo Fu > Sent: Friday, May 29, 2015 4:50 PM > To: dts@dpdk.org > Cc: Fu, JingguoX > Subject: [dts] [DTS][PATCH 1/2] pmd rss reta: add rss reta suite >=20 > Signed-off-by: Jingguo Fu > --- > tests/TestSuite_pmdrssreta.py | 255 > ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 255 insertions(+) > create mode 100644 tests/TestSuite_pmdrssreta.py >=20 > diff --git a/tests/TestSuite_pmdrssreta.py b/tests/TestSuite_pmdrssreta.p= y > new file mode 100644 > index 0000000..60f340d > --- /dev/null > +++ b/tests/TestSuite_pmdrssreta.py > @@ -0,0 +1,255 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. > +# 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. > + > +""" > +DPDK Test suite. > +Test RSS reta (redirection table) update function. > +""" > +import time > +import random > +import re > +import dts > +testQueues =3D [16] > +reta_entries =3D [] > +reta_lines =3D [] > + > +# Use scapy to send packets with different source and dest ip. > +# and collect the hash result of five tuple and the queue id. > +from test_case import TestCase > +from pmd_output import PmdOutput > +# > +# > +# Test class. > +# > +class TestPmdrssreta(TestCase): > + # > + # > + # Utility methods and other non-test code. > + # > + def send_packet(self, itf, tran_type): > + """ > + Sends packets. > + """ > + global reta_lines > + > + self.tester.scapy_foreground() > + self.tester.scapy_append('sys.path.append("./")') > + self.tester.scapy_append('from sctp import *') > + self.dut.send_expect("start", "testpmd>") > + mac =3D self.dut.get_mac_address(0) > + # send packet with different source and dest ip > + if tran_type =3D=3D "IPV4": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.= 0.%d", > dst=3D"192.168.0.%d")], iface=3D"%s")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "IPV4&TCP": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.= 0.%d", > dst=3D"192.168.0.%d")/TCP(sport=3D1024,dport=3D1024)], iface=3D"%s")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "IPV4&UDP": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.= 0.%d", > dst=3D"192.168.0.%d")/UDP(sport=3D1024,dport=3D1024)], iface=3D"%s")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "IPV6": > + for i in range(16): > + packet =3D > r'sendp([Ether(dst=3D"%s")/IPv6(src=3D"3ffe:2501:200:1fff::%d", > dst=3D"3ffe:2501:200:3::%d")], iface=3D"%s")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "IPV6&TCP": > + for i in range(16): > + packet =3D > r'sendp([Ether(dst=3D"%s")/IPv6(src=3D"3ffe:2501:200:1fff::%d", > dst=3D"3ffe:2501:200:3::%d")/TCP(sport=3D1024,dport=3D1024)], iface=3D"%s= ")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "IPV6&UDP": > + for i in range(16): > + packet =3D > r'sendp([Ether(dst=3D"%s")/IPv6(src=3D"3ffe:2501:200:1fff::%d", > dst=3D"3ffe:2501:200:3::%d")/UDP(sport=3D1024,dport=3D1024)], iface=3D"%s= ")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + else: > + print "\ntran_type error!\n" > + > + out =3D self.dut.send_expect("stop", "testpmd>") > + lines =3D out.split("\r\n") > + reta_line =3D {} > + > + # collect the hash result of five tuple and the queue id > + for line in lines: > + line =3D line.strip() > + if len(line) !=3D 0 and line.startswith(("src=3D",)): > + for item in line.split("-"): > + item =3D item.strip() > + if(item.startswith("RSS hash")): > + name, value =3D item.split("=3D", 1) > + print name + "-" + value > + > + reta_line[name.strip()] =3D value.strip() > + reta_lines.append(reta_line) > + reta_line =3D {} > + elif len(line) !=3D 0 and line.strip().startswith("port "): > + rexp =3D r"port (\d)/queue (\d{1,2}): received (\d) > packets" > + m =3D re.match(rexp, line.strip()) > + if m: > + reta_line["port"] =3D m.group(1) > + reta_line["queue"] =3D m.group(2) > + elif len(line) !=3D 0 and line.startswith("stop"): > + break > + else: > + pass > + > + self.verifyResult() > + > + def verifyResult(self): > + """ > + Verify whether or not the result passes. > + """ > + > + global reta_lines > + result =3D [] > + dts.results_table_add_header( > + ['packet index', 'hash value', 'hash index', 'queue id', > 'actual queue id', 'pass ']) > + > + i =3D 0 > + for tmp_reta_line in reta_lines: > + status =3D "false" > + if(self.nic =3D=3D "niantic"): > + # compute the hash result of five tuple into the 7 LSBs > value. > + hash_index =3D int(tmp_reta_line["RSS hash"], 16) % 128 > + else: > + # compute the hash result of five tuple into the 7 LSBs > value. > + hash_index =3D int(tmp_reta_line["RSS hash"], 16) % 512 > + if(reta_entries[hash_index] =3D=3D int(tmp_reta_line["queue"= ])): > + status =3D "true" > + result.insert(i, 0) > + else: > + status =3D "fail" > + result.insert(i, 1) > + dts.results_table_add_row( > + [i, tmp_reta_line["RSS hash"], hash_index, > reta_entries[hash_index], tmp_reta_line["queue"], status]) > + i =3D i + 1 > + > + dts.results_table_print() > + reta_lines =3D [] > + self.verify(sum(result) =3D=3D 0, "the reta update function fail= ed!") > + > + # > + # > + # > + # Test cases. > + # > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + > + self.verify( > + self.nic in ["niantic", "fortville_eagle", "fortville_spirit= ", > "fortville_spirit_single"], > + "NIC Unsupported: " + str(self.nic)) > + ports =3D self.dut.get_ports(self.nic) > + self.ports_socket =3D self.dut.get_numa_id(ports[0]) > + self.verify(len(ports) >=3D 1, "Not enough ports available") > + > + self.pmdout =3D PmdOutput(self.dut) > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + pass > + > + def test_pmdrss_reta(self): > + dutPorts =3D self.dut.get_ports(self.nic) > + localPort =3D self.tester.get_local_port(dutPorts[0]) > + itf =3D self.tester.get_interface(localPort) > + iptypes =3D ['IPV4'] > + > + self.dut.kill_all() > + > + # test with different rss queues > + for queue in testQueues: > + if(queue =3D=3D 16): > + self.pmdout.start_testpmd( > + "all", "--rxq=3D%d --txq=3D%d" % (queue, queue), > socket=3Dself.ports_socket) > + else: > + self.pmdout.start_testpmd( > + "all", "--mbcache=3D128 --rxq=3D%d --txq=3D%d" % (qu= eue, > queue), socket=3Dself.ports_socket) > + > + for iptype in iptypes: > + self.dut.send_expect("set verbose 8", "testpmd> ") > + self.dut.send_expect("set fwd rxonly", "testpmd> ") > + self.dut.send_expect( > + "set nbcore %d" % (queue + 1), "testpmd> ") > + > + # self.dut.send_expect("port stop all", "testpmd> ") > + # self.dut.send_expect("port config all rss udp", > "testpmd> ") > + # self.dut.send_expect("port start all", "testpmd> ") > + > + # configure the reta with specific mappings. > + if(self.nic =3D=3D "niantic"): > + for i in range(128): > + reta_entries.insert(i, random.randint(0, queue - > 1)) > + self.dut.send_expect( > + "port config 0 rss reta (%d,%d)" % (i, > reta_entries[i]), "testpmd> ") > + else: > + for i in range(512): > + reta_entries.insert(i, random.randint(0, queue - > 1)) > + self.dut.send_expect( > + "port config 0 rss reta (%d,%d)" % (i, > reta_entries[i]), "testpmd> ") > + > + self.send_packet(itf, iptype) > + > + self.dut.send_expect("quit", "# ", 30) > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + pass > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + self.dut.kill_all() > -- > 2.1.0