From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3B09B1B1E0 for ; Thu, 11 Jan 2018 01:21:45 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2018 16:21:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,342,1511856000"; d="scan'208";a="192627470" Received: from txasoft-yocto.an.intel.com (HELO txasoft-yocto.an.intel.com.) ([10.123.72.111]) by orsmga005.jf.intel.com with ESMTP; 10 Jan 2018 16:21:43 -0800 From: Erik Gabriel Carrillo To: pbhagavatula@caviumnetworks.com Cc: dev@dpdk.org, jerin.jacob@caviumnetworks.com, nipun.gupta@nxp.com, hemant.agrawal@nxp.com Date: Wed, 10 Jan 2018 18:21:07 -0600 Message-Id: <1515630074-29020-17-git-send-email-erik.g.carrillo@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1515630074-29020-1-git-send-email-erik.g.carrillo@intel.com> References: <1512158458-22661-1-git-send-email-erik.g.carrillo@intel.com> <1515630074-29020-1-git-send-email-erik.g.carrillo@intel.com> Subject: [dpdk-dev] [PATCH v6 16/23] eventtimer: add stats to API 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: Thu, 11 Jan 2018 00:21:45 -0000 Add interfaces to support the collection, retrieval and resetting of per-adapter statistics. Signed-off-by: Erik Gabriel Carrillo --- lib/librte_eventdev/rte_event_timer_adapter.c | 79 +++++++++++++++++++---- lib/librte_eventdev/rte_event_timer_adapter.h | 51 +++++++++++++++ lib/librte_eventdev/rte_event_timer_adapter_pmd.h | 11 ++++ lib/librte_eventdev/rte_eventdev_version.map | 2 + 4 files changed, 130 insertions(+), 13 deletions(-) diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c b/lib/librte_eventdev/rte_event_timer_adapter.c index 176cc5b..ebc6124 100644 --- a/lib/librte_eventdev/rte_event_timer_adapter.c +++ b/lib/librte_eventdev/rte_event_timer_adapter.c @@ -405,6 +405,26 @@ rte_event_timer_init(struct rte_event_timer *evtim) } int +rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter, + struct rte_event_timer_adapter_stats *stats) +{ + ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL); + FUNC_PTR_OR_ERR_RET(adapter->ops->stats_get, -EINVAL); + if (stats == NULL) + return -EINVAL; + + return adapter->ops->stats_get(adapter, stats); +} + +int +rte_event_timer_adapter_stats_reset(struct rte_event_timer_adapter *adapter) +{ + ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL); + FUNC_PTR_OR_ERR_RET(adapter->ops->stats_reset, -EINVAL); + return adapter->ops->stats_reset(adapter); +} + +int rte_event_timer_arm_burst(const struct rte_event_timer_adapter *adapter, struct rte_event_timer **evtims, uint16_t nb_evtims) @@ -503,7 +523,8 @@ event_buffer_add(struct event_buffer *bufp, struct rte_event *eventp) static void event_buffer_flush(struct event_buffer *bufp, uint8_t dev_id, uint8_t port_id, - uint16_t *nb_events_flushed) + uint16_t *nb_events_flushed, + uint16_t *nb_events_inv) { uint16_t n = 0; uint16_t *headp = &bufp->head; @@ -519,17 +540,19 @@ event_buffer_flush(struct event_buffer *bufp, uint8_t dev_id, uint8_t port_id, return; } + *nb_events_inv = 0; *nb_events_flushed = rte_event_enqueue_burst(dev_id, port_id, &events[*headp], n); if (*nb_events_flushed != n && rte_errno == -EINVAL) { /* We must have hit a bad event...skip it to ensure we don't * hang on it. */ - (*nb_events_flushed)++; + nb_events_inv++; } - *headp = (*headp + *nb_events_flushed) % EVENT_BUFFER_SZ; - bufp->count -= *nb_events_flushed; + *headp = (*headp + *nb_events_flushed + *nb_events_inv) % + EVENT_BUFFER_SZ; + bufp->count -= (*nb_events_flushed + *nb_events_inv); } /* @@ -549,6 +572,8 @@ struct rte_event_timer_adapter_sw_data { struct rte_mempool *tim_pool; /* Buffered timer expiry events to be enqueued to an event device. */ struct event_buffer buffer; + /* Statistics */ + struct rte_event_timer_adapter_stats stats; }; enum msg_type {MSG_TYPE_ARM, MSG_TYPE_CANCEL}; @@ -561,7 +586,7 @@ struct msg { static void sw_event_timer_cb(struct rte_timer *tim, void *arg) { - uint16_t nb_evs_flushed; + uint16_t nb_evs_flushed, nb_evs_invalid; int ret; struct rte_event_timer *evtim; struct rte_event_timer_adapter *adapter; @@ -579,6 +604,8 @@ sw_event_timer_cb(struct rte_timer *tim, void *arg) */ rte_timer_reset_sync(tim, SINGLE, 0, rte_lcore_id(), sw_event_timer_cb, evtim); + + sw_data->stats.evtim_retry_count++; } else { sw_data->nb_armed_evtims--; rte_wmb(); @@ -590,7 +617,11 @@ sw_event_timer_cb(struct rte_timer *tim, void *arg) event_buffer_flush(&sw_data->buffer, adapter->data->event_dev_id, adapter->data->event_port_id, - &nb_evs_flushed); + &nb_evs_flushed, + &nb_evs_invalid); + + sw_data->stats.ev_enq_count += nb_evs_flushed; + sw_data->stats.ev_inv_count += nb_evs_invalid; } } @@ -683,9 +714,9 @@ validate_event_timer(struct rte_event_timer *evtim, static int sw_event_timer_adapter_service_func(void *arg) { - int i, num_msgs, ret; + int i, num_msgs; uint64_t cycles; - uint16_t nb_events; + uint16_t nb_evs_flushed, nb_evs_invalid; struct rte_event_timer_adapter *adapter; struct rte_event_timer_adapter_sw_data *sw_data; struct rte_event_timer *evtim = NULL; @@ -751,12 +782,12 @@ sw_event_timer_adapter_service_func(void *arg) rte_timer_manage(); event_buffer_flush(&sw_data->buffer, adapter->data->event_dev_id, - adapter->data->event_port_id, &nb_events); - - /* Could use for stats */ - RTE_SET_USED(nb_events); - RTE_SET_USED(ret); + adapter->data->event_port_id, &nb_evs_flushed, + &nb_evs_invalid); + sw_data->stats.ev_enq_count += nb_evs_flushed; + sw_data->stats.ev_inv_count += nb_evs_invalid; + sw_data->stats.svc_run_count++; return 0; } @@ -911,6 +942,26 @@ sw_event_timer_adapter_stop(const struct rte_event_timer_adapter *adapter) return rte_service_component_runstate_set(sw_data->service_id, 0); } +static int +sw_event_timer_adapter_stats_get(const struct rte_event_timer_adapter *adapter, + struct rte_event_timer_adapter_stats *stats) +{ + struct rte_event_timer_adapter_sw_data *sw_data; + sw_data = adapter->data->adapter_priv; + *stats = sw_data->stats; + return 0; +} + +static int +sw_event_timer_adapter_stats_reset( + const struct rte_event_timer_adapter *adapter) +{ + struct rte_event_timer_adapter_sw_data *sw_data; + sw_data = adapter->data->adapter_priv; + memset(&sw_data->stats, 0, sizeof(sw_data->stats)); + return 0; +} + static __rte_always_inline void swap(struct rte_event_timer **evtims, int i, int j) { @@ -1076,6 +1127,8 @@ const struct rte_event_timer_adapter_ops sw_event_adapter_timer_ops = { .start = sw_event_timer_adapter_start, .stop = sw_event_timer_adapter_stop, .get_info = NULL, + .stats_get = sw_event_timer_adapter_stats_get, + .stats_reset = sw_event_timer_adapter_stats_reset, .arm_burst = sw_event_timer_arm_burst, .arm_tmo_tick_burst = sw_event_timer_arm_tmo_tick_burst, .cancel_burst = sw_event_timer_cancel_burst, diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h b/lib/librte_eventdev/rte_event_timer_adapter.h index 3488488..a4b16a7 100644 --- a/lib/librte_eventdev/rte_event_timer_adapter.h +++ b/lib/librte_eventdev/rte_event_timer_adapter.h @@ -201,6 +201,23 @@ struct rte_event_timer_adapter_conf { /**< Timer adapter config flags (RTE_EVENT_TIMER_ADAPTER_F_*) */ }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * Event timer adapter stats structure + */ +struct rte_event_timer_adapter_stats { + uint64_t ev_enq_count; + /**< Eventdev enqueue count */ + uint64_t ev_inv_count; + /**< Invalid expiry event count */ + uint64_t evtim_retry_count; + /**< Event timer retry count */ + uint64_t svc_run_count; + /**< Service run count */ +}; + struct rte_event_timer_adapter; /** @@ -420,6 +437,40 @@ rte_event_timer_adapter_service_id_get(struct rte_event_timer_adapter *adapter, /** * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Retrieve statistics for an event timer adapter instance. + * + * @param adapter + * A pointer to an event timer adapter structure. + * @param[out] stats + * A pointer to a structure to fill with statistics. + * + * @return + * - 0: Successfully retrieved. + * - <0: Failure; error code returned. + */ +int rte_event_timer_adapter_stats_get(struct rte_event_timer_adapter *adapter, + struct rte_event_timer_adapter_stats *stats); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Reset statistics for an event timer adapter instance. + * + * @param adapter + * A pointer to an event timer adapter structure. + * + * @return + * - 0: Successfully reset; + * - <0: Failure; error code returned. + */ +int rte_event_timer_adapter_stats_reset( + struct rte_event_timer_adapter *adapter); + +/** + * @warning * @b EXPERIMENTAL: this structure may change without prior notice * * Event timer state. diff --git a/lib/librte_eventdev/rte_event_timer_adapter_pmd.h b/lib/librte_eventdev/rte_event_timer_adapter_pmd.h index 6c65c36..a8c068f 100644 --- a/lib/librte_eventdev/rte_event_timer_adapter_pmd.h +++ b/lib/librte_eventdev/rte_event_timer_adapter_pmd.h @@ -68,6 +68,13 @@ typedef void (*rte_event_timer_adapter_get_info_t)( const struct rte_event_timer_adapter *adapter, struct rte_event_timer_adapter_info *adapter_info); /**< @internal Get contextual information for event timer adapter */ +typedef int (*rte_event_timer_adapter_stats_get_t)( + const struct rte_event_timer_adapter *adapter, + struct rte_event_timer_adapter_stats *stats); +/**< @internal Get statistics for event timer adapter */ +typedef int (*rte_event_timer_adapter_stats_reset_t)( + const struct rte_event_timer_adapter *adapter); +/**< @internal Reset statistics for event timer adapter */ typedef int (*rte_event_timer_arm_burst_t)( const struct rte_event_timer_adapter *adapter, struct rte_event_timer **tims, @@ -96,6 +103,10 @@ struct rte_event_timer_adapter_ops { rte_event_timer_adapter_stop_t stop; /**< Stop adapter */ rte_event_timer_adapter_get_info_t get_info; /**< Get info from driver */ + rte_event_timer_adapter_stats_get_t stats_get; + /**< Get adapter statistics */ + rte_event_timer_adapter_stats_reset_t stats_reset; + /**< Reset adapter statistics */ rte_event_timer_arm_burst_t arm_burst; /**< Arm one or more event timers */ rte_event_timer_arm_tmo_tick_burst_t arm_tmo_tick_burst; diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index c4bc946..6a98840 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -77,6 +77,8 @@ DPDK_18.02 { rte_event_timer_adapter_get_info; rte_event_timer_adapter_service_id_get; rte_event_timer_adapter_start; + rte_event_timer_adapter_stats_get; + rte_event_timer_adapter_stats_reset; rte_event_timer_adapter_stop; rte_event_timer_init; rte_event_timer_arm_burst; -- 2.6.4