From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 91C28A0540; Mon, 20 Jul 2020 09:30:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 898E02AA6; Mon, 20 Jul 2020 09:30:20 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 9C2E6255 for ; Mon, 20 Jul 2020 09:30:18 +0200 (CEST) IronPort-SDR: RsVzzHtMHoeYnIbndI+586ydKgSyb6X7SNSqFGlLC9ceSfQJg/HYw7MBX5xj4B0Aoohloc2fuj UX22gAVN1OGA== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="149851815" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="149851815" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 00:30:17 -0700 IronPort-SDR: 8EQJYoZkSZQBGGJA5x0a6dr0j0I9skJs4iRyFpxXZIS21P89kIuFgU2uoK8fvwwaTydCFFREUD tLiuvTUx/YkA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="391961363" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 20 Jul 2020 00:30:06 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 20 Jul 2020 00:30:04 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.22]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.250]) with mapi id 14.03.0439.000; Mon, 20 Jul 2020 15:30:00 +0800 From: "Tu, Lijuan" To: "Chen, Zhaoyan" , "dts@dpdk.org" CC: "Chen, Zhaoyan" , "Chen@dpdk.org" Thread-Topic: [dts] [PATCH v1] Add a test suite for checking SW/HW thash consistence. Thread-Index: AQHWWYoKUV9sw27/EkSIh6SIY2b6hKkQHAig Date: Mon, 20 Jul 2020 07:29:59 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BC82355@SHSMSX101.ccr.corp.intel.com> References: <20200714023623.23556-1-zhaoyan.chen@intel.com> In-Reply-To: <20200714023623.23556-1-zhaoyan.chen@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH v1] Add a test suite for checking SW/HW thash consistence. 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Applied, thanks > -----Original Message----- > From: dts On Behalf Of Chen, Zhaoyan > Sent: 2020=1B$BG/=1B(B7=1B$B7n=1B(B14=1B$BF|=1B(B 10:36 > To: dts@dpdk.org > Cc: Chen, Zhaoyan ; Chen@dpdk.org > Subject: [dts] [PATCH v1] Add a test suite for checking SW/HW thash consi= stence. >=20 > The test suite will calculate the thash value by SW lib, Then check if th= e thash > value is same to NIC's. >=20 > Signed-off-by: Chen, Zhaoyan > --- > ...ate-an-example-for-calling-thash-lib.patch | 301 ++++++++++++++++++ > .../sw_hw_thash_consistence_test_plan.rst | 74 +++++ > 2 files changed, 375 insertions(+) > create mode 100644 dep/0001-Generate-an-example-for-calling-thash- > lib.patch > create mode 100644 test_plans/sw_hw_thash_consistence_test_plan.rst >=20 > diff --git a/dep/0001-Generate-an-example-for-calling-thash-lib.patch > b/dep/0001-Generate-an-example-for-calling-thash-lib.patch > new file mode 100644 > index 0000000..59701d6 > --- /dev/null > +++ b/dep/0001-Generate-an-example-for-calling-thash-lib.patch > @@ -0,0 +1,301 @@ > +From c2efff2cb7d52d8d284629c128e2e1004cf5de00 Mon Sep 17 00:00:00 > 2001 > +From: "Chen, Zhaoyan" > +Date: Tue, 19 May 2020 13:36:16 +0800 > +Subject: [PATCH] Generate an example for calling thash lib to get > +3-tuple/5-tuple hash value. > + > +Add ipv6/ipv6-tcp/ipv6-udp support > + > +Fix ipv6/ipv6-udp/ipv6/tcp hash value is incorrect > +--- > + examples/thash/Makefile | 60 ++++++++++++ > + examples/thash/main.c | 188 +++++++++++++++++++++++++++++++++++++ > + examples/thash/meson.build | 13 +++ > + 3 files changed, 261 insertions(+) > + create mode 100644 examples/thash/Makefile create mode 100644 > +examples/thash/main.c create mode 100644 examples/thash/meson.build > + > +diff --git a/examples/thash/Makefile b/examples/thash/Makefile new file > +mode 100644 index 0000000000..387d920a08 > +--- /dev/null > ++++ b/examples/thash/Makefile > +@@ -0,0 +1,60 @@ > ++# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2010-2014 Intel > ++Corporation > ++ > ++# binary name > ++APP =3D thash_test > ++ > ++# all source are stored in SRCS-y > ++SRCS-y :=3D main.c > ++ > ++# Build using pkg-config variables if possible ifeq ($(shell > ++pkg-config --exists libdpdk && echo 0),0) > ++ > ++all: shared > ++.PHONY: shared static > ++shared: build/$(APP)-shared > ++ ln -sf $(APP)-shared build/$(APP) > ++static: build/$(APP)-static > ++ ln -sf $(APP)-static build/$(APP) > ++ > ++PKGCONF ?=3D pkg-config > ++ > ++PC_FILE :=3D $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS +=3D > ++-O3 $(shell $(PKGCONF) --cflags libdpdk) # Add flag to allow > ++experimental API as l2fwd uses rte_ethdev_set_ptype API CFLAGS +=3D > ++-DALLOW_EXPERIMENTAL_API LDFLAGS_SHARED =3D $(shell $(PKGCONF) --libs > ++libdpdk) LDFLAGS_STATIC =3D -Wl,-Bstatic $(shell $(PKGCONF) --static > ++--libs libdpdk) > ++ > ++build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build > ++ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) > ++ > ++build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build > ++ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) > ++ > ++build: > ++ @mkdir -p $@ > ++ > ++.PHONY: clean > ++clean: > ++ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared > ++ test -d build && rmdir -p build || true > ++ > ++else # Build using legacy build system > ++ > ++ifeq ($(RTE_SDK),) > ++$(error "Please define RTE_SDK environment variable") endif > ++ > ++# Default target, detect a build directory, by looking for a path with > ++a .config RTE_TARGET ?=3D $(notdir $(abspath $(dir $(firstword > ++$(wildcard $(RTE_SDK)/*/.config))))) > ++ > ++include $(RTE_SDK)/mk/rte.vars.mk > ++ > ++CFLAGS +=3D -O3 > ++CFLAGS +=3D $(WERROR_FLAGS) > ++# Add flag to allow experimental API as l2fwd uses > ++rte_ethdev_set_ptype API CFLAGS +=3D -DALLOW_EXPERIMENTAL_API > ++ > ++include $(RTE_SDK)/mk/rte.extapp.mk > ++endif > +diff --git a/examples/thash/main.c b/examples/thash/main.c new file > +mode 100644 index 0000000000..fe7b2bc683 > +--- /dev/null > ++++ b/examples/thash/main.c > +@@ -0,0 +1,188 @@ > ++/* SPDX-License-Identifier: BSD-3-Clause > ++ * Copyright(c) 2010-2016 Intel Corporation */ > ++ > ++#include > ++#include > ++#include > ++#include > ++ > ++#include > ++#include > ++ > ++ > ++uint8_t default_rss_key[] =3D { > ++0x12, 0x34, 0xab, 0xcd, 0x12, 0x34, 0xab, 0xcd, 0x12, 0x34, 0xab, > ++0xcd, 0x12, 0x34, 0xab, 0xcd, 0x12, 0x34, 0xab, 0xcd, 0x12, 0x34, > ++0xab, 0xcd, 0x12, 0x34, 0xab, 0xcd, 0x12, 0x34, 0xab, 0xcd, 0x12, > ++0x34, 0xab, 0xcd, 0x12, 0x34, 0xab, 0xcd, 0x12, 0x34, 0xab, 0xcd, > ++0x12, 0x34, 0xab, 0xcd, 0x12, 0x34, 0xab, 0xcd, }; > ++ > ++struct test_thash_v4 { > ++ uint32_t dst_ip; > ++ uint32_t src_ip; > ++ uint16_t dst_port; > ++ uint16_t src_port; > ++}; > ++ > ++struct test_thash_v6 { > ++ uint8_t dst_ip[16]; > ++ uint8_t src_ip[16]; > ++ uint16_t dst_port; > ++ uint16_t src_port; > ++}; > ++ > ++struct test_thash_v4 v4_tb =3D { > ++ RTE_IPV4(192, 168, 1, 101), > ++ RTE_IPV4(192, 168, 1, 100), > ++ 1766, 2794, > ++}; > ++ > ++struct test_thash_v6 v6_tb =3D { > ++{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xf8, > ++0xff, 0xfe, 0x21, 0x67, 0xcf,}, {0x3f, 0xfe, 0x19, 0x00, 0x45, 0x45, > ++0x00, 0x03, 0x02, 0x00, 0xf8, 0xff, 0xfe, 0x21, 0x67, 0xcf,}, 38024, > ++44251}; > ++ > ++int ipstr2int32(char *ipstr, uint32_t *ipaddr); int ipv6str2int8(char > ++*ipstr, uint8_t *ipaddr); uint32_t calc_ipv4_l3l4_hash(char > ++*ipstr_dst, char *ipstr_src, char* dst_port, char* src_port, int > ++hash_len); uint32_t calc_ipv6_l3l4_hash(char *ipstr_dst, char > ++*ipstr_src, char* dst_port, char* src_port, int hash_len); > ++ > ++int > ++ipstr2int32(char *ipstr, uint32_t *ipaddr) { > ++ unsigned int addr[4]; > ++ if (sscanf(ipstr, "%u.%u.%u.%u", &addr[3], &addr[2], &addr[1], &addr[= 0]) =3D=3D > 4){ > ++ if ((addr[3] < 256) > ++ && (addr[2] < 256) > ++ && (addr[1] < 256) > ++ && (addr[0] < 256) > ++ ) > ++ { > ++ *ipaddr =3D RTE_IPV4(addr[3], addr[2], addr[1], addr[0]); > ++ return -1; > ++ } > ++ } > ++ return 0; > ++}; > ++ > ++int > ++ipv6str2int8(char *ipstr, uint8_t *ipaddr) { > ++ > ++ struct in6_addr result; > ++ int i =3D 0; > ++ if(inet_pton(AF_INET6, ipstr, &result) =3D=3D 1){ > ++ for (i=3D0; i<16; i++){ > ++ ipaddr[i] =3D result.__in6_u.__u6_addr8[i]; > ++ //printf("%0x\n",ipaddr[i]); > ++ } > ++ return 1; > ++ } > ++ > ++ return 0; > ++}; > ++ > ++uint32_t > ++calc_ipv4_l3l4_hash(char *ipstr_dst, char *ipstr_src, char* dst_port, > ++char* src_port, int hash_len){ > ++ uint32_t rss_val =3D 0; > ++ > ++ if (hash_len <=3D 0){ > ++ hash_len =3D 2; > ++ } > ++ > ++ ipstr2int32(ipstr_dst, &v4_tb.dst_ip); > ++ ipstr2int32(ipstr_src, &v4_tb.src_ip); > ++ v4_tb.dst_port =3D atoi(dst_port); > ++ v4_tb.src_port =3D atoi(src_port); > ++ rss_val =3D rte_softrss((uint32_t *)&v4_tb, > ++ hash_len, default_rss_key); > ++ return rss_val; > ++ > ++} > ++ > ++uint32_t > ++calc_ipv6_l3l4_hash(char *ipstr_dst, char *ipstr_src, char* dst_port, > ++char* src_port, int hash_len){ > ++ uint32_t rss_val =3D 0; > ++ uint32_t j =3D 0; > ++ union rte_thash_tuple tuple; > ++ struct rte_ipv6_hdr ipv6_hdr; > ++ > ++ if (hash_len <=3D 0){ > ++ hash_len =3D 8; > ++ } > ++ > ++ ipv6str2int8(ipstr_dst, &v6_tb.dst_ip[0]); ipv6str2int8(ipstr_src, > ++ &v6_tb.src_ip[0]); > ++ > ++ for (j =3D 0; j < RTE_DIM(ipv6_hdr.src_addr); j++) > ++ ipv6_hdr.src_addr[j] =3D v6_tb.src_ip[j]; > ++ > ++ for (j =3D 0; j < RTE_DIM(ipv6_hdr.dst_addr); j++) > ++ ipv6_hdr.dst_addr[j] =3D v6_tb.dst_ip[j]; > ++ > ++ /*Load and convert ipv6 address into tuple*/ > ++ rte_thash_load_v6_addrs(&ipv6_hdr, &tuple); > ++ > ++ tuple.v6.dport =3D atoi(dst_port); > ++ tuple.v6.sport =3D atoi(src_port); > ++ > ++ rss_val =3D rte_softrss((uint32_t *)&tuple, > ++ hash_len, default_rss_key); > ++ return rss_val; > ++ > ++} > ++ > ++ > ++int > ++main(int argc, char **argv) > ++{ > ++ > ++ uint8_t rss_key_be[RTE_DIM(default_rss_key)]; > ++ uint32_t rss_val =3D 0; > ++ int i; > ++ int hash_len =3D 3; // 3 * 32bits(4Bytes) > ++ > ++ if (argc !=3D 6){ > ++ printf("Format: thash_test TYPE(ipv4|ipv4-udp|ipv4-tcp) IP_DST IP_S= RC > PORT_DST PORT_SRC\n"); > ++ printf(" example: ./thash_test ipv4 192.168.1.1 192.168.1.2 1234 4= 321\n"); > ++ return -1; > ++ } > ++ > ++ for (i=3D1;i ++ printf("%s\n", argv[i]); > ++ } > ++ > ++ //Prepare rss key for big-endian > ++ rte_convert_rss_key((uint32_t *)&default_rss_key, > ++ (uint32_t *)rss_key_be, RTE_DIM(default_rss_key)); > ++ > ++ if (!strcmp(argv[1], "ipv4")){ > ++ hash_len =3D 2; > ++ rss_val =3D calc_ipv4_l3l4_hash(argv[2], argv[3], argv[4], > ++ argv[5], hash_len); }else if(!strcmp(argv[1], "ipv4-udp") || !strcmp(= argv[1], > "ipv4-tcp")){ > ++ hash_len =3D 3; > ++ rss_val =3D calc_ipv4_l3l4_hash(argv[2], argv[3], argv[4], > ++ argv[5], hash_len); }else if(!strcmp(argv[1], "ipv6")){ > ++ //8bits*16*2 =3D 8 > ++ hash_len =3D 8; > ++ rss_val =3D calc_ipv6_l3l4_hash(argv[2], argv[3], argv[4], argv[5], > ++ hash_len); > ++ > ++ }else if(!strcmp(argv[1], "ipv6-udp") || !strcmp(argv[1], "ipv6-tcp")= ){ > ++ //8bits*16*2 + 32bits =3D 9 > ++ hash_len =3D 9; > ++ rss_val =3D calc_ipv6_l3l4_hash(argv[2], argv[3], argv[4], argv[5], > ++ hash_len); }else { > ++ printf("Not supported TYPE.\n"); > ++ } > ++ > ++ printf("\nHash value =3D %0x\n", rss_val); > ++ > ++ return 0; > ++} > +\ No newline at end of file > +diff --git a/examples/thash/meson.build b/examples/thash/meson.build > +new file mode 100644 index 0000000000..50d88caa0a > +--- /dev/null > ++++ b/examples/thash/meson.build > +@@ -0,0 +1,13 @@ > ++# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel > ++Corporation > ++ > ++# meson file, for building this example as part of a main DPDK build. > ++# > ++# To build this example as a standalone application with an > ++already-installed # DPDK instance, use 'make' > ++ > ++# Enable experimental API flag as l2fwd uses rte_ethdev_set_ptype API > ++allow_experimental_apis =3D true sources =3D files( > ++ 'main.c' > ++) > +-- > +2.22.0 > + > diff --git a/test_plans/sw_hw_thash_consistence_test_plan.rst > b/test_plans/sw_hw_thash_consistence_test_plan.rst > new file mode 100644 > index 0000000..a263b3d > --- /dev/null > +++ b/test_plans/sw_hw_thash_consistence_test_plan.rst > @@ -0,0 +1,74 @@ > +.. Copyright (c) <2020>, 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+ not= ice, this > list of conditions and the following disclaimer.++ - Redistributions in= binary > form must reproduce the above copyright+ notice, this list of conditi= ons and > the following disclaimer in+ the documentation and/or other materials > provided with the+ distribution.++ - Neither the name of Intel Corp= oration > 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.++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D+ > Software/hardware Toeplitz hash consistence test > suite+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D++This > test suite is to check if the Toeplitz hash by hardware (NIC) is consiste= nce +with > by software (rte_hash)++First apply a DPDK patch, which provide an exampl= e for > calling rte_hash ::++ cd + git apply /dep/0001-Generate-= an- > example-for-calling-thash-lib.patch++Compile the example ::++ export > RTE_SDK=3D+ cd /examples/thash+ make++Run thash example= , > which supported format: thash_test TYPE(ipv4|ipv4-udp|ipv4-tcp) IP_DST > IP_SRC PORT_DST PORT_SRC ::++ ./build/thash_test ipv6 ::22 ::11 1234 4= 321+ > # The output+ ipv6+ ::22+ ::11+ 1234+ 4321++ Hash value= =3D > 914e08e4++Then, configure the NIC and send packets to the NIC, expect the > hash value by NIC is same to thash_test ::++ # Launch testpmd, and con= figure > the hash key+ testpmd> set verbose 1+ testpmd> start+ testpmd> p= ort > config 0 rss-hash-key ipv6 > 1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd12 > 34abcd1234abcd1234abcd1234abcd1234abcd+ # Send packet to testpmd's > interface+ > sendp(Ether(dst=3D"52:36:30:A0:73:69")/IPv6(dst=3D"::22",src=3D"::11"),if= ace=3D'ens801f > 1')+ # The RSS hash value is same to thash_test result+ port 0/queu= e 4: > received 1 packets+ src=3D00:00:00:00:00:00 - dst=3D52:36:30:A0:73:69 = - > type=3D0x86dd - length=3D60 - nb_segs=3D1 - RSS hash=3D0x914e08e4 - RSS q= ueue=3D0x4 - > sw ptype: L2_ETHER L3_IPV6 - l2_len=3D14 - l3_len=3D40 - Receive queue= =3D0x4+ > ol_flags: PKT_RX_RSS_HASH PKT_RX_L4_CKSUM_GOOD > PKT_RX_IP_CKSUM_GOOD PKT_RX_OUTER_L4_CKSUM_UNKNOWN -- > 2.22.0