From patchwork Wed Nov 13 02:33:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanxiao Li X-Patchwork-Id: 148380 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D355345CC8; Wed, 13 Nov 2024 03:40:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E153B40E4B; Wed, 13 Nov 2024 03:39:33 +0100 (CET) Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by mails.dpdk.org (Postfix) with ESMTP id 44FA440E0A for ; Wed, 13 Nov 2024 03:39:26 +0100 (CET) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4Xp6tj29FDz5B1Jv for ; Wed, 13 Nov 2024 10:39:25 +0800 (CST) Received: from szxlzmapp06.zte.com.cn ([10.5.230.252]) by mse-fl2.zte.com.cn with SMTP id 4AD2d57L065783 for ; Wed, 13 Nov 2024 10:39:05 +0800 (+08) (envelope-from li.hanxiao@zte.com.cn) Received: from localhost.localdomain (unknown [192.168.6.15]) by smtp (Zmail) with SMTP; Wed, 13 Nov 2024 10:39:06 +0800 X-Zmail-TransId: 3e816734114a005-aaeef From: Hanxiao Li To: dev@dpdk.org Cc: Hanxiao Li Subject: [PATCH v22 08/13] compress/zsda: add zsda compressdev stats ops Date: Wed, 13 Nov 2024 10:33:13 +0800 Message-ID: <20241113023323.3228516-7-li.hanxiao@zte.com.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241113023323.3228516-1-li.hanxiao@zte.com.cn> References: <20241113022918.3228337-2-li.hanxiao@zte.com.cn> <20241113023323.3228516-1-li.hanxiao@zte.com.cn> MIME-Version: 1.0 X-MAIL: mse-fl2.zte.com.cn 4AD2d57L065783 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6734115D.000/4Xp6tj29FDz5B1Jv X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add zsda compressdev stats interface implementation. Signed-off-by: Hanxiao Li --- drivers/common/zsda/zsda_qp_common.c | 63 +++++++++++++++++++++++++++ drivers/common/zsda/zsda_qp_common.h | 16 +++++++ drivers/compress/zsda/zsda_comp_pmd.c | 25 ++++++++++- 3 files changed, 102 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/drivers/common/zsda/zsda_qp_common.c b/drivers/common/zsda/zsda_qp_common.c index 9c7152eb24..70367e6c82 100644 --- a/drivers/common/zsda/zsda_qp_common.c +++ b/drivers/common/zsda/zsda_qp_common.c @@ -55,3 +55,66 @@ zsda_queue_pair_release(struct zsda_qp **qp_addr) return ZSDA_SUCCESS; } + +void +zsda_stats_get(void **queue_pairs, const uint32_t nb_queue_pairs, + struct zsda_qp_stat *stats) +{ + enum zsda_service_type type; + uint32_t i; + struct zsda_qp *qp; + + if ((stats == NULL) || (queue_pairs == NULL)) { + ZSDA_LOG(ERR, "Failed! stats or queue_pairs is NULL"); + return; + } + + for (i = 0; i < nb_queue_pairs; i++) { + qp = queue_pairs[i]; + + if (qp == NULL) { + ZSDA_LOG(ERR, "Failed! queue_pairs[i] is NULL"); + break; + } + + for (type = 0; type < ZSDA_SERVICE_INVALID; type++) { + if (qp->srv[type].used) { + stats->enqueued_count += + qp->srv[type].stats.enqueued_count; + stats->dequeued_count += + qp->srv[type].stats.dequeued_count; + stats->enqueue_err_count += + qp->srv[type].stats.enqueue_err_count; + stats->dequeue_err_count += + qp->srv[type].stats.dequeue_err_count; + } + } + } +} + +void +zsda_stats_reset(void **queue_pairs, const uint32_t nb_queue_pairs) +{ + enum zsda_service_type type; + uint32_t i; + struct zsda_qp *qp; + + if (queue_pairs == NULL) { + ZSDA_LOG(ERR, "Failed! queue_pairs is NULL"); + return; + } + + for (i = 0; i < nb_queue_pairs; i++) { + qp = queue_pairs[i]; + + if (qp == NULL) { + ZSDA_LOG(ERR, "Failed! queue_pairs[i] is NULL"); + break; + } + for (type = 0; type < ZSDA_MAX_SERVICES; type++) { + if (qp->srv[type].used) + memset(&(qp->srv[type].stats), 0, + sizeof(struct zsda_qp_stat)); + } + } +} diff --git a/drivers/common/zsda/zsda_qp_common.h b/drivers/common/zsda/zsda_qp_common.h index 1522f9605e..35c7038a4d 100644 --- a/drivers/common/zsda/zsda_qp_common.h +++ b/drivers/common/zsda/zsda_qp_common.h @@ -89,10 +89,23 @@ struct zsda_queue { uint16_t sid; }; +struct zsda_qp_stat { + /**< Count of all operations enqueued */ + uint64_t enqueued_count; + /**< Count of all operations dequeued */ + uint64_t dequeued_count; + + /**< Total error count on operations enqueued */ + uint64_t enqueue_err_count; + /**< Total error count on operations dequeued */ + uint64_t dequeue_err_count; +}; + struct qp_srv { bool used; struct zsda_queue tx_q; struct zsda_queue rx_q; + struct zsda_qp_stat stats; struct rte_mempool *op_cookie_pool; void **op_cookies; uint16_t nb_descriptors; @@ -103,5 +116,8 @@ struct zsda_qp { }; int zsda_queue_pair_release(struct zsda_qp **qp_addr); +void zsda_stats_get(void **queue_pairs, const uint32_t nb_queue_pairs, + struct zsda_qp_stat *stats); +void zsda_stats_reset(void **queue_pairs, const uint32_t nb_queue_pairs); #endif /* _ZSDA_QP_COMMON_H_ */ diff --git a/drivers/compress/zsda/zsda_comp_pmd.c b/drivers/compress/zsda/zsda_comp_pmd.c index 3bdcd66f6a..555178cd12 100644 --- a/drivers/compress/zsda/zsda_comp_pmd.c +++ b/drivers/compress/zsda/zsda_comp_pmd.c @@ -140,6 +140,27 @@ zsda_comp_dev_info_get(struct rte_compressdev *dev, } } +static void +zsda_comp_stats_get(struct rte_compressdev *dev, + struct rte_compressdev_stats *stats) +{ + struct zsda_qp_stat stats_info = {0}; + + zsda_stats_get(dev->data->queue_pairs, dev->data->nb_queue_pairs, + &stats_info); + stats->enqueued_count = stats_info.enqueued_count; + stats->dequeued_count = stats_info.dequeued_count; + stats->enqueue_err_count = stats_info.enqueue_err_count; + stats->dequeue_err_count = stats_info.dequeue_err_count; +} + + +static void +zsda_comp_stats_reset(struct rte_compressdev *dev) +{ + zsda_stats_reset(dev->data->queue_pairs, dev->data->nb_queue_pairs); +} + static struct rte_compressdev_ops compress_zsda_ops = { .dev_configure = zsda_comp_dev_config, @@ -148,8 +169,8 @@ static struct rte_compressdev_ops compress_zsda_ops = { .dev_close = zsda_comp_dev_close, .dev_infos_get = zsda_comp_dev_info_get, - .stats_get = NULL, - .stats_reset = NULL, + .stats_get = zsda_comp_stats_get, + .stats_reset = zsda_comp_stats_reset, .queue_pair_setup = NULL, .queue_pair_release = NULL,