From patchwork Mon Nov 14 12:02:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerin Jacob Kollanukkaran X-Patchwork-Id: 119832 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 56029A00C4; Mon, 14 Nov 2022 13:09:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3FE7541101; Mon, 14 Nov 2022 13:09:56 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 5C29840150 for ; Mon, 14 Nov 2022 13:09:54 +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 2AE6hJAw008852; Mon, 14 Nov 2022 04:07:36 -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=YebgTGJePHS1jk8jLLtilR/+eIuTbZf77n+JieZxy04=; b=KyMtCDyFuLxvey7v9q6EfUH+lMf8HkTX2KdfGx9xKsS4IUYDQnHVoEtyJd1fQVGAKsZ5 gF/VkAVgbFaXhT2SPg7iL95YrGZpz1m/ypuRx7TE4wwoHd2PgcRG7013bjpBBlsyGzuv JxlLLgi+DrClc0T1X+ZZNt3a2ySdnR1mEIFxb0Wlz9LlvkKr7DDudfmbm58yRVPNe1Pt oAtPymd3ys+OH6mmm8Lf/83Zz5pr/m8wXS4DP2wUiNHD4kv/lHmKa3HxEec9b1Q+pFwB X4DcQA55wcuSOMCltogDvea1bYCXFM+2rOEPpSCChYBqq7mHfh2VTwMpC8kT1FE34KMK KA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3kugnb0x1j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 14 Nov 2022 04:07:36 -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:33 -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:33 -0800 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 700EA5C68E6; Mon, 14 Nov 2022 04:07:08 -0800 (PST) From: To: , Srikanth Yalavarthi CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jerin Jacob Subject: [dpdk-dev] [PATCH v1 10/12] mldev: support device extended statistics Date: Mon, 14 Nov 2022 17:32:36 +0530 Message-ID: <20221114120238.2143832-11-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 X-Proofpoint-ORIG-GUID: SLRMGjs9EGc-yBsxT1-NlO_o-QeqADbv X-Proofpoint-GUID: SLRMGjs9EGc-yBsxT1-NlO_o-QeqADbv 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 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 41b2a0be84..cdd68e933c 100644 --- a/lib/mldev/rte_mldev.c +++ b/lib/mldev/rte_mldev.c @@ -395,6 +395,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)) { + 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_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)) { + 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_xstats_by_name_get == NULL) + return -ENOTSUP; + + if (name == NULL) { + ML_DEV_LOG(ERR, "Dev %d, name cannot be NULL\n", dev_id); + return -EINVAL; + } + + if (value == NULL) { + ML_DEV_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)) { + 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_xstats_get == NULL) + return -ENOTSUP; + + if (stat_ids == NULL) { + ML_DEV_LOG(ERR, "Dev %d, stat_ids cannot be NULL\n", dev_id); + return -EINVAL; + } + + if (values == NULL) { + ML_DEV_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)) { + 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_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, int16_t *model_id) { diff --git a/lib/mldev/rte_mldev_core.h b/lib/mldev/rte_mldev_core.h index 3f05ecd9c6..82e8ed0422 100644 --- a/lib/mldev/rte_mldev_core.h +++ b/lib/mldev/rte_mldev_core.h @@ -221,6 +221,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 * @@ -452,6 +533,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 d12263010b..02d2eab100 100644 --- a/lib/mldev/version.map +++ b/lib/mldev/version.map @@ -13,6 +13,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;