From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0056.outbound.protection.outlook.com [104.47.42.56]) by dpdk.org (Postfix) with ESMTP id 478C92BB9; Thu, 8 Jun 2017 16:29:17 +0200 (CEST) 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; bh=tABO13sVpTMxjWJUuEBElY2afOUWK1iMZvLyRpUsL7o=; b=EbydnoLHPtSlz8kXw9Qw5CtEcAsdAXSFnxohON9ZtepxBYwJQwk9GuIeTatCHzt4lj1EEux1OlDfooY3PQsGCrIzPfusMwLciJuEpzbn+oUW/QxZKVrAtMKjuQzyhKSAH47WQUyXqfLkKZ358MLxyeyyi6YgHwO0ttF17xfXJFU= Authentication-Results: 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost.localdomain (111.93.218.67) by CY4PR07MB3096.namprd07.prod.outlook.com (10.172.115.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1143.10; Thu, 8 Jun 2017 14:29:13 +0000 From: Santosh Shukla To: olivier.matz@6wind.com, dev@dpdk.org Cc: thomas@monjalon.net, shreyansh.jain@nxp.com, Santosh Shukla , stable@dpdk.org Date: Thu, 8 Jun 2017 14:28:31 +0000 Message-Id: <20170608142831.28166-1-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.13.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MA1PR01CA0078.INDPRD01.PROD.OUTLOOK.COM (10.174.56.18) To CY4PR07MB3096.namprd07.prod.outlook.com (10.172.115.10) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PR07MB3096: X-MS-Office365-Filtering-Correlation-Id: 8dd8e8b9-4d5e-4f04-db46-08d4ae7abd66 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:CY4PR07MB3096; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3096; 3:D9q2fWIVkvEKcGv1SXwc91ugXIQ3ISmugN10FKyMH+FdIEKzGsqrcVbqSYeCGibbAp/AwNddfR7QWk83lPqD3lzNt0dfkKkqyphU8H6ZpuaE3M5UP+J0rfLWjmpzyGsbi4VRKwDJd+R3Effmk5lvCnboBkenxU6tSytS6nc1mBM5B2+THtQgfHM6u0udrL0dXegkqCqjUAx2jfGplmRLmhdir8zRiw2PtEnfeXgl4CxhZjbCD7VxDA1rHLSyVVSV7iRQi/esk105snJmSVlzo9QCZz/o9HtgmVCjQ/klrDchnFgd02osaLxLWLxsO2M4s7REBEyTHD2PTFC1+xPjfQ==; 25:tQrzEZZ9lti8BsOq4wll4wIHucjfpyYKdtMZQjoNYSp7K1LYZZ+hPC8qOeYBHIhRK22VPX3wMHtaKe88rKmW5HukxtynGazupHogjql2grHm00dfom5ZAiDu/Ytbh9b38ChqV9tplgk8FgKxbv7oJ/ksx+xiikmgmrZYpEoHfqO3tgWiXhSxbkkM9n2DYomP4v8AZjoxdW4XR8lW/Ad+j9TdNnnjeIKe7ZTz9Qd/C4H+/Q9XVnzfkkkv/zn2lOB34gapUjZik0aqzUYhVRZEe33cuX4Rl7oY823mz8BEhanl1iOSoSOzuQXBUR8SEsHvY0JlwSeeOlD7vfC0tBdf3amsdwBq3uZqvLcNAmnvIB1AjekrYQghy13S5hZMhCNzfB5w1Z/sANKKzfcXrygQy2Ga9sVYcsBovPp+OIqG8yBdjUlZSP++dz9FMu/LH9eiSu84+LsKVpeMXBsRuFyMoBr4IFtMIoiInsXqL0Y7+t4= X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3096; 31:Y/Lyk/aD7pBt1kJaNRYgMwTxPsYqIBnjvvZcPTGzI5F1qyodGVVSFllUDGBcon3mpeKZEPgrF/8C/6sQGRO51+3qodYDlat4F/WHRITZjYK4SLMvAK6vD3+jgkgmT0AXsPrTfEWeYBv4zW/THKAPJsXG/GiC0Vgujej2IhfyyEyZK23wug96B6eI7Ify2FtlkaNWQdilk+sOWTm2QkdkB4TmktjKfb4YxxBXtr6HsxA=; 20:cMWPnQEXBRxsFTJQgvuAA5Xn6ENgE9gAiBmDAG6TJIxenxnhw5AeeajOsIfVRCcBQF2Vk/hh2qRxSrOIVCOqftEgI3pZCXBbuGQWlAckJgSgzMwiOgLAShwIDiIoO2EQ9Xq35CWkz+5YVpecz1BjrGryMyrl90YO5T1wVZ30GPchVfOh5mS3d9NkilORuNnezuKOeMolq9FM6uhcH43Js9aPHNR8UJV7XCDTm8zXcpnmibumUXxTPrSP8NFk5JPkBz9y5dSbaYH1YGds4iRvNnvu9yLANb/ixDaiKYaO8huf5A5MTTyntbmj3iLCXtcfX2MaAjLxbEg5jbShVr9xo+/zbdA8WOQGp3AL2jwtSwNisW10aEeFR5HgT3PwMTlNCLUDKqHc0nYm99pIm3G//It+9//zg32+pI67c1re/fayCr+TqubjwN+DOMz6sSEHvj1p+TLi10foo42No0c6RrfCytoIOjlSVmLP1HPio7SYyfrXb56+4TTL86oEf6eq5486Y3KglrSBByKdqGCTmNahdNq41JVj0k26f9hX6WfRvJGSEHIDBQBT4hYwkSaJ1NALQSuytxOoWZChINNti9sXHb/w559bclBSjuA+Mtc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(3002001)(100000703101)(100105400095)(10201501046)(6041248)(20161123555025)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR07MB3096; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR07MB3096; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR07MB3096; 4:cWaWAs743kDzVSVDQ0s1LMpaq2CROwgB+3zgakmVeb?= =?us-ascii?Q?AGuH1btBgg87v1qWPaQezZrHjm9MBLatEm92G5pZ1yCyZbbd32tygLnzCJdM?= =?us-ascii?Q?3jGvTaf4xfn8ZIM4ajKWkryyOH7nNTj309TIDE4VT6ZyLvVSpwYkXsbXn4A/?= =?us-ascii?Q?bR1AYwoMLA6sU9XybxnIxChlaHYjsQuQbdly2heuV6dgy+Z69KgWALgyqjnd?= =?us-ascii?Q?AsYUheYwNj7CAGMj/tX84n1Y28MYgP/KcfHiUtt1U2xrJx3ujhwZW9C2LUBv?= =?us-ascii?Q?sxjDI0cQQ2uLpPAtp1Fu8x0VqA/Ae7Zifq+KvOZafJWNsaflyAiyiY4D4VWy?= =?us-ascii?Q?uoYhKJt6+majKa0CdoMGr9XHquAZwAlR9OKerjRem0JGnVXZ/NhUkYMzcz8P?= =?us-ascii?Q?lqWhRnUdSp+uF1PSgCEunr67r/qA7FphgDg5H3kK7iinbB/V2kVl/i+A/6yK?= =?us-ascii?Q?/4OgukVpcFGsg2nzT3VnaFVIacOhmajMq7u2gWU9aTammcLmTC9z0USwFTbE?= =?us-ascii?Q?fEbj7dZXcLc0Nf26P34NT9HWjcVyl0OetTi9yc/In2gFwCJsPWcHA8x+aMaE?= =?us-ascii?Q?NHx5fotjL09/JSelUshuj4rhijeI/jj+j/qjZKRDRDnMZvDjRcJ5+k1vKG7U?= =?us-ascii?Q?8ReGuj+2uQIFzjHViOIcQ+KnYKo87lyj/qCgjizubsz7Fm7GeY/Frgl1FQ+m?= =?us-ascii?Q?byrYBVELOCRY8R7Oh8jdzhlzpFXjoXtbscypeVvPZWIyZwWWsTtO68dDUZwe?= =?us-ascii?Q?D3K2A4vO4LM6tIh0mF6wgi3IvI6D1h49T14/WYhaDZqbWtYK2+4rl4wf0ig2?= =?us-ascii?Q?MAcvJ7A13oE/wqw7gIJ0Y7Z1DfJRfnfqdHI1WjkstQ5CwyG7liMa33SX0ItQ?= =?us-ascii?Q?XPL44PDWPEJcUbBfN3w/Z5Vklwip5t+/kVmZJKLnR6lFjjlb9egeJGeMuOAw?= =?us-ascii?Q?AIMZNwJliZ8ebjm35q1ygV3zKnuqx79QFqudb3DmtisOxFKCXK7BB1I2kvl6?= =?us-ascii?Q?tEsIhjQ8VvDisp7eixWjLSW/bXMMRtLV8nk8Lnd/NU5FrXd/yBbMT2vurnDe?= =?us-ascii?Q?82lmAixrDMu5/Ohd1+u0ZNWkTb9X0J7qBF9vOlPPW5wSPHFEmaPuPPAA6n0T?= =?us-ascii?Q?IFRN4I2r8=3D?= X-Forefront-PRVS: 0332AACBC3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6009001)(6069001)(39840400002)(39450400003)(39850400002)(39410400002)(39400400002)(42186005)(42882006)(47776003)(66066001)(6666003)(4326008)(50986999)(5660300001)(25786009)(5003940100001)(6506006)(8676002)(1076002)(38730400002)(53376002)(110136004)(72206003)(6512007)(53936002)(6306002)(7736002)(3846002)(50226002)(81166006)(6486002)(305945005)(8656002)(6116002)(5890100001)(966005)(478600001)(2906002)(48376002)(50466002)(189998001)(36756003)(5009440100003)(33646002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR07MB3096; H:localhost.localdomain; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR07MB3096; 23:CgShnsJ/yTiPTmClYPFkdL6u5TChz+NQ+gIfa6R/P?= =?us-ascii?Q?RvliY3K+EpSWJzO3dHJahM4wsUJc8HdhKnlh7S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pzrPOMEQ9TpzBsWy5r+ywLrmjXcNI4f6r63F5JTufahLuB1i0hD8E+aHIKTzXqQLfTD5reHH9aWasKCKvfHIh+Xacyrop6CNTfNoyT1zXdft1lwN9GMr4ZjXI5fMfjPN1gdkHMXMK6nGfc6zST5asl9Ksn7Jo/GU6pZGKbe0wAfjyxGi0csWh108iKYEBGhocZUiY34ThH5TNP57vw8f/516ug6ANx1WxdK8WpnF2hS5Cve/rT/6nZkCkTir21l7nfGFtyHiXakeizwVykWZ12U32QnG/WSCbq0pndlFy5EKAKRpCt50aCslVXBXLflmNJ1dZHJ/aKwNleMp+IsA0OACanEmuD2PeZxJvsC+RhhesKVCnpnmo+Ql80MMLyp4sWy5oldyWRHCphW1eQcBZNPLsjtaCIpHW8gs51dfA7rUfowWz2bpzuMcP16y8Ur8/UKD; 24:IhqdIHJyIBtflyNFKyt+VSDiuVI/WMRIAaT0zMwao4tbVYm4cqHUeaJprMh9isdIybEaYKvaG2dxXhv2ZDrm97pTjUdODP2nJczSwHYs79Q= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3096; 7:KvOdHn0ICUIEfVo2Jn2mDGDUJqU1jfKKzU921/pWkapcOm4E6hfrjNfXnyIj31BfLeJPRfWOuSIgIl7JqaPqk6wv863BHUWVFUWIkcasQbFNAWemgQrsbfMiFYDcqF6qORe01ZyIwIh+l3+36a6OlrF/MEzVaXKo2z1alzUD6Vlj9ta+EwVcAYpIObZ1sUKKyWi6PuYHL0GGCMfAhNJP2Oj3WLMGAiYVufYwDr3df6P0zozYS081LTfBDcUEVUZLtHtl18a1DV8rJL/LRHuv4lr7DnbDyjZlWJgIJRQ1JMBOE5l2m2OSqGOresofQc4AukLl7uE8988pBpfafDy18g== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2017 14:29:13.3428 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3096 Subject: [dpdk-stable] [PATCH v2] test/test_mbuf: remove mempool global var X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2017 14:29:18 -0000 Let test_mbuf alloc and free mempool. Cc: stable@dpdk.org Signed-off-by: Santosh Shukla --- v1 --> v2: - Clubed v1 two patch into 1 patch per Olivier review comment [1] [1] http://dpdk.org/dev/patchwork/patch/24237/ test/test/test_mbuf.c | 148 ++++++++++++++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 66 deletions(-) diff --git a/test/test/test_mbuf.c b/test/test/test_mbuf.c index d3ea812e5..d6cf4d611 100644 --- a/test/test/test_mbuf.c +++ b/test/test/test_mbuf.c @@ -82,13 +82,8 @@ #define MAKE_STRING(x) # x -static struct rte_mempool *pktmbuf_pool = NULL; -static struct rte_mempool *pktmbuf_pool2 = NULL; - #ifdef RTE_MBUF_REFCNT_ATOMIC -static struct rte_mempool *refcnt_pool = NULL; -static struct rte_ring *refcnt_mbuf_ring = NULL; static volatile uint32_t refcnt_stop_slaves; static unsigned refcnt_lcore[RTE_MAX_LCORE]; @@ -144,7 +139,7 @@ static unsigned refcnt_lcore[RTE_MAX_LCORE]; * test data manipulation in mbuf with non-ascii data */ static int -test_pktmbuf_with_non_ascii_data(void) +test_pktmbuf_with_non_ascii_data(struct rte_mempool *pktmbuf_pool) { struct rte_mbuf *m = NULL; char *data; @@ -182,7 +177,7 @@ test_pktmbuf_with_non_ascii_data(void) * test data manipulation in mbuf */ static int -test_one_pktmbuf(void) +test_one_pktmbuf(struct rte_mempool *pktmbuf_pool) { struct rte_mbuf *m = NULL; char *data, *data2, *hdr; @@ -328,7 +323,7 @@ test_one_pktmbuf(void) } static int -testclone_testupdate_testdetach(void) +testclone_testupdate_testdetach(struct rte_mempool *pktmbuf_pool) { struct rte_mbuf *m = NULL; struct rte_mbuf *clone = NULL; @@ -432,7 +427,8 @@ testclone_testupdate_testdetach(void) } static int -test_attach_from_different_pool(void) +test_attach_from_different_pool(struct rte_mempool *pktmbuf_pool, + struct rte_mempool *pktmbuf_pool2) { struct rte_mbuf *m = NULL; struct rte_mbuf *clone = NULL; @@ -542,7 +538,7 @@ test_attach_from_different_pool(void) * test allocation and free of mbufs */ static int -test_pktmbuf_pool(void) +test_pktmbuf_pool(struct rte_mempool *pktmbuf_pool) { unsigned i; struct rte_mbuf *m[NB_MBUF]; @@ -583,7 +579,7 @@ test_pktmbuf_pool(void) * test that the pointer to the data on a packet mbuf is set properly */ static int -test_pktmbuf_pool_ptr(void) +test_pktmbuf_pool_ptr(struct rte_mempool *pktmbuf_pool) { unsigned i; struct rte_mbuf *m[NB_MBUF]; @@ -636,7 +632,7 @@ test_pktmbuf_pool_ptr(void) } static int -test_pktmbuf_free_segment(void) +test_pktmbuf_free_segment(struct rte_mempool *pktmbuf_pool) { unsigned i; struct rte_mbuf *m[NB_MBUF]; @@ -680,10 +676,11 @@ test_pktmbuf_free_segment(void) #ifdef RTE_MBUF_REFCNT_ATOMIC static int -test_refcnt_slave(__attribute__((unused)) void *arg) +test_refcnt_slave(void *arg) { unsigned lcore, free; void *mp = 0; + struct rte_ring *refcnt_mbuf_ring = arg; lcore = rte_lcore_id(); printf("%s started at lcore %u\n", __func__, lcore); @@ -704,7 +701,9 @@ test_refcnt_slave(__attribute__((unused)) void *arg) } static void -test_refcnt_iter(unsigned lcore, unsigned iter) +test_refcnt_iter(unsigned int lcore, unsigned int iter, + struct rte_mempool *refcnt_pool, + struct rte_ring *refcnt_mbuf_ring) { uint16_t ref; unsigned i, n, tref, wn; @@ -760,7 +759,8 @@ test_refcnt_iter(unsigned lcore, unsigned iter) } static int -test_refcnt_master(void) +test_refcnt_master(struct rte_mempool *refcnt_pool, + struct rte_ring *refcnt_mbuf_ring) { unsigned i, lcore; @@ -768,7 +768,7 @@ test_refcnt_master(void) printf("%s started at lcore %u\n", __func__, lcore); for (i = 0; i != REFCNT_MAX_ITER; i++) - test_refcnt_iter(lcore, i); + test_refcnt_iter(lcore, i, refcnt_pool, refcnt_mbuf_ring); refcnt_stop_slaves = 1; rte_wmb(); @@ -783,9 +783,10 @@ static int test_refcnt_mbuf(void) { #ifdef RTE_MBUF_REFCNT_ATOMIC - unsigned lnum, master, slave, tref; - + int ret = -1; + struct rte_mempool *refcnt_pool = NULL; + struct rte_ring *refcnt_mbuf_ring = NULL; if ((lnum = rte_lcore_count()) == 1) { printf("skipping %s, number of lcores: %u is not enough\n", @@ -797,31 +798,31 @@ test_refcnt_mbuf(void) /* create refcnt pool & ring if they don't exist */ - if (refcnt_pool == NULL && - (refcnt_pool = rte_pktmbuf_pool_create( - MAKE_STRING(refcnt_pool), - REFCNT_MBUF_NUM, 0, 0, 0, - SOCKET_ID_ANY)) == NULL) { + refcnt_pool = rte_pktmbuf_pool_create(MAKE_STRING(refcnt_pool), + REFCNT_MBUF_NUM, 0, 0, 0, + SOCKET_ID_ANY); + if (refcnt_pool == NULL) { printf("%s: cannot allocate " MAKE_STRING(refcnt_pool) "\n", __func__); return -1; } - if (refcnt_mbuf_ring == NULL && - (refcnt_mbuf_ring = rte_ring_create("refcnt_mbuf_ring", + refcnt_mbuf_ring = rte_ring_create("refcnt_mbuf_ring", rte_align32pow2(REFCNT_RING_SIZE), SOCKET_ID_ANY, - RING_F_SP_ENQ)) == NULL) { + RING_F_SP_ENQ); + if (refcnt_mbuf_ring == NULL) { printf("%s: cannot allocate " MAKE_STRING(refcnt_mbuf_ring) "\n", __func__); - return -1; + goto err; } refcnt_stop_slaves = 0; memset(refcnt_lcore, 0, sizeof (refcnt_lcore)); - rte_eal_mp_remote_launch(test_refcnt_slave, NULL, SKIP_MASTER); + rte_eal_mp_remote_launch(test_refcnt_slave, refcnt_mbuf_ring, + SKIP_MASTER); - test_refcnt_master(); + test_refcnt_master(refcnt_pool, refcnt_mbuf_ring); rte_eal_mp_wait_lcore(); @@ -839,8 +840,15 @@ test_refcnt_mbuf(void) rte_mempool_dump(stdout, refcnt_pool); rte_ring_dump(stdout, refcnt_mbuf_ring); -#endif + ret = 0; + +err: + rte_mempool_free(refcnt_pool); + rte_ring_free(refcnt_mbuf_ring); + return ret; +#else return 0; +#endif } #include @@ -870,7 +878,7 @@ verify_mbuf_check_panics(struct rte_mbuf *buf) } static int -test_failing_mbuf_sanity_check(void) +test_failing_mbuf_sanity_check(struct rte_mempool *pktmbuf_pool) { struct rte_mbuf *buf; struct rte_mbuf badbuf; @@ -931,7 +939,9 @@ test_failing_mbuf_sanity_check(void) } static int -test_mbuf_linearize(int pkt_len, int nb_segs) { +test_mbuf_linearize(struct rte_mempool *pktmbuf_pool, int pkt_len, + int nb_segs) +{ struct rte_mbuf *m = NULL, *mbuf = NULL; uint8_t *data; @@ -1022,7 +1032,7 @@ test_mbuf_linearize(int pkt_len, int nb_segs) { } static int -test_mbuf_linearize_check(void) +test_mbuf_linearize_check(struct rte_mempool *pktmbuf_pool) { struct test_mbuf_array { int size; @@ -1039,7 +1049,7 @@ test_mbuf_linearize_check(void) printf("Test mbuf linearize API\n"); for (i = 0; i < RTE_DIM(mbuf_array); i++) - if (test_mbuf_linearize(mbuf_array[i].size, + if (test_mbuf_linearize(pktmbuf_pool, mbuf_array[i].size, mbuf_array[i].nb_segs)) { printf("Test failed for %d, %d\n", mbuf_array[i].size, mbuf_array[i].nb_segs); @@ -1052,53 +1062,54 @@ test_mbuf_linearize_check(void) static int test_mbuf(void) { + int ret = -1; + struct rte_mempool *pktmbuf_pool = NULL; + struct rte_mempool *pktmbuf_pool2 = NULL; + + RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_MIN_SIZE * 2); /* create pktmbuf pool if it does not exist */ - if (pktmbuf_pool == NULL) { - pktmbuf_pool = rte_pktmbuf_pool_create("test_pktmbuf_pool", + pktmbuf_pool = rte_pktmbuf_pool_create("test_pktmbuf_pool", NB_MBUF, 32, 0, MBUF_DATA_SIZE, SOCKET_ID_ANY); - } if (pktmbuf_pool == NULL) { printf("cannot allocate mbuf pool\n"); - return -1; + goto err; } /* create a specific pktmbuf pool with a priv_size != 0 and no data * room size */ - if (pktmbuf_pool2 == NULL) { - pktmbuf_pool2 = rte_pktmbuf_pool_create("test_pktmbuf_pool2", + pktmbuf_pool2 = rte_pktmbuf_pool_create("test_pktmbuf_pool2", NB_MBUF, 32, MBUF2_PRIV_SIZE, 0, SOCKET_ID_ANY); - } if (pktmbuf_pool2 == NULL) { printf("cannot allocate mbuf pool\n"); - return -1; + goto err; } /* test multiple mbuf alloc */ - if (test_pktmbuf_pool() < 0) { + if (test_pktmbuf_pool(pktmbuf_pool) < 0) { printf("test_mbuf_pool() failed\n"); - return -1; + goto err; } /* do it another time to check that all mbufs were freed */ - if (test_pktmbuf_pool() < 0) { + if (test_pktmbuf_pool(pktmbuf_pool) < 0) { printf("test_mbuf_pool() failed (2)\n"); - return -1; + goto err; } /* test that the pointer to the data on a packet mbuf is set properly */ - if (test_pktmbuf_pool_ptr() < 0) { + if (test_pktmbuf_pool_ptr(pktmbuf_pool) < 0) { printf("test_pktmbuf_pool_ptr() failed\n"); - return -1; + goto err; } /* test data manipulation in mbuf */ - if (test_one_pktmbuf() < 0) { + if (test_one_pktmbuf(pktmbuf_pool) < 0) { printf("test_one_mbuf() failed\n"); - return -1; + goto err; } @@ -1106,47 +1117,52 @@ test_mbuf(void) * do it another time, to check that allocation reinitialize * the mbuf correctly */ - if (test_one_pktmbuf() < 0) { + if (test_one_pktmbuf(pktmbuf_pool) < 0) { printf("test_one_mbuf() failed (2)\n"); - return -1; + goto err; } - if (test_pktmbuf_with_non_ascii_data() < 0) { + if (test_pktmbuf_with_non_ascii_data(pktmbuf_pool) < 0) { printf("test_pktmbuf_with_non_ascii_data() failed\n"); - return -1; + goto err; } /* test free pktmbuf segment one by one */ - if (test_pktmbuf_free_segment() < 0) { + if (test_pktmbuf_free_segment(pktmbuf_pool) < 0) { printf("test_pktmbuf_free_segment() failed.\n"); - return -1; + goto err; } - if (testclone_testupdate_testdetach()<0){ + if (testclone_testupdate_testdetach(pktmbuf_pool) < 0) { printf("testclone_and_testupdate() failed \n"); - return -1; + goto err; } - if (test_attach_from_different_pool() < 0) { + if (test_attach_from_different_pool(pktmbuf_pool, pktmbuf_pool2) < 0) { printf("test_attach_from_different_pool() failed\n"); - return -1; + goto err; } if (test_refcnt_mbuf()<0){ printf("test_refcnt_mbuf() failed \n"); - return -1; + goto err; } - if (test_failing_mbuf_sanity_check() < 0) { + if (test_failing_mbuf_sanity_check(pktmbuf_pool) < 0) { printf("test_failing_mbuf_sanity_check() failed\n"); - return -1; + goto err; } - if (test_mbuf_linearize_check() < 0) { + if (test_mbuf_linearize_check(pktmbuf_pool) < 0) { printf("test_mbuf_linearize_check() failed\n"); - return -1; + goto err; } - return 0; + ret = 0; + +err: + rte_mempool_free(pktmbuf_pool); + rte_mempool_free(pktmbuf_pool2); + return ret; } REGISTER_TEST_COMMAND(mbuf_autotest, test_mbuf); -- 2.13.0