From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id EF9E01B21F for ; Thu, 11 Jan 2018 01:21:46 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2018 16:21:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,342,1511856000"; d="scan'208";a="192627477" Received: from txasoft-yocto.an.intel.com (HELO txasoft-yocto.an.intel.com.) ([10.123.72.111]) by orsmga005.jf.intel.com with ESMTP; 10 Jan 2018 16:21:45 -0800 From: Erik Gabriel Carrillo To: pbhagavatula@caviumnetworks.com Cc: dev@dpdk.org, jerin.jacob@caviumnetworks.com, nipun.gupta@nxp.com, hemant.agrawal@nxp.com Date: Wed, 10 Jan 2018 18:21:10 -0600 Message-Id: <1515630074-29020-20-git-send-email-erik.g.carrillo@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1515630074-29020-1-git-send-email-erik.g.carrillo@intel.com> References: <1512158458-22661-1-git-send-email-erik.g.carrillo@intel.com> <1515630074-29020-1-git-send-email-erik.g.carrillo@intel.com> Subject: [dpdk-dev] [PATCH v6 19/23] test: exercise event timer arm and expiry 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: Thu, 11 Jan 2018 00:21:47 -0000 Add a test that creates an event timer and detects the generation of a timer expiry event being scheduled through the software event device. Signed-off-by: Erik Gabriel Carrillo --- test/test/test_event_timer_adapter.c | 106 +++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/test/test/test_event_timer_adapter.c b/test/test/test_event_timer_adapter.c index 58cbaba..3a16cce 100644 --- a/test/test/test_event_timer_adapter.c +++ b/test/test/test_event_timer_adapter.c @@ -319,6 +319,111 @@ adapter_start_stop(void) return TEST_SUCCESS; } +#define BATCH_SIZE 16 +static int +event_timer_expiry(void) +{ + uint16_t n; + uint32_t evdev_service_id, adapter_service_id; + int ret; + struct rte_event_timer_adapter *adapter = g_adapter; + struct rte_event_timer *evtim = NULL; + struct rte_event_timer *evtim2 = NULL; + struct rte_event evs[BATCH_SIZE]; + + TEST_ASSERT_SUCCESS(rte_event_dev_service_id_get(evdev, + &evdev_service_id), "Failed to get " + "event device service id"); + + TEST_ASSERT(rte_service_lcore_count() > 0, "Need one or more service " + "cores to perform this test"); + + TEST_ASSERT_SUCCESS(rte_event_timer_adapter_service_id_get(g_adapter, + &adapter_service_id), "Failed to get " + "event timer adapter service id"); + + /* Could map using service_id, but just do default mapping */ + ret = rte_service_start_with_defaults(); + TEST_ASSERT_SUCCESS(ret, "Failed to start services"); + + if (rte_event_dev_start(evdev) < 0) { + printf("Failed to start event device\n"); + return TEST_FAILED; + } + + ret = rte_event_timer_adapter_start(adapter); + if (ret < 0) { + printf("Failed to start adapter\n"); + return TEST_FAILED; + } + + /* Set up an event timer */ + rte_mempool_get(g_event_timer_pool, (void **)&evtim); + if (evtim == NULL) { + /* Failed to get an event timer object */ + return TEST_FAILED; + } + + rte_event_timer_init(evtim); + + evtim->ev.event_ptr = evtim; + evtim->ev.queue_id = TEST_QUEUE_ID; + evtim->ev.sched_type = RTE_SCHED_TYPE_ATOMIC; + evtim->timeout_ticks = 30; // expire in 3 sec + + ret = rte_event_timer_arm_burst(adapter, &evtim, 1); + if (ret != 1) { + printf("Failed to arm event timer: %s\n", + rte_strerror(rte_errno)); + return TEST_FAILED; + } + + rte_delay_ms(2999); + + n = rte_event_dequeue_burst(evdev, TEST_PORT_ID, evs, RTE_DIM(evs), 0); + TEST_ASSERT_EQUAL(n, 0, "Dequeued unexpected timer expiry event"); + + /* Delay 1 more millisecond and run the services again - should let us + * dequeue one event + */ + rte_delay_ms(1); + + n = rte_event_dequeue_burst(evdev, TEST_PORT_ID, evs, RTE_DIM(evs), 0); + if (n == 0) { + printf("Failed to dequeue timer expiry event\n"); + return TEST_FAILED; + } + + if (n > 1) { + printf("Dequeued incorrect number (%d) of timer expiry " + "events\n", n); + return TEST_FAILED; + } + + if (evs[0].event_type != RTE_EVENT_TYPE_TIMER) { + printf("Dequeued unexpected type of event\n"); + return TEST_FAILED; + } + + /* Check that we recover the original event timer and then free it */ + evtim2 = evs[0].event_ptr; + TEST_ASSERT_EQUAL(evtim, evtim2, + "Failed to recover pointer to original event timer"); + rte_mempool_put(g_event_timer_pool, evtim2); + + ret = rte_event_timer_adapter_stop(adapter); + if (ret < 0) { + printf("Failed to stop event adapter\n"); + return TEST_FAILED; + } + + rte_event_dev_stop(evdev); + + rte_service_lcore_reset_all(); + + return TEST_SUCCESS; +} + static struct unit_test_suite adapter_tests = { .suite_name = "event timer adapter test suite", .setup = testsuite_setup, @@ -326,6 +431,7 @@ static struct unit_test_suite adapter_tests = { .unit_test_cases = { TEST_CASE(adapter_create_free), TEST_CASE_ST(adapter_create, adapter_free, adapter_start_stop), + TEST_CASE_ST(adapter_create, adapter_free, event_timer_expiry), TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.6.4