From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 140CFC33C9E for ; Tue, 7 Jan 2020 16:04:09 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 782E52080A for ; Tue, 7 Jan 2020 16:04:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=intel.onmicrosoft.com header.i=@intel.onmicrosoft.com header.b="pA7c/lub" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 782E52080A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B64001D9F0; Tue, 7 Jan 2020 17:04:07 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 69C3D1D9EE for ; Tue, 7 Jan 2020 17:04:05 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2020 08:04:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,406,1571727600"; d="scan'208";a="421118633" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga005.fm.intel.com with ESMTP; 07 Jan 2020 08:04:04 -0800 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 7 Jan 2020 08:04:03 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 7 Jan 2020 08:04:01 -0800 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 7 Jan 2020 08:04:01 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.171) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 7 Jan 2020 08:03:59 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D8e6jndkoOw4zoqARibeTgZEjLrAkIK2iMAfxcvDJz0Tbe1uWdxEt8cTu3zUGmTc9nRDB/iVoo9let7AuXALBsSw2fxmly0lyY+D4fx7+H19cTaRbtDhpjPpQdqgjEVpOmd50XYHJbwntVe7HsFHTapZLxcZn67Aspas3wsXFtih3+LwBNG/T2aHmEAZg4pR4O4YWglUaI76TeLlIBiKDcNfdZLux3HUpZx6rLTAWKKlNHNl5qT+ftHKUElFIRlMuRMve7CcRIYnHKGDyQhNdwAEqFgiBS52bz7j4RzLilO6xB1m55/3uTSfb66MQ9hL1GbMm/rQKpXWB79OjjZbcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vOxm7qiHYhqC0fY63GoceWJqQr//u6aDl4Nlcgt5nSQ=; b=iQ10Ft/Fixe0wgapTUIYyc2UMzkncUpuNykzy62LMb5qcz1I6yWhECeg3KWgsWkGTsAKEca4V3jsSLJadyrIQYqr7aMEsMGqqCMX3UvWjCenpbQHD9DxwFO+bbXEu2s1JGu2m8+uxiHAkGgXqTWb0Muylo0TCIdK+GjVRjmrtO/m3Rx+4kFSHG3xAl4xSburGMdQufEt6g1aimHhgQPb4kjBQyObjmf1v3mJ19m2HAv33MZrmLi9XVwyGtQJ1gzWbS1Jasloj4H4Nhz+7SVxGYPoT30B9VFWAqXS8lWH8JH5JZyZJq8iBd5IPnbvllM1A0SHIdI/cV4tRSjJzdQYMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vOxm7qiHYhqC0fY63GoceWJqQr//u6aDl4Nlcgt5nSQ=; b=pA7c/lubjEIf++Ysex5TZ3hEua3mQGWFmRrIf4u/mi9GAGPHmpwBcBEaL81YuaMlch1hpRrvRFsSag529izS2kZz6mq984g6x0s04YZZD/mMaR/Nkb4OQnZ6oTNsLXak2NoNvZz12AaGMrIxvz1v5WsqQVStcH7ZFgLV3aXfsjw= Received: from SN6PR11MB2558.namprd11.prod.outlook.com (52.135.94.19) by SN6PR11MB3215.namprd11.prod.outlook.com (52.135.112.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.13; Tue, 7 Jan 2020 16:03:56 +0000 Received: from SN6PR11MB2558.namprd11.prod.outlook.com ([fe80::4d86:362a:13c3:8386]) by SN6PR11MB2558.namprd11.prod.outlook.com ([fe80::4d86:362a:13c3:8386%7]) with mapi id 15.20.2623.008; Tue, 7 Jan 2020 16:03:56 +0000 From: "Ananyev, Konstantin" To: Honnappa Nagarahalli , "olivier.matz@6wind.com" , "sthemmin@microsoft.com" , "jerinj@marvell.com" , "Richardson, Bruce" , "david.marchand@redhat.com" , "pbhagavatula@marvell.com" CC: "dev@dpdk.org" , Dharmik Thakkar , Ruifeng Wang , Gavin Hu , nd , nd Thread-Topic: [PATCH v7 03/17] test/ring: add functional tests for rte_ring_xxx_elem APIs Thread-Index: AQHVtvB05AIL1u+3/UGhXZRhDoUYw6fXmQ/ggAcrgYCAALI6MA== Date: Tue, 7 Jan 2020 16:03:56 +0000 Message-ID: References: <20190906190510.11146-1-honnappa.nagarahalli@arm.com> <20191220044524.32910-1-honnappa.nagarahalli@arm.com> <20191220044524.32910-4-honnappa.nagarahalli@arm.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTgyMjA1NmQtMWRjNC00MzgzLThlY2UtMDkzOTVkMDEzM2Y0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiU2Vub0xMMDc0UFcxWEdpeWwrZDdpZ0x1T0g0a1ZkZGI2Z3dDTW5ManplVE51RWlMODF5MDhBVEVOclBUSWtXYiJ9 dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 x-ctpclassification: CTP_NT authentication-results: spf=none (sender IP is ) smtp.mailfrom=konstantin.ananyev@intel.com; x-originating-ip: [192.198.151.179] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 468bd28c-b32f-4200-38bb-08d7938b331d x-ms-traffictypediagnostic: SN6PR11MB3215: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 027578BB13 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(346002)(39860400002)(136003)(376002)(189003)(199004)(51234002)(7696005)(66946007)(54906003)(110136005)(66446008)(64756008)(66556008)(66476007)(33656002)(4326008)(316002)(76116006)(55016002)(9686003)(7416002)(8936002)(81156014)(81166006)(8676002)(26005)(71200400001)(478600001)(86362001)(2906002)(52536014)(5660300002)(6506007)(186003)(30864003)(21314003)(559001)(579004); DIR:OUT; SFP:1102; SCL:1; SRVR:SN6PR11MB3215; H:SN6PR11MB2558.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 5NgL2O1u5Vom6Hj2WTgh+b6WLbLODrQucYV4BSOETgLRTjz1EEaIBE2hAwdrmhYU4D6nA5hbOLg7lIWANvqw7y+AfJnuv6Ih2dOi90fKAWU42QP1v6mLHqqA9lanfiz/XvEbhdaHHSq03gabj1ldOPun/nc1/kqVTyZGlFJ5iPocul6r9lM9s6olcwaKRNuRasYZzkCnSZcmt6znmIrx+5Mo6lxoiXHXEOQsoytx0nWUKamlYQv2SL3U05oa7hXzKhotSQQY3v1TdNXcPZS4eAnbCHfsSBotHXb24G1NLwPAr1+HVeiZ/nyDL9hDby7SoH/l5bF6vGtKgsG7OHfRh+HEaD2sYPlmbqmx/NwZEsyIW0TkKOeL6zCSx8Aoyt2/Ey+93zdiz5NWuyMZNfFPD6lemVAMpYPSKDujVGusZ02eM6AnKKa4UmGPXamfbIX+w7WITO2yy7bY/Yz1u+krwe7LX+4pIcTGTwPw6voBZByikTRgf1lNyrAGcBHV8gk9ffeLdfLHUE/GPqAZ5F3ZpQ== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 468bd28c-b32f-4200-38bb-08d7938b331d X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jan 2020 16:03:56.0816 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: n9V5FtuMMiLUUlSxQOAiUe9XrXKYd9kKX+F3TGLmnF++raRxFk5NlacHgf+oQDTGOIL2I5ZQf42VNL3JOz+1hjHPSmGdeJdikOMQyYIbS9E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB3215 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v7 03/17] test/ring: add functional tests for rte_ring_xxx_elem APIs 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > > > Add basic infrastructure to test rte_ring_xxx_elem APIs. Add test > > > cases for testing burst and bulk tests. > > > > > > Signed-off-by: Honnappa Nagarahalli > > > Reviewed-by: Gavin Hu > > > --- > > > app/test/test_ring.c | 466 > > > ++++++++++++++++++++----------------------- > > > app/test/test_ring.h | 203 +++++++++++++++++++ > > > 2 files changed, 419 insertions(+), 250 deletions(-) create mode > > > 100644 app/test/test_ring.h > > > > > > diff --git a/app/test/test_ring.c b/app/test/test_ring.c index > > > aaf1e70ad..e7a8b468b 100644 > > > --- a/app/test/test_ring.c > > > +++ b/app/test/test_ring.c > > > @@ -23,11 +23,13 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > > > > #include "test.h" > > > +#include "test_ring.h" > > > > > > /* > > > * Ring > > > @@ -67,6 +69,50 @@ static rte_atomic32_t synchro; > > > > > > #define TEST_RING_FULL_EMTPY_ITER 8 > > > > > > +static int esize[] =3D {-1, 4, 8, 16}; > > > + > > > +static void > > > +test_ring_mem_init(void *obj, unsigned int count, int esize) { > > > + unsigned int i; > > > + > > > + /* Legacy queue APIs? */ > > > + if (esize =3D=3D -1) > > > + for (i =3D 0; i < count; i++) > > > + ((void **)obj)[i] =3D (void *)(unsigned long)i; > > > + else > > > + for (i =3D 0; i < (count * esize / sizeof(uint32_t)); i++) > > > + ((uint32_t *)obj)[i] =3D i; > > > +} > > > + > > > +static void > > > +test_ring_print_test_string(const char *istr, unsigned int api_type, > > > +int esize) { > > > + printf("\n%s: ", istr); > > > + > > > + if (esize =3D=3D -1) > > > + printf("legacy APIs: "); > > > + else > > > + printf("elem APIs: element size %dB ", esize); > > > + > > > + if (api_type =3D=3D TEST_RING_IGNORE_API_TYPE) > > > + return; > > > + > > > + if ((api_type & TEST_RING_N) =3D=3D TEST_RING_N) > > > + printf(": default enqueue/dequeue: "); > > > + else if ((api_type & TEST_RING_S) =3D=3D TEST_RING_S) > > > + printf(": SP/SC: "); > > > + else if ((api_type & TEST_RING_M) =3D=3D TEST_RING_M) > > > + printf(": MP/MC: "); > > > + > > > + if ((api_type & TEST_RING_SL) =3D=3D TEST_RING_SL) > > > + printf("single\n"); > > > + else if ((api_type & TEST_RING_BL) =3D=3D TEST_RING_BL) > > > + printf("bulk\n"); > > > + else if ((api_type & TEST_RING_BR) =3D=3D TEST_RING_BR) > > > + printf("burst\n"); > > > +} > > > + > > > /* > > > * helper routine for test_ring_basic > > > */ > > > @@ -314,286 +360,203 @@ test_ring_basic(struct rte_ring *r) > > > return -1; > > > } > > > > > > +/* > > > + * Burst and bulk operations with sp/sc, mp/mc and default (during > > > +creation) */ > > > static int > > > -test_ring_burst_basic(struct rte_ring *r) > > > +test_ring_burst_bulk_tests(unsigned int api_type) > > > { > > > + struct rte_ring *r; > > > void **src =3D NULL, **cur_src =3D NULL, **dst =3D NULL, **cur_dst = =3D NULL; > > > int ret; > > > - unsigned i; > > > + unsigned int i, j; > > > + unsigned int num_elems; > > > > > > - /* alloc dummy object pointers */ > > > - src =3D malloc(RING_SIZE*2*sizeof(void *)); > > > - if (src =3D=3D NULL) > > > - goto fail; > > > - > > > - for (i =3D 0; i < RING_SIZE*2 ; i++) { > > > - src[i] =3D (void *)(unsigned long)i; > > > - } > > > - cur_src =3D src; > > > + for (i =3D 0; i < RTE_DIM(esize); i++) { > > > + test_ring_print_test_string("Test standard ring", api_type, > > > + esize[i]); > > > > > > - /* alloc some room for copied objects */ > > > - dst =3D malloc(RING_SIZE*2*sizeof(void *)); > > > - if (dst =3D=3D NULL) > > > - goto fail; > > > + /* Create the ring */ > > > + TEST_RING_CREATE("test_ring_burst_bulk_tests", esize[i], > > > + RING_SIZE, SOCKET_ID_ANY, 0, r); > > > > > > - memset(dst, 0, RING_SIZE*2*sizeof(void *)); > > > - cur_dst =3D dst; > > > - > > > - printf("Test SP & SC basic functions \n"); > > > - printf("enqueue 1 obj\n"); > > > - ret =3D rte_ring_sp_enqueue_burst(r, cur_src, 1, NULL); > > > - cur_src +=3D 1; > > > - if (ret !=3D 1) > > > - goto fail; > > > - > > > - printf("enqueue 2 objs\n"); > > > - ret =3D rte_ring_sp_enqueue_burst(r, cur_src, 2, NULL); > > > - cur_src +=3D 2; > > > - if (ret !=3D 2) > > > - goto fail; > > > - > > > - printf("enqueue MAX_BULK objs\n"); > > > - ret =3D rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL); > > > - cur_src +=3D MAX_BULK; > > > - if (ret !=3D MAX_BULK) > > > - goto fail; > > > - > > > - printf("dequeue 1 obj\n"); > > > - ret =3D rte_ring_sc_dequeue_burst(r, cur_dst, 1, NULL); > > > - cur_dst +=3D 1; > > > - if (ret !=3D 1) > > > - goto fail; > > > - > > > - printf("dequeue 2 objs\n"); > > > - ret =3D rte_ring_sc_dequeue_burst(r, cur_dst, 2, NULL); > > > - cur_dst +=3D 2; > > > - if (ret !=3D 2) > > > - goto fail; > > > + /* alloc dummy object pointers */ > > > + src =3D test_ring_calloc(RING_SIZE * 2, esize[i]); > > > + if (src =3D=3D NULL) > > > + goto fail; > > > + test_ring_mem_init(src, RING_SIZE * 2, esize[i]); > > > + cur_src =3D src; > > > > > > - printf("dequeue MAX_BULK objs\n"); > > > - ret =3D rte_ring_sc_dequeue_burst(r, cur_dst, MAX_BULK, NULL); > > > - cur_dst +=3D MAX_BULK; > > > - if (ret !=3D MAX_BULK) > > > - goto fail; > > > + /* alloc some room for copied objects */ > > > + dst =3D test_ring_calloc(RING_SIZE * 2, esize[i]); > > > + if (dst =3D=3D NULL) > > > + goto fail; > > > + cur_dst =3D dst; > > > > > > - /* check data */ > > > - if (memcmp(src, dst, cur_dst - dst)) { > > > - rte_hexdump(stdout, "src", src, cur_src - src); > > > - rte_hexdump(stdout, "dst", dst, cur_dst - dst); > > > - printf("data after dequeue is not the same\n"); > > > - goto fail; > > > - } > > > + printf("enqueue 1 obj\n"); > > > + TEST_RING_ENQUEUE(r, cur_src, esize[i], 1, ret, api_type); > > > + if (ret !=3D 1) > > > + goto fail; > > > + TEST_RING_INCP(cur_src, esize[i], 1); > > > > > > - cur_src =3D src; > > > - cur_dst =3D dst; > > > + printf("enqueue 2 objs\n"); > > > + TEST_RING_ENQUEUE(r, cur_src, esize[i], 2, ret, api_type); > > > + if (ret !=3D 2) > > > + goto fail; > > > + TEST_RING_INCP(cur_src, esize[i], 2); > > > > > > - printf("Test enqueue without enough memory space \n"); > > > - for (i =3D 0; i< (RING_SIZE/MAX_BULK - 1); i++) { > > > - ret =3D rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, > > NULL); > > > - cur_src +=3D MAX_BULK; > > > + printf("enqueue MAX_BULK objs\n"); > > > + TEST_RING_ENQUEUE(r, cur_src, esize[i], MAX_BULK, ret, > > > + api_type); > > > if (ret !=3D MAX_BULK) > > > goto fail; > > > - } > > > - > > > - printf("Enqueue 2 objects, free entries =3D MAX_BULK - 2 \n"); > > > - ret =3D rte_ring_sp_enqueue_burst(r, cur_src, 2, NULL); > > > - cur_src +=3D 2; > > > - if (ret !=3D 2) > > > - goto fail; > > > + TEST_RING_INCP(cur_src, esize[i], MAX_BULK); > > > > > > - printf("Enqueue the remaining entries =3D MAX_BULK - 2 \n"); > > > - /* Always one free entry left */ > > > - ret =3D rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL); > > > - cur_src +=3D MAX_BULK - 3; > > > - if (ret !=3D MAX_BULK - 3) > > > - goto fail; > > > - > > > - printf("Test if ring is full \n"); > > > - if (rte_ring_full(r) !=3D 1) > > > - goto fail; > > > + printf("dequeue 1 obj\n"); > > > + TEST_RING_DEQUEUE(r, cur_dst, esize[i], 1, ret, api_type); > > > + if (ret !=3D 1) > > > + goto fail; > > > + TEST_RING_INCP(cur_dst, esize[i], 1); > > > > > > - printf("Test enqueue for a full entry \n"); > > > - ret =3D rte_ring_sp_enqueue_burst(r, cur_src, MAX_BULK, NULL); > > > - if (ret !=3D 0) > > > - goto fail; > > > + printf("dequeue 2 objs\n"); > > > + TEST_RING_DEQUEUE(r, cur_dst, esize[i], 2, ret, api_type); > > > + if (ret !=3D 2) > > > + goto fail; > > > + TEST_RING_INCP(cur_dst, esize[i], 2); > > > > > > - printf("Test dequeue without enough objects \n"); > > > - for (i =3D 0; i > > - ret =3D rte_ring_sc_dequeue_burst(r, cur_dst, MAX_BULK, > > NULL); > > > - cur_dst +=3D MAX_BULK; > > > + printf("dequeue MAX_BULK objs\n"); > > > + TEST_RING_DEQUEUE(r, cur_dst, esize[i], MAX_BULK, ret, > > > + api_type); > > > if (ret !=3D MAX_BULK) > > > goto fail; > > > - } > > > - > > > - /* Available memory space for the exact MAX_BULK entries */ > > > - ret =3D rte_ring_sc_dequeue_burst(r, cur_dst, 2, NULL); > > > - cur_dst +=3D 2; > > > - if (ret !=3D 2) > > > - goto fail; > > > - > > > - ret =3D rte_ring_sc_dequeue_burst(r, cur_dst, MAX_BULK, NULL); > > > - cur_dst +=3D MAX_BULK - 3; > > > - if (ret !=3D MAX_BULK - 3) > > > - goto fail; > > > - > > > - printf("Test if ring is empty \n"); > > > - /* Check if ring is empty */ > > > - if (1 !=3D rte_ring_empty(r)) > > > - goto fail; > > > - > > > - /* check data */ > > > - if (memcmp(src, dst, cur_dst - dst)) { > > > - rte_hexdump(stdout, "src", src, cur_src - src); > > > - rte_hexdump(stdout, "dst", dst, cur_dst - dst); > > > - printf("data after dequeue is not the same\n"); > > > - goto fail; > > > - } > > > + TEST_RING_INCP(cur_dst, esize[i], MAX_BULK); > > > > > > - cur_src =3D src; > > > - cur_dst =3D dst; > > > - > > > - printf("Test MP & MC basic functions \n"); > > > - > > > - printf("enqueue 1 obj\n"); > > > - ret =3D rte_ring_mp_enqueue_burst(r, cur_src, 1, NULL); > > > - cur_src +=3D 1; > > > - if (ret !=3D 1) > > > - goto fail; > > > - > > > - printf("enqueue 2 objs\n"); > > > - ret =3D rte_ring_mp_enqueue_burst(r, cur_src, 2, NULL); > > > - cur_src +=3D 2; > > > - if (ret !=3D 2) > > > - goto fail; > > > - > > > - printf("enqueue MAX_BULK objs\n"); > > > - ret =3D rte_ring_mp_enqueue_burst(r, cur_src, MAX_BULK, NULL); > > > - cur_src +=3D MAX_BULK; > > > - if (ret !=3D MAX_BULK) > > > - goto fail; > > > - > > > - printf("dequeue 1 obj\n"); > > > - ret =3D rte_ring_mc_dequeue_burst(r, cur_dst, 1, NULL); > > > - cur_dst +=3D 1; > > > - if (ret !=3D 1) > > > - goto fail; > > > - > > > - printf("dequeue 2 objs\n"); > > > - ret =3D rte_ring_mc_dequeue_burst(r, cur_dst, 2, NULL); > > > - cur_dst +=3D 2; > > > - if (ret !=3D 2) > > > - goto fail; > > > - > > > - printf("dequeue MAX_BULK objs\n"); > > > - ret =3D rte_ring_mc_dequeue_burst(r, cur_dst, MAX_BULK, NULL); > > > - cur_dst +=3D MAX_BULK; > > > - if (ret !=3D MAX_BULK) > > > - goto fail; > > > - > > > - /* check data */ > > > - if (memcmp(src, dst, cur_dst - dst)) { > > > - rte_hexdump(stdout, "src", src, cur_src - src); > > > - rte_hexdump(stdout, "dst", dst, cur_dst - dst); > > > - printf("data after dequeue is not the same\n"); > > > - goto fail; > > > - } > > > - > > > - cur_src =3D src; > > > - cur_dst =3D dst; > > > + /* check data */ > > > + if (memcmp(src, dst, cur_dst - dst)) { > > > + rte_hexdump(stdout, "src", src, cur_src - src); > > > + rte_hexdump(stdout, "dst", dst, cur_dst - dst); > > > + printf("data after dequeue is not the same\n"); > > > + goto fail; > > > + } > > > + > > > + cur_src =3D src; > > > + cur_dst =3D dst; > > > + > > > + printf("fill and empty the ring\n"); > > > + for (j =3D 0; j < RING_SIZE / MAX_BULK; j++) { > > > + TEST_RING_ENQUEUE(r, cur_src, esize[i], MAX_BULK, > > > + ret, api_type); > > > + if (ret !=3D MAX_BULK) > > > + goto fail; > > > + TEST_RING_INCP(cur_src, esize[i], MAX_BULK); > > > + > > > + TEST_RING_DEQUEUE(r, cur_dst, esize[i], MAX_BULK, > > > + ret, api_type); > > > + if (ret !=3D MAX_BULK) > > > + goto fail; > > > + TEST_RING_INCP(cur_dst, esize[i], MAX_BULK); > > > + } > > > > > > - printf("fill and empty the ring\n"); > > > - for (i =3D 0; i > > - ret =3D rte_ring_mp_enqueue_burst(r, cur_src, MAX_BULK, > > NULL); > > > - cur_src +=3D MAX_BULK; > > > - if (ret !=3D MAX_BULK) > > > + /* check data */ > > > + if (memcmp(src, dst, cur_dst - dst)) { > > > + rte_hexdump(stdout, "src", src, cur_src - src); > > > + rte_hexdump(stdout, "dst", dst, cur_dst - dst); > > > + printf("data after dequeue is not the same\n"); > > > goto fail; > > > - ret =3D rte_ring_mc_dequeue_burst(r, cur_dst, MAX_BULK, > > NULL); > > > - cur_dst +=3D MAX_BULK; > > > - if (ret !=3D MAX_BULK) > > > + } > > > + > > > + cur_src =3D src; > > > + cur_dst =3D dst; > > > + > > > + printf("Test enqueue without enough memory space\n"); > > > + for (j =3D 0; j < (RING_SIZE/MAX_BULK - 1); j++) { > > > + TEST_RING_ENQUEUE(r, cur_src, esize[i], MAX_BULK, > > > + ret, api_type); > > > + if (ret !=3D MAX_BULK) > > > + goto fail; > > > + TEST_RING_INCP(cur_src, esize[i], MAX_BULK); > > > + } > > > + > > > + printf("Enqueue 2 objects, free entries =3D MAX_BULK - 2\n"); > > > + TEST_RING_ENQUEUE(r, cur_src, esize[i], 2, ret, api_type); > > > + if (ret !=3D 2) > > > goto fail; > > > - } > > > - > > > - /* check data */ > > > - if (memcmp(src, dst, cur_dst - dst)) { > > > - rte_hexdump(stdout, "src", src, cur_src - src); > > > - rte_hexdump(stdout, "dst", dst, cur_dst - dst); > > > - printf("data after dequeue is not the same\n"); > > > - goto fail; > > > - } > > > - > > > - cur_src =3D src; > > > - cur_dst =3D dst; > > > - > > > - printf("Test enqueue without enough memory space \n"); > > > - for (i =3D 0; i > > - ret =3D rte_ring_mp_enqueue_burst(r, cur_src, MAX_BULK, > > NULL); > > > - cur_src +=3D MAX_BULK; > > > - if (ret !=3D MAX_BULK) > > > + TEST_RING_INCP(cur_src, esize[i], 2); > > > + > > > + > > > + printf("Enqueue the remaining entries =3D MAX_BULK - 3\n"); > > > + /* Bulk APIs enqueue exact number of elements */ > > > + if ((api_type & TEST_RING_BL) =3D=3D TEST_RING_BL) > > > + num_elems =3D MAX_BULK - 3; > > > + else > > > + num_elems =3D MAX_BULK; > > > + /* Always one free entry left */ > > > + TEST_RING_ENQUEUE(r, cur_src, esize[i], num_elems, > > > + ret, api_type); > > > + if (ret !=3D MAX_BULK - 3) > > > goto fail; > > > - } > > > - > > > - /* Available memory space for the exact MAX_BULK objects */ > > > - ret =3D rte_ring_mp_enqueue_burst(r, cur_src, 2, NULL); > > > - cur_src +=3D 2; > > > - if (ret !=3D 2) > > > - goto fail; > > > + TEST_RING_INCP(cur_src, esize[i], MAX_BULK - 3); > > > > > > - ret =3D rte_ring_mp_enqueue_burst(r, cur_src, MAX_BULK, NULL); > > > - cur_src +=3D MAX_BULK - 3; > > > - if (ret !=3D MAX_BULK - 3) > > > - goto fail; > > > + printf("Test if ring is full\n"); > > > + if (rte_ring_full(r) !=3D 1) > > > + goto fail; > > > > > > + printf("Test enqueue for a full entry\n"); > > > + TEST_RING_ENQUEUE(r, cur_src, esize[i], MAX_BULK, > > > + ret, api_type); > > > + if (ret !=3D 0) > > > + goto fail; > > > > > > - printf("Test dequeue without enough objects \n"); > > > - for (i =3D 0; i > > - ret =3D rte_ring_mc_dequeue_burst(r, cur_dst, MAX_BULK, > > NULL); > > > - cur_dst +=3D MAX_BULK; > > > - if (ret !=3D MAX_BULK) > > > + printf("Test dequeue without enough objects\n"); > > > + for (j =3D 0; j < RING_SIZE / MAX_BULK - 1; j++) { > > > + TEST_RING_DEQUEUE(r, cur_dst, esize[i], MAX_BULK, > > > + ret, api_type); > > > + if (ret !=3D MAX_BULK) > > > + goto fail; > > > + TEST_RING_INCP(cur_dst, esize[i], MAX_BULK); > > > + } > > > + > > > + /* Available memory space for the exact MAX_BULK entries > > */ > > > + TEST_RING_DEQUEUE(r, cur_dst, esize[i], 2, ret, api_type); > > > + if (ret !=3D 2) > > > goto fail; > > > - } > > > + TEST_RING_INCP(cur_dst, esize[i], 2); > > > + > > > + /* Bulk APIs enqueue exact number of elements */ > > > + if ((api_type & TEST_RING_BL) =3D=3D TEST_RING_BL) > > > + num_elems =3D MAX_BULK - 3; > > > + else > > > + num_elems =3D MAX_BULK; > > > + TEST_RING_DEQUEUE(r, cur_dst, esize[i], num_elems, > > > + ret, api_type); > > > + if (ret !=3D MAX_BULK - 3) > > > + goto fail; > > > + TEST_RING_INCP(cur_dst, esize[i], MAX_BULK - 3); > > > > > > - /* Available objects - the exact MAX_BULK */ > > > - ret =3D rte_ring_mc_dequeue_burst(r, cur_dst, 2, NULL); > > > - cur_dst +=3D 2; > > > - if (ret !=3D 2) > > > - goto fail; > > > + printf("Test if ring is empty\n"); > > > + /* Check if ring is empty */ > > > + if (rte_ring_empty(r) !=3D 1) > > > + goto fail; > > > > > > - ret =3D rte_ring_mc_dequeue_burst(r, cur_dst, MAX_BULK, NULL); > > > - cur_dst +=3D MAX_BULK - 3; > > > - if (ret !=3D MAX_BULK - 3) > > > - goto fail; > > > + /* check data */ > > > + if (memcmp(src, dst, cur_dst - dst)) { > > > + rte_hexdump(stdout, "src", src, cur_src - src); > > > + rte_hexdump(stdout, "dst", dst, cur_dst - dst); > > > + printf("data after dequeue is not the same\n"); > > > + goto fail; > > > + } > > > > > > - /* check data */ > > > - if (memcmp(src, dst, cur_dst - dst)) { > > > - rte_hexdump(stdout, "src", src, cur_src - src); > > > - rte_hexdump(stdout, "dst", dst, cur_dst - dst); > > > - printf("data after dequeue is not the same\n"); > > > - goto fail; > > > + /* Free memory before test completed */ > > > + rte_ring_free(r); > > > + rte_free(src); > > > + rte_free(dst); > > > } > > > > > > - cur_src =3D src; > > > - cur_dst =3D dst; > > > - > > > - printf("Covering rte_ring_enqueue_burst functions \n"); > > > - > > > - ret =3D rte_ring_enqueue_burst(r, cur_src, 2, NULL); > > > - cur_src +=3D 2; > > > - if (ret !=3D 2) > > > - goto fail; > > > - > > > - ret =3D rte_ring_dequeue_burst(r, cur_dst, 2, NULL); > > > - cur_dst +=3D 2; > > > - if (ret !=3D 2) > > > - goto fail; > > > - > > > - /* Free memory before test completed */ > > > - free(src); > > > - free(dst); > > > return 0; > > > - > > > - fail: > > > - free(src); > > > - free(dst); > > > +fail: > > > + rte_ring_free(r); > > > + rte_free(src); > > > + rte_free(dst); > > > return -1; > > > } > > > > > > @@ -810,6 +773,7 @@ test_ring_with_exact_size(void) static int > > > test_ring(void) > > > { > > > + unsigned int i, j; > > > struct rte_ring *r =3D NULL; > > > > > > /* some more basic operations */ > > > @@ -828,9 +792,11 @@ test_ring(void) > > > goto test_fail; > > > } > > > > > > - /* burst operations */ > > > - if (test_ring_burst_basic(r) < 0) > > > - goto test_fail; > > > + /* Burst and bulk operations with sp/sc, mp/mc and default */ > > > + for (j =3D TEST_RING_BL; j <=3D TEST_RING_BR; j <<=3D 1) > > > + for (i =3D TEST_RING_N; i <=3D TEST_RING_M; i <<=3D 1) > > > + if (test_ring_burst_bulk_tests(i | j) < 0) > > > + goto test_fail; > > > > > > /* basic operations */ > > > if (test_ring_basic(r) < 0) > > > diff --git a/app/test/test_ring.h b/app/test/test_ring.h new file mod= e > > > 100644 index 000000000..19ef1b399 > > > --- /dev/null > > > +++ b/app/test/test_ring.h > > > @@ -0,0 +1,203 @@ > > > +/* SPDX-License-Identifier: BSD-3-Clause > > > + * Copyright(c) 2019 Arm Limited > > > + */ > > > + > > > +#include > > > +#include > > > +#include > > > + > > > +/* API type to call > > > + * N - Calls default APIs > > > + * S - Calls SP or SC API > > > + * M - Calls MP or MC API > > > + */ > > > +#define TEST_RING_N 1 > > > +#define TEST_RING_S 2 > > > +#define TEST_RING_M 4 > > > + > > > +/* API type to call > > > + * SL - Calls single element APIs > > > + * BL - Calls bulk APIs > > > + * BR - Calls burst APIs > > > + */ > > > +#define TEST_RING_SL 8 > > > +#define TEST_RING_BL 16 > > > +#define TEST_RING_BR 32 > > > + > > > +#define TEST_RING_IGNORE_API_TYPE ~0U > > > + > > > +#define TEST_RING_INCP(obj, esize, n) do { \ > > > + /* Legacy queue APIs? */ \ > > > + if ((esize) =3D=3D -1) \ > > > + obj =3D ((void **)obj) + n; \ > > > + else \ > > > + obj =3D (void **)(((uint32_t *)obj) + \ > > > + (n * esize / sizeof(uint32_t))); \ } > > while (0) > > > + > > > +#define TEST_RING_CREATE(name, esize, count, socket_id, flags, r) do= { \ > > > + /* Legacy queue APIs? */ \ > > > + if ((esize) =3D=3D -1) \ > > > + r =3D rte_ring_create((name), (count), (socket_id), (flags)); \ > > > + else \ > > > + r =3D rte_ring_create_elem((name), (esize), (count), \ > > > + (socket_id), (flags)); \ > > > +} while (0) > > > + > > > +#define TEST_RING_ENQUEUE(r, obj, esize, n, ret, api_type) do { \ > > > + /* Legacy queue APIs? */ \ > > > + if ((esize) =3D=3D -1) \ > > > + switch (api_type) { \ > > > + case (TEST_RING_N | TEST_RING_SL): \ > > > + ret =3D rte_ring_enqueue(r, obj); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_SL): \ > > > + ret =3D rte_ring_sp_enqueue(r, obj); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_SL): \ > > > + ret =3D rte_ring_mp_enqueue(r, obj); \ > > > + break; \ > > > + case (TEST_RING_N | TEST_RING_BL): \ > > > + ret =3D rte_ring_enqueue_bulk(r, obj, n, NULL); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_BL): \ > > > + ret =3D rte_ring_sp_enqueue_bulk(r, obj, n, NULL); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_BL): \ > > > + ret =3D rte_ring_mp_enqueue_bulk(r, obj, n, NULL); \ > > > + break; \ > > > + case (TEST_RING_N | TEST_RING_BR): \ > > > + ret =3D rte_ring_enqueue_burst(r, obj, n, NULL); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_BR): \ > > > + ret =3D rte_ring_sp_enqueue_burst(r, obj, n, NULL); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_BR): \ > > > + ret =3D rte_ring_mp_enqueue_burst(r, obj, n, NULL); \ > > > + } \ > > > + else \ > > > + switch (api_type) { \ > > > + case (TEST_RING_N | TEST_RING_SL): \ > > > + ret =3D rte_ring_enqueue_elem(r, obj, esize); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_SL): \ > > > + ret =3D rte_ring_sp_enqueue_elem(r, obj, esize); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_SL): \ > > > + ret =3D rte_ring_mp_enqueue_elem(r, obj, esize); \ > > > + break; \ > > > + case (TEST_RING_N | TEST_RING_BL): \ > > > + ret =3D rte_ring_enqueue_bulk_elem(r, obj, esize, n, \ > > > + NULL); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_BL): \ > > > + ret =3D rte_ring_sp_enqueue_bulk_elem(r, obj, esize, n, > > \ > > > + NULL); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_BL): \ > > > + ret =3D rte_ring_mp_enqueue_bulk_elem(r, obj, esize, n, > > \ > > > + NULL); \ > > > + break; \ > > > + case (TEST_RING_N | TEST_RING_BR): \ > > > + ret =3D rte_ring_enqueue_burst_elem(r, obj, esize, n, \ > > > + NULL); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_BR): \ > > > + ret =3D rte_ring_sp_enqueue_burst_elem(r, obj, esize, n, > > \ > > > + NULL); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_BR): \ > > > + ret =3D rte_ring_mp_enqueue_burst_elem(r, obj, esize, > > n, \ > > > + NULL); \ > > > + } \ > > > +} while (0) > > > + > > > +#define TEST_RING_DEQUEUE(r, obj, esize, n, ret, api_type) do { \ > > > + /* Legacy queue APIs? */ \ > > > + if ((esize) =3D=3D -1) \ > > > + switch (api_type) { \ > > > + case (TEST_RING_N | TEST_RING_SL): \ > > > + ret =3D rte_ring_dequeue(r, obj); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_SL): \ > > > + ret =3D rte_ring_sc_dequeue(r, obj); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_SL): \ > > > + ret =3D rte_ring_mc_dequeue(r, obj); \ > > > + break; \ > > > + case (TEST_RING_N | TEST_RING_BL): \ > > > + ret =3D rte_ring_dequeue_bulk(r, obj, n, NULL); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_BL): \ > > > + ret =3D rte_ring_sc_dequeue_bulk(r, obj, n, NULL); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_BL): \ > > > + ret =3D rte_ring_mc_dequeue_bulk(r, obj, n, NULL); \ > > > + break; \ > > > + case (TEST_RING_N | TEST_RING_BR): \ > > > + ret =3D rte_ring_dequeue_burst(r, obj, n, NULL); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_BR): \ > > > + ret =3D rte_ring_sc_dequeue_burst(r, obj, n, NULL); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_BR): \ > > > + ret =3D rte_ring_mc_dequeue_burst(r, obj, n, NULL); \ > > > + } \ > > > + else \ > > > + switch (api_type) { \ > > > + case (TEST_RING_N | TEST_RING_SL): \ > > > + ret =3D rte_ring_dequeue_elem(r, obj, esize); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_SL): \ > > > + ret =3D rte_ring_sc_dequeue_elem(r, obj, esize); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_SL): \ > > > + ret =3D rte_ring_mc_dequeue_elem(r, obj, esize); \ > > > + break; \ > > > + case (TEST_RING_N | TEST_RING_BL): \ > > > + ret =3D rte_ring_dequeue_bulk_elem(r, obj, esize, n, \ > > > + NULL); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_BL): \ > > > + ret =3D rte_ring_sc_dequeue_bulk_elem(r, obj, esize, n, > > \ > > > + NULL); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_BL): \ > > > + ret =3D rte_ring_mc_dequeue_bulk_elem(r, obj, esize, n, > > \ > > > + NULL); \ > > > + break; \ > > > + case (TEST_RING_N | TEST_RING_BR): \ > > > + ret =3D rte_ring_dequeue_burst_elem(r, obj, esize, n, \ > > > + NULL); \ > > > + break; \ > > > + case (TEST_RING_S | TEST_RING_BR): \ > > > + ret =3D rte_ring_sc_dequeue_burst_elem(r, obj, esize, n, > > \ > > > + NULL); \ > > > + break; \ > > > + case (TEST_RING_M | TEST_RING_BR): \ > > > + ret =3D rte_ring_mc_dequeue_burst_elem(r, obj, esize, > > n, \ > > > + NULL); \ > > > + } \ > > > +} while (0) > > > > > > My thought to avoid test-code duplication was a bit different. > Yes, this can be done multiple ways. My implementation is not complicated= either. >=20 > > Instead of adding extra enums/parameters and then do switch on them, my > The switch statement should be removed by the compiler for the performanc= e tests. I am sure the compiler will do its job properly. My concern is that with all these extra flags, it is really hard to read and understand what exactly function we are calling and what we are tr= ying to test. Might be just me, but let say in original version for enqueue_bulk() we hav= e: const uint64_t sp_start =3D rte_rdtsc(); for (i =3D 0; i < iterations; i++) while (rte_ring_sp_enqueue_bulk(r, burst, size, NULL) =3D= =3D 0) rte_pause(); const uint64_t sp_end =3D rte_rdtsc(); const uint64_t mp_start =3D rte_rdtsc(); for (i =3D 0; i < iterations; i++) while (rte_ring_mp_enqueue_bulk(r, burst, size, NULL) =3D= =3D 0) rte_pause(); const uint64_t mp_end =3D rte_rdtsc(); Simple and easy to understand. Same code after the patch doesn't that straightforward anymore: const uint64_t sp_start =3D rte_rdtsc(); for (i =3D 0; i < iterations; i++) do { if (flag =3D=3D 0) TEST_RING_ENQUEUE(r, burst, esize, bsize, r= et, TEST_RING_S | TEST_RING_BL)= ; else if (flag =3D=3D 1) TEST_RING_DEQUEUE(r, burst, esize, bsize, r= et, TEST_RING_S | TEST_RING_BL)= ; if (ret =3D=3D 0) rte_pause(); } while (!ret); const uint64_t sp_end =3D rte_rdtsc(); Another thing - if tomorrow we'll want to add perf tests for elem_size=3D=3D4/8, etc. - we'll need to do copy/paste for all test-case invocations, as you did for 16B (or some code reorg).=20 >=20 > > intention was something like that: > > > > 1. mv test_ring_perf.c test_ring_perf.h 2. Inside test_ring_perf.h cha= nge > > rte_ring_ create/enqueue/dequeue function > > calls to some not-defined function/macros invocations. > > With similar name, same number of parameters, and same semantics. > > Also change 'void *burst[..]' to 'RING_ELEM[...]'; 3. For each test > > configuration we want to have (default, 4B, 8B, 16B) > > create a new .c file where we: > > - define used in test_ring_perf.h macros(/function) > > - include test_ring_perf.h > > - REGISTER_TEST_COMMAND(, test_ring_perf); > > > > As an example: > > test_ring_perf.h: > > ... > > static int > > enqueue_bulk(void *p) > > { > > ... > > RING_ELEM burst[MAX_BURST]; > > > > memset(burst, 0, sizeof(burst)); > > .... > > const uint64_t sp_start =3D rte_rdtsc(); > > for (i =3D 0; i < iterations; i++) > > while (RING_SP_ENQUEUE_BULK(r, burst, size, NULL) =3D= =3D 0) > > rte_pause(); > > const uint64_t sp_end =3D rte_rdtsc(); > > > > const uint64_t mp_start =3D rte_rdtsc(); > > for (i =3D 0; i < iterations; i++) > > while (RING_MP_ENQUEUE_BULK(r, burst, size, NULL) =3D= =3D 0) > > rte_pause(); > > const uint64_t mp_end =3D rte_rdtsc(); > > .... > > > > Then in test_ring_perf.c: > > > > .... > > #define RING_ELEM void * > > ... > > #define RING_SP_ENQUEUE_BULK(ring, buf, size, spc) \ > > rte_ring_sp_enqueue_bulk(ring, buf, size, spc) .... > > > > #include "test_ring_perf.h" > > REGISTER_TEST_COMMAND(ring_perf_autotest, test_ring_perf); > > > > > > In test_ring_elem16B_perf.c: > > .... > > #define RING_ELEM __uint128_t > > #define RING_SP_ENQUEUE_BULK(ring, buf, size, spc) \ > > rte_ring_sp_enqueue_bulk_elem(ring, buf, sizeof(RING_ELEM), size, > > spc) .... > > #include "test_ring_perf.h" > > REGISTER_TEST_COMMAND(ring_perf_elem16B_autotest, test_ring_perf); > > > > In test_ring_elem4B_per.c: > > > > .... > > #define RING_ELEM uint32_t > > #define RING_SP_ENQUEUE_BULK(ring, buf, size, spc) \ > > rte_ring_sp_enqueue_bulk_elem(ring, buf, sizeof(RING_ELEM), size, > > spc) .... > > #include "test_ring_perf.h" > > REGISTER_TEST_COMMAND(ring_perf_elem4B_autotest, test_ring_perf); > > > > And so on. > > > > > + > > > +/* This function is placed here as it is required for both > > > + * performance and functional tests. > > > + */ > > > +static __rte_always_inline void * > > > +test_ring_calloc(unsigned int rsize, int esize) { > > > + unsigned int sz; > > > + void *p; > > > + > > > + /* Legacy queue APIs? */ > > > + if (esize =3D=3D -1) > > > + sz =3D sizeof(void *); > > > + else > > > + sz =3D esize; > > > + > > > + p =3D rte_zmalloc(NULL, rsize * sz, RTE_CACHE_LINE_SIZE); > > > + if (p =3D=3D NULL) > > > + printf("Failed to allocate memory\n"); > > > + > > > + return p; > > > +} > > > -- > > > 2.17.1