From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0057.outbound.protection.outlook.com [104.47.34.57]) by dpdk.org (Postfix) with ESMTP id 6B2351B771 for ; Tue, 3 Apr 2018 17:06:05 +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=iaFRDQn8hJOoIHkCuvGD1bq6o+zy0Hpu0pQIORJU+wg=; b=LEWFE47K/I7gd0cjG2QRAuzowfWwU70ZNg2dNcsDf+s2/Gug5jtQW8ag/Oergf7PynRUIsjT89sfmyCdzorsLdPgvzxnLEY+1RdXUK7IoC0vbfO1WkLR1mgZphTV5M1cX/Ede05IMsvLs+zJ47doL2cRtpq3TjpuKfNxcl2hba0= 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.631.10; Tue, 3 Apr 2018 15:06:02 +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, 3 Apr 2018 20:35:11 +0530 Message-Id: <20180403150514.24201-10-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180403150514.24201-1-pbhagavatula@caviumnetworks.com> References: <20180216213700.3415-1-pbhagavatula@caviumnetworks.com> <20180403150514.24201-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR0101CA0070.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::32) To MWHPR07MB3470.namprd07.prod.outlook.com (2603:10b6:301:63::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6d48221b-bb28-4d67-3de9-08d599746b66 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:Z0TsfLoKiAEoAJWi6aPwnkzDzMi4KsihP4DjUG49junfQ3iyfsKw+/IDuiBFCXwXR4j7vjPpdfth4HmGHWdCa0tahbKwaVGK51AxQmk8F3YZEq8lIhkY52j4jYRQyDYFzEOktmeqMtsy2wtPOS4ZqJXlNOtAcEJ7kxJc6umTXbRNLy0Zw2Gc1TAnIeqo1zoQRXQ8LHhiZ7/d0uPFTH5ZIJIJoNLiXepJ08hjCOFBibfaH5gLs87AehYf0Z5hpaNq; 25:EfeTsZQVHkGTGPhKW9R6CvXFQb6ZCn6OwV23zEcJglvsLQCQSaqUe4AE3jitaU3peP01zYfTVd9jOi9uFn1ZWkHxvziruE9BqnFjcYAVhvShuAOXSWCvyeAIwSqOh2H+yxfROn/JbdApiDiXk5QfPuKC6/uzWdJfjwfUDoXE/HlGgi2NQmdJJz6sLOjEjk+/WDVRzZXYwQGLUplFOrwoB1vX/RUjWY6I1x82Es7B9CcAN8zD0R2f2aofUs9F3tkqlN5U4scIuHWUUnQvsIohEToLBpU32MA9WvF4jdr8ZhEw0AI/UcPfs0qekPUM4lLusMOMHR0aS0WvxRwC2wBdvQ==; 31:OeYq8qD1VB48uIRtm7TD707ZSyOR+EEaIg/DfpAGLGGaj8NlBCnoJ/tM0zQpuQEwgxpJN8H78iAJE434l/HhNFhTgpge2goYHly3UZz93n+xELSsVYcXQyEqTLgkbW2KOEoBFkjfLD0JYyKkEkLjrBjl2M+ejvNr2D/cs+MqTvVC3aQJVj3vtI1nT5MS0fnDmIp9Rd6dwktRvaHkpOHobZgmK27Rzijx5/qrhaAyBbA= X-MS-TrafficTypeDiagnostic: MWHPR07MB3470: X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 20:3yGvlTBqbp6vUp0jMTCkqRCkeXEfp6e+AMXAI6j6c2dbG4wmgwJUXkOunfxIZYaya/khqWHtQBvxIvuUF1tF602MjvYRQG0b7GOa12W1T6+2M6oJS8U+/ENnP6GFobqZveQSMhglRfeIQIPgajcanQPt59408kHk7eTGGGEVlzq3fcpzlP3MsbbiHrJpSx6fwk6r9eNtz0rFVkMl5PSjG1PzPlZLCuEKQ82cMtLeP4qFZiyHmTToIPKpN6uly91omkPvXHTD1oZWqmmfZ9e/3oN/pYA4104IqJxo7nVy0ggLgS9Dmz/oe3cXPyWOmSbZiwf5fsXaYExP4Tq1+hsMGPNkXuFykadasbFZExh0THDmXp4BAmz0Rvr54DvPNsn1B/F3hdn6xMPpWWxAsFIof3QxULprZOFvA9MGvNFTmrgmiUFwP1yIv9JWPZpAEJXtsMsNPxToC7v1YYA8+cK4yYC4OUl+xH9IVOrYVo22k9keFgMx4q5oIhoG5Qwm/Sb9XjAdT0OYHbzbIKExrOu1WgYGc+8QleF2AUfWX07l0t6wzlK00c03AUX/pcO/ibzkCBS19e0ViMrYS7fX1dgpRdC4NYWYK8NkbvVYF1K5hpU=; 4:DanT5edo/MgMBJFiUFj0GKMx8f8zdsvInzbhmjbt/NIZWeWhkbRNR+ePJJVWo0rGJ0/XOmP467Ykf9PnoHhHTW4UjeLvC+wEG2vtXQZP4bwHU65PWnySdPTKdYlncEJrzcw75dbtTn4yi+T5nLPEE0SkKIja7ZJjJcqPz1ju+BuySb2GBhsliufjaLx2jcM90wa53YfSV7Ox5j6pnoigy/+FBgDE5EMa8BaQYI0RoKQYJLdZJHCri5wayhS22giLtNUqAEheGXJS+pzUa3Qlvw== 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)(10201501046)(3002001)(93006095)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(6072148)(201708071742011); SRVR:MWHPR07MB3470; BCL:0; PCL:0; RULEID:; SRVR:MWHPR07MB3470; X-Forefront-PRVS: 0631F0BC3D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(346002)(39850400004)(376002)(366004)(189003)(199004)(47776003)(305945005)(66066001)(72206003)(386003)(6506007)(16586007)(478600001)(316002)(48376002)(7736002)(76176011)(59450400001)(36756003)(52116002)(51416003)(5009440100003)(50466002)(68736007)(106356001)(4326008)(25786009)(486005)(476003)(2906002)(107886003)(6512007)(11346002)(6116002)(2616005)(53416004)(26005)(16526019)(5660300001)(6486002)(3846002)(1076002)(81166006)(81156014)(446003)(956004)(486005)(69596002)(8676002)(6666003)(97736004)(42882007)(50226002)(105586002)(8936002)(1857600001)(575784001)(53936002)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3470; H:ltp-pvn.caveonetworks.com; 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:x2bF6HX53iSwfnP6IWQR1+CMAcnLWkka1A192upEq?= =?us-ascii?Q?Hj9G/KeEnyTrSWimOZMyIzy2399THXjpM7Zlt5yQLwYrgQpv4NmmRaQ7clxa?= =?us-ascii?Q?uvOQLUuKNGHWMJEL5R8G00R5V4EvnFxvsnely0XclrHAK37CqJfGpvWdWD0u?= =?us-ascii?Q?Js4epPfIC5N0PYyiGF9zE7+0gxzJt/XtK7sc4/me4+7pYLf6LM/V4ysPPBSj?= =?us-ascii?Q?k6cgPziFalQPox1KUYYKH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= =?us-ascii?Q?aUmX5+0A86n1Wj/eA9yow8mnaWGYnC0YEV/kskPQTiup1h57Oi9bG338mb0A?= =?us-ascii?Q?LmWCR7p668q270iXRYhQFy1eHU6jCBKl+/980QGRWX2PwiYR/fuu9sFvMVdX?= =?us-ascii?Q?iYEmQeRHexdhHr9IRtm31hsn8QSeSHbX35LpEvoHfSz8dL5PvZqhku8JAVHg?= =?us-ascii?Q?7sEk0e7YPmQkWlUN8thjmurNoUojNeJZJR8hjPQP9VfJvyJUtAqpn5xCfLZb?= =?us-ascii?Q?jX7gZVQir3snyzc+O/RJgsdROs1PKTPOGs5s4Nh6oQshVzx?= X-Microsoft-Antispam-Message-Info: ql7OhjMjIQcSbWNGbBKeRFKsi3w8mH9S4j2cb3vew04jls/x2ay+RaEVhEmnP3BikCLq3SQbVSON3Xpv8WoGOBBmWKx1iEriphQliLKYFaMM92bDGp+DMNR4pPDXZHFyPWzmg/qVoySeG9+UatA2OBxYMgvhnHp2uo++/e9OROPAajdgnm/V6CF9KwwYN9b4 X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 6:FTtOl2auSRkF00P0/p52m6nF94q+PMZG5D1MaLeaBlF/OHPevV0dad/jXU37QCKWgl+QL1vD3v9l68z4vhqR28D7tV7Nj4mfXkdiKic22XbCYXuZ7HnrYtR5WfYNz2nAeEVumJQ5Z0LJ/LJu3AZz+Ngub37vgpoiNXI47PiqVbh2XNo23SUMC1sotR8fP5AwbAfHc/xKeSoBpvBMW6jKmuBv9xAvaQsG6wkQ1OdmhBXCDnL7dUPVt8nJ4VFuv/acrdxIcZXv24Wv3C9GUiy1IMpqgJqMUV4k23Tpj4xK90ilfGS6qk97lq9nMj80dWkicWk6tYT58/3ZeH/Bpvu6b+eFXuOr0SvAu6InjGDMVunEBXnL/x5g6/2hZG29H4sp8EWjlYYkbsu9KJrSAWlMYzfs0HsZ87IWP0GORbiv9ddDLTJXgdLQQMMFKirkpieUirpEFdp2p/LHWlSWhDYXsw==; 5:E878lVMIMpYaTbgpo/0kR05Q8UMR0Al/ZIK+IC6c/+0gJWftt/hTaq50xU5gmrwfCWXXEjHEf4iAkwTEN8YpmUvQ65KVKJ79gjlQSdc43tVSvO7Epg4cQnt8o/L7faFMFL2X52qUtsBbJuO0X9j2ogS+bLSxZON3K/ZijzUTfpM=; 24:HZlnFrSCyJh6K1I5keyGDHh0+nwJwvzvzsnWVebwMnM9N72H1BKzA6y611gKCAUBQrzyZCx3obWrt3Pxd3+fbbFxSCxqGVZguqYjLBvl840= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 7:eG4emkrCPPH/JVI16ypJ5bTfUqZrS80iPHpqzBiJ3Fhl8Msxp17hN391XnYsPeqYbN9+WmfniEMSFbqj/1WqV2rxnLueJWBh4HGlz2k9E0FjC9BIjzfyl/eCtpLqLvXosXzVmmyohRW2yKdML95d9jui/66yd78HCvigMxt2bdhFLTAf/9nL7mRV9o/IvZDflEmomAGXWvP4Hgv6E5qZu4ny0i4M1S9Q5JnVcNz7wkIEsf4GbffwaXLrL2yKJGjo X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2018 15:06:02.1318 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d48221b-bb28-4d67-3de9-08d599746b66 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 v3 09/12] 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: Tue, 03 Apr 2018 15:06:06 -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 b23500e0d..d1f42a3bd 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 d8a6d111f..22c8c2266 100644 --- a/drivers/event/octeontx/timvf_evdev.h +++ b/drivers/event/octeontx/timvf_evdev.h @@ -192,6 +192,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); uint16_t timvf_timer_unreg_burst(const struct rte_event_timer_adapter *adptr, -- 2.16.3