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 4525BA04B1; Sat, 10 Oct 2020 18:11:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 677E11D98C; Sat, 10 Oct 2020 18:06:10 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 78B821D985 for ; Sat, 10 Oct 2020 18:06:07 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160556euoutp01c9669eb2bcfa8446f2257d47187551dc~8rShdquNL0390103901euoutp01b for ; Sat, 10 Oct 2020 16:05:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160556euoutp01c9669eb2bcfa8446f2257d47187551dc~8rShdquNL0390103901euoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345956; bh=H0SESRE59ofq6tEaPxg1A+VKjAU63AAfipdXXlkRUGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=frqCnbWB6465RhP6Z30BN4evTnSPQhntNGJtmDeGgUHmmR4QPC64tiJTARpum6MyX QD1Q/B2eXxmClXV/msUH5c7U2bG+wVc9gWAArW39cmFVOW10bExYcfy/p6Jr2XFsN1 /ZZ2dR1ztdI+naf9rSDVHsCmEw3Xc71/1pee1EJA= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201010160550eucas1p24c6ed170991c97970e51a34227f92229~8rScSSU9T1926019260eucas1p2M; Sat, 10 Oct 2020 16:05:50 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B7.E6.06456.EDBD18F5; Sat, 10 Oct 2020 17:05:50 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160549eucas1p1eba7cb8e4e9ba9200e9cd498137848c3~8rSbO-ncA2440724407eucas1p1w; Sat, 10 Oct 2020 16:05:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160549eusmtrp2e4e0502a459c5f5a86ce225266a34606~8rSbOg3W31692616926eusmtrp2L; Sat, 10 Oct 2020 16:05:49 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-36-5f81dbde7634 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 7B.A6.06017.DDBD18F5; Sat, 10 Oct 2020 17:05:49 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160549eusmtip10b863759f74b3e670f318c9a8f7e98d3~8rSavPer92972929729eusmtip1C; Sat, 10 Oct 2020 16:05:48 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com Date: Sat, 10 Oct 2020 18:05:04 +0200 Message-Id: <20201010160508.19709-14-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrAIsWRmVeSWpSXmKPExsWy7djPc7r3bjfGGyycoWvRN+kjk8W7T9uZ LJ71rGN0YPb4tWApq8fiPS+ZPA6+28MUwBzFZZOSmpNZllqkb5fAlfHuxSG2gsNaFau2nGZr YNyq2MXIySEhYCJx7uQhpi5GLg4hgRWMEnPv9DFCOF8YJXb+38oC4XxmlHh66z0LTEvrkxPs EInljBInDk9mhXA+MUrsWzYbr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GvgWMDKsYRVJLi3PTc4uN9IoTc4tL89L1kvNzNzECQ2/bsZ9bdjB2 vQs+xCjAwajEwytxqjFeiDWxrLgy9xCjBAezkgiv09nTcUK8KYmVValF+fFFpTmpxYcYTYGu msgsJZqcD4yLvJJ4Q1NDcwtLQ3Njc2MzCyVx3g6BgzFCAumJJanZqakFqUUwfUwcnFINjLpJ W/7/uX4yPM1h4ZrG2PxpTss/7LGb76Ij59kV8CsqQOxi/f/H9yMf3/u54tkO1+j36vfnVE6V FKmTUt8y88S3n8mNgRwTBTv+shs8YSudaMTHema61kqHZx0yWtKHHZd4b5xQKs/12e9j8a62 8kN1GWuPvlxY9OiXyJ5X1w9WvDLX/HTv3x0lluKMREMt5qLiRAAyyoLSUwIAAA== X-CMS-MailID: 20201010160549eucas1p1eba7cb8e4e9ba9200e9cd498137848c3 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20201010160549eucas1p1eba7cb8e4e9ba9200e9cd498137848c3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160549eucas1p1eba7cb8e4e9ba9200e9cd498137848c3 References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 13/16] 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 Acked-by: David Hunt --- 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 e8dd75078..4fc10b3cc 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_RELAXED); + 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_RELAXED); + 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_RELAXED)); + + /* 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