From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id D84B57DEC for ; Fri, 27 Apr 2018 15:24:16 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Apr 2018 06:24:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,335,1520924400"; d="scan'208";a="223862559" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by fmsmga005.fm.intel.com with ESMTP; 27 Apr 2018 06:24:14 -0700 From: Pablo de Lara To: dev@dpdk.org Cc: fiona.trahe@intel.com, shally.verma@cavium.com, ahmed.mansour@nxp.com, Ashish.Gupta@cavium.com, Pablo de Lara , Shally Verma , Ashish Gupta Date: Fri, 27 Apr 2018 14:24:04 +0100 Message-Id: <20180427132407.13385-12-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180427132407.13385-1-pablo.de.lara.guarch@intel.com> References: <1517595924-25963-1-git-send-email-fiona.trahe@intel.com> <20180427132407.13385-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v6 11/14] compressdev: add device stats 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: Fri, 27 Apr 2018 13:24:17 -0000 From: Fiona Trahe Signed-off-by: Fiona Trahe Signed-off-by: Pablo de Lara Signed-off-by: Shally Verma Signed-off-by: Ashish Gupta --- lib/librte_compressdev/rte_compressdev.c | 40 ++++++++++++++++++++++ lib/librte_compressdev/rte_compressdev.h | 39 +++++++++++++++++++++ lib/librte_compressdev/rte_compressdev_pmd.h | 26 ++++++++++++++ lib/librte_compressdev/rte_compressdev_version.map | 2 ++ 4 files changed, 107 insertions(+) diff --git a/lib/librte_compressdev/rte_compressdev.c b/lib/librte_compressdev/rte_compressdev.c index 03f1ab8a7..855385e10 100644 --- a/lib/librte_compressdev/rte_compressdev.c +++ b/lib/librte_compressdev/rte_compressdev.c @@ -555,6 +555,46 @@ rte_compressdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id, dev->data->queue_pairs[qp_id], ops, nb_ops); } +int __rte_experimental +rte_compressdev_stats_get(uint8_t dev_id, struct rte_compressdev_stats *stats) +{ + struct rte_compressdev *dev; + + if (!rte_compressdev_is_valid_dev(dev_id)) { + COMPRESSDEV_LOG(ERR, "Invalid dev_id=%d", dev_id); + return -ENODEV; + } + + if (stats == NULL) { + COMPRESSDEV_LOG(ERR, "Invalid stats ptr"); + return -EINVAL; + } + + dev = &rte_comp_devices[dev_id]; + memset(stats, 0, sizeof(*stats)); + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP); + (*dev->dev_ops->stats_get)(dev, stats); + return 0; +} + +void __rte_experimental +rte_compressdev_stats_reset(uint8_t dev_id) +{ + struct rte_compressdev *dev; + + if (!rte_compressdev_is_valid_dev(dev_id)) { + COMPRESSDEV_LOG(ERR, "Invalid dev_id=%" PRIu8, dev_id); + return; + } + + dev = &rte_comp_devices[dev_id]; + + RTE_FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset); + (*dev->dev_ops->stats_reset)(dev); +} + + void __rte_experimental rte_compressdev_info_get(uint8_t dev_id, struct rte_compressdev_info *dev_info) { diff --git a/lib/librte_compressdev/rte_compressdev.h b/lib/librte_compressdev/rte_compressdev.h index 30cf64c6e..5ad926976 100644 --- a/lib/librte_compressdev/rte_compressdev.h +++ b/lib/librte_compressdev/rte_compressdev.h @@ -63,6 +63,19 @@ struct rte_compressdev_info { */ }; +/** comp device statistics */ +struct rte_compressdev_stats { + uint64_t enqueued_count; + /**< Count of all operations enqueued */ + uint64_t dequeued_count; + /**< Count of all operations dequeued */ + + uint64_t enqueue_err_count; + /**< Total error count on operations enqueued */ + uint64_t dequeue_err_count; + /**< Total error count on operations dequeued */ +}; + /** * Get the compress device name given a device identifier. * @@ -229,6 +242,32 @@ rte_compressdev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, uint16_t __rte_experimental rte_compressdev_queue_pair_count(uint8_t dev_id); + +/** + * Retrieve the general I/O statistics of a device. + * + * @param dev_id + * The identifier of the device + * @param stats + * A pointer to a structure of type + * *rte_compressdev_stats* to be filled with the + * values of device counters + * @return + * - Zero if successful. + * - Non-zero otherwise. + */ +int __rte_experimental +rte_compressdev_stats_get(uint8_t dev_id, struct rte_compressdev_stats *stats); + +/** + * Reset the general I/O statistics of a device. + * + * @param dev_id + * The identifier of the device. + */ +void __rte_experimental +rte_compressdev_stats_reset(uint8_t dev_id); + /** * Retrieve the contextual information of a device. * diff --git a/lib/librte_compressdev/rte_compressdev_pmd.h b/lib/librte_compressdev/rte_compressdev_pmd.h index c08a3ee63..38e9ea02b 100644 --- a/lib/librte_compressdev/rte_compressdev_pmd.h +++ b/lib/librte_compressdev/rte_compressdev_pmd.h @@ -116,6 +116,27 @@ typedef void (*compressdev_stop_t)(struct rte_compressdev *dev); typedef int (*compressdev_close_t)(struct rte_compressdev *dev); +/** + * Function used to get statistics of a device. + * + * @param dev + * Compress device + * @param stats + * Compress device stats to populate + */ +typedef void (*compressdev_stats_get_t)(struct rte_compressdev *dev, + struct rte_compressdev_stats *stats); + + +/** + * Function used to reset statistics of a device. + * + * @param dev + * Compress device + */ +typedef void (*compressdev_stats_reset_t)(struct rte_compressdev *dev); + + /** * Function used to get specific information of a device. * @@ -247,6 +268,11 @@ struct rte_compressdev_ops { compressdev_info_get_t dev_infos_get; /**< Get device info. */ + compressdev_stats_get_t stats_get; + /**< Get device statistics. */ + compressdev_stats_reset_t stats_reset; + /**< Reset device statistics. */ + compressdev_queue_pair_setup_t queue_pair_setup; /**< Set up a device queue pair. */ compressdev_queue_pair_release_t queue_pair_release; diff --git a/lib/librte_compressdev/rte_compressdev_version.map b/lib/librte_compressdev/rte_compressdev_version.map index 5ed3080b4..8e4004631 100644 --- a/lib/librte_compressdev/rte_compressdev_version.map +++ b/lib/librte_compressdev/rte_compressdev_version.map @@ -25,6 +25,8 @@ EXPERIMENTAL { rte_compressdev_queue_pair_setup; rte_compressdev_socket_id; rte_compressdev_start; + rte_compressdev_stats_get; + rte_compressdev_stats_reset; rte_compressdev_stop; rte_compressdev_stream_create; rte_compressdev_stream_free; -- 2.14.3