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 AA073A0540; Tue, 14 Jul 2020 04:53:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9FBA81D54C; Tue, 14 Jul 2020 04:53:40 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 6CE541D536 for ; Tue, 14 Jul 2020 04:53:38 +0200 (CEST) IronPort-SDR: D7PEPpu5n73khI7dKUsIWCLE58Hx+tE4quRC5r0ccKPA89vtVXpZa6f7pqWWxAggZEdqjaM7Xw 29bleC8fiOog== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="233640680" X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="233640680" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2020 19:53:37 -0700 IronPort-SDR: wJLbrSR1ZQbFmF74PzTz4yrpFEZaWKX+wtxrJLcg9oIXkuX5sT5tl+5VbAarHv+Ofhesn+aNTU +5wePo7RcUCw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,349,1589266800"; d="scan'208";a="316250860" Received: from unknown (HELO DPDK-zhaoyan-dev-34.sh.intel.com) ([10.67.118.34]) by orsmga008.jf.intel.com with ESMTP; 13 Jul 2020 19:53:35 -0700 From: "Chen, Zhaoyan" To: dts@dpdk.org Cc: "Chen, Zhaoyan" , Chen@dpdk.org Date: Tue, 14 Jul 2020 10:36:23 +0800 Message-Id: <20200714023623.23556-1-zhaoyan.chen@intel.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [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" The test suite will calculate the thash value by SW lib, Then check if the thash value is same to NIC's. 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 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 A= PI ++CFLAGS +=3D -DALLOW_EXPERIMENTAL_API ++LDFLAGS_SHARED =3D $(shell $(PKGCONF) --libs libdpdk) ++LDFLAGS_STATIC =3D -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpd= k) ++ ++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 A= PI ++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),=20 ++ 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) ++{ ++=20=20 ++ 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; ++ } ++=20=20 ++ return 0; ++}; ++ ++uint32_t ++calc_ipv4_l3l4_hash(char *ipstr_dst, char *ipstr_src, char* dst_port, cha= r* src_port, int hash_len){ ++ uint32_t rss_val =3D 0; ++=20=20 ++ 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, cha= r* 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]; ++=20=20 ++ /*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) ++{ ++=20 ++ 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_SRC= PORT_DST PORT_SRC\n"); ++ printf(" example: ./thash_test ipv4 192.168.1.1 192.168.1.2 1234 432= 1\n"); ++ return -1; ++ } ++ ++ for (i=3D1;i, Intel Corporation=0D + All rights reserved.=0D +=0D + Redistribution and use in source and binary forms, with or without=0D + modification, are permitted provided that the following conditions=0D + are met:=0D +=0D + - Redistributions of source code must retain the above copyright=0D + notice, this list of conditions and the following disclaimer.=0D +=0D + - Redistributions in binary form must reproduce the above copyright=0D + notice, this list of conditions and the following disclaimer in=0D + the documentation and/or other materials provided with the=0D + distribution.=0D +=0D + - Neither the name of Intel Corporation nor the names of its=0D + contributors may be used to endorse or promote products derived=0D + from this software without specific prior written permission.=0D +=0D + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=0D + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=0D + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS=0D + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE=0D + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,=0D + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES=0D + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR=0D + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)=0D + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,=0D + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)=0D + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED=0D + OF THE POSSIBILITY OF SUCH DAMAGE.=0D +=0D +=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=0D +Software/hardware Toeplitz hash consistence test suite=0D +=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=0D +=0D +This test suite is to check if the Toeplitz hash by hardware (NIC) is cons= istence =0D +with by software (rte_hash)=0D +=0D +First apply a DPDK patch, which provide an example for calling rte_hash ::= =0D +=0D + cd =0D + git apply /dep/0001-Generate-an-example-for-calling-thash-lib.pat= ch=0D +=0D +Compile the example ::=0D +=0D + export RTE_SDK=3D=0D + cd /examples/thash=0D + make=0D +=0D +Run thash example, which supported format: thash_test TYPE(ipv4|ipv4-udp|i= pv4-tcp) IP_DST IP_SRC PORT_DST PORT_SRC ::=0D +=0D + ./build/thash_test ipv6 ::22 ::11 1234 4321=0D + # The output=0D + ipv6=0D + ::22=0D + ::11=0D + 1234=0D + 4321=0D +=0D + Hash value =3D 914e08e4=0D +=0D +Then, configure the NIC and send packets to the NIC, expect the hash value= by NIC is same to thash_test ::=0D +=0D + # Launch testpmd, and configure the hash key=0D + testpmd> set verbose 1=0D + testpmd> start=0D + testpmd> port config 0 rss-hash-key ipv6 1234abcd1234abcd1234abcd1234a= bcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd= =0D + # Send packet to testpmd's interface=0D + sendp(Ether(dst=3D"52:36:30:A0:73:69")/IPv6(dst=3D"::22",src=3D"::11")= ,iface=3D'ens801f1')=0D + # The RSS hash value is same to thash_test result=0D + port 0/queue 4: received 1 packets=0D + src=3D00:00:00:00:00:00 - dst=3D52:36:30:A0:73:69 - type=3D0x86dd - le= ngth=3D60 - nb_segs=3D1 - RSS hash=3D0x914e08e4 - RSS queue=3D0x4 - sw ptyp= e: L2_ETHER L3_IPV6 - l2_len=3D14 - l3_len=3D40 - Receive queue=3D0x4=0D + ol_flags: PKT_RX_RSS_HASH PKT_RX_L4_CKSUM_GOOD PKT_RX_IP_CKSUM_GOOD PK= T_RX_OUTER_L4_CKSUM_UNKNOWN =0D --=20 2.22.0