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 4F3F741C25; Mon, 6 Feb 2023 21:26:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15A5342D12; Mon, 6 Feb 2023 21:25:50 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id EE15440A7D for ; Mon, 6 Feb 2023 21:25:48 +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 316F9xis017823; Mon, 6 Feb 2023 12:25:48 -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=zlfJZJXah38cks5VjMF3GWTAXydAKcunQQxjm6m0G7s=; b=fGPyhhET0u1EeyCIYjtaHOf86kLkrnyI7+zA6ClD5SlXGgLGr2NnV92RKpQLXc1YpJo9 CbUSC0XJ2+Jmj4oQT021BA0foFXVe0Q+EqB61dCmxIX2XyNC4LwKmx74WuY+ZUubcFe0 Ev39tAvHGdIleZMqaAJUvGjbXWNX/P/We+NiqgJHfdytf+9THwIZt3U7uI7ouy1i2dRI 0fD6aBuS3v9zDv+wCcjAeBvNmQclSvAc1G3xP/At0dSD9l59yOrwO4/GR/2sL7O2+Odv U4aSZVtbZwrwFJaTVlwk1pwnXk7jIuRHJeRv00J0cvoK8uS28YPc8QU14tV21/Na5B+o ew== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3nhqrte0sq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 06 Feb 2023 12:25:48 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 6 Feb 2023 12:25:46 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Mon, 6 Feb 2023 12:25:46 -0800 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 5E6F63F705B; Mon, 6 Feb 2023 12:25:43 -0800 (PST) From: To: , Srikanth Yalavarthi CC: , , , , , , Jerin Jacob Subject: [dpdk-dev] [PATCH v2 09/12] mldev: support device statistics Date: Tue, 7 Feb 2023 01:54:50 +0530 Message-ID: <20230206202453.336280-10-jerinj@marvell.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230206202453.336280-1-jerinj@marvell.com> References: <20221114120238.2143832-1-jerinj@marvell.com> <20230206202453.336280-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: zCZPfhVeSzfLFaZsMRVy-5KjowHC86UN X-Proofpoint-ORIG-GUID: zCZPfhVeSzfLFaZsMRVy-5KjowHC86UN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-06_07,2023-02-06_03,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 872e4e200a..bd65a44be5 100644 --- a/lib/mldev/rte_mldev.c +++ b/lib/mldev/rte_mldev.c @@ -357,6 +357,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)) { + RTE_MLDEV_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) { + RTE_MLDEV_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)) { + RTE_MLDEV_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, uint16_t *model_id) { diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h index b0144aaf0c..73eefc48c0 100644 --- a/lib/mldev/rte_mldev_core.h +++ b/lib/mldev/rte_mldev_core.h @@ -191,6 +191,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 * @@ -416,6 +442,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 b585b09ec1..58803722be 100644 --- a/lib/mldev/version.map +++ b/lib/mldev/version.map @@ -11,6 +11,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.39.1