From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D70A0A04BC; Thu, 8 Oct 2020 07:28:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 85E701BC0C; Thu, 8 Oct 2020 07:24:08 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 87D171B733 for ; Thu, 8 Oct 2020 07:23:47 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052347euoutp012ea755b944c20017850914f822871e4c~77PSCGKJU2347823478euoutp01A for ; Thu, 8 Oct 2020 05:23:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201008052347euoutp012ea755b944c20017850914f822871e4c~77PSCGKJU2347823478euoutp01A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134627; bh=jMHuFwore4XCujWFa4FPHZRC4UgHvZ5ghfXB+hPBmOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=byeXNuHVkA7ynwyLJ2MkUMgUZYLfl/B4Oe2bV6BQVX89hYu/vjF8OG2f4r3pths7+ qyCI33fDlZn4KpGJNEWrvgyIuHcgfdiGDGfluSYx8uuGh4rMKTSVA5EY92fqpzyGcL +gAZg2+qBMf78rnm8FAcAQ2/PVbCgxAPxUvUfFTA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201008052347eucas1p280cd984b68178743ed7774188d4f14a1~77PR6av9g2934729347eucas1p2W; Thu, 8 Oct 2020 05:23:47 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 55.01.05997.362AE7F5; Thu, 8 Oct 2020 06:23:47 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052346eucas1p15b04bf84cafc2ba52bbe063f57d08c39~77PRW3p1u1495514955eucas1p1C; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052346eusmtrp116169c7e5de2076253e5fe70aece2f75~77PRQf77Y2941629416eusmtrp1Z; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-75-5f7ea2630eda Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 6E.F0.06017.262AE7F5; Thu, 8 Oct 2020 06:23:46 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052346eusmtip1b64152b47d6b23d57c700ec04fe88cef~77PQ0msyK2784127841eusmtip1-; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com Date: Thu, 8 Oct 2020 07:23:21 +0200 Message-Id: <20201008052323.11547-14-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNIsWRmVeSWpSXmKPExsWy7djPc7rJi+riDe5sYrfom/SRyeLdp+1M Fs961jE6MHv8WrCU1WPxnpdMHgff7WEKYI7isklJzcksSy3St0vgytjSso+1oFWr4vn9iAbG XsUuRk4OCQETiZ8f57F1MXJxCAmsYJT4tOYdE4TzhVGieclaIIcDyPnMKNHuBdOwcuUOVoia 5UA19+ezgySEBD4xSkzaVgpiswnYShyZ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oTc4tL89L1kvNzNzECw27bsZ9bdjB2 vQs+xCjAwajEw2twtDZeiDWxrLgy9xCjBAezkgiv09nTcUK8KYmVValF+fFFpTmpxYcYTYGO msgsJZqcD4yJvJJ4Q1NDcwtLQ3Njc2MzCyVx3g6BgzFCAumJJanZqakFqUUwfUwcnFINjDN5 Fpu+7uV8MO+UeoSqd3JC7GOX2Ey5ELHG+AXPFscnchzRDwmKO+C825gv2EhPzNm+NtCXMfFZ S8+eXtep1t5pptxf+SfMrhWKSvCY2XzXIvkm9xS5kzoTM4MZNH54nP1RxM5tErZI6uS7K07P HRi33c4+eX11nkhIwvxv1abG68Vn2D5UYinOSDTUYi4qTgQAXsCt/lECAAA= X-CMS-MailID: 20201008052346eucas1p15b04bf84cafc2ba52bbe063f57d08c39 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20201008052346eucas1p15b04bf84cafc2ba52bbe063f57d08c39 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052346eucas1p15b04bf84cafc2ba52bbe063f57d08c39 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 13/15] test/distributor: add test with packets marking 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" All of the former tests analyzed only statistics of packets processed by all workers. The new test verifies also if packets are processed on workers as expected. Every packets processed by the worker is marked and analyzed after it is returned to distributor. This test allows finding issues in matching algorithms. Signed-off-by: Lukasz Wojciechowski --- app/test/test_distributor.c | 141 ++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 1e0a079ff..0404e463a 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -542,6 +542,141 @@ test_flush_with_worker_shutdown(struct worker_params *wp, return 0; } +static int +handle_and_mark_work(void *arg) +{ + struct rte_mbuf *buf[8] __rte_cache_aligned; + struct worker_params *wp = arg; + struct rte_distributor *db = wp->dist; + unsigned int num, i; + unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); + num = rte_distributor_get_pkt(db, id, buf, NULL, 0); + while (!quit) { + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_ACQ_REL); + for (i = 0; i < num; i++) + buf[i]->udata64 += id + 1; + num = rte_distributor_get_pkt(db, id, + buf, buf, num); + } + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_ACQ_REL); + rte_distributor_return_pkt(db, id, buf, num); + return 0; +} + +/* sanity_mark_test sends packets to workers which mark them. + * Every packet has also encoded sequence number. + * The returned packets are sorted and verified if they were handled + * by proper workers. + */ +static int +sanity_mark_test(struct worker_params *wp, struct rte_mempool *p) +{ + const unsigned int buf_count = 24; + const unsigned int burst = 8; + const unsigned int shift = 12; + const unsigned int seq_shift = 10; + + struct rte_distributor *db = wp->dist; + struct rte_mbuf *bufs[buf_count]; + struct rte_mbuf *returns[buf_count]; + unsigned int i, count, id; + unsigned int sorted[buf_count], seq; + unsigned int failed = 0; + + printf("=== Marked packets test ===\n"); + clear_packet_count(); + if (rte_mempool_get_bulk(p, (void *)bufs, buf_count) != 0) { + printf("line %d: Error getting mbufs from pool\n", __LINE__); + return -1; + } + +/* bufs' hashes will be like these below, but shifted left. + * The shifting is for avoiding collisions with backlogs + * and in-flight tags left by previous tests. + * [1, 1, 1, 1, 1, 1, 1, 1 + * 1, 1, 1, 1, 2, 2, 2, 2 + * 2, 2, 2, 2, 1, 1, 1, 1] + */ + for (i = 0; i < burst; i++) { + bufs[0 * burst + i]->hash.usr = 1 << shift; + bufs[1 * burst + i]->hash.usr = ((i < burst / 2) ? 1 : 2) + << shift; + bufs[2 * burst + i]->hash.usr = ((i < burst / 2) ? 2 : 1) + << shift; + } +/* Assign a sequence number to each packet. The sequence is shifted, + * so that lower bits of the udate64 will hold mark from worker. + */ + for (i = 0; i < buf_count; i++) + bufs[i]->udata64 = i << seq_shift; + + count = 0; + for (i = 0; i < buf_count/burst; i++) { + rte_distributor_process(db, &bufs[i * burst], burst); + count += rte_distributor_returned_pkts(db, &returns[count], + buf_count - count); + } + + do { + rte_distributor_flush(db); + count += rte_distributor_returned_pkts(db, &returns[count], + buf_count - count); + } while (count < buf_count); + + for (i = 0; i < rte_lcore_count() - 1; i++) + printf("Worker %u handled %u packets\n", i, + __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_ACQUIRE)); + +/* Sort returned packets by sent order (sequence numbers). */ + for (i = 0; i < buf_count; i++) { + seq = returns[i]->udata64 >> seq_shift; + id = returns[i]->udata64 - (seq << seq_shift); + sorted[seq] = id; + } + +/* Verify that packets [0-11] and [20-23] were processed + * by the same worker + */ + for (i = 1; i < 12; i++) { + if (sorted[i] != sorted[0]) { + printf("Packet number %u processed by worker %u," + " but should be processes by worker %u\n", + i, sorted[i], sorted[0]); + failed = 1; + } + } + for (i = 20; i < 24; i++) { + if (sorted[i] != sorted[0]) { + printf("Packet number %u processed by worker %u," + " but should be processes by worker %u\n", + i, sorted[i], sorted[0]); + failed = 1; + } + } +/* And verify that packets [12-19] were processed + * by the another worker + */ + for (i = 13; i < 20; i++) { + if (sorted[i] != sorted[12]) { + printf("Packet number %u processed by worker %u," + " but should be processes by worker %u\n", + i, sorted[i], sorted[12]); + failed = 1; + } + } + + rte_mempool_put_bulk(p, (void *)bufs, buf_count); + + if (failed) + return -1; + + printf("Marked packets test passed\n"); + return 0; +} + static int test_error_distributor_create_name(void) { @@ -726,6 +861,12 @@ test_distributor(void) goto err; quit_workers(&worker_params, p); + rte_eal_mp_remote_launch(handle_and_mark_work, + &worker_params, SKIP_MASTER); + if (sanity_mark_test(&worker_params, p) < 0) + goto err; + quit_workers(&worker_params, p); + } else { printf("Too few cores to run worker shutdown test\n"); } -- 2.17.1