From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0085.outbound.protection.outlook.com [104.47.32.85]) by dpdk.org (Postfix) with ESMTP id 1B1E2F957 for ; Fri, 3 Mar 2017 18:30:34 +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; bh=rnjCGSBnIcmUccCAIWznR8ms/Lu1ayk8kBvPvq2yi/4=; b=VFsF9cFqQpclW3Y2pGQ9VibKTvnAGdJM7dba/Pibdvt3iTGgWswu35UZ7h6fuw3Q0IbkWsLi9A3msnnaeYAyti4S9N2mzOyz/JZ3F6OYmK6Vq+YfOldnjL4ENXNKdIDlmkO0XrwCV237MHiIMHGmB4tMY7ueirEGXxc3J6CPCbE= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost.localdomain.localdomain (14.140.2.178) by BN3PR0701MB1719.namprd07.prod.outlook.com (10.163.39.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.933.12; Fri, 3 Mar 2017 17:30:29 +0000 From: Jerin Jacob To: dev@dpdk.org Cc: thomas.monjalon@6wind.com, bruce.richardson@intel.com, harry.van.haaren@intel.com, hemant.agrawal@nxp.com, gage.eads@intel.com, nipun.gupta@nxp.com, santosh.shukla@caviumnetworks.com, Jerin Jacob Date: Fri, 3 Mar 2017 22:58:06 +0530 Message-Id: <1488562101-6658-25-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1488562101-6658-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1488562101-6658-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BMXPR01CA0021.INDPRD01.PROD.OUTLOOK.COM (10.174.214.159) To BN3PR0701MB1719.namprd07.prod.outlook.com (10.163.39.18) X-MS-Office365-Filtering-Correlation-Id: 8ace7f1c-fce6-4d8a-9273-08d4625aff20 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN3PR0701MB1719; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 3:FmSdy6jA0Msa5rljIIKRme3JMNESGPoMjkYDRfN9RVVz0KkwPbr/Br7xe3VRpH8nh/zbyZ9PB4mwDk2NuvlaCi5EjWuS+EVN7kuRzx72w7Qpw9Lyy/BZKNyY0wInYCW+AQmyJ/bvj3OX1e8w6+NAt9JJ8CMfI6YnE9cbr+tV9/tQ3xpa8xXBzzcTUEGbvL0sVryxds4DEOj223P7w50k40pj5Hf2O7TIewHVNQ48TXzKem5WjsMZ4sPlv1eU1aSeEwlurirdJFceGsuXkoSaHw==; 25:Z5DotNVqrYiVJOsp7PTf6e2aH5+yV5Kk4/rBTEQFXNNNDktJbocksTeg1sKB8i+HuStxdWqKIlXLH+SK2zgNmka1OOch60btI05181xBMaq+x0VMuH1BTknfLoKJwg5huhAIuHIajnlyQE+1OWU1kMYDUdm+e4WaTFldH5LvHybj3J+41HG27eLyFQeHjKClvomAODfKRPVFVfuk6nn7psaVV+YhozWS3NPfViDkJzlBPjXVzWCNvJT8Ynhv6/h9h/zkgMXaLoYRD3oMvt0I21utvhz5XG8BaRVyBUbeMl6CvLarVzRGTPGKc2yGr3C6yp7zRhD/VdktjETGzvOl2NS13IbF/DLEvbLuMjPFxsP0UIvhyaFO+5q99BuAWiKGm24CMIFUZcCKqM12VwQF5u6jNnJf/iC4gdvNP9KTreOoi0wp685KAWQ6j7/80bLJ9P58N6KKpDQ2yiDcJrgtTA== X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 31:tKYhOh2pvsKeICoAWIVRCagvAqn4k5A8yxcbL6gRix8oepKh+kKFGwqoXIW6KMvIuRHBbiF0miWOkNANUFbYd2r6AN5Q/FC6m0ViqMGaAudT7NpbQk0OuYB9nYxx4MNVShMvGhEZ+mgzA7Y3WjD9cVkJrTEPr3zoOVSDD3W2RvA8DNaPI5M60QhG3BhWmTDlya4NMuAhbul9xG2tAF0UJlwZk1x8ArkmmgJJi9xJv/I=; 20:a1EJ6nXZovr+Y0BVf83ZbElAo44gdy3wf3Uq4uTIXvsvrhmUy2hlWs1wroGUpOgSA1xJRNGUF40ePFXU/LCuITz9ey22hCoXer47nUs6MB+UgIyRiOU45I0PFRbqEsD7QXvcz/D/kV47ZvsBlp3OqLdGq047UZYa/kGk3AEeh9AAzz7vHhf7TLLeuxHObAqrq0s/a/5cWEAZItR1Bk74WBo8O6j/PdtFWdPrB3SnPdEtZfqzG76dIRRG/ZdMeAc2Pe23hU2Sc9D9g6PHG+oAQpXACJpemhZPHyrqSycNZj0iRjU2HXB1s9TYZ+ctR1JZ5aNB+IGsRD6G0TMzZrElLDMPOuU0l6YAAzHxawyAdLVZpS96VWE96WMjwCZCg0HZFVKk7goqotiUIb3jUJY/7LnDtUjf+MOKGPj4pP7OZyrz7k3zdADK7LcyyX12t6YOSBgY1c9jIrtxmwa+27XVAaJ3R7tSPDBUOyr9Gde/ZRR62xnGFNeJ60TxpTWpv2PbrqxcHa/pXB/qCKNnWWb0GuNj1PztcjDyPCzhOkDitlECSiHFhAiRhosiPduGNmDDZYB+F0fKcLp1a+VnmNFVl+7abj+ngkzNVwwZWzGBd2M= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123555025)(20161123560025)(20161123562025)(20161123558025)(20161123564025)(6072148); SRVR:BN3PR0701MB1719; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1719; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 4:f6xojJOy75zgYPfCA33SxXhY3Shvs8By2CLVNIxbWQLhXSb55ccuu8nbG5h0uSV0MwvN/1FSrTl71yDsj794UUcN9PQs4DtJLVTRzfZNOqAQF1FIrVyxXrVbC9IF6zmOm3yDAKJcM75fzOGbSjp3QDI4P8aBUDOBRA7xSy+Am+/Z9ALjqjSiNAW/3KTshNj1u0+2gpfOnkE8h4yy15uudIvr0RicHQrKlksdE6f889z1wUV4KzBqBkzh8XmW4e/l9HBkB4ELZh6hTMSCb8Du032JL18cwUBQfVtPMU+GR3M3FyD9GMUyZqeF3Kqp89xKBpLBSIRj77VOlmdi5/a32qUiIDyKDbBObT2y0ScvrTMhgvBQXWP2WuhNJJj2THjhxobnen66PZjEEkZakty3NdQHWPytXSrVUzE9xVRjNRvxJB8Oilogb3EPKfihTUQDwSp+iucy3RO5u9pkr8Tmi+U9wLWd+RiItidYfv8omukPwaFL/vdIo9VckwfnHE8pXXiFhmTk6hSQi+0890ikz1MuDvDizMWzd7A64tsFDwgCRuPR15OvzGzrBB1VNdK/nWOu9egjxNpehD3SaqqPKBlu11fnYi2KPyh6Y6pw3wc= X-Forefront-PRVS: 0235CBE7D0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(39450400003)(3846002)(50986999)(6116002)(36756003)(81166006)(6512007)(97736004)(2361001)(2351001)(6506006)(5660300001)(42186005)(50226002)(8676002)(6666003)(106356001)(8656002)(2950100002)(2906002)(25786008)(47776003)(6486002)(76176999)(33646002)(7736002)(107886003)(42882006)(66066001)(110136004)(4326008)(38730400002)(6916009)(305945005)(48376002)(92566002)(5009440100003)(5003940100001)(50466002)(189998001)(53936002)(7099028)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1719; H:localhost.localdomain.localdomain; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1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Output: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 7:FxWWfT074A596+Fp+WMc8avxIbSgcM0a/jA9FZJmiqW/8FxVAGNXws/z7zlbCAqTNUZzuiNBimqsH0SCpL7ARp+ovkQysLuXUvOu0X1MVrYxOdcZxIDJaLfalSCosN+7rV9jMHNzuo7OjTXzuKtuVKhEowJHRsodIbGZd/LQGTBA1SNscdrGIxhdcpO4kSKXuoBMTiy+sbvc8uM57ytapAM1adWD/xVM69YbqwjpRfbaxZ3nz1eI9PiaJmQ9ageLA3OB1e6Mx7XGRXQ67UDfy9yKlp1zl2UG+nVNaW+U4wlCYarHaZp1kXF4n/MFRV5i9lLfwdJl5Jtd5s+Xu/FAOw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2017 17:30:29.7672 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1719 Subject: [dpdk-dev] [PATCH 24/39] app/test: octeontx unit test case helper functions 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: Fri, 03 Mar 2017 17:30:35 -0000 Add helper functions to generate, inject, consume and validate the events. Signed-off-by: Jerin Jacob --- app/test/test_eventdev_octeontx.c | 202 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) diff --git a/app/test/test_eventdev_octeontx.c b/app/test/test_eventdev_octeontx.c index e28880b..8a03920 100644 --- a/app/test/test_eventdev_octeontx.c +++ b/app/test/test_eventdev_octeontx.c @@ -54,6 +54,52 @@ static int evdev; static struct rte_mempool *eventdev_test_mempool; +struct event_attr { + uint32_t flow_id; + uint8_t event_type; + uint8_t sub_event_type; + uint8_t sched_type; + uint8_t queue; + uint8_t port; +}; + + +static uint32_t seqn_list_index; +static int seqn_list[NUM_PACKETS]; + +static inline void +seqn_list_init(void) +{ + RTE_BUILD_BUG_ON(NUM_PACKETS < MAX_EVENTS); + memset(seqn_list, 0, sizeof(seqn_list)); + seqn_list_index = 0; +} + +static inline int +seqn_list_update(int val) +{ + if (seqn_list_index >= NUM_PACKETS) + return TEST_FAILED; + + seqn_list[seqn_list_index++] = val; + rte_smp_wmb(); + return TEST_SUCCESS; +} + +static inline int +seqn_list_check(int limit) +{ + int i; + + for (i = 0; i < limit; i++) { + if (seqn_list[i] != i) { + printf("Seqn mismatch %d %d\n", seqn_list[i], i); + return TEST_FAILED; + } + } + return TEST_SUCCESS; +} + static int testsuite_setup(void) { @@ -205,6 +251,162 @@ eventdev_teardown(void) rte_mempool_free(eventdev_test_mempool); } +static inline void +update_event_and_validation_attr(struct rte_mbuf *m, struct rte_event *ev, + uint32_t flow_id, uint8_t event_type, + uint8_t sub_event_type, uint8_t sched_type, + uint8_t queue, uint8_t port) +{ + struct event_attr *attr; + + /* Store the event attributes in mbuf for future reference */ + attr = rte_pktmbuf_mtod(m, struct event_attr *); + attr->flow_id = flow_id; + attr->event_type = event_type; + attr->sub_event_type = sub_event_type; + attr->sched_type = sched_type; + attr->queue = queue; + attr->port = port; + + ev->flow_id = flow_id; + ev->sub_event_type = sub_event_type; + ev->event_type = event_type; + /* Inject the new event */ + ev->op = RTE_EVENT_OP_NEW; + ev->sched_type = sched_type; + ev->queue_id = queue; + ev->mbuf = m; +} + +static inline int +inject_events(uint32_t flow_id, uint8_t event_type, uint8_t sub_event_type, + uint8_t sched_type, uint8_t queue, uint8_t port, + unsigned int events) +{ + struct rte_mbuf *m; + unsigned int i; + + for (i = 0; i < events; i++) { + struct rte_event ev = {0}; + + m = rte_pktmbuf_alloc(eventdev_test_mempool); + TEST_ASSERT_NOT_NULL(m, "mempool alloc failed"); + + m->seqn = i; + update_event_and_validation_attr(m, &ev, flow_id, event_type, + sub_event_type, sched_type, queue, port); + rte_event_enqueue_burst(evdev, port, &ev, 1); + } + return 0; +} + +static inline int +check_excess_events(uint8_t port) +{ + int i; + uint16_t valid_event; + struct rte_event ev; + + /* Check for excess events, try for a few times and exit */ + for (i = 0; i < 32; i++) { + valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1, 0); + + TEST_ASSERT_SUCCESS(valid_event, "Unexpected valid event=%d", + ev.mbuf->seqn); + } + return 0; +} + +static inline int +generate_random_events(const unsigned int total_events) +{ + struct rte_event_dev_info info; + unsigned int i; + int ret; + + ret = rte_event_dev_info_get(evdev, &info); + TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); + for (i = 0; i < total_events; i++) { + ret = inject_events( + rte_rand() % info.max_event_queue_flows /*flow_id */, + rte_rand() % (RTE_EVENT_TYPE_CPU + 1) /* event_type */, + rte_rand() % 256 /* sub_event_type */, + rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1), + rte_rand() % rte_event_queue_count(evdev) /* queue */, + 0 /* port */, + 1 /* events */); + if (ret) + return TEST_FAILED; + } + return ret; +} + +static inline int +validate_event(struct rte_event *ev) +{ + struct event_attr *attr; + + attr = rte_pktmbuf_mtod(ev->mbuf, struct event_attr *); + TEST_ASSERT_EQUAL(attr->flow_id, ev->flow_id, + "flow_id mismatch enq=%d deq =%d", + attr->flow_id, ev->flow_id); + TEST_ASSERT_EQUAL(attr->event_type, ev->event_type, + "event_type mismatch enq=%d deq =%d", + attr->event_type, ev->event_type); + TEST_ASSERT_EQUAL(attr->sub_event_type, ev->sub_event_type, + "sub_event_type mismatch enq=%d deq =%d", + attr->sub_event_type, ev->sub_event_type); + TEST_ASSERT_EQUAL(attr->sched_type, ev->sched_type, + "sched_type mismatch enq=%d deq =%d", + attr->sched_type, ev->sched_type); + TEST_ASSERT_EQUAL(attr->queue, ev->queue_id, + "queue mismatch enq=%d deq =%d", + attr->queue, ev->queue_id); + return 0; +} + +typedef int (*validate_event_cb)(uint32_t index, uint8_t port, + struct rte_event *ev); + +static inline int +consume_events(uint8_t port, const uint32_t total_events, validate_event_cb fn) +{ + int ret; + uint16_t valid_event; + uint32_t events = 0, forward_progress_cnt = 0, index = 0; + struct rte_event ev; + + while (1) { + if (++forward_progress_cnt > UINT16_MAX) { + printf("Detected deadlock\n"); + return TEST_FAILED; + } + + valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1, 0); + if (!valid_event) + continue; + + forward_progress_cnt = 0; + ret = validate_event(&ev); + if (ret) + return TEST_FAILED; + + if (fn != NULL) { + ret = fn(index, port, &ev); + TEST_ASSERT_SUCCESS(ret, + "Failed to validate test specific event"); + } + + ++index; + + rte_pktmbuf_free(ev.mbuf); + if (++events >= total_events) + break; + } + + return check_excess_events(port); +} + static struct unit_test_suite eventdev_octeontx_testsuite = { .suite_name = "eventdev octeontx unit test suite", .setup = testsuite_setup, -- 2.5.5