diff --git a/0100-hikptool-The-cpu_ring-command-is-added.patch b/0100-hikptool-The-cpu_ring-command-is-added.patch new file mode 100644 index 0000000000000000000000000000000000000000..e82989f8dc5698cf037772ca4938dabc192fbaf4 --- /dev/null +++ b/0100-hikptool-The-cpu_ring-command-is-added.patch @@ -0,0 +1,225 @@ +From 1bcb93fece24ffa688443716898e0150174bb005 Mon Sep 17 00:00:00 2001 +From: veega2022 +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 +--- + 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 ++#include ++#include ++#include ++#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 ++#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 + diff --git a/hikptool.spec b/hikptool.spec index ecdf999d66bd88736dcae31eae63dbc7af0397c0..7d05b8cb90cbe4caf8e260b943dd25727f03f23d 100644 --- a/hikptool.spec +++ b/hikptool.spec @@ -3,7 +3,7 @@ Name: hikptool Summary: A userspace tool for Linux providing problem location on Kunpeng chips Version: 1.0.0 -Release: 18 +Release: 19 License: MulanPSL2 Source: %{name}-%{version}.tar.gz ExclusiveOS: linux @@ -115,6 +115,7 @@ Patch0096: 0096-Hikptool-add-support-dump-SDMA-register-information-.patch Patch0097: 0097-Add-support-collect-sdma-hikptool-dump-reg-info.patch Patch0098: 0098-hikptool-Update-the-tool-version-number-to-1.1.4.patch Patch0099: 0099-hikptool-ras-Add-support-for-exporting-black-box-dat.patch +Patch0100: 0100-hikptool-The-cpu_ring-command-is-added.patch %description This package contains the hikptool @@ -167,6 +168,9 @@ fi /sbin/ldconfig %changelog +* Fri May 9 2025 veega2022 1.0.0-19 +- The cpu_ring command is added. + * Fri Apr 18 2025 Bing Xia 1.0.0-18 - hikptool: ras: Add support for exporting black box data to file.