From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id D39CA36E for ; Tue, 21 Mar 2017 08:14:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490080451; x=1521616451; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Ku+NB41u5tQU73m4R02NBSEZenIXNsQHb9AX95pAMWU=; b=kFBKQowbzXKCjs3FkZyKHUtkwYaQCwq+G5bP1yRuczIv/q2FCKP/m+5c rql8L+kAkn5OkZRwoudGjxltmMPTcw==; Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2017 00:14:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,198,1486454400"; d="scan'208";a="1144981277" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 21 Mar 2017 00:14:10 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 21 Mar 2017 00:14:10 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 21 Mar 2017 00:14:10 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by shsmsx102.ccr.corp.intel.com ([169.254.2.88]) with mapi id 14.03.0248.002; Tue, 21 Mar 2017 15:14:06 +0800 From: "Peng, Yuan" To: "Singh, Jasvinder" , "dev@dpdk.org" CC: "Doherty, Declan" , "De Lara Guarch, Pablo" Thread-Topic: [dpdk-dev] [PATCH v4 2/2] app/test: add unit test for CRC computation Thread-Index: AQHSoa8T/d6IRBGCn0yXFFnm9ArY96Ge4TZA Date: Tue, 21 Mar 2017 07:14:06 +0000 Message-ID: <67D543A150B29E4CAAE53918F64EDAEA3738A761@SHSMSX103.ccr.corp.intel.com> References: <1489354413-137376-2-git-send-email-jasvinder.singh@intel.com> <1490038180-207288-1-git-send-email-jasvinder.singh@intel.com> <1490038180-207288-3-git-send-email-jasvinder.singh@intel.com> In-Reply-To: <1490038180-207288-3-git-send-email-jasvinder.singh@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDA4ODc0MmItYjMxZC00YzQzLTk4NmMtMDE4NmUzMWQ2YzA5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IjNKZzlOZjJrN3JqNHJ1OFlUTHpHZ2x6K2lCc1gzSkJGemJQTmdZTW54bmM9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4 2/2] app/test: add unit test for CRC computation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 07:14:12 -0000 Hi Singh, The second patch cannot be applied, since the test folder has moved to the = DPDK root directory. [root@localhost dpdk]# git apply dpdk-dev-v4-2-2-app-test-add-unit-test-for= -CRC-computation.patch error: app/test/Makefile: No such file or directory Thank you. Yuan. -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jasvinder Singh Sent: Tuesday, March 21, 2017 3:30 AM To: dev@dpdk.org Cc: Doherty, Declan ; De Lara Guarch, Pablo Subject: [dpdk-dev] [PATCH v4 2/2] app/test: add unit test for CRC computat= ion This patch provides a set of tests for verifying the functional correctness= of 16-bit and 32-bit CRC APIs. Signed-off-by: Jasvinder Singh --- app/test/Makefile | 2 + app/test/test_crc.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 225 insertions(+) create mode 100644 app/test/test_crc.c diff --git a/app/test/Makefile b/app/test/Makefile index 1a5e03d..2a497f7 1= 00644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) +=3D test_cmdline_cir= buf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) +=3D test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) +=3D test_cmdline_lib.c =20 +SRCS-$(CONFIG_RTE_LIBRTE_NET) +=3D test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y +=3D test_red.c SRCS-y +=3D test_sched.c diff --git a/app/test/test_crc.c b/app/test/test_crc.c new file mode 100644= index 0000000..2eb0bff --- /dev/null +++ b/app/test/test_crc.c @@ -0,0 +1,223 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2017 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. + */ + +#include +#include +#include + +#include "test.h" + +#define CRC_VEC_LEN 32 +#define CRC32_VEC_LEN1 1512 +#define CRC32_VEC_LEN2 348 +#define CRC16_VEC_LEN1 12 +#define CRC16_VEC_LEN2 2 +#define LINE_LEN 75 + +/* CRC test vector */ +static const uint8_t crc_vec[CRC_VEC_LEN] =3D { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'A', 'B', 'C', 'D', + 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', }; + +/* 32-bit CRC test vector */ +static const uint8_t crc32_vec1[12] =3D { + 0xBE, 0xD7, 0x23, 0x47, 0x6B, 0x8F, + 0xB3, 0x14, 0x5E, 0xFB, 0x35, 0x59, +}; + +/* 16-bit CRC test vector 1*/ +static const uint8_t crc16_vec1[CRC16_VEC_LEN1] =3D { + 0x0D, 0x01, 0x01, 0x23, 0x45, 0x67, + 0x89, 0x01, 0x23, 0x45, 0x00, 0x01, +}; + +/* 16-bit CRC test vector 2*/ +static const uint8_t crc16_vec2[CRC16_VEC_LEN2] =3D { + 0x03, 0x3f, +}; +/** CRC results */ +uint32_t crc32_vec_res, crc32_vec1_res, crc32_vec2_res; uint32_t=20 +crc16_vec_res, crc16_vec1_res, crc16_vec2_res; + +static int +crc_calc(const uint8_t *vec, + uint32_t vec_len, + enum rte_net_crc_type type) +{ + /* compute CRC */ + uint32_t ret =3D rte_net_crc_calc(vec, vec_len, type); + + /* dump data on console*/ + rte_hexdump(stdout, NULL, vec, vec_len); + + return ret; +} + +static void +crc_calc_scalar(void) +{ + uint32_t i; + enum rte_net_crc_type type; + uint8_t *test_data; + + /* 32-bit ethernet CRC: scalar result */ + type =3D RTE_NET_CRC32_ETH; + crc32_vec_res =3D crc_calc(crc_vec, + CRC_VEC_LEN, + type); + + /* 32-bit ethernet CRC scalar result*/ + test_data =3D rte_zmalloc(NULL, CRC32_VEC_LEN1, 0); + + for (i =3D 0; i < CRC32_VEC_LEN1; i +=3D 12) + rte_memcpy(&test_data[i], crc32_vec1, 12); + + crc32_vec1_res =3D crc_calc(test_data, + CRC32_VEC_LEN1, + type); + + /* 32-bit ethernet CRC scalar result */ + test_data =3D rte_zmalloc(NULL, CRC32_VEC_LEN2, 0); + + for (i =3D 0; i < CRC32_VEC_LEN2; i +=3D 12) + rte_memcpy(&test_data[i], crc32_vec1, 12); + + crc32_vec2_res =3D crc_calc(test_data, + CRC32_VEC_LEN2, + type); + + /* 16-bit CCITT CRC scalar result */ + type =3D RTE_NET_CRC16_CCITT; + crc16_vec_res =3D crc_calc(crc_vec, + CRC_VEC_LEN, + type); + + /* 16-bit CCITT CRC scalar result */ + crc16_vec1_res =3D crc_calc(crc16_vec1, + CRC16_VEC_LEN1, + type); + + /* 16-bit CCITT CRC scalar result*/ + crc16_vec2_res =3D crc_calc(crc16_vec2, + CRC16_VEC_LEN2, + type); +} + +static int +test_crc(void) { + uint32_t i; + enum rte_net_crc_type type; + uint8_t *test_data; + uint32_t ret; + + /* set crc scalar mode */ + rte_net_crc_set_alg(RTE_NET_CRC_SCALAR); + crc_calc_scalar(); + + /* set crc sse4.2 mode */ + rte_net_crc_set_alg(RTE_NET_CRC_SSE42); + + /* 32-bit ethernet CRC: Test 1 */ + type =3D RTE_NET_CRC32_ETH; + + ret =3D crc_calc(crc_vec, + CRC_VEC_LEN, + type); + if (ret !=3D crc32_vec_res) { + printf("test_crc(32-bit): test1 failed !\n"); + return -1; + } + + /* 32-bit ethernet CRC: Test 2 */ + test_data =3D rte_zmalloc(NULL, CRC32_VEC_LEN1, 0); + + for (i =3D 0; i < CRC32_VEC_LEN1; i +=3D 12) + rte_memcpy(&test_data[i], crc32_vec1, 12); + + ret =3D crc_calc(test_data, + CRC32_VEC_LEN1, + type); + if (ret !=3D crc32_vec1_res) { + printf("test_crc(32-bit): test2 failed!\n"); + return -1; + } + + /* 32-bit ethernet CRC: Test 3 */ + test_data =3D rte_zmalloc(NULL, CRC32_VEC_LEN2, 0); + + for (i =3D 0; i < CRC32_VEC_LEN2; i +=3D 12) + rte_memcpy(&test_data[i], crc32_vec1, 12); + + ret =3D crc_calc(test_data, + CRC32_VEC_LEN2, + type); + if (ret !=3D crc32_vec2_res) { + printf("test_crc(32-bit): test3 failed!\n"); + return -1; + } + + /* 16-bit CCITT CRC: Test 4 */ + type =3D RTE_NET_CRC16_CCITT; + ret =3D crc_calc(crc_vec, + CRC_VEC_LEN, + type); + if (ret !=3D crc16_vec_res) { + printf("test_crc (16-bit): test4 failed!\n"); + return -1; + } + + /* 16-bit CCITT CRC: Test 5 */ + ret =3D crc_calc(crc16_vec1, + CRC16_VEC_LEN1, + type); + if (ret !=3D crc16_vec1_res) { + printf("test_crc (16-bit): test5 failed!\n"); + return -1; + } + + /* 16-bit CCITT CRC: Test 6 */ + ret =3D crc_calc(crc16_vec2, + CRC16_VEC_LEN2, + type); + if (ret !=3D crc16_vec2_res) { + printf("test_crc (16-bit): test6 failed!\n"); + return -1; + } + + return 0; +} + +REGISTER_TEST_COMMAND(crc_autotest, test_crc); -- 2.5.5