From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 50631A034C; Mon, 14 Nov 2022 13:09:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 42F7E410E5; Mon, 14 Nov 2022 13:09:45 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 2729140DFD for ; Mon, 14 Nov 2022 13:09:43 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AE6hJAp008852; Mon, 14 Nov 2022 04:07:10 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=VBIwRTC9V/2olikzRH22/iGcadLaH6VQ8+RIzHTguL4=; b=PqcnG6+bcfzBwXo6ZH48PL6AZE6WqQnSKqUXzVeL6jGe4+h38iZCUvrVv8tRiVI2RciV u/wLmA02QJxqvzzurEHqzpUIQxPEBGxuiU57YazbQ+Y6lTLl4lIpjgvvrGw22zTTA8To HLNT1ZK6Bz3KjkwplaNsdlmuCyFVsvrMM/dPhT3ZoPWUW0mQfBKgW3EJ6pNqCbjHnhix eXqn6WJdvVTu3c7yssi6A7QCAX17n6WD7vjShUPm7qs55pe9DuMzSwnNsEx/A4c4sWe7 b4d8yXuwymKOsjNyhoYqFiy3r+NmHVCSMsDGFyAvt6NlhGwlZOGNFtx6sPbTJS30AOFT cQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3kugnb0wyd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 14 Nov 2022 04:07:10 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Nov 2022 04:07:08 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 14 Nov 2022 04:07:08 -0800 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 08F655C68E2; Mon, 14 Nov 2022 04:06:42 -0800 (PST) From: To: , Srikanth Yalavarthi CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jerin Jacob Subject: [dpdk-dev] [PATCH v1 09/12] mldev: support device statistics Date: Mon, 14 Nov 2022 17:32:35 +0530 Message-ID: <20221114120238.2143832-10-jerinj@marvell.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114120238.2143832-1-jerinj@marvell.com> References: <20220803132839.2747858-2-jerinj@marvell.com> <20221114120238.2143832-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: 0RyeMM3djZw_AnpaAOMxJxINNB2634Yo X-Proofpoint-GUID: 0RyeMM3djZw_AnpaAOMxJxINNB2634Yo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-14_10,2022-11-11_01,2022-06-22_01 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 From: Srikanth Yalavarthi Added functions to get and reset device stats. Device stats include number of requests enqueued, dequeued and errors. Added function prototypes to used by driver implementations. Signed-off-by: Srikanth Yalavarthi Signed-off-by: Jerin Jacob --- lib/mldev/rte_mldev.c | 40 ++++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 32 ++++++++++++++++++++++++++++++ lib/mldev/version.map | 2 ++ 3 files changed, 74 insertions(+) diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c index adf8ab8cbc..41b2a0be84 100644 --- a/lib/mldev/rte_mldev.c +++ b/lib/mldev/rte_mldev.c @@ -355,6 +355,46 @@ rte_ml_dev_queue_pair_setup(int16_t dev_id, uint16_t queue_pair_id, return (*dev->dev_ops->dev_queue_pair_setup)(dev, queue_pair_id, qp_conf, socket_id); } +int +rte_ml_dev_stats_get(int16_t dev_id, struct rte_ml_dev_stats *stats) +{ + struct rte_ml_dev *dev; + + if (!rte_ml_dev_is_valid_dev(dev_id)) { + ML_DEV_LOG(ERR, "Invalid dev_id = %d\n", dev_id); + return -EINVAL; + } + + dev = rte_ml_dev_pmd_get_dev(dev_id); + if (*dev->dev_ops->dev_stats_get == NULL) + return -ENOTSUP; + + if (stats == NULL) { + ML_DEV_LOG(ERR, "Dev %d, stats cannot be NULL\n", dev_id); + return -EINVAL; + } + memset(stats, 0, sizeof(struct rte_ml_dev_stats)); + + return (*dev->dev_ops->dev_stats_get)(dev, stats); +} + +void +rte_ml_dev_stats_reset(int16_t dev_id) +{ + struct rte_ml_dev *dev; + + if (!rte_ml_dev_is_valid_dev(dev_id)) { + ML_DEV_LOG(ERR, "Invalid dev_id = %d\n", dev_id); + return; + } + + dev = rte_ml_dev_pmd_get_dev(dev_id); + if (*dev->dev_ops->dev_stats_reset == NULL) + return; + + (*dev->dev_ops->dev_stats_reset)(dev); +} + int rte_ml_model_load(int16_t dev_id, struct rte_ml_model_params *params, int16_t *model_id) { diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h index 9c19d7badf..3f05ecd9c6 100644 --- a/lib/mldev/rte_mldev_core.h +++ b/lib/mldev/rte_mldev_core.h @@ -195,6 +195,32 @@ typedef int (*mldev_queue_pair_setup_t)(struct rte_ml_dev *dev, uint16_t queue_p */ typedef int (*mldev_queue_pair_release_t)(struct rte_ml_dev *dev, uint16_t queue_pair_id); +/** + * @internal + * + * Function used to get device statistics. + * + * @param dev + * ML device pointer. + * @param stats + * Pointer to ML device stats structure to update. + * + * @return + * - 0 on success. + * - < 0, error on failure. + */ +typedef int (*mldev_stats_get_t)(struct rte_ml_dev *dev, struct rte_ml_dev_stats *stats); + +/** + * @internal + * + * Function used to reset device statistics. + * + * @param dev + * ML device pointer. + */ +typedef void (*mldev_stats_reset_t)(struct rte_ml_dev *dev); + /** * @internal * @@ -420,6 +446,12 @@ struct rte_ml_dev_ops { /** Release a device queue pair. */ mldev_queue_pair_release_t dev_queue_pair_release; + /** Get device statistics. */ + mldev_stats_get_t dev_stats_get; + + /** Reset device statistics. */ + mldev_stats_reset_t dev_stats_reset; + /** Load an ML model. */ mldev_model_load_t model_load; diff --git a/lib/mldev/version.map b/lib/mldev/version.map index 5d44d210d7..d12263010b 100644 --- a/lib/mldev/version.map +++ b/lib/mldev/version.map @@ -10,6 +10,8 @@ EXPERIMENTAL { rte_ml_dev_queue_pair_setup; rte_ml_dev_socket_id; rte_ml_dev_start; + rte_ml_dev_stats_get; + rte_ml_dev_stats_reset; rte_ml_dev_stop; rte_ml_enqueue_burst; rte_ml_io_dequantize; -- 2.38.1