From patchwork Tue Feb 7 15:13:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerin Jacob Kollanukkaran X-Patchwork-Id: 123266 X-Patchwork-Delegate: thomas@monjalon.net 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 6289B41C30; Tue, 7 Feb 2023 16:14:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 423D742D42; Tue, 7 Feb 2023 16:14:13 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id E1CDB42D2D for ; Tue, 7 Feb 2023 16:14:10 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 317EbXhn006848; Tue, 7 Feb 2023 07:14: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=4MvW/Sx105QATfqHuYE/kqfIPjq4T0uGjHxJ644TeY4=; b=XBq6XkW0bXu6YTKzrzTNOc5Hn7ggoxfsShBfXkVThOesvBBGcC+bZR3TZE8uT8KfHNnZ umCVbu+1vfEo/L7JkcAQ6Rh+fwArbb2UAYsS78dINIIb7N8T3CpnHjnupua0I2+NvKhd 00VM8gK6qAD5iPEbckAq13ObBtTOiyI4ayR967iKcjN+pU5XNrUUIgtFinrGm13BwswZ w2hUwPEc9r4phgNf81MXbNBzHh+xUbMQjIRmq90YQdBjZpk8vioKnabqxHrQiZYVSsJP S/uishzhP9vNUAej4+pK4KoizQLx8VS/6han3jsDSWTw8Me2a5rNwPAbN6NViZc8Wang gw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3nkdyrsk4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 07 Feb 2023 07:14:09 -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.42; Tue, 7 Feb 2023 07:14: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.42 via Frontend Transport; Tue, 7 Feb 2023 07:14:08 -0800 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id B1F453F7082; Tue, 7 Feb 2023 07:14:05 -0800 (PST) From: To: , Srikanth Yalavarthi CC: , , , , , Jerin Jacob Subject: [dpdk-dev] [PATCH v3 10/12] mldev: support device extended statistics Date: Tue, 7 Feb 2023 20:43:14 +0530 Message-ID: <20230207151316.835441-11-jerinj@marvell.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207151316.835441-1-jerinj@marvell.com> References: <20230206202453.336280-1-jerinj@marvell.com> <20230207151316.835441-1-jerinj@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Jp8LN37Qu2Hd09c17bMvc_qSwdaKZykW X-Proofpoint-GUID: Jp8LN37Qu2Hd09c17bMvc_qSwdaKZykW 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-07_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 handle device extended stats. xstats supported are driver specific and can include stats specific to ML device or ML model and I/O. Added prototypes for functions to be called by the device drivers. Signed-off-by: Srikanth Yalavarthi Signed-off-by: Jerin Jacob --- lib/mldev/rte_mldev.c | 88 ++++++++++++++++++++++++++++++++++++ lib/mldev/rte_mldev_core.h | 93 ++++++++++++++++++++++++++++++++++++++ lib/mldev/version.map | 4 ++ 3 files changed, 185 insertions(+) diff --git a/lib/mldev/rte_mldev.c b/lib/mldev/rte_mldev.c index f096ed2bc3..f6c5282f39 100644 --- a/lib/mldev/rte_mldev.c +++ b/lib/mldev/rte_mldev.c @@ -439,6 +439,94 @@ rte_ml_dev_stats_reset(int16_t dev_id) (*dev->dev_ops->dev_stats_reset)(dev); } +int +rte_ml_dev_xstats_names_get(int16_t dev_id, struct rte_ml_dev_xstats_map *xstats_map, uint32_t size) +{ + 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_xstats_names_get == NULL) + return -ENOTSUP; + + return (*dev->dev_ops->dev_xstats_names_get)(dev, xstats_map, size); +} + +int +rte_ml_dev_xstats_by_name_get(int16_t dev_id, const char *name, uint16_t *stat_id, uint64_t *value) +{ + 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_xstats_by_name_get == NULL) + return -ENOTSUP; + + if (name == NULL) { + RTE_MLDEV_LOG(ERR, "Dev %d, name cannot be NULL\n", dev_id); + return -EINVAL; + } + + if (value == NULL) { + RTE_MLDEV_LOG(ERR, "Dev %d, value cannot be NULL\n", dev_id); + return -EINVAL; + } + + return (*dev->dev_ops->dev_xstats_by_name_get)(dev, name, stat_id, value); +} + +int +rte_ml_dev_xstats_get(int16_t dev_id, const uint16_t *stat_ids, uint64_t *values, uint16_t nb_ids) +{ + 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_xstats_get == NULL) + return -ENOTSUP; + + if (stat_ids == NULL) { + RTE_MLDEV_LOG(ERR, "Dev %d, stat_ids cannot be NULL\n", dev_id); + return -EINVAL; + } + + if (values == NULL) { + RTE_MLDEV_LOG(ERR, "Dev %d, values cannot be NULL\n", dev_id); + return -EINVAL; + } + + return (*dev->dev_ops->dev_xstats_get)(dev, stat_ids, values, nb_ids); +} + +int +rte_ml_dev_xstats_reset(int16_t dev_id, const uint16_t *stat_ids, uint16_t nb_ids) +{ + 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_xstats_reset == NULL) + return -ENOTSUP; + + return (*dev->dev_ops->dev_xstats_reset)(dev, stat_ids, nb_ids); +} + 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 7c9877731e..bc94420000 100644 --- a/lib/mldev/rte_mldev_core.h +++ b/lib/mldev/rte_mldev_core.h @@ -217,6 +217,87 @@ typedef int (*mldev_stats_get_t)(struct rte_ml_dev *dev, struct rte_ml_dev_stats */ typedef void (*mldev_stats_reset_t)(struct rte_ml_dev *dev); +/** + * @internal + * + * Function used to get names of extended stats. + * + * @param dev + * ML device pointer. + * @param xstats_map + * Array to insert id and names into. + * @param size + * Size of xstats_map array. + * + * @return + * - >= 0 and <= size on success. + * - > size, error. Returns the size of xstats_map array required. + * - < 0, error code on failure. + */ +typedef int (*mldev_xstats_names_get_t)(struct rte_ml_dev *dev, + struct rte_ml_dev_xstats_map *xstats_map, uint32_t size); + +/** + * @internal + * + * Function used to get a single extended stat by name. + * + * @param dev + * ML device pointer. + * @param name + * Name of the stat to retrieve. + * @param stat_id + * ID of the stat to be returned. + * @param value + * Value of the stat to be returned. + * + * @return + * - >= 0 stat value. + * - < 0, error code on failure. + */ +typedef int (*mldev_xstats_by_name_get_t)(struct rte_ml_dev *dev, const char *name, + uint16_t *stat_id, uint64_t *value); + +/** + * @internal + * + * Function used to retrieve extended stats of a device. + * + * @param dev + * ML device pointer. + * @param stat_ids + * Array of ID numbers of the stats to be retrieved. + * @param values + * Values of the stats requested by the ID. + * @param nb_ids + * Number of stats requested. + * + * @return + * - >= 0, number of entries filled into the values array. + * - < 0, error code on failure. + */ +typedef int (*mldev_xstats_get_t)(struct rte_ml_dev *dev, const uint16_t *stat_ids, + uint64_t *values, uint16_t nb_ids); + +/** + * @internal + * + * Function used to reset extended stats. + * + * @param dev + * ML device pointer. + * @param stat_ids + * Array of stats IDs to be reset. + * @param nb_ids + * Number of IDs in the stat_ids array. + * + * @return + * - 0 on success. + * - < 0, error code on failure. + */ +typedef int (*mldev_xstats_reset_t)(struct rte_ml_dev *dev, const uint16_t *stat_ids, + uint16_t nb_ids); + /** * @internal * @@ -448,6 +529,18 @@ struct rte_ml_dev_ops { /** Reset device statistics. */ mldev_stats_reset_t dev_stats_reset; + /** Get names of extended stats. */ + mldev_xstats_names_get_t dev_xstats_names_get; + + /** Get value of a single extended stat. */ + mldev_xstats_by_name_get_t dev_xstats_by_name_get; + + /** Get extended stats of a device. */ + mldev_xstats_get_t dev_xstats_get; + + /** Reset extended stats of the device. */ + mldev_xstats_reset_t dev_xstats_reset; + /** Load an ML model. */ mldev_model_load_t model_load; diff --git a/lib/mldev/version.map b/lib/mldev/version.map index 7c652f1f9b..1e7c1ab2b2 100644 --- a/lib/mldev/version.map +++ b/lib/mldev/version.map @@ -15,6 +15,10 @@ EXPERIMENTAL { rte_ml_dev_stats_get; rte_ml_dev_stats_reset; rte_ml_dev_stop; + rte_ml_dev_xstats_by_name_get; + rte_ml_dev_xstats_get; + rte_ml_dev_xstats_names_get; + rte_ml_dev_xstats_reset; rte_ml_enqueue_burst; rte_ml_io_dequantize; rte_ml_io_input_size_get;