From patchwork Mon Jan 13 02:29:33 2025
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Hanxiao Li
X-Patchwork-Id: 149926
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 A746C46063;
Mon, 13 Jan 2025 03:42:41 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
by mails.dpdk.org (Postfix) with ESMTP id 1A1BB40B90;
Mon, 13 Jan 2025 03:41:33 +0100 (CET)
Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209])
by mails.dpdk.org (Postfix) with ESMTP id 7D61540685
for ; Mon, 13 Jan 2025 03:41:22 +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 mxct.zte.com.cn (FangMail) with ESMTPS id 4YWc2l3jvtz501bd
for ; Mon, 13 Jan 2025 10:41:19 +0800 (CST)
Received: from szxl2zmapp05.zte.com.cn ([10.1.32.37])
by mse-fl2.zte.com.cn with SMTP id 50D2eqtt077070
for ; Mon, 13 Jan 2025 10:40:52 +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 Jan 2025 10:40:54 +0800
X-Zmail-TransId: 3e8167847d35002-8788f
From: Hanxiao Li
To: dev@dpdk.org
Cc: Hanxiao Li
Subject: [PATCH v24 08/13] compress/zsda: add zsda compressdev stats ops
Date: Mon, 13 Jan 2025 10:29:33 +0800
Message-ID: <20250113022943.2603401-9-li.hanxiao@zte.com.cn>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20250113022943.2603401-1-li.hanxiao@zte.com.cn>
References: <20250109104203.2404659-2-li.hanxiao@zte.com.cn>
<20250113022943.2603401-1-li.hanxiao@zte.com.cn>
MIME-Version: 1.0
X-MAIL: mse-fl2.zte.com.cn 50D2eqtt077070
X-Fangmail-Anti-Spam-Filtered: true
X-Fangmail-MID-QID: 67847D4F.000/4YWc2l3jvtz501bd
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,