From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id EFBF3A0096 for ; Sat, 16 Mar 2019 21:27:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0FC113977; Sat, 16 Mar 2019 21:27:51 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id E766B239 for ; Sat, 16 Mar 2019 21:27:48 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2GKLm3w006381; Sat, 16 Mar 2019 13:27:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=kUNIoA7KKryBB4PQrkG0dD0EqZw4T/5TdYNJcoNFG+k=; b=NLMvGoE2IL0Q5Sss/fjhdx4o6sUAN5oRcKO//CQZL0Jyhkwh8P4mYy8H63BGboGfKVm1 x0F8sIj7kQGEniPpHHKJUmxKIhZWGaKuUx+qoGKSQ5/iD1y49V8rZCHtxk+Zh60cZVNm dO48iWqZ0qxGOv7d22kWCEaEvQcV9LXrknDD5fZbdWtOjHAtrQ+gmsdYXN1OR8XECLk3 w+43SJokHQfjdCp79QCNQ7yieChxEDMTblZycnkYCzVDHEAbL/FqUEd65I+/DZ9lnaZK s8lF/9fwsy5lYBgKsTmTihxk+SA3eQKgJTIno5axAzOJyHVnArV2B03W7IjGniZT7jIM 5A== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2r8xgn1bax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 16 Mar 2019 13:27:47 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sat, 16 Mar 2019 13:27:41 -0700 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (104.47.50.52) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Sat, 16 Mar 2019 13:27:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kUNIoA7KKryBB4PQrkG0dD0EqZw4T/5TdYNJcoNFG+k=; b=ETADdNff3Y/LfyZJCqusMVftESur1AxtDNIxWTnRZrNDHEE+ZmWhD2ZEsqdfTOlYB5Pw21V3I4Zj6YSauxsgQgSKoE1bN+ypgsF3pXjCUPiRcBEXib9JdvHfVUBrYEsJ3xktPomzGXDKRQddJKhybcUS3vp2tHuOdAfg9RV4nKY= Received: from CY4PR1801MB1863.namprd18.prod.outlook.com (10.171.255.14) by CY4PR1801MB1992.namprd18.prod.outlook.com (10.171.255.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.14; Sat, 16 Mar 2019 20:27:39 +0000 Received: from CY4PR1801MB1863.namprd18.prod.outlook.com ([fe80::286d:5e93:974e:8bfa]) by CY4PR1801MB1863.namprd18.prod.outlook.com ([fe80::286d:5e93:974e:8bfa%2]) with mapi id 15.20.1709.011; Sat, 16 Mar 2019 20:27:39 +0000 From: Pavan Nikhilesh Bhagavatula To: Jerin Jacob Kollanukkaran , "erik.g.carrillo@intel.com" CC: "dev@dpdk.org" , Pavan Nikhilesh Bhagavatula Thread-Topic: [dpdk-dev] [PATCH 2/2] test/event_timer: improve unit test compatability Thread-Index: AQHU3DazfFnpRuBHYU6dLI42eOmoNA== Date: Sat, 16 Mar 2019 20:27:39 +0000 Message-ID: <20190316202709.11346-2-pbhagavatula@marvell.com> References: <20190316202709.11346-1-pbhagavatula@marvell.com> In-Reply-To: <20190316202709.11346-1-pbhagavatula@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BMXPR01CA0026.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:c::12) To CY4PR1801MB1863.namprd18.prod.outlook.com (2603:10b6:910:7a::14) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.21.0 x-originating-ip: [115.113.156.3] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 449994ed-e61b-4d28-5fd8-08d6aa4dd5aa x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:CY4PR1801MB1992; x-ms-traffictypediagnostic: CY4PR1801MB1992: x-microsoft-antispam-prvs: x-forefront-prvs: 09781D4C35 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(136003)(39830400003)(396003)(376002)(199004)(189003)(446003)(7736002)(8676002)(76176011)(71190400001)(6116002)(25786009)(4326008)(71200400001)(256004)(102836004)(3846002)(6506007)(14444005)(26005)(386003)(55236004)(54906003)(5660300002)(86362001)(105586002)(81166006)(106356001)(2501003)(2906002)(110136005)(36756003)(305945005)(107886003)(8936002)(6512007)(99286004)(81156014)(1076003)(316002)(6436002)(6486002)(14454004)(97736004)(186003)(50226002)(66066001)(478600001)(2616005)(476003)(11346002)(68736007)(486006)(53936002)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1801MB1992; H:CY4PR1801MB1863.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 634uvmxklGBaIk3ccckiNx8hq7BfVuKLm1KjW7YJ1evgZutRrpaf8NJirEUM39uaTavtQk4JVdS7pZEPb8eh3DWRP6X7AlBD0kMjhUOlV384LkVf2TWUlmoAlR9BbMCvtCxDrxfL4kvSA0Hlwg3IBkt0ryvzUBFCI0BL8HJd3t4Af7llOcHkBHU7cMxMGBlfwCJgAjeWIS1TzM67EH7LR8Zh55vvLO0WCJSY84GQdwE7RbQX3YQBvQ/TDJIEJEsqB2y5sUJloCFlNMJea7f9zNT0KwZs9QtanUEKhh/X5x2koWA/XFOb5IqGt1qSzxV/xWGsDJs13u3ktCJVNzEsd7x1Hm/MCA/hhgM0OH8t7SE2jukmmL4/SYPwxhOsFCb7p73D95WZMfNaZK3hlJ0H3oK4M9uYW1wbl18tRL+lC2U= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 449994ed-e61b-4d28-5fd8-08d6aa4dd5aa X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Mar 2019 20:27:39.7473 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1801MB1992 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-16_16:, , signatures=0 Subject: [dpdk-dev] [PATCH 2/2] test/event_timer: improve unit test compatability 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" Message-ID: <20190316202739.DKl6_E6qWhUFGvR1TqPKGFwQGFBfauP4gX7IS2OfIfA@z> From: Pavan Nikhilesh Check if eventdev is open system eventdevs i.e. max_num_events =3D -1 before asserting. Allow event timer adapter to adjust the resolution using RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES and re-calculate timeout ticks based on the adjusted resolution. Signed-off-by: Pavan Nikhilesh --- app/test/test_event_timer_adapter.c | 61 +++++++++++++++++------------ 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/app/test/test_event_timer_adapter.c b/app/test/test_event_time= r_adapter.c index d4b78e093..742ca8181 100644 --- a/app/test/test_event_timer_adapter.c +++ b/app/test/test_event_timer_adapter.c @@ -42,8 +42,13 @@ static struct rte_event_timer_adapter *timdev; static struct rte_mempool *eventdev_test_mempool; static struct rte_ring *timer_producer_ring; static uint64_t global_bkt_tck_ns; +static uint64_t global_info_bkt_tck_ns; static volatile uint8_t arm_done; =20 +#define CALC_TICKS(tks) \ + ((tks * global_bkt_tck_ns) / global_info_bkt_tck_ns) + + static bool using_services; static uint32_t test_lcore1; static uint32_t test_lcore2; @@ -80,7 +85,8 @@ eventdev_setup(void) =20 ret =3D rte_event_dev_info_get(evdev, &info); TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info"); - TEST_ASSERT(info.max_num_events >=3D (int32_t)MAX_TIMERS, + TEST_ASSERT(info.max_num_events < 0 || + info.max_num_events >=3D (int32_t)MAX_TIMERS, "ERROR max_num_events=3D%d < max_events=3D%d", info.max_num_events, MAX_TIMERS); =20 @@ -276,12 +282,14 @@ test_port_conf_cb(uint16_t id, uint8_t event_dev_id, = uint8_t *event_port_id, static int _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns) { + struct rte_event_timer_adapter_info info; struct rte_event_timer_adapter_conf config =3D { .event_dev_id =3D evdev, .timer_adapter_id =3D TEST_ADAPTER_ID, .timer_tick_ns =3D bkt_tck_ns, .max_tmo_ns =3D max_tmo_ns, .nb_timers =3D MAX_TIMERS * 10, + .flags =3D RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES, }; uint32_t caps =3D 0; const char *pool_name =3D "timdev_test_pool"; @@ -317,6 +325,10 @@ _timdev_setup(uint64_t max_tmo_ns, uint64_t bkt_tck_ns= ) return TEST_FAILED; } =20 + rte_event_timer_adapter_get_info(timdev, &info); + + global_info_bkt_tck_ns =3D info.min_resolution_ns; + return TEST_SUCCESS; } =20 @@ -384,10 +396,11 @@ test_timer_state(void) .state =3D RTE_EVENT_TIMER_NOT_ARMED, }; =20 + rte_mempool_get(eventdev_test_mempool, (void **)&ev_tim); *ev_tim =3D tim; ev_tim->ev.event_ptr =3D ev_tim; - ev_tim->timeout_ticks =3D 120; + ev_tim->timeout_ticks =3D CALC_TICKS(120); =20 TEST_ASSERT_EQUAL(rte_event_timer_arm_burst(timdev, &ev_tim, 1), 0, "Armed timer exceeding max_timeout."); @@ -396,7 +409,7 @@ test_timer_state(void) RTE_EVENT_TIMER_ERROR_TOOLATE, ev_tim->state); =20 ev_tim->state =3D RTE_EVENT_TIMER_NOT_ARMED; - ev_tim->timeout_ticks =3D 10; + ev_tim->timeout_ticks =3D CALC_TICKS(10); =20 TEST_ASSERT_EQUAL(rte_event_timer_arm_burst(timdev, &ev_tim, 1), 1, "Failed to arm timer with proper timeout."); @@ -412,7 +425,7 @@ test_timer_state(void) "Armed timer failed to trigger."); =20 ev_tim->state =3D RTE_EVENT_TIMER_NOT_ARMED; - ev_tim->timeout_ticks =3D 90; + ev_tim->timeout_ticks =3D CALC_TICKS(90); TEST_ASSERT_EQUAL(rte_event_timer_arm_burst(timdev, &ev_tim, 1), 1, "Failed to arm timer with proper timeout."); TEST_ASSERT_EQUAL(rte_event_timer_cancel_burst(timdev, &ev_tim, 1), @@ -438,7 +451,7 @@ _arm_timers(uint64_t timeout_tcks, uint64_t timers) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D timeout_tcks, + .timeout_ticks =3D CALC_TICKS(timeout_tcks), }; =20 for (i =3D 0; i < timers; i++) { @@ -539,7 +552,7 @@ _arm_timers_burst(uint64_t timeout_tcks, uint64_t timer= s) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D timeout_tcks, + .timeout_ticks =3D CALC_TICKS(timeout_tcks), }; =20 for (i =3D 0; i < timers / MAX_BURST; i++) { @@ -608,7 +621,7 @@ test_timer_cancel(void) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D 20, + .timeout_ticks =3D CALC_TICKS(20), }; =20 for (i =3D 0; i < MAX_TIMERS; i++) { @@ -650,7 +663,7 @@ _cancel_producer(uint64_t timeout_tcks, uint64_t timers= ) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D timeout_tcks, + .timeout_ticks =3D CALC_TICKS(timeout_tcks), }; =20 for (i =3D 0; i < timers; i++) { @@ -689,7 +702,7 @@ _cancel_producer_burst(uint64_t timeout_tcks, uint64_t = timers) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D timeout_tcks, + .timeout_ticks =3D CALC_TICKS(timeout_tcks), }; int arm_count =3D 0; =20 @@ -870,7 +883,7 @@ test_timer_cancel_random(void) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D 20, + .timeout_ticks =3D CALC_TICKS(20), }; =20 for (i =3D 0; i < MAX_TIMERS; i++) { @@ -917,7 +930,7 @@ adapter_create(void) .timer_tick_ns =3D NSECPERSEC / 10, .max_tmo_ns =3D 180 * NSECPERSEC, .nb_timers =3D MAX_TIMERS, - .flags =3D 0, + .flags =3D RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES, }; uint32_t caps =3D 0; =20 @@ -1058,7 +1071,7 @@ stat_inc_reset_ev_enq(void) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D 5, // expire in .5 sec + .timeout_ticks =3D CALC_TICKS(5), // expire in .5 sec }; =20 ret =3D rte_mempool_get_bulk(eventdev_test_mempool, (void **)evtims, @@ -1151,7 +1164,7 @@ event_timer_arm(void) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D 5, // expire in .5 sec + .timeout_ticks =3D CALC_TICKS(5), // expire in .5 sec }; =20 rte_mempool_get(eventdev_test_mempool, (void **)&evtim); @@ -1208,7 +1221,7 @@ event_timer_arm_double(void) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D 5, // expire in .5 sec + .timeout_ticks =3D CALC_TICKS(5), // expire in .5 sec }; =20 rte_mempool_get(eventdev_test_mempool, (void **)&evtim); @@ -1267,7 +1280,7 @@ event_timer_arm_expiry(void) =20 /* Set up an event timer */ *evtim =3D init_tim; - evtim->timeout_ticks =3D 30, // expire in 3 secs + evtim->timeout_ticks =3D CALC_TICKS(30), // expire in 3 secs evtim->ev.event_ptr =3D evtim; =20 ret =3D rte_event_timer_arm_burst(adapter, &evtim, 1); @@ -1327,7 +1340,7 @@ event_timer_arm_rearm(void) =20 /* Set up a timer */ *evtim =3D init_tim; - evtim->timeout_ticks =3D 1; // expire in 0.1 sec + evtim->timeout_ticks =3D CALC_TICKS(1); // expire in 0.1 sec evtim->ev.event_ptr =3D evtim; =20 /* Arm it */ @@ -1388,7 +1401,7 @@ event_timer_arm_max(void) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D 5, // expire in .5 sec + .timeout_ticks =3D CALC_TICKS(5), // expire in .5 sec }; =20 ret =3D rte_mempool_get_bulk(eventdev_test_mempool, (void **)evtims, @@ -1456,7 +1469,7 @@ event_timer_arm_invalid_sched_type(void) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D 5, // expire in .5 sec + .timeout_ticks =3D CALC_TICKS(5), // expire in .5 sec }; =20 if (!using_services) @@ -1498,7 +1511,7 @@ event_timer_arm_invalid_timeout(void) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D 5, // expire in .5 sec + .timeout_ticks =3D CALC_TICKS(5), // expire in .5 sec }; =20 rte_mempool_get(eventdev_test_mempool, (void **)&evtim); @@ -1521,7 +1534,7 @@ event_timer_arm_invalid_timeout(void) =20 *evtim =3D init_tim; evtim->ev.event_ptr =3D evtim; - evtim->timeout_ticks =3D 1801; // timeout too big + evtim->timeout_ticks =3D CALC_TICKS(1801); // timeout too big =20 ret =3D rte_event_timer_arm_burst(timdev, &evtim, 1); TEST_ASSERT_EQUAL(ret, 0, "Expected to fail timer arm with invalid " @@ -1569,7 +1582,7 @@ event_timer_cancel(void) /* Set up a timer */ *evtim =3D init_tim; evtim->ev.event_ptr =3D evtim; - evtim->timeout_ticks =3D 30; // expire in 3 sec + evtim->timeout_ticks =3D CALC_TICKS(30); // expire in 3 sec =20 /* Check that cancelling an inited but unarmed timer fails */ ret =3D rte_event_timer_cancel_burst(adapter, &evtim, 1); @@ -1619,7 +1632,7 @@ event_timer_cancel_double(void) .ev.priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, .ev.event_type =3D RTE_EVENT_TYPE_TIMER, .state =3D RTE_EVENT_TIMER_NOT_ARMED, - .timeout_ticks =3D 5, // expire in .5 sec + .timeout_ticks =3D CALC_TICKS(5), // expire in .5 sec }; =20 rte_mempool_get(eventdev_test_mempool, (void **)&evtim); @@ -1631,7 +1644,7 @@ event_timer_cancel_double(void) /* Set up a timer */ *evtim =3D init_tim; evtim->ev.event_ptr =3D evtim; - evtim->timeout_ticks =3D 30; // expire in 3 sec + evtim->timeout_ticks =3D CALC_TICKS(30); // expire in 3 sec =20 ret =3D rte_event_timer_arm_burst(adapter, &evtim, 1); TEST_ASSERT_EQUAL(ret, 1, "Failed to arm event timer: %s\n", @@ -1716,7 +1729,7 @@ adapter_create_max(void) .timer_tick_ns =3D NSECPERSEC / 10, .max_tmo_ns =3D 180 * NSECPERSEC, .nb_timers =3D MAX_TIMERS, - .flags =3D 0, + .flags =3D RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES, }; =20 if (!using_services) --=20 2.21.0