From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 8B4583277 for ; Tue, 28 Mar 2017 21:27:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490729229; x=1522265229; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=npvP77NisM0D4ayRAjnckGVHp8yfT/r3Kblx94gU06o=; b=b/xCdrKOFXEiVe8SA8g/ZUTVJq3nkN4AaOO1RV86od4u0fMpiHi4TALg J1WvO0r2WqghZdcMWYkCHZ7Xa9qvsw==; Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2017 12:27:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,237,1486454400"; d="scan'208";a="949134944" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by orsmga003.jf.intel.com with ESMTP; 28 Mar 2017 12:27:07 -0700 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.241]) by IRSMSX104.ger.corp.intel.com ([163.33.3.159]) with mapi id 14.03.0319.002; Tue, 28 Mar 2017 20:27:06 +0100 From: "Singh, Jasvinder" To: "De Lara Guarch, Pablo" , "dev@dpdk.org" CC: "olivier.matz@6wind.com" , "Doherty, Declan" Thread-Topic: [PATCH v5 2/2] test/test: add unit test for CRC computation Thread-Index: AQHSp/i8O52mnYdp5kSN15O/TE3IDKGqomfg Date: Tue, 28 Mar 2017 19:27:05 +0000 Message-ID: <54CBAA185211B4429112C315DA58FF6D31B40721@IRSMSX103.ger.corp.intel.com> References: <1490038180-207288-2-git-send-email-jasvinder.singh@intel.com> <1490107540-66614-1-git-send-email-jasvinder.singh@intel.com> <1490107540-66614-3-git-send-email-jasvinder.singh@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMWUxMTc3N2UtYjI1ZC00NmYwLWE2OTgtZjliMDliNjNlODk0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlJ3N0tjS3ZNS1ZtQytWdnNaS0JaNUFuaW5CTFNSQWxcL24yNGNYbHJzbFVnPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v5 2/2] test/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, 28 Mar 2017 19:27:10 -0000 Hi Pablo, > -----Original Message----- > From: De Lara Guarch, Pablo > Sent: Tuesday, March 28, 2017 8:23 PM > To: Singh, Jasvinder ; dev@dpdk.org > Cc: olivier.matz@6wind.com; Doherty, Declan > Subject: RE: [PATCH v5 2/2] test/test: add unit test for CRC computation >=20 > Hi Jasvinder, >=20 >=20 > > -----Original Message----- > > From: Singh, Jasvinder > > Sent: Tuesday, March 21, 2017 2:46 PM > > To: dev@dpdk.org > > Cc: olivier.matz@6wind.com; Doherty, Declan; De Lara Guarch, Pablo > > Subject: [PATCH v5 2/2] test/test: add unit test for CRC computation > > > > 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 > > --- > > test/test/Makefile | 2 + > > test/test/test_crc.c | 223 > > +++++++++++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 225 insertions(+) > > create mode 100644 test/test/test_crc.c > > >=20 > > diff --git a/test/test/test_crc.c b/test/test/test_crc.c new file mode > > 100644 index 0000000..2eb0bff > > --- /dev/null > > +++ b/test/test/test_crc.c > > @@ -0,0 +1,223 @@ >=20 >=20 > > + > > +#include "test.h" > > + > > +#define CRC_VEC_LEN 32 >=20 > Unnecessary extra tab. >=20 > > +#define CRC32_VEC_LEN1 1512 > > +#define CRC32_VEC_LEN2 348 > > +#define CRC16_VEC_LEN1 12 > > +#define CRC16_VEC_LEN2 2 > > +#define LINE_LEN 75 >=20 > I would align this to the other values above. >=20 > ... >=20 > > + > > +/* 16-bit CRC test vector 1*/ >=20 > Extra space before "*/". >=20 > > +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*/ >=20 > Same here. >=20 > > +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 > > +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*/ >=20 > Same here. >=20 > > + rte_hexdump(stdout, NULL, vec, vec_len); >=20 > I would use TEST_HEXDUMP, which dumps the stream only if debug is > enabled (to avoid too much output). >=20 > > + > > + 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); >=20 > Remove unnecessary tabs (more of this in the rest of the file). >=20 > > + > > + /* 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); >=20 > Wrong indentation (more of this in the rest of the file). > Also, why not just one memcpy call, with CRC32_VEC_LEN1. > A comment would be good to explain why. >=20 > ... >=20 > > +static int > > +test_crc(void) { >=20 > Looks strange to start the parameters in a new line. > I would say you can start in the same line as the function name. >=20 > > + uint32_t i; > > + enum rte_net_crc_type type; > > + uint8_t *test_data; > > + uint32_t ret; > > + > > + /* set crc scalar mode */ >=20 > Probably the references of "crc" in comments should be uppercase "CRC". >=20 > > + 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"); >=20 > Extra space before "!" (keep consistency with the other printfs). >=20 > > + return -1; > > + } > > + > > + /* 32-bit ethernet CRC: Test 2 */ > > + test_data =3D rte_zmalloc(NULL, CRC32_VEC_LEN1, 0); >=20 > Free the memory after the test (also for other calls). Will correct the patch and send the next version. Thank you. Jasvinder