From: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
To: jerin.jacob@caviumnetworks.com,
santosh.shukla@caviumnetworks.com, erik.g.carrillo@intel.com
Cc: dev@dpdk.org, Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Subject: [dpdk-dev] [PATCH v4 04/11] event/octeontx: add support to start and stop timer device
Date: Tue, 10 Apr 2018 02:30:28 +0530 [thread overview]
Message-ID: <20180409210035.23278-5-pbhagavatula@caviumnetworks.com> (raw)
In-Reply-To: <20180409210035.23278-1-pbhagavatula@caviumnetworks.com>
When application requests to start the timer adapter through
`rte_event_timer_adapter_start`, Octeontx TIMvf ring does the
following:
- Uses mbox to communicate TIMpf driver about,
* SCLK frequency used to convert ns<->cycles.
* program the ring control parameters and start the ring.
* get the exact cycle at which the TIMvf ring has started which can be
used to estimate the bucket position.
On `rte_event_timer_adapter_stop` i.e stop, Octeontx TIMvf ring does the
following:
- Use mbox to communicate TIMpf driver about,
* reset the ring control parameters and stop the ring.
Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
drivers/event/octeontx/timvf_evdev.c | 144 +++++++++++++++++++++++++++
drivers/event/octeontx/timvf_evdev.h | 5 +
2 files changed, 149 insertions(+)
diff --git a/drivers/event/octeontx/timvf_evdev.c b/drivers/event/octeontx/timvf_evdev.c
index 5728d4944..84c6a511e 100644
--- a/drivers/event/octeontx/timvf_evdev.c
+++ b/drivers/event/octeontx/timvf_evdev.c
@@ -16,6 +16,32 @@ otx_timvf_init_log(void)
rte_log_set_level(otx_logtype_timvf, RTE_LOG_NOTICE);
}
+struct __rte_packed timvf_mbox_dev_info {
+ uint64_t ring_active[4];
+ uint64_t clk_freq;
+};
+
+/* Response messages */
+enum {
+ MBOX_RET_SUCCESS,
+ MBOX_RET_INVALID,
+ MBOX_RET_INTERNAL_ERR,
+};
+
+static int
+timvf_mbox_dev_info_get(struct timvf_mbox_dev_info *info)
+{
+ struct octeontx_mbox_hdr hdr = {0};
+ uint16_t len = sizeof(struct timvf_mbox_dev_info);
+
+ hdr.coproc = TIM_COPROC;
+ hdr.msg = TIM_GET_DEV_INFO;
+ hdr.vfid = 0; /* TIM DEV is always 0. TIM RING ID changes. */
+
+ memset(info, 0, len);
+ return octeontx_mbox_send(&hdr, NULL, 0, info, len);
+}
+
static void
timvf_ring_info_get(const struct rte_event_timer_adapter *adptr,
struct rte_event_timer_adapter_info *adptr_info)
@@ -27,6 +53,122 @@ timvf_ring_info_get(const struct rte_event_timer_adapter *adptr,
sizeof(struct rte_event_timer_adapter_conf));
}
+static int
+timvf_ring_conf_set(struct timvf_ctrl_reg *rctl, uint8_t ring_id)
+{
+ struct octeontx_mbox_hdr hdr = {0};
+ uint16_t len = sizeof(struct timvf_ctrl_reg);
+ int ret;
+
+ hdr.coproc = TIM_COPROC;
+ hdr.msg = TIM_SET_RING_INFO;
+ hdr.vfid = ring_id;
+
+ ret = octeontx_mbox_send(&hdr, rctl, len, NULL, 0);
+ if (ret < 0 || hdr.res_code != MBOX_RET_SUCCESS)
+ return -EACCES;
+ return 0;
+}
+
+static int
+timvf_get_start_cyc(uint64_t *now, uint8_t ring_id)
+{
+ struct octeontx_mbox_hdr hdr = {0};
+
+ hdr.coproc = TIM_COPROC;
+ hdr.msg = TIM_RING_START_CYC_GET;
+ hdr.vfid = ring_id;
+ *now = 0;
+ return octeontx_mbox_send(&hdr, NULL, 0, now, sizeof(uint64_t));
+}
+
+static int
+timvf_ring_start(const struct rte_event_timer_adapter *adptr)
+{
+ int ret;
+ uint64_t interval;
+ struct timvf_ctrl_reg rctrl;
+ struct timvf_mbox_dev_info dinfo;
+ struct timvf_ring *timr = adptr->data->adapter_priv;
+
+ ret = timvf_mbox_dev_info_get(&dinfo);
+ if (ret < 0 || ret != sizeof(struct timvf_mbox_dev_info))
+ return -EINVAL;
+
+ /* Calculate the interval cycles according to clock source. */
+ switch (timr->clk_src) {
+ case TIM_CLK_SRC_SCLK:
+ interval = NSEC2CLK(timr->tck_nsec, dinfo.clk_freq);
+ break;
+ case TIM_CLK_SRC_GPIO:
+ /* GPIO doesn't work on tck_nsec. */
+ interval = 0;
+ break;
+ case TIM_CLK_SRC_GTI:
+ interval = NSEC2CLK(timr->tck_nsec, dinfo.clk_freq);
+ break;
+ case TIM_CLK_SRC_PTP:
+ interval = NSEC2CLK(timr->tck_nsec, dinfo.clk_freq);
+ break;
+ default:
+ timvf_log_err("Unsupported clock source configured %d",
+ timr->clk_src);
+ return -EINVAL;
+ }
+
+ /*CTRL0 register.*/
+ rctrl.rctrl0 = interval;
+
+ /*CTRL1 register.*/
+ rctrl.rctrl1 = (uint64_t)(timr->clk_src) << 51 |
+ 1ull << 48 /* LOCK_EN (Enable hw bucket lock mechanism) */ |
+ 1ull << 47 /* ENA */ |
+ 1ull << 44 /* ENA_LDWB */ |
+ (timr->nb_bkts - 1);
+
+ rctrl.rctrl2 = (uint64_t)(TIM_CHUNK_SIZE / 16) << 40;
+
+ timvf_write64((uintptr_t)timr->bkt,
+ (uint8_t *)timr->vbar0 + TIM_VRING_BASE);
+ if (timvf_ring_conf_set(&rctrl, timr->tim_ring_id)) {
+ ret = -EACCES;
+ goto error;
+ }
+
+ if (timvf_get_start_cyc(&timr->ring_start_cyc,
+ timr->tim_ring_id) < 0) {
+ ret = -EACCES;
+ goto error;
+ }
+ timr->tck_int = NSEC2CLK(timr->tck_nsec, rte_get_timer_hz());
+ timr->fast_div = rte_reciprocal_value_u64(timr->tck_int);
+ timvf_log_info("nb_bkts %d min_ns %"PRIu64" min_cyc %"PRIu64""
+ " maxtmo %"PRIu64"\n",
+ timr->nb_bkts, timr->tck_nsec, interval,
+ timr->max_tout);
+
+ return 0;
+error:
+ rte_free(timr->bkt);
+ rte_mempool_free(timr->chunk_pool);
+ return ret;
+}
+
+static int
+timvf_ring_stop(const struct rte_event_timer_adapter *adptr)
+{
+ struct timvf_ring *timr = adptr->data->adapter_priv;
+ struct timvf_ctrl_reg rctrl = {0};
+ rctrl.rctrl0 = timvf_read64((uint8_t *)timr->vbar0 + TIM_VRING_CTL0);
+ rctrl.rctrl1 = timvf_read64((uint8_t *)timr->vbar0 + TIM_VRING_CTL1);
+ rctrl.rctrl1 &= ~(1ull << 47); /* Disable */
+ rctrl.rctrl2 = timvf_read64((uint8_t *)timr->vbar0 + TIM_VRING_CTL2);
+
+ if (timvf_ring_conf_set(&rctrl, timr->tim_ring_id))
+ return -EACCES;
+ return 0;
+}
+
static int
timvf_ring_create(struct rte_event_timer_adapter *adptr)
{
@@ -129,6 +271,8 @@ timvf_ring_free(struct rte_event_timer_adapter *adptr)
static struct rte_event_timer_adapter_ops timvf_ops = {
.init = timvf_ring_create,
.uninit = timvf_ring_free,
+ .start = timvf_ring_start,
+ .stop = timvf_ring_stop,
.get_info = timvf_ring_info_get,
};
diff --git a/drivers/event/octeontx/timvf_evdev.h b/drivers/event/octeontx/timvf_evdev.h
index ef8ec0ced..7663dc375 100644
--- a/drivers/event/octeontx/timvf_evdev.h
+++ b/drivers/event/octeontx/timvf_evdev.h
@@ -75,6 +75,11 @@
#define TIM_VRING_AURA (0x108)
#define TIM_VRING_REL (0x110)
+
+#define NSEC_PER_SEC 1E9
+#define NSEC2CLK(__ns, __freq) (((__ns) * (__freq)) / NSEC_PER_SEC)
+#define CLK2NSEC(__clk, __freq) (((__clk) * NSEC_PER_SEC) / (__freq))
+
#define timvf_read64 rte_read64_relaxed
#define timvf_write64 rte_write64_relaxed
--
2.17.0
next prev parent reply other threads:[~2018-04-09 21:01 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-16 21:36 [dpdk-dev] [PATCH 0/9] event/octeontx: add event timer adapter driver Pavan Nikhilesh
2018-02-16 21:36 ` [dpdk-dev] [PATCH 01/10] eal: add API to align variable to previous power of 2 Pavan Nikhilesh
2018-02-17 4:49 ` Jerin Jacob
2018-02-16 21:36 ` [dpdk-dev] [PATCH 02/10] mempool/octeontx: probe timvf PCIe devices Pavan Nikhilesh
2018-02-17 4:54 ` Jerin Jacob
2018-02-19 9:19 ` Pavan Nikhilesh
2018-02-16 21:36 ` [dpdk-dev] [PATCH 03/10] event/octeontx: add support to create and free timer adapter Pavan Nikhilesh
2018-02-16 21:36 ` [dpdk-dev] [PATCH 04/10] event/octeontx: add support to start and stop timer device Pavan Nikhilesh
2018-02-16 21:36 ` [dpdk-dev] [PATCH 05/10] event/octeontx: add support for arm and cancel Pavan Nikhilesh
2018-02-16 21:36 ` [dpdk-dev] [PATCH 06/10] event/octeontx: add single producer timer arm variant Pavan Nikhilesh
2018-03-07 19:41 ` Carrillo, Erik G
2018-02-16 21:36 ` [dpdk-dev] [PATCH 07/10] event/octeontx: optimize timer adapter resolution parameters Pavan Nikhilesh
2018-02-17 5:06 ` Jerin Jacob
2018-02-19 9:34 ` Pavan Nikhilesh
2018-02-16 21:36 ` [dpdk-dev] [PATCH 08/10] event/octeontx: add option to use fpavf as chunk pool Pavan Nikhilesh
2018-02-18 11:42 ` santosh
2018-02-19 9:15 ` Pavan Nikhilesh
2018-02-23 20:17 ` Carrillo, Erik G
2018-02-26 19:25 ` Pavan Nikhilesh
2018-02-16 21:36 ` [dpdk-dev] [PATCH 09/10] event/octeontx: add timer adapter SW traversal routine Pavan Nikhilesh
2018-02-17 5:01 ` Jerin Jacob
2018-02-16 21:37 ` [dpdk-dev] [PATCH 10/10] maintainers: claim responsibility for octeontx timvf Pavan Nikhilesh
2018-02-17 5:03 ` Jerin Jacob
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 00/11] event/octeontx: add event timer adapter driver Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 01/11] mempool/octeontx: probe timvf PCIe devices Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 02/11] usertools: add Cavium TIM as an event device Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 03/11] event/octeontx: add support to create and free timer adapter Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 04/11] event/octeontx: add support to start and stop timer device Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 05/11] event/octeontx: add multiproducer timer arm and cancel Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 06/11] event/octeontx: add single producer timer arm variant Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 07/11] event/octeontx: add burst mode for timer arm Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 08/11] event/octeontx: optimize timer adapter resolution parameters Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 09/11] event/octeontx: add option to use fpavf as chunk pool Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 10/11] doc: update eventdev OcteonTx documentation Pavan Nikhilesh
2018-03-14 13:52 ` [dpdk-dev] [PATCH v2 11/11] maintainers: claim responsibility for octeontx timvf Pavan Nikhilesh
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 00/12] event/octeontx: add event timer adapter driver Pavan Nikhilesh
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 01/12] mempool/octeontx: probe timvf PCIe devices Pavan Nikhilesh
2018-04-08 2:19 ` Jerin Jacob
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 02/12] usertools: add Cavium TIM as an event device Pavan Nikhilesh
2018-04-08 3:23 ` Jerin Jacob
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 03/12] event/octeontx: add support to create and free timer adapter Pavan Nikhilesh
2018-04-08 7:39 ` Jerin Jacob
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 04/12] event/octeontx: add support to start and stop timer device Pavan Nikhilesh
2018-04-08 7:47 ` Jerin Jacob
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 05/12] event/octeontx: add event timer stats get and reset Pavan Nikhilesh
2018-04-04 1:59 ` Carrillo, Erik G
2018-04-08 7:52 ` Jerin Jacob
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 06/12] event/octeontx: add multiproducer timer arm and cancel Pavan Nikhilesh
2018-04-08 7:59 ` Jerin Jacob
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 07/12] event/octeontx: add single producer timer arm variant Pavan Nikhilesh
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 08/12] event/octeontx: add burst mode for timer arm Pavan Nikhilesh
2018-04-04 2:15 ` Carrillo, Erik G
2018-04-08 8:06 ` Jerin Jacob
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 09/12] event/octeontx: optimize timer adapter resolution parameters Pavan Nikhilesh
2018-04-08 8:09 ` Jerin Jacob
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 10/12] event/octeontx: add option to use fpavf as chunk pool Pavan Nikhilesh
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 11/12] doc: update eventdev OcteonTx documentation Pavan Nikhilesh
2018-04-04 2:19 ` Carrillo, Erik G
2018-04-08 8:13 ` Jerin Jacob
2018-04-03 15:05 ` [dpdk-dev] [PATCH v3 12/12] maintainers: claim responsibility for octeontx timvf Pavan Nikhilesh
2018-04-08 8:15 ` Jerin Jacob
2018-04-08 2:55 ` [dpdk-dev] [PATCH v3 00/12] event/octeontx: add event timer adapter driver Jerin Jacob
2018-04-08 8:58 ` Pavan Nikhilesh
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 00/11] " Pavan Nikhilesh
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 01/11] usertools: add Cavium TIM as an event device Pavan Nikhilesh
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 02/11] event/octeontx: add support to probe timvf PCIe devices Pavan Nikhilesh
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 03/11] event/octeontx: add support to create and free timer adapter Pavan Nikhilesh
2018-04-09 21:00 ` Pavan Nikhilesh [this message]
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 05/11] event/octeontx: add event timer stats get and reset Pavan Nikhilesh
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 06/11] event/octeontx: add multiproducer timer arm and cancel Pavan Nikhilesh
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 07/11] event/octeontx: add single producer timer arm variant Pavan Nikhilesh
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 08/11] event/octeontx: add burst mode for timer arm Pavan Nikhilesh
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 09/11] event/octeontx: optimize timer adapter resolution parameters Pavan Nikhilesh
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 10/11] event/octeontx: add option to use fpavf as chunk pool Pavan Nikhilesh
2018-04-09 21:00 ` [dpdk-dev] [PATCH v4 11/11] doc: update eventdev OcteonTx documentation Pavan Nikhilesh
2018-04-12 12:30 ` [dpdk-dev] [PATCH v4 00/11] event/octeontx: add event timer adapter driver Jerin Jacob
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180409210035.23278-5-pbhagavatula@caviumnetworks.com \
--to=pbhagavatula@caviumnetworks.com \
--cc=dev@dpdk.org \
--cc=erik.g.carrillo@intel.com \
--cc=jerin.jacob@caviumnetworks.com \
--cc=santosh.shukla@caviumnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).