From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0085.outbound.protection.outlook.com [104.47.33.85]) by dpdk.org (Postfix) with ESMTP id 2074E1BA3F for ; Mon, 9 Apr 2018 23:01:44 +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=sw8j4BnvHQA6K8P1Xkqa3SsC8yOv4FSi70n5SKbcIm8=; b=VppukDFjtCCkNuWACAIhlz+ckqjVbotqHsZLosHBmbAgwMgVA/H71LTE7JW3hFDls5VaR2/nRUjgcoQc+mewZh6+ygtitnS0s/KdqQtnNHYkD3Osikt3mCBa+LV5lmZUn9K4uy9Qe7hYyOzYtvruzCl/Nyd79W+9HPdquaS7sIw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by MWHPR07MB3470.namprd07.prod.outlook.com (2603:10b6:301:63::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Mon, 9 Apr 2018 21:01:40 +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: Tue, 10 Apr 2018 02:30:33 +0530 Message-Id: <20180409210035.23278-10-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180409210035.23278-1-pbhagavatula@caviumnetworks.com> References: <20180216213700.3415-1-pbhagavatula@caviumnetworks.com> <20180409210035.23278-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR01CA0088.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::28) To MWHPR07MB3470.namprd07.prod.outlook.com (2603:10b6:301:63::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c55a599-b266-423a-bc7d-08d59e5d18a5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(2017052603328)(7153060)(7193020); SRVR:MWHPR07MB3470; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 3:Aorn8fETqYrjgfGelAdRz98cTJV0ZzpfNVjXuB21ryQAaRkqrLVwyFrileTNBurXJN4h9f1AtLqQyiMF9wz/xRg2HLZCXY0se5ropDbTHYVcXAoQer76Y7aZ+aS7riA51wtvMfLTcLj4Nb7LLtTESmFrwSvteD6iUzOHw78IIK+gZLK1f70jHUFELgWZVNL4WG+jycOyHwZip2HHZ67Bc4HPNVJFZIb52TMaeQR6R549DQI/5dOBgPypTa/c26if; 25:4vG/FVb5e3qP4BvCxmwJP7GmJ2mXf0sbgUC/CGWm3i5fVJiwh0UniWpHWhsKBHbCS/0vS4az8Vx41GFDgicpBXRXOl1CkDxJTOn3vyuJGMe3359nCVIJHB49X3lqlxwuB+So7amy4aAqsm7CcZPkwiS7C6T0R16YhV1LXtNTdgAoZiQHLDG/H7Vg+RpW97hGn39BLZrlslh5p9daDJD2P+V9dA5dM/0mEhWrupr1iUZQK+qnaie+TZAxIPY0GDN6eGlCOk+t+uGTYlYkH/aYpCb0B7B82JATCz1Yr4OQGeJjX8EN5zkUb1pO7JiCB9R92T36RVlxCZoMEtY4HCrUVA==; 31:ao8dWBjGwWpp9mgudbGNdBaoABKu9Zt9wZF9f9WNAV7ikAUAIxESFzxPge8kypYsJAmradlTlh/B5AXyKcQTsDNRfPg/NY8oczU0OyLv3tx2DfrFBg23tISyKuRBGD6OvccQA4s5ny7DSwbb63HHkmyIwUy/uDr7O2aTKGdbSl30C/zkgLaWl0Bf8sazmfLyLZXJsTRpAS9sOV0aVqn/5+n0TRlDWORAnHr+SrXjRdk= X-MS-TrafficTypeDiagnostic: MWHPR07MB3470: X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 20:kYRnEvJ43cCJwHGy89VEZy7lhMwKkup+lFyovfDUosBsahv73DtafJNBxLnAK/HOegy7ktuarsB0UDqqps0nxNJXZdTnmBHJk6o4mI3GWvAydFazwZDAm25TyICZYdgL2Ur8jRfJnGXHRwh1AI+17zl7DW//qzAwLaBCysIQTF7LaEvNVDK9N64Og3JFVi9Hd9Ho8WsvWuEMQFiFaPujHZxSjsLC00eKJzIqLQlO/hUyda1fVPQGC3mCmZ+zqz/cTP5ZierMhtxjXkBriU8bNnZCeNokYB/ejnQo8gjNfKxVTBrxhYtqaDevU1aLGTKNAwIasW94zoD941G5J703ycP/bkDE1vRXp2zzpOt6/Ni4pLZitF2w2SrMhlrpb4dPaH+5YheViLm7ubWYhRpVFkShrAGwVYcGfNZRBj/sYJ46DBar2bbg0hlM5oSsrdPRQGrK8lQpe+YSrGTyUE3fqZkHNp5lWdTmxfyVNaDQQly+fKAt0h1JMNVSiGSFInLDclHYFa5aA4UhjEk5gv1zXQLZID8BBqqnRDg5X1ElBYDGdGg+Z8aOA3cXnqCEmGFvd2t5ix0Ot0XjrL4WyyvKg4+p5lIloW/pwwinPZjDPUI=; 4:/FqUafTGKFI5XAwEIfM+5idue45dRqVPnwVeXHhDfcXJwr+c0k7rcc39D0BlZrqUpVKrWCsahrTuwY5uBCpvf5leMt08N6coBO1PfipBkhowXGCIhBIYACqhnjX/iXXYHZJNd/La9NsX+m2E5bv/gwpz1XWwhaiTKHZ2E7SmVd1f1pcrXAjWt84WJUPQfRCs198hengs26Oe854t7oc8mTg54Afm+8dceazif8yiwsOQOK4WKZ12519h/hjKR4yiOmw5JbVA2EqvTgNpxau71g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501327)(52105095)(3002001)(10201501046)(93006095)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:MWHPR07MB3470; BCL:0; PCL:0; RULEID:; SRVR:MWHPR07MB3470; X-Forefront-PRVS: 0637FCE711 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(366004)(376002)(346002)(39860400002)(396003)(39380400002)(189003)(199004)(107886003)(48376002)(446003)(1857600001)(50466002)(97736004)(66066001)(2906002)(53936002)(6512007)(42882007)(59450400001)(81166006)(956004)(81156014)(25786009)(16526019)(6116002)(2616005)(476003)(5660300001)(6486002)(3846002)(11346002)(8936002)(26005)(50226002)(8676002)(486006)(47776003)(1076002)(6666003)(478600001)(105586002)(76176011)(68736007)(72206003)(7736002)(106356001)(5009440100003)(305945005)(4326008)(6506007)(316002)(16586007)(386003)(51416003)(52116002)(36756003)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3470; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR07MB3470; 23:FevwLPX6ZNZhBTzKhh6dwPcYMOGbofQTNBwA5RlwI?= =?us-ascii?Q?/oAZUnk+G/rIizKtuU9irZYgdIoq8zBBUpY1Qj0JUcA0nuZpPEv0Z2mVfkH3?= =?us-ascii?Q?vJkEecYkP+xZ9X6hMNWtwqTr39TURn2sDnbmxZzikRw1G1HA2Acnv7GP3G/m?= =?us-ascii?Q?izHCUKVyRja9UuL3nSBkdlSbluUkZAAqkFW3DdTn7EhBy4KUCGvLAzVC3q1w?= =?us-ascii?Q?0Iwk9Vv+cKAbP55gTqBl8xJVn2KQZ/c05uJVr0Wk0fkIFS+Psj0rW4Nxrodu?= =?us-ascii?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0eUqXBW1QvvQ3donE+QkC1xlwxls+SiZzTamh3Ag+DII5ZFZF1WEkqg=; 24:9lxDbARi+P+kGu/qebkJfD0iwbaul+Eljv4MHhzg822BgiJdTMOj/4A7qRUhQJ2mbQ0rLNRvOri6Ov045UvP9i5YdED1OuhTP51IUi6M+d8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 7:KazzB5ju5SjIJj/1Kj29q4YfyArEikvlgqu9jnADV6gaTfAsCoQ1HcwqK4BXtAIMmHnzDWI2zCBROHN/lqAeB86Jmvd+txWVxzcvv0Kn7e1nGmoiiiL7NWlPSYsXSePxhHL0HHNpz1MIl1OV6pdWKvgPkfJnLWF+qORDGkEbTJhvUxLWW50L5ACoTT9RiteTNj9Nch6JbsiWAP60toLiufGGDKIJpeEyMEHXLoVloPrn/CaU4AkTSnz5q7dENG00 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2018 21:01:40.5455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c55a599-b266-423a-bc7d-08d59e5d18a5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3470 Subject: [dpdk-dev] [PATCH v4 09/11] 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: Mon, 09 Apr 2018 21:01:44 -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 Acked-by: Jerin Jacob --- drivers/event/octeontx/timvf_evdev.c | 52 +++++++++++++++++++++++++++- drivers/event/octeontx/timvf_evdev.h | 6 ++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c index b54d8b84f..d6a8bb355 100644 --- a/drivers/event/octeontx/timvf_evdev.c +++ b/drivers/event/octeontx/timvf_evdev.c @@ -82,6 +82,45 @@ timvf_get_start_cyc(uint64_t *now, uint8_t ring_id) return octeontx_mbox_send(&hdr, NULL, 0, now, sizeof(uint64_t)); } +static int +optimize_bucket_parameters(struct timvf_ring *timr) +{ + uint32_t hbkts; + uint32_t lbkts; + uint64_t tck_nsec; + + hbkts = rte_align32pow2(timr->nb_bkts); + tck_nsec = RTE_ALIGN_MUL_CEIL(timr->max_tout / (hbkts - 1), 10); + + if ((tck_nsec < 1000 || hbkts > TIM_MAX_BUCKETS)) + hbkts = 0; + + lbkts = rte_align32prevpow2(timr->nb_bkts); + tck_nsec = RTE_ALIGN_MUL_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->nb_bkts = lbkts; + goto end; + } else if (!lbkts) { + timr->nb_bkts = hbkts; + goto end; + } + + timr->nb_bkts = (hbkts - timr->nb_bkts) < + (timr->nb_bkts - lbkts) ? hbkts : lbkts; +end: + timr->get_target_bkt = bkt_and; + timr->tck_nsec = RTE_ALIGN_MUL_CEIL((timr->max_tout / + (timr->nb_bkts - 1)), 10); + return 1; +} + static int timvf_ring_start(const struct rte_event_timer_adapter *adptr) { @@ -204,7 +243,7 @@ timvf_ring_create(struct rte_event_timer_adapter *adptr) timr->clk_src = (int) rcfg->clk_src; timr->tim_ring_id = adptr->data->id; - timr->tck_nsec = rcfg->timer_tick_ns; + timr->tck_nsec = RTE_ALIGN_MUL_CEIL(rcfg->timer_tick_ns, 10); timr->max_tout = rcfg->max_tmo_ns; timr->nb_bkts = (timr->max_tout / timr->tck_nsec); timr->vbar0 = timvf_bar(timr->tim_ring_id, 0); @@ -214,6 +253,17 @@ 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->nb_bkts)) { + if (optimize_bucket_parameters(timr)) { + timvf_log_info("Optimized configured values"); + timvf_log_dbg("nb_bkts : %"PRIu32"", timr->nb_bkts); + timvf_log_dbg("tck_nsec : %"PRIu64"", timr->tck_nsec); + } else + timvf_log_info("Failed to Optimize 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 2e905702f..b3fc343af 100644 --- a/drivers/event/octeontx/timvf_evdev.h +++ b/drivers/event/octeontx/timvf_evdev.h @@ -190,6 +190,12 @@ bkt_mod(const uint32_t rel_bkt, const uint32_t nb_bkts) return rel_bkt % nb_bkts; } +static __rte_always_inline uint32_t +bkt_and(uint32_t rel_bkt, uint32_t nb_bkts) +{ + return rel_bkt & (nb_bkts - 1); +} + int timvf_info(struct timvf_info *tinfo); void *timvf_bar(uint8_t id, uint8_t bar); int timvf_timer_adapter_caps_get(const struct rte_eventdev *dev, uint64_t flags, -- 2.17.0