Add zsda compressdev stats interface implementation.
Signed-off-by: Hanxiao Li <li.hanxiao@zte.com.cn>
---
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(-)
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 4bcec4ad4c..603c0e9e3a 100644
--- a/drivers/common/zsda/zsda_qp_common.h
+++ b/drivers/common/zsda/zsda_qp_common.h
@@ -52,10 +52,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;
@@ -66,5 +79,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,
--
2.27.0