代码拉取完成,页面将自动刷新
From 1bcb93fece24ffa688443716898e0150174bb005 Mon Sep 17 00:00:00 2001
From: veega2022 <zhuweijia@huawei.com>
Date: Wed, 7 May 2025 17:35:03 +0800
Subject: [PATCH] hikptool: The cpu_ring command is added.
Added the cpu_ring command for obtaining
the ring information of the CPU core.
Obtains the ring information of all chips
based on the -d parameter.
eg: hikptool cpu_ring -d
The information is displayed at the cluster granularity.
Signed-off-by: veega2022 <zhuweijia@huawei.com>
---
CMakeLists.txt | 1 +
core_ring/hikp_core_ring.c | 106 ++++++++++++++++++++++++++++
core_ring/hikp_core_ring.h | 42 +++++++++++
libhikptdev/include/hikptdev_plug.h | 1 +
tool_lib/tool_lib.h | 2 +-
5 files changed, 151 insertions(+), 1 deletion(-)
create mode 100644 core_ring/hikp_core_ring.c
create mode 100644 core_ring/hikp_core_ring.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d50e2ac..386cc28 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,6 +37,7 @@ endmacro()
option(ENABLE_STATIC "Make tool run as independently as possible" off)
file(GLOB_RECURSE HIKPTOOL_SRC
+ ${CMAKE_CURRENT_SOURCE_DIR}/core_ring/*.c
${CMAKE_CURRENT_SOURCE_DIR}/cxl/*.c
${CMAKE_CURRENT_SOURCE_DIR}/net/*.c
${CMAKE_CURRENT_SOURCE_DIR}/ossl/*.c
diff --git a/core_ring/hikp_core_ring.c b/core_ring/hikp_core_ring.c
new file mode 100644
index 0000000..1e8178f
--- /dev/null
+++ b/core_ring/hikp_core_ring.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2025 Hisilicon Technologies Co., Ltd.
+ * Hikptool is licensed under Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ * http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ *
+ * See the Mulan PSL v2 for more details.
+ */
+
+#include "hikp_core_ring.h"
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include "tool_cmd.h"
+#include "hikptdev_plug.h"
+
+static uint32_t g_cmd_param_mask = {0};
+
+static int hikp_core_ring_help(struct major_cmd_ctrl *self, const char *argv)
+{
+ HIKP_SET_USED(argv);
+
+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-d");
+ printf("\n %s\n", self->cmd_ptr->help_info);
+ printf(" Options:\n\n");
+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit");
+ printf(" %s, %-25s %s\n", "-d", "--dump", "dump the ring info of the cpu core");
+ printf("\n");
+
+ return 0;
+}
+
+static int hikp_core_ring_get_info(struct major_cmd_ctrl *self, const char *argv)
+{
+ HIKP_SET_USED(self);
+ HIKP_SET_USED(argv);
+
+ g_cmd_param_mask |= PARAM_DUMP_MASK;
+
+ return 0;
+}
+
+static void hikp_core_ring_print_info(const struct core_ring_info *ring_info)
+{
+ uint32_t cnt = 0;
+
+ for (uint32_t chip = 0; chip < ring_info->chip_num; chip++) {
+ printf("chip %u core ring:\n", chip);
+ for (uint32_t cluster = 0; cluster < ring_info->per_cluster_num; cluster++) {
+ if (cnt >= RING_DATA_MAX)
+ break;
+
+ printf("\tcluster%u ring info: 0x%" PRIx64 "\n",
+ cluster, ring_info->ring_data[cnt++]);
+ }
+ }
+}
+
+static void hikp_core_ring_dump(struct major_cmd_ctrl *self)
+{
+ struct hikp_cmd_header req_header = {0};
+ struct core_ring_req cmd_req = {0};
+ struct hikp_cmd_ret *cmd_ret;
+
+ hikp_cmd_init(&req_header, CORE_RING_MOD, CORE_RING_DUMP, RING_INFO_DUMP);
+ cmd_ret = hikp_cmd_alloc(&req_header, &cmd_req, sizeof(cmd_req));
+ self->err_no = hikp_rsp_normal_check(cmd_ret);
+ if (self->err_no != 0) {
+ snprintf(self->err_str, sizeof(self->err_str), "get core ring info failed.");
+ hikp_cmd_free(&cmd_ret);
+ return;
+ }
+
+ hikp_core_ring_print_info((struct core_ring_info *)cmd_ret->rsp_data);
+
+ hikp_cmd_free(&cmd_ret);
+}
+
+static void hikp_core_ring_cmd_execute(struct major_cmd_ctrl *self)
+{
+ if ((g_cmd_param_mask & PARAM_DUMP_MASK) == 0) {
+ snprintf(self->err_str, sizeof(self->err_str), "Need input -d param!");
+ self->err_no = -EINVAL;
+ return;
+ }
+
+ hikp_core_ring_dump(self);
+}
+
+static void cmd_core_ring_info_init(void)
+{
+ struct major_cmd_ctrl *major_cmd = get_major_cmd();
+
+ major_cmd->option_count = 0;
+ major_cmd->execute = hikp_core_ring_cmd_execute;
+
+ cmd_option_register("-h", "--help", false, hikp_core_ring_help);
+ cmd_option_register("-d", "--dump", false, hikp_core_ring_get_info);
+}
+
+HIKP_CMD_DECLARE("cpu_ring", "dump cpu core ring info.", cmd_core_ring_info_init);
diff --git a/core_ring/hikp_core_ring.h b/core_ring/hikp_core_ring.h
new file mode 100644
index 0000000..68f8261
--- /dev/null
+++ b/core_ring/hikp_core_ring.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Hisilicon Technologies Co., Ltd.
+ * Hikptool is licensed under Mulan PSL v2.
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
+ * You may obtain a copy of Mulan PSL v2 at:
+ * http://license.coscl.org.cn/MulanPSL2
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
+ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
+ *
+ * See the Mulan PSL v2 for more details.
+ */
+
+#ifndef HIKP_CORE_RING_H
+#define HIKP_CORE_RING_H
+#include <stdint.h>
+#include "tool_lib.h"
+
+#define PARAM_DUMP_MASK HI_BIT(0)
+
+enum core_ring_cmd_type {
+ CORE_RING_DUMP = 1,
+};
+
+enum core_ring_sub_cmd_type {
+ RING_INFO_DUMP = 1,
+};
+
+#define RING_DATA_MAX 29 /* A maximum of 240 bytes can be transmitted at a time. */
+struct core_ring_info {
+ uint8_t chip_num;
+ uint8_t per_cluster_num;
+ uint8_t rsv0[2];
+ uint32_t rsv1;
+ uint64_t ring_data[RING_DATA_MAX];
+};
+
+struct core_ring_req {
+ uint32_t cmd_flag; /* Reserved in the current version */
+};
+
+#endif /* HIKP_CORE_RING_H */
diff --git a/libhikptdev/include/hikptdev_plug.h b/libhikptdev/include/hikptdev_plug.h
index bb58496..ba9931f 100644
--- a/libhikptdev/include/hikptdev_plug.h
+++ b/libhikptdev/include/hikptdev_plug.h
@@ -46,6 +46,7 @@ enum cmd_module_type {
UB_MOD = 11,
HCCS_MOD = 16,
SDMA_MOD = 17,
+ CORE_RING_MOD = 18,
RAS_MOD = 19
};
diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h
index d4493d7..d4accf1 100644
--- a/tool_lib/tool_lib.h
+++ b/tool_lib/tool_lib.h
@@ -18,7 +18,7 @@
#define TOOL_NAME "hikptool"
-#define TOOL_VER "1.1.4"
+#define TOOL_VER "1.1.5"
#define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask))
#define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift))
--
2.45.0.windows.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。