From patchwork Sat Sep 14 07:13:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 144062 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 396364598A; Sat, 14 Sep 2024 09:23:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3F2542FCB; Sat, 14 Sep 2024 09:23:37 +0200 (CEST) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id D5D9A4026A for ; Sat, 14 Sep 2024 09:23:35 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4X5N1d1rQVz2CpVq; Sat, 14 Sep 2024 15:23:01 +0800 (CST) Received: from kwepemf500004.china.huawei.com (unknown [7.202.181.242]) by mail.maildlp.com (Postfix) with ESMTPS id 4413D1401F0; Sat, 14 Sep 2024 15:23:34 +0800 (CST) Received: from localhost.localdomain (10.28.79.22) by kwepemf500004.china.huawei.com (7.202.181.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 14 Sep 2024 15:23:33 +0800 From: Jie Hai To: , , , CC: , , Subject: [PATCH v7 1/8] ethdev: support report register names and filter Date: Sat, 14 Sep 2024 15:13:13 +0800 Message-ID: <20240914071320.1982-2-haijie1@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20240914071320.1982-1-haijie1@huawei.com> References: <20231214015650.3738578-1-haijie1@huawei.com> <20240914071320.1982-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemf500004.china.huawei.com (7.202.181.242) 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 This patch adds "filter" and "names" fields to "rte_dev_reg_info" structure. Names of registers in data fields can be reported and the registers can be filtered by their module names. The new API rte_eth_dev_get_reg_info_ext() is added to support reporting names and filtering by modules. And the original API rte_eth_dev_get_reg_info() does not use the names and filter fields. A local variable is used in rte_eth_dev_get_reg_info for compatibility. If the drivers does not report the names, set them to "index_XXX", which means the location in the register table. Signed-off-by: Jie Hai Acked-by: Huisong Li Acked-by: Chengwen Feng Reviewed-by: Ferruh Yigit --- doc/guides/rel_notes/release_24_11.rst | 9 ++++++ lib/ethdev/ethdev_trace.h | 2 ++ lib/ethdev/rte_dev_info.h | 11 ++++++++ lib/ethdev/rte_ethdev.c | 38 ++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 29 ++++++++++++++++++++ lib/ethdev/version.map | 3 ++ 6 files changed, 92 insertions(+) mode change 100644 => 100755 doc/guides/rel_notes/release_24_11.rst diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst old mode 100644 new mode 100755 index 0ff70d90578e..d53ab8fa5bc7 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support for dumping registers with names and filtering by modules.** + + Added new API functions ``rte_eth_dev_get_reg_info_ext()`` to filter the + registers by module names and get the information (names, values and other + attributes) of the filtered registers. + Removed Items ------------- @@ -100,6 +106,9 @@ ABI Changes Also, make sure to start the actual text at the margin. ======================================================= +* ethdev: Added ``filter`` and ``names`` fields to ``rte_dev_reg_info`` + structure for filtering by modules and reporting names of registers. + Known Issues ------------ diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h index 3bec87bfdb70..0c4780a09ef5 100644 --- a/lib/ethdev/ethdev_trace.h +++ b/lib/ethdev/ethdev_trace.h @@ -1152,6 +1152,8 @@ RTE_TRACE_POINT( rte_trace_point_emit_u32(info->length); rte_trace_point_emit_u32(info->width); rte_trace_point_emit_u32(info->version); + rte_trace_point_emit_ptr(info->names); + rte_trace_point_emit_ptr(info->filter); rte_trace_point_emit_int(ret); ) diff --git a/lib/ethdev/rte_dev_info.h b/lib/ethdev/rte_dev_info.h index 67cf0ae52668..26b777f9836e 100644 --- a/lib/ethdev/rte_dev_info.h +++ b/lib/ethdev/rte_dev_info.h @@ -11,6 +11,11 @@ extern "C" { #include +#define RTE_ETH_REG_NAME_SIZE 64 +struct rte_eth_reg_name { + char name[RTE_ETH_REG_NAME_SIZE]; +}; + /* * Placeholder for accessing device registers */ @@ -20,6 +25,12 @@ struct rte_dev_reg_info { uint32_t length; /**< Number of registers to fetch */ uint32_t width; /**< Size of device register */ uint32_t version; /**< Device version */ + /** + * Name of target module, filter for target subset of registers. + * This field could affects register selection for data/length/names. + */ + const char *filter; + struct rte_eth_reg_name *names; /**< Registers name saver */ }; /* diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index f1c658f49e80..30ca4a0043c5 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6388,8 +6388,37 @@ rte_eth_read_clock(uint16_t port_id, uint64_t *clock) int rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info) +{ + struct rte_dev_reg_info reg_info = { 0 }; + int ret; + + if (info == NULL) { + RTE_ETHDEV_LOG_LINE(ERR, + "Cannot get ethdev port %u register info to NULL", + port_id); + return -EINVAL; + } + + reg_info.length = info->length; + reg_info.data = info->data; + + ret = rte_eth_dev_get_reg_info_ext(port_id, ®_info); + if (ret != 0) + return ret; + + info->length = reg_info.length; + info->width = reg_info.width; + info->version = reg_info.version; + info->offset = reg_info.offset; + + return 0; +} + +int +rte_eth_dev_get_reg_info_ext(uint16_t port_id, struct rte_dev_reg_info *info) { struct rte_eth_dev *dev; + uint32_t i; int ret; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); @@ -6402,12 +6431,21 @@ rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info) return -EINVAL; } + if (info->names != NULL && info->length != 0) + memset(info->names, 0, sizeof(struct rte_eth_reg_name) * info->length); + if (*dev->dev_ops->get_reg == NULL) return -ENOTSUP; ret = eth_err(port_id, (*dev->dev_ops->get_reg)(dev, info)); rte_ethdev_trace_get_reg_info(port_id, info, ret); + /* Report the default names if drivers not report. */ + if (ret == 0 && info->names != NULL && strlen(info->names[0].name) == 0) { + for (i = 0; i < info->length; i++) + snprintf(info->names[i].name, RTE_ETH_REG_NAME_SIZE, + "index_%u", info->offset + i); + } return ret; } diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 548fada1c7ad..02cb3c07f742 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -5071,6 +5071,35 @@ __rte_experimental int rte_eth_get_monitor_addr(uint16_t port_id, uint16_t queue_id, struct rte_power_monitor_cond *pmc); +/** + * Retrieve the filtered device registers (values and names) and + * register attributes (number of registers and register size) + * + * @param port_id + * The port identifier of the Ethernet device. + * @param info + * Pointer to rte_dev_reg_info structure to fill in. + * - If info->filter is NULL, return info for all registers (seen as filter + * none). + * - If info->filter is not NULL, return error if the driver does not support + * filter. Fill the length field with filtered register number. + * - If info->data is NULL, the function fills in the width and length fields. + * - If info->data is not NULL, ethdev considers there are enough spaces to + * store the registers, and the values of registers with the filter string + * as the module name are put into the buffer pointed at by info->data. + * - If info->names is not NULL, drivers should fill it or the ethdev fills it + * with default names. + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-EINVAL) if bad parameter. + * - (-ENODEV) if *port_id* invalid. + * - (-EIO) if device is removed. + * - others depends on the specific operations implementation. + */ +__rte_experimental +int rte_eth_dev_get_reg_info_ext(uint16_t port_id, struct rte_dev_reg_info *info); + /** * Retrieve device registers and register attributes (number of registers and * register size) diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 1669055ca566..abc2ff5bb4d5 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -325,6 +325,9 @@ EXPERIMENTAL { rte_flow_template_table_resizable; rte_flow_template_table_resize; rte_flow_template_table_resize_complete; + + # added in 24.07 + rte_eth_dev_get_reg_info_ext; }; INTERNAL {