From patchwork Thu Jan 9 10:44:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanxiao Li X-Patchwork-Id: 149768 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 4E26645F6A; Thu, 9 Jan 2025 11:55:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D004410D2; Thu, 9 Jan 2025 11:55:20 +0100 (CET) Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by mails.dpdk.org (Postfix) with ESMTP id 0561B40EE4 for ; Thu, 9 Jan 2025 11:55:19 +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 4YTMBV2KS7z8R043 for ; Thu, 9 Jan 2025 18:55:14 +0800 (CST) Received: from szxlzmapp03.zte.com.cn ([10.5.231.207]) by mse-fl2.zte.com.cn with SMTP id 509Ash85043527 for ; Thu, 9 Jan 2025 18:54:43 +0800 (+08) (envelope-from li.hanxiao@zte.com.cn) Received: from localhost.localdomain (unknown [192.168.6.15]) by smtp (Zmail) with SMTP; Sat, 9 Jan 2025 18:54:45 +0800 X-Zmail-TransId: 3e81677faaf5002-53b45 From: Hanxiao Li To: dev@dpdk.org Cc: Hanxiao Li Subject: [PATCH v23 08/13] compress/zsda: add zsda compressdev stats ops Date: Thu, 9 Jan 2025 18:44:12 +0800 Message-ID: <20250109104454.2404815-7-li.hanxiao@zte.com.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250109104454.2404815-1-li.hanxiao@zte.com.cn> References: <20250109104203.2404659-2-li.hanxiao@zte.com.cn> <20250109104454.2404815-1-li.hanxiao@zte.com.cn> MIME-Version: 1.0 X-MAIL: mse-fl2.zte.com.cn 509Ash85043527 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 677FAB12.000/4YTMBV2KS7z8R043 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 | 24 +++++++++- 3 files changed, 101 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 5a249be675..577392871f 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 edce415298..f589df986e 100644 --- a/drivers/common/zsda/zsda_qp_common.h +++ b/drivers/common/zsda/zsda_qp_common.h @@ -93,10 +93,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; @@ -108,5 +121,8 @@ struct zsda_qp { void zsda_queue_delete(const struct zsda_queue *queue); 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 7e4e0372df..ee3d6602ec 100644 --- a/drivers/compress/zsda/zsda_comp_pmd.c +++ b/drivers/compress/zsda/zsda_comp_pmd.c @@ -129,6 +129,26 @@ 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, @@ -137,8 +157,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,