
Support roce_dfx_sta query Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com> --- ...-roce-Fix-array-out-of-bounds-access.patch | 110 ++++++++ ...l-roce-Support-to-print-u64-reg_data.patch | 198 ++++++++++++++ ...d-roce_dfx_sta-cmd-for-RoCE-DFX-stat.patch | 248 ++++++++++++++++++ hikptool.spec | 8 +- 4 files changed, 563 insertions(+), 1 deletion(-) create mode 100644 0100-hikptool-roce-Fix-array-out-of-bounds-access.patch create mode 100644 0101-hikptool-roce-Support-to-print-u64-reg_data.patch create mode 100644 0102-hikptool-roce-Add-roce_dfx_sta-cmd-for-RoCE-DFX-stat.patch diff --git a/0100-hikptool-roce-Fix-array-out-of-bounds-access.patch b/0100-hikptool-roce-Fix-array-out-of-bounds-access.patch new file mode 100644 index 0000000..9b02414 --- /dev/null +++ b/0100-hikptool-roce-Fix-array-out-of-bounds-access.patch @@ -0,0 +1,110 @@ +From e4888f49e7d72d23e72537849141901fa2227440 Mon Sep 17 00:00:00 2001 +From: wenglianfa <wenglianfa@huawei.com> +Date: Tue, 20 May 2025 20:37:22 +0800 +Subject: [PATCH 100/102] hikptool/roce: Fix array out-of-bounds access + +cur_block_num may be greater than reg data num. As +a result, out-of-bounds access to the reg_data.offset or +reg_data.data array may occur during memcpy(). + +Signed-off-by: wenglianfa <wenglianfa@huawei.com> +--- + net/roce/roce_ext_common/hikp_roce_ext_common.c | 10 ++++++++++ + net/roce/roce_scc/hikp_roce_scc.c | 10 ++++++---- + net/roce/roce_trp/hikp_roce_trp.c | 12 +++++++----- + 3 files changed, 23 insertions(+), 9 deletions(-) + +diff --git a/net/roce/roce_ext_common/hikp_roce_ext_common.c b/net/roce/roce_ext_common/hikp_roce_ext_common.c +index 9c844f4..fda2cf8 100644 +--- a/net/roce/roce_ext_common/hikp_roce_ext_common.c ++++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c +@@ -96,6 +96,7 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, + struct reg_data *reg = &output->reg; + struct hikp_cmd_ret *cmd_ret; + uint32_t remain_block; ++ size_t reg_data_size; + size_t cur_size; + int ret; + +@@ -144,6 +145,15 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, + } + + cur_size = res_head->cur_block_num * sizeof(uint32_t); ++ /*calculates the size of reg_data in the roce_ext_res_param structure.*/ ++ reg_data_size = cmd_ret->rsp_data_num * sizeof(uint32_t) - sizeof(struct roce_ext_head); ++ if (cur_size + reg_array_length * sizeof(uint32_t) > reg_data_size) { ++ printf("hikptool roce_%s cur size error, cur_size: %zu, reg_data_size: %zu.\n", ++ cmd_name, cur_size, reg_data_size); ++ ret = -EINVAL; ++ hikp_roce_ext_reg_data_free(reg); ++ goto get_data_error; ++ } + memcpy(reg->offset + block_id, + (uint32_t *)&roce_ext_res->reg_data, cur_size); + memcpy(reg->data + block_id, +diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c +index 67a2a1e..d8aee47 100644 +--- a/net/roce/roce_scc/hikp_roce_scc.c ++++ b/net/roce/roce_scc/hikp_roce_scc.c +@@ -169,9 +169,10 @@ static int hikp_roce_scc_get_total_data_num(struct roce_scc_head *res_head, + } + + cur_size = roce_scc_res->head.cur_block_num * sizeof(uint32_t); +- if (cur_size > max_size) { ++ if (cur_size > max_size || roce_scc_res->head.cur_block_num > ROCE_HIKP_SCC_REG_NUM) { + printf("hikptool roce_scc log data copy size error, " +- "data size: 0x%zx, max size: 0x%zx\n", cur_size, max_size); ++ "data size: 0x%zx, max size: 0x%zx, block_num: 0x%x\n", ++ cur_size, max_size, roce_scc_res->head.cur_block_num); + ret = -EINVAL; + goto get_data_error; + } +@@ -204,10 +205,11 @@ static int hikp_roce_scc_get_next_data(struct roce_scc_head *res_head, + + roce_scc_res = (struct roce_scc_res_param *)cmd_ret->rsp_data; + cur_size = roce_scc_res->head.cur_block_num * sizeof(uint32_t); +- if (cur_size > data_size) { ++ if (cur_size > data_size || roce_scc_res->head.cur_block_num > ROCE_HIKP_SCC_REG_NUM) { + hikp_cmd_free(&cmd_ret); + printf("hikptool roce_scc next log data copy size error, " +- "data size: 0x%zx, max size: 0x%zx\n", cur_size, data_size); ++ "data size: 0x%zx, max size: 0x%zx, block_num: 0x%x\n", ++ cur_size, data_size, roce_scc_res->head.cur_block_num); + return -EINVAL; + } + memcpy(*offset, roce_scc_res->reg_data.offset, cur_size); +diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c +index 67dfb8e..8b34409 100644 +--- a/net/roce/roce_trp/hikp_roce_trp.c ++++ b/net/roce/roce_trp/hikp_roce_trp.c +@@ -192,9 +192,10 @@ static int hikp_roce_trp_get_total_data_num(struct roce_trp_head *res_head, + } + + cur_size = roce_trp_res->head.cur_block_num * sizeof(uint32_t); +- if (cur_size > max_size) { ++ if (cur_size > max_size || roce_trp_res->head.cur_block_num > ROCE_HIKP_TRP_REG_NUM) { + printf("hikptool roce_trp log data copy size error, " +- "data size: 0x%zx, max size: 0x%zx\n", cur_size, max_size); ++ "data size: 0x%zx, max size: 0x%zx, block_num: 0x%x\n", ++ cur_size, max_size, roce_trp_res->head.cur_block_num); + hikp_roce_trp_reg_data_free(offset, data); + ret = -EINVAL; + goto get_data_error; +@@ -229,10 +230,11 @@ static int hikp_roce_trp_get_next_data(struct roce_trp_head *res_head, + roce_trp_res = (struct roce_trp_res_param *)cmd_ret->rsp_data; + cur_size = roce_trp_res->head.cur_block_num * sizeof(uint32_t); + +- if (cur_size > data_size) { +- hikp_cmd_free(&cmd_ret); ++ if (cur_size > data_size || roce_trp_res->head.cur_block_num > ROCE_HIKP_TRP_REG_NUM) { + printf("hikptool roce_trp next log data copy size error, " +- "data size: 0x%zx, max size: 0x%zx\n", cur_size, data_size); ++ "data size: 0x%zx, max size: 0x%zx, block_num: 0x%x\n", ++ cur_size, data_size, roce_trp_res->head.cur_block_num); ++ hikp_cmd_free(&cmd_ret); + return -EINVAL; + } + memcpy(*offset, roce_trp_res->reg_data.offset, cur_size); +-- +2.33.0 + diff --git a/0101-hikptool-roce-Support-to-print-u64-reg_data.patch b/0101-hikptool-roce-Support-to-print-u64-reg_data.patch new file mode 100644 index 0000000..1e09945 --- /dev/null +++ b/0101-hikptool-roce-Support-to-print-u64-reg_data.patch @@ -0,0 +1,198 @@ +From e680dee0da5cc54d3a71076ecb49f7de88feb62a Mon Sep 17 00:00:00 2001 +From: wenglianfa <wenglianfa@huawei.com> +Date: Thu, 3 Jul 2025 17:25:08 +0800 +Subject: [PATCH 101/102] hikptool/roce: Support to print u64 reg_data + +Support to print u64 reg_data. + +Signed-off-by: wenglianfa <wenglianfa@huawei.com> +--- + .../roce_ext_common/hikp_roce_ext_common.c | 61 +++++++++++++------ + .../roce_ext_common/hikp_roce_ext_common.h | 26 +++++++- + 2 files changed, 66 insertions(+), 21 deletions(-) + +diff --git a/net/roce/roce_ext_common/hikp_roce_ext_common.c b/net/roce/roce_ext_common/hikp_roce_ext_common.c +index fda2cf8..c225ec8 100644 +--- a/net/roce/roce_ext_common/hikp_roce_ext_common.c ++++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c +@@ -12,6 +12,7 @@ + */ + + #include "hikp_roce_ext_common.h" ++#include <stddef.h> + + static void hikp_roce_ext_reg_data_free(struct reg_data *reg) + { +@@ -95,9 +96,11 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, + struct roce_ext_res_param *roce_ext_res; + struct reg_data *reg = &output->reg; + struct hikp_cmd_ret *cmd_ret; ++ size_t reg_data_offset; + uint32_t remain_block; +- size_t reg_data_size; +- size_t cur_size; ++ size_t offset_size; ++ size_t data_size; ++ void *dst_data; + int ret; + + /* reg_array_length greater than or equal to 0 ensures that cmd_name +@@ -117,6 +120,7 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, + + if (block_id == 0) { + res_head->total_block_num = roce_ext_res->head.total_block_num; ++ res_head->flags = roce_ext_res->head.flags; + if (!res_head->total_block_num) { + printf("hikptool roce_%s total_block_num error!\n", + cmd_name); +@@ -124,10 +128,12 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, + goto get_data_error; + } + reg->offset = (uint32_t *)calloc(res_head->total_block_num, sizeof(uint32_t)); +- reg->data = (uint32_t *)calloc(res_head->total_block_num, sizeof(uint32_t)); ++ output->per_val_size = res_head->flags & ROCE_HIKP_DATA_U64_FLAG ? ++ sizeof(uint64_t) : sizeof(uint32_t); ++ reg->data = calloc(res_head->total_block_num, output->per_val_size); + if ((reg->offset == NULL) || (reg->data == NULL)) { +- printf("hikptool roce_%s alloc log memmory 0x%zx failed!\n", +- cmd_name, res_head->total_block_num * sizeof(uint32_t)); ++ printf("hikptool roce_%s alloc log memmory failed!\n", ++ cmd_name); + ret = -ENOMEM; + hikp_roce_ext_reg_data_free(reg); + goto get_data_error; +@@ -144,20 +150,32 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, + goto get_data_error; + } + +- cur_size = res_head->cur_block_num * sizeof(uint32_t); +- /*calculates the size of reg_data in the roce_ext_res_param structure.*/ +- reg_data_size = cmd_ret->rsp_data_num * sizeof(uint32_t) - sizeof(struct roce_ext_head); +- if (cur_size + reg_array_length * sizeof(uint32_t) > reg_data_size) { +- printf("hikptool roce_%s cur size error, cur_size: %zu, reg_data_size: %zu.\n", +- cmd_name, cur_size, reg_data_size); ++ /* ++ * The data structure `roce_ext_res_param_u64` returned by the ++ * firmware is 8-byte aligned, so the offset of the `reg_data` ++ * member needs to be adjusted accordingly. ++ */ ++ if (res_head->flags & ROCE_HIKP_DATA_U64_FLAG) ++ reg_data_offset = offsetof(struct roce_ext_res_param_u64, reg_data); ++ else ++ reg_data_offset = offsetof(struct roce_ext_res_param, reg_data); ++ ++ offset_size = res_head->cur_block_num * sizeof(uint32_t); ++ data_size = res_head->cur_block_num * output->per_val_size; ++ dst_data = reg->data_u32 + block_id * output->per_val_size / sizeof(uint32_t); ++ /* Avoid memcpy out-of-bounds. */ ++ if ((reg_data_offset + data_size) / sizeof(uint32_t) + reg_array_length > cmd_ret->rsp_data_num) { ++ printf("hikptool roce_%s cur size error, data_size: %zu, rsp_data_num: %u.\n", ++ cmd_name, data_size, cmd_ret->rsp_data_num); + ret = -EINVAL; + hikp_roce_ext_reg_data_free(reg); + goto get_data_error; + } + memcpy(reg->offset + block_id, +- (uint32_t *)&roce_ext_res->reg_data, cur_size); +- memcpy(reg->data + block_id, +- (uint32_t *)&roce_ext_res->reg_data + reg_array_length, cur_size); ++ (uint32_t *)&roce_ext_res->head + reg_data_offset / sizeof(uint32_t), ++ offset_size); ++ memcpy(dst_data, (uint32_t *)&roce_ext_res->head + reg_data_offset ++ / sizeof(uint32_t) + reg_array_length, data_size); + + get_data_error: + hikp_cmd_free(&cmd_ret); +@@ -172,15 +190,20 @@ static void hikp_roce_ext_print(enum roce_cmd_type cmd_type, + const char *cmd_name = get_cmd_name(cmd_type); + uint8_t arr_len = output->reg_name.arr_len; + uint32_t *offset = output->reg.offset; +- uint32_t *data = output->reg.data; ++ struct reg_data *reg = &output->reg; ++ const char *name; + uint32_t i; + + printf("**************%s INFO*************\n", cmd_name); + printf("%-40s[addr_offset] : reg_data\n", "reg_name"); +- for (i = 0; i < total_block_num; i++) +- printf("%-40s[0x%08X] : 0x%08X\n", +- i < arr_len ? reg_name[i] : "", +- offset[i], data[i]); ++ for (i = 0; i < total_block_num; i++) { ++ name = i < arr_len ? reg_name[i] : ""; ++ printf("%-40s[0x%08X] : ", name, offset[i]); ++ if (output->res_head.flags & ROCE_HIKP_DATA_U64_FLAG) ++ printf("0x%016lX\n", reg->data_u64[i]); ++ else ++ printf("0x%08X\n", reg->data_u32[i]); ++ } + printf("************************************\n"); + } + +diff --git a/net/roce/roce_ext_common/hikp_roce_ext_common.h b/net/roce/roce_ext_common/hikp_roce_ext_common.h +index 8568556..6f04024 100644 +--- a/net/roce/roce_ext_common/hikp_roce_ext_common.h ++++ b/net/roce/roce_ext_common/hikp_roce_ext_common.h +@@ -17,6 +17,7 @@ + #include "hikp_net_lib.h" + + #define ROCE_MAX_REG_NUM (NET_MAX_REQ_DATA_NUM - 1) ++#define ROCE_MAX_U64_REG_NUM 18 + + #define ROCE_HIKP_CAEP_REG_NUM_EXT ROCE_MAX_REG_NUM + #define ROCE_HIKP_GMV_REG_NUM_EXT ROCE_MAX_REG_NUM +@@ -30,11 +31,15 @@ + #define ROCE_HIKP_RST_REG_NUM ROCE_MAX_REG_NUM + #define ROCE_HIKP_GLOBAL_CFG_REG_NUM ROCE_MAX_REG_NUM + #define ROCE_HIKP_BOND_REG_NUM ROCE_MAX_REG_NUM ++#define ROCE_HIKP_DFX_STA_NUM_EXT ROCE_MAX_U64_REG_NUM ++ ++#define ROCE_HIKP_DATA_U64_FLAG 1 << 0 + + struct roce_ext_head { + uint8_t total_block_num; + uint8_t cur_block_num; +- uint16_t reserved; ++ uint8_t flags; ++ uint8_t reserved; + }; + + struct roce_ext_res_param { +@@ -42,9 +47,25 @@ struct roce_ext_res_param { + uint32_t reg_data[0]; + }; + ++struct roce_ext_res_data_u64 { ++ uint32_t offset[ROCE_MAX_U64_REG_NUM]; ++ uint64_t data[ROCE_MAX_U64_REG_NUM]; ++ uint32_t rsv[4]; ++}; ++ ++struct roce_ext_res_param_u64 { ++ struct roce_ext_head head; ++ uint32_t rsv; ++ struct roce_ext_res_data_u64 reg_data; ++}; ++ + struct reg_data { + uint32_t *offset; +- uint32_t *data; ++ union { ++ void *data; ++ uint32_t *data_u32; ++ uint64_t *data_u64; ++ }; + }; + + struct roce_ext_reg_name { +@@ -55,6 +76,7 @@ struct roce_ext_reg_name { + struct roce_ext_res_output { + struct roce_ext_head res_head; + struct reg_data reg; ++ uint32_t per_val_size; + struct roce_ext_reg_name reg_name; + }; + +-- +2.33.0 + diff --git a/0102-hikptool-roce-Add-roce_dfx_sta-cmd-for-RoCE-DFX-stat.patch b/0102-hikptool-roce-Add-roce_dfx_sta-cmd-for-RoCE-DFX-stat.patch new file mode 100644 index 0000000..1c2d9eb --- /dev/null +++ b/0102-hikptool-roce-Add-roce_dfx_sta-cmd-for-RoCE-DFX-stat.patch @@ -0,0 +1,248 @@ +From f704e9fc2d5d878e669b303ec8571e54c734e811 Mon Sep 17 00:00:00 2001 +From: wenglianfa <wenglianfa@huawei.com> +Date: Wed, 2 Jul 2025 11:46:15 +0800 +Subject: [PATCH 102/102] hikptool/roce: Add roce_dfx_sta cmd for RoCE DFX + statistics + +Add roce_dfx_sta cmd for RoCE DFX statistics. + +Example: +hikptool roce_dfx_sta -i eth1 + +Signed-off-by: wenglianfa <wenglianfa@huawei.com> +--- + info_collect/hikp_collect_roce.c | 22 ++++ + net/hikp_net_lib.h | 1 + + net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c | 107 ++++++++++++++++++ + net/roce/roce_dfx_sta/hikp_roce_dfx_sta.h | 33 ++++++ + .../roce_ext_common/hikp_roce_ext_common.c | 1 + + 5 files changed, 164 insertions(+) + create mode 100644 net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c + create mode 100644 net/roce/roce_dfx_sta/hikp_roce_dfx_sta.h + +diff --git a/info_collect/hikp_collect_roce.c b/info_collect/hikp_collect_roce.c +index baf2899..01d773b 100644 +--- a/info_collect/hikp_collect_roce.c ++++ b/info_collect/hikp_collect_roce.c +@@ -26,6 +26,7 @@ + #include "hikp_roce_tsp.h" + #include "hikp_roce_scc.h" + #include "hikp_roce_gmv.h" ++#include "hikp_roce_dfx_sta.h" + + static void collect_roce_devinfo_log(void) + { +@@ -125,6 +126,26 @@ static int collect_hikp_roce_gmv_log(void *nic_name) + return 0; + } + ++static int collect_hikp_roce_dfx_sta_log(void *nic_name) ++{ ++ struct major_cmd_ctrl self = {0}; ++ struct hikp_cmd_type type = {0}; ++ int ret; ++ ++ self.cmd_ptr = &type; ++ ret = hikp_roce_set_dfx_sta_bdf((char *)nic_name); ++ if (ret) { ++ HIKP_ERROR_PRINT("failed to set roce_dfx_sta bdf for %s.\n", ++ (char *)nic_name); ++ return ret; ++ } ++ ++ printf("hikptool roce_dfx_sta -i %s\n", (char *)nic_name); ++ hikp_roce_dfx_sta_execute(&self); ++ ++ return 0; ++} ++ + static int collect_hikp_roce_scc_log(void *nic_name) + { + struct major_cmd_ctrl self = {0}; +@@ -466,6 +487,7 @@ static int collect_one_roce_hikp_log(void *net_name) + { "roce_tsp", collect_hikp_roce_tsp_log }, + { "roce_scc", collect_hikp_roce_scc_log }, + { "roce_gmv", collect_hikp_roce_gmv_log }, ++ { "roce_dfx_sta", collect_hikp_roce_dfx_sta_log }, + }; + size_t i; + +diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h +index 7ebabfa..aa700ab 100644 +--- a/net/hikp_net_lib.h ++++ b/net/hikp_net_lib.h +@@ -103,6 +103,7 @@ enum roce_cmd_type { + GET_ROCEE_RST_CMD, + GET_ROCEE_GLOBAL_CFG_CMD, + GET_ROCEE_BOND_CMD, ++ GET_ROCEE_DFX_STA_CMD, + }; + + enum ub_cmd_type { +diff --git a/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c b/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c +new file mode 100644 +index 0000000..b74507c +--- /dev/null ++++ b/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c +@@ -0,0 +1,107 @@ ++/* ++ * 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_roce_dfx_sta.h" ++ ++static struct cmd_roce_dfx_sta_param_t g_roce_dfx_sta_param_t = { 0 }; ++ ++int hikp_roce_set_dfx_sta_bdf(char *nic_name) ++{ ++ return tool_check_and_get_valid_bdf_id(nic_name, ++ &g_roce_dfx_sta_param_t.target); ++} ++ ++static int hikp_roce_dfx_sta_help(struct major_cmd_ctrl *self, const char *argv) ++{ ++ HIKP_SET_USED(argv); ++ ++ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i <interface>\n"); ++ 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", "-i", "--interface=<interface>", "device target, e.g. eth0"); ++ printf(" %s, %-25s %s\n", "-c", "--clear=<clear>", "clear param count registers"); ++ printf("\n"); ++ ++ return 0; ++} ++ ++static int hikp_roce_dfx_sta_target(struct major_cmd_ctrl *self, const char *argv) ++{ ++ self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_roce_dfx_sta_param_t.target)); ++ if (self->err_no != 0) ++ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); ++ ++ return self->err_no; ++} ++ ++static int hikp_roce_dfx_sta_clear_set(struct major_cmd_ctrl *self, const char *argv) ++{ ++ HIKP_SET_USED(self); ++ HIKP_SET_USED(argv); ++ ++ g_roce_dfx_sta_param_t.reset_flag = 1; ++ return 0; ++} ++ ++/* DON'T change the order of this array or add entries between! */ ++static const char *g_dfx_sta_reg_name[] = { ++ "PKT_RNR_STA", ++ "PKT_RTY_STA", ++ "MSN_RTY_STA", ++}; ++ ++static int hikp_roce_dfx_sta_get_data(struct hikp_cmd_ret **cmd_ret, ++ uint32_t block_id, ++ struct roce_ext_reg_name *reg_name) ++{ ++ struct hikp_cmd_header req_header = { 0 }; ++ struct roce_dfx_sta_req_param req_data; ++ uint32_t req_size; ++ int ret; ++ ++ reg_name->reg_name = g_dfx_sta_reg_name; ++ reg_name->arr_len = HIKP_ARRAY_SIZE(g_dfx_sta_reg_name); ++ ++ req_data.reset_flag = g_roce_dfx_sta_param_t.reset_flag; ++ req_data.bdf = g_roce_dfx_sta_param_t.target.bdf; ++ req_data.block_id = block_id; ++ ++ req_size = sizeof(struct roce_dfx_sta_req_param); ++ hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_DFX_STA_CMD, 0); ++ *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, req_size); ++ ret = hikp_rsp_normal_check(*cmd_ret); ++ if (ret) ++ printf("hikptool roce_dfx_sta get cmd data failed, ret: %d\n", ret); ++ ++ return ret; ++} ++ ++void hikp_roce_dfx_sta_execute(struct major_cmd_ctrl *self) ++{ ++ hikp_roce_ext_execute(self, GET_ROCEE_DFX_STA_CMD, hikp_roce_dfx_sta_get_data); ++} ++ ++static void cmd_roce_dfx_sta_init(void) ++{ ++ struct major_cmd_ctrl *major_cmd = get_major_cmd(); ++ ++ major_cmd->option_count = 0; ++ major_cmd->execute = hikp_roce_dfx_sta_execute; ++ ++ cmd_option_register("-h", "--help", false, hikp_roce_dfx_sta_help); ++ cmd_option_register("-i", "--interface", true, hikp_roce_dfx_sta_target); ++ cmd_option_register("-c", "--clear", false, hikp_roce_dfx_sta_clear_set); ++} ++ ++HIKP_CMD_DECLARE("roce_dfx_sta", "get or clear RoCE dfx statistics", cmd_roce_dfx_sta_init); +diff --git a/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.h b/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.h +new file mode 100644 +index 0000000..b515356 +--- /dev/null ++++ b/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.h +@@ -0,0 +1,33 @@ ++/* ++ * 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_ROCE_DFX_STA_H ++#define HIKP_ROCE_DFX_STA_H ++ ++#include "hikp_roce_ext_common.h" ++ ++struct cmd_roce_dfx_sta_param_t { ++ uint8_t reset_flag; ++ struct tool_target target; ++}; ++ ++struct roce_dfx_sta_req_param { ++ struct bdf_t bdf; ++ uint32_t block_id; ++ uint8_t reset_flag; ++}; ++ ++int hikp_roce_set_dfx_sta_bdf(char *nic_name); ++void hikp_roce_dfx_sta_execute(struct major_cmd_ctrl *self); ++ ++#endif /* HIKP_ROCE_DFX_STA_H */ +diff --git a/net/roce/roce_ext_common/hikp_roce_ext_common.c b/net/roce/roce_ext_common/hikp_roce_ext_common.c +index c225ec8..ac6c8fb 100644 +--- a/net/roce/roce_ext_common/hikp_roce_ext_common.c ++++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c +@@ -44,6 +44,7 @@ static const struct cmd_type_info { + {GET_ROCEE_RST_CMD, "RST", ROCE_HIKP_RST_REG_NUM}, + {GET_ROCEE_GLOBAL_CFG_CMD, "GLOBAL_CFG", ROCE_HIKP_GLOBAL_CFG_REG_NUM}, + {GET_ROCEE_BOND_CMD, "BOND", ROCE_HIKP_BOND_REG_NUM}, ++ {GET_ROCEE_DFX_STA_CMD, "DFX_STA", ROCE_HIKP_DFX_STA_NUM_EXT}, + }; + + static int get_cmd_info_table_idx(enum roce_cmd_type cmd_type) +-- +2.33.0 + diff --git a/hikptool.spec b/hikptool.spec index c19df02..c6ea91f 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,9 @@ 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-The-cpu_ring-command-is-added.patch +Patch0100: 0100-hikptool-roce-Fix-array-out-of-bounds-access.patch +Patch0101: 0101-hikptool-roce-Support-to-print-u64-reg_data.patch +Patch0102: 0102-hikptool-roce-Add-roce_dfx_sta-cmd-for-RoCE-DFX-stat.patch %description This package contains the hikptool @@ -167,6 +170,9 @@ fi /sbin/ldconfig %changelog +* Fri Jul 25 2025 Junxian Huang <huangjunxian6@hisilicon.com> 1.0.0-19 +- Support roce_dfx_sta query + * Fri Jun 6 2025 veega2022 <zhuweijia@huawei.com> 1.0.0-18 - The cpu_ring command is added. -- 2.33.0