From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-eopbgr820051.outbound.protection.outlook.com [40.107.82.51]) by dpdk.org (Postfix) with ESMTP id 2503014EC for ; Tue, 6 Nov 2018 16:37:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UGsd6VWZmz23flyZWmFcbx4UeRFLqIrEE5d3OKw7dEg=; b=VnTOXwdNg29X2HNoCGjC8Jmz8aoBZFbusFyMz0PCtJgpjBiBxfWS+TyngbXRO3l128+31IAwCfgGpLtcgrPQ1MOCjZlwmLuoP1fSGXlXJp3Zx6XNcc4yp6/YAv84eGbqOmkAX03pOfhmSwCSiSGErhjsXwPs3hxi2jKnu7/c+kk= Received: from SN6PR07MB5152.namprd07.prod.outlook.com (52.135.101.33) by SN6PR07MB4287.namprd07.prod.outlook.com (52.135.89.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Tue, 6 Nov 2018 15:37:18 +0000 Received: from SN6PR07MB5152.namprd07.prod.outlook.com ([fe80::49cb:b2a:974:2211]) by SN6PR07MB5152.namprd07.prod.outlook.com ([fe80::49cb:b2a:974:2211%4]) with mapi id 15.20.1294.034; Tue, 6 Nov 2018 15:37:18 +0000 From: "Verma, Shally" To: "Jozwiak, TomaszX" , "dev@dpdk.org" , "Trahe, Fiona" , "akhil.goyal@nxp.com" Thread-Topic: [PATCH v2 2/3] app/compress-perf: add performance measurement Thread-Index: AQHUcpCcS5ESYz6wkEqWlqsL+AItVqVA5DbQgAGR3ICAAHEV4A== Date: Tue, 6 Nov 2018 15:37:18 +0000 Message-ID: References: <1538400427-20164-1-git-send-email-tomaszx.jozwiak@intel.com> <1541151842-8746-1-git-send-email-tomaszx.jozwiak@intel.com> <1541151842-8746-3-git-send-email-tomaszx.jozwiak@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; x-originating-ip: [223.230.32.215] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SN6PR07MB4287; 6:KVm64fe1wDac2BszqNVsVdVSIX8yDOrYI50tjylemuwM0n9LzjBhB4SxOKRc+h1gy8caLVINawYLnqUaYTtlMS3Vlbzoi+q4ac4HWBYTXWkM7/CUdqbq3BmXXCgo0RloTW3mrciHvQz1qrGBhVlaqkyJgPalA44jqucsczP2S+5731+hiyqgwlspCSxo5fJs0xFmOCYvdIVKnoYODZnkjJxt/XeXLTAoYeT56WVG3wzyGCW/IA8yZuTBYfuHeqhSB7CtrIUzAnoC45gu2XEjD0Up2TqC5E4CYp4QCCUWrp0cbUeJdFJP4AWy6eRcUP5peb88HnFd7e3A+jZRi8CuvCS7DX/VW22bOgjzswOOAYlPPJAMi2dVpLiAs1Wlrg2EMib5v2asmSBhRah8+I0XtawQ6GUAKy6YKI/D4PTwtP/VFPCvfB9XTvH5RJTWsi+N/r7/pT07an/pul3/ZD/faw==; 5:S7zUT1wpmS3RagYc0irLdkU3/5vlKxwtvwi+xXfMxmD5e8I5Bzfkq0AbhQdasm6jS+ukt1hRusiGMUccqcoR8LNEz0gl+mdIA4GRF7O30GSq6M8m0E0jkFe95IrPow9avjfm6PiGAvKAWtASZG54xlfV5KT1n7Bs2keQq6/vyUM=; 7:x3mnPfwMZIZ8Yrn/FJzim71l2zNTkAsoOHWtcfxE2BVKbSc8grj6/ggAeDr7BssY+NcXd1OBbHuRvRcha3i0qP3Ee/8++E9NZXt5uOGAZKAMMNFVrZmboFUHdTCk4zkpFj4glhIh26fMRHPpuW2DQA== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 7cd9ab34-39be-42ff-cd9d-08d643fdbc27 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:SN6PR07MB4287; x-ms-traffictypediagnostic: SN6PR07MB4287: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:SN6PR07MB4287; BCL:0; PCL:0; RULEID:; SRVR:SN6PR07MB4287; x-forefront-prvs: 0848C1A6AA x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(39860400002)(376002)(346002)(136003)(199004)(189003)(13464003)(2900100001)(446003)(110136005)(5660300001)(11346002)(93886005)(33656002)(72206003)(316002)(486006)(476003)(97736004)(6436002)(76176011)(55016002)(9686003)(7696005)(53946003)(2501003)(53936002)(186003)(102836004)(26005)(6506007)(53546011)(25786009)(478600001)(6246003)(66066001)(99286004)(2906002)(8936002)(229853002)(14454004)(81156014)(8676002)(81166006)(3846002)(71200400001)(6116002)(71190400001)(106356001)(86362001)(105586002)(305945005)(7736002)(74316002)(68736007)(256004)(4744004); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR07MB4287; H:SN6PR07MB5152.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: WK2u9IvVgB70F01jftueUeBtJQIYzbBvmAOsk6Bl5an5kvDmH1bBTRBRJUStU8FehuH/zEXlw9ChPVCqGqxSXEPSsrAiKJ7NbTI8gtFL0fAHsQXPtzJMb5SNwtIc9yvh7csbz2eS0pD7/kjnizVRIxOqalPExaczKC3xHKmGU6t2DaZU5GhT+dYh9cHBL9N9eJLv0GOyt5g6DRi21vYYl0rjrpf3VMDL+kFakMTu+guQSJ5XyBQrTFx+lwel5xc6hUs0IT38n++DuCZaqBG9EtUr9SR08VPauloc+usb6qKR8myoeHV8bcwrt8fZIC02QA5LduHh1xer0ZG+HAQrha0YpjloTMaHZWph3P6GD7I= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7cd9ab34-39be-42ff-cd9d-08d643fdbc27 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2018 15:37:18.0695 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB4287 Subject: Re: [dpdk-dev] [PATCH v2 2/3] app/compress-perf: add performance measurement 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, 06 Nov 2018 15:37:20 -0000 >-----Original Message----- >From: Jozwiak, TomaszX >Sent: 06 November 2018 14:19 >To: Verma, Shally ; dev@dpdk.org; Trahe, Fiona ; akhil.goyal@nxp.com >Subject: RE: [PATCH v2 2/3] app/compress-perf: add performance measurement > >External Email > >> -----Original Message----- >> From: Verma, Shally [mailto:Shally.Verma@cavium.com] >> Sent: Monday, November 5, 2018 9:57 AM >> To: Jozwiak, TomaszX ; dev@dpdk.org; Trahe, >> Fiona ; akhil.goyal@nxp.com >> Subject: RE: [PATCH v2 2/3] app/compress-perf: add performance >> measurement >> >> >> >> >-----Original Message----- >> >From: Tomasz Jozwiak >> >Sent: 02 November 2018 15:14 >> >To: dev@dpdk.org; fiona.trahe@intel.com; tomaszx.jozwiak@intel.com; >> >Verma, Shally ; akhil.goyal@nxp.com >> >Subject: [PATCH v2 2/3] app/compress-perf: add performance >> measurement >> > >> >External Email >> > >> >Added performance measurement part into compression perf. test. >> > >> >Signed-off-by: De Lara Guarch, Pablo >> >Signed-off-by: Tomasz Jozwiak >> >--- >> > app/test-compress-perf/comp_perf_options_parse.c | 8 +- >> > app/test-compress-perf/main.c | 886 >> ++++++++++++++++++++++- >> > 2 files changed, 883 insertions(+), 11 deletions(-) >> > >> >diff --git a/app/test-compress-perf/comp_perf_options_parse.c >> >b/app/test-compress-perf/comp_perf_options_parse.c >> >index bef4d2f..e5da3ad 100644 >> >--- a/app/test-compress-perf/comp_perf_options_parse.c >> >+++ b/app/test-compress-perf/comp_perf_options_parse.c >> >@@ -431,10 +431,6 @@ parse_huffman_enc(struct comp_test_data >> *test_data, const char *arg) >> > { >> > "fixed", >> > RTE_COMP_HUFFMAN_FIXED >> >- }, >> >- { >> >- "dynamic", >> >- RTE_COMP_HUFFMAN_DYNAMIC >> > } >> > }; >> > >> >@@ -569,9 +565,9 @@ comp_perf_options_default(struct comp_test_data >> *test_data) >> > test_data->seg_sz =3D 2048; >> > test_data->burst_sz =3D 32; >> > test_data->pool_sz =3D 8192; >> >- test_data->max_sgl_segs =3D UINT16_MAX; >> >+ test_data->max_sgl_segs =3D 16; >> > test_data->num_iter =3D 10000; >> >- test_data->huffman_enc =3D RTE_COMP_HUFFMAN_DYNAMIC; >> >+ test_data->huffman_enc =3D RTE_COMP_HUFFMAN_FIXED; >> > test_data->test_op =3D COMPRESS_DECOMPRESS; >> > test_data->window_sz =3D -1; >> > test_data->level.min =3D 1; >> >diff --git a/app/test-compress-perf/main.c >> >b/app/test-compress-perf/main.c index f52b98d..e3f4bf6 100644 >> >--- a/app/test-compress-perf/main.c >> >+++ b/app/test-compress-perf/main.c >> >@@ -5,14 +5,728 @@ >> > #include >> > #include >> > #include >> >+#include >> > #include >> > >> > #include "comp_perf_options.h" >> > >> >+#define NUM_MAX_XFORMS 16 >> >+#define NUM_MAX_INFLIGHT_OPS 512 >> >+#define EXPANSE_RATIO 1.05 >> >+#define MIN_ISAL_SIZE 8 >> Can we avoid ISAL specific naming ? > >TJ: yes true :) will be fixed in V3 > > > > >> >+ >> >+#define DIV_CEIL(a, b) ((a) / (b) + ((a) % (b) !=3D 0)) >> >+ >> >+/* Cleanup state machine */ >> >+static enum cleanup_st { >> >+ ST_CLEAR =3D 0, >> >+ ST_TEST_DATA, >> >+ ST_COMPDEV, >> >+ ST_INPUT_DATA, >> >+ ST_MEMORY_ALLOC, >> >+ ST_PREPARE_BUF, >> >+ ST_DURING_TEST >> >+} cleanup =3D ST_CLEAR; >> >+ >> >+static int >> >+param_range_check(uint16_t size, const struct rte_param_log2_range >> >+*range) { >> >+ unsigned int next_size; >> >+ >> >+ /* Check lower/upper bounds */ >> >+ if (size < range->min) >> >+ return -1; >> >+ >> >+ if (size > range->max) >> >+ return -1; >> >+ >> >+ /* If range is actually only one value, size is correct */ >> >+ if (range->increment =3D=3D 0) >> >+ return 0; >> >+ >> >+ /* Check if value is one of the supported sizes */ >> >+ for (next_size =3D range->min; next_size <=3D range->max; >> >+ next_size +=3D range->increment) >> >+ if (size =3D=3D next_size) >> >+ return 0; >> >+ >> >+ return -1; >> >+} >> >+ >> >+static int >> >+comp_perf_check_capabilities(struct comp_test_data *test_data) { >> >+ const struct rte_compressdev_capabilities *cap; >> >+ >> >+ cap =3D rte_compressdev_capability_get(test_data->cdev_id, >> >+ RTE_COMP_ALGO_DEFLATE); >> >+ >> >+ if (cap =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, >> >+ "Compress device does not support DEFLATE\n"); >> >+ return -1; >> >+ } >> >+ >> >+ uint64_t comp_flags =3D cap->comp_feature_flags; >> >+ >> >+ /* Huffman enconding */ >> >+ if (test_data->huffman_enc =3D=3D RTE_COMP_HUFFMAN_FIXED && >> >+ (comp_flags & RTE_COMP_FF_HUFFMAN_FIXED) =3D=3D= 0) { >> >+ RTE_LOG(ERR, USER1, >> >+ "Compress device does not supported Fixed Huffm= an\n"); >> >+ return -1; >> >+ } >> >+ >> >+ if (test_data->huffman_enc =3D=3D RTE_COMP_HUFFMAN_DYNAMIC && >> >+ (comp_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) =3D= =3D 0) { >> >+ RTE_LOG(ERR, USER1, >> >+ "Compress device does not supported Dynamic Huf= fman\n"); >> >+ return -1; >> >+ } >> >+ >> >+ /* Window size */ >> >+ if (test_data->window_sz !=3D -1) { >> >+ if (param_range_check(test_data->window_sz, &cap- >> >window_size) >> >+ < 0) { >> >+ RTE_LOG(ERR, USER1, >> >+ "Compress device does not support " >> >+ "this window size\n"); >> >+ return -1; >> >+ } >> >+ } else >> >+ /* Set window size to PMD maximum if none was specified= */ >> >+ test_data->window_sz =3D cap->window_size.max; >> >+ >> >+ /* Check if chained mbufs is supported */ >> >+ if (test_data->max_sgl_segs > 1 && >> >+ (comp_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) = =3D=3D 0) { >> >+ RTE_LOG(INFO, USER1, "Compress device does not support = " >> >+ "chained mbufs. Max SGL segments set to= 1\n"); >> >+ test_data->max_sgl_segs =3D 1; >> >+ } >> >+ >> >+ /* Level 0 support */ >> >+ if (test_data->level.min =3D=3D 0 && >> >+ (comp_flags & RTE_COMP_FF_NONCOMPRESSED_BLOCKS)= =3D=3D >> 0) { >> >+ RTE_LOG(ERR, USER1, "Compress device does not support " >> >+ "level 0 (no compression)\n"); >> >+ return -1; >> >+ } >> >+ >> >+ return 0; >> >+} >> >+ >> >+static int >> >+comp_perf_allocate_memory(struct comp_test_data *test_data) { >> >+ /* Number of segments for input and output >> >+ * (compression and decompression) >> >+ */ >> >+ uint32_t total_segs =3D DIV_CEIL(test_data->input_data_sz, >> >+ test_data->seg_sz); >> >+ test_data->comp_buf_pool =3D >> rte_pktmbuf_pool_create("comp_buf_pool", >> >+ total_segs, >> >+ 0, 0, test_data->seg_sz + RTE_PKTMBUF_H= EADROOM, >> >+ rte_socket_id()); >> >+ if (test_data->comp_buf_pool =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Mbuf mempool could not be created\= n"); >> >+ return -1; >> >+ } >> >+ >> >+ cleanup =3D ST_MEMORY_ALLOC; >> >+ test_data->decomp_buf_pool =3D >> rte_pktmbuf_pool_create("decomp_buf_pool", >> >+ total_segs, >> >+ 0, 0, test_data->seg_sz + RTE_PKTMBUF_H= EADROOM, >> >+ rte_socket_id()); >> >+ if (test_data->decomp_buf_pool =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Mbuf mempool could not be created\= n"); >> >+ return -1; >> >+ } >> Unless am missing to see it, you need to free pre-allocated memories her= e >> before return call for all failed cases. > >TJ: There's only one 'freeing stack' at the end of main application functi= on to avoid double freeing resources (which was previously n >V1). >We have state machine for that stuff (static enum cleanup_st) to know what= should be free and what has been allocated already. >In case you mean the state machine is set just after first alloc in line 1= 36: > >cleanup =3D ST_MEMORY_ALLOC; > >so we know what should be free at the end of application running in line 8= 91: > >end: > switch (cleanup) { > > case ST_DURING_TEST: > case ST_PREPARE_BUF: > free_bufs(test_data); > /* fallthrough */ > case ST_MEMORY_ALLOC: > rte_free(test_data->decomp_bufs); Even if we are in this state but it doesn't guarantee all of the buffers in= this state are allocated. So shouldn't every pointer be null-checked befor= e? Thanks Shally > rte_free(test_data->comp_bufs); > rte_free(test_data->decompressed_data); > rte_free(test_data->compressed_data); > rte_mempool_free(test_data->op_pool); > rte_mempool_free(test_data->decomp_buf_pool); > rte_mempool_free(test_data->comp_buf_pool); > /* fallthrough */ > case ST_INPUT_DATA: > rte_free(test_data->input_data); > /* fallthrough */ > case ST_COMPDEV: > if (test_data->cdev_id !=3D -1) > rte_compressdev_stop(test_data->cdev_id); > /* fallthrough */ > case ST_TEST_DATA: > rte_free(test_data); > /* fallthrough */ > case ST_CLEAR: > default: > i =3D rte_eal_cleanup(); > if (i) { > RTE_LOG(ERR, USER1, > "Error from rte_eal_cleanup(), %d\n", i); > ret =3D i; > } > break; > } > return ret; > > > >> >> >+ >> >+ test_data->total_bufs =3D DIV_CEIL(total_segs, >> >+ test_data->max_sgl_segs); >> >+ >> >+ test_data->op_pool =3D rte_comp_op_pool_create("op_pool", >> >+ test_data->total_bufs, >> >+ 0, 0, rte_socket_id()); >> >+ if (test_data->op_pool =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Comp op mempool could not be >> created\n"); >> >+ return -1; >> >+ } >> >+ >> >+ /* >> >+ * Compressed data might be a bit larger than input data, >> >+ * if data cannot be compressed >> >+ */ >> >+ test_data->compressed_data =3D rte_zmalloc_socket(NULL, >> >+ test_data->input_data_sz * EXPANSE_RATI= O >> >+ + >> >+ MIN_ISAL_SIZE, 0, >> MIN_ISAL_SIZE looks specific to ISAL driver. if so, then is this perf ap= p specific >> to that PMD? or Can we make it somewhat generic? > >TJ: True will be fixed > > >> >> >+ rte_socket_id()); >> >+ if (test_data->compressed_data =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Memory to hold the data from the i= nput " >> >+ "file could not be allocated\n"); >> >+ return -1; >> >+ } >> >+ >> >+ test_data->decompressed_data =3D rte_zmalloc_socket(NULL, >> >+ test_data->input_data_sz, 0, >> >+ rte_socket_id()); >> >+ if (test_data->decompressed_data =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Memory to hold the data from the i= nput " >> >+ "file could not be allocated\n"); >> >+ return -1; >> >+ } >> >+ >> >+ test_data->comp_bufs =3D rte_zmalloc_socket(NULL, >> >+ test_data->total_bufs * sizeof(struct rte_mbuf = *), >> >+ 0, rte_socket_id()); >> >+ if (test_data->comp_bufs =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Memory to hold the compression mbu= fs" >> >+ " could not be allocated\n"); >> >+ return -1; >> >+ } >> >+ >> >+ test_data->decomp_bufs =3D rte_zmalloc_socket(NULL, >> >+ test_data->total_bufs * sizeof(struct rte_mbuf = *), >> >+ 0, rte_socket_id()); >> >+ if (test_data->decomp_bufs =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Memory to hold the decompression >> mbufs" >> >+ " could not be allocated\n"); >> >+ return -1; >> >+ } >> >+ return 0; >> >+} >> >+ >> >+static int >> >+comp_perf_dump_input_data(struct comp_test_data *test_data) { >> >+ FILE *f =3D fopen(test_data->input_file, "r"); >> >+ int ret =3D -1; >> >+ >> >+ if (f =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Input file could not be opened\n")= ; >> >+ return -1; >> >+ } >> >+ >> >+ if (fseek(f, 0, SEEK_END) !=3D 0) { >> >+ RTE_LOG(ERR, USER1, "Size of input could not be calcula= ted\n"); >> >+ goto end; >> >+ } >> >+ size_t actual_file_sz =3D ftell(f); >> >+ /* If extended input data size has not been set, >> >+ * input data size =3D file size >> >+ */ >> >+ >> >+ if (test_data->input_data_sz =3D=3D 0) >> >+ test_data->input_data_sz =3D actual_file_sz; >> >+ >> >+ if (fseek(f, 0, SEEK_SET) !=3D 0) { >> >+ RTE_LOG(ERR, USER1, "Size of input could not be calcula= ted\n"); >> >+ goto end; >> >+ } >> >+ >> >+ test_data->input_data =3D rte_zmalloc_socket(NULL, >> >+ test_data->input_data_sz, 0, >> >+ rte_socket_id()); >> >+ >> >+ if (test_data->input_data =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Memory to hold the data from the i= nput " >> >+ "file could not be allocated\n"); >> >+ goto end; >> >+ } >> >+ >> >+ size_t remaining_data =3D test_data->input_data_sz; >> >+ uint8_t *data =3D test_data->input_data; >> >+ >> >+ while (remaining_data > 0) { >> >+ size_t data_to_read =3D RTE_MIN(remaining_data, >> >+ actual_file_sz); >> >+ >> >+ if (fread(data, data_to_read, 1, f) !=3D 1) { >> >+ RTE_LOG(ERR, USER1, "Input file could not be re= ad\n"); >> >+ goto end; >> >+ } >> >+ if (fseek(f, 0, SEEK_SET) !=3D 0) { >> >+ RTE_LOG(ERR, USER1, >> >+ "Size of input could not be calculated\= n"); >> >+ goto end; >> >+ } >> >+ remaining_data -=3D data_to_read; >> >+ data +=3D data_to_read; >> >+ } >> >+ >> >+ if (test_data->input_data_sz > actual_file_sz) >> >+ RTE_LOG(INFO, USER1, >> >+ "%zu bytes read from file %s, extending the file %.2f= times\n", >> >+ test_data->input_data_sz, test_data->input_file= , >> >+ (double)test_data->input_data_sz/actual_file_sz= ); >> >+ else >> >+ RTE_LOG(INFO, USER1, >> >+ "%zu bytes read from file %s\n", >> >+ test_data->input_data_sz, >> >+ test_data->input_file); >> >+ >> >+ ret =3D 0; >> >+ >> >+end: >> >+ fclose(f); >> >+ return ret; >> >+} >> >+ >> >+static int >> >+comp_perf_initialize_compressdev(struct comp_test_data *test_data) { >> >+ uint8_t enabled_cdev_count; >> >+ uint8_t enabled_cdevs[RTE_COMPRESS_MAX_DEVS]; >> >+ >> >+ enabled_cdev_count =3D rte_compressdev_devices_get(test_data- >> >driver_name, >> >+ enabled_cdevs, RTE_COMPRESS_MAX_DEVS); >> >+ if (enabled_cdev_count =3D=3D 0) { >> >+ RTE_LOG(ERR, USER1, "No compress devices type %s availa= ble\n", >> >+ test_data->driver_name); >> >+ return -EINVAL; >> >+ } >> >+ >> >+ if (enabled_cdev_count > 1) >> >+ RTE_LOG(INFO, USER1, >> >+ "Only the first compress device will be >> >+ used\n"); >> >+ >> >+ test_data->cdev_id =3D enabled_cdevs[0]; >> >+ >> >+ if (comp_perf_check_capabilities(test_data) < 0) >> >+ return -1; >> >+ >> >+ /* Configure compressdev (one device, one queue pair) */ >> >+ struct rte_compressdev_config config =3D { >> >+ .socket_id =3D rte_socket_id(), >> >+ .nb_queue_pairs =3D 1, >> >+ .max_nb_priv_xforms =3D NUM_MAX_XFORMS, >> >+ .max_nb_streams =3D 0 >> >+ }; >> >+ >> >+ if (rte_compressdev_configure(test_data->cdev_id, &config) < 0)= { >> >+ RTE_LOG(ERR, USER1, "Device configuration failed\n"); >> >+ return -1; >> >+ } >> >+ >> >+ if (rte_compressdev_queue_pair_setup(test_data->cdev_id, 0, >> >+ NUM_MAX_INFLIGHT_OPS, rte_socket_id()) < 0) { >> >+ RTE_LOG(ERR, USER1, "Queue pair setup failed\n"); >> >+ return -1; >> >+ } >> >+ >> >+ if (rte_compressdev_start(test_data->cdev_id) < 0) { >> >+ RTE_LOG(ERR, USER1, "Device could not be started\n"); >> >+ return -1; >> >+ } >> >+ >> >+ return 0; >> >+} >> >+ >> >+static int >> >+prepare_bufs(struct comp_test_data *test_data) { >> >+ uint32_t remaining_data =3D test_data->input_data_sz; >> >+ uint8_t *input_data_ptr =3D test_data->input_data; >> >+ size_t data_sz; >> >+ uint8_t *data_addr; >> >+ uint32_t i, j; >> >+ >> >+ for (i =3D 0; i < test_data->total_bufs; i++) { >> >+ /* Allocate data in input mbuf and copy data from input= file */ >> >+ test_data->decomp_bufs[i] =3D >> >+ rte_pktmbuf_alloc(test_data->decomp_buf_pool); >> >+ if (test_data->decomp_bufs[i] =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Could not allocate mbuf\n"= ); >> >+ return -1; >> >+ } >> >+ >> >+ cleanup =3D ST_PREPARE_BUF; >> >+ data_sz =3D RTE_MIN(remaining_data, test_data->seg_sz); >> >+ data_addr =3D (uint8_t *) rte_pktmbuf_append( >> >+ test_data->decomp_bufs[i], data= _sz); >> >+ if (data_addr =3D=3D NULL) { >> >+ RTE_LOG(ERR, USER1, "Could not append data\n"); >> So is here ..free of allocated buffer before return from failed cases >> >> Thanks >> Shally > >Thx, Tomek