From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0043.outbound.protection.outlook.com [104.47.34.43]) by dpdk.org (Postfix) with ESMTP id E33991B321 for ; Fri, 16 Feb 2018 22:37:51 +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=YRl+02uCO5MkOcn4jJTeLVtuQU6dMvyF8G/WqqUFXpE=; b=EWBWCHyk5pQ2X4VobkNv0iI0DX5LHYz5/K1WPRBjynp9n1b+/rZftfCo/0Mjh+g6bAHDQZG1PoA+eewQEW7PELfogzZ4mY7kKLy3JhcDzL2w0i6XPOYq/yKWsux2J/LMp09AvvIe2v4IPbooxc/qC67M5v4kAt1XcTgXttSo/Zk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by DM5PR07MB3467.namprd07.prod.outlook.com (2603:10b6:4:67::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Fri, 16 Feb 2018 21:37:48 +0000 From: Pavan Nikhilesh To: jerin.jacob@caviumnetworks.com, santosh.shukla@caviumnetworks.com, erik.g.carrillo@intel.com Cc: dev@dpdk.org, Pavan Nikhilesh Date: Sat, 17 Feb 2018 03:06:57 +0530 Message-Id: <20180216213700.3415-8-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180216213700.3415-1-pbhagavatula@caviumnetworks.com> References: <20180216213700.3415-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: SG2PR01CA0090.apcprd01.prod.exchangelabs.com (2603:1096:3:15::16) To DM5PR07MB3467.namprd07.prod.outlook.com (2603:10b6:4:67::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 163d4d11-be54-4fe9-8553-08d57585878c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:DM5PR07MB3467; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3467; 3:lPeTDDuYisCdxKi2X7zd8WFmRw7lIARniL77CYViM6rwrdjY8Ib6RBd5lt6b8Qrt762ttv6luP8CrNrK5MXOKvSLPXEuvpMLxlhsbQi61KsPO2b79wfmhJj5kH5cEFuFALArksjo2Ku1s9XrxDK6hlwrV4xgILJl1QdLOgYIHdgOSakEZsmET/UTKzHv2+LZBmmyMkIoUpZXzD/Qg+CrXoZHTO/MwSSH3//Iz4ycxQA/Qv8I9gCvNSZWEwpNR05P; 25:LHEdAruWwxYvWoMMzkQ9Te/BPVcRhdNkNkyK1gBpjj75Z12Z2s4JDwMSprntQTL0g6B8CtVIrghywJqj9eu8ko7orzPwfDX9kiSj5wbnqFBoLAW2AZZHnwK+MrNj5v8Ap6cusVTwVPE2PavNngBE1JTj9yBl25A0iisYbKGhfmONOYGRG+JBxL6qZ6Eq6v71tsttyI3AOHMUf7d1AkQqEPu+PabqqJMn0HwDcc7Nie2X2KJXNoN18i54nhsz0+5VfgIRVN/u9lwJ6D7kIfwTBNgB6RLWU5wo+XufzHzYHEirprFetqK6OIEtJ53sWmldCdR5ptiH2oC85/tU63fv/w==; 31:7k7JctGMlsIgvKVI8G9k+PoEkuUTZXA1e+AiLQxO8VkQPcJA05BeEsEMj/SagzEThi0E8ktWIs6zTzwcveNx3Gxw/2yNXJODDR3JJnJO7HwG/6EHK8eqxBr2vPqL/pTLjA+qIMkVJgMAn37KqTKebkr3RzpvjQRKQE236hBx39Yuuv6l9H3z/M2YjTRnbuMWq/ZLa09MllO4wIv0S9/SlEewnSzNlFn7+uDqPfMA3yM= X-MS-TrafficTypeDiagnostic: DM5PR07MB3467: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3467; 20:rL8p1T2Il8mtcFmS8ZYpoRJdTs+Gjn4KPViLqGIwlRhRr67t/AqdGrX6kOtJgPu5GwsASD2DPLIfT39UEonprhVjqGfh5aDLQcv2JT4dsDkUdDAdACHBxF6Jwwy6K4xorOq005H4drdMKIgoa5Wg0+AsUXMJcOxUE957/mBx/axGnZzfOM5DhiJ3D3ll+qmjjC/vZIs2z0L/2qllw+a5OLo3R+9aTjrTGr45NqdRcXYebKoOwijg5GzZayk2zW79k9gAP0+ASkBY54bMt8PDZgczxqahDg7NHJqwG+IJTW9GQvqyv+VuoeeN7IxO/Apxd+6F+V4+r3UyrgiAv8eaTQT3xau1dEx9/PfZOnFmuZK7byjgemtmU7rEVCXalF1W0TxsIGTnvA0G5IOD7jwRzaBcdppF4rEl3d0gIewJlH1SsW9isQIEoJRSFfOy8BgS+rTfFemN+2o+ocg2qLzGrFxvMEdDZnb+Z0IhUbzBTaVp9sPFq/VruSQ+56W+5j4xoFzfABwMnAoZAh24C5Q34djcaRj/5SMvxydIbg6n2L0NFgsgSABOUTS/ics+RbhzcuWWVGSBjJiFrI12u3UMOmGgjV+cC9WCM2ooK27VZ28=; 4:YJ82T1W/5lwHFsrWH9EjB32ptUsY1yKH5UG5G/EzwwOyTbtgXpiQB1hyr5Scd8TO49O+rOwMOvuWfhB6c7L/4Kv5WVjndDoHqoI+PYiPKkb7fiiRJgjg/ANuuK/Bu0oXvR80AQ3VGi3ZC18uGofQptOJ2jz6iMs/GtBEBcl/OpWuambA51KH8nWssvlOioJoVwMka7Enuh5oZXYhngcQw4U49nb+jCY6ffMtNH2zpkjEU2/yFeTES4GXfWUhjXQ7BoEtx5xUtwp3esv6N+JyYQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(10201501046)(3231101)(944501161)(93006095)(3002001)(6041288)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:DM5PR07MB3467; BCL:0; PCL:0; RULEID:; SRVR:DM5PR07MB3467; X-Forefront-PRVS: 0585417D7B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(346002)(366004)(396003)(39860400002)(39380400002)(376002)(189003)(199004)(6486002)(25786009)(2950100002)(386003)(6506007)(53936002)(42882006)(5009440100003)(4326008)(107886003)(6666003)(59450400001)(6512007)(16586007)(106356001)(316002)(105586002)(36756003)(478600001)(2906002)(47776003)(6116002)(76176011)(3846002)(1076002)(97736004)(66066001)(8676002)(51416003)(50466002)(48376002)(81156014)(5660300001)(68736007)(8936002)(52116002)(16526019)(26005)(305945005)(1857600001)(72206003)(81166006)(50226002)(7736002)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3467; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR07MB3467; 23:JxAsG99xztjt/W+vCr2FlAiEjmD9XT6KnV7B+844x?= =?us-ascii?Q?MZpmLd8gjgo47sulgvbQmGP218+ZmNgEQxUbsrWFcbFgwIC9c0kIz2mzelQP?= =?us-ascii?Q?8IBWKWhFmAqytGsOJHdky7aa1+FCinC2TAH3ROcSSPLwCMdY4QAhLJKtpKAr?= =?us-ascii?Q?YmPr+QhpZnbF0Gt++/q+z402trseu9a4QZOPkHAVCfxUgsb3Dw4EKxFNgPlR?= =?us-ascii?Q?3C2TdW1/uu1ED6XLGrOSKKN1+McReE79bwDDOUjWtzArIGGOS6w0hllaAjhs?= =?us-ascii?Q?lc3BeiapxyyTtuG4iWyAy0N5Ro4+/7qvmHdXyB0Ip0HB32F+knuVX5SW80Lw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rg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2018 21:37:48.9589 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 163d4d11-be54-4fe9-8553-08d57585878c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3467 Subject: [dpdk-dev] [PATCH 07/10] event/octeontx: optimize timer adapter resolution parameters 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, 16 Feb 2018 21:37:52 -0000 When application sets `RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES` flag while creating adapter underlying driver is free to optimize the resolution for best possible configuration. Signed-off-by: Pavan Nikhilesh --- drivers/event/octeontx/timvf_evdev.c | 51 +++++++++++++++++++++++++++++++++++- drivers/event/octeontx/timvf_evdev.h | 6 +++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c index 6cf5d4846..ffdfbb387 100644 --- a/drivers/event/octeontx/timvf_evdev.c +++ b/drivers/event/octeontx/timvf_evdev.c @@ -82,6 +82,48 @@ timvf_get_start_cyc(uint64_t *now, uint8_t ring_id) return octeontx_ssovf_mbox_send(&hdr, NULL, 0, now, sizeof(uint64_t)); } +#define ALIGN_CEIL(a, b) \ + (((a + (typeof(a)) b - 1) / ((typeof(a)) b)) * (typeof(a))b) + +static int +optimize_bucket_parameters(struct timvf_ring *timr) +{ + uint32_t hbkts; + uint32_t lbkts; + uint64_t tck_nsec; + + hbkts = rte_align32pow2(timr->meta.nb_bkts); + tck_nsec = ALIGN_CEIL(timr->max_tout / (hbkts - 1), 10); + + if ((tck_nsec < 1000 || hbkts > TIM_MAX_BUCKETS)) + hbkts = 0; + + lbkts = rte_align32lowpow2(timr->meta.nb_bkts); + tck_nsec = ALIGN_CEIL((timr->max_tout / (lbkts - 1)), 10); + + if ((tck_nsec < 1000 || hbkts > TIM_MAX_BUCKETS)) + lbkts = 0; + + if (!hbkts && !lbkts) + return 0; + + if (!hbkts) { + timr->meta.nb_bkts = lbkts; + goto end; + } else if (!lbkts) { + timr->meta.nb_bkts = hbkts; + goto end; + } + + timr->meta.nb_bkts = (hbkts - timr->meta.nb_bkts) < + (timr->meta.nb_bkts - lbkts) ? hbkts : lbkts; +end: + timr->meta.get_target_bkt = bkt_and; + timr->tck_nsec = ALIGN_CEIL((timr->max_tout / + (timr->meta.nb_bkts - 1)), 10); + return 1; +} + static int timvf_ring_start(const struct rte_event_timer_adapter *adptr) { @@ -215,7 +257,7 @@ timvf_ring_create(struct rte_event_timer_adapter *adptr) } timr->tim_ring_id = adptr->data->id; - timr->tck_nsec = rcfg->timer_tick_ns; + timr->tck_nsec = ALIGN_CEIL(rcfg->timer_tick_ns, 10); timr->max_tout = rcfg->max_tmo_ns; timr->meta.nb_bkts = (timr->max_tout / timr->tck_nsec) + 1; timr->vbar0 = octeontx_timvf_bar(timr->tim_ring_id, 0); @@ -225,6 +267,13 @@ timvf_ring_create(struct rte_event_timer_adapter *adptr) timr->nb_chunks = nb_timers / nb_chunk_slots; + /* Try to optimize the bucket parameters. */ + if ((rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_ADJUST_RES) + && !rte_is_power_of_2(timr->meta.nb_bkts)) { + optimize_bucket_parameters(timr); + timvf_log_info("Optimizing configured values"); + } + if (rcfg->flags & RTE_EVENT_TIMER_ADAPTER_F_SP_PUT) { mp_flags = MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET; timvf_log_info("Using single producer mode"); diff --git a/drivers/event/octeontx/timvf_evdev.h b/drivers/event/octeontx/timvf_evdev.h index b5db233bb..5e526a36a 100644 --- a/drivers/event/octeontx/timvf_evdev.h +++ b/drivers/event/octeontx/timvf_evdev.h @@ -184,6 +184,12 @@ bkt_mod(uint32_t rel_bkt, uint32_t nb_bkts) return rel_bkt % nb_bkts; } +static __rte_always_inline uint32_t __hot +bkt_and(uint32_t rel_bkt, uint32_t nb_bkts) +{ + return rel_bkt & (nb_bkts - 1); +} + int timvf_timer_adapter_caps_get(const struct rte_eventdev *dev, uint64_t flags, uint32_t *caps, const struct rte_event_timer_adapter_ops **ops); int timvf_timer_reg_brst(const struct rte_event_timer_adapter *adptr, -- 2.16.1