From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0079.outbound.protection.outlook.com [104.47.38.79]) by dpdk.org (Postfix) with ESMTP id 59B6B2BDF for ; Fri, 31 Mar 2017 21:37:03 +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=87/k2KRHIn7qlluwkSMiRyS9oaAsEUfRklXtlWkJf5M=; b=SQCpukTSLgntzzwsJODxTXJA4hXURDCO/PpfTPu4U/qYRXg5dqIOIocacXbxul0uciaVmBPHEcRy2DL7GVhJBgb6U3WkhvY7asyy31LxJQGkvC4cEeL7hJ08/t5wQT97wEUIaQk7NWbh1/fuklWrCAljxDoC/wORURiFqLvRz0g= 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 (14.140.2.178) by BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14; Fri, 31 Mar 2017 19:36:58 +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: Sat, 1 Apr 2017 01:04:48 +0530 Message-Id: <1490988905-12584-22-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1490988905-12584-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1488562101-6658-1-git-send-email-jerin.jacob@caviumnetworks.com> <1490988905-12584-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: MAXPR01CA0058.INDPRD01.PROD.OUTLOOK.COM (10.164.146.158) To BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) X-MS-Office365-Filtering-Correlation-Id: 4426545a-31c7-461c-b7ec-08d4786d4dba X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 3:Awl2wfjOINBmX/ZHI+E7VbJHMCb7FzNMADTlyKspC5eTPaAu5CwsNMRMoPOOlTswPWtHoDQAwKLNEY/XBjBMpxN7clTx+pWY5TJt0MeOIu9gKjKNqr4Kxu5KTWwCx9y2GuZHqmzLaowZrh7/7iF45WFa4dYPGSS7bTKnec5od2vUyEY4mg2gzzeVgIGFOYnxkthS1YkZq9cL+tWctSMBZo5F0p+KOcasceU7pI3y3gu9iJLG4GFcIOzuE/79HF2KtXPBVjGlRe8cyBCtQ/VI7rMS5xX5GvBWoZYwGfndYBBhTEWpJq9UtPS24MD2N89jhsD3ylXQFjqMzlm7/jBzEw==; 25:NzAoutFZ9xSRDGFt9SZDgzXemzoeBg6MomIf58trdtI2UL4zIO/qoGcVcv5S9vhD8yHCg5JYGCU6bmHGsbzJyF0Q8J5Cn6NHJdMgeGclQqeayci6AR7zYi7u7H7l5xbZdO1Pbxxa0wTABG5Nklg8oKDu3LH7jfo/ZCo1H36kY515UR1PknN8c6IqIrpolWwHAvTJiROqjR4G/JUDq+cbWBq+MIsTn2imSYahck2vp2Qli8OM6CzNMIsZKrTMG+BpHWhgJog0JvR6HJw8u/BiImIvbrITXhKN9FN+IlO0eiacHPXSCbaF1plrIIL8TAywMMBw7FKWoCBy/V1jELN2gl35ICfUyrRtNQYjbvHiUvUP2bP3OeX99ajGSDNLsRxS4bPB/xUsca3Uku35qq/3V4Z/fyy/7BQX+qx72kf+KpuClmWUbHDYqnKudTpsjY1M1qPWydqYSiWLRDZiQYpDHg== X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 31:E+XhmdohrXlbXIdMtd9b9kmkctzoMcH8+V0lVNviuZL2jsdRzX9hQjkVBm7seR+MwlF5+5gZXcMMciNaGYzu2ovU9atcruQTLRHSOFEURd5V08AaglMGSWWtZMrxCkIS4i8AaNIwTBl1zndvy9FSBlkXljRdoNhlzqOgOf3/0drg3at4mpAFAW9KRPjxj6uI2mUEPobQNA9gB52qQJsrge3UwaAqM8KOManmvhFcqJWuEuNv4VehEdfjau7ka/Eu; 20:4edKSxfs5NxcdnoSuAxtK9f62Ku1fUJAvEqmRgz7BbUrIfTFh6KIbs73PX6MjZ7ENAjo8/0vJP2jkMGcQkumR1YEalLw1BENR2caYTTMVfjgJ8VBop76m+HrZur2XRaQFtiUfF86YRW5GFtSpt3iWNnmfbmN11XiBZRryTxAGmKBHCKBVoZ3MVdGxxW5CPAQg+FQdmytQhpQaTKZzZB29C6/05oeYoYuQxyzXWdTNY89X+m03UGQfME0ZNomAl2ZrneBcBfhpb4zVTbQ46S49o+rZ6okYFOOGv90MJynF/+0jmmDWYbLo5B//a1MbzE2qLy1Le7z3QJOnacg0ircAttkFQ7v9GoxmbS7s6YXBhs2I0/aMHoFVpqMeYaichvEOWuJGQgGNT/IycT2fjCLNARjPUYDMgNWBsctQuTMyOEOVGVvvs4jPpyczD05CeYT0joYL+vfGFHTF1LY+tZoQzHUKFspOg00A9FLLcbDBTPH89G1FXxrA/HGn49R5eZTogiWhrzF5FhTdTD5ofRFzLxCzjCpl4xseO1Wme2sJzdgEJ3BpB7xsk4upXOUtCKl0lVNxYmfHvIGQeuMYzqPCj/nAj9ECHPjo8FJhkdzGOM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(3002001)(6041248)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123564025)(6072148); SRVR:BY1PR0701MB1723; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 4:rn/igiPZEbVVxisOcM+bF+WS23BUzfxCLtMWpyGVROBowoBZ3kX0mJV2EqtlrVME6mVL3tUh6CRA5SsD4az94BPh/oBn4n+DkZjWdiOGXZPnCuSbcBnqd9nV+akAMxXDO41aZgIhOQmpyRckpdNFpY4TTbICEx4frbzaTcLrTkeDOFGAqI4ZGQa4zO9WQ2l4S/qZU6FrXEudU57IFG2DB1gMGruDr+oBAr1zrsTTu89LxFL+Sqr/Bd8v10Ulq3aEFO6WlWw/Dh3fchVjSUDdS+yU8husJAdAKwZxxGGfsU21mvzv0QLE8vIjsXGDOhLC5XoCb9vzLUD4bkm1de973Tt7L9mVRHTIHOvw6slbMe5y9i/iK2HCBUTYVjK3GIIFYEtlDsYzzPEYOGmfdCfDrE7pfYRUgW0xWQNcAmy8K9GETh1atQkCgaVwdd1HZmzC/ExL1R4socpNpPmQ+IF86U91Bqx3r3Mep5RPWvx5qXeJpJ3TVQFOoIyznN+WNGFRMNTOJd14UxSUeRtweeC75yRvoC9CBkSZzu5QlOH4zw29EmuiUj8K2G0MP9A4AziKgWShuNhHfTFHdr0oMGU7RaqPvkU7ttjKsS+vLvsLEsQG69NR2RPFf4iGHMCizOTr4EZE9nTfknBTvI4RKVKcjrioeXiJKhLgXEW1pwcnnaOyNXmvFyGYF2mzEHAQFPY5etSYuG4n6PvAeNwPugL5kUuUe2UKXF/I22Uv4zBtUmn7p+MPXzkdLMhhx5pCY1it X-Forefront-PRVS: 02638D901B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(39450400003)(39410400002)(39400400002)(39850400002)(39840400002)(38730400002)(8676002)(107886003)(110136004)(50466002)(189998001)(305945005)(6506006)(36756003)(50226002)(25786009)(48376002)(6666003)(8656002)(6486002)(7736002)(2950100002)(5660300001)(53936002)(81156014)(81166006)(3846002)(42882006)(6916009)(6116002)(6512007)(42186005)(33646002)(2361001)(2351001)(76176999)(50986999)(5003940100001)(47776003)(2906002)(5009440100003)(4326008)(66066001)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1723; H:localhost.localdomain; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0701MB1723; 23:onud9bBF1VuqJ11oWQTs6f/gxrKQVXKJo3FjCd6?= =?us-ascii?Q?onP5lQQoObE0pyLEn4G6uwTlfCC7iS5sgd38J3tzyT0H3KLzXOL1WmAQznQK?= =?us-ascii?Q?xQYqvnDz15A1GuGDdbvcFyRVqeTRgsloLBTrwUU9Mkc+WNfamtkn/bQvjwVr?= =?us-ascii?Q?fSbbdt7nMBa9dUtBGL7zjtCmwS7bTorDaInifH6GMQRlZE+uNnM2avuwKgep?= =?us-ascii?Q?BFMq6cTv1Z7t6DQ1/oqVzrkHDcPhUeW2L9VaspsV+sno7cE7hO15of8XClCK?= =?us-ascii?Q?gctswNtO5PW+hv+J3n9pXD3Amp5T4HTZTBgUpJCUsDgy03aXvJUkrR9cwC/J?= =?us-ascii?Q?FSQF/m6C+959xB5Y8PAkxV/pL6RPh/jregrJyWneSrgMx78ReUx0tSFYgD4g?= =?us-ascii?Q?6V7oeEDhZG1hK9VH6KqDiMYKKnJ+HQH48Kxn93xz81rdJmBoFTWNGt7ztTap?= =?us-ascii?Q?fqGC/bNY9x9cRGGQO6RUdz8TCZuE+A5/G8suDwVHaR+FfH/7V1rXarxOgCJN?= =?us-ascii?Q?em5zGRZ/8NjZyp9A9y+KAE5Dkqz/tRT4j+h1MZ3HIkwNRN2wy8fXEGH2FJRg?= =?us-ascii?Q?jJ+l3o2gi8Bf1UGvGAJb8ogZqwPmmEDbNr92uYNUqF7YxU4V7eMkfmfPd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/OpPSQoKXugqG3/C9TxspS7wh+0F7JeN3/dpun8eqFcVSoGLDphRbgb/9g8qFPSD0sSCabgBElbpaA==; 5:s9+nEgv0vZdINvozj3zHNCkT+nhYNDf4VOu6qlef4MJb2n0VV+xSZ+2uPRgvs+UYetD0bj7ptvxTTm93savV6SkX3B7U79tdeAgKFZM57Opzo9ze/bbC9tiC6fSqucLrN4SWEGPdoVamFmgdxcsBWXgDd8mvfYstA6kd+ZBGoQw=; 24:9xzqQD0pGzcna3qGTs+D2imJQ8TRfPat0miDVMQBP1czVwPRFwUTFJ903xjnsskqXXcS/Q8WWgixd5Gs4ZtvUPoEsEWU+5ydO+KWfUMoCBA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 7:tGNrTgjfSIpFHhHURswym1lBtUYeS2QFw/o0RWYJ8nPFhPb+PU+Wj04f1uEqMIR2YlSAyyz60DHk6T8SHkBR5dos6T8mAUPj88QH1pa3XM1rFT6qrWNjZIgb3XRJelthttm7Pwx9FROVuvMDTMmaacurlzmcNTwm+XuJV9ZyMocQ5ZiNG8C5n4gdQleK2OF1O86TjdB3qXoyA9mU4tFp8eHil8favAu398TjB+g0TnOkfSv6I70qRG6A5jHXPfgsCbsVTBjXwTNWEuw6TXsYAzyR7EKYcE9x5m9yjsFmshIBehwOGaHCnYfM1/aQwEmtErfc9QHRDHrqIQ55j1MBxA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2017 19:36:58.3463 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1723 Subject: [dpdk-dev] [PATCH v2 21/38] test/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, 31 Mar 2017 19:37:04 -0000 Add helper functions to generate, inject, consume and validate the events. Signed-off-by: Jerin Jacob Acked-by: Harry van Haaren --- test/test/test_eventdev_octeontx.c | 202 +++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) diff --git a/test/test/test_eventdev_octeontx.c b/test/test/test_eventdev_octeontx.c index e28880b..412944d 100644 --- a/test/test/test_eventdev_octeontx.c +++ b/test/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 = {}; + + 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