From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0040.outbound.protection.outlook.com [104.47.38.40]) by dpdk.org (Postfix) with ESMTP id B3813AAD5 for ; Wed, 14 Mar 2018 14:53:31 +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=6LEAacy+A5C4EH0ImyswZQOqXKVToee7Z1TJjGXjJSo=; b=OgNDQgORUR2h3tYMrGNOluXKXZNJ63PvCguzYofnp8hrakUpBWHAcsNicEPWPPNUTvknDx9T5b0NAkXV8KQ3MGE95o20hRmFKCe+pUQw6NcMlzy6nOQN0CQYF/fXEEpaOAFNCkCIZs8lLHPfdKfurkARtpQ+4pxkcwNRhQxVxTg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from ltp-pvn.caveonetworks.com (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.567.14; Wed, 14 Mar 2018 13:53:28 +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: Wed, 14 Mar 2018 19:22:30 +0530 Message-Id: <20180314135233.31282-9-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180314135233.31282-1-pbhagavatula@caviumnetworks.com> References: <20180216213700.3415-1-pbhagavatula@caviumnetworks.com> <20180314135233.31282-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: DM5PR20CA0005.namprd20.prod.outlook.com (2603:10b6:3:93::15) To MWHPR07MB3470.namprd07.prod.outlook.com (2603:10b6:301:63::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 443213bf-8092-4b8a-fd00-08d589b2f805 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:IViIcPWkqEw1dSPPLlxfmOXcdaWf3W7it3wdeNGlJ+ojRZ32JK1Q4h4lHGGh3GlSycyWv7JXqs34/U3xco7CKPBFua6Co9WgQ0E7tnx306m2S9wedbI9QrHrwtWtcdhAejwwYNJDbfNhFPAfYlDbhubUMfrEZduw9tiDTpc+iGuy787m9iSGvEe7lVwJTHHZpxF1EcYJ+anlezFteGN2f/BYbddKj5+57pkGvoZpAVIRoiZyfjgvk6tmTEBNyChk; 25:f1UfXvc4FXAoiMRiToSmpaM+kGonA7KQ7JVy46HWSnxFYG/f8V7BRqjHR15BDh+gaf0K9NfepQA4lUf9ltJG1VWEH/1OHAQOoXdXNQyqpkqb8ZKznXpw9FQ/z3BXicuhCj43ZFPW5nENJmRREUT8cxXPB7KgxdVr3rCB9mPK8eAEbNnl9rouOCVgK4gtsBRxhmxb5anPPillh8USGjpW8MAx/LdDJ6vOYyKhwKZj1dCax2wRMaujP1ZFlUzJKENvPR4sJUz86ECt9q5rH+du29Ka6OKL1q8lBQoek2Y+iN6P3OpVurRI+k9UjinZ+2/MsaWTS0sjqyEsvkyLqW/jrg==; 31:xm805xChjwWv1RXEwDmpPKlyAq1P0AOS1IJ2cw0XKlBL+pTVR1IwdpSpRGLtLypVKO+0BzTYbjZGSuHSFZxqq7ZH6KhRBtC/TuhOqwilbl+s5Qa6ykJmjnC6VvEyBnyd47yoSEgy6KZd1H4C6zfTjNWpJpPfVgCCyvSc2Cd9KAOUd/+I8Ozdbx3N+3WVy4Hr1u4U1WGKnfW822P1QLK3dj3SUQfgQZojfPtA9fqGUJw= X-MS-TrafficTypeDiagnostic: MWHPR07MB3470: X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 20:lApJxSzH3xKy1ER/JHIbnCxSWt6c3yovAjEbf49NHP24gcSn7gnkvqS+oZ2zggl23WGe6nl9mmafCRwb/3TJcja9YAMWVkM2e+OtdIdD4Bo+rxJyuig06ZyuelPXR0Jq0wrd93pScXSr4ikIys/AdDIwkm87cGtsK8643VJzlimqxzH3McQm8f/HQPOxAImBciICAnKE9gx2QqPo6n6niy9C1nzBAyCK0mhM+Tb0x+a+w8FYnF57/YI5I586+TBvo/jN+fbRyJ4N9GDGOu3o7knwlabqkkuysOcxS7dYVDPcFD09Q985pea7MZMhqH6YCV3JIMc0IO4NLWnga1E2ofNsZnASiRAifhkpq121ZGUJrCIaPSy4DpFwfDiiecKBOVHY+B04KtntOfwtP/F6WDx9BysFM9zxvo1momqFeHKTpNy9VBnxAtmFfE/Ui+IVVSZ/cZNAMCbuPeiTiH+yI3sbTVdCKDCS8cpccaM4aHFxJmjc4AlIr7URjUg6ihZGw6qIP2V0W56PnoL+DOWJPqGjwV8kiZ1MAXgZNCjS/0EMT9CYO4shZTLFBZL012nWfexOh6lbKrR/hAqxmjJm9BwRybSDuLgLSQ1fMmtXpfs=; 4:4P+aAIfDaouOU2psWeMj3+GQ9scmWxeMIgdz+KTQMDlBJ0K2dEV1JxmBVqCFFCoh8sbfAw3PPBa7xfUUnNgeqkAdPdeAcLRZKDD0RBehnoFk39oKAxCf8kn508kzzUGh1BIATwWI8Hf20HirA5L0qcoZRfWuuS+OibERcOGpex4csrtM6MfEKrVX0gdCOD7t91nLOWSNVr5FlAAZgx3USxItW5KHYw5VDHvznZRtIB4bsORkmFSGbuYFtulpRcVxUINZlnRwAa2itwp9T4HFbQ== 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)(944501244)(52105095)(3002001)(93006095)(10201501046)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:MWHPR07MB3470; BCL:0; PCL:0; RULEID:; SRVR:MWHPR07MB3470; X-Forefront-PRVS: 0611A21987 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(39380400002)(366004)(346002)(396003)(189003)(199004)(53936002)(6512007)(3846002)(4326008)(6666003)(6506007)(48376002)(26005)(105586002)(68736007)(97736004)(47776003)(2950100002)(386003)(1076002)(6486002)(106356001)(52116002)(305945005)(107886003)(7736002)(69596002)(76176011)(66066001)(5660300001)(59450400001)(51416003)(25786009)(36756003)(50466002)(316002)(16586007)(72206003)(53416004)(1857600001)(6116002)(478600001)(8676002)(81156014)(81166006)(42882007)(2906002)(5009440100003)(50226002)(16526019)(8936002)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3470; H:ltp-pvn.caveonetworks.com; 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; MWHPR07MB3470; 23:Z+gMTK7Cjy27G5HHeMVpQF77gBTUtgO0Hv41cMU8J?= =?us-ascii?Q?wvnGEw2WbjSP4AuPkm/7OfqDo8YApy+aEXwSqwYquF1j/xK8jkDebTts5BBK?= =?us-ascii?Q?eCLH2K7LX6pfoXeA5AbgS/tbxoF00t7KbHo3EVWOKgOpSS2Zfgc5lGuz6DMw?= =?us-ascii?Q?hsZ7wdA1Yy3op1UaPck2EiBr6B7KxvOLzLVO10HJkfbbMzNSDDbooGhghIGA?= =?us-ascii?Q?DrEqioT+lXSfPzX5I1gF1cdoSmFn/2c2wM039gEbiYCC7J9Qia4AsWWWnV/K?= =?us-ascii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bPa8IuftMFNvJeuPlIP6Ocd7aXafESlpdXZnLxIHVPDFS9G7fRBP163wE1jBw9E02ebW9K4fKx4eohTtrIbHiSo2uIlf6ZZnmjHbD7ZfC6Xh3ly8RibVOP2qmBOigyJUB3Mf9r+Wjz0mWpmp/e5aEX0Yyg3O/zvSGmn5IdhKN+1MGpIv2YmFKLvnivuYNfjj5J8yhBCPuEkpgfzMe8moE SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2018 13:53:28.1118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 443213bf-8092-4b8a-fd00-08d589b2f805 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 v2 08/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: Wed, 14 Mar 2018 13:53:32 -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 | 48 +++++++++++++++++++++++++++++++++++- drivers/event/octeontx/timvf_evdev.h | 6 +++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c index fe4e8cd05..43ec98ce8 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_ssovf_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->meta.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->meta.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->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 = RTE_ALIGN_MUL_CEIL((timr->max_tout / + (timr->meta.nb_bkts - 1)), 10); + return 1; +} + static int timvf_ring_start(const struct rte_event_timer_adapter *adptr) { @@ -217,7 +256,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 = RTE_ALIGN_MUL_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); @@ -227,6 +266,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 a263ccc68..06e6a1588 100644 --- a/drivers/event/octeontx/timvf_evdev.h +++ b/drivers/event/octeontx/timvf_evdev.h @@ -191,6 +191,12 @@ bkt_mod(const uint32_t rel_bkt, const 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_unreg_burst(const struct rte_event_timer_adapter *adptr, -- 2.16.2