From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0074.outbound.protection.outlook.com [104.47.36.74]) by dpdk.org (Postfix) with ESMTP id E31CE1BA14 for ; Mon, 9 Apr 2018 23:01:27 +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=4A5CoruV8gklMCCysEozbhbRzgnUZqz9KIlDSCozp3M=; b=lvaziri1fvmyrYd//nBRmBzxgqX5lozjN2Ci/VwfgaYe+M2t5NGvThrefjfP0lR6Jq3FPVSat2Lipd0Miio9It8gBoRnv2AIvX2ICATspjnC+07uY4A8gY3/fW3lA6Y9sEGIemy8CynuxYfU8L3pEoEAisXyOHTg7FN5eIFXTo8= 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:24 +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:27 +0530 Message-Id: <20180409210035.23278-4-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: 0eeef75a-2700-4df9-c552-08d59e5d0f1e 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:AW7BrrE1Zs/l6xKwxF9hIEEvwWG/vsQS/0DykLCQH4QEc70+Y+ZlWasgxgL94MV/kvitSCky3WxnzbmrwlWS8OgE44v7uANAvgEEAbex1rtWbyqdRFH5eMwCx9pcekMTKAJPrLHOaUqCdxebKBanrBWguNujlHg7jPOZHkrRoZbZCXlKxxQdD4rtJTCJaPHRYcV5u64lEtSxkA3cOW3AcnhcEcpEimrB6sFEdUwSieYRJydFQ23sb6c0ERjJwjuY; 25:wkZJ1Vsxq1SEinCYm7AVu5HuxItqiaxsXjLnPjly+WttuXv/Mzrr52zxbsqzrWD2tE5LxUVuoCMtI3FC4JjhRi68GysrBqsw4rH+a7KWytqxpU0HE4Yg4cu8KMuLYg+sgvaqGaLXSGLjk6TBri1W391l0YWneNk4Vv6sgDIxAKCSvgkqL2DXuQ+JnZXu5wfLvmRsYlAUSjJgQsySVxXy3ig3PxcY07G1zAoGR4FXgrQvFe8Lg7vgr40eF4nbmgCvHHH3OJQK7gDzArxu/LEzHMDk/GQroBMNDRs1+nd9mxW4hcWis23K/kNWriqHbWoK2k/y4eUOTfvw992W7xi3bg==; 31:+Vlojtvz3kWpbbZlO7m67ABbxI0grm5v5EDMBVoYjTI3mtSlPbw1Gx4bFNzhQGc/w43DtYdsVix980c/HI9uicsi6xL8AHcmchHLXO2IWY/DIxM30O/21j+bRW2O+ikNA4FD+GRSgEODjdgjqEtrlY6wHxX6kwXmN5dBoc7GUG/o7km60IkgiDrJuR63SEj4V+XwFecGL/nmZ0jwUfimzivs2DFz+Q48CbbVH4xtsv0= X-MS-TrafficTypeDiagnostic: MWHPR07MB3470: X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 20:pp6GYqvLkwel7DvE6oMavI7jYGWzkzTrDjUKXmk+hxe+sElGxWfVH7BZSkWrMqB+TfKSkWoKRKHDkcZx2Y8Ylid9ZR3EgGYfYh8XUJbh8HIj8Cpnf6/0icB5H4G37qSAigvL/bu14qlLQGywf3KkYm6zF68N23fm+LQ9C7YOdPwS3wZmwvxNs/jtr1P9iz0CQlJ7Q0Xw57yz8GQsrpPnWpg0ZCj/emrzdApYil++fS8fRBLsBGJPzu9clxHstKmaQqQbZDcZ1eYIp6/kQj5laA8nOsv4Z/b/4SanAMYdHXtu2zXHtCdCmQ9vQOwiCiDvb3Xr074cZpi18IdL/6xnwaGv1k4DDNBwgbt8H2UZKXb2TX8pYzx4FJCBK3AS1LH6XktmS+PdJq7CJlrFl7cSFcNjTWryspeRKhxkEE0N+si+Czr2ZoCN/WxYjvQWpdw1MSutkT6ROjnrOdBm+TeZRUIpJZ3xtrbEPMadzDSZWxmOe9WqodyA0ItwvKsHvNjbkgPt2D4JP914wVoZsInIao1Gep2D9jYcwX/aODFRhHU9zHB8aD9DKT8aRqHe195kAq1EEiLDp9zN+nqi8ZchDI/t/NkP0GV4Tjtt/cTKS4E=; 4:UkvF6JrwFd9hdxU771p80QPrw87HXPeypMwdRIxE806EP7PNE4zxGJ8F6f4ymX+ZAERk9zOEDfYjaRjI81kkakrHa+gjFVGCFFKcjHCI81XPngualV34NwY2TO65uXSMyHeP4Am5xhZ78PZPnUuDVBGk7FcABHQPSxzzsFL+mJCk1zuHB7qD8VqO0OP/yTHra+Vh3HDtX9BitkN+FjnlmbtTsZePH17rk+/xurXW5hBs2tCl76F42XZNslS1ubtDW7gSaju5zS27VU2PXe3uyA== 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)(575784001)(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)(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:0EYyFW2Ctn7IgVnG/0f6cL8RH2VPV9b2fUSz1mkFx?= =?us-ascii?Q?k+GM3QjgFbZgIGZYOSOjieHj9PAPaYmiaUtbRa7t1YmcpxgAAWem3em8SbPm?= =?us-ascii?Q?twhfT7SwzQsukekUD3tfMyivd1AIWknvgdYlvGT5kcpnuNzHU1DG0rvjtLbC?= =?us-ascii?Q?Of1GtIeehhMheUy/82EBJqGNv3hnC8PryI43tF85to7sfPj8HFq2Ynjr48wP?= =?us-ascii?Q?QOrJmCAwBb2T8BIkxs58gTgZpgTAU+1RKwh9cUjtBW65ATGoFeTVbfohRhZk?= =?us-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QbKG4m3erx7K37weTUpG9O2TKuqpE4BCoWWEoIya+m2f9M2CvyWP4faw+iDQSwjldWscBQ=; 24:MHPabx62gtxChn8tlGEx5gAJDZxvCdvGOyxtTnY7NIYLMt5sdPUkL1+8kMsmTdM+WEoU8UOEwax2iNEfFnC5IGKYS2XYFQ8xksF5iQwzTGE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3470; 7:+zVKMVuw/Pu7Tm8TOeGZ6pjtxTJrT7Ch8zHGDgHZ29N1Z4fMD3ZfT+HZgKfhIjKYfNnnhaDu3BacMwlHLX/IsQpsJnnGgg2mTHLGcuUgytKWfL3PxL4LG/eyXVENUihxr9jIg6MP7O7mtJpfhjekEgtZcf/2kb5imPOjHWus9MXvBdq5sidsT0h6T/IDzwTDiyHmPThOMTnRoiSJHisCJWb6ARPsClLqqJtPjn/q/zrD8NYsLza6l86P7kM5jtZ2 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2018 21:01:24.4365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0eeef75a-2700-4df9-c552-08d59e5d0f1e 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 03/11] event/octeontx: add support to create and free timer adapter 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:28 -0000 When the application requests to create a timer device, Octeontx TIM create does the following: - Get the requested TIMvf ring based on adapter_id. - Verify the config parameters supplied. - Allocate memory required for * Buckets based on min and max timeout supplied. * Allocate the chunk pool based on the number of timers. - Clear the interrupts. On Free: - Free the allocated bucket and chunk memory. - Free private data used by TIMvf. Signed-off-by: Pavan Nikhilesh --- drivers/event/octeontx/Makefile | 3 + drivers/event/octeontx/meson.build | 5 +- drivers/event/octeontx/ssovf_evdev.c | 10 ++ drivers/event/octeontx/timvf_evdev.c | 146 +++++++++++++++++++++++++++ drivers/event/octeontx/timvf_evdev.h | 131 ++++++++++++++++++++++++ 5 files changed, 294 insertions(+), 1 deletion(-) create mode 100644 drivers/event/octeontx/timvf_evdev.c diff --git a/drivers/event/octeontx/Makefile b/drivers/event/octeontx/Makefile index 6a6073b4d..8dbfd88c5 100644 --- a/drivers/event/octeontx/Makefile +++ b/drivers/event/octeontx/Makefile @@ -13,6 +13,7 @@ CFLAGS += $(WERROR_FLAGS) CFLAGS += -I$(RTE_SDK)/drivers/common/octeontx/ CFLAGS += -I$(RTE_SDK)/drivers/mempool/octeontx/ CFLAGS += -I$(RTE_SDK)/drivers/net/octeontx/ +CFLAGS += -DALLOW_EXPERIMENTAL_API LDLIBS += -lrte_eal -lrte_eventdev -lrte_common_octeontx -lrte_pmd_octeontx LDLIBS += -lrte_bus_pci -lrte_mempool -lrte_mbuf -lrte_kvargs @@ -29,6 +30,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF) += ssovf_worker.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF) += ssovf_evdev.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF) += ssovf_evdev_selftest.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF) += ssovf_probe.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF) += timvf_evdev.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF) += timvf_probe.c ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) CFLAGS_ssovf_worker.o += -fno-prefetch-loop-arrays diff --git a/drivers/event/octeontx/meson.build b/drivers/event/octeontx/meson.build index 56d4207bd..90af4fd1a 100644 --- a/drivers/event/octeontx/meson.build +++ b/drivers/event/octeontx/meson.build @@ -4,7 +4,10 @@ sources = files('ssovf_worker.c', 'ssovf_evdev.c', 'ssovf_evdev_selftest.c', - 'ssovf_probe.c' + 'ssovf_probe.c', + 'timvf_evdev.c', + 'timvf_probe.c' ) +allow_experimental_apis = true deps += ['common_octeontx', 'mempool_octeontx', 'bus_vdev', 'pmd_octeontx'] diff --git a/drivers/event/octeontx/ssovf_evdev.c b/drivers/event/octeontx/ssovf_evdev.c index 2400b20d2..34496f114 100644 --- a/drivers/event/octeontx/ssovf_evdev.c +++ b/drivers/event/octeontx/ssovf_evdev.c @@ -18,6 +18,7 @@ #include #include "ssovf_evdev.h" +#include "timvf_evdev.h" int otx_logtype_ssovf; @@ -601,6 +602,13 @@ ssovf_selftest(const char *key __rte_unused, const char *value, return 0; } +static int +ssovf_timvf_caps_get(const struct rte_eventdev *dev, uint64_t flags, + uint32_t *caps, const struct rte_event_timer_adapter_ops **ops) +{ + return timvf_timer_adapter_caps_get(dev, flags, caps, ops, 0); +} + /* Initialize and register event driver with DPDK Application */ static struct rte_eventdev_ops ssovf_ops = { .dev_infos_get = ssovf_info_get, @@ -621,6 +629,8 @@ static struct rte_eventdev_ops ssovf_ops = { .eth_rx_adapter_start = ssovf_eth_rx_adapter_start, .eth_rx_adapter_stop = ssovf_eth_rx_adapter_stop, + .timer_adapter_caps_get = ssovf_timvf_caps_get, + .dev_selftest = test_eventdev_octeontx, .dump = ssovf_dump, diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c new file mode 100644 index 000000000..5728d4944 --- /dev/null +++ b/drivers/event/octeontx/timvf_evdev.c @@ -0,0 +1,146 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Cavium, Inc + */ + +#include "timvf_evdev.h" + +int otx_logtype_timvf; + +RTE_INIT(otx_timvf_init_log); +static void +otx_timvf_init_log(void) +{ + otx_logtype_timvf = rte_log_register("pmd.event.octeontx.timer"); + if (otx_logtype_timvf >= 0) + rte_log_set_level(otx_logtype_timvf, RTE_LOG_NOTICE); +} + +static void +timvf_ring_info_get(const struct rte_event_timer_adapter *adptr, + struct rte_event_timer_adapter_info *adptr_info) +{ + struct timvf_ring *timr = adptr->data->adapter_priv; + adptr_info->max_tmo_ns = timr->max_tout; + adptr_info->min_resolution_ns = timr->tck_nsec; + rte_memcpy(&adptr_info->conf, &adptr->data->conf, + sizeof(struct rte_event_timer_adapter_conf)); +} + +static int +timvf_ring_create(struct rte_event_timer_adapter *adptr) +{ + char pool_name[25]; + int ret; + uint64_t nb_timers; + struct rte_event_timer_adapter_conf *rcfg = &adptr->data->conf; + struct timvf_ring *timr; + struct timvf_info tinfo; + const char *mempool_ops; + + if (timvf_info(&tinfo) < 0) + return -ENODEV; + + if (adptr->data->id >= tinfo.total_timvfs) + return -ENODEV; + + timr = rte_zmalloc("octeontx_timvf_priv", + sizeof(struct timvf_ring), 0); + if (timr == NULL) + return -ENOMEM; + + adptr->data->adapter_priv = timr; + /* Check config parameters. */ + if ((rcfg->clk_src != RTE_EVENT_TIMER_ADAPTER_CPU_CLK) && + (!rcfg->timer_tick_ns || + rcfg->timer_tick_ns < TIM_MIN_INTERVAL)) { + timvf_log_err("Too low timer ticks"); + goto cfg_err; + } + + timr->clk_src = (int) rcfg->clk_src; + timr->tim_ring_id = adptr->data->id; + timr->tck_nsec = rcfg->timer_tick_ns; + 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); + timr->bkt_pos = (uint8_t *)timr->vbar0 + TIM_VRING_REL; + nb_timers = rcfg->nb_timers; + timr->get_target_bkt = bkt_mod; + + timr->nb_chunks = nb_timers / nb_chunk_slots; + + timr->bkt = rte_zmalloc("octeontx_timvf_bucket", + (timr->nb_bkts) * sizeof(struct tim_mem_bucket), + 0); + if (timr->bkt == NULL) + goto mem_err; + + snprintf(pool_name, 30, "timvf_chunk_pool%d", timr->tim_ring_id); + timr->chunk_pool = (void *)rte_mempool_create_empty(pool_name, + timr->nb_chunks, TIM_CHUNK_SIZE, 0, 0, rte_socket_id(), + 0); + + if (!timr->chunk_pool) { + rte_free(timr->bkt); + timvf_log_err("Unable to create chunkpool."); + return -ENOMEM; + } + + mempool_ops = rte_mbuf_best_mempool_ops(); + ret = rte_mempool_set_ops_byname(timr->chunk_pool, + mempool_ops, NULL); + + if (ret != 0) { + timvf_log_err("Unable to set chunkpool ops."); + goto mem_err; + } + + ret = rte_mempool_populate_default(timr->chunk_pool); + if (ret < 0) { + timvf_log_err("Unable to set populate chunkpool."); + goto mem_err; + } + timvf_write64(0, (uint8_t *)timr->vbar0 + TIM_VRING_BASE); + timvf_write64(0, (uint8_t *)timr->vbar0 + TIM_VF_NRSPERR_INT); + timvf_write64(0, (uint8_t *)timr->vbar0 + TIM_VF_NRSPERR_INT_W1S); + timvf_write64(0x7, (uint8_t *)timr->vbar0 + TIM_VF_NRSPERR_ENA_W1C); + timvf_write64(0x7, (uint8_t *)timr->vbar0 + TIM_VF_NRSPERR_ENA_W1S); + + return 0; +mem_err: + rte_free(timr); + return -ENOMEM; +cfg_err: + rte_free(timr); + return -EINVAL; +} + +static int +timvf_ring_free(struct rte_event_timer_adapter *adptr) +{ + struct timvf_ring *timr = adptr->data->adapter_priv; + rte_mempool_free(timr->chunk_pool); + rte_free(timr->bkt); + rte_free(adptr->data->adapter_priv); + return 0; +} + +static struct rte_event_timer_adapter_ops timvf_ops = { + .init = timvf_ring_create, + .uninit = timvf_ring_free, + .get_info = timvf_ring_info_get, +}; + +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, + uint8_t enable_stats) +{ + RTE_SET_USED(dev); + RTE_SET_USED(flags); + RTE_SET_USED(enable_stats); + *caps = RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT; + *ops = &timvf_ops; + return -EINVAL; +} diff --git a/drivers/event/octeontx/timvf_evdev.h b/drivers/event/octeontx/timvf_evdev.h index 7e577edf4..ef8ec0ced 100644 --- a/drivers/event/octeontx/timvf_evdev.h +++ b/drivers/event/octeontx/timvf_evdev.h @@ -7,6 +7,22 @@ #define __TIMVF_EVDEV_H__ #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -20,14 +36,129 @@ #define timvf_log_err(fmt, ...) timvf_log(ERR, fmt, ##__VA_ARGS__) #define timvf_func_trace timvf_log_dbg +#define TIM_COPROC (8) +#define TIM_GET_DEV_INFO (1) +#define TIM_GET_RING_INFO (2) +#define TIM_SET_RING_INFO (3) +#define TIM_RING_START_CYC_GET (4) + +#define TIM_MAX_RINGS (64) +#define TIM_DEV_PER_NODE (1) +#define TIM_VF_PER_DEV (64) +#define TIM_RING_PER_DEV (TIM_VF_PER_DEV) +#define TIM_RING_NODE_SHIFT (6) +#define TIM_RING_MASK ((TIM_RING_PER_DEV) - 1) +#define TIM_RING_INVALID (-1) + +#define TIM_MIN_INTERVAL (1E3) +#define TIM_MAX_INTERVAL ((1ull << 32) - 1) +#define TIM_MAX_BUCKETS (1ull << 20) +#define TIM_CHUNK_SIZE (4096) +#define TIM_MAX_CHUNKS_PER_BUCKET (1ull << 32) + +#define TIMVF_MAX_BURST (8) + +/* TIM VF Control/Status registers (CSRs): */ +/* VF_BAR0: */ +#define TIM_VF_NRSPERR_INT (0x0) +#define TIM_VF_NRSPERR_INT_W1S (0x8) +#define TIM_VF_NRSPERR_ENA_W1C (0x10) +#define TIM_VF_NRSPERR_ENA_W1S (0x18) +#define TIM_VRING_FR_RN_CYCLES (0x20) +#define TIM_VRING_FR_RN_GPIOS (0x28) +#define TIM_VRING_FR_RN_GTI (0x30) +#define TIM_VRING_FR_RN_PTP (0x38) +#define TIM_VRING_CTL0 (0x40) +#define TIM_VRING_CTL1 (0x50) +#define TIM_VRING_CTL2 (0x60) +#define TIM_VRING_BASE (0x100) +#define TIM_VRING_AURA (0x108) +#define TIM_VRING_REL (0x110) + +#define timvf_read64 rte_read64_relaxed +#define timvf_write64 rte_write64_relaxed + extern int otx_logtype_timvf; +static const uint16_t nb_chunk_slots = (TIM_CHUNK_SIZE / 16) - 1; struct timvf_info { uint16_t domain; /* Domain id */ uint8_t total_timvfs; /* Total timvf available in domain */ }; +enum timvf_clk_src { + TIM_CLK_SRC_SCLK = RTE_EVENT_TIMER_ADAPTER_CPU_CLK, + TIM_CLK_SRC_GPIO = RTE_EVENT_TIMER_ADAPTER_EXT_CLK0, + TIM_CLK_SRC_GTI = RTE_EVENT_TIMER_ADAPTER_EXT_CLK1, + TIM_CLK_SRC_PTP = RTE_EVENT_TIMER_ADAPTER_EXT_CLK2, +}; + +/* TIM_MEM_BUCKET */ +struct tim_mem_bucket { + uint64_t first_chunk; + union { + uint64_t w1; + struct { + uint32_t nb_entry; + uint8_t sbt:1; + uint8_t hbt:1; + uint8_t bsk:1; + uint8_t rsvd:5; + uint8_t lock; + int16_t chunk_remainder; + }; + }; + uint64_t current_chunk; + uint64_t pad; +} __rte_packed; + +struct tim_mem_entry { + uint64_t w0; + uint64_t wqe; +} __rte_packed; + +struct timvf_ctrl_reg { + uint64_t rctrl0; + uint64_t rctrl1; + uint64_t rctrl2; + uint8_t use_pmu; +} __rte_packed; + +struct timvf_ring; + +typedef uint32_t (*bkt_id)(const uint32_t bkt_tcks, const uint32_t nb_bkts); +typedef struct tim_mem_entry * (*refill_chunk)( + struct tim_mem_bucket * const bkt, + struct timvf_ring * const timr); + +struct timvf_ring { + bkt_id get_target_bkt; + refill_chunk refill_chunk; + struct rte_reciprocal_u64 fast_div; + uint64_t ring_start_cyc; + uint32_t nb_bkts; + struct tim_mem_bucket *bkt; + void *chunk_pool; + uint64_t tck_int; + uint64_t tck_nsec; + void *vbar0; + void *bkt_pos; + uint64_t max_tout; + uint64_t nb_chunks; + enum timvf_clk_src clk_src; + uint16_t tim_ring_id; +} __rte_cache_aligned; + +static __rte_always_inline uint32_t +bkt_mod(const uint32_t rel_bkt, const uint32_t nb_bkts) +{ + return rel_bkt % nb_bkts; +} + 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, + uint32_t *caps, const struct rte_event_timer_adapter_ops **ops, + uint8_t enable_stats); #endif /* __TIMVF_EVDEV_H__ */ -- 2.17.0