diff --git a/0001-socip-Return-EINVAL-when-the-parameter-check-fails.patch b/0001-socip-Return-EINVAL-when-the-parameter-check-fails.patch deleted file mode 100644 index 112cf62b7fd78feb5edbfbced61c56350354ec84..0000000000000000000000000000000000000000 --- a/0001-socip-Return-EINVAL-when-the-parameter-check-fails.patch +++ /dev/null @@ -1,35 +0,0 @@ -From b70d76d5c20b3fb32e01986568c695da5879106b Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Sat, 10 Dec 2022 18:07:54 +0800 -Subject: [PATCH] socip: Return -EINVAL when the parameter check fails - -Return -EINVAL when the parameter check fails - -Signed-off-by: fangjian ---- - socip/hikp_socip_dumpreg.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/socip/hikp_socip_dumpreg.c b/socip/hikp_socip_dumpreg.c -index 088f5dd..b74dac8 100644 ---- a/socip/hikp_socip_dumpreg.c -+++ b/socip/hikp_socip_dumpreg.c -@@ -131,6 +131,7 @@ static void hikp_socip_dumpreg_execute(struct major_cmd_ctrl *self) - struct hikp_cmd_ret *cmd_ret; - - if (!check_socip_dumpreg_param()) { -+ self->err_no = -EINVAL; - cmd_socip_dump_help(self, NULL); - return; - } -@@ -141,6 +142,7 @@ static void hikp_socip_dumpreg_execute(struct major_cmd_ctrl *self) - hikp_cmd_init(&req_header, SOCIP_MOD, HIKP_SOCIP_CMD_DUMPREG, param[MODULE_ID_INDEX].val); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (!cmd_ret) { -+ self->err_no=-EINVAL; - HIKP_ERROR_PRINT("hikp_cmd_alloc\n"); - return; - } --- -2.33.0 - diff --git a/0002-fix-compiler-security-option-problem.patch b/0002-fix-compiler-security-option-problem.patch deleted file mode 100644 index 6a96cfdbebebc1450a9b7084088272125f55b009..0000000000000000000000000000000000000000 --- a/0002-fix-compiler-security-option-problem.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0a4e7eb4cb35e126e9ca6e8e1f8f4282a008d0d2 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Tue, 13 Dec 2022 21:32:52 +0800 -Subject: [PATCH] fix compiler security option problem - -add compiler option -pie -fPIE, -Wl,-z,relro,-z,now -and disable rpath - -Signed-off-by: veega2022 ---- - CMakeLists.txt | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 1d79a31..c697edf 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -11,6 +11,9 @@ - - project(hikptool C) - -+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -pie -fPIE -Wall") -+set(CMAKE_SKIP_RPATH TRUE) -+ - macro(get_header_dir_recurse HEADER_DIR_LIST) - file(GLOB_RECURSE HEADER_LIST *.h) - set(DIR_LIST "") -@@ -40,5 +43,7 @@ get_header_dir_recurse(HIKPTOOL_HEADER_DIR) - target_include_directories(hikptool PRIVATE ${HIKPTOOL_HEADER_DIR}) - target_link_directories(hikptool PRIVATE ${CMAKE_INSTALL_PREFIX}/lib) - target_link_libraries(hikptool PRIVATE KPTDEV_SO) --target_link_options(hikptool PRIVATE -g -lpthread -ldl -lm -lrt -T ${CMAKE_CURRENT_SOURCE_DIR}/hikp_register.ld) -+target_link_options(hikptool PRIVATE -+ -Wl,-z,relro,-z,now -Wl,-z,noexecstack -+ -g -lpthread -ldl -lm -lrt -T ${CMAKE_CURRENT_SOURCE_DIR}/hikp_register.ld) - install(TARGETS hikptool RUNTIME DESTINATION bin OPTIONAL) --- -2.33.0 - diff --git a/0003-fix-the-security-compilation-PIE-issue.patch b/0003-fix-the-security-compilation-PIE-issue.patch deleted file mode 100644 index 00e9ec8236b8dde5b413f74c326826f727267171..0000000000000000000000000000000000000000 --- a/0003-fix-the-security-compilation-PIE-issue.patch +++ /dev/null @@ -1,51 +0,0 @@ -From bac5c53adcb43f4bbba6f436c98d6451d55c80ad Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 15 Mar 2023 08:28:37 +0000 -Subject: [PATCH] fix the security compilation PIE issue - -add link options "-fPIE -pie", because the -T link is used, the pie becomes -invalid.Therefore,change the ld file PROVIDE address to 0. - -Signed-off-by: veega2022 ---- - CMakeLists.txt | 4 ++-- - hikp_register.ld | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 0ba7370..6a396e7 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -11,7 +11,7 @@ - - project(hikptool C) - --set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -pie -fPIE -Wall") -+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -fPIC -fPIE -Wall") - set(CMAKE_SKIP_RPATH TRUE) - - macro(get_header_dir_recurse HEADER_DIR_LIST) -@@ -44,6 +44,6 @@ target_include_directories(hikptool PRIVATE ${HIKPTOOL_HEADER_DIR}) - target_link_directories(hikptool PRIVATE ${CMAKE_INSTALL_PREFIX}/lib) - target_link_libraries(hikptool PRIVATE KPTDEV_SO) - target_link_options(hikptool PRIVATE -- -Wl,-z,relro,-z,now -Wl,-z,noexecstack -+ -Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIE -pie - -g -lpthread -ldl -lm -lrt -T ${CMAKE_CURRENT_SOURCE_DIR}/hikp_register.ld) - install(TARGETS hikptool RUNTIME DESTINATION bin OPTIONAL) -diff --git a/hikp_register.ld b/hikp_register.ld -index b1bec44..3bd44ff 100644 ---- a/hikp_register.ld -+++ b/hikp_register.ld -@@ -11,7 +11,7 @@ SEARCH_DIR("=/usr/aarch64-Huawei-linux/lib64"); SEARCH_DIR("=/usr/lib64"); SEARC - SECTIONS - { - /* Read-only sections, merged into text segment: */ -- PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS; -+ PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x0)); . = SEGMENT_START("text-segment", 0x0) + SIZEOF_HEADERS; - .interp : { *(.interp) } - .note.gnu.build-id : { *(.note.gnu.build-id) } - .hash : { *(.hash) } --- -2.25.1 - diff --git a/0004-hikptool-fix-print-sas_dev-info-error-problem.patch b/0004-hikptool-fix-print-sas_dev-info-error-problem.patch deleted file mode 100644 index 19509e68a313502b238a86af690b6f39e9c398d1..0000000000000000000000000000000000000000 --- a/0004-hikptool-fix-print-sas_dev-info-error-problem.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 1a4f58e149d14146d399878418bdba9dc824e0a6 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 6 Apr 2023 11:33:14 +0000 -Subject: [PATCH] hikptool: fix print sas_dev info error problem - -the volatile modifier is added because the O2 compilation optimization is enbaled. -As a result, the pointer data is not updated. - -Signed-off-by: veega2022 ---- - sas/sas_func/sas_read_dev.c | 2 +- - tool_lib/tool_lib.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/sas/sas_func/sas_read_dev.c b/sas/sas_func/sas_read_dev.c -index 382a1ef..d01f95f 100644 ---- a/sas/sas_func/sas_read_dev.c -+++ b/sas/sas_func/sas_read_dev.c -@@ -77,7 +77,7 @@ static void print_dev_link(const uint32_t *reg_save, uint32_t reg_num) - - static void print_dev_info(const void *reg_save, uint32_t reg_num) - { -- struct hikp_sas_itct *itct = (struct hikp_sas_itct *)reg_save; -+ volatile struct hikp_sas_itct *itct = (volatile struct hikp_sas_itct *)reg_save; - - printf("The device information as below:\n"); - printf("dev_type: %d\n", itct->dw0.dev_type); -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index 29e7e8c..b211175 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.0.12" -+#define TOOL_VER "1.0.13" - - #define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask)) - #define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift)) --- -2.25.1 - diff --git a/0005-fix-hikptool-rciep-rsp-filed-error-problem.patch b/0005-fix-hikptool-rciep-rsp-filed-error-problem.patch deleted file mode 100644 index 4729653aadaf9da2b94a4045f3f65ac3be53f068..0000000000000000000000000000000000000000 --- a/0005-fix-hikptool-rciep-rsp-filed-error-problem.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 436ab65e026ae1260b7e7cab905a23096bf7e1e5 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 10 May 2023 17:39:59 +0800 -Subject: [PATCH 01/18] fix hikptool rciep rsp filed error problem - -union hikp_space_rsp 0xF8h is reserved and 0xFCh is cpl_status - -Signed-off-by: hesiyuan ---- - libhikptdev/src/rciep/hikpt_rciep.c | 2 +- - libhikptdev/src/rciep/hikpt_rciep.h | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/libhikptdev/src/rciep/hikpt_rciep.c b/libhikptdev/src/rciep/hikpt_rciep.c -index 9b7a82a..5c7e82f 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.c -+++ b/libhikptdev/src/rciep/hikpt_rciep.c -@@ -97,7 +97,7 @@ static uint32_t hikp_wait_for_cpl_status(void) - uint32_t status; - - do { -- status = g_hikp_req->field.cpl_status; -+ status = g_hikp_rsp->field.cpl_status; - if (status != HIKP_INIT_STAT) - return status; - count--; -diff --git a/libhikptdev/src/rciep/hikpt_rciep.h b/libhikptdev/src/rciep/hikpt_rciep.h -index 093724a..8fbb3c0 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.h -+++ b/libhikptdev/src/rciep/hikpt_rciep.h -@@ -75,8 +75,8 @@ union hikp_space_rsp { - uint32_t version; /* 000h */ - uint32_t rsp_para_num; /* 004h */ - uint32_t data[HIKP_RSP_DATA_MAX]; /* 008h */ -- uint32_t cpl_status; /* 0F8h */ -- uint32_t pid_record; /* 0FCh */ -+ uint32_t rsv; /* 0F8h */ -+ uint32_t cpl_status; /* 0FCh */ - struct iep_doorbell sw_db; /* 100h. Fixed and unmodifiable */ - } field; - --- -2.25.1 - diff --git a/0006-fix-pcie_info-cmd-print-display-problem.patch b/0006-fix-pcie_info-cmd-print-display-problem.patch deleted file mode 100644 index 3de81ad3a2caad290101043cb1514eb684b902dc..0000000000000000000000000000000000000000 --- a/0006-fix-pcie_info-cmd-print-display-problem.patch +++ /dev/null @@ -1,37 +0,0 @@ -From befc663ba761c1b334b50de138e57e2a00be4f32 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 10 May 2023 17:54:59 +0800 -Subject: [PATCH 02/18] fix pcie_info cmd print display problem - -The spelling of WITDH is incorrect. Change it to WIDTH. - -Signed-off-by: hesiyuan ---- - pcie/func_lib/pcie_func/pcie_statistics.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c -index f12660d..308a142 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.c -+++ b/pcie/func_lib/pcie_func/pcie_statistics.c -@@ -22,7 +22,7 @@ - #include "pcie_statistics.h" - - static const char *g_global_width_name[GLOBAL_WIDTH_TABLE_SIZE] = { -- "PCIE_WITDH_X1", "PCIE_WITDH_X2", "PCIE_WITDH_X4", "PCIE_WITDH_X8", "PCIE_WITDH_X16" -+ "PCIE_WIDTH_X1", "PCIE_WIDTH_X2", "PCIE_WIDTH_X4", "PCIE_WIDTH_X8", "PCIE_WIDTH_X16" - }; - - static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, uint32_t *port_num) -@@ -81,7 +81,7 @@ int pcie_port_distribution_get(uint32_t chip_id) - for (i = 0; i < pair_num; i++) { - if (port_info->info_pair[i].port_width >= HIKP_ARRAY_SIZE(g_global_width_name)) { - Info("PCIe Base", "port_id[%u] %s\n", port_info->info_pair[i].port_id, -- "UNKNOWN_WITDH"); -+ "UNKNOWN_WIDTH"); - continue; - } - Info("PCIe Base", "port_id[%u] %s\n", port_info->info_pair[i].port_id, --- -2.25.1 - diff --git a/0007-fix-signal-proc-func-api-modified-to-be-open-to-the-.patch b/0007-fix-signal-proc-func-api-modified-to-be-open-to-the-.patch deleted file mode 100644 index 582149a82976b7f8d094b01cf0021dc42c59d597..0000000000000000000000000000000000000000 --- a/0007-fix-signal-proc-func-api-modified-to-be-open-to-the-.patch +++ /dev/null @@ -1,123 +0,0 @@ -From e649f6245f73b99e5c2501f789a3b363c2a25554 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 10 May 2023 18:05:01 +0800 -Subject: [PATCH 03/18] fix signal proc func api modified to be open to the - public - -move sig_init api to op_logs public header file - -Signed-off-by: wangkang ---- - hikp_init_main.c | 20 -------------------- - libhikptdev/src/rciep/hikpt_rciep.h | 2 +- - tool_lib/op_logs.c | 23 ++++++++++++++++++++++- - tool_lib/op_logs.h | 3 ++- - 4 files changed, 25 insertions(+), 23 deletions(-) - -diff --git a/hikp_init_main.c b/hikp_init_main.c -index 4102c69..4629b40 100644 ---- a/hikp_init_main.c -+++ b/hikp_init_main.c -@@ -19,26 +19,6 @@ - /* hikptool command adapter */ - struct cmd_adapter g_tool = { 0 }; - --static void _sig_ign_handle(int arg) --{ -- signal_op_log_write(arg); -- hikp_unlock(); -- _exit(1); --} -- --static void sig_init(void) --{ -- (void)signal(SIGINT, _sig_ign_handle); /* Quit process */ -- (void)signal(SIGTERM, _sig_ign_handle); -- (void)signal(SIGQUIT, _sig_ign_handle); -- (void)signal(SIGHUP, _sig_ign_handle); -- (void)signal(SIGSEGV, _sig_ign_handle); -- (void)signal(SIGBUS, _sig_ign_handle); -- (void)signal(SIGFPE, _sig_ign_handle); -- (void)signal(SIGABRT, _sig_ign_handle); -- (void)signal(SIGTSTP, _sig_ign_handle); /* Stop process */ --} -- - static void show_tool_version(const struct cmd_adapter *adapter) - { - printf("%s version %s Huawei\n", adapter->name, adapter->version); -diff --git a/libhikptdev/src/rciep/hikpt_rciep.h b/libhikptdev/src/rciep/hikpt_rciep.h -index 8fbb3c0..dd08759 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.h -+++ b/libhikptdev/src/rciep/hikpt_rciep.h -@@ -40,7 +40,7 @@ - #define MAX_LOCK_COUNT 5 - #define LOCK_CHECK_GAP_US 1000 - #define CPL_CHECK_GAP_US 1000 --#define WAIT_CPL_MAX_MS 5000 -+#define WAIT_CPL_MAX_MS 8000 - - enum { - HIKP_RESOURCE_DIR, -diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c -index d6082a3..069428d 100644 ---- a/tool_lib/op_logs.c -+++ b/tool_lib/op_logs.c -@@ -14,7 +14,9 @@ - #include - #include - #include -+#include - #include "tool_lib.h" -+#include "hikptdev_plug.h" - #include "op_logs.h" - - static char g_op_log[OP_LOG_FILE_PATH_MAXLEN] = {0}; -@@ -23,7 +25,6 @@ static bool g_record = true; - static bool g_log_info; - static char g_input_buf[OP_LOG_FILE_W_MAXSIZE + 1] = {0}; - -- - static void op_log_write(const char *log_data) - { - size_t w_size; -@@ -414,3 +415,23 @@ SIGNAL_LOG_OUT: - (void)close(fd); - (void)uda_unfcntl(&op_log_fd, UDA_FLOCK_BLOCK); - } -+ -+static void signal_handle(int arg) -+{ -+ signal_op_log_write(arg); -+ hikp_unlock(); -+ _exit(1); -+} -+ -+void sig_init(void) -+{ -+ (void)signal(SIGINT, signal_handle); /* Quit process */ -+ (void)signal(SIGTERM, signal_handle); -+ (void)signal(SIGQUIT, signal_handle); -+ (void)signal(SIGHUP, signal_handle); -+ (void)signal(SIGSEGV, signal_handle); -+ (void)signal(SIGBUS, signal_handle); -+ (void)signal(SIGFPE, signal_handle); -+ (void)signal(SIGABRT, signal_handle); -+ (void)signal(SIGTSTP, signal_handle); /* Stop process */ -+} -diff --git a/tool_lib/op_logs.h b/tool_lib/op_logs.h -index 597f063..6b6e421 100644 ---- a/tool_lib/op_logs.h -+++ b/tool_lib/op_logs.h -@@ -45,7 +45,8 @@ struct op_log_print_t { - char *str; - }; - --void signal_op_log_write(int signal_code); -+void sig_init(void); -+ - void op_log_on(void); - void op_log_off(void); - int op_log_initialise(const char *log_dir); --- -2.25.1 - diff --git a/0008-delete-pcie-AP_INT-module-for-dump-reg.patch b/0008-delete-pcie-AP_INT-module-for-dump-reg.patch deleted file mode 100644 index b0a94bec6a4fd692811292ec25799b96821fff5e..0000000000000000000000000000000000000000 --- a/0008-delete-pcie-AP_INT-module-for-dump-reg.patch +++ /dev/null @@ -1,28 +0,0 @@ -From b369c7bf28b576097b46470d509ac61116872958 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 10 May 2023 18:09:55 +0800 -Subject: [PATCH 04/18] delete pcie AP_INT module for dump reg - -the AP_INT module is abandoned, so deleted this module and do not dump -this module reg - -Signed-off-by: hesiyuan ---- - pcie/func_lib/pcie_func/pcie_reg_read.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_reg_read.c b/pcie/func_lib/pcie_func/pcie_reg_read.c -index 6ba4f07..b3d4643 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_read.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_read.c -@@ -30,7 +30,6 @@ static struct pcie_module_table g_module_table[] = { - {"PCIPC_REG", PCIPC_REG_ID}, - {"AP_MCTP_REG", AP_MCTP_REG_ID}, - {"AP_ENGINE_REG", AP_ENGINE_REG_ID}, -- {"AP_INT_REG", AP_INT_REG_ID}, - {"AP_DMA_REG", AP_DMA_REG_ID}, - {"TOP_REG", TOP_REG_ID}, - {"CORE_GLOBAL_REG", CORE_GLOBAL_REG_ID}, --- -2.25.1 - diff --git a/0009-fix-serdes-module-dump-reg-num-is-not-enough-problem.patch b/0009-fix-serdes-module-dump-reg-num-is-not-enough-problem.patch deleted file mode 100644 index 09917b74f3ad50939036775ae6b062ce2e36890e..0000000000000000000000000000000000000000 --- a/0009-fix-serdes-module-dump-reg-num-is-not-enough-problem.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 2b679f7b8023298c3942b424545a4eff8aebe683 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 10 May 2023 18:14:50 +0800 -Subject: [PATCH 05/18] fix serdes module dump reg num is not enough problem - -The number of new chip registers may increase. Therefore, increase the number of dump registers. - -Signed-off-by: wangkang ---- - serdes/hikp_serdes.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c -index 89e66e1..dd9eee3 100644 ---- a/serdes/hikp_serdes.c -+++ b/serdes/hikp_serdes.c -@@ -23,7 +23,7 @@ - - static struct cmd_serdes_param g_serdes_param = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - --#define SERDES_OUTPUT_MAX_SIZE 2048 -+#define SERDES_OUTPUT_MAX_SIZE 2560 - static char g_serdes_data_out_buf[SERDES_OUTPUT_MAX_SIZE] = {0}; - - static int cmd_serdes_maininfo_help(struct major_cmd_ctrl *self, const char *argv) --- -2.25.1 - diff --git a/0010-fix-the-number-of-PCS-lane-registers-in-the-PCIe-dum.patch b/0010-fix-the-number-of-PCS-lane-registers-in-the-PCIe-dum.patch deleted file mode 100644 index 6947fef86bd88fbc1ca4db886e94865aa2b46c27..0000000000000000000000000000000000000000 --- a/0010-fix-the-number-of-PCS-lane-registers-in-the-PCIe-dum.patch +++ /dev/null @@ -1,125 +0,0 @@ -From 104dce7743c31c73a54095844d704272fa14de69 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 10 May 2023 18:20:58 +0800 -Subject: [PATCH 06/18] fix the number of PCS lane registers in the PCIe - dumpreg - -Traverse the PCS registers of all lanes under the current core. - -Signed-off-by: hesiyuan ---- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 36 +++++++++++------------- - pcie/func_lib/pcie_func/pcie_reg_dump.h | 10 +++++++ - pcie/usr_cmd/interface/pcie_common_api.h | 4 +++ - 3 files changed, 31 insertions(+), 19 deletions(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index 7d91969..e10ff7e 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -108,13 +108,13 @@ struct pcie_dumpreg_info g_reg_table_mac[] = { - }; - - struct pcie_dumpreg_info g_reg_table_pcs[] = { -- {0, "SERDES_STATUS_RPT"}, -- {0, "EBUF_STATUS"}, -- {0, "GEN3_DEC_ENC_STATUS"}, -- {0, "WAKE_STATUS"}, -- {0, "RECV_DET_OR_PWR_CHAGE"}, -- {0, "EQEVAL_STATUS"}, -- {0, "LANE_INTR_STATUS"}, -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(SERDES_STATUS_RPT), -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(EBUF_STATUS), -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(GEN3_DEC_ENC_STATUS), -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(WAKE_STATUS), -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(RECV_DET_OR_PWR_CHAGE), -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(EQEVAL_STATUS), -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(LANE_INTR_STATUS), - }; - - struct pcie_dumpreg_info g_reg_table_iob_tx[] = { -@@ -348,6 +348,13 @@ static void pcie_dumpreg_save_glb_analysis_log(const uint32_t *data, uint32_t da - pcie_dumpreg_write_value_to_file(g_reg_table_core_glb[item_i].name, - g_reg_table_core_glb[item_i].val); - } -+ /* PCS REG */ -+ for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_pcs) && -+ data_i < data_num; item_i++, data_i++) { -+ g_reg_table_pcs[item_i].val = data[data_i]; -+ pcie_dumpreg_write_value_to_file(g_reg_table_pcs[item_i].name, -+ g_reg_table_pcs[item_i].val); -+ } - } - - static void pcie_dumpreg_save_port_analysis_log(uint32_t *data, uint32_t data_num) -@@ -376,13 +383,6 @@ static void pcie_dumpreg_save_port_analysis_log(uint32_t *data, uint32_t data_nu - pcie_dumpreg_write_value_to_file(g_reg_table_mac[item_i].name, - g_reg_table_mac[item_i].val); - } -- /* PCS REG */ -- for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_pcs) && -- data_i < data_num; item_i++, data_i++) { -- g_reg_table_pcs[item_i].val = data[data_i]; -- pcie_dumpreg_write_value_to_file(g_reg_table_pcs[item_i].name, -- g_reg_table_pcs[item_i].val); -- } - } - - static int pcie_dumpreg_write_header_to_file(uint32_t version, -@@ -421,14 +421,12 @@ static int pcie_dumpreg_save_log(uint32_t *data, uint32_t data_num, - switch (req_data->level) { - case DUMP_GLOBAL_LEVEL: - expect_data_num = HIKP_ARRAY_SIZE(g_reg_table_iob_tx) + -- HIKP_ARRAY_SIZE(g_reg_table_iob_rx) + HIKP_ARRAY_SIZE(g_reg_table_ap_glb) + -- HIKP_ARRAY_SIZE(g_reg_table_core_glb); -+ HIKP_ARRAY_SIZE(g_reg_table_iob_rx) + HIKP_ARRAY_SIZE(g_reg_table_ap_glb) + -+ HIKP_ARRAY_SIZE(g_reg_table_core_glb) + HIKP_ARRAY_SIZE(g_reg_table_pcs); - break; - case DUMP_PORT_LEVEL: - expect_data_num = HIKP_ARRAY_SIZE(g_reg_table_tl) + -- HIKP_ARRAY_SIZE(g_reg_table_dl) + -- HIKP_ARRAY_SIZE(g_reg_table_mac) + -- HIKP_ARRAY_SIZE(g_reg_table_pcs); -+ HIKP_ARRAY_SIZE(g_reg_table_dl) + HIKP_ARRAY_SIZE(g_reg_table_mac); - break; - default: - Err("PCIe DUMPREG", "check dump level failed.\n"); -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.h b/pcie/func_lib/pcie_func/pcie_reg_dump.h -index 1993c1f..4ec1909 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.h -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.h -@@ -20,6 +20,16 @@ - #define MAX_STR_LEN 80 - #define PCIE_DUMPREG_LOGFILE_NAME "pcie_dumpreg" - -+#define HIKP_PCIE_PCS_LANE_TBL_ENTRY(name) \ -+ {0, STR(CONTACT(name, _00))}, {0, STR(CONTACT(name, _01))}, \ -+ {0, STR(CONTACT(name, _02))}, {0, STR(CONTACT(name, _03))}, \ -+ {0, STR(CONTACT(name, _04))}, {0, STR(CONTACT(name, _05))}, \ -+ {0, STR(CONTACT(name, _06))}, {0, STR(CONTACT(name, _07))}, \ -+ {0, STR(CONTACT(name, _08))}, {0, STR(CONTACT(name, _09))}, \ -+ {0, STR(CONTACT(name, _10))}, {0, STR(CONTACT(name, _11))}, \ -+ {0, STR(CONTACT(name, _12))}, {0, STR(CONTACT(name, _13))}, \ -+ {0, STR(CONTACT(name, _14))}, {0, STR(CONTACT(name, _15))} -+ - enum pcie_dump_level { - DUMP_GLOBAL_LEVEL = 1, - DUMP_PORT_LEVEL = 2, -diff --git a/pcie/usr_cmd/interface/pcie_common_api.h b/pcie/usr_cmd/interface/pcie_common_api.h -index f6541bd..9809575 100644 ---- a/pcie/usr_cmd/interface/pcie_common_api.h -+++ b/pcie/usr_cmd/interface/pcie_common_api.h -@@ -17,6 +17,10 @@ - #include - #include - -+#define CONTACT(x, y) x##y -+#define STR_INTER(x) #x -+#define STR(x) STR_INTER(x) -+ - struct print_info { - char *buff; - size_t buff_size; --- -2.25.1 - diff --git a/0011-optimize-the-nic_mac-dump-register.patch b/0011-optimize-the-nic_mac-dump-register.patch deleted file mode 100644 index da863563c2c30c88316bf8f19266157c060b4cfe..0000000000000000000000000000000000000000 --- a/0011-optimize-the-nic_mac-dump-register.patch +++ /dev/null @@ -1,46 +0,0 @@ -From c0f8dd5ae8fe688825e77cf63ddb30d0cb27ecdf Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 11 May 2023 08:54:09 +0800 -Subject: [PATCH 08/18] optimize the nic_mac dump register - -if reg dump block data num is 0, print not support dump and return. -hikptool version: 1.0.14 - -Signed-off-by: veega2022 ---- - net/nic/nic_mac/hikp_nic_mac_dump.c | 5 +++++ - tool_lib/tool_lib.h | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/net/nic/nic_mac/hikp_nic_mac_dump.c b/net/nic/nic_mac/hikp_nic_mac_dump.c -index 6e856a8..3e818cd 100644 ---- a/net/nic/nic_mac/hikp_nic_mac_dump.c -+++ b/net/nic/nic_mac/hikp_nic_mac_dump.c -@@ -64,6 +64,11 @@ static int mac_cmd_dump_mod(struct major_cmd_ctrl *self, const char *name, - uint32_t i; - int ret; - -+ if (blk_num == 0) { -+ printf("%s module is not support dump.\n", name); -+ return 0; -+ } -+ - printf("============ %10s REG INFO ==============\n", name); - printf("\t %s :\t%10s\n", "offset", "value"); - -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index bf37465..9766a7e 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.0.13" -+#define TOOL_VER "1.0.14" - - #define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask)) - #define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift)) --- -2.25.1 - diff --git a/0012-Fix-a-resource-release-bug-in-hikp_roh_get_cam_reg_n.patch b/0012-Fix-a-resource-release-bug-in-hikp_roh_get_cam_reg_n.patch deleted file mode 100644 index 8d1ac2dbd3fb0ff4a58cf27f5ce9c86bcf323811..0000000000000000000000000000000000000000 --- a/0012-Fix-a-resource-release-bug-in-hikp_roh_get_cam_reg_n.patch +++ /dev/null @@ -1,53 +0,0 @@ -From e51911b2c5daa7f9d650849aaa4f389291415255 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 11 May 2023 09:29:48 +0800 -Subject: [PATCH 14/18] Fix a resource release bug in hikp_roh_get_cam_reg_num - -Fix a resource release bug in hikp_roh_get_cam_reg_num - -Signed-off-by: chenke chenke54@huawei.com ---- - net/roh/hikp_roh_mac.c | 6 +++++- - net/roh/hikp_roh_show_bp.c | 2 +- - 2 files changed, 6 insertions(+), 2 deletions(-) - -diff --git a/net/roh/hikp_roh_mac.c b/net/roh/hikp_roh_mac.c -index 90708b1..43f954c 100644 ---- a/net/roh/hikp_roh_mac.c -+++ b/net/roh/hikp_roh_mac.c -@@ -141,6 +141,7 @@ static int hikp_roh_get_cam_reg_num(struct major_cmd_ctrl *self) - struct roh_mac_req_para req_data = { 0 }; - struct hikp_cmd_header req_header = { 0 }; - struct hikp_cmd_ret *cmd_ret = NULL; -+ uint32_t cam_reg_num; - - req_data.bdf = g_roh_mac_param.target.bdf; - hikp_cmd_init(&req_header, ROH_MOD, HIKP_ROH_MAC, CMD_GET_CAM_REG_NUM); -@@ -153,7 +154,10 @@ static int hikp_roh_get_cam_reg_num(struct major_cmd_ctrl *self) - return -EIO; - } - mac_rsp = (struct roh_mac_cam_reg_num *)(cmd_ret->rsp_data); -- return mac_rsp->cam_reg_num; -+ cam_reg_num = mac_rsp->cam_reg_num; -+ free(cmd_ret); -+ cmd_ret = NULL; -+ return cam_reg_num; - } - - static int hikp_roh_build_cam(struct major_cmd_ctrl *self, struct cam_table_entry_t *cam_table) -diff --git a/net/roh/hikp_roh_show_bp.c b/net/roh/hikp_roh_show_bp.c -index c89e98b..73a53d8 100644 ---- a/net/roh/hikp_roh_show_bp.c -+++ b/net/roh/hikp_roh_show_bp.c -@@ -44,7 +44,7 @@ static int hikp_roh_show_bp(struct major_cmd_ctrl *self) - union bp_val res; - uint8_t flit_bp; - int mac_id; -- int ret; -+ int ret = 0; - - struct hikp_cmd_ret *cmd_ret = NULL; - struct hikp_cmd_header req_header = { 0 }; --- -2.25.1 - diff --git a/0013-fix-missing-white-space-issue.patch b/0013-fix-missing-white-space-issue.patch deleted file mode 100644 index 4ffa6c4a6adcc2e1bddc37b8919f39ae09229518..0000000000000000000000000000000000000000 --- a/0013-fix-missing-white-space-issue.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 28283e9ab010f418846eaa00511721745927088f Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 11 May 2023 09:36:38 +0800 -Subject: [PATCH 15/18] fix missing white space issue - -Add a space on the left and right of the "=" - -Signed-off-by: veega2022 ---- - socip/hikp_socip_dumpreg.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/socip/hikp_socip_dumpreg.c b/socip/hikp_socip_dumpreg.c -index b74dac8..32325bb 100644 ---- a/socip/hikp_socip_dumpreg.c -+++ b/socip/hikp_socip_dumpreg.c -@@ -142,7 +142,7 @@ static void hikp_socip_dumpreg_execute(struct major_cmd_ctrl *self) - hikp_cmd_init(&req_header, SOCIP_MOD, HIKP_SOCIP_CMD_DUMPREG, param[MODULE_ID_INDEX].val); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (!cmd_ret) { -- self->err_no=-EINVAL; -+ self->err_no = -EINVAL; - HIKP_ERROR_PRINT("hikp_cmd_alloc\n"); - return; - } --- -2.25.1 - diff --git a/0014-hikptool-fix-maininfo-detail-info-print-error.patch b/0014-hikptool-fix-maininfo-detail-info-print-error.patch deleted file mode 100644 index 547ff040903b6fda8f005664de3788262d2e88ef..0000000000000000000000000000000000000000 --- a/0014-hikptool-fix-maininfo-detail-info-print-error.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 90c8f3c14e4d5cf1ea5fd8181810f07d33af4e9b Mon Sep 17 00:00:00 2001 -From: huangguanhua -Date: Thu, 18 May 2023 16:29:28 +0800 -Subject: [PATCH 17/18] hikptool-fix-maininfo-detail-info-print-error - -Signed-off-by: huangguanhua ---- - serdes/hikp_serdes.c | 12 ++++++++---- - serdes/hikp_serdes.h | 3 ++- - tool_lib/op_logs.c | 6 +++--- - 3 files changed, 13 insertions(+), 8 deletions(-) - -diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c -index dd9eee3..527fd53 100644 ---- a/serdes/hikp_serdes.c -+++ b/serdes/hikp_serdes.c -@@ -184,21 +184,22 @@ static void hikp_serdes_brief_info_print(struct major_cmd_ctrl *self, - "Tap16,Tap17,Tap18,Tap19,Tap20]\n" \ - "FWFourEye: It only takes effect when the firmware is running and " \ - "continuous adaptation is turned on\n" \ -+ "Snr: [SNR_METRIC,SNR_METRIC_HIS_MIN,SNR_CYCLES,HEH,SNR_METRIC_SW]\n" \ - "-----------------------------------------------------" \ - "------------------------------------------------" \ - "-----------------------------------------------------" \ - "------------------------------------------------" \ -- "-------------------\n" \ -+ "--------------------------------\n" \ - " [ FFE ]" \ - "[ CTLE ]" \ - "[ " \ - "DFE ]" \ -- "[ FWFourEye ][ snr ]\n" \ -+ "[ FWFourEye ][ Snr ]\n" \ - "-----------------------------------------------------" \ - "-------------------------------------------------" \ - "-----------------------------------------------------" \ - "-------------------------------------------------" \ -- "------------------\n") -+ "--------------------------------\n") - - static void hikp_serdes_detail_info_print(struct major_cmd_ctrl *self, - const struct hilink_detail_info *data, -@@ -233,7 +234,10 @@ static void hikp_serdes_detail_info_print(struct major_cmd_ctrl *self, - printf("][%4d,%4d,%4d,%4d]", - data[ds_id].eye_diagram.top, data[ds_id].eye_diagram.bottom, - data[ds_id].eye_diagram.left, data[ds_id].eye_diagram.right); -- printf("[%7d]\n", data[ds_id].snr); -+ /* 0: SNR_METRIC, 1:SNR_METRIC_HIS_MIN */ -+ printf("[%3d,%3d,%3d,%3d,%3d]\n", data[ds_id].snr_para[0], data[ds_id].snr_para[1], -+ /* 2:SNR_CYCLES, 3:HEH, 4:SNR_METRIC_SW */ -+ data[ds_id].snr_para[2], data[ds_id].snr_para[3], data[ds_id].snr_para[4]); - } - } - -diff --git a/serdes/hikp_serdes.h b/serdes/hikp_serdes.h -index 99b9b15..83c28b8 100644 ---- a/serdes/hikp_serdes.h -+++ b/serdes/hikp_serdes.h -@@ -192,7 +192,8 @@ struct hilink_detail_info { - struct hilink_rx_param rx_ctle_cfg; - struct hilink_serdes_rx_tap rx_tap_cfg; - struct hilink_4p_eye_result eye_diagram; -- uint32_t snr; -+ /* 5: (0: SNR_METRIC, 1:SNR_METRIC_HIS_MIN, 2:SNR_CYCLES, 3:HEH, 4:SNR_METRIC_SW) */ -+ int32_t snr_para[5]; - }; - - struct hilink_brief_info { -diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c -index 069428d..d91ddb0 100644 ---- a/tool_lib/op_logs.c -+++ b/tool_lib/op_logs.c -@@ -431,7 +431,7 @@ void sig_init(void) - (void)signal(SIGHUP, signal_handle); - (void)signal(SIGSEGV, signal_handle); - (void)signal(SIGBUS, signal_handle); -- (void)signal(SIGFPE, signal_handle); -- (void)signal(SIGABRT, signal_handle); -- (void)signal(SIGTSTP, signal_handle); /* Stop process */ -+ (void)signal(SIGFPE, signal_handle); -+ (void)signal(SIGABRT, signal_handle); -+ (void)signal(SIGTSTP, signal_handle); /* Stop process */ - } --- -2.25.1 - diff --git a/0015-hikptool-fix-print-sas_dqe-info-error-problem.patch b/0015-hikptool-fix-print-sas_dqe-info-error-problem.patch deleted file mode 100644 index b9a73b13bb62ce67177531818f17e9acd49ac3d0..0000000000000000000000000000000000000000 --- a/0015-hikptool-fix-print-sas_dqe-info-error-problem.patch +++ /dev/null @@ -1,29 +0,0 @@ -From dc15df882b56ec2abff2a5bba45238309a02f5e9 Mon Sep 17 00:00:00 2001 -From: FuJia Ni -Date: Thu, 25 May 2023 09:36:39 +0800 -Subject: [PATCH 18/18] hikptool: fix print sas_dqe info error problem - -the volatile modifier is added because the O2 compilation optimization is enbaled. -As a result, the pointer data is not updated. - -Signed-off-by: FuJia Ni ---- - sas/sas_func/sas_read_dqe.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/sas/sas_func/sas_read_dqe.c b/sas/sas_func/sas_read_dqe.c -index fc04682..2f653df 100644 ---- a/sas/sas_func/sas_read_dqe.c -+++ b/sas/sas_func/sas_read_dqe.c -@@ -47,7 +47,7 @@ static int sas_get_dqe(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - - static void print_dqe_info(const void *reg_save, uint32_t reg_num) - { -- struct hisi_sas_dq_info *dqe = (struct hisi_sas_dq_info *)(reg_save); -+ volatile struct hisi_sas_dq_info *dqe = (volatile struct hisi_sas_dq_info *)(reg_save); - - printf("The dqe dw0 information as below:\n"); - printf("abort_flag: %u\n", dqe->dw0.abort_flag); --- -2.25.1 - diff --git a/0016-hikptool-fix-compiling-specifications-check-problem.patch b/0016-hikptool-fix-compiling-specifications-check-problem.patch deleted file mode 100644 index 7d0087678b20a6c5a75ba7b2465ae597b916aedd..0000000000000000000000000000000000000000 --- a/0016-hikptool-fix-compiling-specifications-check-problem.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 834b2fe48984703a41aceb2307b8604b93d0e6e8 Mon Sep 17 00:00:00 2001 -From: veega -Date: Thu, 1 Jun 2023 09:56:39 +0800 -Subject: [PATCH] hikptool: fix compiling specifications check problem - -delete -g option for release vesion and add compile option: -Wextra --fno-common -std=gnu11 -Wfloat-equal - -Signed-off-by: veega ---- - CMakeLists.txt | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 6a396e7..174dd8f 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -11,7 +11,8 @@ - - project(hikptool C) - --set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -fPIC -fPIE -Wall") -+set(CMAKE_C_FLAGS -+ "${CMAKE_C_FLAGS} -O2 -fPIC -fPIE -Wall -Wextra -fno-common -std=gnu11 -Wfloat-equal") - set(CMAKE_SKIP_RPATH TRUE) - - macro(get_header_dir_recurse HEADER_DIR_LIST) --- -2.25.1 - diff --git a/0017-Complete-the-developing-of-hikptool-ub_dfx-function.patch b/0017-Complete-the-developing-of-hikptool-ub_dfx-function.patch deleted file mode 100644 index 73dfb8d76f7d73b4e7a5381ae12ca8c6a4565233..0000000000000000000000000000000000000000 --- a/0017-Complete-the-developing-of-hikptool-ub_dfx-function.patch +++ /dev/null @@ -1,497 +0,0 @@ -From 11887e073c584d64c800ac5183fee43f895fccb1 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 11 May 2023 08:52:35 +0800 -Subject: [PATCH 07/15] Complete the developing of hikptool ub_dfx function - -The hikptool ub_dfx command is submitted for the first time. -This command can be used to dump register information of the LRB, PFA, and PM modules. - -Signed-off-by: Jianqiang Li ---- - libhikptdev/include/hikptdev_plug.h | 1 + - net/hikp_net_lib.h | 9 + - net/ub/ub_dfx/hikp_ub_dfx.c | 319 ++++++++++++++++++++++++++++ - net/ub/ub_dfx/hikp_ub_dfx.h | 100 +++++++++ - tool_lib/tool_lib.h | 2 +- - 5 files changed, 430 insertions(+), 1 deletion(-) - create mode 100644 net/ub/ub_dfx/hikp_ub_dfx.c - create mode 100644 net/ub/ub_dfx/hikp_ub_dfx.h - -diff --git a/libhikptdev/include/hikptdev_plug.h b/libhikptdev/include/hikptdev_plug.h -index 42bea6b..56cea78 100644 ---- a/libhikptdev/include/hikptdev_plug.h -+++ b/libhikptdev/include/hikptdev_plug.h -@@ -43,6 +43,7 @@ enum cmd_module_type { - MAC_MOD = 8, - DPDK_MOD = 9, - CXL_MOD = 10, -+ UB_MOD = 11, - }; - - void hikp_unlock(void); -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index cc99d0c..af0a51d 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -98,6 +98,15 @@ enum roce_cmd_type { - GET_ROCEE_TSP_CMD, - }; - -+enum ub_cmd_type { -+ GET_UNIC_PPP_CMD = 0x1, -+ GET_UB_DFX_INFO_CMD, -+ GET_UB_LINK_INFO_CMD, -+ GET_UB_BP_INFO_CMD, -+ GET_UB_CRD_INFO_CMD, -+ GET_UB_BASIC_INFO_CMD, -+}; -+ - #define HIKP_MAX_PF_NUM 8 - #define HIKP_NIC_MAX_FUNC_NUM 256 - -diff --git a/net/ub/ub_dfx/hikp_ub_dfx.c b/net/ub/ub_dfx/hikp_ub_dfx.c -new file mode 100644 -index 0000000..c50f555 ---- /dev/null -+++ b/net/ub/ub_dfx/hikp_ub_dfx.c -@@ -0,0 +1,319 @@ -+/* -+ * Copyright (c) 2023 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 "tool_cmd.h" -+#include "hikp_net_lib.h" -+#include "hikp_ub_dfx.h" -+ -+struct ub_dfx_param g_ub_dfx_param = { 0 }; -+ -+static const struct dfx_module_cmd g_ub_dfx_module_parse[] = { -+ {"LRB", LRB_DFX_REG_DUMP}, -+ {"PFA", PFA_DFX_REG_DUMP}, -+ {"PM", PM_DFX_REG_DUMP} -+}; -+ -+static const struct dfx_type_parse g_dfx_type_parse[] = { -+ {INCORRECT_REG_TYPE, WIDTH_32_BIT, "INCORRECT TYPE"}, -+ {TYPE_32_STATS, WIDTH_32_BIT, "32 bit statistics"}, -+ {TYPE_32_RUNNING_STATUS, WIDTH_32_BIT, "32 bit running status"}, -+ {TYPE_64_STATS, WIDTH_64_BIT, "64 bit statistics"}, -+}; -+ -+static void dfx_help_info(const struct major_cmd_ctrl *self) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \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=", -+ "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); -+ printf(" %s\n", " [-m/--module LRB/PFA/PM] : this is necessary param\n"); -+} -+ -+static int hikp_ub_dfx_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ dfx_help_info(self); -+ return 0; -+} -+ -+static int hikp_ub_dfx_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ub_dfx_param.target)); -+ if (self->err_no != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); -+ return self->err_no; -+ } -+ -+ return 0; -+} -+ -+static int hikp_ub_dfx_module_select(struct major_cmd_ctrl *self, const char *argv) -+{ -+ size_t arr_size = HIKP_ARRAY_SIZE(g_ub_dfx_module_parse); -+ bool is_found; -+ size_t i; -+ -+ for (i = 0; i < arr_size; i++) { -+ is_found = strncmp(argv, (const char *)g_ub_dfx_module_parse[i].module_name, -+ sizeof(g_ub_dfx_module_parse[i].module_name)) == 0; -+ if (is_found) { -+ g_ub_dfx_param.sub_cmd_code = g_ub_dfx_module_parse[i].sub_cmd_code; -+ g_ub_dfx_param.module_idx = i; -+ g_ub_dfx_param.flag |= MODULE_SET_FLAG; -+ return 0; -+ } -+ } -+ dfx_help_info(self); -+ snprintf(self->err_str, sizeof(self->err_str), "-m/--module param error!!!"); -+ self->err_no = -EINVAL; -+ -+ return -EINVAL; -+} -+ -+static int hikp_ub_dfx_get_blk_data(struct hikp_cmd_ret **cmd_ret, -+ uint32_t blk_id, uint32_t sub_cmd_code) -+{ -+ struct hikp_cmd_header req_header = { 0 }; -+ struct ub_dfx_req_para req_data = { 0 }; -+ -+ req_data.bdf = g_ub_dfx_param.target.bdf; -+ req_data.block_id = blk_id; -+ hikp_cmd_init(&req_header, UB_MOD, GET_UB_DFX_INFO_CMD, sub_cmd_code); -+ *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -+ -+ return hikp_rsp_normal_check(*cmd_ret); -+} -+ -+static int hikp_ub_get_first_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t **reg_data, -+ uint32_t *max_dfx_size, uint32_t *version) -+{ -+ struct ub_dfx_rsp *dfx_rsp = NULL; -+ struct hikp_cmd_ret *cmd_ret; -+ int ret; -+ -+ ret = hikp_ub_dfx_get_blk_data(&cmd_ret, 0, g_ub_dfx_param.sub_cmd_code); -+ if (ret < 0) -+ goto err_out; -+ -+ dfx_rsp = (struct ub_dfx_rsp *)(cmd_ret->rsp_data); -+ *version = cmd_ret->version; -+ *rsp_head = dfx_rsp->rsp_head; -+ if (rsp_head->total_blk_num == 0) { -+ /* if total block number is zero, set total type number to zero anyway */ -+ rsp_head->total_type_num = 0; -+ goto err_out; -+ } -+ *max_dfx_size = (uint32_t)(rsp_head->total_blk_num * MAX_DFX_DATA_NUM * sizeof(uint32_t)); -+ *reg_data = (uint32_t *)calloc(1, *max_dfx_size); -+ if (*reg_data == NULL) { -+ HIKP_ERROR_PRINT("malloc log memory 0x%x failed.\n", *max_dfx_size); -+ ret = -ENOMEM; -+ goto err_out; -+ } -+ -+ if (rsp_head->cur_blk_size > *max_dfx_size) { -+ free(*reg_data); -+ *reg_data = NULL; -+ HIKP_ERROR_PRINT("blk0 reg_data copy size error, data size: 0x%x, max size: 0x%x\n", -+ rsp_head->cur_blk_size, *max_dfx_size); -+ ret = -EINVAL; -+ goto err_out; -+ } -+ memcpy(*reg_data, dfx_rsp->reg_data, rsp_head->cur_blk_size); -+ -+ *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; -+err_out: -+ free(cmd_ret); -+ cmd_ret = NULL; -+ -+ return ret; -+} -+ -+static int hikp_ub_get_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t blk_id, -+ uint32_t *reg_data, uint32_t *max_dfx_size) -+{ -+ struct ub_dfx_rsp *dfx_rsp = NULL; -+ struct hikp_cmd_ret *cmd_ret; -+ int ret; -+ -+ ret = hikp_ub_dfx_get_blk_data(&cmd_ret, blk_id, g_ub_dfx_param.sub_cmd_code); -+ if (ret < 0) -+ goto err_out; -+ -+ dfx_rsp = (struct ub_dfx_rsp *)(cmd_ret->rsp_data); -+ *rsp_head = dfx_rsp->rsp_head; -+ if (rsp_head->cur_blk_size > *max_dfx_size) { -+ HIKP_ERROR_PRINT("blk%u reg_data copy size error, " -+ "data size: 0x%x, max size: 0x%x\n", -+ blk_id, rsp_head->cur_blk_size, *max_dfx_size); -+ ret = -EINVAL; -+ goto err_out; -+ } -+ memcpy(reg_data, dfx_rsp->reg_data, rsp_head->cur_blk_size); -+ *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; -+ -+err_out: -+ free(cmd_ret); -+ cmd_ret = NULL; -+ -+ return ret; -+} -+ -+static bool is_type_found(uint16_t type_id, uint32_t *index) -+{ -+ size_t arr_size = HIKP_ARRAY_SIZE(g_dfx_type_parse); -+ size_t i; -+ -+ for (i = 0; i < arr_size; i++) { -+ if (g_dfx_type_parse[i].type_id == type_id) { -+ *index = i; -+ return true; -+ } -+ } -+ -+ return false; -+} -+ -+static void hikp_ub_dfx_print_type_head(uint8_t type_id, uint8_t *last_type_id) -+{ -+ uint32_t index = 0; -+ -+ if (type_id != *last_type_id) { -+ printf("-----------------------------------------------------\n"); -+ if (is_type_found(type_id, &index)) -+ printf("type name: %s\n\n", g_dfx_type_parse[index].type_name); -+ else -+ HIKP_WARN_PRINT("type name: unknown type, type id is %u\n\n", type_id); -+ -+ *last_type_id = type_id; -+ } -+} -+ -+static void hikp_ub_dfx_print_b32(uint32_t num, uint32_t *reg_data) -+{ -+ uint32_t word_num = num * WORD_NUM_PER_REG; -+ uint16_t offset; -+ uint32_t value; -+ uint32_t index; -+ uint32_t i; -+ -+ for (i = 0, index = 1; i < word_num; i = i + WORD_NUM_PER_REG, index++) { -+ offset = (uint16_t)HI_GET_BITFIELD(reg_data[i], 0, DFX_REG_ADDR_MASK); -+ value = reg_data[i + 1]; -+ printf("%03u: 0x%04x\t0x%08x\n", index, offset, value); -+ } -+} -+ -+static void hikp_ub_dfx_print_b64(uint32_t num, uint32_t *reg_data) -+{ -+ uint32_t word_num = num * WORD_NUM_PER_REG; -+ uint16_t offset; -+ uint64_t value; -+ uint32_t index; -+ uint32_t i; -+ -+ for (i = 0, index = 1; i < word_num; i = i + WORD_NUM_PER_REG, index++) { -+ offset = (uint16_t)HI_GET_BITFIELD(reg_data[i], 0, DFX_REG_ADDR_MASK); -+ value = (uint64_t)reg_data[i + 1] | -+ (HI_GET_BITFIELD((uint64_t)reg_data[i], DFX_REG_VALUE_OFF, -+ DFX_REG_VALUE_MASK) << BIT_NUM_OF_WORD); -+ printf("%03u: 0x%04x\t0x%016lx\n", index, offset, value); -+ } -+} -+ -+static void hikp_ub_dfx_print(const struct ub_dfx_rsp_head *rsp_head, uint32_t *reg_data) -+{ -+ struct ub_dfx_type_head *type_head; -+ uint8_t last_type_id = 0; -+ uint32_t *ptr = reg_data; -+ uint8_t i; -+ -+ printf("****************** module %s reg dump start ********************\n", -+ g_ub_dfx_module_parse[g_ub_dfx_param.module_idx].module_name); -+ for (i = 0; i < rsp_head->total_type_num; i++) { -+ type_head = (struct ub_dfx_type_head *)ptr; -+ if (type_head->type_id == INCORRECT_REG_TYPE) { -+ HIKP_ERROR_PRINT("No.%u type is incorrect reg type\n", i + 1u); -+ break; -+ } -+ hikp_ub_dfx_print_type_head(type_head->type_id, &last_type_id); -+ ptr++; -+ if (type_head->bit_width == WIDTH_32_BIT) { -+ hikp_ub_dfx_print_b32((uint32_t)type_head->reg_num, ptr); -+ } else if (type_head->bit_width == WIDTH_64_BIT) { -+ hikp_ub_dfx_print_b64((uint32_t)type_head->reg_num, ptr); -+ } else { -+ HIKP_ERROR_PRINT("type%u's bit width error.\n", type_head->type_id); -+ break; -+ } -+ ptr += (uint32_t)type_head->reg_num * WORD_NUM_PER_REG; -+ } -+ printf("################### ====== dump end ====== ######################\n"); -+} -+ -+static void hikp_ub_dfx_execute(struct major_cmd_ctrl *self) -+{ -+ struct ub_dfx_rsp_head rsp_head = { 0 }; -+ struct ub_dfx_rsp_head tmp_head = { 0 }; -+ uint32_t *reg_data = NULL; -+ uint32_t max_dfx_size = 0; -+ uint32_t real_reg_size; -+ uint32_t version; -+ uint32_t i; -+ -+ if (!(g_ub_dfx_param.flag & MODULE_SET_FLAG)) { -+ self->err_no = -EINVAL; -+ snprintf(self->err_str, sizeof(self->err_str), "Please specify a module."); -+ dfx_help_info(self); -+ return; -+ } -+ -+ self->err_no = hikp_ub_get_first_blk_dfx(&rsp_head, ®_data, &max_dfx_size, &version); -+ if (self->err_no != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "get the first block dfx fail."); -+ return; -+ } -+ real_reg_size = (uint32_t)rsp_head.cur_blk_size; -+ for (i = 1; i < rsp_head.total_blk_num; i++) { -+ self->err_no = hikp_ub_get_blk_dfx(&tmp_head, i, -+ reg_data + (real_reg_size / sizeof(uint32_t)), -+ &max_dfx_size); -+ if (self->err_no != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "getting block%u reg fail.", i); -+ free(reg_data); -+ return; -+ } -+ real_reg_size += (uint32_t)tmp_head.cur_blk_size; -+ memset(&tmp_head, 0, sizeof(struct ub_dfx_rsp_head)); -+ } -+ -+ printf("DFX cmd version: 0x%x\n\n", version); -+ hikp_ub_dfx_print((const struct ub_dfx_rsp_head *)&rsp_head, reg_data); -+ free(reg_data); -+} -+ -+static void cmd_ub_dfx_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_ub_dfx_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_ub_dfx_help); -+ cmd_option_register("-i", "--interface", true, hikp_ub_dfx_target); -+ cmd_option_register("-m", "--module", true, hikp_ub_dfx_module_select); -+} -+ -+HIKP_CMD_DECLARE("ub_dfx", "dump ub dfx info of hardware", cmd_ub_dfx_init); -diff --git a/net/ub/ub_dfx/hikp_ub_dfx.h b/net/ub/ub_dfx/hikp_ub_dfx.h -new file mode 100644 -index 0000000..4ba37a1 ---- /dev/null -+++ b/net/ub/ub_dfx/hikp_ub_dfx.h -@@ -0,0 +1,100 @@ -+/* -+ * Copyright (c) 2023 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_UB_DFX_H -+#define HIKP_UB_DFX_H -+ -+#include "hikp_net_lib.h" -+ -+#define MAX_DFX_DATA_NUM 59 -+#define MODULE_SET_FLAG 0x1 -+ -+enum ub_dfx_cmd_type { -+ LRB_DFX_REG_DUMP = 0, -+ PFA_DFX_REG_DUMP = 1, -+ PM_DFX_REG_DUMP = 2, -+ INVALID_MODULE = 0xFFFFFFFF, -+}; -+ -+enum ub_dfx_reg_type { -+ INCORRECT_REG_TYPE = 0, -+ TYPE_32_STATS = 1, -+ TYPE_32_RUNNING_STATUS = 2, -+ TYPE_64_STATS = 3, -+ TYPE_INVALID = 255, -+}; -+ -+#define MAX_TYPE_NAME_LEN 40 -+ -+enum ub_dfx_reg_width { -+ WIDTH_32_BIT = 32, -+ WIDTH_64_BIT = 64, -+}; -+ -+struct dfx_type_parse { -+ uint8_t type_id; -+ uint8_t bit_width; -+ uint8_t type_name[MAX_TYPE_NAME_LEN]; -+}; -+ -+struct ub_dfx_param { -+ struct tool_target target; -+ uint32_t sub_cmd_code; -+ uint8_t module_idx; -+ uint8_t flag; -+}; -+ -+#define MAX_MODULE_NAME_LEN 20 -+struct dfx_module_cmd { -+ uint8_t module_name[MAX_MODULE_NAME_LEN]; -+ uint32_t sub_cmd_code; -+}; -+ -+struct ub_dfx_req_para { -+ struct bdf_t bdf; -+ uint8_t block_id; -+}; -+ -+struct ub_dfx_type_head { -+ uint8_t type_id; -+ uint8_t bit_width; -+ uint8_t reg_num; -+ uint8_t flag; -+}; -+ -+struct ub_dfx_rsp_head { -+ uint8_t total_blk_num; -+ uint8_t total_type_num; -+ uint8_t cur_blk_size; -+ uint8_t rsvd; -+}; -+ -+/********************************************************* -+ * All registers are returned as key-value pairs, and divided -+ * into three groups of data. -+ * 1. 32bit regs: R0 bit0~bit15: offset, R1 bit0~bit31: value -+ * 2. 64bit regs: R0 bit0~bit15: offset, R0 bit16~bit31 high16 value, R1 bit0~bit31: low32 value -+ *********************************************************/ -+#define DFX_REG_VALUE_OFF 16 -+#define DFX_REG_VALUE_MASK 0xFFFF -+#define DFX_REG_ADDR_MASK 0xFFFF -+ -+#define WORD_NUM_PER_REG 2 -+#define BIT_NUM_OF_WORD 32 -+ -+struct ub_dfx_rsp { -+ struct ub_dfx_rsp_head rsp_head; -+ uint32_t reg_data[MAX_DFX_DATA_NUM]; -+}; -+ -+#endif /* HIKP_UB_DFX_H */ -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index b211175..bf37465 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.0.14" -+#define TOOL_VER "1.0.15" - - #define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask)) - #define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift)) --- -2.36.1.windows.1 diff --git a/0018-Complete-the-developing-of-hikptool-ub_link-function.patch b/0018-Complete-the-developing-of-hikptool-ub_link-function.patch deleted file mode 100644 index 30670e93c8bea336a4bb26822ee96923791cbf9d..0000000000000000000000000000000000000000 --- a/0018-Complete-the-developing-of-hikptool-ub_link-function.patch +++ /dev/null @@ -1,182 +0,0 @@ -From a9a370cf2127f8317759ef3d963c4c7db89c499c Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 11 May 2023 08:56:30 +0800 -Subject: [PATCH 09/15] Complete the developing of hikptool ub_link function - -The hikptool ub_link command is submitted for the first time. -This command can be used to query the link state machine and status statistics during link establishment. - -Signed-off-by: Jianqiang Li ---- - net/ub/ub_link/hikp_ub_link.c | 98 +++++++++++++++++++++++++++++++++++ - net/ub/ub_link/hikp_ub_link.h | 53 +++++++++++++++++++ - 2 files changed, 151 insertions(+) - create mode 100644 net/ub/ub_link/hikp_ub_link.c - create mode 100644 net/ub/ub_link/hikp_ub_link.h - -diff --git a/net/ub/ub_link/hikp_ub_link.c b/net/ub/ub_link/hikp_ub_link.c -new file mode 100644 -index 0000000..b6353f7 ---- /dev/null -+++ b/net/ub/ub_link/hikp_ub_link.c -@@ -0,0 +1,98 @@ -+/* -+ * Copyright (c) 2023 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_ub_link.h" -+ -+static struct ub_link_param g_ub_link_param = { 0 }; -+ -+static int hikp_ub_link_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \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=", -+ "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); -+ printf("\n"); -+ return 0; -+} -+ -+static int hikp_ub_link_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ub_link_param.target)); -+ if (self->err_no != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); -+ return self->err_no; -+ } -+ -+ return 0; -+} -+ -+static void hikp_ub_link_info_show(const struct ub_link_rsp *info) -+{ -+ printf("%-32s %u\n", "mac id:", info->mac_id); -+ printf("%-32s %s\n", "hdlc link status:", info->hdlc_link ? "true" : "false"); -+ printf("%-32s %s\n", "hpcs link status:", info->hpcs_link ? "true" : "false"); -+ printf("%-32s 0x%08x\n", "hdlc_link_fsm register value:", info->hdlc_link_fsm); -+ printf("%-32s 0x%08x\n", "hpcs_link_fsm register value:", info->hpcs_link_fsm); -+} -+ -+static int hikp_ub_query_link_info(const struct bdf_t *bdf) -+{ -+ struct hikp_cmd_header header = { 0 }; -+ struct ub_link_req_paras req = { 0 }; -+ struct hikp_cmd_ret *cmd_ret; -+ struct ub_link_rsp *rsp; -+ -+ req.bdf = *bdf; -+ hikp_cmd_init(&header, UB_MOD, GET_UB_LINK_INFO_CMD, UB_LINK_INFO_DUMP); -+ cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); -+ if (cmd_ret == NULL || cmd_ret->status != 0) { -+ free(cmd_ret); -+ cmd_ret = NULL; -+ return -EIO; -+ } -+ -+ rsp = (struct ub_link_rsp *)cmd_ret->rsp_data; -+ hikp_ub_link_info_show(rsp); -+ -+ free(cmd_ret); -+ cmd_ret = NULL; -+ return 0; -+} -+ -+static void hikp_ub_link_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ struct bdf_t *bdf = &g_ub_link_param.target.bdf; -+ int ret; -+ -+ ret = hikp_ub_query_link_info(bdf); -+ if (ret != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "fail to get link info."); -+ self->err_no = ret; -+ return; -+ } -+} -+ -+static void cmd_ub_link_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_ub_link_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_ub_link_help); -+ cmd_option_register("-i", "--interface", true, hikp_ub_link_target); -+} -+ -+HIKP_CMD_DECLARE("ub_link", "get ub link information", cmd_ub_link_init); -diff --git a/net/ub/ub_link/hikp_ub_link.h b/net/ub/ub_link/hikp_ub_link.h -new file mode 100644 -index 0000000..dec5129 ---- /dev/null -+++ b/net/ub/ub_link/hikp_ub_link.h -@@ -0,0 +1,53 @@ -+/* -+ * Copyright (c) 2023 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. -+ */ -+ -+/* -+ * Copyright (c) 2023 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_UB_LINK_H -+#define HIKP_UB_LINK_H -+ -+#include "hikp_net_lib.h" -+ -+enum ub_link_sub_cmd_type { -+ UB_LINK_INFO_DUMP = 0, -+}; -+ -+struct ub_link_param { -+ struct tool_target target; -+}; -+ -+struct ub_link_req_paras { -+ struct bdf_t bdf; -+}; -+ -+struct ub_link_rsp { -+ uint8_t mac_id; -+ uint8_t hdlc_link; -+ uint8_t hpcs_link; -+ uint8_t rsvd; -+ uint32_t hdlc_link_fsm; -+ uint32_t hpcs_link_fsm; -+}; -+ -+#endif /* HIKP_UB_LINK_H */ --- -2.36.1.windows.1 - diff --git a/0019-Complete-the-developing-of-hikptool-ub_bp-function.patch b/0019-Complete-the-developing-of-hikptool-ub_bp-function.patch deleted file mode 100644 index 21e5164aa0a9d11da6de2607862286e24ffd9ac6..0000000000000000000000000000000000000000 --- a/0019-Complete-the-developing-of-hikptool-ub_bp-function.patch +++ /dev/null @@ -1,172 +0,0 @@ -From 4e6d7c9e6614b3d7eaa83a513b06a53f93a23484 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 11 May 2023 08:58:01 +0800 -Subject: [PATCH 10/15] Complete the developing of hikptool ub_bp function - -The hikptool ub_bp command is submitted for the first time. -This command can be used to query the back pressure status of the VL in the UB-N. - -Signed-off-by: Jianqiang Li ---- - net/ub/ub_bp/hikp_ub_bp.c | 102 ++++++++++++++++++++++++++++++++++++++ - net/ub/ub_bp/hikp_ub_bp.h | 39 +++++++++++++++ - 2 files changed, 141 insertions(+) - create mode 100644 net/ub/ub_bp/hikp_ub_bp.c - create mode 100644 net/ub/ub_bp/hikp_ub_bp.h - -diff --git a/net/ub/ub_bp/hikp_ub_bp.c b/net/ub/ub_bp/hikp_ub_bp.c -new file mode 100644 -index 0000000..70a9a4b ---- /dev/null -+++ b/net/ub/ub_bp/hikp_ub_bp.c -@@ -0,0 +1,102 @@ -+/* -+ * Copyright (c) 2023 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_ub_bp.h" -+ -+static struct ub_bp_param g_ub_bp_param = { 0 }; -+ -+static int hikp_ub_bp_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \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=", -+ "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); -+ printf("\n"); -+ return 0; -+} -+ -+static int hikp_ub_bp_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ub_bp_param.target)); -+ if (self->err_no) { -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); -+ return self->err_no; -+ } -+ return 0; -+} -+ -+static void hikp_ub_bp_info_show(const struct ub_bp_rsp *info) -+{ -+ int bp_val_offset; -+ -+ printf("%-28s : %u\n", "mac id", info->mac_id); -+ printf("%-28s : ", "back pressure status"); -+ -+ for (bp_val_offset = MAX_VL_NUM; bp_val_offset >= 0; bp_val_offset--) { -+ printf("%d", HI_GETBIT(info->bp_val, bp_val_offset) ? 1 : 0); -+ } -+ printf("\n"); -+} -+ -+ -+static int hikp_ub_query_bp(const struct bdf_t *bdf) -+{ -+ struct hikp_cmd_header header = { 0 }; -+ struct ub_bp_req_para req = { 0 }; -+ struct hikp_cmd_ret *cmd_ret; -+ struct ub_bp_rsp *rsp; -+ -+ req.bdf = *bdf; -+ hikp_cmd_init(&header, UB_MOD, GET_UB_BP_INFO_CMD, UB_BP_INFO_DUMP); -+ cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); -+ if (cmd_ret == NULL || cmd_ret->status != 0) { -+ free(cmd_ret); -+ cmd_ret = NULL; -+ return -EIO; -+ } -+ -+ rsp = (struct ub_bp_rsp *)cmd_ret->rsp_data; -+ hikp_ub_bp_info_show(rsp); -+ -+ free(cmd_ret); -+ cmd_ret = NULL; -+ return 0; -+} -+ -+static void hikp_ub_bp_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ struct bdf_t *bdf = &g_ub_bp_param.target.bdf; -+ int ret; -+ -+ ret = hikp_ub_query_bp(bdf); -+ if (ret != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "fail to get ub bp info."); -+ self->err_no = ret; -+ return; -+ } -+} -+ -+static void cmd_ub_bp_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_ub_bp_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_ub_bp_help); -+ cmd_option_register("-i", "--interface", true, hikp_ub_bp_target); -+} -+ -+HIKP_CMD_DECLARE("ub_bp", "get ub bp information", cmd_ub_bp_init); -diff --git a/net/ub/ub_bp/hikp_ub_bp.h b/net/ub/ub_bp/hikp_ub_bp.h -new file mode 100644 -index 0000000..0bd4740 ---- /dev/null -+++ b/net/ub/ub_bp/hikp_ub_bp.h -@@ -0,0 +1,39 @@ -+/* -+ * Copyright (c) 2023 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_UB_BP_H -+#define HIKP_UB_BP_H -+ -+#include "hikp_net_lib.h" -+ -+#define MAX_VL_NUM 17 -+ -+enum ub_bp_sub_cmd_type { -+ UB_BP_INFO_DUMP = 0, -+}; -+ -+struct ub_bp_param { -+ struct tool_target target; -+}; -+ -+struct ub_bp_req_para { -+ struct bdf_t bdf; -+}; -+ -+struct ub_bp_rsp { -+ uint8_t mac_id; -+ uint8_t rsvd[3]; -+ uint32_t bp_val; -+}; -+ -+#endif /* HIKP_UB_BP_H */ --- -2.36.1.windows.1 - diff --git a/0020-Complete-the-developing-of-hikptool-ub_crd-function.patch b/0020-Complete-the-developing-of-hikptool-ub_crd-function.patch deleted file mode 100644 index ca4b8f613ce07c5c08b11e0ed0cafed37040f7e4..0000000000000000000000000000000000000000 --- a/0020-Complete-the-developing-of-hikptool-ub_crd-function.patch +++ /dev/null @@ -1,208 +0,0 @@ -From 575dc2b31315c2ea0e9fe488f30f86135e9ea7bf Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 11 May 2023 08:59:11 +0800 -Subject: [PATCH 11/15] Complete the developing of hikptool ub_crd function - -The hikptool ub_crd command is submitted for the first time. -This command is used to query the letter of credit status by reading the register value. - -Signed-off-by: Jianqiang Li ---- - net/ub/ub_crd/hikp_ub_crd.c | 133 ++++++++++++++++++++++++++++++++++++ - net/ub/ub_crd/hikp_ub_crd.h | 44 ++++++++++++ - 2 files changed, 177 insertions(+) - create mode 100644 net/ub/ub_crd/hikp_ub_crd.c - create mode 100644 net/ub/ub_crd/hikp_ub_crd.h - -diff --git a/net/ub/ub_crd/hikp_ub_crd.c b/net/ub/ub_crd/hikp_ub_crd.c -new file mode 100644 -index 0000000..d5d0015 ---- /dev/null -+++ b/net/ub/ub_crd/hikp_ub_crd.c -@@ -0,0 +1,133 @@ -+/* -+ * Copyright (c) 2023 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_ub_crd.h" -+ -+static struct ub_crd_param g_ub_crd_param = { 0 }; -+ -+static int hikp_ub_crd_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \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=", -+ "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); -+ printf("\n"); -+ return 0; -+} -+ -+static int hikp_ub_crd_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ub_crd_param.target)); -+ if (self->err_no) { -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); -+ return self->err_no; -+ } -+ return 0; -+} -+ -+static int hikp_ub_show_crd(uint32_t off, struct ub_crd_rsp *crd_rsp, uint32_t num_rows, -+ char const *crds[][2]) -+{ -+ int reg_index; -+ int i; -+ -+ for (i = 0; i < num_rows; i++) { -+ union cut_reg reg; -+ -+ reg_index = off + i; -+ reg.value = crd_rsp->cut_reg_value[reg_index]; -+ if (strcmp(crds[i][0], "NULL") != 0) -+ printf("%-28s : %#x\n", crds[i][0], reg.cut[0]); -+ -+ if (strcmp(crds[i][1], "NULL") != 0) -+ printf("%-28s : %#x\n", crds[i][1], reg.cut[1]); -+ } -+ return off + num_rows; -+} -+ -+static int hikp_ub_query_crd(void) -+{ -+ struct hikp_cmd_header req_header = { 0 }; -+ struct ub_crd_req_para req_data = { 0 }; -+ struct hikp_cmd_ret *cmd_ret = NULL; -+ struct ub_crd_rsp *crd_rsp = NULL; -+ int offset; -+ int ret; -+ -+ char const *init_crds[][2] = { -+ {"CFG_REMOTE_ICRD", "CFG_REMOTE_LCRD"}, -+ {"CFG_REMOTE_CRD_VL6", "CFG_REMOTE_CRD_VL7"}, -+ {"CFG_REMOTE_CRD_VL4", "CFG_REMOTE_CRD_VL5"}, -+ {"CFG_REMOTE_CRD_VL2", "CFG_REMOTE_CRD_VL3"}, -+ {"CFG_REMOTE_CRD_VL0", "CFG_REMOTE_CRD_VL1"}, -+ {"CFG_REMOTE_CRD_VL8", "NULL"} }; -+ -+ char const *temp_crds[][2] = { -+ {"TX_LCRD_VNA_EXIST_NUM", "NULL"}, {"TX_ICRD_VNA_EXIST_NUM", "NULL"}, -+ {"TX_CRD_VN0_EXIST_NUM", "NULL"}, {"TX_CRD_VN1_EXIST_NUM", "NULL"}, -+ {"TX_CRD_VN2_EXIST_NUM", "NULL"}, {"TX_CRD_VN3_EXIST_NUM", "NULL"}, -+ {"TX_CRD_VN4_EXIST_NUM", "NULL"}, {"TX_CRD_VN5_EXIST_NUM", "NULL"}, -+ {"TX_CRD_VN6_EXIST_NUM", "NULL"}, {"TX_CRD_VN7_EXIST_NUM", "NULL"}, -+ {"TX_ACK_EXIST_NUM", "NULL"}, {"TX_ROH_LCRD_LOCAL_NUM", "NULL"} }; -+ -+ hikp_cmd_init(&req_header, UB_MOD, GET_UB_CRD_INFO_CMD, UB_CRD_INFO_DUMP); -+ req_data.bdf = g_ub_crd_param.target.bdf; -+ cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -+ if (cmd_ret == NULL || cmd_ret->status != 0) { -+ free(cmd_ret); -+ cmd_ret = NULL; -+ return -EIO; -+ } -+ -+ crd_rsp = (struct ub_crd_rsp *)(cmd_ret->rsp_data); -+ -+ printf("******************** CREDIT CNT START ********************\n"); -+ printf("------------------- INIT CREDIT START -----------------\n"); -+ offset = hikp_ub_show_crd(0, crd_rsp, NUM_ROWS_INIT_CRDS, init_crds); -+ printf("------------------- INIT CREDIT END --------------------\n"); -+ printf("------------------- TEMP CREDIT START ------------------\n"); -+ offset = hikp_ub_show_crd(offset, crd_rsp, NUM_ROWS_TEMP_CRDS, temp_crds); -+ printf("------------------- TEMP CREDIT END --------------------\n"); -+ printf("********************* CREDIT CNT END *********************\n"); -+ -+ free(cmd_ret); -+ cmd_ret = NULL; -+ return 0; -+} -+ -+static void hikp_ub_crd_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ int ret; -+ -+ ret = hikp_ub_query_crd(); -+ if (ret != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "fail to get ub crd info."); -+ self->err_no = ret; -+ return; -+ } -+} -+ -+static void cmd_ub_crd_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_ub_crd_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_ub_crd_help); -+ cmd_option_register("-i", "--interface", true, hikp_ub_crd_target); -+} -+ -+HIKP_CMD_DECLARE("ub_crd", "get ub crd information", cmd_ub_crd_init); -diff --git a/net/ub/ub_crd/hikp_ub_crd.h b/net/ub/ub_crd/hikp_ub_crd.h -new file mode 100644 -index 0000000..5dfa38a ---- /dev/null -+++ b/net/ub/ub_crd/hikp_ub_crd.h -@@ -0,0 +1,44 @@ -+/* -+ * Copyright (c) 2023 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_UB_CRD_H -+#define HIKP_UB_CRD_H -+ -+#include "hikp_net_lib.h" -+ -+#define MAX_CRD_SIZE 20 -+#define NUM_ROWS_INIT_CRDS 6 -+#define NUM_ROWS_TEMP_CRDS 12 -+ -+enum ub_crd_sub_cmd_type { -+ UB_CRD_INFO_DUMP = 0, -+}; -+ -+union cut_reg { -+ uint32_t value; -+ uint16_t cut[2]; -+}; -+ -+struct ub_crd_param { -+ struct tool_target target; -+}; -+ -+struct ub_crd_req_para { -+ struct bdf_t bdf; -+}; -+ -+struct ub_crd_rsp { -+ uint32_t cut_reg_value[MAX_CRD_SIZE]; -+}; -+ -+#endif /* HIKP_UB_CRD_H */ --- -2.36.1.windows.1 - diff --git a/0021-Complete-the-developing-of-hikptool-ub_info-function.patch b/0021-Complete-the-developing-of-hikptool-ub_info-function.patch deleted file mode 100644 index ac36926df533f95bda20762a2f03644a1154b17b..0000000000000000000000000000000000000000 --- a/0021-Complete-the-developing-of-hikptool-ub_info-function.patch +++ /dev/null @@ -1,164 +0,0 @@ -From 43db6b06b49696cb4fd9556c975b2cf67da4b86b Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 11 May 2023 09:00:25 +0800 -Subject: [PATCH 12/15] Complete the developing of hikptool ub_info function - -The hikptool ub_info command is submitted for the first time. -This command is used to query whether the cloud attack defense function is enabled and query the single-port multi-stack working mode. - -Signed-off-by: Jianqiang Li ---- - net/ub/ub_info/hikp_ub_info.c | 96 +++++++++++++++++++++++++++++++++++ - net/ub/ub_info/hikp_ub_info.h | 37 ++++++++++++++ - 2 files changed, 133 insertions(+) - create mode 100644 net/ub/ub_info/hikp_ub_info.c - create mode 100644 net/ub/ub_info/hikp_ub_info.h - -diff --git a/net/ub/ub_info/hikp_ub_info.c b/net/ub/ub_info/hikp_ub_info.c -new file mode 100644 -index 0000000..3b354dd ---- /dev/null -+++ b/net/ub/ub_info/hikp_ub_info.c -@@ -0,0 +1,96 @@ -+/* -+ * Copyright (c) 2023 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_ub_info.h" -+ -+static struct ub_info_param g_ub_info_param = { 0 }; -+ -+static int hikp_ub_info_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \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=", -+ "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); -+ printf("\n"); -+ return 0; -+} -+ -+static int hikp_ub_info_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ub_info_param.target)); -+ if (self->err_no != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); -+ return self->err_no; -+ } -+ -+ return 0; -+} -+ -+static void hikp_ub_basic_info_show(const struct ub_info_rsp *info) -+{ -+ printf("%-32s : %s\n", "cloud-based attack defense", info->cloud_mode ? "YES" : "NO"); -+ printf("%-32s : %s\n", "pf working mode", info->pf_drv_type ? "UB" : "RDMA"); -+ printf("%-32s : %s\n", "vf working mode", info->vf_drv_type ? "UB" : "RDMA"); -+} -+ -+static int hikp_ub_query_basic_info(const struct bdf_t *bdf) -+{ -+ struct hikp_cmd_header header = { 0 }; -+ struct ub_info_req_para req = { 0 }; -+ struct hikp_cmd_ret *cmd_ret; -+ struct ub_info_rsp *rsp; -+ -+ req.bdf = *bdf; -+ hikp_cmd_init(&header, UB_MOD, GET_UB_BASIC_INFO_CMD, UB_BASIC_INFO_DUMP); -+ cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); -+ if (cmd_ret == NULL || cmd_ret->status != 0) { -+ free(cmd_ret); -+ cmd_ret = NULL; -+ return -EIO; -+ } -+ -+ rsp = (struct ub_info_rsp *)cmd_ret->rsp_data; -+ hikp_ub_basic_info_show(rsp); -+ -+ free(cmd_ret); -+ cmd_ret = NULL; -+ return 0; -+} -+ -+static void hikp_ub_info_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ struct bdf_t *bdf = &g_ub_info_param.target.bdf; -+ int ret; -+ -+ ret = hikp_ub_query_basic_info(bdf); -+ if (ret != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "fail to get basic info."); -+ self->err_no = ret; -+ return; -+ } -+} -+ -+static void cmd_ub_info_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_ub_info_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_ub_info_help); -+ cmd_option_register("-i", "--interface", true, hikp_ub_info_target); -+} -+ -+HIKP_CMD_DECLARE("ub_info", "get ub basic information", cmd_ub_info_init); -diff --git a/net/ub/ub_info/hikp_ub_info.h b/net/ub/ub_info/hikp_ub_info.h -new file mode 100644 -index 0000000..a9cb858 ---- /dev/null -+++ b/net/ub/ub_info/hikp_ub_info.h -@@ -0,0 +1,37 @@ -+/* -+ * Copyright (c) 2023 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_UB_INFO_H -+#define HIKP_UB_INFO_H -+ -+#include "hikp_net_lib.h" -+ -+enum ub_info_sub_cmd_type { -+ UB_BASIC_INFO_DUMP = 0, -+}; -+ -+struct ub_info_param { -+ struct tool_target target; -+}; -+ -+struct ub_info_req_para { -+ struct bdf_t bdf; -+}; -+ -+struct ub_info_rsp { -+ uint32_t cloud_mode; -+ uint32_t pf_drv_type; -+ uint32_t vf_drv_type; -+}; -+ -+#endif /* HIKP_UB_INFO_H */ --- -2.36.1.windows.1 - diff --git a/0022-add-support-query-ip-guid-entries.patch b/0022-add-support-query-ip-guid-entries.patch deleted file mode 100644 index 289d91629aea1c073e92e245eca89e48d7ffc778..0000000000000000000000000000000000000000 --- a/0022-add-support-query-ip-guid-entries.patch +++ /dev/null @@ -1,638 +0,0 @@ -From b51c3b0cdb438a18a4db2e180b57c84c49dab011 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 11 May 2023 09:23:48 +0800 -Subject: [PATCH 13/15] add support query ip/guid entries - -The function of reading IP and guid entries through the imp command is added. - -Signed-off-by: Jianqiang Li ---- - net/ub/ub_unic/hikp_unic_ppp.c | 468 +++++++++++++++++++++++++++++++++ - net/ub/ub_unic/hikp_unic_ppp.h | 139 ++++++++++ - 2 files changed, 607 insertions(+) - create mode 100644 net/ub/ub_unic/hikp_unic_ppp.c - create mode 100644 net/ub/ub_unic/hikp_unic_ppp.h - -diff --git a/net/ub/ub_unic/hikp_unic_ppp.c b/net/ub/ub_unic/hikp_unic_ppp.c -new file mode 100644 -index 0000000..5325b03 ---- /dev/null -+++ b/net/ub/ub_unic/hikp_unic_ppp.c -@@ -0,0 +1,468 @@ -+/* -+ * Copyright (c) 2023 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 -+#include -+#include -+#include -+#include -+#include "hikp_unic_ppp.h" -+ -+static struct hikp_unic_ppp_hw_resources g_unic_ppp_hw_res = { 0 }; -+static struct unic_ppp_param g_unic_ppp_param = { 0 }; -+ -+static void hikp_unic_ppp_show_ip_tbl(const void *data); -+static void hikp_unic_ppp_show_guid_tbl(const void *data); -+ -+static int hikp_unic_query_ppp_ip_tbl(struct hikp_cmd_header *req_header, -+ const struct bdf_t *bdf, void *data); -+static int hikp_unic_query_ppp_guid_tbl(struct hikp_cmd_header *req_header, -+ const struct bdf_t *bdf, void *data); -+ -+static const struct unic_ppp_feature_cmd g_unic_ppp_feature_cmd[] = { -+ { UNIC_PPP_IP_TBL_NAME, UNIC_IP_TBL_DUMP, true, -+ hikp_unic_query_ppp_ip_tbl, hikp_unic_ppp_show_ip_tbl }, -+ { UNIC_PPP_GUID_TBL_NAME, UNIC_GUID_TBL_DUMP, true, -+ hikp_unic_query_ppp_guid_tbl, hikp_unic_ppp_show_guid_tbl }, -+}; -+ -+static int hikp_unic_ppp_cmd_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); -+ printf(" %s, %-25s %s\n", "-i", "--interface=", -+ "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); -+ printf(" %s, %-24s %s\n", "-du", "--dump", "dump ip or guid table info."); -+ -+ return 0; -+} -+ -+static int hikp_unic_cmd_get_ppp_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_unic_ppp_param.target)); -+ if (self->err_no != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "unknown device!"); -+ return self->err_no; -+ } -+ -+ return 0; -+} -+ -+static int hikp_unic_cmd_ppp_feature_select(struct major_cmd_ctrl *self, const char *argv) -+{ -+ size_t feat_size = HIKP_ARRAY_SIZE(g_unic_ppp_feature_cmd); -+ size_t i; -+ -+ for (i = 0; i < feat_size; i++) { -+ if (strncmp(argv, g_unic_ppp_feature_cmd[i].feature_name, -+ HIKP_UNIC_PPP_MAX_FEATURE_NAME_LEN) == 0) { -+ g_unic_ppp_param.feature_idx = i; -+ return 0; -+ } -+ } -+ -+ hikp_unic_ppp_cmd_help(self, NULL); -+ snprintf(self->err_str, sizeof(self->err_str), "please input valid dump type."); -+ self->err_no = -EINVAL; -+ -+ return self->err_no; -+} -+ -+static int hikp_unic_ppp_get_blk(struct hikp_cmd_header *req_header, -+ const struct unic_ppp_req_para *req_data, void *buf, -+ size_t buf_len, struct unic_ppp_rsp_head *rsp_head) -+{ -+ struct hikp_cmd_ret *cmd_ret; -+ struct unic_ppp_rsp *rsp; -+ int ret = 0; -+ -+ cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data)); -+ if (cmd_ret == NULL || cmd_ret->status != 0) { -+ ret = -EIO; -+ goto out; -+ } -+ -+ rsp = (struct unic_ppp_rsp *)cmd_ret->rsp_data; -+ if (rsp->rsp_head.cur_blk_size > buf_len) { -+ HIKP_ERROR_PRINT("unic_ppp block context copy size error, " -+ "buffer size=%llu, data size=%u.\n", -+ buf_len, rsp->rsp_head.cur_blk_size); -+ ret = -EINVAL; -+ goto out; -+ } -+ memcpy(buf, rsp->rsp_data, rsp->rsp_head.cur_blk_size); -+ memcpy(rsp_head, &rsp->rsp_head, sizeof(struct unic_ppp_rsp_head)); -+ -+out: -+ free(cmd_ret); -+ return ret; -+} -+ -+static int hikp_unic_query_ppp_by_blkid(struct hikp_cmd_header *req_header, const struct bdf_t *bdf, -+ void *data, size_t len) -+{ -+ struct unic_ppp_rsp_head rsp_head = { 0 }; -+ struct unic_ppp_req_para req_data = { 0 }; -+ uint32_t total_blk_size; -+ uint8_t blk_id = 0; -+ int ret = 0; -+ -+ req_data.bdf = *bdf; -+ req_data.block_id = blk_id; -+ ret = hikp_unic_ppp_get_blk(req_header, &req_data, data, len, &rsp_head); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Fail to get block-%u context.\n", blk_id); -+ return ret; -+ } -+ total_blk_size = rsp_head.cur_blk_size; -+ -+ for (blk_id = 1; blk_id < rsp_head.total_blk_num; blk_id++) { -+ req_data.block_id = blk_id; -+ ret = hikp_unic_ppp_get_blk(req_header, &req_data, (uint8_t *)data + total_blk_size, -+ len - total_blk_size, &rsp_head); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Fail to get block-%u context.\n", blk_id); -+ return ret; -+ } -+ total_blk_size += rsp_head.cur_blk_size; -+ } -+ -+ return ret; -+} -+ -+static int hikp_unic_get_ppp_entry_hw_res(const struct bdf_t *bdf, -+ struct hikp_unic_ppp_hw_resources *hw_res) -+{ -+ struct hikp_cmd_header req_header = { 0 }; -+ -+ hikp_cmd_init(&req_header, UB_MOD, GET_UNIC_PPP_CMD, UNIC_PPP_ENTRY_HW_SPEC_GET); -+ return hikp_unic_query_ppp_by_blkid(&req_header, bdf, hw_res, -+ sizeof(struct hikp_unic_ppp_hw_resources)); -+} -+ -+static int hikp_unic_ppp_alloc_ip_tbl_entry(const struct hikp_unic_ppp_hw_resources *hw_res, -+ struct unic_ip_tbl *ip_tbl) -+{ -+ uint32_t max_ip_entry_size; -+ -+ max_ip_entry_size = hw_res->ip_max_mem_size + hw_res->ip_overflow_size; -+ if (max_ip_entry_size == 0) { -+ HIKP_ERROR_PRINT("ip tbl query is not supported\n"); -+ return -EIO; -+ } -+ ip_tbl->entry = (struct unic_ip_entry *)calloc(max_ip_entry_size, -+ sizeof(struct unic_ip_entry)); -+ if (ip_tbl->entry == NULL) { -+ HIKP_ERROR_PRINT("fail to alloc ip_table_entry memory.\n"); -+ return -ENOMEM; -+ } -+ -+ return 0; -+} -+ -+static int hikp_unic_ppp_alloc_guid_tbl_entry(const struct hikp_unic_ppp_hw_resources *hw_res, -+ struct unic_guid_tbl *guid_tbl) -+{ -+ if (hw_res->uc_guid_tbl_size == 0 && hw_res->mc_guid_tbl_size == 0) { -+ HIKP_ERROR_PRINT("guid tbl query is not supported\n"); -+ return -EIO; -+ } -+ guid_tbl->uc_tbl.entry = (struct unic_guid_uc_entry *)calloc(hw_res->uc_guid_tbl_size, -+ sizeof(struct unic_guid_uc_entry)); -+ if (guid_tbl->uc_tbl.entry == NULL) { -+ HIKP_ERROR_PRINT("fail to alloc uc_guid_entry_table memory.\n"); -+ return -ENOMEM; -+ } -+ -+ guid_tbl->mc_tbl.entry = (struct unic_guid_mc_entry *)calloc(hw_res->mc_guid_tbl_size, -+ sizeof(struct unic_guid_mc_entry)); -+ if (guid_tbl->mc_tbl.entry == NULL) { -+ HIKP_ERROR_PRINT("fail to alloc mc_guid_entry_table memory.\n"); -+ free(guid_tbl->uc_tbl.entry); -+ return -ENOMEM; -+ } -+ -+ return 0; -+} -+ -+static union unic_ppp_feature_info* -+hikp_unic_ppp_data_alloc(const struct unic_ppp_feature_cmd *unic_ppp_cmd, -+ const struct hikp_unic_ppp_hw_resources *hw_res) -+{ -+ union unic_ppp_feature_info *unic_ppp_data; -+ int ret = -1; -+ -+ unic_ppp_data = (union unic_ppp_feature_info *)calloc(1, -+ sizeof(union unic_ppp_feature_info)); -+ if (unic_ppp_data == NULL) { -+ HIKP_ERROR_PRINT("Fail to allocate unic_ppp_feature_info memory.\n"); -+ return NULL; -+ } -+ -+ if (g_unic_ppp_param.feature_idx == UNIC_PPP_IP_FEATURE_IDX) { -+ ret = hikp_unic_ppp_alloc_ip_tbl_entry(hw_res, &unic_ppp_data->ip_tbl); -+ } else if (g_unic_ppp_param.feature_idx == UNIC_PPP_GUID_FEATURE_IDX) { -+ ret = hikp_unic_ppp_alloc_guid_tbl_entry(hw_res, &unic_ppp_data->guid_tbl); -+ } -+ -+ if (ret != 0) { -+ goto out; -+ } -+ -+ return unic_ppp_data; -+out: -+ free(unic_ppp_data); -+ return NULL; -+} -+ -+static int hikp_unic_query_ppp_ip_tbl(struct hikp_cmd_header *req_header, const struct bdf_t *bdf, -+ void *data) -+{ -+ struct unic_ip_tbl *ip_tbl = (struct unic_ip_tbl *)data; -+ struct unic_ppp_rsp_head unic_rsp_head = { 0 }; -+ struct unic_ppp_req_para req_data = { 0 }; -+ uint32_t max_ip_entry_size; -+ uint32_t entry_size = 0; -+ size_t left_buf_len = 0; -+ uint32_t index = 0; -+ int ret = -1; -+ -+ max_ip_entry_size = g_unic_ppp_hw_res.ip_max_mem_size + g_unic_ppp_hw_res.ip_overflow_size; -+ req_data.bdf = *bdf; -+ while (index < max_ip_entry_size) { -+ req_data.cur_entry_idx = index; -+ left_buf_len = sizeof(struct unic_ip_entry) * (max_ip_entry_size - entry_size); -+ ret = hikp_unic_ppp_get_blk(req_header, &req_data, ip_tbl->entry + entry_size, -+ left_buf_len, &unic_rsp_head); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Fail to get the ip entry after index=%u, ret=%d.\n", -+ index, ret); -+ return ret; -+ } -+ entry_size += unic_rsp_head.cur_blk_entry_cnt; -+ index = unic_rsp_head.next_entry_idx; -+ } -+ ip_tbl->entry_size = entry_size; -+ -+ return ret; -+} -+ -+static int hikp_unic_query_ppp_guid_tbl(struct hikp_cmd_header *req_header, -+ const struct bdf_t *bdf, void *data) -+{ -+ struct unic_guid_tbl *guid_tbl = (struct unic_guid_tbl*)data; -+ struct unic_ppp_rsp_head unic_rsp_head = { 0 }; -+ struct unic_ppp_req_para req_data = { 0 }; -+ uint32_t entry_size = 0; -+ size_t left_buf_len = 0; -+ uint32_t index = 0; -+ int ret = -1; -+ -+ req_data.bdf = *bdf; -+ req_data.is_unicast = 1; -+ while (index < g_unic_ppp_hw_res.uc_guid_tbl_size) { -+ req_data.cur_entry_idx = index; -+ left_buf_len = sizeof(struct unic_guid_uc_entry) * -+ (g_unic_ppp_hw_res.uc_guid_tbl_size - entry_size); -+ ret = hikp_unic_ppp_get_blk(req_header, &req_data, -+ guid_tbl->uc_tbl.entry + entry_size, -+ left_buf_len, &unic_rsp_head); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Fail to get the uc_guid entry after index=%u, ret=%d.\n", -+ index, ret); -+ return ret; -+ } -+ entry_size += unic_rsp_head.cur_blk_entry_cnt; -+ index = unic_rsp_head.next_entry_idx; -+ } -+ guid_tbl->uc_tbl.entry_size = entry_size; -+ -+ left_buf_len = 0; -+ entry_size = 0; -+ index = 0; -+ req_data.is_unicast = 0; -+ -+ while (index < g_unic_ppp_hw_res.mc_guid_tbl_size) { -+ req_data.cur_entry_idx = index; -+ left_buf_len = sizeof(struct unic_guid_mc_entry) * -+ (g_unic_ppp_hw_res.mc_guid_tbl_size - entry_size); -+ ret = hikp_unic_ppp_get_blk(req_header, &req_data, -+ guid_tbl->mc_tbl.entry + entry_size, -+ left_buf_len, &unic_rsp_head); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Fail to get the mc_guid entry after index=%u, ret=%d.\n", -+ index, ret); -+ return ret; -+ } -+ entry_size += unic_rsp_head.cur_blk_entry_cnt; -+ index = unic_rsp_head.next_entry_idx; -+ } -+ guid_tbl->mc_tbl.entry_size = entry_size; -+ -+ return ret; -+} -+ -+static void hikp_unic_ppp_show_ip_tbl(const void *data) -+{ -+ struct unic_ip_tbl *ip_tbl = (struct unic_ip_tbl *)data; -+ struct unic_ip_entry *entry; -+ uint16_t *ip_addr_tbl_str; -+ int i, j; -+ -+ printf("ip_table_size = %u\n", ip_tbl->entry_size); -+ printf("index\t| func_id\t| ip_addr\n"); -+ for (i = 0; i < ip_tbl->entry_size; i++) { -+ entry = &ip_tbl->entry[i]; -+ ip_addr_tbl_str = (uint16_t *)entry->ip_addr; -+ printf("%-4u\t| %-3u\t\t| ", entry->index, entry->function_id); -+ for (j = 0; j < IP_ADDR_TBL_LEN - 1; j++) -+ printf("%04x:" , ntohs(ip_addr_tbl_str[j])); -+ printf("%04x\n", ntohs(ip_addr_tbl_str[IP_ADDR_TBL_LEN - 1])); -+ } -+} -+ -+static void hikp_unic_ppp_show_guid_tbl(const void *data) -+{ -+ struct unic_guid_tbl *guid_tbl = (struct unic_guid_tbl *)data; -+ uint32_t cnt; -+ int i; -+ -+ printf("unicast guid num : %u\n", guid_tbl->uc_tbl.entry_size); -+ if (guid_tbl->uc_tbl.entry_size > 0) { -+ printf("| num\t| func id | GUID \n"); -+ for (cnt = 0; cnt < guid_tbl->uc_tbl.entry_size; cnt++) { -+ printf("| %3u\t| %7u | ", cnt, guid_tbl->uc_tbl.entry[cnt].function_id); -+ for (i = 0; i < HIKP_UNIC_GUID_ADDR_LEN - 1; i++) { -+ printf("%02x:", guid_tbl->uc_tbl.entry[cnt].guid_addr[i]); -+ } -+ printf("%02x\n", -+ guid_tbl->uc_tbl.entry[cnt].guid_addr[HIKP_UNIC_GUID_ADDR_LEN - 1]); -+ } -+ } -+ -+ printf("multicast guid num : %u\n", guid_tbl->mc_tbl.entry_size); -+ if (guid_tbl->mc_tbl.entry_size > 0) { -+ printf("| num\t| idx\t| %-48s\t| bitmap\n", "GUID"); -+ for (cnt = 0; cnt < guid_tbl->mc_tbl.entry_size; cnt++) { -+ printf("| %3u\t| %4u\t| ", cnt, guid_tbl->mc_tbl.entry[cnt].idx); -+ for (i = 0; i < HIKP_UNIC_GUID_ADDR_LEN - 1; i++) { -+ printf("%02x:", guid_tbl->mc_tbl.entry[cnt].guid_addr[i]); -+ } -+ printf("%02x\t| ", -+ guid_tbl->mc_tbl.entry[cnt].guid_addr[HIKP_UNIC_GUID_ADDR_LEN - 1]); -+ for (i = HIKP_UNIC_GUID_BITMAP_LEN - 1; i > 0; i--) { -+ printf("%08x:", guid_tbl->mc_tbl.entry[cnt].function_bitmap[i]); -+ } -+ printf("%08x\n", guid_tbl->mc_tbl.entry[cnt].function_bitmap[0]); -+ } -+ } -+} -+ -+static int hikp_unic_ppp_check_input_param(struct major_cmd_ctrl *self, -+ const struct unic_ppp_param *ppp_param) -+{ -+ const struct bdf_t *bdf = &ppp_param->target.bdf; -+ -+ if (bdf->dev_id != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "VF does not support query!"); -+ self->err_no = -EINVAL; -+ return self->err_no; -+ } -+ -+ if (ppp_param->feature_idx == UNIC_PPP_INIT_FEATURE_IDX) { -+ hikp_unic_ppp_cmd_help(self, NULL); -+ snprintf(self->err_str, sizeof(self->err_str), "-du/--dump parameter error!"); -+ self->err_no = -EINVAL; -+ return self->err_no; -+ } -+ -+ return 0; -+} -+ -+static void hikp_unic_ppp_data_free(union unic_ppp_feature_info *unic_ppp_data) -+{ -+ struct unic_guid_tbl *guid_tbl; -+ struct unic_ip_tbl *ip_tbl; -+ -+ if (g_unic_ppp_param.feature_idx == UNIC_PPP_IP_FEATURE_IDX) { -+ ip_tbl = &unic_ppp_data->ip_tbl; -+ free(ip_tbl->entry); -+ } else if (g_unic_ppp_param.feature_idx == UNIC_PPP_GUID_FEATURE_IDX) { -+ guid_tbl = &unic_ppp_data->guid_tbl; -+ free(guid_tbl->uc_tbl.entry); -+ free(guid_tbl->mc_tbl.entry); -+ } -+ -+ free(unic_ppp_data); -+} -+ -+static void hikp_unic_ppp_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ const struct unic_ppp_feature_cmd *unic_ppp_cmd; -+ union unic_ppp_feature_info *unic_ppp_data; -+ struct hikp_cmd_header req_header = {0}; -+ int ret; -+ -+ ret = hikp_unic_ppp_check_input_param(self, &g_unic_ppp_param); -+ if (ret != 0) -+ return; -+ -+ ret = hikp_unic_get_ppp_entry_hw_res(&g_unic_ppp_param.target.bdf, &g_unic_ppp_hw_res); -+ if (ret != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "fail to obtain unic_ppp hardware resources."); -+ self->err_no = ret; -+ return; -+ } -+ -+ unic_ppp_cmd = &g_unic_ppp_feature_cmd[g_unic_ppp_param.feature_idx]; -+ unic_ppp_data = hikp_unic_ppp_data_alloc(unic_ppp_cmd, &g_unic_ppp_hw_res); -+ if (unic_ppp_data == NULL) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "failed to allocate unic_ppp_data memory!"); -+ self->err_no = -ENOMEM; -+ return; -+ } -+ -+ hikp_cmd_init(&req_header, UB_MOD, GET_UNIC_PPP_CMD, unic_ppp_cmd->sub_cmd_code); -+ ret = unic_ppp_cmd->query(&req_header, &g_unic_ppp_param.target.bdf, unic_ppp_data); -+ if (ret != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "failed to query %s info, ret = %d.", unic_ppp_cmd->feature_name, ret); -+ self->err_no = ret; -+ goto out; -+ } -+ -+ printf("############## UNIC_PPP: %s info ############\n", unic_ppp_cmd->feature_name); -+ unic_ppp_cmd->show(unic_ppp_data); -+ printf("#################### END #######################\n"); -+ -+out: -+ hikp_unic_ppp_data_free(unic_ppp_data); -+} -+ -+static void cmd_unic_get_ppp_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ g_unic_ppp_param.feature_idx = UNIC_PPP_INIT_FEATURE_IDX; -+ major_cmd->execute = hikp_unic_ppp_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_unic_ppp_cmd_help); -+ cmd_option_register("-i", "--interface", true, hikp_unic_cmd_get_ppp_target); -+ cmd_option_register("-du", "--dump", true, hikp_unic_cmd_ppp_feature_select); -+} -+ -+HIKP_CMD_DECLARE("unic_ppp", "dump ppp info of unic!", cmd_unic_get_ppp_init); -\ No newline at end of file -diff --git a/net/ub/ub_unic/hikp_unic_ppp.h b/net/ub/ub_unic/hikp_unic_ppp.h -new file mode 100644 -index 0000000..c25fabd ---- /dev/null -+++ b/net/ub/ub_unic/hikp_unic_ppp.h -@@ -0,0 +1,139 @@ -+/* -+ * Copyright (c) 2023 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_UNIC_PPP_H -+#define HIKP_UNIC_PPP_H -+ -+#include "hikp_net_lib.h" -+ -+#define HIKP_UNIC_IP_ADDR_FMT_SIZE 50 -+#define MAX_IP_ADDR_STR_LEN 50 -+#define IP_ADDR_LEN 16 -+#define IP_ADDR_TBL_LEN 8 -+ -+#define HIKP_UNIC_IP_ADDR_LEN 4 -+#define HIKP_UNIC_GUID_BITMAP_LEN 8 -+#define HIKP_UNIC_GUID_ADDR_LEN 16 -+ -+#define UNIC_PPP_MAX_RSP_DATA 57 -+#define HIKP_UNIC_PPP_MAX_FEATURE_NAME_LEN 20 -+ -+#define UNIC_PPP_IP_TBL_NAME "ip" -+#define UNIC_PPP_GUID_TBL_NAME "guid" -+ -+enum unic_ppp_sub_cmd_type { -+ UNIC_PPP_ENTRY_HW_SPEC_GET = 0, -+ UNIC_IP_TBL_DUMP, -+ UNIC_GUID_TBL_DUMP, -+}; -+ -+enum unic_ppp_feature_idx { -+ UNIC_PPP_IP_FEATURE_IDX = 0, -+ UNIC_PPP_GUID_FEATURE_IDX, -+ UNIC_PPP_INIT_FEATURE_IDX = -1, -+}; -+ -+struct hikp_unic_ppp_hw_resources { -+ uint16_t uc_guid_tbl_size; -+ uint16_t mc_guid_tbl_size; -+ uint32_t ip_max_mem_size; -+ uint32_t ip_overflow_size; -+ uint32_t rsv; -+ /* port information */ -+ uint16_t total_func_num; /* contain PF and VF. */ -+ uint16_t abs_func_id_base; /* The absolute func_id of the first VF in this port. */ -+ uint32_t rsv1[11]; -+}; -+ -+struct unic_ip_entry { -+ uint32_t index; -+ uint32_t function_id; -+ uint32_t ip_addr[HIKP_UNIC_IP_ADDR_LEN]; -+}; -+ -+struct unic_ip_tbl { -+ uint32_t entry_size; -+ struct unic_ip_entry *entry; -+}; -+ -+struct unic_guid_uc_entry { -+ uint32_t function_id; -+ uint8_t guid_addr[HIKP_UNIC_GUID_ADDR_LEN]; -+}; -+ -+struct unic_guid_uc_tbl { -+ uint32_t entry_size; -+ struct unic_guid_uc_entry *entry; -+}; -+ -+struct unic_guid_mc_entry { -+ uint32_t idx; -+ uint8_t guid_addr[HIKP_UNIC_GUID_ADDR_LEN]; -+ uint32_t function_bitmap[8]; -+}; -+ -+struct unic_guid_mc_tbl { -+ uint32_t entry_size; -+ struct unic_guid_mc_entry *entry; -+}; -+ -+struct unic_guid_tbl { -+ struct unic_guid_uc_tbl uc_tbl; -+ struct unic_guid_mc_tbl mc_tbl; -+}; -+ -+union unic_ppp_feature_info { -+ struct unic_guid_tbl guid_tbl; -+ struct unic_ip_tbl ip_tbl; -+}; -+ -+struct unic_ppp_feature_cmd { -+ const char feature_name[HIKP_UNIC_PPP_MAX_FEATURE_NAME_LEN]; -+ uint32_t sub_cmd_code; -+ bool need_query_hw_res; -+ int (*query)(struct hikp_cmd_header *req_header, -+ const struct bdf_t *bdf, void *data); -+ void (*show)(const void *data); -+}; -+ -+struct unic_ppp_param { -+ struct tool_target target; -+ int feature_idx; -+}; -+ -+struct unic_ppp_req_para { -+ struct bdf_t bdf; -+ uint8_t block_id; -+ union { -+ uint8_t is_unicast; /* 1: uc GUID, 0: mc GUID. */ -+ uint8_t rsv; /* firmware ignores it if isn't used to query GUID table. */ -+ }; -+ uint8_t rsv1[2]; -+ uint32_t cur_entry_idx; /* firmware queries GUID/IP table from the value. */ -+}; -+ -+struct unic_ppp_rsp_head { -+ uint8_t total_blk_num; -+ uint8_t cur_blk_size; /* real data size, not contain head size. */ -+ uint16_t rsv; -+ /* firmware must set following fields when query GUID/IP table. */ -+ uint32_t next_entry_idx; -+ uint32_t cur_blk_entry_cnt; -+}; -+ -+typedef struct unic_ppp_rsp { -+ struct unic_ppp_rsp_head rsp_head; /* 12 Byte */ -+ uint32_t rsp_data[UNIC_PPP_MAX_RSP_DATA]; -+} unic_ppp_rsp_t; -+ -+#endif /* HIKP_UNIC_PPP_H */ --- -2.36.1.windows.1 - diff --git a/0023-hikptool-delete-redundant-copyright-notices.patch b/0023-hikptool-delete-redundant-copyright-notices.patch deleted file mode 100644 index 5e0529a0a8bf4bb268d1dcbe063d8044abc2b964..0000000000000000000000000000000000000000 --- a/0023-hikptool-delete-redundant-copyright-notices.patch +++ /dev/null @@ -1,53 +0,0 @@ -From a170acb3dc9203cd1d9708c9834640df0a916f72 Mon Sep 17 00:00:00 2001 -From: veega -Date: Tue, 16 May 2023 10:39:39 +0800 -Subject: [PATCH] hikptool: delete redundant copyright notices - -Delete redundant copyright notices in hikp_ub_link.h - -Signed-off-by: veega ---- - net/ub/ub_link/hikp_ub_link.h | 13 ------------- - tool_lib/tool_lib.h | 2 +- - 2 files changed, 1 insertion(+), 14 deletions(-) - -diff --git a/net/ub/ub_link/hikp_ub_link.h b/net/ub/ub_link/hikp_ub_link.h -index 14ee912..7c71cb2 100644 ---- a/net/ub/ub_link/hikp_ub_link.h -+++ b/net/ub/ub_link/hikp_ub_link.h -@@ -11,19 +11,6 @@ - * See the Mulan PSL v2 for more details. - */ - --/* -- * Copyright (c) 2023 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_UB_LINK_H - #define HIKP_UB_LINK_H - -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index 9766a7e..6548b57 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.0.15" -+#define TOOL_VER "1.0.16" - - #define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask)) - #define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift)) --- -2.36.1.windows.1 - diff --git a/0024-hikptool-add-pm-trace.patch b/0024-hikptool-add-pm-trace.patch deleted file mode 100644 index 09ad6bb18c217620b4b2eb68ce37587aee01dd76..0000000000000000000000000000000000000000 --- a/0024-hikptool-add-pm-trace.patch +++ /dev/null @@ -1,343 +0,0 @@ -From c28cf6381c20a707a2898503677facf304896752 Mon Sep 17 00:00:00 2001 -From: Bingquan Mou -Date: Wed, 28 Jun 2023 11:13:03 +0800 -Subject: [PATCH] hikptool: the PM trace function is added to the PCIe module. - -The pm trace function of the PCIe module is added to improve the DFX. - -Signed-off-by: Bingquan Mou ---- - pcie/func_lib/pcie_func/pcie_common.h | 1 + - pcie/func_lib/pcie_func/pcie_link_ltssm.c | 180 +++++++++++++++++++++ - pcie/func_lib/pcie_func/pcie_link_ltssm.h | 7 + - pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c | 17 +- - pcie/usr_cmd/interface/pcie_common_api.c | 1 + - pcie/usr_cmd/interface/pcie_common_api.h | 1 + - 6 files changed, 205 insertions(+), 2 deletions(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_common.h b/pcie/func_lib/pcie_func/pcie_common.h -index 434b4ed..98d9e25 100644 ---- a/pcie/func_lib/pcie_func/pcie_common.h -+++ b/pcie/func_lib/pcie_func/pcie_common.h -@@ -28,6 +28,7 @@ enum pcie_trace_cmd_type { - TRACE_CLEAR = 2, - TRACE_INFO = 3, - TRACE_MODE = 4, -+ TRACE_PM = 5, - }; - - enum pcie_info_cmd_type { -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.c b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -index d57688b..9c4b70c 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.c -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -@@ -43,6 +43,31 @@ union ltssm_state_reg { - uint64_t val; - }; - -+union pm_state_reg { -+ struct { -+ uint64_t pm_state : 6; /* [0:5] */ -+ uint64_t pm_clock : 18; /* [6:23] */ -+ uint64_t reserved1 : 8; /* [24:31] */ -+ uint64_t refclk_stable_vld : 1; /* [32] */ -+ uint64_t enter_l12_case : 1; /* [33] */ -+ uint64_t pm_t_dl_l2_gnt_timeout : 1; /* [34] */ -+ uint64_t pm_t_dl_l1_gnt_timeout : 1; /* [35] */ -+ uint64_t pm_t_dl_l0s_gnt_timeout : 1; /* [36] */ -+ uint64_t pm_t_dl_lastack_timeout : 1; /* [37] */ -+ uint64_t pme_turn_off_vld_hold : 1; /* [38] */ -+ uint64_t pm_blk_tlp_timeout : 1; /* [39] */ -+ uint64_t aspm_nak_vld : 1; /* [40] */ -+ uint64_t retrain_link_vld : 1; /* [41] */ -+ uint64_t pending_dllp_vld : 1; /* [42] */ -+ uint64_t pm_wakeup_tol0_en : 1; /* [43] */ -+ uint64_t mac2pm_rx_data_vld : 1; /* [44] */ -+ uint64_t dfe_req : 1; /* [45] */ -+ uint64_t pm_t_dfe_time_meet : 1; /* [46] */ -+ uint64_t reserved2 : 17; /* [47:63] */ -+ } bits; -+ uint64_t val; -+}; -+ - static int pcie_get_ltssm_trace(uint32_t port_id, uint64_t *ltssm_status, uint32_t *ltssm_num) - { - struct hikp_cmd_header req_header; -@@ -280,3 +305,158 @@ free_cmd_ret: - - return ret; - } -+ -+static int pcie_get_pm_trace(uint32_t port_id, uint64_t *pm_status, uint32_t *pm_num) -+{ -+ struct hikp_cmd_header req_header; -+ struct hikp_cmd_ret *cmd_ret = NULL; -+ struct pcie_trace_req_para req_data = { 0 }; -+ size_t src_size, dst_size; -+ int ret; -+ -+ req_data.port_id = port_id; -+ hikp_cmd_init(&req_header, PCIE_MOD, PCIE_TRACE, TRACE_PM); -+ cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -+ ret = hikp_rsp_normal_check(cmd_ret); -+ if (ret) { -+ Err("PCIe Base", "pcie pm trace cmd_ret check failed, ret: %d.\n", ret); -+ goto free_cmd_ret; -+ } -+ -+ if (cmd_ret->rsp_data_num == 0) { -+ Err("PCIe Base", "without rsp data.\n"); -+ ret = -EINVAL; -+ goto free_cmd_ret; -+ } -+ /* 0: First uint32_t is pm trace num received from TF */ -+ *pm_num = cmd_ret->rsp_data[0]; -+ -+ if ((cmd_ret->rsp_data_num - 1) * sizeof(uint32_t) != (*pm_num) * sizeof(uint64_t)) { -+ Err("PCIe Base", "rsp data number check failed, rsp_data_num: %u, pm_num: %u.\n", -+ cmd_ret->rsp_data_num, *pm_num); -+ ret = -EINVAL; -+ goto free_cmd_ret; -+ } -+ -+ src_size = (*pm_num) * sizeof(uint64_t); -+ dst_size = TRACER_DEPTH * sizeof(uint64_t); -+ if (src_size > dst_size) { -+ Err("PCIe Base", "size check failed, %u > %u.\n", src_size, dst_size); -+ ret = -EINVAL; -+ goto free_cmd_ret; -+ } -+ memcpy(pm_status, (cmd_ret->rsp_data + 1), src_size); -+ -+free_cmd_ret: -+ free(cmd_ret); -+ return ret; -+} -+ -+struct pcie_pm_num_string g_pm_string_table[] = { -+ {0x0, "pm_pme_idle"}, -+ {0x1, "pm_wait_dc_pme_msg_send_out"}, -+ {0x2, "pm_wait_dc_tl_enter_l2"}, -+ {0x3, "pm_wait_dc_dl_enter_l2"}, -+ {0x4, "pm_wait_dc_mac_enter_l2"}, -+ {0x5, "pm_dc_enter_l2"}, -+ {0x6, "pm_wait_dc_tl_enter_pcipm_l1"}, -+ {0x7, "pm_wait_dc_dl_enter_pcipm_l1"}, -+ {0x8, "pm_wait_dc_tl_enter_aspm_l1"}, -+ {0x9, "pm_wait_dc_dl_enter_aspm_l1"}, -+ {0xa, "pm_wait_tl_enter_aspm_l0"}, -+ {0xb, "pm_wait_dl_enter_aspm_l0"}, -+ {0xc, "pm_wait_dc_mac_enter_l1"}, -+ {0xd, "pm_wait_mac_enter_l0s"}, -+ {0xe, "pm_device_in_l0s"}, -+ {0xf, "pm_dc_device_in_l1"}, -+ {0x10, "pm_wait_dc_enter_l0"}, -+ {0x11, "pm_wait_uc_tl_enter_l2"}, -+ {0x12, "pm_wait_uc_dl_enter_l2"}, -+ {0x13, "pm_wait_uc_mac_enter_l2"}, -+ {0x15, "pm_wait_uc_tl_enter_pcipm_l1"}, -+ {0x17, "pm_wait_uc_dl_enter_aspm_l1"}, -+ {0x18, "pm_wait_uc_tl_enter_aspm_l1"}, -+ {0x1a, "pm_wait_uc_dl_enter_pcipm_l1"}, -+ {0x1c, "pm_wait_uc_mac_enter_l1"}, -+ {0x1d, "pm_wait_uc_pme_enter_l1_nak_sent_out"}, -+ {0x1e, "pm_wait_uc_enter_l0"}, -+ {0x20, "pm_device_will_enter_l1_substate"}, -+ {0x21, "pm_device_in_l1_1"}, -+ {0x22, "pm_device_will_exit_l1_substate"}, -+ {0x23, "pm_device_in_l1_2_entry"}, -+ {0x24, "pm_device_in_l1_2_idle"}, -+ {0x25, "pm_device_in_l1_2_exit"}, -+ {-1, "unknown"} /* end of array */ -+}; -+ -+static char *hisi_pcie_pm_string_get(uint32_t pm) -+{ -+ int i = 0; -+ -+ while (g_pm_string_table[i].pm >= 0) { -+ if ((uint32_t)g_pm_string_table[i].pm != pm) { -+ i++; -+ continue; -+ } -+ break; -+ } -+ -+ return g_pm_string_table[i].pm_c; -+} -+ -+static int pcie_print_pm_trace(const uint64_t *pm_status, uint32_t pm_num) -+{ -+ uint32_t i; -+ char *pm_c = NULL; -+ union pm_state_reg pm_val; -+ -+ if (pm_num > TRACER_DEPTH || pm_num == 0) { -+ Err("PCIe Base", "pm_num(%u) is over range or zero\n", pm_num); -+ return -EINVAL; -+ } -+ Info("PCIe Base", "pm tracer:\n"); -+ Info("PCIe Base", "\ttrace state: %llx\n", pm_status[0]); -+ Info("PCIe Base", -+ "\tpm[ii]: BE8: 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 " -+ "BD8: 23:6 5:0 : pm state\n"); -+ for (i = 1; i < pm_num; i++) { -+ pm_val.val = pm_status[i]; -+ pm_c = hisi_pcie_pm_string_get((uint32_t)pm_val.bits.pm_state); -+ Info("PCIe Base", -+ "\tpm[%02u]:\t %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x 0x%06x 0x%02x %s\n", -+ i, -+ (uint32_t)pm_val.bits.pm_t_dfe_time_meet, -+ (uint32_t)pm_val.bits.dfe_req, -+ (uint32_t)pm_val.bits.mac2pm_rx_data_vld, -+ (uint32_t)pm_val.bits.pm_wakeup_tol0_en, -+ (uint32_t)pm_val.bits.pending_dllp_vld, -+ (uint32_t)pm_val.bits.retrain_link_vld, -+ (uint32_t)pm_val.bits.aspm_nak_vld, -+ (uint32_t)pm_val.bits.pm_blk_tlp_timeout, -+ (uint32_t)pm_val.bits.pme_turn_off_vld_hold, -+ (uint32_t)pm_val.bits.pm_t_dl_lastack_timeout, -+ (uint32_t)pm_val.bits.pm_t_dl_l0s_gnt_timeout, -+ (uint32_t)pm_val.bits.pm_t_dl_l1_gnt_timeout, -+ (uint32_t)pm_val.bits.pm_t_dl_l2_gnt_timeout, -+ (uint32_t)pm_val.bits.enter_l12_case, -+ (uint32_t)pm_val.bits.refclk_stable_vld, -+ (uint32_t)pm_val.bits.pm_clock, -+ (uint32_t)pm_val.bits.pm_state, -+ pm_c); -+ } -+ -+ return 0; -+} -+ -+int pcie_pm_trace(uint32_t port_id) -+{ -+ int ret; -+ uint32_t pm_num = 0; -+ uint64_t pm_st_save[TRACER_DEPTH]; -+ -+ ret = pcie_get_pm_trace(port_id, pm_st_save, &pm_num); -+ if (ret) -+ return ret; -+ -+ return pcie_print_pm_trace(pm_st_save, pm_num); -+} -\ No newline at end of file -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.h b/pcie/func_lib/pcie_func/pcie_link_ltssm.h -index eb57ead..8f3502b 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.h -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.h -@@ -18,12 +18,18 @@ - - #define TRACE_STR_NUM 0x20 - #define TRACER_DEPTH 65 -+#define PM_TRACE_STR_NUM 0x28 - - struct pcie_ltssm_num_string { - int ltssm; - char ltssm_c[TRACE_STR_NUM]; - }; - -+struct pcie_pm_num_string { -+ int pm; -+ char pm_c[PM_TRACE_STR_NUM]; -+}; -+ - struct pcie_trace_req_para { - uint32_t port_id; - uint32_t trace_mode; -@@ -51,5 +57,6 @@ int pcie_ltssm_trace_show(uint32_t port_id); - int pcie_ltssm_trace_clear(uint32_t port_id); - int pcie_ltssm_trace_mode_set(uint32_t port_id, uint32_t mode); - int pcie_ltssm_link_status_get(uint32_t port_id); -+int pcie_pm_trace(uint32_t port_id); - - #endif -diff --git a/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c b/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c -index e50b434..8ceb85a 100644 ---- a/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c -+++ b/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c -@@ -37,6 +37,7 @@ static int pcie_trace_help(struct major_cmd_ctrl *self, const char *argv) - printf(" %s, %-25s %s\n", "-m", "--mode", - "set ltssm trace mode val 1:recver_en 0:recver_dis\n"); - printf(" %s, %-25s %s\n", "-f", "--information", "display link information\n"); -+ printf(" %s, %-25s %s\n", "-pm", "--pm-state", "show pm status\n"); - printf("\n"); - - return 0; -@@ -57,6 +58,13 @@ static int pcie_trace_show(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - -+static int pcie_pm_show(struct major_cmd_ctrl *self, const char *argv) -+{ -+ g_trace_cmd.cmd_type = TRACE_PM; -+ -+ return 0; -+} -+ - static int pcie_trace_mode_set(struct major_cmd_ctrl *self, const char *argv) - { - int ret; -@@ -108,6 +116,8 @@ static int pcie_trace_excute_funs_call(int cmd_type) - return comm_api->ltssm_trace_mode_set(port_id, recover_en); - else if (cmd_type == TRACE_INFO) - return comm_api->ltssm_link_information_get(port_id); -+ else if (cmd_type == TRACE_PM) -+ return comm_api->pm_trace(port_id); - else - return -EINVAL; - } -@@ -120,14 +130,16 @@ static void pcie_trace_execute(struct major_cmd_ctrl *self) - "pcie_trace_show success.", - "pcie_trace_clear success.", - "get mac link information success.", -- "pcie_trace_mode_set success." -+ "pcie_trace_mode_set success.", -+ "pcie_pm_trace success." - }; - const char *err_msg[] = { - "pcie_trace sub command type error.", - "pcie_trace_show error.", - "pcie_trace_clear error.", - "get mac link information error.", -- "pcie_trace_mode_set error." -+ "pcie_trace_mode_set error.", -+ "pcie_pm_trace error" - }; - - ret = pcie_trace_excute_funs_call(g_trace_cmd.cmd_type); -@@ -153,6 +165,7 @@ static void cmd_pcie_trace_init(void) - cmd_option_register("-m", "--mode", true, pcie_trace_mode_set); - cmd_option_register("-f", "--information", false, pcie_link_information_get); - cmd_option_register("-i", "--interface", true, pcie_port_id_set); -+ cmd_option_register("-pm", "--pm-state", false, pcie_pm_show); - } - - HIKP_CMD_DECLARE("pcie_trace", "pcie ltssm trace", cmd_pcie_trace_init); -diff --git a/pcie/usr_cmd/interface/pcie_common_api.c b/pcie/usr_cmd/interface/pcie_common_api.c -index 491daf2..8875481 100644 ---- a/pcie/usr_cmd/interface/pcie_common_api.c -+++ b/pcie/usr_cmd/interface/pcie_common_api.c -@@ -27,6 +27,7 @@ struct pcie_comm_api g_tools_api = { - .err_status_clear = pcie_error_state_clear, - .reg_dump = pcie_dumpreg_do_dump, - .reg_read = pcie_reg_read, -+ .pm_trace = pcie_pm_trace, - }; - - -diff --git a/pcie/usr_cmd/interface/pcie_common_api.h b/pcie/usr_cmd/interface/pcie_common_api.h -index 9809575..08d4403 100644 ---- a/pcie/usr_cmd/interface/pcie_common_api.h -+++ b/pcie/usr_cmd/interface/pcie_common_api.h -@@ -37,6 +37,7 @@ struct pcie_comm_api { - int (*err_status_clear)(uint32_t port_id); - int (*reg_dump)(uint32_t port_id, uint32_t dump_level); - int (*reg_read)(uint32_t port_id, uint32_t moudle_id, uint32_t offset); -+ int (*pm_trace)(uint32_t port_id); - }; - - struct pcie_comm_api *pcie_get_comm_api(void); --- -2.33.0 \ No newline at end of file diff --git a/0025-hikptool-add-The-security-compilation-options.patch b/0025-hikptool-add-The-security-compilation-options.patch deleted file mode 100644 index 94cedde5bb6bab24dcb6062f225abd6d149de7f7..0000000000000000000000000000000000000000 --- a/0025-hikptool-add-The-security-compilation-options.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0dfd23227be058ce1618660fbf7e52d7ca6e5f10 Mon Sep 17 00:00:00 2001 -From: veega -Date: Tue, 4 Jul 2023 21:14:47 +0800 -Subject: [PATCH] hikptool: add The security compilation options - -Add -fstack-protector-strong and -D_FORTIFY_SOURCE=2 compiler options -for SP and FS. add -s link options for Strip. - -Signed-off-by: veega ---- - CMakeLists.txt | 6 +++--- - libhikptdev/src/rciep/CMakeLists.txt | 4 +++- - 2 files changed, 6 insertions(+), 4 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 174dd8f..cbd063c 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -11,8 +11,8 @@ - - project(hikptool C) - --set(CMAKE_C_FLAGS -- "${CMAKE_C_FLAGS} -O2 -fPIC -fPIE -Wall -Wextra -fno-common -std=gnu11 -Wfloat-equal") -+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -fPIC -fPIE -Wall -Wextra -fno-common -std=gnu11") -+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-equal -fstack-protector-strong -D_FORTIFY_SOURCE=2") - set(CMAKE_SKIP_RPATH TRUE) - - macro(get_header_dir_recurse HEADER_DIR_LIST) -@@ -46,5 +46,5 @@ target_link_directories(hikptool PRIVATE ${CMAKE_INSTALL_PREFIX}/lib) - target_link_libraries(hikptool PRIVATE KPTDEV_SO) - target_link_options(hikptool PRIVATE - -Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIE -pie -- -g -lpthread -ldl -lm -lrt -T ${CMAKE_CURRENT_SOURCE_DIR}/hikp_register.ld) -+ -s -lpthread -ldl -lm -lrt -T ${CMAKE_CURRENT_SOURCE_DIR}/hikp_register.ld) - install(TARGETS hikptool RUNTIME DESTINATION bin OPTIONAL) -diff --git a/libhikptdev/src/rciep/CMakeLists.txt b/libhikptdev/src/rciep/CMakeLists.txt -index b96d621..5017f5b 100644 ---- a/libhikptdev/src/rciep/CMakeLists.txt -+++ b/libhikptdev/src/rciep/CMakeLists.txt -@@ -17,5 +17,7 @@ add_library(KPTDEV_SO SHARED hikpt_rciep.c) - - target_include_directories(KPTDEV_SO PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include) - -+target_link_options(KPTDEV_SO PRIVATE -Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIE -pie -s) -+ - set_target_properties(KPTDEV_SO PROPERTIES OUTPUT_NAME ${KPTDEV_SO_NAME} SOVERSION 1 VERSION 1.0.0) --install(TARGETS KPTDEV_SO LIBRARY DESTINATION lib OPTIONAL) -\ No newline at end of file -+install(TARGETS KPTDEV_SO LIBRARY DESTINATION lib OPTIONAL) --- -2.36.1.windows.1 - diff --git a/0026-hikptool-nic_port-cmd-add-print-arb-info-and-phy-inf.patch b/0026-hikptool-nic_port-cmd-add-print-arb-info-and-phy-inf.patch deleted file mode 100644 index c70d7c54ff5cce1fb1690c288baa2ad2706f620e..0000000000000000000000000000000000000000 --- a/0026-hikptool-nic_port-cmd-add-print-arb-info-and-phy-inf.patch +++ /dev/null @@ -1,61 +0,0 @@ -From a5b22e528f0fc0332d736b428e519c6b936e9766 Mon Sep 17 00:00:00 2001 -From: veega -Date: Thu, 13 Jul 2023 12:06:13 +0800 -Subject: [PATCH] hikptool: nic_port cmd add print arb info and phy info - -Add arbitration information print in port ARB LINK INFO display area, and PHY -INFO display area for print PHY config and regs. - -Signed-off-by: veega ---- - net/nic/nic_mac/hikp_nic_port.c | 4 +++- - net/nic/nic_mac/hikp_nic_port.h | 4 ++++ - 2 files changed, 7 insertions(+), 1 deletion(-) - -diff --git a/net/nic/nic_mac/hikp_nic_port.c b/net/nic/nic_mac/hikp_nic_port.c -index 1ff3569..22a6467 100644 ---- a/net/nic/nic_mac/hikp_nic_port.c -+++ b/net/nic/nic_mac/hikp_nic_port.c -@@ -355,6 +355,7 @@ static void mac_cmd_disp_arb_info(const struct mac_cmd_arb_dfx *arb_dfx) - mac_cmd_disp_port_param("Default", &arb_dfx->default_cfg); - mac_cmd_disp_port_param("BIOS", &arb_dfx->bios_cfg); - mac_cmd_disp_port_param("TOOL", &arb_dfx->user_cfg); -+ mac_cmd_disp_port_param("ARB", &arb_dfx->arb_cfg); - mac_cmd_disp_port_param("Final", &arb_dfx->port_cfg); - } - -@@ -443,7 +444,8 @@ static void mac_cmd_port_execute(struct major_cmd_ctrl *self) - } - - port_hw = (struct mac_cmd_port_hardware *)(hw_cmd_ret->rsp_data); -- if (port_hw->port_type == 1) -+ if (port_hw->port_type == HIKP_PORT_TYPE_PHY || -+ port_hw->port_type == HIKP_PORT_TYPE_PHY_SDS) - mask |= MAC_LSPORT_PHY; - - mac_cmd_show_port_dfx(self, mask); -diff --git a/net/nic/nic_mac/hikp_nic_port.h b/net/nic/nic_mac/hikp_nic_port.h -index ac00f55..f6334d0 100644 ---- a/net/nic/nic_mac/hikp_nic_port.h -+++ b/net/nic/nic_mac/hikp_nic_port.h -@@ -95,6 +95,9 @@ enum { - #define HIKP_MAC_PHY_ABI_PAUSE HI_BIT(13) - #define HIKP_MAC_PHY_ABI_ASYM_PAUSE HI_BIT(14) - -+#define HIKP_PORT_TYPE_PHY 1 -+#define HIKP_PORT_TYPE_PHY_SDS 3 -+ - struct mac_item { - uint32_t key; - const char *name; -@@ -151,6 +154,7 @@ struct mac_cmd_arb_dfx { - struct mac_port_param bios_cfg; - struct mac_port_param user_cfg; - struct mac_port_param port_cfg; -+ struct mac_port_param arb_cfg; - }; - - #define MAC_PHY_DFX_REG_NUM 12 --- -2.36.1.windows.1 - diff --git a/0027-hikptool-add-pcie-new-dump.patch b/0027-hikptool-add-pcie-new-dump.patch deleted file mode 100644 index 05bba574b618a54fead29bc9c3f81d171f1aa913..0000000000000000000000000000000000000000 --- a/0027-hikptool-add-pcie-new-dump.patch +++ /dev/null @@ -1,399 +0,0 @@ -From fd2d8a0b59f77d6783d85ac8f1f24e1cac9261e8 Mon Sep 17 00:00:00 2001 -From: Bingquan Mou -Date: Fri, 21 Jul 2023 14:26:53 +0800 -Subject: [PATCH] hikptool: some registers are added to the PCIe module. - -To improve the DFX, some registers need to be dumped and new registers are added. - -Signed-off-by: Bingquan Mou ---- - pcie/func_lib/pcie_func/pcie_link_ltssm.c | 41 ++-- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 235 +++++++++++++++------- - pcie/func_lib/pcie_func/pcie_reg_dump.h | 5 + - 3 files changed, 189 insertions(+), 92 deletions(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.c b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -index 9c4b70c..09d3b5e 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.c -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -@@ -45,25 +45,25 @@ union ltssm_state_reg { - - union pm_state_reg { - struct { -- uint64_t pm_state : 6; /* [0:5] */ -- uint64_t pm_clock : 18; /* [6:23] */ -- uint64_t reserved1 : 8; /* [24:31] */ -- uint64_t refclk_stable_vld : 1; /* [32] */ -- uint64_t enter_l12_case : 1; /* [33] */ -- uint64_t pm_t_dl_l2_gnt_timeout : 1; /* [34] */ -- uint64_t pm_t_dl_l1_gnt_timeout : 1; /* [35] */ -- uint64_t pm_t_dl_l0s_gnt_timeout : 1; /* [36] */ -- uint64_t pm_t_dl_lastack_timeout : 1; /* [37] */ -- uint64_t pme_turn_off_vld_hold : 1; /* [38] */ -- uint64_t pm_blk_tlp_timeout : 1; /* [39] */ -- uint64_t aspm_nak_vld : 1; /* [40] */ -- uint64_t retrain_link_vld : 1; /* [41] */ -- uint64_t pending_dllp_vld : 1; /* [42] */ -- uint64_t pm_wakeup_tol0_en : 1; /* [43] */ -- uint64_t mac2pm_rx_data_vld : 1; /* [44] */ -- uint64_t dfe_req : 1; /* [45] */ -- uint64_t pm_t_dfe_time_meet : 1; /* [46] */ -- uint64_t reserved2 : 17; /* [47:63] */ -+ uint64_t pm_state : 6; /* [0:5] */ -+ uint64_t pm_clock : 18; /* [6:23] */ -+ uint64_t reserved1 : 8; /* [24:31] */ -+ uint64_t refclk_stable_vld : 1; /* [32] */ -+ uint64_t enter_l12_case : 1; /* [33] */ -+ uint64_t pm_t_dl_l2_gnt_timeout : 1; /* [34] */ -+ uint64_t pm_t_dl_l1_gnt_timeout : 1; /* [35] */ -+ uint64_t pm_t_dl_l0s_gnt_timeout : 1; /* [36] */ -+ uint64_t pm_t_dl_lastack_timeout : 1; /* [37] */ -+ uint64_t pme_turn_off_vld_hold : 1; /* [38] */ -+ uint64_t pm_blk_tlp_timeout : 1; /* [39] */ -+ uint64_t aspm_nak_vld : 1; /* [40] */ -+ uint64_t retrain_link_vld : 1; /* [41] */ -+ uint64_t pending_dllp_vld : 1; /* [42] */ -+ uint64_t pm_wakeup_tol0_en : 1; /* [43] */ -+ uint64_t mac2pm_rx_data_vld : 1; /* [44] */ -+ uint64_t dfe_req : 1; /* [45] */ -+ uint64_t pm_t_dfe_time_meet : 1; /* [46] */ -+ uint64_t reserved2 : 17; /* [47:63] */ - } bits; - uint64_t val; - }; -@@ -423,7 +423,8 @@ static int pcie_print_pm_trace(const uint64_t *pm_status, uint32_t pm_num) - pm_val.val = pm_status[i]; - pm_c = hisi_pcie_pm_string_get((uint32_t)pm_val.bits.pm_state); - Info("PCIe Base", -- "\tpm[%02u]:\t %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x 0x%06x 0x%02x %s\n", -+ "\tpm[%02u]:\t %x %x %x %x %x %x %x %x %x %x %x " -+ "%x %x %x %x 0x%06x 0x%02x %s\n", - i, - (uint32_t)pm_val.bits.pm_t_dfe_time_meet, - (uint32_t)pm_val.bits.dfe_req, -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index e10ff7e..aac3843 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -66,6 +66,8 @@ struct pcie_dumpreg_info g_reg_table_tl[] = { - {0, "TL_RX_LOC_TLP_CNT"}, - {0, "TL_RX_ERR_STATUS"}, - {0, "TL_CFGSPACE_BDF"}, -+ {0, "TL_TX_UR_CNT"}, -+ {0, "TL_RX_ERR_STATUS"}, - }; - - struct pcie_dumpreg_info g_reg_table_dl[] = { -@@ -105,6 +107,28 @@ struct pcie_dumpreg_info g_reg_table_mac[] = { - {0, "MAC_REG_FE_INT_RO"}, - {0, "MAC_REG_CE_INT_RO"}, - {0, "MAC_REG_NFE_INT_RO"}, -+ {0, "MAC_REG_EQ_FIX_LP_TX_PRESET"}, -+ {0, "MAC_REG_ESM_32G_EQ_FIX_LP_TX_PRESET"}, -+ {0, "MAC_REG_ADJ_HILINK_MODE_EN"}, -+ {0, "MAC_REG_EQ_OPT_TX_PRESET_1"}, -+ {0, "MAC_REG_LP_GEN3_TX_PRESET_P1_2"}, -+ {0, "MAC_REG_GEN3_EQ_OPT_TX_PRESET_2"}, -+ {0, "MAC_REG_GEN4_EQ_OPT_TX_PRESET_1"}, -+ {0, "MAC_REG_GEN4_EQ_OPT_TX_PRESET_2"}, -+ {0, "MAC_REG_LP_GEN4_TX_PRESET_P1_1"}, -+ {0, "MAC_REG_LP_GEN4_TX_PRESET_P1_2"}, -+ {0, "MAC_REG_DEBUG_PIPE1"}, -+ {0, "MAC_REG_DEBUG_PIPE2"}, -+ {0, "MAC_REG_DEBUG_PIPE3"}, -+ {0, "MAC_REG_DEBUG_PIPE5"}, -+ {0, "MAC_REG_DEBUG_PIPE7"}, -+ {0, "MAC_REG_DEBUG_PIPE8"}, -+ {0, "MAC_REG_DEBUG_PIPE9"}, -+ {0, "MAC_REG_DEBUG_PIPE10"}, -+ {0, "MAC_REG_DEBUG_PIPE11"}, -+ {0, "MAC_LEAVE_L0_INFO"}, -+ {0, "DFX_APB_LANE_ERROR_STATUS_0"}, -+ {0, "DFX_APB_LANE_ERROR_STATUS_1"}, - }; - - struct pcie_dumpreg_info g_reg_table_pcs[] = { -@@ -115,6 +139,8 @@ struct pcie_dumpreg_info g_reg_table_pcs[] = { - HIKP_PCIE_PCS_LANE_TBL_ENTRY(RECV_DET_OR_PWR_CHAGE), - HIKP_PCIE_PCS_LANE_TBL_ENTRY(EQEVAL_STATUS), - HIKP_PCIE_PCS_LANE_TBL_ENTRY(LANE_INTR_STATUS), -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(M_PCS_RPT_REG), -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(MSG_BUS_DFX), - }; - - struct pcie_dumpreg_info g_reg_table_iob_tx[] = { -@@ -141,6 +167,71 @@ struct pcie_dumpreg_info g_reg_table_iob_tx[] = { - {0, "IOB_TX_INT_SEVERITY3"}, - {0, "IOB_TX_INT_SEVERITY4"}, - {0, "IOB_TX_INT_SEVERITY5"}, -+ {0, "IOB_TX_TCS_DEC_ERR_INFO_L"}, -+ {0, "IOB_TX_TCS_DEC_ERR_INFO_H"}, -+ {0, "DFX_IOB_TX_P_CNT_0"}, -+ {0, "DFX_IOB_TX_P_CNT_1"}, -+ {0, "DFX_IOB_TX_P_CNT_2"}, -+ {0, "DFX_IOB_TX_P_CNT_3"}, -+ {0, "DFX_IOB_TX_P_CNT_4"}, -+ {0, "DFX_IOB_TX_NP_CNT_0"}, -+ {0, "DFX_IOB_TX_NP_CNT_1"}, -+ {0, "DFX_IOB_TX_NP_CNT_2"}, -+ {0, "DFX_IOB_TX_NP_CNT_3"}, -+ {0, "DFX_IOB_TX_NP_CNT_4"}, -+ {0, "DFX_IOB_TX_NP_CNT_5"}, -+ {0, "DFX_IOB_TX_NP_CNT_6"}, -+ {0, "DFX_IOB_TX_NP_CNT_7"}, -+ {0, "DFX_IOB_TX_NP_CNT_8"}, -+ {0, "DFX_IOB_TX_NP_CNT_9"}, -+ {0, "DFX_IOB_TX_NP_CNT_10"}, -+ {0, "DFX_IOB_TX_NP_CNT_11"}, -+ {0, "DFX_IOB_TX_CPL_CNT_0"}, -+ {0, "DFX_IOB_TX_CPL_CNT_1"}, -+ {0, "DFX_IOB_TX_CPL_CNT_2"}, -+ {0, "DFX_IOB_TX_REQ_CNT"}, -+ {0, "DFX_IOB_TX_STATUS0"}, -+ {0, "DFX_IOB_TX_STATUS1"}, -+ {0, "DFX_IOB_TX_STATUS2"}, -+ {0, "DFX_IOB_TX_STATUS3"}, -+ {0, "DFX_IOB_TX_STATUS4"}, -+ {0, "DFX_IOB_TX_STATUS5"}, -+ {0, "DFX_IOB_TX_ABNORMAL_CNT_0"}, -+ {0, "DFX_IOB_TX_ABNORMAL_CNT_1"}, -+ {0, "DFX_IOB_TX_ABNORMAL_CNT_2"}, -+ {0, "DFX_IOB_TX_ABNORMAL_CNT_3"}, -+ {0, "DFX_IOB_TX_ERROR0"}, -+ {0, "DFX_IOB_TX_ERROR1"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_0"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_1"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_2"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_3"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_4"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_5"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_6"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_7"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_8"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_9"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_10"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_11"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_12"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_13"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_14"}, -+ {0, "DFX_IOB_TX_TCS_NORMAL_CNT_15"}, -+ {0, "DFX_IOB_TX_TCS_P2P_CNT_0"}, -+ {0, "DFX_IOB_TX_TCS_P2P_CNT_1"}, -+ {0, "DFX_IOB_TX_TCS_P2P_CNT_2"}, -+ {0, "DFX_IOB_TX_TCS_P2P_CNT_3"}, -+ {0, "DFX_IOB_TX_TCS_P2P_CNT_4"}, -+ {0, "DFX_IOB_TX_TCS_P2P_CNT_5"}, -+ {0, "DFX_IOB_TX_TCS_P2P_CNT_6"}, -+ {0, "DFX_IOB_TX_TCS_P2P_CNT_7"}, -+ {0, "DFX_IOB_TX_TCS_ARNORAML_CNT_0"}, -+ {0, "DFX_IOB_TX_TCS_ARNORAML_CNT_1"}, -+ {0, "DFX_IOB_TX_TCS_STATUS0"}, -+ {0, "DFX_IOB_TX_TCS_STATUS1"}, -+ {0, "DFX_IOB_TX_TCS_STATUS2"}, -+ {0, "DFX_IOB_TX_TCS_IDLE"}, - }; - - struct pcie_dumpreg_info g_reg_table_iob_rx[] = { -@@ -150,6 +241,19 @@ struct pcie_dumpreg_info g_reg_table_iob_rx[] = { - {0, "IOB_RX_MSI_MSIX_CTRL_0"}, - {0, "IOB_RX_MSI_MSIX_ADDR_HIGH_0"}, - {0, "IOB_RX_MSI_MSIX_ADDR_LOW_0"}, -+ {0, "DFX_IOB_RX_CNT_RX_REQ"}, -+ {0, "DFX_IOB_RX_CNT_LOC_REQ"}, -+ {0, "DFX_IOB_RX_CNT_SEND_AM"}, -+ {0, "DFX_IOB_RX_CNT_SEND_LOC"}, -+ {0, "DFX_IOB_RX_CNT_RESP_RX"}, -+ {0, "DFX_IOB_RX_CNT_RESP_LOC"}, -+ {0, "DFX_IOB_RX_CNT_RESP_RECV"}, -+ {0, "IOB_RX_INT_STATUS"}, -+ {0, "DFX_IOB_RX_AMB_WR_CNT_0"}, -+ {0, "DFX_IOB_RX_AMB_WR_CNT_1"}, -+ {0, "DFX_IOB_RX_AMB_RD_CNT_0"}, -+ {0, "DFX_IOB_RX_AMB_RD_CNT_1"}, -+ {0, "DFX_IOB_RX_AMB_INT_NUM"}, - }; - - struct pcie_dumpreg_info g_reg_table_ap_glb[] = { -@@ -256,6 +360,30 @@ struct pcie_dumpreg_info g_reg_table_core_glb[] = { - {0, "CORE_INT_FE_MSK_2"}, - {0, "CORE_INT_FE_STATUS_2"}, - {0, "CORE_INT_FE_RO_2"}, -+ {0, "PORT07_LINK_MODE"}, -+ {0, "PORT815_LINK_MODE"}, -+}; -+ -+struct pcie_dumpreg_info g_reg_table_core_tl[] = { -+ {0, "TL_PM_AUTO_EXIT_TIME_VALUE"}, -+ {0, "TL_DFX_PM_CORE_FUNC_EN"}, -+ {0, "TL_PM_DFE_TIME_VALUE"}, -+}; -+ -+struct pcie_dumpreg_info g_reg_table_dfx_core_tl[] = { -+ {0, "TL_TX_ASYN_FIFO_ST"}, -+ {0, "TL_TX_INGRESS_CNT"}, -+ {0, "TL_TX_CTRL_EGRESS_CNT"}, -+ {0, "TL_TX_CFG_CNT"}, -+ {0, "TL_TX_MEM_RD_CNT"}, -+ {0, "TL_TX_MEM_WR_CNT"}, -+ {0, "TL_TX_IO_RD_CNT"}, -+ {0, "TL_TX_IO_WR_CNT"}, -+ {0, "TL_TX_MSG_CNT"}, -+ {0, "TL_TX_CPL_CNT"}, -+ {0, "TL_TX_ATOMIC_CNT"}, -+ {0, "TL_TX_CFG_TX_CNT"}, -+ {0, "TL_TX_GEN_CPL_CNT"}, - }; - - static int pcie_create_dumpreg_log_file(uint32_t port_id, uint32_t dump_level) -@@ -315,73 +443,33 @@ static void pcie_dumpreg_write_value_to_file(const char *reg_name, uint32_t val) - } - } - --static void pcie_dumpreg_save_glb_analysis_log(const uint32_t *data, uint32_t data_num) --{ -- uint32_t item_i, data_i; -- -- data_i = 0; -- /* IOB_TX REG */ -- for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_iob_tx) && -- data_i < data_num; item_i++, data_i++) { -- g_reg_table_iob_tx[item_i].val = data[data_i]; -- pcie_dumpreg_write_value_to_file(g_reg_table_iob_tx[item_i].name, -- g_reg_table_iob_tx[item_i].val); -- } -- /* IOB_RX REG */ -- for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_iob_rx) && -- data_i < data_num; item_i++, data_i++) { -- g_reg_table_iob_rx[item_i].val = data[data_i]; -- pcie_dumpreg_write_value_to_file(g_reg_table_iob_rx[item_i].name, -- g_reg_table_iob_rx[item_i].val); -- } -- /* AP_GLB REG */ -- for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_ap_glb) && -- data_i < data_num; item_i++, data_i++) { -- g_reg_table_ap_glb[item_i].val = data[data_i]; -- pcie_dumpreg_write_value_to_file(g_reg_table_ap_glb[item_i].name, -- g_reg_table_ap_glb[item_i].val); -- } -- /* CORE_GLB REG */ -- for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_core_glb) && -- data_i < data_num; item_i++, data_i++) { -- g_reg_table_core_glb[item_i].val = data[data_i]; -- pcie_dumpreg_write_value_to_file(g_reg_table_core_glb[item_i].name, -- g_reg_table_core_glb[item_i].val); -- } -- /* PCS REG */ -- for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_pcs) && -- data_i < data_num; item_i++, data_i++) { -- g_reg_table_pcs[item_i].val = data[data_i]; -- pcie_dumpreg_write_value_to_file(g_reg_table_pcs[item_i].name, -- g_reg_table_pcs[item_i].val); -- } --} -+struct pcie_dumpreg_table g_dump_info_glb[] = { -+ {HIKP_ARRAY_SIZE(g_reg_table_iob_tx), g_reg_table_iob_tx}, -+ {HIKP_ARRAY_SIZE(g_reg_table_iob_rx), g_reg_table_iob_rx}, -+ {HIKP_ARRAY_SIZE(g_reg_table_ap_glb), g_reg_table_ap_glb}, -+ {HIKP_ARRAY_SIZE(g_reg_table_core_glb), g_reg_table_core_glb}, -+ {HIKP_ARRAY_SIZE(g_reg_table_pcs), g_reg_table_pcs}, -+ {HIKP_ARRAY_SIZE(g_reg_table_core_tl), g_reg_table_core_tl}, -+ {HIKP_ARRAY_SIZE(g_reg_table_dfx_core_tl), g_reg_table_dfx_core_tl}, -+}; - --static void pcie_dumpreg_save_port_analysis_log(uint32_t *data, uint32_t data_num) -+struct pcie_dumpreg_table g_dump_info_port[] = { -+ {HIKP_ARRAY_SIZE(g_reg_table_tl), g_reg_table_tl}, -+ {HIKP_ARRAY_SIZE(g_reg_table_dl), g_reg_table_dl}, -+ {HIKP_ARRAY_SIZE(g_reg_table_mac), g_reg_table_mac}, -+}; -+ -+static void pcie_dumpreg_save_analysis_log(const uint32_t *data, uint32_t data_num, -+ struct pcie_dumpreg_table *table, uint32_t size) - { -- uint32_t item_i, data_i; -- -- data_i = 0; -- /* TL REG */ -- for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_tl) && -- data_i < data_num; item_i++, data_i++) { -- g_reg_table_tl[item_i].val = data[data_i]; -- pcie_dumpreg_write_value_to_file(g_reg_table_tl[item_i].name, -- g_reg_table_tl[item_i].val); -- } -- /* DL REG */ -- for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_dl) && -- data_i < data_num; item_i++, data_i++) { -- g_reg_table_dl[item_i].val = data[data_i]; -- pcie_dumpreg_write_value_to_file(g_reg_table_dl[item_i].name, -- g_reg_table_dl[item_i].val); -- } -- /* MAC REG */ -- for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_mac) && -- data_i < data_num; item_i++, data_i++) { -- g_reg_table_mac[item_i].val = data[data_i]; -- pcie_dumpreg_write_value_to_file(g_reg_table_mac[item_i].name, -- g_reg_table_mac[item_i].val); -+ uint32_t i, j, data_i = 0; -+ -+ for (i = 0; i < size; i++) { -+ struct pcie_dumpreg_info *info = table[i].dump_info; -+ for (j = 0; j < table[i].size && data_i < data_num; j++, data_i++) { -+ info[j].val = data[data_i]; -+ pcie_dumpreg_write_value_to_file(info[j].name, info[j].val); -+ } - } - } - -@@ -420,13 +508,14 @@ static int pcie_dumpreg_save_log(uint32_t *data, uint32_t data_num, - - switch (req_data->level) { - case DUMP_GLOBAL_LEVEL: -- expect_data_num = HIKP_ARRAY_SIZE(g_reg_table_iob_tx) + -- HIKP_ARRAY_SIZE(g_reg_table_iob_rx) + HIKP_ARRAY_SIZE(g_reg_table_ap_glb) + -- HIKP_ARRAY_SIZE(g_reg_table_core_glb) + HIKP_ARRAY_SIZE(g_reg_table_pcs); -+ for (i = 0; i < HIKP_ARRAY_SIZE(g_dump_info_glb); i++) { -+ expect_data_num += g_dump_info_glb[i].size; -+ } - break; - case DUMP_PORT_LEVEL: -- expect_data_num = HIKP_ARRAY_SIZE(g_reg_table_tl) + -- HIKP_ARRAY_SIZE(g_reg_table_dl) + HIKP_ARRAY_SIZE(g_reg_table_mac); -+ for (i = 0; i < HIKP_ARRAY_SIZE(g_dump_info_port); i++) { -+ expect_data_num += g_dump_info_port[i].size; -+ } - break; - default: - Err("PCIe DUMPREG", "check dump level failed.\n"); -@@ -441,9 +530,11 @@ static int pcie_dumpreg_save_log(uint32_t *data, uint32_t data_num, - pcie_dumpreg_write_value_to_file(reg_name, data[i]); - } - } else if (req_data->level == DUMP_GLOBAL_LEVEL) { -- pcie_dumpreg_save_glb_analysis_log(data, data_num); -+ pcie_dumpreg_save_analysis_log(data, data_num, -+ g_dump_info_glb, HIKP_ARRAY_SIZE(g_dump_info_glb)); - } else { -- pcie_dumpreg_save_port_analysis_log(data, data_num); -+ pcie_dumpreg_save_analysis_log(data, data_num, -+ g_dump_info_port, HIKP_ARRAY_SIZE(g_dump_info_port)); - } - - return 0; -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.h b/pcie/func_lib/pcie_func/pcie_reg_dump.h -index 4ec1909..cbea2f6 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.h -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.h -@@ -49,6 +49,11 @@ struct pcie_dump_req_para { - uint32_t level; - }; - -+struct pcie_dumpreg_table { -+ uint32_t size; -+ struct pcie_dumpreg_info *dump_info; -+}; -+ - int pcie_dumpreg_do_dump(uint32_t port_id, uint32_t dump_level); - - #endif --- -2.33.0 - diff --git a/0028-hikptool-add-show-CDR-DFX-info-in-nic_port-cmd.patch b/0028-hikptool-add-show-CDR-DFX-info-in-nic_port-cmd.patch deleted file mode 100644 index 9de95acc5c1151068296bc9c7fcc8f7639e01544..0000000000000000000000000000000000000000 --- a/0028-hikptool-add-show-CDR-DFX-info-in-nic_port-cmd.patch +++ /dev/null @@ -1,201 +0,0 @@ -From c3a11cf422c8edfe07146395c1084fdc45d44486 Mon Sep 17 00:00:00 2001 -From: veega -Date: Wed, 26 Jul 2023 17:35:06 +0800 -Subject: [PATCH] hikptool: add show CDR DFX info in nic_port cmd - -If the port contains CDRs, the nic_port command displays the hardware information of the CDRs, which helps locate port link setup faults. - -Signed-off-by: veega ---- - net/nic/nic_mac/hikp_mac_cmd.h | 1 + - net/nic/nic_mac/hikp_nic_port.c | 72 ++++++++++++++++++++++++++++++++- - net/nic/nic_mac/hikp_nic_port.h | 49 +++++++++++++++++++--- - 3 files changed, 116 insertions(+), 6 deletions(-) - -diff --git a/net/nic/nic_mac/hikp_mac_cmd.h b/net/nic/nic_mac/hikp_mac_cmd.h -index 5f0450a..adaadf4 100644 ---- a/net/nic/nic_mac/hikp_mac_cmd.h -+++ b/net/nic/nic_mac/hikp_mac_cmd.h -@@ -30,6 +30,7 @@ enum mac_port_sub_cmd { - QUERY_PORT_ADAPT_DFX, - QUERY_PORT_PHY_DFX, - QUERY_HOT_PLUG_CARD_DFX, -+ QUERY_PORT_CDR_DFX, - }; - - enum mac_dump_reg_sub_cmd { -diff --git a/net/nic/nic_mac/hikp_nic_port.c b/net/nic/nic_mac/hikp_nic_port.c -index 22a6467..c9f46fc 100644 ---- a/net/nic/nic_mac/hikp_nic_port.c -+++ b/net/nic/nic_mac/hikp_nic_port.c -@@ -405,6 +405,73 @@ static void mac_cmd_show_hot_plug_card(struct major_cmd_ctrl *self) - free(cmd_ret); - } - -+static void mac_cmd_print_cdr_dfx(struct mac_cmd_cdr_dfx *cdr_dfx, struct mac_port_cdr_dfx *info) -+{ -+ struct mac_item type_table[] = { -+ {PORT_CDR_TYPE_A, "cdr_a"}, {PORT_CDR_TYPE_B, "cdr_b"}, -+ }; -+ struct mac_item cdr_a_mode[] = { -+ {CDR_A_MODE_2PLL, "2pll"}, {CDR_A_MODE_FASTPI, "fastpi"}, -+ }; -+ struct mac_item cdr_b_mode[] = { -+ {CDR_B_MODE_PCS, "pcs"}, {CDR_B_MODE_CDR, "cdr"}, -+ }; -+ struct mac_item status_table[] = { -+ {CDR_STATUS_NORMAL, "normal"}, {CDR_STATUS_ERROR, "error"}, -+ }; -+ const char *type_str = mac_get_str(cdr_dfx->cdr_type, -+ type_table, HIKP_ARRAY_SIZE(type_table), "unknown"); -+ const char *mode_str = "NA"; -+ -+ for (uint32_t i = 0; i < cdr_dfx->cdr_num; i++) { -+ if (cdr_dfx->cdr_type == PORT_CDR_TYPE_A) { -+ mode_str = mac_get_str(info->dfx[i].cdr_mode, cdr_a_mode, -+ HIKP_ARRAY_SIZE(cdr_a_mode), "unknown"); -+ } else if (cdr_dfx->cdr_type == PORT_CDR_TYPE_B) { -+ mode_str = mac_get_str(info->dfx[i].cdr_mode, cdr_b_mode, -+ HIKP_ARRAY_SIZE(cdr_b_mode), "unknown"); -+ } -+ printf("\t|0x%-8x%-9u%-10s%-10s%-10s\n", info->dfx[i].cdr_addr, -+ info->dfx[i].cdr_start_lane, type_str, mode_str, -+ mac_get_str(info->dfx[i].cdr_err, -+ status_table, HIKP_ARRAY_SIZE(status_table), "unknown")); -+ } -+} -+ -+static void mac_cmd_disp_cdr_info(struct mac_cmd_cdr_dfx *cdr_dfx) -+{ -+ if (!cdr_dfx->cdr_num) -+ return; -+ -+ printf("\n======================== PORT CDR INFO =======================\n"); -+ printf("direct\t|addr |lane |type |mode |status \n"); -+ printf("----------------------------------------------------------------------------\n"); -+ -+ printf("WIRE"); -+ mac_cmd_print_cdr_dfx(cdr_dfx, &cdr_dfx->wire_cdr); -+ -+ printf("HOST"); -+ mac_cmd_print_cdr_dfx(cdr_dfx, &cdr_dfx->host_cdr); -+} -+ -+static void mac_cmd_show_cdr(struct major_cmd_ctrl *self) -+{ -+ struct mac_cmd_cdr_dfx *cdr_dfx = NULL; -+ struct hikp_cmd_ret *cmd_ret = NULL; -+ int ret; -+ -+ ret = mac_cmd_get_dfx_cfg(QUERY_PORT_CDR_DFX, &cmd_ret); -+ if (ret != 0) { -+ self->err_no = -ENOSPC; -+ snprintf(self->err_str, sizeof(self->err_str), "mac get cdr dfx failed."); -+ return; -+ } -+ -+ cdr_dfx = (struct mac_cmd_cdr_dfx *)(cmd_ret->rsp_data); -+ mac_cmd_disp_cdr_info(cdr_dfx); -+ free(cmd_ret); -+} -+ - static void mac_cmd_show_port_dfx(struct major_cmd_ctrl *self, uint32_t mask) - { - struct mac_cmd_dfx_callback dfx_cb[] = { -@@ -413,6 +480,7 @@ static void mac_cmd_show_port_dfx(struct major_cmd_ctrl *self, uint32_t mask) - {MAC_LSPORT_PHY, mac_cmd_show_phy}, - {MAC_LSPORT_ARB, mac_cmd_show_arb}, - {MAC_HOT_PLUG_CARD, mac_cmd_show_hot_plug_card}, -+ {MAC_LSPORT_CDR, mac_cmd_show_cdr} - }; - size_t size = HIKP_ARRAY_SIZE(dfx_cb); - size_t i; -@@ -425,9 +493,9 @@ static void mac_cmd_show_port_dfx(struct major_cmd_ctrl *self, uint32_t mask) - - static void mac_cmd_port_execute(struct major_cmd_ctrl *self) - { -- uint32_t mask = MAC_LSPORT_LINK | MAC_LSPORT_MAC | MAC_LSPORT_ARB | MAC_HOT_PLUG_CARD; - struct mac_cmd_port_hardware *port_hw = NULL; - struct hikp_cmd_ret *hw_cmd_ret = NULL; -+ uint32_t mask; - int ret; - - if (!g_port_info.port_flag) { -@@ -443,6 +511,8 @@ static void mac_cmd_port_execute(struct major_cmd_ctrl *self) - return; - } - -+ mask = MAC_LSPORT_LINK | MAC_LSPORT_MAC | -+ MAC_LSPORT_ARB | MAC_HOT_PLUG_CARD | MAC_LSPORT_CDR; - port_hw = (struct mac_cmd_port_hardware *)(hw_cmd_ret->rsp_data); - if (port_hw->port_type == HIKP_PORT_TYPE_PHY || - port_hw->port_type == HIKP_PORT_TYPE_PHY_SDS) -diff --git a/net/nic/nic_mac/hikp_nic_port.h b/net/nic/nic_mac/hikp_nic_port.h -index f6334d0..42ab3f9 100644 ---- a/net/nic/nic_mac/hikp_nic_port.h -+++ b/net/nic/nic_mac/hikp_nic_port.h -@@ -16,11 +16,12 @@ - - #include "hikp_net_lib.h" - --#define MAC_LSPORT_LINK HI_BIT(0) --#define MAC_LSPORT_MAC HI_BIT(1) --#define MAC_LSPORT_PHY HI_BIT(2) --#define MAC_LSPORT_ARB HI_BIT(3) --#define MAC_HOT_PLUG_CARD HI_BIT(4) -+#define MAC_LSPORT_LINK HI_BIT(0) -+#define MAC_LSPORT_MAC HI_BIT(1) -+#define MAC_LSPORT_PHY HI_BIT(2) -+#define MAC_LSPORT_ARB HI_BIT(3) -+#define MAC_HOT_PLUG_CARD HI_BIT(4) -+#define MAC_LSPORT_CDR HI_BIT(5) - - enum { - PORT_CFG_NOT_SET = 0, -@@ -186,6 +187,44 @@ struct mac_cmd_phy_info { - struct mac_cmd_phy_dfx phy_dfx; - }; - -+enum { -+ PORT_CDR_TYPE_A = 0, -+ PORT_CDR_TYPE_B, -+}; -+ -+enum { -+ CDR_A_MODE_2PLL = 0, -+ CDR_A_MODE_FASTPI, -+}; -+ -+enum { -+ CDR_B_MODE_PCS = 0, -+ CDR_B_MODE_CDR, -+}; -+ -+enum { -+ CDR_STATUS_NORMAL = 0, -+ CDR_STATUS_ERROR, -+}; -+ -+struct cdr_dfx_info { -+ uint8_t cdr_mode; -+ uint8_t cdr_addr; -+ uint8_t cdr_start_lane; -+ uint8_t cdr_err; /* 0:normal, 1:error */ -+}; -+ -+struct mac_port_cdr_dfx { -+ struct cdr_dfx_info dfx[2]; /* one side reserved max 2 cdr */ -+}; -+ -+struct mac_cmd_cdr_dfx { -+ uint8_t cdr_num; -+ uint8_t cdr_type; -+ struct mac_port_cdr_dfx wire_cdr; -+ struct mac_port_cdr_dfx host_cdr; -+}; -+ - struct mac_cmd_dfx_callback { - uint32_t mask; - void (*show_dfx)(struct major_cmd_ctrl *self); --- -2.36.1.windows.1 diff --git a/0029-hikptool-add-new-cmd-support-query-ncsi-dfx-info.patch b/0029-hikptool-add-new-cmd-support-query-ncsi-dfx-info.patch deleted file mode 100644 index 4696e038f3b278cfae0f4ca6cf170d302bd88b53..0000000000000000000000000000000000000000 --- a/0029-hikptool-add-new-cmd-support-query-ncsi-dfx-info.patch +++ /dev/null @@ -1,227 +0,0 @@ -From 1ba7b82d8f933550dd1552143b77d077b7e4f40a Mon Sep 17 00:00:00 2001 -From: veega -Date: Wed, 9 Aug 2023 20:04:27 +0800 -Subject: [PATCH] hikptool: add new cmd support query ncsi dfx info - -Add nic_ncsi cmd for query nic port number of NCSI packets processed by software. - -Signed-off-by: veega ---- - net/hikp_net_lib.h | 5 ++ - net/nic/nic_ncsi/hikp_nic_ncsi.c | 116 +++++++++++++++++++++++++++++++ - net/nic/nic_ncsi/hikp_nic_ncsi.h | 57 +++++++++++++++ - 3 files changed, 178 insertions(+) - create mode 100644 net/nic/nic_ncsi/hikp_nic_ncsi.c - create mode 100644 net/nic/nic_ncsi/hikp_nic_ncsi.h - -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index af0a51d..ed984ce 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -78,6 +78,7 @@ enum nic_cmd_type { - GET_FD_INFO_CMD, - GET_FEC_INFO_CMD, - GET_GRO_INFO_CMD, -+ GET_NCSI_INFO_CMD, - }; - - enum roh_cmd_type { -@@ -107,6 +108,10 @@ enum ub_cmd_type { - GET_UB_BASIC_INFO_CMD, - }; - -+enum nic_get_ncsi_sub_cmd { -+ NIC_NCSI_GET_DFX_INFO, -+}; -+ - #define HIKP_MAX_PF_NUM 8 - #define HIKP_NIC_MAX_FUNC_NUM 256 - -diff --git a/net/nic/nic_ncsi/hikp_nic_ncsi.c b/net/nic/nic_ncsi/hikp_nic_ncsi.c -new file mode 100644 -index 0000000..d09e16f ---- /dev/null -+++ b/net/nic/nic_ncsi/hikp_nic_ncsi.c -@@ -0,0 +1,116 @@ -+/* -+ * Copyright (c) 2022 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 -+#include "tool_cmd.h" -+#include "hikp_net_lib.h" -+#include "hikptdev_plug.h" -+#include "hikp_nic_ncsi.h" -+ -+static struct nic_ncsi_cmd_info g_ncsi_cmd_info = {0}; -+ -+static void nic_ncsi_cmd_print_dfx_info(struct nic_ncsi_cmd_resp *ncsi_info) -+{ -+ printf("port ncsi: %s\n", ncsi_info->ncsi_en ? "enable" : "disable"); -+ if (!ncsi_info->ncsi_en) -+ return; /* ncsi not enable do not print dfx info */ -+ -+ printf("processing packet statistics\n"); -+ printf("\tncsi_control_total: %u\n", ncsi_info->ncsi_dfx.ncsi_control_total); -+ printf("\tncsi_eth_to_ub_total: %u\n", ncsi_info->ncsi_dfx.ncsi_eth_to_ub_total); -+ printf("\tncsi_ub_to_eth_total: %u\n", ncsi_info->ncsi_dfx.ncsi_ub_to_eth_total); -+ printf("\tncsi_control_good: %u\n", ncsi_info->ncsi_dfx.ncsi_control_good); -+ printf("\tncsi_eth_to_ub_good: %u\n", ncsi_info->ncsi_dfx.ncsi_eth_to_ub_good); -+ printf("\tncsi_ub_to_eth_good: %u\n", ncsi_info->ncsi_dfx.ncsi_ub_to_eth_good); -+ -+ printf("\tncsi_eth_to_ub_arp: %u\n", ncsi_info->ncsi_dfx.ncsi_eth_to_ub_arp); -+ printf("\tncsi_eth_to_ub_free_arp: %u\n", ncsi_info->ncsi_dfx.ncsi_eth_to_ub_free_arp); -+ printf("\tncsi_eth_to_ub_ipv6_ra: %u\n", ncsi_info->ncsi_dfx.ncsi_eth_to_ub_ipv6_ra); -+ printf("\tncsi_eth_to_ub_dhcpv4: %u\n", ncsi_info->ncsi_dfx.ncsi_eth_to_ub_dhcpv4); -+ printf("\tncsi_eth_to_ub_dhcpv6: %u\n", ncsi_info->ncsi_dfx.ncsi_eth_to_ub_dhcpv6); -+ printf("\tncsi_eth_to_ub_lldp: %u\n", ncsi_info->ncsi_dfx.ncsi_eth_to_ub_lldp); -+ -+ printf("\tncsi_ub_to_eth_ipv4: %u\n", ncsi_info->ncsi_dfx.ncsi_ub_to_eth_ipv4); -+ printf("\tncsi_ub_to_eth_ipv6: %u\n", ncsi_info->ncsi_dfx.ncsi_ub_to_eth_ipv6); -+ printf("\tncsi_ub_to_eth_ipnotify: %u\n", ncsi_info->ncsi_dfx.ncsi_ub_to_eth_ipnotify); -+ printf("\tncsi_ub_to_eth_dhcpv4: %u\n", ncsi_info->ncsi_dfx.ncsi_ub_to_eth_dhcpv4); -+ printf("\tncsi_ub_to_eth_dhcpv6: %u\n", ncsi_info->ncsi_dfx.ncsi_ub_to_eth_dhcpv6); -+ printf("\tncsi_ub_to_eth_lldp: %u\n", ncsi_info->ncsi_dfx.ncsi_ub_to_eth_lldp); -+} -+ -+static void nic_ncsi_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ struct hikp_cmd_ret *cmd_resp = NULL; -+ struct hikp_cmd_header req_header = {0}; -+ struct nic_ncsi_cmd_req ncsi_req = {0}; -+ -+ if (!g_ncsi_cmd_info.port_flag) { -+ self->err_no = -EINVAL; -+ snprintf(self->err_str, sizeof(self->err_str), "Need port id."); -+ return; -+ } -+ -+ memcpy(&ncsi_req.bdf, &g_ncsi_cmd_info.target.bdf, sizeof(ncsi_req.bdf)); -+ hikp_cmd_init(&req_header, NIC_MOD, GET_NCSI_INFO_CMD, NIC_NCSI_GET_DFX_INFO); -+ cmd_resp = hikp_cmd_alloc(&req_header, &ncsi_req, sizeof(ncsi_req)); -+ self->err_no = hikp_rsp_normal_check(cmd_resp); -+ if (self->err_no) { -+ snprintf(self->err_str, sizeof(self->err_str), "Get ncsi dfx info failed."); -+ goto ERR_OUT; -+ } -+ -+ nic_ncsi_cmd_print_dfx_info((struct nic_ncsi_cmd_resp *)cmd_resp->rsp_data); -+ -+ERR_OUT: -+ free(cmd_resp); -+ cmd_resp = NULL; -+} -+ -+static int nic_ncsi_cmd_get_port_info(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_ncsi_cmd_info.target); -+ if (self->err_no) { -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); -+ return self->err_no; -+ } -+ g_ncsi_cmd_info.port_flag = true; -+ -+ return 0; -+} -+ -+static int nic_ncsi_cmd_show_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); -+ printf(" %s, %-25s %s\n", "-i", "--interface=", -+ "device target or bdf id, e.g. eth0~3 or 0000:35:00.0"); -+ printf("\n"); -+ -+ return 0; -+} -+ -+static void cmd_nic_get_ncsi_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ g_ncsi_cmd_info.port_flag = false; -+ major_cmd->option_count = 0; -+ major_cmd->execute = nic_ncsi_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, nic_ncsi_cmd_show_help); -+ cmd_option_register("-i", "--interface", true, nic_ncsi_cmd_get_port_info); -+} -+ -+HIKP_CMD_DECLARE("nic_ncsi", "query nic port ncsi information", cmd_nic_get_ncsi_init); -diff --git a/net/nic/nic_ncsi/hikp_nic_ncsi.h b/net/nic/nic_ncsi/hikp_nic_ncsi.h -new file mode 100644 -index 0000000..a391d20 ---- /dev/null -+++ b/net/nic/nic_ncsi/hikp_nic_ncsi.h -@@ -0,0 +1,57 @@ -+/* -+ * Copyright (c) 2022 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_NIC_NCSI_H -+#define HIKP_NIC_NCSI_H -+ -+#include "hikp_net_lib.h" -+ -+struct nic_ncsi_dfx_info { -+ uint16_t ncsi_control_total; -+ uint16_t ncsi_eth_to_ub_total; -+ uint16_t ncsi_ub_to_eth_total; -+ uint16_t ncsi_control_good; -+ uint16_t ncsi_eth_to_ub_good; -+ uint16_t ncsi_ub_to_eth_good; -+ uint16_t ncsi_eth_to_ub_arp; -+ uint16_t ncsi_eth_to_ub_free_arp; -+ uint16_t ncsi_eth_to_ub_ipv6_ra; -+ uint16_t ncsi_eth_to_ub_dhcpv4; -+ uint16_t ncsi_eth_to_ub_dhcpv6; -+ uint16_t ncsi_eth_to_ub_lldp; -+ uint16_t ncsi_ub_to_eth_ipv4; -+ uint16_t ncsi_ub_to_eth_ipv6; -+ uint16_t ncsi_ub_to_eth_ipnotify; -+ uint16_t ncsi_ub_to_eth_dhcpv4; -+ uint16_t ncsi_ub_to_eth_dhcpv6; -+ uint16_t ncsi_ub_to_eth_lldp; -+}; -+ -+struct nic_ncsi_cmd_resp { -+ uint8_t ncsi_en; -+ uint8_t rsv0[3]; -+ struct nic_ncsi_dfx_info ncsi_dfx; -+ uint32_t rsv1[50]; /* max resp data: 240 Bytes */ -+}; -+ -+struct nic_ncsi_cmd_req { -+ struct bdf_t bdf; -+ uint32_t rsv0[30]; /* max req data: 128 Bytes */ -+}; -+ -+struct nic_ncsi_cmd_info { -+ struct tool_target target; -+ bool port_flag; -+}; -+ -+#endif /* HIKP_NIC_NCSI_H */ --- -2.36.1.windows.1 - diff --git a/0030-hikptool-Don-t-show-gen5.patch b/0030-hikptool-Don-t-show-gen5.patch deleted file mode 100644 index d7640e338707be77e791bcefae7edec48bd9013d..0000000000000000000000000000000000000000 --- a/0030-hikptool-Don-t-show-gen5.patch +++ /dev/null @@ -1,30 +0,0 @@ -From cd294fef2bb22262bb43d912cb2eedea7c986f77 Mon Sep 17 00:00:00 2001 -From: Bingquan Mou -Date: Sat, 26 Aug 2023 11:10:51 +0800 -Subject: [PATCH] hikptool: fix don`t show gen5 problem - -The mac_rate field does not support displaying the GEN5 rate. -Therefore, the rxl0s_st field is added to determine the rate together with the mac_rate field. - -Signed-off-by: Bingquan Mou ---- - pcie/func_lib/pcie_func/pcie_link_ltssm.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.c b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -index 09d3b5e..156f4be 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.c -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -@@ -213,7 +213,8 @@ static int pcie_print_ltssm_trace(const uint64_t *ltssm_input, uint32_t ltssm_nu - (uint32_t)ltssm_val.bits.any_change_pipe_req, - (uint32_t)ltssm_val.bits.rxl0s_st, - (uint32_t)ltssm_val.bits.train_bit_map1, -- (uint32_t)ltssm_val.bits.mac_rate, -+ (((uint32_t)ltssm_val.bits.rxl0s_st) << 2) | -+ ((uint32_t)ltssm_val.bits.mac_rate), - (uint32_t)ltssm_val.bits.duration_counter, - (uint32_t)ltssm_val.bits.ltssm_state, - ltssm_c); --- -2.33.0 - diff --git a/0031-hikptool-RDMA-Fix-the-missing-bank-ID-in-roce_trp-GE.patch b/0031-hikptool-RDMA-Fix-the-missing-bank-ID-in-roce_trp-GE.patch deleted file mode 100644 index c8a4a021ef577d02e9b4d39fda4aeb6428863a78..0000000000000000000000000000000000000000 --- a/0031-hikptool-RDMA-Fix-the-missing-bank-ID-in-roce_trp-GE.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 074af28f22f7e3dff9637a6366ad0a1ad1dd2852 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Wed, 30 Aug 2023 09:24:49 +0800 -Subject: hikptool/RDMA: Fix the missing bank ID in roce_trp GEN_AC - -Upstream: Yes - -Currently hikptool only accepts bank ID 0 and 1 for roce_trp GEN_AC. -The firmware then multiplies the bank ID received from hikptool by 2 -and converts it to 0 and 2. But actually there are 4 banks in GEN_AC -and each of them is independent. - -To fix the problem, both hikptool and firmware should be modified. -This patch modifies the bank ID limit form 2 to 4 in hikptool. - -Signed-off-by: Junxian Huang ---- - net/roce/roce_trp/hikp_roce_trp.c | 2 +- - net/roce/roce_trp/hikp_roce_trp.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c -index 8befb06..bf22484 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.c -+++ b/net/roce/roce_trp/hikp_roce_trp.c -@@ -32,7 +32,7 @@ static int hikp_roce_trp_help(struct major_cmd_ctrl *self, const char *argv) - "this is necessary param COMMON/TRP_RX/GEN_AC/PAYL"); - printf(" %s, %-25s %s\n", "-b", "--bank=", - "[option]set which bank to read. (default 0) " -- "COMMON : 0~3\n PAYL: 0~1\n GEN_AC : 0~1\n "); -+ "COMMON : 0~3\n PAYL: 0~1\n GEN_AC : 0~3\n "); - printf("\n"); - - return 0; -diff --git a/net/roce/roce_trp/hikp_roce_trp.h b/net/roce/roce_trp/hikp_roce_trp.h -index db58216..80d28af 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.h -+++ b/net/roce/roce_trp/hikp_roce_trp.h -@@ -25,7 +25,7 @@ - } - #define TRP_MAX_BANK_NUM 0x3 - #define PAYL_MAX_BANK_NUM 0x1 --#define GAC_MAX_BANK_NUM 0x1 -+#define GAC_MAX_BANK_NUM 0x3 - #define PER_TRP_DATA_NUM 2 - - struct roce_trp_req_param { --- -2.30.0 - diff --git a/0032-hikptool-fix-the-memory-leak-risk-problem.patch b/0032-hikptool-fix-the-memory-leak-risk-problem.patch deleted file mode 100644 index 6752e0b4cd81888c2eed86a94ae3985d0c7236ec..0000000000000000000000000000000000000000 --- a/0032-hikptool-fix-the-memory-leak-risk-problem.patch +++ /dev/null @@ -1,486 +0,0 @@ -From a5efd8daf63f13196ea38e2a2cd9e41c3d4be82b Mon Sep 17 00:00:00 2001 -From: veega -Date: Wed, 6 Sep 2023 12:01:21 +0800 -Subject: [PATCH] hikptool: fix the memory leak risk problem - -After the framework fails to apply for memory, the memory needs to be released. The framework returns a processing failure message. The module needs to exit and release the memory. - -Signed-off-by: veega ---- - net/nic/nic_dfx/hikp_nic_dfx.c | 17 +++++++++-------- - net/nic/nic_fd/hikp_nic_fd.c | 6 ++++-- - net/nic/nic_info/hikp_nic_info.c | 4 +++- - net/nic/nic_log/hikp_nic_log.c | 8 ++++---- - net/nic/nic_ppp/hikp_nic_ppp.c | 5 +++-- - net/nic/nic_qos/hikp_nic_qos.c | 5 +++-- - net/nic/nic_queue/hikp_nic_queue.c | 5 +++-- - net/nic/nic_rss/hikp_nic_rss.c | 5 +++-- - net/roce/roce_pkt/hikp_roce_pkt.c | 11 +++++++---- - net/roce/roce_scc/hikp_roce_scc.c | 11 +++++++---- - net/roce/roce_trp/hikp_roce_trp.c | 11 +++++++---- - net/roce/roce_tsp/hikp_roce_tsp.c | 11 +++++++---- - sas/sas_func/sas_analy_queue.c | 3 ++- - sas/sas_func/sas_dump_reg.c | 3 ++- - sas/sas_func/sas_read_dev.c | 3 ++- - sas/sas_func/sas_read_dqe.c | 3 ++- - sas/sas_func/sas_read_errcode.c | 3 ++- - sata/sata_func/sata_dump_reg.c | 3 ++- - serdes/hikp_serdes.c | 8 ++++---- - socip/hikp_socip_dumpreg.c | 4 +++- - 20 files changed, 79 insertions(+), 50 deletions(-) - -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c -index 3584493..c734ce0 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.c -+++ b/net/nic/nic_dfx/hikp_nic_dfx.c -@@ -123,12 +123,12 @@ static int hikp_nic_get_first_blk_dfx(struct nic_dfx_rsp_head_t *rsp_head, uint3 - uint32_t *max_dfx_size, uint32_t *version) - { - struct nic_dfx_rsp_t *dfx_rsp = NULL; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - int ret; - - ret = hikp_nic_dfx_get_blk(&cmd_ret, 0, g_dfx_param.sub_cmd_code); - if (ret < 0) -- return ret; -+ goto err_out; - - dfx_rsp = (struct nic_dfx_rsp_t *)(cmd_ret->rsp_data); - *version = cmd_ret->version; -@@ -168,12 +168,12 @@ static int hikp_nic_get_blk_dfx(struct nic_dfx_rsp_head_t *rsp_head, uint32_t bl - uint32_t *reg_data, uint32_t *max_dfx_size) - { - struct nic_dfx_rsp_t *dfx_rsp = NULL; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - int ret; - - ret = hikp_nic_dfx_get_blk(&cmd_ret, blk_id, g_dfx_param.sub_cmd_code); - if (ret < 0) -- return ret; -+ goto err_out; - - dfx_rsp = (struct nic_dfx_rsp_t *)(cmd_ret->rsp_data); - *rsp_head = dfx_rsp->rsp_head; -@@ -181,16 +181,17 @@ static int hikp_nic_get_blk_dfx(struct nic_dfx_rsp_head_t *rsp_head, uint32_t bl - HIKP_ERROR_PRINT("blk%u reg_data copy size error, " - "data size: 0x%x, max size: 0x%x\n", - blk_id, rsp_head->cur_blk_size, *max_dfx_size); -- free(cmd_ret); -- cmd_ret = NULL; -- return -EINVAL; -+ ret = -EINVAL; -+ goto err_out; - } - memcpy(reg_data, dfx_rsp->reg_data, rsp_head->cur_blk_size); - *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; -+ -+err_out: - free(cmd_ret); - cmd_ret = NULL; - -- return 0; -+ return ret; - } - - static int cmd_dfx_module_select(struct major_cmd_ctrl *self, const char *argv) -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index 5a87c30..57bc94b 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -558,8 +558,10 @@ static int hikp_nic_fd_get_blk(struct hikp_cmd_header *req_header, - int ret = 0; - - cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data)); -- if (cmd_ret == NULL) -- return -EIO; -+ if (hikp_rsp_normal_check(cmd_ret)) { -+ ret = -EIO; -+ goto out; -+ } - - rsp = (struct nic_fd_rsp *)cmd_ret->rsp_data; - if (rsp->rsp_head.cur_blk_size > buf_len) { -diff --git a/net/nic/nic_info/hikp_nic_info.c b/net/nic/nic_info/hikp_nic_info.c -index 1853d95..d84ca18 100644 ---- a/net/nic/nic_info/hikp_nic_info.c -+++ b/net/nic/nic_info/hikp_nic_info.c -@@ -64,12 +64,14 @@ static int hikp_nic_get_hw_info(struct hikp_cmd_ret **cmd_ret) - static int hikp_nic_get_curr_die_info(void) - { - struct nic_info_rsp_t *info_rsp = NULL; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - int ret; - - ret = hikp_nic_get_hw_info(&cmd_ret); - if (ret != 0) { - HIKP_ERROR_PRINT("Get chip info fail.\n"); -+ free(cmd_ret); -+ cmd_ret = NULL; - return ret; - } - info_rsp = (struct nic_info_rsp_t *)(cmd_ret->rsp_data); -diff --git a/net/nic/nic_log/hikp_nic_log.c b/net/nic/nic_log/hikp_nic_log.c -index 527f9e9..5cafe4e 100644 ---- a/net/nic/nic_log/hikp_nic_log.c -+++ b/net/nic/nic_log/hikp_nic_log.c -@@ -96,13 +96,13 @@ static int hikp_nic_get_first_blk_info(uint32_t *total_blk_num, - uint32_t *cur_blk_size, uint8_t **log_data) - { - struct nic_log_rsp_data *log_rsp = NULL; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - uint32_t log_size; - int ret; - - ret = hikp_nic_get_blk_log(&cmd_ret, 0); - if (ret < 0) -- return ret; -+ goto err_out; - - log_rsp = (struct nic_log_rsp_data *)(cmd_ret->rsp_data); - log_size = (uint32_t)(log_rsp->total_blk_num * MAX_LOG_DATA_NUM * sizeof(uint32_t)); -@@ -132,12 +132,12 @@ static int hikp_nic_get_log_info(uint32_t blk_id, uint32_t *cur_blk_size, uint8_ - uint32_t max_log_size, uint32_t *blk_num) - { - struct nic_log_rsp_data *log_rsp = NULL; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - int ret; - - ret = hikp_nic_get_blk_log(&cmd_ret, blk_id); - if (ret) -- return ret; -+ goto err_out; - - log_rsp = (struct nic_log_rsp_data *)(cmd_ret->rsp_data); - *cur_blk_size = (uint32_t)log_rsp->cur_blk_size; -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index 28c867d..b71fc48 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -482,8 +482,9 @@ static int hikp_nic_ppp_get_blk(struct hikp_cmd_header *req_header, - int ret = 0; - - cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data)); -- if (cmd_ret == NULL) -- return -EIO; -+ ret = hikp_rsp_normal_check(cmd_ret); -+ if (ret) -+ goto out; - - rsp = (struct nic_ppp_rsp *)cmd_ret->rsp_data; - if (rsp->rsp_head.cur_blk_size > buf_len) { -diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c -index 2d55e45..6c2db1d 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.c -+++ b/net/nic/nic_qos/hikp_nic_qos.c -@@ -143,9 +143,10 @@ static int hikp_nic_qos_get_blk(struct hikp_cmd_header *req_header, - int ret = 0; - - cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data)); -- if (cmd_ret == NULL) { -+ ret = hikp_rsp_normal_check(cmd_ret); -+ if (ret) { - HIKP_ERROR_PRINT("failed to get block-%u context.\n", req_data->block_id); -- return -EIO; -+ goto out; - } - - rsp = (struct nic_qos_rsp *)cmd_ret->rsp_data; -diff --git a/net/nic/nic_queue/hikp_nic_queue.c b/net/nic/nic_queue/hikp_nic_queue.c -index 37460c0..f229e09 100644 ---- a/net/nic/nic_queue/hikp_nic_queue.c -+++ b/net/nic/nic_queue/hikp_nic_queue.c -@@ -239,9 +239,10 @@ static int hikp_nic_queue_get_blk(struct hikp_cmd_header *req_header, - int ret = 0; - - cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data)); -- if (cmd_ret == NULL) { -+ ret = hikp_rsp_normal_check(cmd_ret); -+ if (ret) { - HIKP_ERROR_PRINT("failed to get block-%u context.\n", req_data->block_id); -- return -EIO; -+ goto out; - } - - rsp = (struct nic_queue_rsp *)cmd_ret->rsp_data; -diff --git a/net/nic/nic_rss/hikp_nic_rss.c b/net/nic/nic_rss/hikp_nic_rss.c -index b785ba4..5e4d261 100644 ---- a/net/nic/nic_rss/hikp_nic_rss.c -+++ b/net/nic/nic_rss/hikp_nic_rss.c -@@ -357,9 +357,10 @@ static int hikp_nic_rss_get_blk(struct hikp_cmd_header *req_header, - int ret = 0; - - cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data)); -- if (cmd_ret == NULL) { -+ ret = hikp_rsp_normal_check(cmd_ret); -+ if (ret) { - HIKP_ERROR_PRINT("failed to get block-%u context.\n", req_data->block_id); -- return -EIO; -+ goto out; - } - - rsp = (struct nic_rss_rsp *)cmd_ret->rsp_data; -diff --git a/net/roce/roce_pkt/hikp_roce_pkt.c b/net/roce/roce_pkt/hikp_roce_pkt.c -index abfc526..d3bf885 100644 ---- a/net/roce/roce_pkt/hikp_roce_pkt.c -+++ b/net/roce/roce_pkt/hikp_roce_pkt.c -@@ -48,15 +48,18 @@ static int hikp_roce_pkt_clear_set(struct major_cmd_ctrl *self, const char *argv - static int hikp_roce_pkt_get_data(struct hikp_cmd_ret **cmd_ret, struct roce_pkt_req_param req_data) - { - struct hikp_cmd_header req_header = { 0 }; -+ int ret; - - hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_PKT_CMD, 0); - *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (*cmd_ret == NULL) { -- printf("hikptool roce_pkt cmd_ret malloc failed\n"); -- return -EIO; -+ ret = hikp_rsp_normal_check(*cmd_ret); -+ if (ret) { -+ printf("hikptool roce_pkt get cmd data failed, ret: %d\n", ret); -+ free(*cmd_ret); -+ *cmd_ret = NULL; - } - -- return 0; -+ return ret; - } - - static void hikp_roce_pkt_print(uint32_t total_block_num, -diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c -index 1011814..e8e166d 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.c -+++ b/net/roce/roce_scc/hikp_roce_scc.c -@@ -88,6 +88,7 @@ static int hikp_roce_scc_get_data(struct hikp_cmd_ret **cmd_ret, const uint32_t - { - struct roce_scc_req_param req_data = { 0 }; - struct hikp_cmd_header req_header = { 0 }; -+ int ret; - - req_data.block_id = *block_id; - req_data.bdf = g_roce_scc_param_t.target.bdf; -@@ -99,12 +100,14 @@ static int hikp_roce_scc_get_data(struct hikp_cmd_ret **cmd_ret, const uint32_t - - hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_SCC_CMD, g_roce_scc_param_t.sub_cmd); - *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (*cmd_ret == NULL) { -- printf("hikptool roce_scc cmd_ret malloc failed\n"); -- return -EIO; -+ ret = hikp_rsp_normal_check(*cmd_ret); -+ if (ret) { -+ printf("hikptool roce_scc get cmd data failed, ret: %d\n", ret); -+ free(*cmd_ret); -+ *cmd_ret = NULL; - } - -- return 0; -+ return ret; - } - - static void hikp_roce_scc_reg_data_free(uint32_t **offset, uint32_t **data) -diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c -index bf22484..4591a47 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.c -+++ b/net/roce/roce_trp/hikp_roce_trp.c -@@ -112,6 +112,7 @@ static int hikp_roce_trp_get_data(struct hikp_cmd_ret **cmd_ret, const uint32_t - { - struct roce_trp_req_param req_data = { 0 }; - struct hikp_cmd_header req_header = { 0 }; -+ int ret; - - req_data.block_id = *block_id; - req_data.bdf = g_roce_trp_param_t.target.bdf; -@@ -122,12 +123,14 @@ static int hikp_roce_trp_get_data(struct hikp_cmd_ret **cmd_ret, const uint32_t - } - hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_TRP_CMD, g_roce_trp_param_t.sub_cmd); - *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (*cmd_ret == NULL) { -- printf("hikptool roce_trp cmd_ret malloc failed\n"); -- return -EIO; -+ ret = hikp_rsp_normal_check(*cmd_ret); -+ if (ret) { -+ printf("hikptool roce_trp get cmd data failed, ret: %d\n", ret); -+ free(*cmd_ret); -+ *cmd_ret = NULL; - } - -- return 0; -+ return ret; - } - - static void hikp_roce_trp_reg_data_free(uint32_t **offset, uint32_t **data) -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.c b/net/roce/roce_tsp/hikp_roce_tsp.c -index 5d06ede..ca3126b 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.c -+++ b/net/roce/roce_tsp/hikp_roce_tsp.c -@@ -122,6 +122,7 @@ static int hikp_roce_tsp_get_data(struct hikp_cmd_ret **cmd_ret, - struct roce_tsp_req_param req_data, uint32_t sub_cmd_code) - { - struct hikp_cmd_header req_header = { 0 }; -+ int ret; - - if (g_roce_tsp_param_t.sub_cmd_code == 0) { - printf("please enter module name: -m/--modlue\n"); -@@ -129,12 +130,14 @@ static int hikp_roce_tsp_get_data(struct hikp_cmd_ret **cmd_ret, - } - hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_TSP_CMD, sub_cmd_code); - *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (*cmd_ret == NULL) { -- printf("hikptool roce_tsp cmd_ret malloc failed\n"); -- return -EIO; -+ ret = hikp_rsp_normal_check(*cmd_ret); -+ if (ret) { -+ printf("hikptool roce_tsp get cmd data failed, ret: %d\n", ret); -+ free(*cmd_ret); -+ *cmd_ret = NULL; - } - -- return 0; -+ return ret; - } - - static void hikp_roce_tsp_print(uint32_t total_block_num, -diff --git a/sas/sas_func/sas_analy_queue.c b/sas/sas_func/sas_analy_queue.c -index ce886b9..8fca197 100644 ---- a/sas/sas_func/sas_analy_queue.c -+++ b/sas/sas_func/sas_analy_queue.c -@@ -40,8 +40,9 @@ static int sas_get_res(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - hikp_cmd_init(&req_header, SAS_MOD, SAS_ANACQ, ANACQ_PRT); - - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL) { -+ if (cmd_ret == NULL || cmd_ret->status != 0) { - printf("sas_analy excutes hikp_cmd_alloc err\n"); -+ free(cmd_ret); - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; -diff --git a/sas/sas_func/sas_dump_reg.c b/sas/sas_func/sas_dump_reg.c -index d012aa1..5736726 100644 ---- a/sas/sas_func/sas_dump_reg.c -+++ b/sas/sas_func/sas_dump_reg.c -@@ -32,8 +32,9 @@ static int sas_get_reg(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - - hikp_cmd_init(&req_header, SAS_MOD, SAS_DUMP, cmd->sas_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL) { -+ if (cmd_ret == NULL || cmd_ret->status != 0) { - printf("sas_dump excutes hikp_cmd_alloc err\n"); -+ free(cmd_ret); - return -1; - } - *reg_num = cmd_ret->rsp_data_num; -diff --git a/sas/sas_func/sas_read_dev.c b/sas/sas_func/sas_read_dev.c -index d01f95f..8b9b58d 100644 ---- a/sas/sas_func/sas_read_dev.c -+++ b/sas/sas_func/sas_read_dev.c -@@ -33,8 +33,9 @@ static int sas_get_dev(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - - hikp_cmd_init(&req_header, SAS_MOD, SAS_DEV, cmd->sas_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL) { -+ if (cmd_ret == NULL || cmd_ret->status != 0) { - printf("sas_dqe excutes hikp_cmd_alloc err\n"); -+ free(cmd_ret); - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; -diff --git a/sas/sas_func/sas_read_dqe.c b/sas/sas_func/sas_read_dqe.c -index 2f653df..dbd30f3 100644 ---- a/sas/sas_func/sas_read_dqe.c -+++ b/sas/sas_func/sas_read_dqe.c -@@ -33,8 +33,9 @@ static int sas_get_dqe(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - - hikp_cmd_init(&req_header, SAS_MOD, SAS_DQE, cmd->sas_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL) { -+ if (cmd_ret == NULL || cmd_ret->status != 0) { - printf("sas_dqe excutes hikp_cmd_alloc err\n"); -+ free(cmd_ret); - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; -diff --git a/sas/sas_func/sas_read_errcode.c b/sas/sas_func/sas_read_errcode.c -index 4f89bda..6c7850e 100644 ---- a/sas/sas_func/sas_read_errcode.c -+++ b/sas/sas_func/sas_read_errcode.c -@@ -31,8 +31,9 @@ static int sas_get_errcode(const struct tool_sas_cmd *cmd, uint32_t *reg_save, u - - hikp_cmd_init(&req_header, SAS_MOD, SAS_ERRCODE, cmd->sas_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL) { -+ if (cmd_ret == NULL || cmd_ret->status != 0) { - printf("sas_errcode excutes hikp_cmd_alloc err\n"); -+ free(cmd_ret); - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; -diff --git a/sata/sata_func/sata_dump_reg.c b/sata/sata_func/sata_dump_reg.c -index 86f6760..b4ff35f 100644 ---- a/sata/sata_func/sata_dump_reg.c -+++ b/sata/sata_func/sata_dump_reg.c -@@ -33,8 +33,9 @@ static int sata_get_reg(const struct tool_sata_cmd *cmd, uint32_t *reg_save, uin - - hikp_cmd_init(&req_header, SATA_MOD, SATA_DUMP, cmd->sata_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL) { -+ if (cmd_ret == NULL || cmd_ret->status != 0) { - printf("hikp_data_proc err\n"); -+ free(cmd_ret); - return -1; - } - *reg_num = cmd_ret->rsp_data_num; -diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c -index 527fd53..320ded2 100644 ---- a/serdes/hikp_serdes.c -+++ b/serdes/hikp_serdes.c -@@ -309,10 +309,10 @@ static void hikp_serdes_info_cmd_execute(struct major_cmd_ctrl *self) - - hikp_cmd_init(&req_header, SERDES_MOD, SERDES_KEY_INFO, g_serdes_param.sub_cmd); - cmd_ret = hikp_cmd_alloc(&req_header, &hilink_cmd, sizeof(hilink_cmd)); -- if (cmd_ret == NULL) { -+ if (cmd_ret == NULL || cmd_ret->status != 0) { - snprintf(self->err_str, sizeof(self->err_str), "hikp_cmd_alloc err."); - self->err_no = -EINVAL; -- return; -+ goto err_out; - } - out_out_header_size = sizeof(out_put.str_len) + sizeof(out_put.result_offset) + - sizeof(out_put.type) + sizeof(out_put.ret_val); -@@ -467,10 +467,10 @@ static void hikp_serdes_dump_cmd_execute(struct major_cmd_ctrl *self) - - hikp_cmd_init(&req_header, SERDES_MOD, SERDES_DUMP_REG, g_serdes_param.sub_cmd); - cmd_ret = hikp_cmd_alloc(&req_header, &hilink_cmd, sizeof(hilink_cmd)); -- if (cmd_ret == NULL) { -+ if (cmd_ret == NULL || cmd_ret->status != 0) { - self->err_no = -EINVAL; - snprintf(self->err_str, sizeof(self->err_str), "hikp_cmd_alloc err."); -- return; -+ goto err_out; - } - out_out_header_size = sizeof(out_put.str_len) + sizeof(out_put.result_offset) + - sizeof(out_put.type) + sizeof(out_put.ret_val); -diff --git a/socip/hikp_socip_dumpreg.c b/socip/hikp_socip_dumpreg.c -index 32325bb..0153dd9 100644 ---- a/socip/hikp_socip_dumpreg.c -+++ b/socip/hikp_socip_dumpreg.c -@@ -141,9 +141,11 @@ static void hikp_socip_dumpreg_execute(struct major_cmd_ctrl *self) - req_data.controller_id = param[CONTROLLER_ID_INDEX].val; - hikp_cmd_init(&req_header, SOCIP_MOD, HIKP_SOCIP_CMD_DUMPREG, param[MODULE_ID_INDEX].val); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (!cmd_ret) { -+ if (!cmd_ret || cmd_ret->status != 0) { - self->err_no = -EINVAL; - HIKP_ERROR_PRINT("hikp_cmd_alloc\n"); -+ free(cmd_ret); -+ cmd_ret = NULL; - return; - } - --- -2.36.1.windows.1 - diff --git a/0033-hikptool-add-new-cmd-support-query-fault-notify-pkt-.patch b/0033-hikptool-add-new-cmd-support-query-fault-notify-pkt-.patch deleted file mode 100644 index e24ca535863f3f70d88194e166465c644d916cd1..0000000000000000000000000000000000000000 --- a/0033-hikptool-add-new-cmd-support-query-fault-notify-pkt-.patch +++ /dev/null @@ -1,223 +0,0 @@ -From b593a7e393147a0b9cf87640066d5f4932f8cd3c Mon Sep 17 00:00:00 2001 -From: Jijie Shao -Date: Thu, 7 Sep 2023 14:40:42 +0800 -Subject: [PATCH] hikptool: add new cmd support query fault notify pkt info - -Add nic_notify_pkt cmd for query fault notify pkt info - -Bugfix or Feature: Feature - -Signed-off-by: Jijie Shao ---- - net/hikp_net_lib.h | 1 + - net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c | 126 +++++++++++++++++++ - net/nic/nic_notify_pkt/hikp_nic_notify_pkt.h | 52 ++++++++ - 3 files changed, 179 insertions(+) - create mode 100644 net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c - create mode 100644 net/nic/nic_notify_pkt/hikp_nic_notify_pkt.h - -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index ed984ce..06ae598 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -79,6 +79,7 @@ enum nic_cmd_type { - GET_FEC_INFO_CMD, - GET_GRO_INFO_CMD, - GET_NCSI_INFO_CMD, -+ GET_NOTIFY_PKT_CMD, - }; - - enum roh_cmd_type { -diff --git a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -new file mode 100644 -index 0000000..307d336 ---- /dev/null -+++ b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -@@ -0,0 +1,126 @@ -+/* -+ * Copyright (c) 2023 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 -+#include -+#include -+#include -+#include "hikp_nic_notify_pkt.h" -+ -+static struct tool_target g_notify_pkt_target; -+ -+static int hikp_nic_notify_pkt_query(struct major_cmd_ctrl *self, const struct bdf_t *bdf, -+ struct nic_notify_pkt_info *info) -+{ -+ struct nic_notify_pkt_req_para req = { 0 }; -+ struct hikp_cmd_header header = { 0 }; -+ struct nic_notify_pkt_rsp *rsp; -+ struct hikp_cmd_ret *cmd_resp; -+ -+ req.bdf = *bdf; -+ hikp_cmd_init(&header, NIC_MOD, GET_NOTIFY_PKT_CMD, GET_NOTIFY_PKT_CMD); -+ cmd_resp = hikp_cmd_alloc(&header, &req, sizeof(req)); -+ self->err_no = hikp_rsp_normal_check(cmd_resp); -+ if (self->err_no) { -+ snprintf(self->err_str, sizeof(self->err_str), "get notify pkt failed."); -+ if (cmd_resp) -+ free(cmd_resp); -+ return self->err_no; -+ } -+ -+ rsp = (struct nic_notify_pkt_rsp *)cmd_resp->rsp_data; -+ *info = *(struct nic_notify_pkt_info *)rsp->data; -+ free(cmd_resp); -+ -+ return 0; -+} -+ -+static void hikp_nic_notify_pkt_show(const struct nic_notify_pkt_info *info) -+{ -+#define HIKP_NIC_NOFITY_PKT_DATA_PEER_LINE_MAX_CNT 16 -+ -+ uint32_t pkt_start_en = hikp_get_bit(info->cfg, HIKP_NOTIFY_PKT_CFG_START_EN); -+ uint32_t pkt_num = hikp_get_field(info->cfg, HIKP_NOTIFY_PKT_CFG_PKT_NUM_M, -+ HIKP_NOTIFY_PKT_CFG_PKT_NUM_S); -+ uint32_t pkt_en = hikp_get_bit(info->cfg, HIKP_NOTIFY_PKT_CFG_PKT_EN); -+ uint32_t i; -+ -+ printf("################ NIC notify pkt info ##################\n"); -+ printf("pkt_en : %u\n", pkt_en); -+ printf("pkt_start_en : %u\n", pkt_start_en); -+ printf("pkt_num : %u\n", pkt_num); -+ printf("pkt_ipg : %u %s\n", info->ipg, info->ipg > 1 ? -+ "clock cycles" : "clock cycle"); -+ -+ printf("pkt_data:\n"); -+ for (i = 1; i <= NIC_NOTIFY_PKT_DATA_LEN; i++) { -+ printf("%02x ", info->data[i - 1]); -+ if (i % HIKP_NIC_NOFITY_PKT_DATA_PEER_LINE_MAX_CNT == 0) -+ printf("\n"); -+ } -+ printf("####################### END ###########################\n"); -+} -+ -+static void hikp_nic_notify_pkt_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ struct bdf_t *bdf = &g_notify_pkt_target.bdf; -+ struct nic_notify_pkt_info info; -+ -+ self->err_no = hikp_nic_notify_pkt_query(self, bdf, &info); -+ if (self->err_no) -+ return; -+ -+ hikp_nic_notify_pkt_show(&info); -+} -+ -+static int hikp_nic_notify_pkt_cmd_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); -+ printf(" %s, %-25s %s\n", "-i", "--interface=", -+ "device target or bdf id, e.g. eth0~7 or 0000:35:00.0"); -+ -+ return 0; -+} -+ -+static int hikp_nic_notify_pkt_get_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_notify_pkt_target); -+ if (self->err_no != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "unknown device!"); -+ return self->err_no; -+ } -+ -+ if (g_notify_pkt_target.bdf.dev_id != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "VF does not support query!"); -+ self->err_no = -EOPNOTSUPP; -+ return self->err_no; -+ } -+ -+ return 0; -+} -+ -+static void cmd_nic_notify_pkt_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_nic_notify_pkt_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_nic_notify_pkt_cmd_help); -+ cmd_option_register("-i", "--interface", true, hikp_nic_notify_pkt_get_target); -+} -+ -+HIKP_CMD_DECLARE("nic_notify_pkt", "dump notify pkt info of nic!", cmd_nic_notify_pkt_init); -diff --git a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.h b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.h -new file mode 100644 -index 0000000..8bdb795 ---- /dev/null -+++ b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.h -@@ -0,0 +1,52 @@ -+/* -+ * Copyright (c) 2023 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_NIC_NOTIFY_PKT_H -+#define HIKP_NIC_NOTIFY_PKT_H -+ -+#include "hikp_net_lib.h" -+ -+enum nic_notify_pkt_sub_cmd_type { -+ NIC_NOTIFY_PKT_DUMP = 0, -+}; -+ -+struct nic_notify_pkt_req_para { -+ struct bdf_t bdf; -+ uint32_t block_id; -+}; -+ -+struct nic_notify_pkt_rsp_head { -+ uint8_t total_blk_num; -+ uint8_t curr_blk_size; /* real data size, not contain head size. */ -+ uint16_t rsv; -+}; -+ -+#define NIC_NOTIFY_PKT_MAX_RSP_DATA 18 -+struct nic_notify_pkt_rsp { -+ struct nic_notify_pkt_rsp_head head; -+ uint32_t data[NIC_NOTIFY_PKT_MAX_RSP_DATA]; -+}; -+ -+#define NIC_NOTIFY_PKT_DATA_LEN 64 -+struct nic_notify_pkt_info { -+ uint32_t cfg; -+ uint32_t ipg; -+ uint8_t data[NIC_NOTIFY_PKT_DATA_LEN]; -+}; -+ -+#define HIKP_NOTIFY_PKT_CFG_PKT_EN 0 -+#define HIKP_NOTIFY_PKT_CFG_START_EN 1 -+#define HIKP_NOTIFY_PKT_CFG_PKT_NUM_M GENMASK(5, 2) -+#define HIKP_NOTIFY_PKT_CFG_PKT_NUM_S 2 -+ -+#endif /* HIKP_NIC_NOTIFY_PKT_H */ --- -2.30.0 - diff --git a/0034-hikptool-add-new-cmd-to-support-query-port-fault-inf.patch b/0034-hikptool-add-new-cmd-to-support-query-port-fault-inf.patch deleted file mode 100644 index 6410e6ce0a90269c7edcf8428c454f4ab37410a5..0000000000000000000000000000000000000000 --- a/0034-hikptool-add-new-cmd-to-support-query-port-fault-inf.patch +++ /dev/null @@ -1,238 +0,0 @@ -From 84d1e8a09e69ffe3809f0e4fa27d586c7ef8c706 Mon Sep 17 00:00:00 2001 -From: Jie Wang -Date: Mon, 28 Aug 2023 10:35:19 +0800 -Subject: [PATCH] hikptool: add new cmd to support query port fault info - -Add nic port fault cmd for query nic port fault status. - -Bugfix or Feature: Feature - -Signed-off-by: Jie Wang ---- - net/hikp_net_lib.h | 1 + - net/nic/nic_ft/hikp_nic_port_fault.c | 139 +++++++++++++++++++++++++++ - net/nic/nic_ft/hikp_nic_port_fault.h | 54 +++++++++++ - 3 files changed, 194 insertions(+) - create mode 100644 net/nic/nic_ft/hikp_nic_port_fault.c - create mode 100644 net/nic/nic_ft/hikp_nic_port_fault.h - -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index 06ae598..cb537ff 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -80,6 +80,7 @@ enum nic_cmd_type { - GET_GRO_INFO_CMD, - GET_NCSI_INFO_CMD, - GET_NOTIFY_PKT_CMD, -+ GET_PORT_FAULT_STATUS = 0xE, - }; - - enum roh_cmd_type { -diff --git a/net/nic/nic_ft/hikp_nic_port_fault.c b/net/nic/nic_ft/hikp_nic_port_fault.c -new file mode 100644 -index 0000000..fd94214 ---- /dev/null -+++ b/net/nic/nic_ft/hikp_nic_port_fault.c -@@ -0,0 +1,139 @@ -+/* -+ * Copyright (c) 2023 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 -+#include -+#include -+#include -+#include "hikp_nic_port_fault.h" -+ -+static struct tool_target g_port_fault_target; -+ -+static int hikp_nic_port_fault_query(const struct bdf_t *bdf, -+ struct nic_port_fault_status *info) -+{ -+ struct nic_port_fault_req_para req = { 0 }; -+ struct hikp_cmd_header header = { 0 }; -+ struct nic_port_fault_rsp *rsp; -+ struct hikp_cmd_ret *cmd_ret; -+ -+ req.bdf = *bdf; -+ hikp_cmd_init(&header, NIC_MOD, GET_PORT_FAULT_STATUS, -+ NIC_PORT_FAULT_INFO_DUMP); -+ cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); -+ if (cmd_ret == NULL || cmd_ret->status != 0) { -+ HIKP_ERROR_PRINT("fail to get port fault, retcode: %u\n", -+ cmd_ret ? cmd_ret->status : EIO); -+ if (cmd_ret != NULL) -+ free(cmd_ret); -+ -+ return -EIO; -+ } -+ -+ rsp = (struct nic_port_fault_rsp *)cmd_ret->rsp_data; -+ *info = *(struct nic_port_fault_status *)rsp->data; -+ free(cmd_ret); -+ -+ return 0; -+} -+ -+static void hikp_nic_format_port_fault_info(struct nic_port_fault_status *info) -+{ -+ if (info->cdr_core_status > NIC_PORT_FAULT_INVALID) -+ info->cdr_core_status = NIC_PORT_FAULT_INVALID; -+ -+ if (info->cdr_flash_status > NIC_PORT_FAULT_INVALID) -+ info->cdr_flash_status = NIC_PORT_FAULT_INVALID; -+ -+ if (info->fault_9545_status > NIC_PORT_FAULT_INVALID) -+ info->fault_9545_status = NIC_PORT_FAULT_INVALID; -+ -+ if (info->hilink_ref_status > NIC_PORT_FAULT_INVALID) -+ info->hilink_ref_status = NIC_PORT_FAULT_INVALID; -+} -+ -+static void hikp_nic_port_fault_show(struct nic_port_fault_status *info) -+{ -+ const char *port_fault_info[] = { -+ "OK", -+ "Device error", -+ "Device not support", -+ "Invalid" -+ }; -+ -+ hikp_nic_format_port_fault_info(info); -+ printf("############ NIC port fault status ###############\n"); -+ printf("cdr flash : %s.\n", port_fault_info[info->cdr_flash_status]); -+ printf("cdr core : %s.\n", port_fault_info[info->cdr_core_status]); -+ printf("9545 fault: %s.\n", port_fault_info[info->fault_9545_status]); -+ printf("hilink ref: %s.\n", port_fault_info[info->hilink_ref_status]); -+ printf("#################### END #######################\n"); -+} -+ -+static void hikp_nic_port_fault_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ struct bdf_t *bdf = &g_port_fault_target.bdf; -+ struct nic_port_fault_status info; -+ int ret; -+ -+ ret = hikp_nic_port_fault_query(bdf, &info); -+ if (ret != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "fail to get fault info."); -+ self->err_no = ret; -+ return; -+ } -+ -+ hikp_nic_port_fault_show(&info); -+} -+ -+static int hikp_nic_port_fault_cmd_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); -+ printf(" %s, %-25s %s\n", "-i", "--interface=", -+ "device target or bdf id, e.g. eth0~7 or 0000:35:00.0"); -+ -+ return 0; -+} -+ -+static int hikp_nic_port_fault_get_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_port_fault_target); -+ if (self->err_no != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "unknown device!"); -+ return self->err_no; -+ } -+ -+ if (g_port_fault_target.bdf.dev_id != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "VF is not supported!"); -+ self->err_no = -EOPNOTSUPP; -+ return self->err_no; -+ } -+ -+ return 0; -+} -+ -+static void cmd_nic_port_fault_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_nic_port_fault_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_nic_port_fault_cmd_help); -+ cmd_option_register("-i", "--interface", true, hikp_nic_port_fault_get_target); -+} -+ -+HIKP_CMD_DECLARE("nic_port_fault", "dump port fault of nic!", cmd_nic_port_fault_init); -diff --git a/net/nic/nic_ft/hikp_nic_port_fault.h b/net/nic/nic_ft/hikp_nic_port_fault.h -new file mode 100644 -index 0000000..7db54f7 ---- /dev/null -+++ b/net/nic/nic_ft/hikp_nic_port_fault.h -@@ -0,0 +1,54 @@ -+/* -+ * Copyright (c) 2023 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_NIC_PORT_FAULT_H -+#define HIKP_NIC_PORT_FAULT_H -+ -+#include "hikp_net_lib.h" -+ -+enum nic_port_fault_sub_cmd_type { -+ NIC_PORT_FAULT_INFO_DUMP, -+}; -+ -+enum nic_port_fault_info_type { -+ NIC_PORT_FAULT_OK, -+ NIC_PORT_FAULT_ERR, -+ NIC_PORT_FAULT_NOTSUP, -+ NIC_PORT_FAULT_INVALID -+}; -+ -+struct nic_port_fault_req_para { -+ struct bdf_t bdf; -+ uint8_t block_id; -+}; -+ -+struct nic_port_fault_rsp_head { -+ uint8_t total_blk_num; -+ uint8_t curr_blk_size; -+ uint16_t rsv; -+}; -+ -+#define NIC_PORT_FAULT_MAX_RSP_DATA 1 -+struct nic_port_fault_rsp { -+ struct nic_port_fault_rsp_head head; -+ uint32_t data[NIC_PORT_FAULT_MAX_RSP_DATA]; -+}; -+ -+struct nic_port_fault_status { -+ uint8_t cdr_flash_status; -+ uint8_t fault_9545_status; -+ uint8_t cdr_core_status; -+ uint8_t hilink_ref_status; -+}; -+ -+#endif /* HIKP_NIC_PORT_FAULT_H */ --- -2.30.0 - diff --git a/0035-hikptool-support-to-query-pfc-storm-parameters.patch b/0035-hikptool-support-to-query-pfc-storm-parameters.patch deleted file mode 100644 index 5187b7cb6288754180967b1d44ba686269e8cff1..0000000000000000000000000000000000000000 --- a/0035-hikptool-support-to-query-pfc-storm-parameters.patch +++ /dev/null @@ -1,240 +0,0 @@ -From 134f0a4dbcc5bc7636bcc5d9553c147b0eac99aa Mon Sep 17 00:00:00 2001 -From: Peiyang Wang -Date: Mon, 11 Sep 2023 19:04:48 +0800 -Subject: [PATCH] hikptool: support to query pfc storm parameters - -Add new feature in nic_qos to support query pfc storm parameters info. - -Bugfix or Feature: Feature - -Signed-off-by: Peiyang Wang ---- - net/nic/nic_qos/hikp_nic_qos.c | 72 ++++++++++++++++++++++++++++++++-- - net/nic/nic_qos/hikp_nic_qos.h | 20 ++++++++++ - 2 files changed, 89 insertions(+), 3 deletions(-) - -diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c -index 6c2db1d..e3f0e9c 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.c -+++ b/net/nic/nic_qos/hikp_nic_qos.c -@@ -17,17 +17,21 @@ - #include - - #include "hikp_nic_qos.h" -+#include "hikpt_rciep.h" - - static struct nic_qos_param g_qos_param = { 0 }; - - static void hikp_nic_qos_show_pkt_buf(const void *data); - static void hikp_nic_qos_show_dcb_info(const void *data); - static void hikp_nic_qos_show_pause_info(const void *data); -+static void hikp_nic_qos_show_pfc_storm_para(const void *data); - - static const struct qos_feature_cmd g_qos_feature_cmd[] = { - {"pkt_buf", NIC_PACKET_BUFFER_DUMP, hikp_nic_qos_show_pkt_buf}, - {"dcb", NIC_DCB_DUMP, hikp_nic_qos_show_dcb_info}, - {"pause", NIC_PAUSE_DUMP, hikp_nic_qos_show_pause_info}, -+ {"pfc_storm_para", NIC_PFC_STORM_PARA_DUMP, -+ hikp_nic_qos_show_pfc_storm_para}, - }; - - static int hikp_nic_qos_cmd_help(struct major_cmd_ctrl *self, const char *argv) -@@ -42,8 +46,12 @@ static int hikp_nic_qos_cmd_help(struct major_cmd_ctrl *self, const char *argv) - "[-g/--get ]\n" - " pkt_buf : get nic packet buffer.\n" - " dcb : get dcb information.\n" -- " pause : get pause information\n"); -- -+ " pause : get pause information\n" -+ " pfc_storm_para : get pfc storm configuration parameters\n"); -+ printf(" %s\n", -+ "[-d/--dir ]\n" -+ " tx : transmit.\n" -+ " rx : receive.\n"); - return 0; - } - -@@ -134,6 +142,22 @@ static void hikp_nic_qos_show_pause_info(const void *data) - printf("pause gap: 0x%x\n", pause->pause_gap); - } - -+static void hikp_nic_qos_show_pfc_storm_para(const void *data) -+{ -+ struct nic_pfc_storm_para *pfc_storm_para = -+ (struct nic_pfc_storm_para *)data; -+ -+ printf("PFC STORM Information:\n"); -+ printf("direction: %s\n", pfc_storm_para->dir ? "tx" : "rx"); -+ printf("enabled: %s\n", pfc_storm_para->enable ? "on" : "off"); -+ printf("period: %ums\n", pfc_storm_para->period_ms); -+ strncmp(g_qos_param.revision_id, HIKP_IEP_REVISION, -+ MAX_PCI_REVISION_LEN) ? -+ printf("check times: %u\n", pfc_storm_para->times) : -+ printf("pfc threshold: %ums\n", pfc_storm_para->times); -+ printf("recovery period: %ums\n", pfc_storm_para->recovery_period_ms); -+} -+ - static int hikp_nic_qos_get_blk(struct hikp_cmd_header *req_header, - const struct nic_qos_req_para *req_data, - void *buf, size_t buf_len, struct nic_qos_rsp_head *rsp_head) -@@ -181,6 +205,8 @@ static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const - req_data.bdf = *bdf; - - req_data.block_id = blk_id; -+ req_data.dir = g_qos_param.dir; -+ - ret = hikp_nic_qos_get_blk(req_header, &req_data, data, buf_len, &rsp_head); - if (ret != 0) - return ret; -@@ -191,6 +217,8 @@ static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const - /* Copy the remaining block content if total block number is greater than 1. */ - for (blk_id = 1; blk_id < total_blk_num; blk_id++) { - req_data.block_id = blk_id; -+ req_data.dir = g_qos_param.dir; -+ - ret = hikp_nic_qos_get_blk(req_header, &req_data, - (uint8_t *)data + total_blk_size, - buf_len - total_blk_size, &rsp_head); -@@ -204,10 +232,11 @@ static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const - - static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self) - { -+ char *revision_id = g_qos_param.revision_id; - struct bdf_t *bdf = &g_qos_param.target.bdf; - union nic_qos_feature_info qos_data = {0}; -- const struct qos_feature_cmd *qos_cmd; - struct hikp_cmd_header req_header = {0}; -+ const struct qos_feature_cmd *qos_cmd; - int ret; - - if (bdf->dev_id != 0) { -@@ -223,6 +252,15 @@ static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self) - return; - } - -+ if (g_qos_param.feature_idx == NIC_PFC_STORM_PARA_DUMP && -+ g_qos_param.dir == NIC_QUEUE_DIR_NONE) { -+ hikp_nic_qos_cmd_help(self, NULL); -+ snprintf(self->err_str, sizeof(self->err_str), -+ "-d/--dir param error!"); -+ self->err_no = -EINVAL; -+ return; -+ } -+ - qos_cmd = &g_qos_feature_cmd[g_qos_param.feature_idx]; - hikp_cmd_init(&req_header, NIC_MOD, GET_QOS_INFO_CMD, qos_cmd->sub_cmd_code); - ret = hikp_nic_query_qos_feature(&req_header, &g_qos_param.target.bdf, &qos_data); -@@ -233,6 +271,13 @@ static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self) - return; - } - -+ memset(revision_id, 0, MAX_PCI_ID_LEN + 1); -+ ret = get_revision_id_by_bdf(bdf, revision_id); -+ // show pfc threshold as default if get revision_id error -+ if (ret) -+ strncpy(g_qos_param.revision_id, HIKP_IEP_REVISION, -+ MAX_PCI_REVISION_LEN); -+ - printf("############## NIC QOS: %s info ############\n", qos_cmd->feature_name); - qos_cmd->show(&qos_data); - printf("#################### END #######################\n"); -@@ -268,11 +313,31 @@ static int hikp_nic_cmd_qos_feature_select(struct major_cmd_ctrl *self, const ch - return self->err_no; - } - -+static int hikp_nic_cmd_qos_direct(struct major_cmd_ctrl *self, -+ const char *argv) -+{ -+ if (strcmp(argv, "rx") == 0) { -+ g_qos_param.dir = NIC_RX_QUEUE; -+ return 0; -+ } -+ if (strcmp(argv, "tx") == 0) { -+ g_qos_param.dir = NIC_TX_QUEUE; -+ return 0; -+ } -+ -+ snprintf(self->err_str, sizeof(self->err_str), -+ "-d/--dir option is invalid."); -+ self->err_no = -EINVAL; -+ -+ return self->err_no; -+} -+ - static void cmd_nic_get_qos_init(void) - { - struct major_cmd_ctrl *major_cmd = get_major_cmd(); - - g_qos_param.feature_idx = -1; -+ g_qos_param.dir = NIC_QUEUE_DIR_NONE; - - major_cmd->option_count = 0; - major_cmd->execute = hikp_nic_qos_cmd_execute; -@@ -280,6 +345,7 @@ static void cmd_nic_get_qos_init(void) - cmd_option_register("-h", "--help", false, hikp_nic_qos_cmd_help); - cmd_option_register("-i", "--interface", true, hikp_nic_cmd_get_qos_target); - cmd_option_register("-g", "--get", true, hikp_nic_cmd_qos_feature_select); -+ cmd_option_register("-d", "--dir", true, hikp_nic_cmd_qos_direct); - } - - HIKP_CMD_DECLARE("nic_qos", "show qos info of nic!", cmd_nic_get_qos_init); -diff --git a/net/nic/nic_qos/hikp_nic_qos.h b/net/nic/nic_qos/hikp_nic_qos.h -index b5481f5..d55970a 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.h -+++ b/net/nic/nic_qos/hikp_nic_qos.h -@@ -20,6 +20,7 @@ enum nic_qos_sub_cmd_type { - NIC_PACKET_BUFFER_DUMP = 0, - NIC_DCB_DUMP, - NIC_PAUSE_DUMP, -+ NIC_PFC_STORM_PARA_DUMP, - }; - - struct nic_buf_waterline { -@@ -50,6 +51,14 @@ struct nic_pfc_info { - uint8_t rsv[2]; - }; - -+struct nic_pfc_storm_para { -+ uint32_t dir; -+ uint32_t enable; -+ uint32_t period_ms; -+ uint32_t times; -+ uint32_t recovery_period_ms; -+}; -+ - struct nic_ets_info { - uint8_t prio_tc[HIKP_NIC_MAX_USER_PRIO_NUM]; - uint8_t tc_bw[HIKP_NIC_MAX_TC_NUM]; -@@ -82,6 +91,7 @@ union nic_qos_feature_info { - struct nic_pkt_buf_info pkt_buf; - struct nic_dcb_info dcb; - struct nic_pause_info pause; -+ struct nic_pfc_storm_para pfc_storm_para; - }; - - struct nic_qos_rsp_head { -@@ -99,11 +109,21 @@ struct nic_qos_rsp { - struct nic_qos_req_para { - struct bdf_t bdf; - uint8_t block_id; -+ uint8_t dir; -+ uint8_t rsv[2]; -+}; -+ -+enum nic_pfc_dir { -+ NIC_RX_QUEUE = 0, -+ NIC_TX_QUEUE, -+ NIC_QUEUE_DIR_NONE, - }; - - struct nic_qos_param { - struct tool_target target; - int feature_idx; -+ enum nic_pfc_dir dir; -+ char revision_id[MAX_PCI_ID_LEN + 1]; - }; - - #define HIKP_QOS_MAX_FEATURE_NAME_LEN 20 --- -2.33.0 - diff --git a/0036-hikptool-add-sub-cmd-nic_torus-support.patch b/0036-hikptool-add-sub-cmd-nic_torus-support.patch deleted file mode 100644 index 39ae8e1d59aedac1ac66591259e90bb0f2c835c6..0000000000000000000000000000000000000000 --- a/0036-hikptool-add-sub-cmd-nic_torus-support.patch +++ /dev/null @@ -1,310 +0,0 @@ -From 01b5303ea6a533e956481a94a449e18bc86d01d2 Mon Sep 17 00:00:00 2001 -From: Hao Chen -Date: Tue, 12 Sep 2023 19:58:38 +0800 -Subject: [PATCH] hikptool: add sub cmd nic_torus support - -Add nic_torus cmd for query 1D torus setting info - -Bugfix or Feature: Feature - -Signed-off-by: Hao Chen ---- - net/hikp_net_lib.h | 1 + - net/nic/nic_torus/hikp_nic_torus.c | 189 +++++++++++++++++++++++++++++ - net/nic/nic_torus/hikp_nic_torus.h | 76 ++++++++++++ - 3 files changed, 266 insertions(+) - create mode 100644 net/nic/nic_torus/hikp_nic_torus.c - create mode 100644 net/nic/nic_torus/hikp_nic_torus.h - -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index cb537ff..21b5357 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -80,6 +80,7 @@ enum nic_cmd_type { - GET_GRO_INFO_CMD, - GET_NCSI_INFO_CMD, - GET_NOTIFY_PKT_CMD, -+ GET_TORUS_INFO_CMD = 0xD, - GET_PORT_FAULT_STATUS = 0xE, - }; - -diff --git a/net/nic/nic_torus/hikp_nic_torus.c b/net/nic/nic_torus/hikp_nic_torus.c -new file mode 100644 -index 0000000..4baede6 ---- /dev/null -+++ b/net/nic/nic_torus/hikp_nic_torus.c -@@ -0,0 +1,189 @@ -+/* -+ * Copyright (c) 2023 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 -+#include -+#include -+#include -+ -+#include "hikp_nic_torus.h" -+ -+static struct tool_target g_torus_target; -+ -+static int hikp_nic_torus_query(const struct bdf_t *bdf, -+ struct nic_torus_info *info) -+{ -+ struct nic_torus_req_para req = { 0 }; -+ struct hikp_cmd_header header = { 0 }; -+ struct hikp_cmd_ret *cmd_ret; -+ struct nic_torus_rsp *rsp; -+ -+ req.bdf = *bdf; -+ hikp_cmd_init(&header, NIC_MOD, GET_TORUS_INFO_CMD, NIC_TORUS_INFO_DUMP); -+ cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); -+ if (cmd_ret == NULL || cmd_ret->status != 0) { -+ HIKP_ERROR_PRINT("fail to get torus info, retcode: %u\n", -+ cmd_ret ? cmd_ret->status : EIO); -+ if (cmd_ret) -+ free(cmd_ret); -+ return -EIO; -+ } -+ -+ rsp = (struct nic_torus_rsp *)cmd_ret->rsp_data; -+ *info = *(struct nic_torus_info *)rsp->data; -+ free(cmd_ret); -+ -+ return 0; -+} -+ -+static void hikp_nic_torus_lan_prt_pair_show(const struct nic_torus_info *info) -+{ -+ uint32_t mac_id = hikp_get_field(info->lan_prt_pair, NIC_TORUS_MAC_ID_M, -+ NIC_TORUS_MAC_ID_S); -+ uint32_t uc_lan_pair_en = hikp_get_bit(info->lan_prt_pair, -+ NIC_TORUS_UC_LAN_PAIR_EN); -+ uint32_t mc_bc_lan_pair_en = hikp_get_bit(info->lan_prt_pair, -+ NIC_TORUS_MC_BC_LAN_PAIR_EN); -+ uint32_t lldp_lan_pair_en = hikp_get_bit(info->lan_prt_pair, -+ NIC_TORUS_LLDP_LAN_PAIR_EN); -+ uint32_t tc2vlanpri_mapping_en = hikp_get_bit(info->lan_prt_pair, -+ NIC_TORUS_TC2VLANPRI_MAPPING_EN); -+ uint32_t torus_lpbk_drop_en = hikp_get_bit(info->lan_prt_pair, -+ NIC_TORUS_LPBK_DROP_EN); -+ -+ printf("dst mac id: %u\n", mac_id); -+ printf("uc_lan_pair_en: %u\n", uc_lan_pair_en); -+ printf("mc_bc_lan_pair_en: %u\n", mc_bc_lan_pair_en); -+ printf("lldp_lan_pair_en: %u\n", lldp_lan_pair_en); -+ printf("tc2vlanpri_mapping_en: %u\n", tc2vlanpri_mapping_en); -+ printf("torus_lpbk_drop_en: %u\n", torus_lpbk_drop_en); -+} -+ -+static void hikp_nic_torus_lan_fwd_tc_cfg_show(const struct nic_torus_info *info) -+{ -+ uint32_t tc0_map_tc = hikp_get_field(info->lan_fwd_tc_cfg, -+ NIC_TORUS_TC0_MAP_TC_M, -+ NIC_TORUS_TC0_MAP_TC_S); -+ uint32_t tc1_map_tc = hikp_get_field(info->lan_fwd_tc_cfg, -+ NIC_TORUS_TC1_MAP_TC_M, -+ NIC_TORUS_TC1_MAP_TC_S); -+ uint32_t tc2_map_tc = hikp_get_field(info->lan_fwd_tc_cfg, -+ NIC_TORUS_TC2_MAP_TC_M, -+ NIC_TORUS_TC2_MAP_TC_S); -+ uint32_t tc3_map_tc = hikp_get_field(info->lan_fwd_tc_cfg, -+ NIC_TORUS_TC3_MAP_TC_M, -+ NIC_TORUS_TC3_MAP_TC_S); -+ -+ printf("tc0_map_tc : %u\n", tc0_map_tc); -+ printf("tc1_map_tc : %u\n", tc1_map_tc); -+ printf("tc2_map_tc : %u\n", tc2_map_tc); -+ printf("tc3_map_tc : %u\n", tc3_map_tc); -+} -+ -+static void hikp_nic_torus_switch_param_show(const struct nic_torus_info *info) -+{ -+ printf("nic_mac_anti_spoof_en: %s\n", info->nic_switch_param & -+ NIC_TORUS_MAC_ANTI_SPOOF_EN_MASK ? "enable" : "disable"); -+ printf("nic_alw_lpbk: %s\n", info->nic_switch_param & -+ NIC_TORUS_ALW_LPBK_MASK ? "enable" : "disable"); -+ printf("nic_alw_lcl_lpbk: %s\n", info->nic_switch_param & -+ NIC_TORUS_ALW_LCL_LPBK_MASK ? "enable" : "disable"); -+ printf("nic_alw_dst_ovrd: %s\n", info->nic_switch_param & -+ NIC_TORUS_ALW_DST_OVRD_MASK ? "enable" : "disable"); -+ printf("roce_mac_anti_spoof_en: %s\n", info->roce_switch_param & -+ NIC_TORUS_MAC_ANTI_SPOOF_EN_MASK ? "enable" : "disable"); -+ printf("roce_alw_lpbk: %s\n", info->roce_switch_param & -+ NIC_TORUS_ALW_LPBK_MASK ? "enable" : "disable"); -+ printf("roce_alw_lcl_lpbk: %s\n", info->roce_switch_param & -+ NIC_TORUS_ALW_LCL_LPBK_MASK ? "enable" : "disable"); -+ printf("roce_alw_dst_ovrd: %s\n", info->roce_switch_param & -+ NIC_TORUS_ALW_DST_OVRD_MASK ? "enable" : "disable"); -+} -+ -+static void hikp_nic_torus_show(const struct nic_torus_info *info) -+{ -+ printf("################ NIC TORUS info ##################\n"); -+ printf("enable: %s\n", info->enable ? "true" : "false"); -+ -+ hikp_nic_torus_lan_prt_pair_show(info); -+ -+ hikp_nic_torus_lan_fwd_tc_cfg_show(info); -+ -+ printf("ssu_pause_time_out: %uus\n", info->pause_time_out); -+ printf("ssu_pause_time_out_en: %u\n", info->pause_time_out_en); -+ printf("vlan_fe: 0x%x (for port vlan)\n", info->vlan_fe); -+ printf("ets_tcg0_mapping: 0x%x\n", info->ets_tcg0_mapping); -+ printf("ets_tcg0_mapping is showed as 0xff if ncl_config forward bit is setted to 1\n"); -+ -+ hikp_nic_torus_switch_param_show(info); -+ -+ printf("#################### END ##########################\n"); -+} -+ -+static void hikp_nic_torus_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ struct bdf_t *bdf = &g_torus_target.bdf; -+ struct nic_torus_info info; -+ int ret; -+ -+ ret = hikp_nic_torus_query(bdf, &info); -+ if (ret != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "fail to obtain torus info."); -+ self->err_no = ret; -+ return; -+ } -+ -+ hikp_nic_torus_show(&info); -+} -+ -+static int hikp_nic_torus_cmd_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); -+ printf(" %s, %-25s %s\n", "-i", "--interface=", -+ "device target or bdf id, e.g. eth0~7 or 0000:35:00.0"); -+ -+ return 0; -+} -+ -+static int hikp_nic_torus_get_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_torus_target); -+ if (self->err_no != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "unknown device!"); -+ return self->err_no; -+ } -+ -+ if (g_torus_target.bdf.dev_id != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "VF does not support query!"); -+ self->err_no = -EOPNOTSUPP; -+ return self->err_no; -+ } -+ -+ return 0; -+} -+ -+static void cmd_nic_torus_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_nic_torus_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_nic_torus_cmd_help); -+ cmd_option_register("-i", "--interface", true, hikp_nic_torus_get_target); -+} -+ -+HIKP_CMD_DECLARE("nic_torus", "dump torus info of nic!", cmd_nic_torus_init); -diff --git a/net/nic/nic_torus/hikp_nic_torus.h b/net/nic/nic_torus/hikp_nic_torus.h -new file mode 100644 -index 0000000..e6b6552 ---- /dev/null -+++ b/net/nic/nic_torus/hikp_nic_torus.h -@@ -0,0 +1,76 @@ -+/* -+ * Copyright (c) 2023 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_NIC_TORUS_H -+#define HIKP_NIC_TORUS_H -+ -+#include "hikp_net_lib.h" -+ -+#define NIC_TORUS_MAC_ANTI_SPOOF_EN_MASK 0x1 -+#define NIC_TORUS_ALW_LPBK_MASK 0x2 -+#define NIC_TORUS_ALW_LCL_LPBK_MASK 0x4 -+#define NIC_TORUS_ALW_DST_OVRD_MASK 0x8 -+ -+#define NIC_TORUS_UC_LAN_PAIR_EN 16 -+#define NIC_TORUS_MC_BC_LAN_PAIR_EN 17 -+#define NIC_TORUS_LLDP_LAN_PAIR_EN 18 -+#define NIC_TORUS_TC2VLANPRI_MAPPING_EN 19 -+#define NIC_TORUS_LPBK_DROP_EN 20 -+ -+#define NIC_TORUS_MAC_ID_M GENMASK(1, 0) -+#define NIC_TORUS_MAC_ID_S 0 -+ -+#define NIC_TORUS_TC0_MAP_TC_M GENMASK(2, 0) -+#define NIC_TORUS_TC0_MAP_TC_S 0 -+#define NIC_TORUS_TC1_MAP_TC_M GENMASK(8, 6) -+#define NIC_TORUS_TC1_MAP_TC_S 6 -+#define NIC_TORUS_TC2_MAP_TC_M GENMASK(14, 12) -+#define NIC_TORUS_TC2_MAP_TC_S 12 -+#define NIC_TORUS_TC3_MAP_TC_M GENMASK(20, 18) -+#define NIC_TORUS_TC3_MAP_TC_S 18 -+ -+enum nic_torus_sub_cmd_type { -+ NIC_TORUS_INFO_DUMP, -+}; -+ -+struct nic_torus_req_para { -+ struct bdf_t bdf; -+ uint8_t block_id; -+ uint8_t rsv[3]; -+}; -+ -+struct nic_torus_rsp_head { -+ uint8_t total_blk_num; -+ uint8_t curr_blk_size; /* real data size, not contain head size. */ -+ uint16_t rsv; -+}; -+ -+#define NIC_TORUS_MAX_RSP_DATA 6 -+struct nic_torus_rsp { -+ struct nic_torus_rsp_head head; -+ uint32_t data[NIC_TORUS_MAX_RSP_DATA]; -+}; -+ -+struct nic_torus_info { -+ uint32_t enable; -+ uint32_t lan_prt_pair; -+ uint32_t lan_fwd_tc_cfg; -+ uint32_t pause_time_out; -+ uint8_t pause_time_out_en; -+ uint8_t vlan_fe; -+ uint8_t nic_switch_param; -+ uint8_t roce_switch_param; -+ uint32_t ets_tcg0_mapping; -+}; -+ -+#endif /* HIKP_NIC_TORUS_H */ --- -2.30.0 - diff --git a/0037-hikptool-optimized-display-the-hot-plug-card-info-in.patch b/0037-hikptool-optimized-display-the-hot-plug-card-info-in.patch deleted file mode 100644 index a1c05426f8c3a2e1d7d0ced5f5b2d08a35dde290..0000000000000000000000000000000000000000 --- a/0037-hikptool-optimized-display-the-hot-plug-card-info-in.patch +++ /dev/null @@ -1,140 +0,0 @@ -From 16154c431d5c694707b12cdb3ab3b52207d9c44d Mon Sep 17 00:00:00 2001 -From: veega -Date: Fri, 15 Sep 2023 09:32:33 +0800 -Subject: [PATCH] hikptool: optimized display the hot-plug card info in - nic_port cmd - -A command word was added to query the port information display capability. -If a port does not support a flexible card, the card information is not displayed. - -Signed-off-by: veega ---- - net/nic/nic_mac/hikp_mac_cmd.h | 1 + - net/nic/nic_mac/hikp_nic_port.c | 81 +++++++++++++++++++++------------ - net/nic/nic_mac/hikp_nic_port.h | 17 ++++--- - 3 files changed, 65 insertions(+), 34 deletions(-) - -diff --git a/net/nic/nic_mac/hikp_mac_cmd.h b/net/nic/nic_mac/hikp_mac_cmd.h -index adaadf4..f74fd2a 100644 ---- a/net/nic/nic_mac/hikp_mac_cmd.h -+++ b/net/nic/nic_mac/hikp_mac_cmd.h -@@ -31,6 +31,7 @@ enum mac_port_sub_cmd { - QUERY_PORT_PHY_DFX, - QUERY_HOT_PLUG_CARD_DFX, - QUERY_PORT_CDR_DFX, -+ QUERY_PORT_INFO_DFX_CAP, - }; - - enum mac_dump_reg_sub_cmd { -diff --git a/net/nic/nic_mac/hikp_nic_port.c b/net/nic/nic_mac/hikp_nic_port.c -index c9f46fc..5ba6927 100644 ---- a/net/nic/nic_mac/hikp_nic_port.c -+++ b/net/nic/nic_mac/hikp_nic_port.c -@@ -361,11 +361,12 @@ static void mac_cmd_disp_arb_info(const struct mac_cmd_arb_dfx *arb_dfx) - - static void mac_cmd_disp_hot_plug_card_info(const struct cmd_hot_plug_card_info *hpc_dfx) - { -- printf("\n======================== HOT PLUG CARD INFO =======================\n"); -+ printf("\n===================== HOT PLUG CARD INFO =====================\n"); - - printf("hot plug card in position: 0x%x\n", hpc_dfx->in_pos); - printf("support type: 0x%x\n", hpc_dfx->support_type); -- printf("current type: 0x%x\n", hpc_dfx->cur_type); -+ if (hpc_dfx->in_pos) -+ printf("current type: 0x%x\n", hpc_dfx->cur_type); - printf("----------------------------------------------------------------------------\n"); - } - -@@ -491,35 +492,59 @@ static void mac_cmd_show_port_dfx(struct major_cmd_ctrl *self, uint32_t mask) - } - } - --static void mac_cmd_port_execute(struct major_cmd_ctrl *self) -+static int mac_cmd_get_port_dfx_cap(uint32_t *cap) - { - struct mac_cmd_port_hardware *port_hw = NULL; -+ struct mac_cmd_port_dfx_cap *dfx_cap = NULL; -+ struct hikp_cmd_ret *dfx_cap_resp = NULL; - struct hikp_cmd_ret *hw_cmd_ret = NULL; -- uint32_t mask; - int ret; - -- if (!g_port_info.port_flag) { -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), "Need port id."); -- return; -+ ret = mac_cmd_get_dfx_cfg(QUERY_PORT_INFO_DFX_CAP, &dfx_cap_resp); -+ if (ret == 0) { -+ dfx_cap = (struct mac_cmd_port_dfx_cap *)dfx_cap_resp->rsp_data; -+ *cap = dfx_cap->cap_bit_map; -+ free(dfx_cap_resp); -+ dfx_cap_resp = NULL; -+ return ret; - } - -+ /* not support get capability, so use old process */ - ret = mac_cmd_get_dfx_cfg(QUERY_PORT_HARDWARE, &hw_cmd_ret); -- if (ret != 0) { -- printf("hikp_data_proc get port hw failed.\n"); -- self->err_no = -ENOSPC; -- return; -- } -+ if (ret) -+ return ret; - -- mask = MAC_LSPORT_LINK | MAC_LSPORT_MAC | -- MAC_LSPORT_ARB | MAC_HOT_PLUG_CARD | MAC_LSPORT_CDR; -+ *cap = MAC_LSPORT_LINK | MAC_LSPORT_MAC | MAC_LSPORT_ARB | -+ MAC_HOT_PLUG_CARD | MAC_LSPORT_CDR; - port_hw = (struct mac_cmd_port_hardware *)(hw_cmd_ret->rsp_data); - if (port_hw->port_type == HIKP_PORT_TYPE_PHY || - port_hw->port_type == HIKP_PORT_TYPE_PHY_SDS) -- mask |= MAC_LSPORT_PHY; -+ *cap |= MAC_LSPORT_PHY; - -- mac_cmd_show_port_dfx(self, mask); - free(hw_cmd_ret); -+ hw_cmd_ret = NULL; -+ return ret; -+} -+ -+static void mac_cmd_port_execute(struct major_cmd_ctrl *self) -+{ -+ uint32_t dfx_cap; -+ int ret; -+ -+ if (!g_port_info.port_flag) { -+ self->err_no = -EINVAL; -+ snprintf(self->err_str, sizeof(self->err_str), "Need port id."); -+ return; -+ } -+ -+ ret = mac_cmd_get_port_dfx_cap(&dfx_cap); -+ if (ret) { -+ self->err_no = ret; -+ snprintf(self->err_str, sizeof(self->err_str), "Get DFX capability failed."); -+ return; -+ } -+ -+ mac_cmd_show_port_dfx(self, dfx_cap); - } - - static int mac_cmd_get_port_target(struct major_cmd_ctrl *self, const char *argv) -diff --git a/net/nic/nic_mac/hikp_nic_port.h b/net/nic/nic_mac/hikp_nic_port.h -index 42ab3f9..78928b3 100644 ---- a/net/nic/nic_mac/hikp_nic_port.h -+++ b/net/nic/nic_mac/hikp_nic_port.h -@@ -225,6 +225,11 @@ struct mac_cmd_cdr_dfx { - struct mac_port_cdr_dfx host_cdr; - }; - -+struct mac_cmd_port_dfx_cap { -+ uint32_t cap_bit_map; -+ uint32_t rsvd[3]; -+}; -+ - struct mac_cmd_dfx_callback { - uint32_t mask; - void (*show_dfx)(struct major_cmd_ctrl *self); --- -2.36.1.windows.1 diff --git a/0038-hikptool-Update-the-tool-version-number-to-1.1.0.patch b/0038-hikptool-Update-the-tool-version-number-to-1.1.0.patch deleted file mode 100644 index 107e8df7854b3311c7c5f57b90bb66195f494b23..0000000000000000000000000000000000000000 --- a/0038-hikptool-Update-the-tool-version-number-to-1.1.0.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 6a571cd63eab0a5b8e6496964d6e3916b793b9bf Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Fri, 20 Oct 2023 21:30:31 +0800 -Subject: [PATCH] hikptool: Update the tool version number to 1.1.0 - -Update the tool version number to 1.1.0, the first SP3 release version - -Signed-off-by: veega2022 ---- - tool_lib/tool_lib.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index 6548b57..14b3db5 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.0.16" -+#define TOOL_VER "1.1.0" - - #define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask)) - #define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift)) --- -2.38.1.windows.1 - diff --git a/0039-hikptool-roce-Add-a-common-frame-for-hikptool-roce-r.patch b/0039-hikptool-roce-Add-a-common-frame-for-hikptool-roce-r.patch deleted file mode 100644 index b0c20fbf25b479b3aa84cff04e21e3dcd9460163..0000000000000000000000000000000000000000 --- a/0039-hikptool-roce-Add-a-common-frame-for-hikptool-roce-r.patch +++ /dev/null @@ -1,386 +0,0 @@ -From 8b3b68347165b602cded484d090509426f88cc75 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Mon, 31 Jul 2023 21:19:46 +0800 -Subject: hikptool/roce: Add a common frame for hikptool roce register query - -Add a common frame for hikptool roce register query. - -Signed-off-by: Junxian Huang ---- - net/roce/roce_caep/hikp_roce_caep.h | 2 +- - .../roce_ext_common/hikp_roce_ext_common.c | 178 ++++++++++++++++++ - .../roce_ext_common/hikp_roce_ext_common.h | 52 +++++ - net/roce/roce_gmv/hikp_roce_gmv.h | 2 +- - net/roce/roce_mdb/hikp_roce_mdb.h | 2 +- - net/roce/roce_pkt/hikp_roce_pkt.h | 2 +- - net/roce/roce_qmm/hikp_roce_qmm.h | 2 +- - net/roce/roce_scc/hikp_roce_scc.h | 2 +- - net/roce/roce_timer/hikp_roce_timer.h | 2 +- - net/roce/roce_trp/hikp_roce_trp.h | 2 +- - net/roce/roce_tsp/hikp_roce_tsp.h | 2 +- - 11 files changed, 239 insertions(+), 9 deletions(-) - create mode 100644 net/roce/roce_ext_common/hikp_roce_ext_common.c - create mode 100644 net/roce/roce_ext_common/hikp_roce_ext_common.h - -diff --git a/net/roce/roce_caep/hikp_roce_caep.h b/net/roce/roce_caep/hikp_roce_caep.h -index 3c494b1..804d2df 100644 ---- a/net/roce/roce_caep/hikp_roce_caep.h -+++ b/net/roce/roce_caep/hikp_roce_caep.h -@@ -14,7 +14,7 @@ - #ifndef __HIKP_ROCE_CAEP_H__ - #define __HIKP_ROCE_CAEP_H__ - --#include "hikp_net_lib.h" -+#include "hikp_roce_ext_common.h" - - #define ROCE_HIKP_CAEP_REG_NUM 29 - #define PER_REG_NUM 2 -diff --git a/net/roce/roce_ext_common/hikp_roce_ext_common.c b/net/roce/roce_ext_common/hikp_roce_ext_common.c -new file mode 100644 -index 0000000..ec47dce ---- /dev/null -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -0,0 +1,178 @@ -+/* -+ * Copyright (c) 2023 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_ext_common.h" -+ -+static void hikp_roce_ext_reg_data_free(struct reg_data *reg) -+{ -+ if (reg->offset) -+ free(reg->offset); -+ -+ if (reg->data) -+ free(reg->data); -+} -+ -+static void hikp_roce_ext_cmd_ret_free(struct hikp_cmd_ret *cmd_ret) -+{ -+ if (cmd_ret) -+ free(cmd_ret); -+} -+ -+static const struct cmd_type_info { -+ enum roce_cmd_type cmd_type; -+ const char *cmd_name; -+ uint8_t reg_array_length; -+} cmd_info_table[] = { -+ {GET_ROCEE_MDB_CMD, "MDB", ROCE_HIKP_MDB_REG_NUM_EXT}, -+ {GET_ROCEE_GMV_CMD, "GMV", ROCE_HIKP_GMV_REG_NUM_EXT}, -+ {GET_ROCEE_CAEP_CMD, "CAEP", ROCE_HIKP_CAEP_REG_NUM_EXT}, -+ {GET_ROCEE_PKT_CMD, "PKT", ROCE_HIKP_PKT_REG_NUM_EXT}, -+ {GET_ROCEE_SCC_CMD, "SCC", ROCE_HIKP_SCC_REG_NUM_EXT}, -+ {GET_ROCEE_QMM_CMD, "QMM", ROCE_HIKP_QMM_REG_NUM_EXT}, -+ {GET_ROCEE_TIMER_CMD, "TIMER", ROCE_HIKP_TIMER_REG_NUM_EXT}, -+ {GET_ROCEE_TRP_CMD, "TRP", ROCE_HIKP_TRP_REG_NUM_EXT}, -+ {GET_ROCEE_TSP_CMD, "TSP", ROCE_HIKP_TSP_REG_NUM_EXT}, -+}; -+ -+static int get_cmd_info_table_idx(enum roce_cmd_type cmd_type) -+{ -+ int array_size = sizeof(cmd_info_table) / sizeof(struct cmd_type_info); -+ int i; -+ -+ for (i = 0; i < array_size; i++) -+ if (cmd_type == cmd_info_table[i].cmd_type) -+ return i; -+ -+ return -ENOENT; -+} -+ -+static const char *get_cmd_name(enum roce_cmd_type cmd_type) -+{ -+ int idx; -+ -+ idx = get_cmd_info_table_idx(cmd_type); -+ if (idx >= 0) -+ return cmd_info_table[idx].cmd_name; -+ -+ printf("Failed to get cmd name, cmd_type = %d\n", cmd_type); -+ return NULL; -+} -+ -+static int get_cmd_reg_array_length(enum roce_cmd_type cmd_type) -+{ -+ int idx; -+ -+ idx = get_cmd_info_table_idx(cmd_type); -+ if (idx >= 0) -+ return cmd_info_table[idx].reg_array_length; -+ -+ printf("Failed to get cmd reg array length, cmd_type = %d\n", cmd_type); -+ return idx; -+} -+ -+static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, -+ uint32_t block_id, -+ struct roce_ext_head *res_head, -+ struct reg_data *reg, -+ int (*get_data)(struct hikp_cmd_ret **cmd_ret, -+ uint32_t block_id)) -+{ -+ int reg_array_length = get_cmd_reg_array_length(cmd_type); -+ const char *cmd_name = get_cmd_name(cmd_type); -+ struct roce_ext_res_param *roce_ext_res; -+ struct hikp_cmd_ret *cmd_ret; -+ size_t max_size; -+ size_t cur_size; -+ int ret; -+ -+ /* reg_array_length greater than or equal to 0 ensures that cmd_name -+ * is not NULL, so cmd_name does not need to be checked. -+ */ -+ if (reg_array_length < 0) -+ return reg_array_length; -+ -+ ret = get_data(&cmd_ret, block_id); -+ if (ret) { -+ printf("hikptool roce_%s get data failed!\n", cmd_name); -+ goto get_data_error; -+ } -+ -+ roce_ext_res = (struct roce_ext_res_param *)cmd_ret->rsp_data; -+ *res_head = roce_ext_res->head; -+ max_size = res_head->total_block_num * sizeof(uint32_t); -+ -+ if (block_id == 0) { -+ reg->offset = (uint32_t *)malloc(max_size); -+ reg->data = (uint32_t *)malloc(max_size); -+ if ((reg->offset == NULL) || (reg->data == NULL)) { -+ printf("hikptool roce_%s alloc log memmory 0x%x failed!\n", -+ cmd_name, max_size); -+ ret = -ENOMEM; -+ hikp_roce_ext_reg_data_free(reg); -+ goto get_data_error; -+ } -+ } -+ -+ cur_size = res_head->cur_block_num * sizeof(uint32_t); -+ if (cur_size > max_size) { -+ printf("hikptool roce_%s log data copy size error, data size: 0x%x, max size: 0x%x\n", -+ cmd_name, cur_size, max_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, -+ (uint32_t *)&roce_ext_res->reg_data + reg_array_length, cur_size); -+ -+get_data_error: -+ hikp_roce_ext_cmd_ret_free(cmd_ret); -+ return ret; -+} -+ -+static void hikp_roce_ext_print(const char *cmd_name, uint32_t total_block_num, -+ const uint32_t *offset, const uint32_t *data) -+{ -+ int i; -+ -+ printf("**************%s INFO*************\n", cmd_name); -+ for (i = 0; i < total_block_num; i++) -+ printf("[0x%08X] : 0x%08X\n", offset[i], data[i]); -+ printf("************************************\n"); -+} -+ -+void hikp_roce_ext_execute(struct major_cmd_ctrl *self, -+ enum roce_cmd_type cmd_type, -+ int (*get_data)(struct hikp_cmd_ret **cmd_ret, -+ uint32_t block_id)) -+{ -+ uint32_t queried_block_id = 0; -+ struct roce_ext_head res_head; -+ struct reg_data reg = { 0 }; -+ -+ do { -+ self->err_no = hikp_roce_ext_get_res(cmd_type, queried_block_id, -+ &res_head, ®, get_data); -+ if (self->err_no) -+ return; -+ -+ queried_block_id += res_head.cur_block_num; -+ } while (queried_block_id < res_head.total_block_num); -+ -+ hikp_roce_ext_print(get_cmd_name(cmd_type), res_head.total_block_num, -+ reg.offset, reg.data); -+ -+ hikp_roce_ext_reg_data_free(®); -+} -diff --git a/net/roce/roce_ext_common/hikp_roce_ext_common.h b/net/roce/roce_ext_common/hikp_roce_ext_common.h -new file mode 100644 -index 0000000..1e8063d ---- /dev/null -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.h -@@ -0,0 +1,52 @@ -+/* -+ * Copyright (c) 2023 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_EXT_COMMON_H__ -+#define __HIKP_ROCE_EXT_COMMON_H__ -+ -+#include "hikp_net_lib.h" -+ -+#define ROCE_MAX_REG_NUM (NET_MAX_REQ_DATA_NUM - 1) -+ -+#define ROCE_HIKP_CAEP_REG_NUM_EXT ROCE_MAX_REG_NUM -+#define ROCE_HIKP_GMV_REG_NUM_EXT ROCE_MAX_REG_NUM -+#define ROCE_HIKP_MDB_REG_NUM_EXT ROCE_MAX_REG_NUM -+#define ROCE_HIKP_PKT_REG_NUM_EXT ROCE_MAX_REG_NUM -+#define ROCE_HIKP_QMM_REG_NUM_EXT ROCE_MAX_REG_NUM -+#define ROCE_HIKP_SCC_REG_NUM_EXT ROCE_MAX_REG_NUM -+#define ROCE_HIKP_TIMER_REG_NUM_EXT ROCE_MAX_REG_NUM -+#define ROCE_HIKP_TRP_REG_NUM_EXT ROCE_MAX_REG_NUM -+#define ROCE_HIKP_TSP_REG_NUM_EXT ROCE_MAX_REG_NUM -+ -+struct roce_ext_head { -+ uint8_t total_block_num; -+ uint8_t cur_block_num; -+ uint16_t reserved; -+}; -+ -+struct roce_ext_res_param { -+ struct roce_ext_head head; -+ uint32_t reg_data[0]; -+}; -+ -+struct reg_data { -+ uint32_t *offset; -+ uint32_t *data; -+}; -+ -+void hikp_roce_ext_execute(struct major_cmd_ctrl *self, -+ enum roce_cmd_type cmd_type, -+ int (*get_data)(struct hikp_cmd_ret **cmd_ret, -+ uint32_t block_id)); -+ -+#endif /* __HIKP_ROCE_EXT_COMMON_H__ */ -diff --git a/net/roce/roce_gmv/hikp_roce_gmv.h b/net/roce/roce_gmv/hikp_roce_gmv.h -index 30f37fb..1ef5b93 100644 ---- a/net/roce/roce_gmv/hikp_roce_gmv.h -+++ b/net/roce/roce_gmv/hikp_roce_gmv.h -@@ -14,7 +14,7 @@ - #ifndef __HIKP_ROCE_GMV_H__ - #define __HIKP_ROCE_GMV_H__ - --#include "hikp_net_lib.h" -+#include "hikp_roce_ext_common.h" - - #define ROCE_HIKP_GMV_REG_NUM 7 - #define ROCE_HIKP_GMV_REG_SWICTH 2 -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.h b/net/roce/roce_mdb/hikp_roce_mdb.h -index 8e7da03..7643dff 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.h -+++ b/net/roce/roce_mdb/hikp_roce_mdb.h -@@ -14,7 +14,7 @@ - #ifndef __HIKP_ROCE_MDB_H__ - #define __HIKP_ROCE_MDB_H__ - --#include "hikp_net_lib.h" -+#include "hikp_roce_ext_common.h" - - #define ROCE_HIKP_MDB_REG_NUM 22 - #define ROCE_HIKP_REG_SWICTH 2 -diff --git a/net/roce/roce_pkt/hikp_roce_pkt.h b/net/roce/roce_pkt/hikp_roce_pkt.h -index 5f438b7..0200c44 100644 ---- a/net/roce/roce_pkt/hikp_roce_pkt.h -+++ b/net/roce/roce_pkt/hikp_roce_pkt.h -@@ -14,7 +14,7 @@ - #ifndef __HIKP_ROCE_PKT_H__ - #define __HIKP_ROCE_PKT_H__ - --#include "hikp_net_lib.h" -+#include "hikp_roce_ext_common.h" - - #define ROCE_HIKP_PKT_REG_NUM 29 - #define PKT_PER_REG_NUM 2 -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.h b/net/roce/roce_qmm/hikp_roce_qmm.h -index 08cb5d2..0645ab3 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.h -+++ b/net/roce/roce_qmm/hikp_roce_qmm.h -@@ -14,7 +14,7 @@ - #ifndef __HIKP_ROCE_QMM_H__ - #define __HIKP_ROCE_QMM_H__ - --#include "hikp_net_lib.h" -+#include "hikp_roce_ext_common.h" - - #define ROCE_HIKP_QMM_REG_NUM 36 - #define QMM_BANK_NUM 0x7 -diff --git a/net/roce/roce_scc/hikp_roce_scc.h b/net/roce/roce_scc/hikp_roce_scc.h -index de8772e..5d37a11 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.h -+++ b/net/roce/roce_scc/hikp_roce_scc.h -@@ -14,7 +14,7 @@ - #ifndef __HIKP_ROCE_SCC_H__ - #define __HIKP_ROCE_SCC_H__ - --#include "hikp_net_lib.h" -+#include "hikp_roce_ext_common.h" - - #define ROCE_HIKP_SCC_REG_NUM 29 - #define MAX_SCC_MODULE_NAME_LEN 20 -diff --git a/net/roce/roce_timer/hikp_roce_timer.h b/net/roce/roce_timer/hikp_roce_timer.h -index a4a32b1..7f7deb6 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.h -+++ b/net/roce/roce_timer/hikp_roce_timer.h -@@ -14,7 +14,7 @@ - #ifndef __HIKP_ROCE_TIMER_H__ - #define __HIKP_ROCE_TIMER_H__ - --#include "hikp_net_lib.h" -+#include "hikp_roce_ext_common.h" - - #define ROCE_HIKP_TIMER_REG_NUM 25 - #define ROCE_TIMER_CMD_CLEAR (1 << 0) -diff --git a/net/roce/roce_trp/hikp_roce_trp.h b/net/roce/roce_trp/hikp_roce_trp.h -index 80d28af..97f1838 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.h -+++ b/net/roce/roce_trp/hikp_roce_trp.h -@@ -14,7 +14,7 @@ - #ifndef __HIKP_ROCE_TRP_H__ - #define __HIKP_ROCE_TRP_H__ - --#include "hikp_net_lib.h" -+#include "hikp_roce_ext_common.h" - - #define TRP_DIV_NUM_T 4 - #define ROCE_HIKP_TRP_REG_NUM 29 -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.h b/net/roce/roce_tsp/hikp_roce_tsp.h -index ae864ba..43d0d0d 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.h -+++ b/net/roce/roce_tsp/hikp_roce_tsp.h -@@ -14,7 +14,7 @@ - #ifndef __HIKP_ROCE_TSP_H__ - #define __HIKP_ROCE_TSP_H__ - --#include "hikp_net_lib.h" -+#include "hikp_roce_ext_common.h" - - #define ROCE_HIKP_TSP_REG_NUM 29 - #define TSP_PER_REG_NUM 2 --- -2.30.0 - diff --git a/0040-hikptool-roce-Add-roce_rst-cmd-for-reset-signal-regi.patch b/0040-hikptool-roce-Add-roce_rst-cmd-for-reset-signal-regi.patch deleted file mode 100644 index 22312d35d94e39fcb37135997299b74919ba42b8..0000000000000000000000000000000000000000 --- a/0040-hikptool-roce-Add-roce_rst-cmd-for-reset-signal-regi.patch +++ /dev/null @@ -1,179 +0,0 @@ -From a0ac3e3cd5e94657ee1a58c74037aa6898898c75 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Fri, 4 Aug 2023 17:25:53 +0800 -Subject: hikptool/roce: Add roce_rst cmd for reset signal registers query - -Add roce_rst cmd for reset signal registers query. - -Example: -hikptool roce_rst -i eth1 - -Signed-off-by: Junxian Huang ---- - net/hikp_net_lib.h | 1 + - .../roce_ext_common/hikp_roce_ext_common.c | 1 + - .../roce_ext_common/hikp_roce_ext_common.h | 1 + - net/roce/roce_rst/hikp_roce_rst.c | 78 +++++++++++++++++++ - net/roce/roce_rst/hikp_roce_rst.h | 29 +++++++ - 5 files changed, 110 insertions(+) - create mode 100644 net/roce/roce_rst/hikp_roce_rst.c - create mode 100644 net/roce/roce_rst/hikp_roce_rst.h - -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index 21b5357..e60fc15 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -100,6 +100,7 @@ enum roce_cmd_type { - GET_ROCEE_TIMER_CMD, - GET_ROCEE_TRP_CMD, - GET_ROCEE_TSP_CMD, -+ GET_ROCEE_RST_CMD, - }; - - enum ub_cmd_type { -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 ec47dce..01dded5 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -42,6 +42,7 @@ static const struct cmd_type_info { - {GET_ROCEE_TIMER_CMD, "TIMER", ROCE_HIKP_TIMER_REG_NUM_EXT}, - {GET_ROCEE_TRP_CMD, "TRP", ROCE_HIKP_TRP_REG_NUM_EXT}, - {GET_ROCEE_TSP_CMD, "TSP", ROCE_HIKP_TSP_REG_NUM_EXT}, -+ {GET_ROCEE_RST_CMD, "RST", ROCE_HIKP_RST_REG_NUM}, - }; - - static int get_cmd_info_table_idx(enum roce_cmd_type cmd_type) -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 1e8063d..918712f 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.h -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.h -@@ -27,6 +27,7 @@ - #define ROCE_HIKP_TIMER_REG_NUM_EXT ROCE_MAX_REG_NUM - #define ROCE_HIKP_TRP_REG_NUM_EXT ROCE_MAX_REG_NUM - #define ROCE_HIKP_TSP_REG_NUM_EXT ROCE_MAX_REG_NUM -+#define ROCE_HIKP_RST_REG_NUM ROCE_MAX_REG_NUM - - struct roce_ext_head { - uint8_t total_block_num; -diff --git a/net/roce/roce_rst/hikp_roce_rst.c b/net/roce/roce_rst/hikp_roce_rst.c -new file mode 100644 -index 0000000..ad4dd0c ---- /dev/null -+++ b/net/roce/roce_rst/hikp_roce_rst.c -@@ -0,0 +1,78 @@ -+/* -+ * Copyright (c) 2023 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_rst.h" -+ -+static struct cmd_roce_rst_param g_roce_rst_param = { 0 }; -+ -+static int hikp_roce_rst_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \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=", "device target, e.g. eth0"); -+ printf("\n"); -+ -+ return 0; -+} -+ -+static int hikp_roce_rst_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_roce_rst_param.target)); -+ if (self->err_no) -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.\n", argv); -+ -+ return self->err_no; -+} -+ -+static int hikp_roce_rst_get_data(struct hikp_cmd_ret **cmd_ret, -+ uint32_t block_id) -+{ -+ struct hikp_cmd_header req_header = { 0 }; -+ struct roce_rst_req_param req_data; -+ uint32_t req_size; -+ int ret; -+ -+ req_data.bdf = g_roce_rst_param.target.bdf; -+ req_data.block_id = block_id; -+ -+ req_size = sizeof(struct roce_rst_req_param); -+ hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_RST_CMD, -+ g_roce_rst_param.sub_cmd); -+ *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, req_size); -+ ret = hikp_rsp_normal_check(*cmd_ret); -+ if (ret) -+ printf("hikptool roce_rst cmd_ret malloc failed, sub_cmd = %u, ret = %d.\n", -+ g_roce_rst_param.sub_cmd, ret); -+ -+ return ret; -+} -+ -+static void hikp_roce_rst_execute(struct major_cmd_ctrl *self) -+{ -+ hikp_roce_ext_execute(self, GET_ROCEE_RST_CMD, hikp_roce_rst_get_data); -+} -+ -+static void cmd_roce_rst_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_roce_rst_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_roce_rst_help); -+ cmd_option_register("-i", "--interface", true, hikp_roce_rst_target); -+} -+ -+HIKP_CMD_DECLARE("roce_rst", "get roce_rst registers information", cmd_roce_rst_init); -diff --git a/net/roce/roce_rst/hikp_roce_rst.h b/net/roce/roce_rst/hikp_roce_rst.h -new file mode 100644 -index 0000000..731effc ---- /dev/null -+++ b/net/roce/roce_rst/hikp_roce_rst.h -@@ -0,0 +1,29 @@ -+/* -+ * Copyright (c) 2023 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_RST_H__ -+#define __HIKP_ROCE_RST_H__ -+ -+#include "hikp_roce_ext_common.h" -+ -+struct cmd_roce_rst_param { -+ struct tool_target target; -+ uint32_t sub_cmd; -+}; -+ -+struct roce_rst_req_param { -+ struct bdf_t bdf; -+ uint32_t block_id; -+}; -+ -+#endif /* __HIKP_ROCE_RST_H__ */ --- -2.30.0 - diff --git a/0041-hikptool-roce-Add-roce_global_cfg-cmd-for-global-con.patch b/0041-hikptool-roce-Add-roce_global_cfg-cmd-for-global-con.patch deleted file mode 100644 index 460cad38259fcdde17e6a15907c9e5b49dec25e2..0000000000000000000000000000000000000000 --- a/0041-hikptool-roce-Add-roce_global_cfg-cmd-for-global-con.patch +++ /dev/null @@ -1,210 +0,0 @@ -From 36ba114387e6b262d5a55b397a47e63fd0e75d0a Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Wed, 2 Aug 2023 16:12:49 +0800 -Subject: hikptool/roce: Add roce_global_cfg cmd for global config registers - query - -Add roce_global_cfg cmd for global config registers query - -Example: -hikptool roce_global_cfg -i eth1 - -Signed-off-by: Junxian Huang ---- - net/hikp_net_lib.h | 1 + - .../roce_ext_common/hikp_roce_ext_common.c | 1 + - .../roce_ext_common/hikp_roce_ext_common.h | 1 + - .../roce_global_cfg/hikp_roce_global_cfg.c | 97 +++++++++++++++++++ - .../roce_global_cfg/hikp_roce_global_cfg.h | 40 ++++++++ - 5 files changed, 140 insertions(+) - create mode 100644 net/roce/roce_global_cfg/hikp_roce_global_cfg.c - create mode 100644 net/roce/roce_global_cfg/hikp_roce_global_cfg.h - -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index e60fc15..bdaacb1 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -101,6 +101,7 @@ enum roce_cmd_type { - GET_ROCEE_TRP_CMD, - GET_ROCEE_TSP_CMD, - GET_ROCEE_RST_CMD, -+ GET_ROCEE_GLOBAL_CFG_CMD, - }; - - enum ub_cmd_type { -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 01dded5..0ff07dc 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -43,6 +43,7 @@ static const struct cmd_type_info { - {GET_ROCEE_TRP_CMD, "TRP", ROCE_HIKP_TRP_REG_NUM_EXT}, - {GET_ROCEE_TSP_CMD, "TSP", ROCE_HIKP_TSP_REG_NUM_EXT}, - {GET_ROCEE_RST_CMD, "RST", ROCE_HIKP_RST_REG_NUM}, -+ {GET_ROCEE_GLOBAL_CFG_CMD, "GLOBAL_CFG", ROCE_HIKP_GLOBAL_CFG_REG_NUM}, - }; - - static int get_cmd_info_table_idx(enum roce_cmd_type cmd_type) -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 918712f..870a361 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.h -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.h -@@ -28,6 +28,7 @@ - #define ROCE_HIKP_TRP_REG_NUM_EXT ROCE_MAX_REG_NUM - #define ROCE_HIKP_TSP_REG_NUM_EXT ROCE_MAX_REG_NUM - #define ROCE_HIKP_RST_REG_NUM ROCE_MAX_REG_NUM -+#define ROCE_HIKP_GLOBAL_CFG_REG_NUM ROCE_MAX_REG_NUM - - struct roce_ext_head { - uint8_t total_block_num; -diff --git a/net/roce/roce_global_cfg/hikp_roce_global_cfg.c b/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -new file mode 100644 -index 0000000..49a4a2c ---- /dev/null -+++ b/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -@@ -0,0 +1,97 @@ -+/* -+ * Copyright (c) 2023 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_global_cfg.h" -+ -+static struct cmd_roce_global_cfg_param g_roce_global_cfg_param = { 0 }; -+ -+static int hikp_roce_global_cfg_help(struct major_cmd_ctrl *self, -+ const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \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=", "device target, e.g. eth0"); -+ printf("\n"); -+ -+ return 0; -+} -+ -+static int hikp_roce_global_cfg_target(struct major_cmd_ctrl *self, -+ const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_roce_global_cfg_param.target)); -+ if (self->err_no) -+ snprintf(self->err_str, sizeof(self->err_str), -+ "Unknown device %s.\n", argv); -+ -+ return self->err_no; -+} -+ -+static int hikp_roce_global_cfg_get_data(struct hikp_cmd_ret **cmd_ret, -+ uint32_t block_id) -+{ -+ struct hikp_cmd_header req_header = { 0 }; -+ struct roce_global_cfg_req_param req_data; -+ uint32_t req_size; -+ int ret; -+ -+ req_data.bdf = g_roce_global_cfg_param.target.bdf; -+ req_data.block_id = block_id; -+ -+ req_size = sizeof(struct roce_global_cfg_req_param); -+ hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_GLOBAL_CFG_CMD, -+ g_roce_global_cfg_param.sub_cmd); -+ *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, req_size); -+ ret = hikp_rsp_normal_check(*cmd_ret); -+ if (ret) -+ printf("hikptool roce_global_cfg cmd_ret malloc failed, sub_cmd = %u, ret = %d.\n", -+ g_roce_global_cfg_param.sub_cmd, ret); -+ -+ return ret; -+} -+ -+static void hikp_roce_global_cfg_execute(struct major_cmd_ctrl *self) -+{ -+ enum roce_global_cfg_cmd_type sub_cmds[] = { -+ ROCE_GLB_GENAC, -+ ROCE_GLB_TRP_BANK, -+ ROCE_GLB_TRP_RX, -+ ROCE_GLB_TPP_M, -+ ROCE_GLB_QMM, -+ ROCE_GLB_TGP_TMP, -+ ROCE_GLB_TDP_M, -+ ROCE_GLB_NICL, -+ }; -+ int i; -+ -+ for (i = 0; i < HIKP_ARRAY_SIZE(sub_cmds); i++) { -+ g_roce_global_cfg_param.sub_cmd = sub_cmds[i]; -+ hikp_roce_ext_execute(self, GET_ROCEE_GLOBAL_CFG_CMD, -+ hikp_roce_global_cfg_get_data); -+ } -+} -+ -+static void cmd_roce_global_cfg_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_roce_global_cfg_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_roce_global_cfg_help); -+ cmd_option_register("-i", "--interface", true, hikp_roce_global_cfg_target); -+} -+ -+HIKP_CMD_DECLARE("roce_global_cfg", "get roce_global_cfg registers information", cmd_roce_global_cfg_init); -diff --git a/net/roce/roce_global_cfg/hikp_roce_global_cfg.h b/net/roce/roce_global_cfg/hikp_roce_global_cfg.h -new file mode 100644 -index 0000000..66e7fb8 ---- /dev/null -+++ b/net/roce/roce_global_cfg/hikp_roce_global_cfg.h -@@ -0,0 +1,40 @@ -+/* -+ * Copyright (c) 2023 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_GLOBAL_CFG_H__ -+#define __HIKP_ROCE_GLOBAL_CFG_H__ -+ -+#include "hikp_roce_ext_common.h" -+ -+struct cmd_roce_global_cfg_param { -+ struct tool_target target; -+ uint32_t sub_cmd; -+}; -+ -+struct roce_global_cfg_req_param { -+ struct bdf_t bdf; -+ uint32_t block_id; -+}; -+ -+enum roce_global_cfg_cmd_type { -+ ROCE_GLB_GENAC = 0, -+ ROCE_GLB_TRP_BANK, -+ ROCE_GLB_TRP_RX, -+ ROCE_GLB_TPP_M, -+ ROCE_GLB_QMM, -+ ROCE_GLB_TGP_TMP, -+ ROCE_GLB_TDP_M, -+ ROCE_GLB_NICL, -+}; -+ -+#endif /* __HIKP_ROCE_GLOBAL_CFG_H__ */ --- -2.30.0 - diff --git a/0042-hikptool-roce-Add-roce_bond-cmd-for-bond-registers-q.patch b/0042-hikptool-roce-Add-roce_bond-cmd-for-bond-registers-q.patch deleted file mode 100644 index d35e5337339ebc6b8d98606a1c63198b43943b42..0000000000000000000000000000000000000000 --- a/0042-hikptool-roce-Add-roce_bond-cmd-for-bond-registers-q.patch +++ /dev/null @@ -1,179 +0,0 @@ -From 7f0a2e3f2dff9b49ce5be8b07835fa7c791cdce1 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Wed, 2 Aug 2023 16:17:40 +0800 -Subject: hikptool/roce: Add roce_bond cmd for bond registers query - -Add roce_bond cmd for bond registers query. - -Example: -hikptool roce_bond -i eth1 - -Signed-off-by: Junxian Huang ---- - net/hikp_net_lib.h | 1 + - net/roce/roce_bond/hikp_roce_bond.c | 78 +++++++++++++++++++ - net/roce/roce_bond/hikp_roce_bond.h | 29 +++++++ - .../roce_ext_common/hikp_roce_ext_common.c | 1 + - .../roce_ext_common/hikp_roce_ext_common.h | 1 + - 5 files changed, 110 insertions(+) - create mode 100644 net/roce/roce_bond/hikp_roce_bond.c - create mode 100644 net/roce/roce_bond/hikp_roce_bond.h - -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index bdaacb1..ad9e7e4 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -102,6 +102,7 @@ enum roce_cmd_type { - GET_ROCEE_TSP_CMD, - GET_ROCEE_RST_CMD, - GET_ROCEE_GLOBAL_CFG_CMD, -+ GET_ROCEE_BOND_CMD, - }; - - enum ub_cmd_type { -diff --git a/net/roce/roce_bond/hikp_roce_bond.c b/net/roce/roce_bond/hikp_roce_bond.c -new file mode 100644 -index 0000000..89f8bab ---- /dev/null -+++ b/net/roce/roce_bond/hikp_roce_bond.c -@@ -0,0 +1,78 @@ -+/* -+ * Copyright (c) 2023 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_bond.h" -+ -+static struct cmd_roce_bond_param g_roce_bond_param = { 0 }; -+ -+static int hikp_roce_bond_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \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=", "device target, e.g. eth0"); -+ printf("\n"); -+ -+ return 0; -+} -+ -+static int hikp_roce_bond_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_roce_bond_param.target)); -+ if (self->err_no) -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.\n", argv); -+ -+ return self->err_no; -+} -+ -+static int hikp_roce_bond_get_data(struct hikp_cmd_ret **cmd_ret, -+ uint32_t block_id) -+{ -+ struct hikp_cmd_header req_header = { 0 }; -+ struct roce_bond_req_param req_data; -+ uint32_t req_size; -+ int ret; -+ -+ req_data.bdf = g_roce_bond_param.target.bdf; -+ req_data.block_id = block_id; -+ -+ req_size = sizeof(struct roce_bond_req_param); -+ hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_BOND_CMD, -+ g_roce_bond_param.sub_cmd); -+ *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, req_size); -+ ret = hikp_rsp_normal_check(*cmd_ret); -+ if (ret) -+ printf("hikptool roce_bond cmd_ret malloc failed, sub_cmd = %u, ret = %d.\n", -+ g_roce_bond_param.sub_cmd, ret); -+ -+ return ret; -+} -+ -+static void hikp_roce_bond_execute(struct major_cmd_ctrl *self) -+{ -+ hikp_roce_ext_execute(self, GET_ROCEE_BOND_CMD, hikp_roce_bond_get_data); -+} -+ -+static void cmd_roce_bond_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_roce_bond_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_roce_bond_help); -+ cmd_option_register("-i", "--interface", true, hikp_roce_bond_target); -+} -+ -+HIKP_CMD_DECLARE("roce_bond", "get roce_bond registers information", cmd_roce_bond_init); -diff --git a/net/roce/roce_bond/hikp_roce_bond.h b/net/roce/roce_bond/hikp_roce_bond.h -new file mode 100644 -index 0000000..14bd233 ---- /dev/null -+++ b/net/roce/roce_bond/hikp_roce_bond.h -@@ -0,0 +1,29 @@ -+/* -+ * Copyright (c) 2023 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_BOND_H__ -+#define __HIKP_ROCE_BOND_H__ -+ -+#include "hikp_roce_ext_common.h" -+ -+struct cmd_roce_bond_param { -+ struct tool_target target; -+ uint32_t sub_cmd; -+}; -+ -+struct roce_bond_req_param { -+ struct bdf_t bdf; -+ uint32_t block_id; -+}; -+ -+#endif /* __HIKP_ROCE_BOND_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 0ff07dc..d0fae69 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_TSP_CMD, "TSP", ROCE_HIKP_TSP_REG_NUM_EXT}, - {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}, - }; - - static int get_cmd_info_table_idx(enum roce_cmd_type cmd_type) -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 870a361..a600449 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.h -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.h -@@ -29,6 +29,7 @@ - #define ROCE_HIKP_TSP_REG_NUM_EXT ROCE_MAX_REG_NUM - #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 - - struct roce_ext_head { - uint8_t total_block_num; --- -2.30.0 - diff --git a/0043-hikptool-roce-Add-ext-query-for-roce_caep-cmd.patch b/0043-hikptool-roce-Add-ext-query-for-roce_caep-cmd.patch deleted file mode 100644 index 7ee6275c8ba0ec477de9b9eb180d3a00f5250aef..0000000000000000000000000000000000000000 --- a/0043-hikptool-roce-Add-ext-query-for-roce_caep-cmd.patch +++ /dev/null @@ -1,174 +0,0 @@ -From 80d9d76b7d5af23e58d13569bd1898604c8e2456 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Tue, 1 Aug 2023 17:41:24 +0800 -Subject: hikptool/roce: Add ext query for roce_caep cmd - -Add ext query for roce_caep cmd. To query these ext registers, add --e to the query cmd. - -Example: -hikptool roce_caep -i eth1 -e - -Signed-off-by: Junxian Huang ---- - net/roce/roce_caep/hikp_roce_caep.c | 69 +++++++++++++++++++---------- - net/roce/roce_caep/hikp_roce_caep.h | 11 +++++ - 2 files changed, 57 insertions(+), 23 deletions(-) - -diff --git a/net/roce/roce_caep/hikp_roce_caep.c b/net/roce/roce_caep/hikp_roce_caep.c -index 69a4742..6c92ea1 100644 ---- a/net/roce/roce_caep/hikp_roce_caep.c -+++ b/net/roce/roce_caep/hikp_roce_caep.c -@@ -22,6 +22,7 @@ static int hikp_roce_caep_help(struct major_cmd_ctrl *self, const char *argv) - printf(" Options:\n\n"); - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); - printf(" %s, %-25s %s\n", "-i", "--interface=", "device target, e.g. eth0"); -+ printf(" %s, %-25s %s\n", "-e", "--extend", "query extend caep registers"); - printf("\n"); - - return 0; -@@ -31,7 +32,7 @@ static int hikp_roce_caep_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_roce_caep_param_t.target)); - if (self->err_no != 0) { -- snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.\n", argv); - return self->err_no; - } - -@@ -39,18 +40,28 @@ static int hikp_roce_caep_target(struct major_cmd_ctrl *self, const char *argv) - } - - static int hikp_roce_caep_get_data(struct hikp_cmd_ret **cmd_ret, -- struct roce_caep_req_param req_data) -+ uint32_t block_id) - { -+ struct roce_caep_req_param_ext req_data_ext; - struct hikp_cmd_header req_header = { 0 }; -+ uint32_t req_size; -+ int ret; - -- hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_CAEP_CMD, 0); -- *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (*cmd_ret == NULL) { -- printf("hikptool roce_caep cmd_ret malloc failed\n"); -- return -EIO; -- } -- -- return 0; -+ req_data_ext.origin_param.bdf = g_roce_caep_param_t.target.bdf; -+ req_data_ext.block_id = block_id; -+ -+ req_size = (g_roce_caep_param_t.sub_cmd == CAEP_ORIGIN) ? -+ sizeof(struct roce_caep_req_param) : -+ sizeof(struct roce_caep_req_param_ext); -+ hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_CAEP_CMD, -+ g_roce_caep_param_t.sub_cmd); -+ *cmd_ret = hikp_cmd_alloc(&req_header, &req_data_ext, req_size); -+ ret = hikp_rsp_normal_check(*cmd_ret); -+ if (ret) -+ printf("hikptool roce_caep cmd_ret malloc failed, sub_cmd = %u, ret = %d.\n", -+ g_roce_caep_param_t.sub_cmd, ret); -+ -+ return ret; - } - - static void hikp_roce_caep_print(uint32_t total_block_num, -@@ -64,29 +75,40 @@ static void hikp_roce_caep_print(uint32_t total_block_num, - printf("************************************\n"); - } - --static void hikp_roce_caep_execute(struct major_cmd_ctrl *self) -+static void hikp_roce_caep_execute_origin(struct major_cmd_ctrl *self) - { - struct roce_caep_res_param *roce_caep_res; -- struct roce_caep_req_param req_data; - struct hikp_cmd_ret *cmd_ret; -- int ret; - -- req_data.bdf = g_roce_caep_param_t.target.bdf; -- ret = hikp_roce_caep_get_data(&cmd_ret, req_data); -- if (ret < 0) { -- self->err_no = ret; -- return; -- } else if (cmd_ret->status != 0) { -- printf("hikptool roce_caep read data failed\n"); -+ self->err_no = hikp_roce_caep_get_data(&cmd_ret, 0); -+ if (self->err_no) { -+ printf("hikptool roce_caep get data failed.\n"); - goto exec_error; - } - roce_caep_res = (struct roce_caep_res_param *)cmd_ret->rsp_data; - hikp_roce_caep_print(roce_caep_res->total_block_num, -- roce_caep_res->reg_data.offset, roce_caep_res->reg_data.data); -+ roce_caep_res->reg_data.offset, -+ roce_caep_res->reg_data.data); - - exec_error: -- free(cmd_ret); -- cmd_ret = NULL; -+ if (cmd_ret) -+ free(cmd_ret); -+} -+ -+static void hikp_roce_caep_execute(struct major_cmd_ctrl *self) -+{ -+ if (g_roce_caep_param_t.sub_cmd == CAEP_ORIGIN) -+ hikp_roce_caep_execute_origin(self); -+ else -+ hikp_roce_ext_execute(self, GET_ROCEE_CAEP_CMD, -+ hikp_roce_caep_get_data); -+} -+ -+static int hikp_roce_caep_ext_set(struct major_cmd_ctrl *self, const char *argv) -+{ -+ g_roce_caep_param_t.sub_cmd = CAEP_EXT; -+ -+ return 0; - } - - static void cmd_roce_caep_init(void) -@@ -98,6 +120,7 @@ static void cmd_roce_caep_init(void) - - cmd_option_register("-h", "--help", false, hikp_roce_caep_help); - cmd_option_register("-i", "--interface", true, hikp_roce_caep_target); -+ cmd_option_register("-e", "--extend", false, hikp_roce_caep_ext_set); - } - - HIKP_CMD_DECLARE("roce_caep", "get roce_caep registers information", cmd_roce_caep_init); -diff --git a/net/roce/roce_caep/hikp_roce_caep.h b/net/roce/roce_caep/hikp_roce_caep.h -index 804d2df..547a4d6 100644 ---- a/net/roce/roce_caep/hikp_roce_caep.h -+++ b/net/roce/roce_caep/hikp_roce_caep.h -@@ -21,12 +21,18 @@ - - struct cmd_roce_caep_param_t { - struct tool_target target; -+ uint32_t sub_cmd; - }; - - struct roce_caep_req_param { - struct bdf_t bdf; - }; - -+struct roce_caep_req_param_ext { -+ struct roce_caep_req_param origin_param; -+ uint32_t block_id; -+}; -+ - struct roce_caep_res { - uint32_t offset[ROCE_HIKP_CAEP_REG_NUM]; - uint32_t data[ROCE_HIKP_CAEP_REG_NUM]; -@@ -37,4 +43,9 @@ struct roce_caep_res_param { - struct roce_caep_res reg_data; - }; - -+enum roce_caep_cmd_type { -+ CAEP_ORIGIN = 0, -+ CAEP_EXT, -+}; -+ - #endif /* __HIKP_ROCE_CAEP_H__ */ --- -2.30.0 - diff --git a/0044-hikptool-roce-Add-ext-query-for-roce_mdb-cmd.patch b/0044-hikptool-roce-Add-ext-query-for-roce_mdb-cmd.patch deleted file mode 100644 index e167f36de9ea7b8c67e2b43182bd41665daa7ac3..0000000000000000000000000000000000000000 --- a/0044-hikptool-roce-Add-ext-query-for-roce_mdb-cmd.patch +++ /dev/null @@ -1,210 +0,0 @@ -From b949611a7a302743916155adee01db0c73c0f8e7 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Fri, 4 Aug 2023 17:25:23 +0800 -Subject: hikptool/roce: Add ext query for roce_mdb cmd - -Add ext query for roce_mdb cmd. To query these ext registers, add --e to the query cmd. - -Example: -hikptool roce_mdb -i eth1 -e - -Signed-off-by: Junxian Huang ---- - net/roce/roce_mdb/hikp_roce_mdb.c | 83 ++++++++++++++++++++----------- - net/roce/roce_mdb/hikp_roce_mdb.h | 13 ++++- - 2 files changed, 67 insertions(+), 29 deletions(-) - -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.c b/net/roce/roce_mdb/hikp_roce_mdb.c -index 9cc07a1..04af817 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.c -+++ b/net/roce/roce_mdb/hikp_roce_mdb.c -@@ -14,7 +14,6 @@ - #include - #include "hikp_roce_mdb.h" - --#define ROCE_MDB_CMD_CLEAR HI_BIT(0) - static struct cmd_roce_mdb_param g_roce_mdb_param = { 0 }; - - static int hikp_roce_mdb_help(struct major_cmd_ctrl *self, const char *argv) -@@ -25,6 +24,7 @@ static int hikp_roce_mdb_help(struct major_cmd_ctrl *self, const char *argv) - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); - printf(" %s, %-25s %s\n", "-i", "--interface=", "device target, e.g. eth0"); - printf(" %s, %-25s %s\n", "-c", "--clear=", "clear mdb registers"); -+ printf(" %s, %-25s %s\n", "-e", "--extend", "query extend mdb registers"); - printf("\n"); - - return 0; -@@ -34,7 +34,7 @@ static int hikp_roce_mdb_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_roce_mdb_param.target)); - if (self->err_no) { -- snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.\n", argv); - return self->err_no; - } - -@@ -43,7 +43,8 @@ static int hikp_roce_mdb_target(struct major_cmd_ctrl *self, const char *argv) - - static int hikp_roce_mdb_clear_set(struct major_cmd_ctrl *self, const char *argv) - { -- g_roce_mdb_param.reset_flag = ROCE_MDB_CMD_CLEAR; -+ g_roce_mdb_param.flag |= ROCE_MDB_CMD_CLEAR; -+ - return 0; - } - -@@ -58,53 +59,78 @@ static void hikp_roce_mdb_print(uint32_t reg_num, struct roce_mdb_rsp_data *mdb_ - printf("***********************************\n"); - } - --static int hikp_roce_mdb_show(struct major_cmd_ctrl *self) -+static int hikp_roce_mdb_get_data(struct hikp_cmd_ret **cmd_ret, -+ uint32_t block_id) - { -- struct roce_mdb_req_para req_data = { 0 }; -- struct roce_mdb_rsp_data *mdb_rsp = NULL; -+ struct roce_mdb_req_param_ext req_data_ext; - struct hikp_cmd_header req_header = { 0 }; -+ uint32_t req_size; -+ int ret; -+ -+ req_data_ext.origin_param.bdf = g_roce_mdb_param.target.bdf; -+ req_data_ext.block_id = block_id; -+ -+ req_size = (g_roce_mdb_param.flag & ROCE_MDB_CMD_EXT) ? -+ sizeof(struct roce_mdb_req_param_ext) : -+ sizeof(struct roce_mdb_req_para); -+ hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_MDB_CMD, -+ g_roce_mdb_param.sub_cmd); -+ *cmd_ret = hikp_cmd_alloc(&req_header, &req_data_ext, req_size); -+ ret = hikp_rsp_normal_check(*cmd_ret); -+ if (ret) -+ printf("hikptool roce_mdb cmd_ret malloc failed, sub_cmd = %u, ret = %d.\n", -+ g_roce_mdb_param.sub_cmd, ret); -+ -+ return ret; -+} -+ -+static void hikp_roce_mdb_execute_origin(struct major_cmd_ctrl *self) -+{ -+ struct roce_mdb_rsp_data *mdb_rsp = NULL; - struct hikp_cmd_ret *cmd_ret = NULL; - uint32_t reg_num; - int ret; - -- req_data.bdf = g_roce_mdb_param.target.bdf; -- if (g_roce_mdb_param.reset_flag) -- hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_MDB_CMD, MDB_CLEAR); -- else -- hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_MDB_CMD, MDB_SHOW); -- -- cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- ret = hikp_rsp_normal_check(cmd_ret); -- if (ret != 0) -+ self->err_no = hikp_roce_mdb_get_data(&cmd_ret, 0); -+ if (self->err_no) { -+ printf("hikptool roce_mdb get data failed\n"); - goto exec_error; -+ } - - reg_num = cmd_ret->rsp_data_num / ROCE_HIKP_REG_SWICTH; - if (reg_num != ROCE_HIKP_MDB_REG_NUM) { - printf("version might not match.\n"); -- ret = -1; -+ self->err_no = -EPROTO; - goto exec_error; - } - - mdb_rsp = (struct roce_mdb_rsp_data *)(cmd_ret->rsp_data); - hikp_roce_mdb_print(reg_num, mdb_rsp); -- ret = 0; - - exec_error: -- free(cmd_ret); -- cmd_ret = NULL; -- return ret; -+ if (cmd_ret) -+ free(cmd_ret); - } - - static void hikp_roce_mdb_execute(struct major_cmd_ctrl *self) - { -- self->err_no = hikp_roce_mdb_show(self); -- if (self->err_no) -- return; -- -- if (g_roce_mdb_param.reset_flag) -- printf("clear roce_mdb reg success.\n"); -- else -- printf("show roce_mdb reg success.\n"); -+ if (g_roce_mdb_param.flag & ROCE_MDB_CMD_EXT) { -+ g_roce_mdb_param.sub_cmd = (g_roce_mdb_param.flag & ROCE_MDB_CMD_CLEAR) ? -+ MDB_CLEAR_EXT : MDB_EXT; -+ hikp_roce_ext_execute(self, GET_ROCEE_MDB_CMD, -+ hikp_roce_mdb_get_data); -+ } else { -+ g_roce_mdb_param.sub_cmd = (g_roce_mdb_param.flag & ROCE_MDB_CMD_CLEAR) ? -+ MDB_CLEAR : MDB_SHOW; -+ hikp_roce_mdb_execute_origin(self); -+ } -+} -+ -+static int hikp_roce_mdb_ext_set(struct major_cmd_ctrl *self, const char *argv) -+{ -+ g_roce_mdb_param.flag |= ROCE_MDB_CMD_EXT; -+ -+ return 0; - } - - static void cmd_roce_mdb_init(void) -@@ -117,6 +143,7 @@ static void cmd_roce_mdb_init(void) - cmd_option_register("-h", "--help", false, hikp_roce_mdb_help); - cmd_option_register("-i", "--interface", true, hikp_roce_mdb_target); - cmd_option_register("-c", "--clear", false, hikp_roce_mdb_clear_set); -+ cmd_option_register("-e", "--extend", false, hikp_roce_mdb_ext_set); - } - - HIKP_CMD_DECLARE("roce_mdb", "get or clear roce_mdb registers information", cmd_roce_mdb_init); -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.h b/net/roce/roce_mdb/hikp_roce_mdb.h -index 7643dff..26fc549 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.h -+++ b/net/roce/roce_mdb/hikp_roce_mdb.h -@@ -19,15 +19,24 @@ - #define ROCE_HIKP_MDB_REG_NUM 22 - #define ROCE_HIKP_REG_SWICTH 2 - -+#define ROCE_MDB_CMD_CLEAR (1 << 0) -+#define ROCE_MDB_CMD_EXT (1 << 1) -+ - struct cmd_roce_mdb_param { - struct tool_target target; -- int reset_flag; -+ uint32_t sub_cmd; -+ uint8_t flag; - }; - - struct roce_mdb_req_para { - struct bdf_t bdf; - }; - -+struct roce_mdb_req_param_ext { -+ struct roce_mdb_req_para origin_param; -+ uint32_t block_id; -+}; -+ - struct roce_mdb_rsp_data { - uint32_t reg_offset[ROCE_HIKP_MDB_REG_NUM]; - uint32_t reg_data[ROCE_HIKP_MDB_REG_NUM]; -@@ -36,6 +45,8 @@ struct roce_mdb_rsp_data { - enum roce_mdb_cmd_type { - MDB_SHOW = 0x0, - MDB_CLEAR, -+ MDB_EXT, -+ MDB_CLEAR_EXT, - }; - - #endif /* __HIKP_ROCE_MDB_H__ */ --- -2.30.0 - diff --git a/0045-hikptool-roce-Add-ext-query-for-roce_qmm-cmd.patch b/0045-hikptool-roce-Add-ext-query-for-roce_qmm-cmd.patch deleted file mode 100644 index 29a344a419475ad0ef7baf7c2b7094fa5c38ad47..0000000000000000000000000000000000000000 --- a/0045-hikptool-roce-Add-ext-query-for-roce_qmm-cmd.patch +++ /dev/null @@ -1,252 +0,0 @@ -From 87f8605c32d308938df17b29816720ca97b0a23f Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Sat, 26 Aug 2023 15:05:53 +0800 -Subject: hikptool/roce: Add ext query for roce_qmm cmd - -Add ext query for roce_qmm cmd. To query these ext registers, add --e to the query cmd. - -Example: -hikptool roce_qmm -i eth1 -e - -Signed-off-by: Junxian Huang ---- - net/roce/roce_qmm/hikp_roce_qmm.c | 137 ++++++++++++++---------------- - net/roce/roce_qmm/hikp_roce_qmm.h | 11 +++ - 2 files changed, 75 insertions(+), 73 deletions(-) - -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.c b/net/roce/roce_qmm/hikp_roce_qmm.c -index c7e0ca4..b020c6a 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.c -+++ b/net/roce/roce_qmm/hikp_roce_qmm.c -@@ -25,6 +25,7 @@ static int hikp_roce_qmm_help(struct major_cmd_ctrl *self, const char *argv) - printf(" %s, %-25s %s\n", "-i", "--interface=", "device target, e.g. eth0"); - printf(" %s, %-25s %s\n", "-b", "--bank=", - "[option]bank number, e.g. 0~7. (default 0)"); -+ printf(" %s, %-25s %s\n", "-e", "--extend", "query extend qmm registers"); - printf("\n"); - - return 0; -@@ -34,7 +35,7 @@ static int hikp_roce_qmm_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_roce_qmm_param.target)); - if (self->err_no != 0) { -- snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); -+ snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.\n", argv); - return self->err_no; - } - -@@ -61,6 +62,8 @@ static void hikp_roce_qmm_print(struct roce_qmm_rsp_data *qmm_rsp) - { - int index = 0; - -+ printf("**************QMM %s INFO*************\n", -+ g_roce_qmm_param.sub_name); - while (index < qmm_rsp->reg_num) { - printf("0x%08X : 0x%08X\n", qmm_rsp->qmm_content[index][0], - qmm_rsp->qmm_content[index][1]); -@@ -69,101 +72,88 @@ static void hikp_roce_qmm_print(struct roce_qmm_rsp_data *qmm_rsp) - printf("***************************************\n"); - } - --static int hikp_roce_qmm_show_cqc(struct major_cmd_ctrl *self) -+static int hikp_roce_qmm_get_data(struct hikp_cmd_ret **cmd_ret, -+ uint32_t block_id) - { -- struct roce_qmm_req_para req_data = { 0 }; -- struct roce_qmm_rsp_data *qmm_rsp = NULL; -+ struct roce_qmm_req_para_ext req_data_ext; - struct hikp_cmd_header req_header = { 0 }; -- struct hikp_cmd_ret *cmd_ret = NULL; -+ uint32_t req_size; - int ret; - -- req_data.bdf = g_roce_qmm_param.target.bdf; -+ req_data_ext.origin_param.bdf = g_roce_qmm_param.target.bdf; -+ req_data_ext.origin_param.bank_id = g_roce_qmm_param.bank_id; -+ req_data_ext.block_id = block_id; -+ -+ req_size = g_roce_qmm_param.ext_flag ? -+ sizeof(struct roce_qmm_req_para) : -+ sizeof(struct roce_qmm_req_para_ext); -+ hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_QMM_CMD, -+ g_roce_qmm_param.sub_cmd); -+ *cmd_ret = hikp_cmd_alloc(&req_header, &req_data_ext, req_size); -+ ret = hikp_rsp_normal_check(*cmd_ret); -+ if (ret) -+ printf("hikptool roce_qmm cmd_ret malloc failed, sub_cmd = %u, ret = %d.\n", -+ g_roce_qmm_param.sub_cmd, ret); - -- hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_QMM_CMD, QMM_SHOW_CQC); -- cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- ret = hikp_rsp_normal_check(cmd_ret); -- if (ret != 0) -- goto out; -- -- qmm_rsp = (struct roce_qmm_rsp_data *)(cmd_ret->rsp_data); -- printf("**************QMM CQC INFO*************\n"); -- hikp_roce_qmm_print(qmm_rsp); --out: -- free(cmd_ret); -- cmd_ret = NULL; -- return ret; --} -- --static int hikp_roce_qmm_show_qpc(struct major_cmd_ctrl *self) --{ -- struct roce_qmm_req_para req_data = { 0 }; -- struct roce_qmm_rsp_data *qmm_rsp = NULL; -- struct hikp_cmd_header req_header = { 0 }; -- struct hikp_cmd_ret *cmd_ret = NULL; -- int ret; -- -- req_data.bdf = g_roce_qmm_param.target.bdf; -- req_data.bank_id = g_roce_qmm_param.bank_id; -- -- hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_QMM_CMD, QMM_SHOW_QPC); -- cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- ret = hikp_rsp_normal_check(cmd_ret); -- if (ret != 0) -- goto out; -- -- qmm_rsp = (struct roce_qmm_rsp_data *)(cmd_ret->rsp_data); -- printf("**************QMM QPC INFO*************\n"); -- hikp_roce_qmm_print(qmm_rsp); --out: -- free(cmd_ret); -- cmd_ret = NULL; - return ret; - } - --static int hikp_roce_qmm_show_top(struct major_cmd_ctrl *self) -+static void hikp_roce_qmm_execute_origin(struct major_cmd_ctrl *self) - { -- struct roce_qmm_req_para req_data = { 0 }; -- struct roce_qmm_rsp_data *qmm_rsp = NULL; -- struct hikp_cmd_header req_header = { 0 }; -- struct hikp_cmd_ret *cmd_ret = NULL; -- int ret; -+ struct roce_qmm_rsp_data *roce_qmm_res; -+ struct hikp_cmd_ret *cmd_ret; - -- req_data.bdf = g_roce_qmm_param.target.bdf; -- -- hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_QMM_CMD, QMM_SHOW_TOP); -- cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- ret = hikp_rsp_normal_check(cmd_ret); -- if (ret != 0) -- goto out; -+ self->err_no = hikp_roce_qmm_get_data(&cmd_ret, 0); -+ if (self->err_no) { -+ printf("hikptool roce_qmm get data failed.\n"); -+ goto exec_error; -+ } -+ roce_qmm_res = (struct roce_qmm_rsp_data *)cmd_ret->rsp_data; -+ hikp_roce_qmm_print(roce_qmm_res); - -- qmm_rsp = (struct roce_qmm_rsp_data *)(cmd_ret->rsp_data); -- printf("**************QMM TOP INFO*************\n"); -- hikp_roce_qmm_print(qmm_rsp); --out: -- free(cmd_ret); -- cmd_ret = NULL; -- return ret; -+exec_error: -+ if (cmd_ret) -+ free(cmd_ret); - } - - static void hikp_roce_qmm_execute(struct major_cmd_ctrl *self) - { -- int (*func[])(struct major_cmd_ctrl *self) = { -- hikp_roce_qmm_show_cqc, hikp_roce_qmm_show_qpc, hikp_roce_qmm_show_top -+ const struct cmd_type_info { -+ enum roce_qmm_cmd_type sub_cmd; -+ enum roce_qmm_cmd_type sub_ext_cmd; -+ const char *sub_name; -+ } sub_cmd_info_table[] = { -+ {QMM_SHOW_CQC, QMM_SHOW_CQC_EXT, "CQC"}, -+ {QMM_SHOW_QPC, QMM_SHOW_QPC_EXT, "QPC"}, -+ {QMM_SHOW_TOP, QMM_SHOW_TOP_EXT, "TOP"}, - }; -- char *function[] = {"show cqc", "show qpc", "show top"}; -- int ret; - -- for (int i = 0; i < HIKP_ARRAY_SIZE(func); i++) { -- ret = func[i](self); -- if (ret != 0) { -- self->err_no = -EINVAL; -+ for (int i = 0; i < HIKP_ARRAY_SIZE(sub_cmd_info_table); i++) { -+ g_roce_qmm_param.sub_name = sub_cmd_info_table[i].sub_name; -+ if (g_roce_qmm_param.ext_flag) { -+ g_roce_qmm_param.sub_cmd = sub_cmd_info_table[i].sub_ext_cmd; -+ hikp_roce_ext_execute(self, GET_ROCEE_QMM_CMD, -+ hikp_roce_qmm_get_data); -+ } else { -+ g_roce_qmm_param.sub_cmd = sub_cmd_info_table[i].sub_cmd; -+ hikp_roce_qmm_execute_origin(self); -+ } -+ if (self->err_no) { - snprintf(self->err_str, sizeof(self->err_str), -- "roce_qmm %s function failed\n", function[i]); -+ "roce_qmm show %s function failed\n", -+ sub_cmd_info_table[i].sub_name); - break; - } - } - } - -+static int hikp_roce_qmm_ext_set(struct major_cmd_ctrl *self, const char *argv) -+{ -+ g_roce_qmm_param.ext_flag = true; -+ -+ return 0; -+} -+ - static void cmd_roce_qmm_init(void) - { - struct major_cmd_ctrl *major_cmd = get_major_cmd(); -@@ -174,6 +164,7 @@ static void cmd_roce_qmm_init(void) - cmd_option_register("-h", "--help", false, hikp_roce_qmm_help); - cmd_option_register("-i", "--interface", true, hikp_roce_qmm_target); - cmd_option_register("-b", "--bank", true, hikp_roce_qmm_bank_get); -+ cmd_option_register("-e", "--extend", false, hikp_roce_qmm_ext_set); - } - - HIKP_CMD_DECLARE("roce_qmm", "get roce_qmm registers information", cmd_roce_qmm_init); -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.h b/net/roce/roce_qmm/hikp_roce_qmm.h -index 0645ab3..06e6bcf 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.h -+++ b/net/roce/roce_qmm/hikp_roce_qmm.h -@@ -22,6 +22,9 @@ - struct cmd_roce_qmm_param_t { - struct tool_target target; - uint32_t bank_id; -+ uint32_t sub_cmd; -+ const char *sub_name; -+ bool ext_flag; - }; - - struct roce_qmm_rsp_data { -@@ -34,10 +37,18 @@ struct roce_qmm_req_para { - uint32_t bank_id; - }; - -+struct roce_qmm_req_para_ext { -+ struct roce_qmm_req_para origin_param; -+ uint32_t block_id; -+}; -+ - enum roce_qmm_cmd_type { - QMM_SHOW_CQC = 0x1, - QMM_SHOW_QPC = 0x2, - QMM_SHOW_TOP = 0x3, -+ QMM_SHOW_CQC_EXT, -+ QMM_SHOW_QPC_EXT, -+ QMM_SHOW_TOP_EXT, - }; - - #endif /* __HIKP_ROCE_QMM_H__ */ --- -2.30.0 - diff --git a/0046-hikptool-Querying-the-SerDes-Relationship-of-the-PCI.patch b/0046-hikptool-Querying-the-SerDes-Relationship-of-the-PCI.patch deleted file mode 100644 index 6646cc54a5383e84412908dd29ca105874fe2140..0000000000000000000000000000000000000000 --- a/0046-hikptool-Querying-the-SerDes-Relationship-of-the-PCI.patch +++ /dev/null @@ -1,100 +0,0 @@ -From 6747635a4423fc0844230bc66112853856b9fe97 Mon Sep 17 00:00:00 2001 -From: mou bingquan -Date: Wed, 18 Oct 2023 09:52:39 +0800 -Subject: [PATCH] hikptool : Querying the SerDes Relationship of the PCIe - -This function is used to query the macro corresponding to the -port of the PCIe. It is a type of SerDes multiplexing relationship. ---- - pcie/func_lib/pcie_func/pcie_statistics.c | 30 +++++++++++++++++++++++ - pcie/func_lib/pcie_func/pcie_statistics.h | 10 ++++++++ - 2 files changed, 40 insertions(+) - -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c -index 308a142..128e7f7 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.c -+++ b/pcie/func_lib/pcie_func/pcie_statistics.c -@@ -25,6 +25,10 @@ static const char *g_global_width_name[GLOBAL_WIDTH_TABLE_SIZE] = { - "PCIE_WIDTH_X1", "PCIE_WIDTH_X2", "PCIE_WIDTH_X4", "PCIE_WIDTH_X8", "PCIE_WIDTH_X16" - }; - -+static const char *g_global_ndie_name[] = { -+ "Ndie_A", "Ndie_B" -+}; -+ - static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, uint32_t *port_num) - { - size_t rsp_data_size, expect_data_size; -@@ -58,6 +62,29 @@ static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, - return 0; - } - -+static int pcie_portid_serdes_relation(const struct pcie_macro_info *macro_info, -+ uint32_t macro_num, uint32_t ndie_id) -+{ -+ uint32_t i, j; -+ -+ if (ndie_id >= HIKP_ARRAY_SIZE(g_global_ndie_name)) { -+ Info("PCIe Base", "ndie_id [%u]: %s\n", ndie_id, "UNKNOWN_NDIE"); -+ return -1; -+ } -+ -+ if (macro_num >= MAX_MACRO_ONEPORT) { -+ Info("PCIe Base", "macro_num [%u] exceeds the maximum array length\n", macro_num); -+ return -1; -+ } -+ -+ Info("PCIe Base", "\tndie_id: %s\n", g_global_ndie_name[ndie_id]); -+ for (i = 0; i < macro_num; i++) { -+ for (j = macro_info[i].lane_s; j <= macro_info[i].lane_e; j++) -+ Info("PCIe Base", "\t\tmacro %d \t lane: %d\n", macro_info[i].id, j); -+ } -+ return 0; -+} -+ - int pcie_port_distribution_get(uint32_t chip_id) - { - struct hikp_cmd_header req_header; -@@ -86,6 +113,9 @@ int pcie_port_distribution_get(uint32_t chip_id) - } - Info("PCIe Base", "port_id[%u] %s\n", port_info->info_pair[i].port_id, - g_global_width_name[port_info->info_pair[i].port_width]); -+ pcie_portid_serdes_relation(port_info->info_pair[i].macro_info, -+ port_info->info_pair[i].macro_num, -+ port_info->info_pair[i].ndie_id); - } - free_cmd_ret: - free(cmd_ret); -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.h b/pcie/func_lib/pcie_func/pcie_statistics.h -index 2a3cc66..3e3916b 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.h -+++ b/pcie/func_lib/pcie_func/pcie_statistics.h -@@ -17,6 +17,7 @@ - #include "pcie_common_api.h" - - #define GLOBAL_WIDTH_TABLE_SIZE 5 -+#define MAX_MACRO_ONEPORT 3 - - union mac_test_cnt { - /* Define the struct bits */ -@@ -88,9 +89,18 @@ union dfx_dcrc_err_num { - unsigned int u32; - }; - -+struct pcie_macro_info { -+ uint32_t id; -+ uint32_t lane_s; -+ uint32_t lane_e; -+}; -+ - struct pcie_info_distribution_pair { - uint32_t port_id; - uint32_t port_width; -+ uint32_t ndie_id; -+ uint32_t macro_num; -+ struct pcie_macro_info macro_info[MAX_MACRO_ONEPORT]; - }; - - struct pcie_port_info { --- -2.33.0 diff --git a/0047-hikptool-Remove-the-function-of-querying-SAS-device-.patch b/0047-hikptool-Remove-the-function-of-querying-SAS-device-.patch deleted file mode 100644 index b4af52f61aa494b156ff93a3297e1c8f86cd845b..0000000000000000000000000000000000000000 --- a/0047-hikptool-Remove-the-function-of-querying-SAS-device-.patch +++ /dev/null @@ -1,177 +0,0 @@ -From ba80a0dd531a4eebccb1852a65b4b7272a02c06d Mon Sep 17 00:00:00 2001 -From: Yihang Li -Date: Tue, 17 Oct 2023 18:58:27 +0800 -Subject: [PATCH] hikptool: Remove the function of querying SAS device - configurations - -Currently, SAS device information cannot be obtained. -Remove the function of querying SAS device configurations - -Signed-off-by: Yihang Li ---- - sas/sas_func/sas_common.h | 2 -- - sas/sas_func/sas_read_dev.c | 21 --------------------- - sas/user_cmd/cmd_code/sas_cmd_common.c | 10 ---------- - sas/user_cmd/cmd_code/sas_cmd_dev.c | 17 ----------------- - sas/user_cmd/cmd_code/sas_tools_include.h | 2 -- - 5 files changed, 52 deletions(-) - -diff --git a/sas/sas_func/sas_common.h b/sas/sas_func/sas_common.h -index 9464792..1bace0c 100644 ---- a/sas/sas_func/sas_common.h -+++ b/sas/sas_func/sas_common.h -@@ -22,7 +22,6 @@ - #define IPTT_ICT_STATUS 29 - #define LINK_SPEED_OFFSET 8 - #define LINK_SPEED_WIDTH 4 --#define MAX_DEVICE_NUM 2048 - - #define DWS_LOST 0 - #define RESET_PROB 1 -@@ -73,7 +72,6 @@ enum sas_errcode_cmd_type { - - enum sas_dev_cmd_type { - DEV_LINK, -- DEV_INFO, - DEV_UNKNOWN_TYPE, - }; - -diff --git a/sas/sas_func/sas_read_dev.c b/sas/sas_func/sas_read_dev.c -index 8b9b58d..3a3db07 100644 ---- a/sas/sas_func/sas_read_dev.c -+++ b/sas/sas_func/sas_read_dev.c -@@ -76,24 +76,6 @@ static void print_dev_link(const uint32_t *reg_save, uint32_t reg_num) - } - } - --static void print_dev_info(const void *reg_save, uint32_t reg_num) --{ -- volatile struct hikp_sas_itct *itct = (volatile struct hikp_sas_itct *)reg_save; -- -- printf("The device information as below:\n"); -- printf("dev_type: %d\n", itct->dw0.dev_type); -- printf("dev_valid: %d\n", itct->dw0.dev_valid); -- printf("break_reply_en: %d\n", itct->dw0.break_reply_en); -- printf("smp_timeout: %d\n", itct->dw0.smp_timeout); -- printf("tlr_en: %d\n", itct->dw0.tlr_en); -- printf("awt_continue: %d\n", itct->dw0.awt_continue); -- printf("sas_addr: 0x%llx\n", itct->sas_addr); -- printf("I_T_nexus_loss: %d\n", itct->dw2.I_T_nexus_loss); -- printf("awt_initial_value: %d\n", itct->dw2.awt_initial_value); -- printf("maximum_connect_time: %d\n", itct->dw2.maximum_connect_time); -- printf("reject_to_open_limit: %d\n", itct->dw2.reject_to_open_limit); --} -- - static void sas_print_dev(const uint32_t *reg_save, uint32_t reg_num, uint32_t cmd_type) - { - uint32_t i; -@@ -106,9 +88,6 @@ static void sas_print_dev(const uint32_t *reg_save, uint32_t reg_num, uint32_t c - case DEV_LINK: - print_dev_link(reg_save, reg_num); - break; -- case DEV_INFO: -- print_dev_info(reg_save, reg_num); -- break; - default: - printf("cmd_type is error\n"); - } -diff --git a/sas/user_cmd/cmd_code/sas_cmd_common.c b/sas/user_cmd/cmd_code/sas_cmd_common.c -index 9dca63f..358cf39 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_common.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_common.c -@@ -54,11 +54,6 @@ int sas_get_phy_id(void) - return g_sas_cmd.phy_id; - } - --int sas_get_dev_id(void) --{ -- return g_sas_cmd.dev_id; --} -- - int sas_get_que_id(void) - { - return g_sas_cmd.que_id; -@@ -84,11 +79,6 @@ int sas_set_die_id(struct major_cmd_ctrl *self, const char *argv) - return sas_set_id(self, argv, &g_sas_cmd.die_id); - } - --int sas_set_dev_id(struct major_cmd_ctrl *self, const char *argv) --{ -- return sas_set_id(self, argv, &g_sas_cmd.dev_id); --} -- - int sas_set_que_id(struct major_cmd_ctrl *self, const char *argv) - { - return sas_set_id(self, argv, &g_sas_cmd.que_id); -diff --git a/sas/user_cmd/cmd_code/sas_cmd_dev.c b/sas/user_cmd/cmd_code/sas_cmd_dev.c -index c95006b..6a5eae0 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_dev.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_dev.c -@@ -26,7 +26,6 @@ static int sas_dev_help(struct major_cmd_ctrl *self, const char *argv) - printf("\n Options:\n\n"); - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); - printf(" %s, %-25s %s\n", "-l", "--link", "dispaly device type and speed\n"); -- printf(" %s, %-25s %s\n", "-i", "--info", "dispaly the device detail information\n"); - printf("\n"); - - return 0; -@@ -37,19 +36,6 @@ static int sas_dev_link(struct major_cmd_ctrl *self, const char *argv) - return sas_set_cmd_type(DEV_LINK); - } - --static int sas_dev_info(struct major_cmd_ctrl *self, const char *argv) --{ -- int ret; -- -- (void)sas_set_cmd_type(DEV_INFO); -- ret = sas_set_dev_id(self, argv); -- if (ret || sas_get_dev_id() >= MAX_DEVICE_NUM) { -- printf("device id is too large(>=%d)\n", MAX_DEVICE_NUM); -- return -EINVAL; -- } -- return ret; --} -- - static int sas_dev_excute_funs_call(uint32_t cmd_type) - { - if (cmd_type != SAS_UNKNOW_CMD) -@@ -63,11 +49,9 @@ static void sas_dev_execute(struct major_cmd_ctrl *self) - int ret, cmd; - const char *suc_msg[] = { - "sas_dev_link success.", -- "sas_dev_info success.", - }; - const char *err_msg[] = { - "sas_dev_link error.", -- "sas_dev_info error.", - "sas_dev failed, unknown type", - }; - -@@ -95,7 +79,6 @@ static void cmd_sas_dev_init(void) - cmd_option_register("-d", "--dieid", true, sas_set_die_id); - cmd_option_register("-h", "--help", false, sas_dev_help); - cmd_option_register("-l", "--link", false, sas_dev_link); -- cmd_option_register("-i", "--info", true, sas_dev_info); - } - - HIKP_CMD_DECLARE("sas_dev", "sas device information ", cmd_sas_dev_init); -diff --git a/sas/user_cmd/cmd_code/sas_tools_include.h b/sas/user_cmd/cmd_code/sas_tools_include.h -index a71e614..0aa7703 100644 ---- a/sas/user_cmd/cmd_code/sas_tools_include.h -+++ b/sas/user_cmd/cmd_code/sas_tools_include.h -@@ -34,13 +34,11 @@ struct tool_sas_cmd { - int sas_set_cmd_type(int cmd_type); - int sas_get_cmd_type(void); - int sas_get_phy_id(void); --int sas_get_dev_id(void); - int sas_get_que_id(void); - struct tool_sas_cmd *sas_get_cmd_p(void); - int sas_set_chip_id(struct major_cmd_ctrl *self, const char *argv); - int sas_set_phy_id(struct major_cmd_ctrl *self, const char *argv); - int sas_set_die_id(struct major_cmd_ctrl *self, const char *argv); --int sas_set_dev_id(struct major_cmd_ctrl *self, const char *argv); - int sas_set_que_id(struct major_cmd_ctrl *self, const char *argv); - int sas_set_dqe_id(struct major_cmd_ctrl *self, const char *argv); - --- -2.33.0 diff --git a/0048-hikptool-roce-Use-calloc-to-alloc-memory-for-array-i.patch b/0048-hikptool-roce-Use-calloc-to-alloc-memory-for-array-i.patch deleted file mode 100644 index 9ddbce8f88ee1affeb0782ad8936147b13a2f025..0000000000000000000000000000000000000000 --- a/0048-hikptool-roce-Use-calloc-to-alloc-memory-for-array-i.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 2abbc6020498b1c464775623de8b2db76e684d55 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Tue, 24 Oct 2023 11:16:49 +0800 -Subject: hikptool/roce: Use calloc to alloc memory for array instead of malloc - -calloc is more situable for memory allocation for array than malloc, -since the allocated memory will be set to 0. - -Fixes: 8b3b68347165 ("hikptool/roce: Add a common frame for hikptool roce register query") -Signed-off-by: Junxian Huang ---- - net/roce/roce_ext_common/hikp_roce_ext_common.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 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 d0fae69..d5ae64a 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -115,8 +115,8 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - max_size = res_head->total_block_num * sizeof(uint32_t); - - if (block_id == 0) { -- reg->offset = (uint32_t *)malloc(max_size); -- reg->data = (uint32_t *)malloc(max_size); -+ 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)); - if ((reg->offset == NULL) || (reg->data == NULL)) { - printf("hikptool roce_%s alloc log memmory 0x%x failed!\n", - cmd_name, max_size); --- -2.30.0 diff --git a/0049-hikptool-roce-Fix-missing-check-of-reg-num-responsed.patch b/0049-hikptool-roce-Fix-missing-check-of-reg-num-responsed.patch deleted file mode 100644 index f12db5627fc8c40deb65b355861944f1bc86f7d9..0000000000000000000000000000000000000000 --- a/0049-hikptool-roce-Fix-missing-check-of-reg-num-responsed.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 679cfd5353da2165dbf5b89769bbd5b69209bc5b Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Tue, 24 Oct 2023 15:12:41 +0800 -Subject: hikptool/roce: Fix missing check of reg num responsed from FW - -If the reg num responsed from a new-version FW exceeds the array -length in the old-version hikptool, an out-of-bounds access error -will occur. So add a check to ensure the reg num is not greater -than tha array length. - -Fixes: 392c269be165 ("support querying RoCE module information") -Fixes: 87f8605c32d3 ("hikptool/roce: Add ext query for roce_qmm cmd") -Signed-off-by: Junxian Huang ---- - net/roce/roce_caep/hikp_roce_caep.c | 7 +++++++ - net/roce/roce_pkt/hikp_roce_pkt.c | 7 +++++++ - net/roce/roce_qmm/hikp_roce_qmm.c | 7 +++++++ - net/roce/roce_timer/hikp_roce_timer.c | 12 ++++++++++++ - net/roce/roce_tsp/hikp_roce_tsp.c | 6 ++++++ - 5 files changed, 39 insertions(+) - -diff --git a/net/roce/roce_caep/hikp_roce_caep.c b/net/roce/roce_caep/hikp_roce_caep.c -index 6c92ea1..126551a 100644 ---- a/net/roce/roce_caep/hikp_roce_caep.c -+++ b/net/roce/roce_caep/hikp_roce_caep.c -@@ -85,7 +85,14 @@ static void hikp_roce_caep_execute_origin(struct major_cmd_ctrl *self) - printf("hikptool roce_caep get data failed.\n"); - goto exec_error; - } -+ - roce_caep_res = (struct roce_caep_res_param *)cmd_ret->rsp_data; -+ if (roce_caep_res->total_block_num > ROCE_HIKP_CAEP_REG_NUM) { -+ printf("version might not match, adjust the reg num to %d.\n", -+ ROCE_HIKP_CAEP_REG_NUM); -+ roce_caep_res->total_block_num = ROCE_HIKP_CAEP_REG_NUM; -+ } -+ - hikp_roce_caep_print(roce_caep_res->total_block_num, - roce_caep_res->reg_data.offset, - roce_caep_res->reg_data.data); -diff --git a/net/roce/roce_pkt/hikp_roce_pkt.c b/net/roce/roce_pkt/hikp_roce_pkt.c -index d3bf885..e710e08 100644 ---- a/net/roce/roce_pkt/hikp_roce_pkt.c -+++ b/net/roce/roce_pkt/hikp_roce_pkt.c -@@ -87,7 +87,14 @@ static void hikp_roce_pkt_execute(struct major_cmd_ctrl *self) - self->err_no = ret; - return; - } -+ - roce_pkt_res = (struct roce_pkt_res_param *)cmd_ret->rsp_data; -+ if (roce_pkt_res->total_block_num > ROCE_HIKP_PKT_REG_NUM) { -+ printf("version might not match, adjust the reg num to %d.\n", -+ ROCE_HIKP_PKT_REG_NUM); -+ roce_pkt_res->total_block_num = ROCE_HIKP_PKT_REG_NUM; -+ } -+ - hikp_roce_pkt_print(roce_pkt_res->total_block_num, - roce_pkt_res->reg_data.offset, roce_pkt_res->reg_data.data); - -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.c b/net/roce/roce_qmm/hikp_roce_qmm.c -index b020c6a..d127264 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.c -+++ b/net/roce/roce_qmm/hikp_roce_qmm.c -@@ -108,7 +108,14 @@ static void hikp_roce_qmm_execute_origin(struct major_cmd_ctrl *self) - printf("hikptool roce_qmm get data failed.\n"); - goto exec_error; - } -+ - roce_qmm_res = (struct roce_qmm_rsp_data *)cmd_ret->rsp_data; -+ if (roce_qmm_res->reg_num > ROCE_HIKP_QMM_REG_NUM) { -+ printf("version might not match, adjust the reg num to %d.\n", -+ ROCE_HIKP_QMM_REG_NUM); -+ roce_qmm_res->reg_num = ROCE_HIKP_QMM_REG_NUM; -+ } -+ - hikp_roce_qmm_print(roce_qmm_res); - - exec_error: -diff --git a/net/roce/roce_timer/hikp_roce_timer.c b/net/roce/roce_timer/hikp_roce_timer.c -index c4e979f..a78d383 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.c -+++ b/net/roce/roce_timer/hikp_roce_timer.c -@@ -76,6 +76,12 @@ static int hikp_roce_timer_show_qpc(struct major_cmd_ctrl *self) - goto out; - - timer_rsp = (struct roce_timer_rsp_data *)(cmd_ret->rsp_data); -+ if (timer_rsp->reg_num > ROCE_HIKP_TIMER_REG_NUM) { -+ printf("version might not match, adjust the reg num to %d.\n", -+ ROCE_HIKP_TIMER_REG_NUM); -+ timer_rsp->reg_num = ROCE_HIKP_TIMER_REG_NUM; -+ } -+ - printf("**************QPC TIMER INFO*************\n"); - hikp_roce_timer_print(timer_rsp); - out: -@@ -104,6 +110,12 @@ static int hikp_roce_timer_show_cqc(struct major_cmd_ctrl *self) - goto out; - - timer_rsp = (struct roce_timer_rsp_data *)(cmd_ret->rsp_data); -+ if (timer_rsp->reg_num > ROCE_HIKP_TIMER_REG_NUM) { -+ printf("version might not match, adjust the reg num to %d.\n", -+ ROCE_HIKP_TIMER_REG_NUM); -+ timer_rsp->reg_num = ROCE_HIKP_TIMER_REG_NUM; -+ } -+ - printf("**************CQC TIMER INFO*************\n"); - hikp_roce_timer_print(timer_rsp); - out: -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.c b/net/roce/roce_tsp/hikp_roce_tsp.c -index a036fae..5bb2649 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.c -+++ b/net/roce/roce_tsp/hikp_roce_tsp.c -@@ -181,6 +181,12 @@ static void hikp_roce_tsp_execute(struct major_cmd_ctrl *self) - } - - roce_tsp_res = (struct roce_tsp_res_param *)cmd_ret->rsp_data; -+ if (roce_tsp_res->total_block_num > ROCE_HIKP_TSP_REG_NUM) { -+ printf("version might not match, adjust the reg num to %d.\n", -+ ROCE_HIKP_TSP_REG_NUM); -+ roce_tsp_res->total_block_num = ROCE_HIKP_TSP_REG_NUM; -+ } -+ - hikp_roce_tsp_print(roce_tsp_res->total_block_num, - roce_tsp_res->reg_data.offset, roce_tsp_res->reg_data.data); - --- -2.30.0 \ No newline at end of file diff --git a/0050-hikptool-Change-the-unic_ppp-directory-to-ub_ppp.patch b/0050-hikptool-Change-the-unic_ppp-directory-to-ub_ppp.patch deleted file mode 100644 index 6f9d370eb1c0d6e9eda15504ab6d12359385fa2d..0000000000000000000000000000000000000000 --- a/0050-hikptool-Change-the-unic_ppp-directory-to-ub_ppp.patch +++ /dev/null @@ -1,43 +0,0 @@ -From bb4201e589f3875351a5a7b1305254701663dc9a Mon Sep 17 00:00:00 2001 -From: JianQiang Li -Date: Wed, 25 Oct 2023 09:14:55 +0800 -Subject: [PATCH] [hikptool] Change the unic_ppp directory to ub_ppp. - -tool inclusion -category:bugfix -bugzilla:NA -CVE:NA - ----------------------------------------------------------------------- - -Change the unic_ppp directory to ub_ppp and add a blank line to the end of the hikp_unic_ppp.c file. - -Signed-off-by: Jianqiang Li ---- - net/ub/{ub_unic => ub_ppp}/hikp_unic_ppp.c | 2 +- - net/ub/{ub_unic => ub_ppp}/hikp_unic_ppp.h | 0 - 2 files changed, 1 insertion(+), 1 deletion(-) - rename net/ub/{ub_unic => ub_ppp}/hikp_unic_ppp.c (99%) - rename net/ub/{ub_unic => ub_ppp}/hikp_unic_ppp.h (100%) - -diff --git a/net/ub/ub_unic/hikp_unic_ppp.c b/net/ub/ub_ppp/hikp_unic_ppp.c -similarity index 99% -rename from net/ub/ub_unic/hikp_unic_ppp.c -rename to net/ub/ub_ppp/hikp_unic_ppp.c -index 5325b03..ccba4e0 100644 ---- a/net/ub/ub_unic/hikp_unic_ppp.c -+++ b/net/ub/ub_ppp/hikp_unic_ppp.c -@@ -465,4 +465,4 @@ static void cmd_unic_get_ppp_init(void) - cmd_option_register("-du", "--dump", true, hikp_unic_cmd_ppp_feature_select); - } - --HIKP_CMD_DECLARE("unic_ppp", "dump ppp info of unic!", cmd_unic_get_ppp_init); -\ No newline at end of file -+HIKP_CMD_DECLARE("unic_ppp", "dump ppp info of unic!", cmd_unic_get_ppp_init); -diff --git a/net/ub/ub_unic/hikp_unic_ppp.h b/net/ub/ub_ppp/hikp_unic_ppp.h -similarity index 100% -rename from net/ub/ub_unic/hikp_unic_ppp.h -rename to net/ub/ub_ppp/hikp_unic_ppp.h --- -2.21.0.windows.1 - diff --git a/0051-hikptool-roce-Fix-the-wrong-maximum-of-gmv-index.patch b/0051-hikptool-roce-Fix-the-wrong-maximum-of-gmv-index.patch deleted file mode 100644 index 1c6e632462f7439337f0c1994045ab00336f9c35..0000000000000000000000000000000000000000 --- a/0051-hikptool-roce-Fix-the-wrong-maximum-of-gmv-index.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 48d87bcd204c6aa226b5dbdb8c68ead8d12b1745 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Tue, 31 Oct 2023 20:51:38 +0800 -Subject: hikptool/roce: Fix the wrong maximum of gmv index - -The RoCE driver supports up to 256 gmv table entry, the allowed -gmv index of hikptool command roce_gmv should cover this range. - -Signed-off-by: Junxian Huang ---- - net/roce/roce_gmv/hikp_roce_gmv.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/net/roce/roce_gmv/hikp_roce_gmv.h b/net/roce/roce_gmv/hikp_roce_gmv.h -index 1ef5b93..a02b960 100644 ---- a/net/roce/roce_gmv/hikp_roce_gmv.h -+++ b/net/roce/roce_gmv/hikp_roce_gmv.h -@@ -18,7 +18,7 @@ - - #define ROCE_HIKP_GMV_REG_NUM 7 - #define ROCE_HIKP_GMV_REG_SWICTH 2 --#define ROCE_MAX_HIKPTOOL_GMV 128 -+#define ROCE_MAX_HIKPTOOL_GMV 256 - struct cmd_roce_gmv_param { - struct tool_target target; - uint32_t gmv_index; --- -2.30.0 - diff --git a/0052-hikptool-Resolved-some-centralized-code-review-comme.patch b/0052-hikptool-Resolved-some-centralized-code-review-comme.patch deleted file mode 100644 index 154d70c2672ccb7e8e612807e96431fd2b9453ea..0000000000000000000000000000000000000000 --- a/0052-hikptool-Resolved-some-centralized-code-review-comme.patch +++ /dev/null @@ -1,1390 +0,0 @@ -From faccc8979f5a6e458b02c7865b9e3316b9facfd1 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 8 Nov 2023 20:43:06 +0800 -Subject: [PATCH] hikptool: Resolved some centralized code review comments. - -1. The ret variable may be a random value. -2. The unsigned variable judgment branch is redundant judgment. -3. Fix Magic Numbers. -4. The print format does not match. -5. After the pointer is released, a null value is assigned to the pointer to prevent it from being used again. -6. Delete unused variables. -7. The uint64_t print issue is rectified and PRIx64/PRIu64 is used. -8. Add 'const' to constant array. -9. Modifying File Permissions.Eliminate software privilege escalation risks. - -Signed-off-by: veega2022 ---- - cxl/func_lib/cxl_func/cxl_feature.c | 16 +++---- - cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c | 2 +- - libhikptdev/src/rciep/hikpt_rciep.c | 22 ++++----- - libhikptdev/src/rciep/hikpt_rciep.h | 2 + - net/hikp_net_lib.c | 33 +++++++------ - net/hikp_net_lib.h | 6 +-- - net/nic/nic_dfx/hikp_nic_dfx.c | 1 - - net/nic/nic_fd/hikp_nic_fd.c | 48 +++++++++---------- - net/nic/nic_fec/hikp_nic_fec.c | 7 +-- - net/nic/nic_info/hikp_nic_info.c | 9 ++-- - net/nic/nic_log/hikp_nic_log.c | 2 +- - net/nic/nic_ppp/hikp_nic_ppp.c | 27 +++++++---- - net/nic/nic_qos/hikp_nic_qos.c | 9 ++-- - net/nic/nic_queue/hikp_nic_queue.c | 3 +- - net/nic/nic_rss/hikp_nic_rss.c | 3 +- - .../roce_ext_common/hikp_roce_ext_common.c | 12 +++-- - net/roce/roce_gmv/hikp_roce_gmv.c | 8 ++-- - net/roce/roce_mdb/hikp_roce_mdb.c | 1 - - net/roce/roce_qmm/hikp_roce_qmm.c | 8 ++-- - net/roce/roce_scc/hikp_roce_scc.c | 6 +-- - net/roce/roce_timer/hikp_roce_timer.c | 2 +- - net/roce/roce_trp/hikp_roce_trp.c | 18 ++++--- - net/roce/roce_tsp/hikp_roce_tsp.c | 7 +-- - net/ub/ub_crd/hikp_ub_crd.c | 1 - - net/ub/ub_ppp/hikp_unic_ppp.c | 5 ++ - ossl/ossl_user_linux.c | 1 - - pcie/func_lib/pcie_func/pcie_link_ltssm.c | 3 +- - pcie/func_lib/pcie_func/pcie_link_ltssm.h | 1 + - pcie/func_lib/pcie_func/pcie_reg_dump.c | 4 +- - pcie/func_lib/pcie_func/pcie_statistics.c | 4 +- - sas/sas_func/sas_read_dev.c | 2 - - sas/sas_func/sas_read_dqe.c | 4 +- - sas/user_cmd/cmd_code/sas_cmd_dqe.c | 1 - - sas/user_cmd/cmd_code/sas_cmd_dump.c | 1 - - serdes/hikp_serdes.c | 4 +- - socip/hikp_socip_dumpreg.c | 1 - - tool_lib/op_logs.c | 18 ++++--- - tool_lib/tool_cmd.c | 1 - - tool_lib/tool_lib.c | 3 ++ - 39 files changed, 161 insertions(+), 145 deletions(-) - -diff --git a/cxl/func_lib/cxl_func/cxl_feature.c b/cxl/func_lib/cxl_func/cxl_feature.c -index 6de3f89..cd41b09 100644 ---- a/cxl/func_lib/cxl_func/cxl_feature.c -+++ b/cxl/func_lib/cxl_func/cxl_feature.c -@@ -77,13 +77,9 @@ static void cxl_dl_fsm_str_get(struct cxl_fsm_state_str *fsm_str_table, - { - int i = 0; - -- while (fsm_str_table[i].fsm_state >= 0) { -- if ((uint32_t)fsm_str_table[i].fsm_state != fsm_state) { -- i++; -- continue; -- } -- break; -- } -+ while (fsm_str_table[i].fsm_state >= 0 && -+ (uint32_t)fsm_str_table[i].fsm_state != fsm_state) -+ i++; - - *fsm_s = fsm_str_table[i].fsm_str; - } -@@ -95,7 +91,7 @@ static void cxl_dl_fsm_state_print(const struct cxl_data_unit *data, uint32_t da - struct cxl_fsm_state_str rrsm_state[] = { - {0x0, "retry_remote_normal"}, - {0x1, "retry_llrack"}, -- {-1, "unknow"} -+ {-1, "unknown"} - }; - struct cxl_fsm_state_str lrsm_state[] = { - {0x1, "retry_local_normal"}, -@@ -103,14 +99,14 @@ static void cxl_dl_fsm_state_print(const struct cxl_data_unit *data, uint32_t da - {0x4, "retry_phy_reinit"}, - {0x8, "retry_local_idle"}, - {0x10, "retry_abort"}, -- {-1, "unknow"} -+ {-1, "unknown"} - }; - struct cxl_fsm_state_str init_fsm_state[] = { - {0x1, "inactive"}, - {0x2, "retry"}, - {0x4, "param"}, - {0x8, "active"}, -- {-1, "unknow"} -+ {-1, "unknown"} - }; - - if (data_unit_len == 0) { -diff --git a/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c b/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c -index 2607705..2df9dc5 100644 ---- a/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c -+++ b/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c -@@ -46,7 +46,7 @@ static int cxl_port_id_set(struct major_cmd_ctrl *self, const char *argv) - - ret = string_toui(argv, &val); - if (ret) { -- printf("cpa set port id err %d\n", ret); -+ printf("cxl cpa set port id err %d\n", ret); - return ret; - } - g_cxl_cpa_cmd.port_id = val; -diff --git a/libhikptdev/src/rciep/hikpt_rciep.c b/libhikptdev/src/rciep/hikpt_rciep.c -index 5c7e82f..f673dd0 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.c -+++ b/libhikptdev/src/rciep/hikpt_rciep.c -@@ -41,7 +41,7 @@ static int hikp_memcpy_io(void *dst, size_t dst_size, void const *src, size_t sr - if (dst_size < src_size) - return -EINVAL; - -- for (i = 0; i < src_size / sizeof(uint32_t); i++) -+ for (i = 0; i < src_size / REP_DATA_BLK_SIZE; i++) - ((uint32_t *)dst)[i] = ((uint32_t *)src)[i]; - - return 0; -@@ -148,13 +148,13 @@ static int hikp_rep_init(void const *req_data, uint32_t req_size, - printf("The request data is NULL.\n"); - return -EINVAL; - } -- data_num = (req_size + (sizeof(uint32_t) - 1)) / sizeof(uint32_t); -+ data_num = (req_size + (REP_DATA_BLK_SIZE - 1)) / REP_DATA_BLK_SIZE; - if (data_num > HIKP_REQ_DATA_MAX) { -- printf("request data num(%u) exceeds max size(%u).\n", data_num, HIKP_REQ_DATA_MAX); -+ printf("request data num(%zu) exceeds max size(%u).\n", data_num, HIKP_REQ_DATA_MAX); - return -EINVAL; - } - if (data_num != 0) { -- *align_req_data = (uint32_t *)calloc(data_num, sizeof(uint32_t)); -+ *align_req_data = (uint32_t *)calloc(data_num, REP_DATA_BLK_SIZE); - if (*align_req_data == NULL) { - printf("request memory malloc failed.\n"); - return -ENOMEM; -@@ -175,12 +175,12 @@ static int hikp_req_first_round(uint32_t *req_data, uint32_t rep_num, uint32_t * - if (req_data == NULL) - return 0; - -- src_size = rep_num * sizeof(uint32_t); -+ src_size = rep_num * REP_DATA_BLK_SIZE; - dst_size = sizeof(g_hikp_req->field.data); - hikp_memclr_io(); - ret = hikp_memcpy_io((uint32_t *)(g_hikp_req->field.data), dst_size, req_data, src_size); - if (ret != 0) { -- printf("size error, dst_size:%u, src_size:%u.\n", dst_size, src_size); -+ printf("size error, dst_size:%zu, src_size:%zu.\n", dst_size, src_size); - return ret; - } - g_hikp_req->field.exe_round = 0; -@@ -209,7 +209,7 @@ static int hikp_multi_round_interact(struct hikp_cmd_ret **cmd_ret, uint32_t sta - } - - p_cmd_ret = (struct hikp_cmd_ret *)malloc(sizeof(struct hikp_cmd_ret) + -- rsp_num * sizeof(uint32_t)); -+ rsp_num * REP_DATA_BLK_SIZE); - if (p_cmd_ret == NULL) { - printf("response memory malloc fail.\n"); - return -ENOMEM; -@@ -235,8 +235,8 @@ static int hikp_multi_round_interact(struct hikp_cmd_ret **cmd_ret, uint32_t sta - } - } - src_size = (i == cycle - 1) ? -- (rsp_num - (i * HIKP_RSP_DATA_MAX)) * sizeof(uint32_t) : -- HIKP_RSP_DATA_MAX * sizeof(uint32_t); -+ (rsp_num - (i * HIKP_RSP_DATA_MAX)) * REP_DATA_BLK_SIZE : -+ HIKP_RSP_DATA_MAX * REP_DATA_BLK_SIZE; - dst_size = src_size; - (void)hikp_memcpy_io(&(p_cmd_ret->rsp_data)[i * HIKP_RSP_DATA_MAX], - dst_size, (uint32_t *)(g_hikp_rsp->field.data), src_size); -@@ -258,7 +258,7 @@ struct hikp_cmd_ret *hikp_cmd_alloc(struct hikp_cmd_header *req_header, - { - struct hikp_cmd_ret *cmd_ret = NULL; - uint32_t *p_req_data = NULL; -- uint32_t rep_num, rsp_num; -+ uint32_t rep_num; - uint32_t cpl_status = HIKP_INIT_STAT; - int ret; - -@@ -557,7 +557,7 @@ int hikp_dev_init(void) - goto out_unmap; - } - -- len = (sizeof(union hikp_space_req) - sizeof(struct iep_doorbell)) / sizeof(uint32_t); -+ len = (sizeof(union hikp_space_req) - sizeof(struct iep_doorbell)) / REP_DATA_BLK_SIZE; - for (i = 0; i < len; i++) - g_hikp_req->dw[i] = 0; - -diff --git a/libhikptdev/src/rciep/hikpt_rciep.h b/libhikptdev/src/rciep/hikpt_rciep.h -index dd08759..296d235 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.h -+++ b/libhikptdev/src/rciep/hikpt_rciep.h -@@ -42,6 +42,8 @@ - #define CPL_CHECK_GAP_US 1000 - #define WAIT_CPL_MAX_MS 8000 - -+#define REP_DATA_BLK_SIZE sizeof(uint32_t) -+ - enum { - HIKP_RESOURCE_DIR, - HIKP_CONFIG_DIR, -diff --git a/net/hikp_net_lib.c b/net/hikp_net_lib.c -index eba086e..8db4ad5 100644 ---- a/net/hikp_net_lib.c -+++ b/net/hikp_net_lib.c -@@ -23,7 +23,7 @@ - #include "tool_lib.h" - #include "hikptdev_plug.h" - --static int hikp_read_net_pci_info(const char *file_path, uint32_t len, char *content) -+static int hikp_read_net_pci_info(const char *file_path, char *content, size_t len) - { - char path[PATH_MAX + 1] = { 0 }; - int ret; -@@ -32,7 +32,7 @@ static int hikp_read_net_pci_info(const char *file_path, uint32_t len, char *con - if (file_path == NULL || content == NULL) - return -EINVAL; - -- if (len > MAX_PCI_ID_LEN) -+ if (len > MAX_PCI_ID_LEN + 1 || len < 1) - return -EINVAL; - - if (strlen(file_path) > PATH_MAX || realpath(file_path, path) == NULL) -@@ -42,12 +42,12 @@ static int hikp_read_net_pci_info(const char *file_path, uint32_t len, char *con - if (fd < 0) - return -EPERM; - -- ret = pread(fd, content, len, 0); -+ ret = pread(fd, content, len - 1, 0); - if (ret < 0) { - close(fd); - return -EIO; - } -- content[len] = '\0'; // The invoker ensures that the bounds are not crossed. -+ content[len - 1] = '\0'; // The invoker ensures that the bounds are not crossed. - close(fd); - - return 0; -@@ -191,7 +191,7 @@ static int tool_get_bdf_by_dev_name(const char *name, struct tool_target *target - int tool_check_and_get_valid_bdf_id(const char *name, struct tool_target *target) - { - if (!name || !target) -- return 0; -+ return -EINVAL; - - if (interface_is_bdf_id(name, target)) - return 0; -@@ -211,11 +211,14 @@ bool is_dev_valid_and_special(int sockfd, struct tool_target *target) - return true; - } - --int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id) -+int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id, size_t id_len) - { - char revision_dir[MAX_BUS_PCI_DIR_LEN] = { 0 }; - int ret; - -+ if (id_len < MAX_PCI_ID_LEN + 1) -+ return -EINVAL; -+ - ret = snprintf(revision_dir, sizeof(revision_dir), "%s%04x:%02x:%02x.%u%s", - HIKP_BUS_PCI_DEV_DIR, bdf->domain, bdf->bus_id, bdf->dev_id, - bdf->fun_id, HIKP_PCI_REVISION_DIR); -@@ -223,14 +226,14 @@ int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id) - HIKP_ERROR_PRINT("get revision dir fail.\n"); - return -EIO; - } -- ret = hikp_read_net_pci_info((const char *)revision_dir, MAX_PCI_ID_LEN, revision_id); -+ ret = hikp_read_net_pci_info((const char *)revision_dir, revision_id, id_len); - if (ret != 0) - return ret; - - return 0; - } - --static int hikp_get_dir_name_of_device(const char *path, uint32_t len, char *dir_name) -+static int hikp_get_dir_name_of_device(const char *path, size_t len, char *dir_name) - { - struct dirent *ptr; - DIR *dir = NULL; -@@ -261,12 +264,12 @@ static int hikp_get_dir_name_of_device(const char *path, uint32_t len, char *dir - return closedir(dir); - } - --int get_dev_name_by_bdf(const struct bdf_t *bdf, char *dev_name) -+int get_dev_name_by_bdf(const struct bdf_t *bdf, char *dev_name, size_t name_len) - { - char dev_name_dir[MAX_BUS_PCI_DIR_LEN] = { 0 }; - int ret; - -- if (!dev_name || !bdf) -+ if (!dev_name || !bdf || name_len < IFNAMSIZ) - return -EINVAL; - - /* if dev_name already has a value, we do not need to obtain it. */ -@@ -283,7 +286,7 @@ int get_dev_name_by_bdf(const struct bdf_t *bdf, char *dev_name) - if (!is_dir_exist(dev_name_dir)) - return -ENOENT; - -- return hikp_get_dir_name_of_device(dev_name_dir, IFNAMSIZ, dev_name); -+ return hikp_get_dir_name_of_device(dev_name_dir, name_len, dev_name); - } - - int get_vf_dev_info_by_pf_dev_name(const char *pf_dev_name, -@@ -352,7 +355,7 @@ int get_numvfs_by_bdf(const struct bdf_t *bdf, uint8_t *numvfs) - HIKP_ERROR_PRINT("get numvfs dir fail.\n"); - return -EIO; - } -- ret = hikp_read_net_pci_info((const char *)numvfs_dir, MAX_PCI_ID_LEN, numvf); -+ ret = hikp_read_net_pci_info((const char *)numvfs_dir, numvf, MAX_PCI_ID_LEN + 1); - if (ret != 0) - return ret; - -@@ -366,12 +369,12 @@ int get_numvfs_by_bdf(const struct bdf_t *bdf, uint8_t *numvfs) - return 0; - } - --void hikp_ether_format_addr(char *buf, uint16_t size, const uint8_t *mac_addr) -+void hikp_ether_format_addr(char *buf, uint16_t size, const uint8_t *mac_addr, uint8_t mac_len) - { - int len; - -- if (buf == NULL || mac_addr == NULL) { -- HIKP_WARN_PRINT("buf or mac_addr pointer is NULL.\n"); -+ if (buf == NULL || mac_addr == NULL || mac_len != HIKP_NIC_ETH_MAC_ADDR_LEN) { -+ HIKP_WARN_PRINT("buf or mac_addr pointer is NULL, or len(%u) is invalid\n", mac_len); - return; - } - -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index ad9e7e4..8a0958f 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -130,12 +130,12 @@ enum nic_get_ncsi_sub_cmd { - int hikp_net_creat_sock(void); - int tool_check_and_get_valid_bdf_id(const char *name, struct tool_target *target); - bool is_dev_valid_and_special(int sockfd, struct tool_target *target); --int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id); --int get_dev_name_by_bdf(const struct bdf_t *bdf, char *dev_name); -+int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id, size_t id_len); -+int get_dev_name_by_bdf(const struct bdf_t *bdf, char *dev_name, size_t name_len); - int get_numvfs_by_bdf(const struct bdf_t *bdf, uint8_t *numvfs); - int get_vf_dev_info_by_pf_dev_name(const char *pf_dev_name, - struct tool_target *vf_target, uint8_t vf_id); - int get_pf_dev_info_by_vf_dev_name(const char *vf_dev_name, struct tool_target *pf_target); --void hikp_ether_format_addr(char *buf, uint16_t size, const uint8_t *mac_addr); -+void hikp_ether_format_addr(char *buf, uint16_t size, const uint8_t *mac_addr, uint8_t mac_len); - - #endif -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c -index c734ce0..4095229 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.c -+++ b/net/nic/nic_dfx/hikp_nic_dfx.c -@@ -318,7 +318,6 @@ static void hikp_nic_dfx_cmd_execute(struct major_cmd_ctrl *self) - uint32_t max_dfx_size; - uint32_t version; - uint32_t i; -- int ret; - - if (!(g_dfx_param.flag & MODULE_SET_FLAG)) { - self->err_no = -EINVAL; -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index 57bc94b..e699bf9 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -15,7 +15,7 @@ - #include - #include - #include -- -+#include - #include "hikp_nic_fd.h" - - struct key_info { -@@ -255,13 +255,13 @@ static void hikp_nic_print_tuple(const struct key_info *tuple_key, - case OUTER_SRC_MAC: - case INNER_DST_MAC: - case INNER_SRC_MAC: -- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask); -+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask); - printf("%02x:%02x:%02x:%02x:%02x:%02x\n", *(tcam_y + 5), *(tcam_y + 4), - *(tcam_y + 3), *(tcam_y + 2), *(tcam_y + 1), *tcam_y); - break; - case OUTER_ETH_TYPE: - case INNER_ETH_TYPE: -- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask); -+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask); - printf("0x%x\n", *(uint16_t *)tcam_y); - break; - case OUTER_VLAN_TAG_FST: -@@ -276,7 +276,7 @@ static void hikp_nic_print_tuple(const struct key_info *tuple_key, - case OUTER_DST_PORT: - case INNER_SRC_PORT: - case INNER_DST_PORT: -- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask); -+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask); - printf("%u\n", *(uint16_t *)tcam_y); - break; - case OUTER_IP_TOS: -@@ -284,25 +284,25 @@ static void hikp_nic_print_tuple(const struct key_info *tuple_key, - case OUTER_IP_PROTO: - case INNER_IP_PROTO: - case OUTER_TUN_FLOW_ID: -- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask); -+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask); - printf("0x%x\n", *tcam_y); - break; - case OUTER_SRC_IP: - case OUTER_DST_IP: - case INNER_SRC_IP: - case INNER_DST_IP: -- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask); -+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask); - printf("%u.%u.%u.%u\n", *(tcam_y + 3), *(tcam_y + 2), *(tcam_y + 1), *tcam_y); - break; - case OUTER_L4_RSV: - case INNER_L4_RSV: -- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask); -+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask); - printf("%u\n", *(uint32_t *)tcam_y); - break; - case OUTER_TUN_VNI: - for (i = 0; i < HIKP_NIC_FD_TUN_VNI_LEN; i++) - tun_vni |= (((uint32_t)*(tcam_y + i)) << (i * HIKP_BITS_PER_BYTE)); -- printf("\t %s[mask=0x%llx]: ", tuple_key->key_name, mask); -+ printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask); - printf("0x%x\n", tun_vni); - break; - default: -@@ -407,12 +407,12 @@ static void hikp_nic_fd_print_meta_data(struct nic_fd_rule_info *rule) - meta_bytes = HIKP_DIV_ROUND_UP(active_meta_width, HIKP_BITS_PER_BYTE); - meta_data_region = active_tcam_size - meta_bytes; - if (meta_bytes > sizeof(meta_data)) { -- printf("meta data copy size error, data size: 0x%x, max size: 0x%x\n", -+ printf("meta data copy size error, data size: %u, max size: %zu\n", - meta_bytes, sizeof(meta_data)); - return; - } - memcpy(&meta_data, &key_y[meta_data_region], meta_bytes); -- printf("\t meta_data[meta_data=0x%llx]:\n", meta_data); -+ printf("\t meta_data[meta_data=0x%" PRIx64 "]:\n", meta_data); - cur_pos = meta_bytes * HIKP_BITS_PER_BYTE; - end = cur_pos - 1; - for (i = MAX_META_DATA - 1; i >= 0; i--) { -@@ -470,7 +470,7 @@ static void hikp_nic_fd_print_ad_data(struct nic_fd_rule_info *rule) - uint64_t ad_data; - - ad_data = (uint64_t)rule->ad_data_h << NIC_FD_AD_DATA_S | rule->ad_data_l; -- printf("\n\tAction[ad data: 0x%llx]:\n", ad_data); -+ printf("\n\tAction[ad data: 0x%" PRIx64 "]:\n", ad_data); - - hikp_nic_parse_ad_data(rule, &action); - -@@ -544,7 +544,7 @@ static void hikp_nic_show_fd_counter(const void *data) - printf(" idx | hit_cnt\n"); - for (i = 0; i < counter[stage_no].counter_size; i++) { - entry = &counter[stage_no].entry[i]; -- printf(" %3u | %llu\n", entry->idx, entry->value); -+ printf(" %3u | %" PRIu64 "\n", entry->idx, entry->value); - } - } - -@@ -554,7 +554,6 @@ static int hikp_nic_fd_get_blk(struct hikp_cmd_header *req_header, - { - struct hikp_cmd_ret *cmd_ret; - struct nic_fd_rsp *rsp; -- uint16_t idx; - int ret = 0; - - cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data)); -@@ -792,10 +791,13 @@ static void hikp_nic_fd_data_free(union nic_fd_feature_info *fd_data) - const struct fd_feature_cmd *fd_cmd; - - fd_cmd = &g_fd_feature_cmd[g_fd_param.feature_idx]; -- if (strcmp(fd_cmd->feature_name, NIC_FD_RULES_NAME) == 0) -+ if (strcmp(fd_cmd->feature_name, NIC_FD_RULES_NAME) == 0) { - free(fd_data->rules[stage_no].rule); -- else if (strcmp(fd_cmd->feature_name, NIC_FD_COUNTER_NAME) == 0) -+ fd_data->rules[stage_no].rule = NULL; -+ } else if (strcmp(fd_cmd->feature_name, NIC_FD_COUNTER_NAME) == 0) { - free(fd_data->counter[stage_no].entry); -+ fd_data->counter[stage_no].entry = NULL; -+ } - - free(fd_data); - } -@@ -859,31 +861,27 @@ static int hikp_nic_fd_check_input_param(struct major_cmd_ctrl *self, - - if (bdf->dev_id != 0) { - snprintf(self->err_str, sizeof(self->err_str), "VF does not support query!"); -- self->err_no = -EINVAL; -- return self->err_no; -+ return -EINVAL; - } - - if (fd_param->feature_idx == -1) { - hikp_nic_fd_cmd_help(self, NULL); - snprintf(self->err_str, sizeof(self->err_str), "-du/--dump parameter error!"); -- self->err_no = -EINVAL; -- return self->err_no; -+ return -EINVAL; - } - - fd_cmd = &g_fd_feature_cmd[g_fd_param.feature_idx]; - if (fd_param->stage_no == -1 && fd_cmd->sub_cmd_code != NIC_FD_HW_INFO_DUMP) { - snprintf(self->err_str, sizeof(self->err_str), - "please input '-st/--stage' parameter."); -- self->err_no = -EINVAL; -- return self->err_no; -+ return -EINVAL; - } - - if (fd_cmd->sub_cmd_code == NIC_FD_HW_INFO_DUMP && - (fd_param->id != -1 || fd_param->stage_no != -1)) { - snprintf(self->err_str, sizeof(self->err_str), - "no need '-id/--index' and '-st/--stage' parameter."); -- self->err_no = -EINVAL; -- return self->err_no; -+ return -EINVAL; - } - - return 0; -@@ -899,8 +897,10 @@ static void hikp_nic_fd_cmd_execute(struct major_cmd_ctrl *self) - int ret; - - ret = hikp_nic_fd_check_input_param(self, &g_fd_param); -- if (ret != 0) -+ if (ret != 0) { -+ self->err_no = ret; - return; -+ } - - ret = hikp_nic_get_fd_hw_info(bdf, &g_fd_hw_info); - if (ret != 0) { -diff --git a/net/nic/nic_fec/hikp_nic_fec.c b/net/nic/nic_fec/hikp_nic_fec.c -index 5d9025c..342b3eb 100644 ---- a/net/nic/nic_fec/hikp_nic_fec.c -+++ b/net/nic/nic_fec/hikp_nic_fec.c -@@ -15,7 +15,7 @@ - #include - #include - #include -- -+#include - #include "hikp_nic_fec.h" - - static struct tool_target g_fec_target; -@@ -40,6 +40,7 @@ static int hikp_nic_fec_err_query(const struct bdf_t *bdf, struct nic_fec_err_in - rsp = (struct nic_fec_rsp *)cmd_ret->rsp_data; - *info = *(struct nic_fec_err_info *)rsp->data; - free(cmd_ret); -+ cmd_ret = NULL; - - if (info->fec_mode >= NIC_FEC_MODE_BUTT) { - HIKP_ERROR_PRINT("unknown fec mode: %u\n", info->fec_mode); -@@ -71,7 +72,7 @@ static void hikp_nic_fec_err_show_basefec(const struct nic_fec_err_info *info) - for (total = 0, i = 0; i < lane_num; i++) - total += info->basefec.lane_corr_block_cnt[i]; - -- printf(" corrected_blocks: %llu\n", total); -+ printf(" corrected_blocks: %" PRIu64 "\n", total); - for (i = 0; i < lane_num; i++) - printf(" Lane %u: %u\n", i, info->basefec.lane_corr_block_cnt[i]); - -@@ -79,7 +80,7 @@ static void hikp_nic_fec_err_show_basefec(const struct nic_fec_err_info *info) - for (total = 0, i = 0; i < lane_num; i++) - total += info->basefec.lane_uncorr_block_cnt[i]; - -- printf(" uncorrectable_blocks: %llu\n", total); -+ printf(" uncorrectable_blocks: %" PRIu64 "\n", total); - for (i = 0; i < lane_num; i++) - printf(" Lane %u: %u\n", i, info->basefec.lane_uncorr_block_cnt[i]); - } -diff --git a/net/nic/nic_info/hikp_nic_info.c b/net/nic/nic_info/hikp_nic_info.c -index d84ca18..cd78bc7 100644 ---- a/net/nic/nic_info/hikp_nic_info.c -+++ b/net/nic/nic_info/hikp_nic_info.c -@@ -79,7 +79,8 @@ static int hikp_nic_get_curr_die_info(void) - free(cmd_ret); - cmd_ret = NULL; - -- ret = get_revision_id_by_bdf(&g_info_param.target.bdf, g_info_param.revision_id); -+ ret = get_revision_id_by_bdf(&g_info_param.target.bdf, g_info_param.revision_id, -+ sizeof(g_info_param.revision_id)); - if (ret != 0) { - HIKP_ERROR_PRINT("Getting revision fail.\n"); - return ret; -@@ -87,7 +88,8 @@ static int hikp_nic_get_curr_die_info(void) - ret = get_numvfs_by_bdf(&g_info_param.target.bdf, &g_info_param.numvfs); - if (ret != 0) - HIKP_ERROR_PRINT("Getting numvfs fail, ret = %d.\n", ret); -- ret = get_dev_name_by_bdf(&g_info_param.target.bdf, g_info_param.target.dev_name); -+ ret = get_dev_name_by_bdf(&g_info_param.target.bdf, g_info_param.target.dev_name, -+ sizeof(g_info_param.target.dev_name)); - if ((ret != 0) && (ret != -ENOENT)) { - HIKP_ERROR_PRINT("Getting dev name fail.\n"); - return ret; -@@ -258,7 +260,8 @@ static void hikp_nic_info_print_cur_vf(const struct bdf_t *bdf) - printf("Current function is vf:\n"); - printf("\t%-16s %04x:%02x:%02x.%u\n", "vf bdf id:", - bdf->domain, bdf->bus_id, bdf->dev_id, bdf->fun_id); -- ret = get_dev_name_by_bdf(&g_info_param.target.bdf, g_info_param.target.dev_name); -+ ret = get_dev_name_by_bdf(&g_info_param.target.bdf, g_info_param.target.dev_name, -+ sizeof(g_info_param.target.dev_name)); - if ((ret != 0) && (ret != -ENOENT)) { - HIKP_ERROR_PRINT("Getting dev name fail.\n"); - return; -diff --git a/net/nic/nic_log/hikp_nic_log.c b/net/nic/nic_log/hikp_nic_log.c -index 5cafe4e..893aef1 100644 ---- a/net/nic/nic_log/hikp_nic_log.c -+++ b/net/nic/nic_log/hikp_nic_log.c -@@ -113,7 +113,7 @@ static int hikp_nic_get_first_blk_info(uint32_t *total_blk_num, - } - *log_data = (uint8_t *)calloc(1, log_size); - if (*log_data == NULL) { -- HIKP_ERROR_PRINT("malloc log memory 0x%x failed.", log_size); -+ HIKP_ERROR_PRINT("calloc log memory 0x%x failed.", log_size); - ret = -ENOMEM; - goto err_out; - } -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index b71fc48..7968ac3 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -95,7 +95,7 @@ static uint16_t hikp_nic_ppp_get_abs_func_id(const struct bdf_t *bdf, int relati - static void hikp_nic_ppp_get_func_name(char *buf, uint8_t len, uint8_t id) - { - if (id > 0) -- snprintf(buf, len, "vf%d", id - 1); -+ snprintf(buf, len, "vf%u", id - 1); - else - snprintf(buf, len, "pf"); - } -@@ -145,7 +145,8 @@ static void hikp_nic_ppp_show_key_mem(struct nic_mac_tbl *tbl, bool is_key_mem) - uc_entry = &uc_tbl->entry[idx]; - if (uc_entry->idx < g_ppp_hw_res.max_key_mem_size || !is_key_mem) { - hikp_ether_format_addr(mac_str, -- HIKP_NIC_ETH_ADDR_FMT_SIZE, uc_entry->mac_addr); -+ HIKP_NIC_ETH_ADDR_FMT_SIZE, uc_entry->mac_addr, -+ HIKP_NIC_ETH_MAC_ADDR_LEN); - printf("%04u | %01u | %s | ", uc_entry->idx, uc_entry->valid, mac_str); - printf("%04u | %u | %01u | ", - uc_entry->vlan_id, uc_entry->vmdq1, uc_entry->mac_en); -@@ -161,7 +162,8 @@ static void hikp_nic_ppp_show_key_mem(struct nic_mac_tbl *tbl, bool is_key_mem) - mc_entry = &mc_tbl->entry[idx]; - if (mc_entry->idx < g_ppp_hw_res.max_key_mem_size || !is_key_mem) { - hikp_ether_format_addr(mac_str, -- HIKP_NIC_ETH_ADDR_FMT_SIZE, mc_entry->mac_addr); -+ HIKP_NIC_ETH_ADDR_FMT_SIZE, mc_entry->mac_addr, -+ HIKP_NIC_ETH_MAC_ADDR_LEN); - printf("%04u | %s | ", mc_entry->idx, mac_str); - printf("%08x:%08x:%08x:%08x:%08x:%08x:%08x:%08x", - mc_entry->function_bitmap[7], mc_entry->function_bitmap[6], -@@ -191,7 +193,7 @@ static void hikp_nic_ppp_show_func_uc_mac_addr(struct mac_vlan_uc_tbl *uc_tbl, - vf_id = hikp_get_field(uc_entry->e_vport, HIKP_NIC_VF_ID_MASK, HIKP_NIC_VF_ID_S); - if (bdf->fun_id == pf_id && vf_id == func_id) { - hikp_ether_format_addr(mac_str, HIKP_NIC_ETH_ADDR_FMT_SIZE, -- uc_entry->mac_addr); -+ uc_entry->mac_addr, HIKP_NIC_ETH_MAC_ADDR_LEN); - printf("\t%s\n", mac_str); - } - } -@@ -205,7 +207,7 @@ static void hikp_nic_ppp_show_func_mc_mac_addr(struct mac_vlan_mc_tbl *mc_tbl, - uint16_t abs_func_id; - uint8_t offset; - uint8_t idx; -- uint8_t i; -+ uint32_t i; - - abs_func_id = hikp_nic_ppp_get_abs_func_id(bdf, func_id); - idx = abs_func_id / HIKP_NIC_PPP_FUNC_BITMAP_SIZE; -@@ -218,7 +220,7 @@ static void hikp_nic_ppp_show_func_mc_mac_addr(struct mac_vlan_mc_tbl *mc_tbl, - - if (hikp_get_bit(mc_entry->function_bitmap[idx], offset) != 0) { - hikp_ether_format_addr(mac_str, HIKP_NIC_ETH_ADDR_FMT_SIZE, -- mc_entry->mac_addr); -+ mc_entry->mac_addr, HIKP_NIC_ETH_MAC_ADDR_LEN); - printf("\t%s\n", mac_str); - } - } -@@ -401,7 +403,8 @@ static void hikp_nic_ppp_show_manager_tbl(const void *data) - "| i_map | i_dir | e_type | pf_id | vf_id | q_id | drop\n"); - for (i = 0; i < tbl->entry_size; i++) { - entry = &tbl->entry[i]; -- hikp_ether_format_addr(mac_str, HIKP_NIC_ETH_ADDR_FMT_SIZE, entry->mac_addr); -+ hikp_ether_format_addr(mac_str, HIKP_NIC_ETH_ADDR_FMT_SIZE, entry->mac_addr, -+ HIKP_NIC_ETH_MAC_ADDR_LEN); - printf(" %02u | %s | %u ", entry->entry_no, mac_str, entry->mac_mask); - printf("| %04x | %u | %04u | %u ", - entry->ether_type, entry->ether_mask, entry->vlan_id, entry->vlan_mask); -@@ -489,7 +492,7 @@ static int hikp_nic_ppp_get_blk(struct hikp_cmd_header *req_header, - rsp = (struct nic_ppp_rsp *)cmd_ret->rsp_data; - if (rsp->rsp_head.cur_blk_size > buf_len) { - HIKP_ERROR_PRINT("nic_ppp block context copy size error, " -- "buffer size=%u, data size=%u.\n", -+ "buffer size=%zu, data size=%u.\n", - buf_len, rsp->rsp_head.cur_blk_size); - ret = -EINVAL; - goto out; -@@ -791,6 +794,7 @@ static int hikp_nic_ppp_alloc_mac_tbl_entry(struct nic_mac_tbl *mac_tbl, - if (mac_tbl->mc_tbl.entry == NULL) { - HIKP_ERROR_PRINT("Fail to alloc mc_entry memory.\n"); - free(mac_tbl->uc_tbl.entry); -+ mac_tbl->uc_tbl.entry = NULL; - return -ENOMEM; - } - -@@ -813,6 +817,7 @@ static int hikp_nic_ppp_alloc_vlan_tbl_entry(struct nic_vlan_tbl *vlan_tbl, - if (vlan_tbl->vf_vlan_tbl.entry == NULL) { - HIKP_ERROR_PRINT("Fail to alloc vf_vlan_tbl_entry memory.\n"); - free(vlan_tbl->port_vlan_tbl.entry); -+ vlan_tbl->port_vlan_tbl.entry = NULL; - return -ENOMEM; - } - -@@ -872,16 +877,22 @@ static void hikp_nic_ppp_data_free(union nic_ppp_feature_info *ppp_data) - if (strcmp(ppp_cmd->feature_name, NIC_PPP_MAC_TBL_NAME) == 0) { - mac_tbl = &ppp_data->mac_tbl; - free(mac_tbl->uc_tbl.entry); -+ mac_tbl->uc_tbl.entry = NULL; - free(mac_tbl->mc_tbl.entry); -+ mac_tbl->mc_tbl.entry = NULL; - } else if (strcmp(ppp_cmd->feature_name, NIC_PPP_VLAN_TBL_NAME) == 0) { - vlan_tbl = &ppp_data->vlan_tbl; - free(vlan_tbl->vf_vlan_tbl.entry); -+ vlan_tbl->vf_vlan_tbl.entry = NULL; - free(vlan_tbl->port_vlan_tbl.entry); -+ vlan_tbl->port_vlan_tbl.entry = NULL; - } else if (strcmp(ppp_cmd->feature_name, NIC_PPP_MNG_TBL_NAME) == 0) { - mng_tbl = &ppp_data->mng_tbl; - free(mng_tbl->entry); -+ mng_tbl->entry = NULL; - } - free(ppp_data); -+ ppp_data = NULL; - } - - static int hikp_nic_ppp_check_optional_param(struct major_cmd_ctrl *self, -diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c -index e3f0e9c..a09b4f1 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.c -+++ b/net/nic/nic_qos/hikp_nic_qos.c -@@ -98,12 +98,12 @@ static void hikp_nic_qos_show_dcb_info(const void *data) - printf("PFC configuration\n"); - printf(" PFC enable:"); - for (up = 0; up < HIKP_NIC_MAX_USER_PRIO_NUM; up++) -- printf(" %d", HI_BIT(up) & pfc->pfc_en ? 1 : 0); -+ printf(" %u", HI_BIT(up) & pfc->pfc_en ? 1 : 0); - - printf("\n"); - printf(" TC enable:"); - for (tc_no = 0; tc_no < HIKP_NIC_MAX_TC_NUM; tc_no++) -- printf(" %d", HI_BIT(tc_no) & pfc->hw_tc_map ? 1 : 0); -+ printf(" %u", HI_BIT(tc_no) & pfc->hw_tc_map ? 1 : 0); - - printf("\n"); - printf("ETS configuration\n"); -@@ -176,7 +176,7 @@ static int hikp_nic_qos_get_blk(struct hikp_cmd_header *req_header, - rsp = (struct nic_qos_rsp *)cmd_ret->rsp_data; - if (rsp->rsp_head.cur_blk_size > buf_len) { - HIKP_ERROR_PRINT("nic_qos block-%u copy size error, " -- "buffer size=%u, data size=%u.\n", -+ "buffer size=%zu, data size=%u.\n", - req_data->block_id, buf_len, rsp->rsp_head.cur_blk_size); - ret = -EINVAL; - goto out; -@@ -198,7 +198,6 @@ static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const - size_t buf_len = sizeof(*data); - uint32_t total_blk_size; - uint8_t total_blk_num; -- uint8_t blk_num = 0; - uint8_t blk_id = 0; - int ret; - -@@ -272,7 +271,7 @@ static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self) - } - - memset(revision_id, 0, MAX_PCI_ID_LEN + 1); -- ret = get_revision_id_by_bdf(bdf, revision_id); -+ ret = get_revision_id_by_bdf(bdf, revision_id, sizeof(g_qos_param.revision_id)); - // show pfc threshold as default if get revision_id error - if (ret) - strncpy(g_qos_param.revision_id, HIKP_IEP_REVISION, -diff --git a/net/nic/nic_queue/hikp_nic_queue.c b/net/nic/nic_queue/hikp_nic_queue.c -index f229e09..fa3b9d3 100644 ---- a/net/nic/nic_queue/hikp_nic_queue.c -+++ b/net/nic/nic_queue/hikp_nic_queue.c -@@ -248,7 +248,7 @@ static int hikp_nic_queue_get_blk(struct hikp_cmd_header *req_header, - rsp = (struct nic_queue_rsp *)cmd_ret->rsp_data; - if (rsp->rsp_head.cur_blk_size > buf_len) { - HIKP_ERROR_PRINT("nic_queue block-%u copy size error, " -- "buffer size=%u, data size=%u.\n", -+ "buffer size=%zu, data size=%u.\n", - req_data->block_id, buf_len, rsp->rsp_head.cur_blk_size); - ret = -EINVAL; - goto out; -@@ -340,7 +340,6 @@ static bool hikp_nic_queue_check_feature_para_vaild(const struct queue_feature_c - - static void hikp_nic_queue_cmd_execute(struct major_cmd_ctrl *self) - { -- struct bdf_t *bdf = &g_queue_param.target.bdf; - const struct queue_feature_cmd *queue_cmd; - union nic_queue_feature_info *queue_data; - struct hikp_cmd_header req_header = {0}; -diff --git a/net/nic/nic_rss/hikp_nic_rss.c b/net/nic/nic_rss/hikp_nic_rss.c -index 5e4d261..ff1cfd2 100644 ---- a/net/nic/nic_rss/hikp_nic_rss.c -+++ b/net/nic/nic_rss/hikp_nic_rss.c -@@ -366,7 +366,7 @@ static int hikp_nic_rss_get_blk(struct hikp_cmd_header *req_header, - rsp = (struct nic_rss_rsp *)cmd_ret->rsp_data; - if (rsp->rsp_head.cur_blk_size > buf_len) { - HIKP_ERROR_PRINT("nic_rss block-%u copy size error, " -- "buffer size=%u, data size=%u.\n", -+ "buffer size=%zu, data size=%u.\n", - req_data->block_id, buf_len, rsp->rsp_head.cur_blk_size); - ret = -EINVAL; - goto out; -@@ -388,7 +388,6 @@ static int hikp_nic_query_rss_feature(struct hikp_cmd_header *req_header, const - size_t buf_len = sizeof(*data); - uint32_t total_blk_size; - uint8_t total_blk_num; -- uint8_t blk_num = 0; - uint8_t blk_id = 0; - int ret; - -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 d5ae64a..3a0c1ae 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -15,11 +15,15 @@ - - static void hikp_roce_ext_reg_data_free(struct reg_data *reg) - { -- if (reg->offset) -+ if (reg->offset) { - free(reg->offset); -+ reg->offset = NULL; -+ } - -- if (reg->data) -+ if (reg->data) { - free(reg->data); -+ reg->data = NULL; -+ } - } - - static void hikp_roce_ext_cmd_ret_free(struct hikp_cmd_ret *cmd_ret) -@@ -118,7 +122,7 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - 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)); - if ((reg->offset == NULL) || (reg->data == NULL)) { -- printf("hikptool roce_%s alloc log memmory 0x%x failed!\n", -+ printf("hikptool roce_%s alloc log memmory 0x%zx failed!\n", - cmd_name, max_size); - ret = -ENOMEM; - hikp_roce_ext_reg_data_free(reg); -@@ -128,7 +132,7 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - - cur_size = res_head->cur_block_num * sizeof(uint32_t); - if (cur_size > max_size) { -- printf("hikptool roce_%s log data copy size error, data size: 0x%x, max size: 0x%x\n", -+ printf("hikptool roce_%s log data copy size error, data size: 0x%zx, max size: 0x%zx\n", - cmd_name, cur_size, max_size); - ret = -EINVAL; - hikp_roce_ext_reg_data_free(reg); -diff --git a/net/roce/roce_gmv/hikp_roce_gmv.c b/net/roce/roce_gmv/hikp_roce_gmv.c -index d65dc82..36ba665 100644 ---- a/net/roce/roce_gmv/hikp_roce_gmv.c -+++ b/net/roce/roce_gmv/hikp_roce_gmv.c -@@ -44,16 +44,16 @@ static int hikp_roce_gmv_target(struct major_cmd_ctrl *self, const char *argv) - static int hikp_roce_gmv_idxget(struct major_cmd_ctrl *self, const char *argv) - { - char *endptr = NULL; -- int index; -+ uint64_t index; - -- index = strtol(argv, &endptr, 0); -+ index = strtoul(argv, &endptr, 0); - if ((endptr <= argv) || (*endptr != '\0') || -- (index < 0) || (index >= ROCE_MAX_HIKPTOOL_GMV)) { -+ (index >= ROCE_MAX_HIKPTOOL_GMV)) { - snprintf(self->err_str, sizeof(self->err_str), "Invalid gmv_index."); - self->err_no = -EINVAL; - return -EINVAL; - } -- g_roce_gmv_param.gmv_index = index; -+ g_roce_gmv_param.gmv_index = (uint32_t)index; - - return 0; - } -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.c b/net/roce/roce_mdb/hikp_roce_mdb.c -index 04af817..374f100 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.c -+++ b/net/roce/roce_mdb/hikp_roce_mdb.c -@@ -89,7 +89,6 @@ static void hikp_roce_mdb_execute_origin(struct major_cmd_ctrl *self) - struct roce_mdb_rsp_data *mdb_rsp = NULL; - struct hikp_cmd_ret *cmd_ret = NULL; - uint32_t reg_num; -- int ret; - - self->err_no = hikp_roce_mdb_get_data(&cmd_ret, 0); - if (self->err_no) { -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.c b/net/roce/roce_qmm/hikp_roce_qmm.c -index d127264..e440b82 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.c -+++ b/net/roce/roce_qmm/hikp_roce_qmm.c -@@ -45,16 +45,16 @@ static int hikp_roce_qmm_target(struct major_cmd_ctrl *self, const char *argv) - static int hikp_roce_qmm_bank_get(struct major_cmd_ctrl *self, const char *argv) - { - char *endptr = NULL; -- int bank_num; -+ uint64_t bank_num; - -- bank_num = strtol(argv, &endptr, 0); -- if ((endptr <= argv) || (*endptr != '\0') || bank_num > QMM_BANK_NUM || bank_num < 0) { -+ bank_num = strtoul(argv, &endptr, 0); -+ if ((endptr <= argv) || (*endptr != '\0') || bank_num > QMM_BANK_NUM) { - snprintf(self->err_str, sizeof(self->err_str), "Invalid bank number!\n"); - self->err_no = -EINVAL; - return -EINVAL; - } - -- g_roce_qmm_param.bank_id = bank_num; -+ g_roce_qmm_param.bank_id = (uint32_t)bank_num; - return 0; - } - -diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c -index e8e166d..fe08873 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.c -+++ b/net/roce/roce_scc/hikp_roce_scc.c -@@ -150,7 +150,7 @@ static int hikp_roce_scc_get_total_data_num(struct roce_scc_head *res_head, - *offset = (uint32_t *)calloc(1, max_size); - *data = (uint32_t *)calloc(1, max_size); - if ((*offset == NULL) || (*data == NULL)) { -- printf("hikptool roce_scc alloc log memmory 0x%x failed\n", max_size); -+ printf("hikptool roce_scc alloc log memmory 0x%zx failed\n", max_size); - ret = -ENOMEM; - goto get_data_error; - } -@@ -158,7 +158,7 @@ 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) { - printf("hikptool roce_scc log data copy size error, " -- "data size: 0x%x, max size: 0x%x\n", cur_size, max_size); -+ "data size: 0x%zx, max size: 0x%zx\n", cur_size, max_size); - ret = -EINVAL; - goto get_data_error; - } -@@ -194,7 +194,7 @@ static int hikp_roce_scc_get_next_data(struct roce_scc_head *res_head, - if (cur_size > data_size) { - hikp_roce_scc_cmd_ret_free(&cmd_ret); - printf("hikptool roce_scc next log data copy size error, " -- "data size: 0x%x, max size: 0x%x\n", cur_size, data_size); -+ "data size: 0x%zx, max size: 0x%zx\n", cur_size, data_size); - return -EINVAL; - } - memcpy(*offset, roce_scc_res->reg_data.offset, cur_size); -diff --git a/net/roce/roce_timer/hikp_roce_timer.c b/net/roce/roce_timer/hikp_roce_timer.c -index a78d383..05ad3e1 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.c -+++ b/net/roce/roce_timer/hikp_roce_timer.c -@@ -149,7 +149,7 @@ static void hikp_roce_timer_execute(struct major_cmd_ctrl *self) - int (*func[])(struct major_cmd_ctrl *self) = { - hikp_roce_timer_show_cqc, hikp_roce_timer_show_qpc - }; -- char *function[] = {"show cqc", "show qpc"}; -+ const char *function[] = {"show cqc", "show qpc"}; - int i = 0; - int ret; - -diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c -index 4591a47..fad3317 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.c -+++ b/net/roce/roce_trp/hikp_roce_trp.c -@@ -85,20 +85,17 @@ static int hikp_roce_trp_bank_get(struct major_cmd_ctrl *self, const char *argv) - - static int hikp_roce_trp_bank_check(void) - { -- uint32_t temp; -- -- temp = g_roce_trp_param_t.bank_id; - switch (g_roce_trp_param_t.sub_cmd) { - case (COMMON): -- if (temp > TRP_MAX_BANK_NUM || temp < 0) -+ if (g_roce_trp_param_t.bank_id > TRP_MAX_BANK_NUM) - return -EINVAL; - break; - case (PAYL): -- if (temp > PAYL_MAX_BANK_NUM || temp < 0) -+ if (g_roce_trp_param_t.bank_id > PAYL_MAX_BANK_NUM) - return -EINVAL; - break; - case (GEN_AC): -- if (temp > GAC_MAX_BANK_NUM || temp < 0) -+ if (g_roce_trp_param_t.bank_id > GAC_MAX_BANK_NUM) - return -EINVAL; - break; - default: -@@ -173,7 +170,8 @@ static int hikp_roce_trp_get_total_data_num(struct roce_trp_head *res_head, - *offset = (uint32_t *)calloc(1, max_size); - *data = (uint32_t *)calloc(1, max_size); - if ((*offset == NULL) || (*data == NULL)) { -- printf("hikptool roce_trp alloc log memmory 0x%x failed\n", max_size); -+ printf("hikptool roce_trp alloc log memmory 0x%zx failed\n", max_size); -+ hikp_roce_trp_reg_data_free(offset, data); - ret = -ENOMEM; - goto get_data_error; - } -@@ -181,7 +179,8 @@ 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) { - printf("hikptool roce_trp log data copy size error, " -- "data size: 0x%x, max size: 0x%x\n", cur_size, max_size); -+ "data size: 0x%zx, max size: 0x%zx\n", cur_size, max_size); -+ hikp_roce_trp_reg_data_free(offset, data); - ret = -EINVAL; - goto get_data_error; - } -@@ -218,7 +217,7 @@ static int hikp_roce_trp_get_next_data(struct roce_trp_head *res_head, - if (cur_size > data_size) { - hikp_roce_trp_cmd_ret_free(&cmd_ret); - printf("hikptool roce_trp next log data copy size error, " -- "data size: 0x%x, max size: 0x%x\n", cur_size, data_size); -+ "data size: 0x%zx, max size: 0x%zx\n", cur_size, data_size); - return -EINVAL; - } - memcpy(*offset, roce_trp_res->reg_data.offset, cur_size); -@@ -268,7 +267,6 @@ static void hikp_roce_trp_execute(struct major_cmd_ctrl *self) - if (self->err_no) { - snprintf(self->err_str, sizeof(self->err_str), - "get the first roce_trp block dfx fail."); -- hikp_roce_trp_reg_data_free(&offset, &data); - return; - } - total_block_num = res_head.total_block_num; -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.c b/net/roce/roce_tsp/hikp_roce_tsp.c -index 9469e4d..5bb2649 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.c -+++ b/net/roce/roce_tsp/hikp_roce_tsp.c -@@ -84,16 +84,13 @@ static int hikp_roce_tsp_bank_get(struct major_cmd_ctrl *self, const char *argv) - - static int hikp_roce_tsp_bank_check(void) - { -- uint32_t temp; -- -- temp = g_roce_tsp_param_t.bank_id; - switch (g_roce_tsp_param_t.sub_cmd_code) { - case (COMMON): -- if ((temp > MAX_TSP_BANK_NUM) || temp < 0) -+ if (g_roce_tsp_param_t.bank_id > MAX_TSP_BANK_NUM) - return -EINVAL; - break; - case (TGP_TMP): -- if ((temp > MAX_TGP_TMP_BANK_NUM) || temp < 0) -+ if (g_roce_tsp_param_t.bank_id > MAX_TGP_TMP_BANK_NUM) - return -EINVAL; - break; - default: -diff --git a/net/ub/ub_crd/hikp_ub_crd.c b/net/ub/ub_crd/hikp_ub_crd.c -index e207ea2..0e47b5b 100644 ---- a/net/ub/ub_crd/hikp_ub_crd.c -+++ b/net/ub/ub_crd/hikp_ub_crd.c -@@ -64,7 +64,6 @@ static int hikp_ub_query_crd(void) - struct hikp_cmd_ret *cmd_ret = NULL; - struct ub_crd_rsp *crd_rsp = NULL; - int offset; -- int ret; - - char const *init_crds[][2] = { - {"CFG_REMOTE_ICRD", "CFG_REMOTE_LCRD"}, -diff --git a/net/ub/ub_ppp/hikp_unic_ppp.c b/net/ub/ub_ppp/hikp_unic_ppp.c -index ccba4e0..bf0c026 100644 ---- a/net/ub/ub_ppp/hikp_unic_ppp.c -+++ b/net/ub/ub_ppp/hikp_unic_ppp.c -@@ -191,6 +191,7 @@ static int hikp_unic_ppp_alloc_guid_tbl_entry(const struct hikp_unic_ppp_hw_reso - if (guid_tbl->mc_tbl.entry == NULL) { - HIKP_ERROR_PRINT("fail to alloc mc_guid_entry_table memory.\n"); - free(guid_tbl->uc_tbl.entry); -+ guid_tbl->uc_tbl.entry = NULL; - return -ENOMEM; - } - -@@ -399,13 +400,17 @@ static void hikp_unic_ppp_data_free(union unic_ppp_feature_info *unic_ppp_data) - if (g_unic_ppp_param.feature_idx == UNIC_PPP_IP_FEATURE_IDX) { - ip_tbl = &unic_ppp_data->ip_tbl; - free(ip_tbl->entry); -+ ip_tbl->entry = NULL; - } else if (g_unic_ppp_param.feature_idx == UNIC_PPP_GUID_FEATURE_IDX) { - guid_tbl = &unic_ppp_data->guid_tbl; - free(guid_tbl->uc_tbl.entry); -+ guid_tbl->uc_tbl.entry = NULL; - free(guid_tbl->mc_tbl.entry); -+ guid_tbl->mc_tbl.entry = NULL; - } - - free(unic_ppp_data); -+ unic_ppp_data = NULL; - } - - static void hikp_unic_ppp_cmd_execute(struct major_cmd_ctrl *self) -diff --git a/ossl/ossl_user_linux.c b/ossl/ossl_user_linux.c -index 8266a19..9dee61c 100644 ---- a/ossl/ossl_user_linux.c -+++ b/ossl/ossl_user_linux.c -@@ -47,7 +47,6 @@ int uda_realpath(const char *file_dir, char *format_dir) - - int uda_fcntl(const char *lock_file, uint32_t operation, int *fd) - { -- uint32_t f_opt = 0; - int fd_t = 0; - int ret; - -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.c b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -index 9697529..66226e0 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.c -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -@@ -213,7 +213,7 @@ static int pcie_print_ltssm_trace(const uint64_t *ltssm_input, uint32_t ltssm_nu - (uint32_t)ltssm_val.bits.any_change_pipe_req, - (uint32_t)ltssm_val.bits.rxl0s_st, - (uint32_t)ltssm_val.bits.train_bit_map1, -- (((uint32_t)ltssm_val.bits.rxl0s_st) << 2) | -+ (((uint32_t)ltssm_val.bits.rxl0s_st) << GEN5_BIT_OFFEST) | - ((uint32_t)ltssm_val.bits.mac_rate), - (uint32_t)ltssm_val.bits.duration_counter, - (uint32_t)ltssm_val.bits.ltssm_state, -@@ -271,7 +271,6 @@ int pcie_ltssm_trace_clear(uint32_t port_id) - - int pcie_ltssm_link_status_get(uint32_t port_id) - { -- uint32_t i; - union pcie_link_info reg_val; - struct hikp_cmd_header req_header; - struct hikp_cmd_ret *cmd_ret; -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.h b/pcie/func_lib/pcie_func/pcie_link_ltssm.h -index 8f3502b..cc51501 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.h -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.h -@@ -19,6 +19,7 @@ - #define TRACE_STR_NUM 0x20 - #define TRACER_DEPTH 65 - #define PM_TRACE_STR_NUM 0x28 -+#define GEN5_BIT_OFFEST 2 - - struct pcie_ltssm_num_string { - int ltssm; -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index aac3843..b8c2241 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -405,7 +405,7 @@ static int pcie_create_dumpreg_log_file(uint32_t port_id, uint32_t dump_level) - - (void)remove((const char *)file_name); - /* Add write permission to the file */ -- fd_file = open(file_name, O_RDWR | O_SYNC | O_CREAT, 0640); -+ fd_file = open(file_name, O_RDWR | O_SYNC | O_CREAT, 0600); - if (fd_file < 0) { - Err("PCIe DUMPREG", "open %s failed.\n", file_name); - return -EPERM; -@@ -419,7 +419,7 @@ static int pcie_close_dumpreg_log_file(void) - { - int ret; - -- ret = fchmod(g_pcie_dumpreg_fd, 0440); -+ ret = fchmod(g_pcie_dumpreg_fd, 0400); - close(g_pcie_dumpreg_fd); - /* Revoke write permission of file */ - g_pcie_dumpreg_fd = -1; -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c -index 40e5645..ed42cec 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.c -+++ b/pcie/func_lib/pcie_func/pcie_statistics.c -@@ -63,7 +63,7 @@ static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, - } - - static int pcie_portid_serdes_relation(const struct pcie_macro_info *macro_info, -- uint32_t macro_num, uint32_t ndie_id) -+ uint32_t macro_num, uint32_t ndie_id) - { - uint32_t i, j; - -@@ -90,7 +90,7 @@ int pcie_port_distribution_get(uint32_t chip_id) - struct hikp_cmd_header req_header; - struct hikp_cmd_ret *cmd_ret; - struct pcie_info_req_para req_data = { 0 }; -- uint32_t src_size, dst_size, pair_num; -+ uint32_t pair_num; - struct pcie_port_info *port_info; - uint32_t i; - int ret; -diff --git a/sas/sas_func/sas_read_dev.c b/sas/sas_func/sas_read_dev.c -index 3a3db07..670e2d4 100644 ---- a/sas/sas_func/sas_read_dev.c -+++ b/sas/sas_func/sas_read_dev.c -@@ -78,8 +78,6 @@ static void print_dev_link(const uint32_t *reg_save, uint32_t reg_num) - - static void sas_print_dev(const uint32_t *reg_save, uint32_t reg_num, uint32_t cmd_type) - { -- uint32_t i; -- - if (reg_num == 0) { - printf("SAS device is failed\n"); - return; -diff --git a/sas/sas_func/sas_read_dqe.c b/sas/sas_func/sas_read_dqe.c -index dbd30f3..7d49c0a 100644 ---- a/sas/sas_func/sas_read_dqe.c -+++ b/sas/sas_func/sas_read_dqe.c -@@ -57,7 +57,7 @@ static void print_dqe_info(const void *reg_save, uint32_t reg_num) - printf("TLR_Ctrl: %u\n", dqe->dw0.TLR_Ctrl); - printf("Phy_ID: %u\n", dqe->dw0.Phy_ID); - printf("Force_Phy: %u\n", dqe->dw0.Force_Phy); -- printf("PORT: 0x%llx\n", dqe->dw0.PORT); -+ printf("PORT: 0x%x\n", dqe->dw0.PORT); - printf("PRI: %u\n", dqe->dw0.PRI); - printf("CMD: %u\n", dqe->dw0.CMD); - -@@ -68,7 +68,7 @@ static void print_dqe_info(const void *reg_save, uint32_t reg_num) - printf("Reset: %u\n", dqe->dw1.Reset); - printf("PIR_Present: %u\n", dqe->dw1.PIR_Present); - printf("Enable_Transport_Layer_Retry: %u\n", dqe->dw1.Enable_Transport_Layer_Retry); -- printf("Verify_Data_Transfer_Length: 0x%llx\n", dqe->dw1.Verify_Data_Transfer_Length); -+ printf("Verify_Data_Transfer_Length: 0x%x\n", dqe->dw1.Verify_Data_Transfer_Length); - printf("Frame_Type: %u\n", dqe->dw1.Frame_Type); - printf("Device_ID: %u\n", dqe->dw1.Device_ID); - -diff --git a/sas/user_cmd/cmd_code/sas_cmd_dqe.c b/sas/user_cmd/cmd_code/sas_cmd_dqe.c -index 4a9547a..26bf0eb 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_dqe.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_dqe.c -@@ -44,7 +44,6 @@ static int sas_dqe_info(struct major_cmd_ctrl *self, const char *argv) - static int sas_set_queue_id(struct major_cmd_ctrl *self, const char *argv) - { - int ret; -- uint32_t val = 0; - - ret = sas_set_que_id(self, argv); - if (ret || sas_get_que_id() >= SAS_QUEUE_NUM) { -diff --git a/sas/user_cmd/cmd_code/sas_cmd_dump.c b/sas/user_cmd/cmd_code/sas_cmd_dump.c -index 4f2cfea..e7dedf0 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_dump.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_dump.c -@@ -42,7 +42,6 @@ static int sas_dump_global(struct major_cmd_ctrl *self, const char *argv) - static int sas_dump_phyx(struct major_cmd_ctrl *self, char const *argv) - { - int ret; -- uint32_t val = 0; - - (void)sas_set_cmd_type(DUMP_PHYX); - ret = sas_set_phy_id(self, argv); -diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c -index 320ded2..4afcb9b 100644 ---- a/serdes/hikp_serdes.c -+++ b/serdes/hikp_serdes.c -@@ -322,7 +322,7 @@ static void hikp_serdes_info_cmd_execute(struct major_cmd_ctrl *self) - SERDES_OUTPUT_MAX_SIZE) { - self->err_no = -EINVAL; - snprintf(self->err_str, sizeof(self->err_str), -- "serdes_info rsp_data data copy size error, data size:0x%x max size:0x%x.", -+ "serdes_info rsp_data data copy size error, data size:0x%zx max size:0x%x.", - (cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size), - SERDES_OUTPUT_MAX_SIZE); - goto err_out; -@@ -480,7 +480,7 @@ static void hikp_serdes_dump_cmd_execute(struct major_cmd_ctrl *self) - SERDES_OUTPUT_MAX_SIZE) { - self->err_no = -EINVAL; - snprintf(self->err_str, sizeof(self->err_str), -- "serdes_dump rsp_data data copy size error, data size:0x%x max size:0x%x.", -+ "serdes_dump rsp_data data copy size error, data size:0x%zx max size:0x%x.", - (cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size), - SERDES_OUTPUT_MAX_SIZE); - goto err_out; -diff --git a/socip/hikp_socip_dumpreg.c b/socip/hikp_socip_dumpreg.c -index 0153dd9..7b11523 100644 ---- a/socip/hikp_socip_dumpreg.c -+++ b/socip/hikp_socip_dumpreg.c -@@ -108,7 +108,6 @@ static bool check_socip_dumpreg_param(void) - static void dump_reg_info(const uint32_t *reg_data, uint32_t data_num) - { - #define ONE_LINE_PRINT_DATA_NUM 4 -- struct dump_reg_param_t *param = &g_dump_reg_param[0]; - uint32_t i; - - for (i = 0; i < data_num; i++) { -diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c -index d91ddb0..f57f5fd 100644 ---- a/tool_lib/op_logs.c -+++ b/tool_lib/op_logs.c -@@ -29,7 +29,6 @@ static void op_log_write(const char *log_data) - { - size_t w_size; - FILE *fd; -- int ret; - - if (strlen(g_op_log) == 0) - return; -@@ -108,8 +107,6 @@ static int op_log_add_time_to_log(char *log_base, int *offset, uint32_t flag) - struct timeval tv; - struct tm ptm; - int len = 0; -- long usec; -- long sec; - int ret; - - (void)gettimeofday(&tv, NULL); -@@ -118,12 +115,18 @@ static int op_log_add_time_to_log(char *log_base, int *offset, uint32_t flag) - g_tv = tv; - len = (int)strftime(log_base + *offset, (OP_LOG_FILE_W_MAXSIZE + 1 - *offset), - OP_LOG_TIME_TEMP, &ptm); -+ if ((*offset + len) >= (OP_LOG_FILE_W_MAXSIZE + 1)) -+ return -ENOMEM; -+ - ret = snprintf(log_base + *offset + len, - (OP_LOG_FILE_W_MAXSIZE + 1 - *offset - len), OP_LOG_SEC_TIME_TEMP, - tv.tv_sec + tv.tv_usec / OP_LOG_SEC_AND_MICROSEC_TRANS); -- } else if (flag == LOG_FLAG_ONLY_TIME) { -+ } else { - len = (int)strftime(log_base + *offset, (OP_LOG_FILE_W_MAXSIZE + 1 - *offset), - OP_LOG_RESULT_TIME_TEMP, &ptm); -+ if ((*offset + len) >= (OP_LOG_FILE_W_MAXSIZE + 1)) -+ return -ENOMEM; -+ - ret = snprintf(log_base + *offset + len, - (OP_LOG_FILE_W_MAXSIZE + 1 - *offset - len), - OP_LOG_SEC_TIME_TEMP, -@@ -157,7 +160,6 @@ static int op_log_file_rollback(const char *op_log_backup, const char *log_dir) - char rollback_log[OP_LOG_FILE_W_MAXSIZE + 1] = {0}; - int offset = 0; - int ret; -- int len; - - ret = file_rollback(g_op_log, op_log_backup, OP_LOG_FILE_MAX_SIZE); - if (ret) { -@@ -280,10 +282,14 @@ void op_log_record_input(const int argc, const char **argv) - - arg = input_str; - for (i = 0; i < argc; i++) { -- snprintf(arg, (sizeof(input_str) - (arg - input_str)), "%s ", argv[i]); -+ ret = snprintf(arg, (sizeof(input_str) - (arg - input_str)), "%s ", argv[i]); -+ if (ret < 0 || ret >= (sizeof(input_str) - (arg - input_str))) -+ return; -+ - arg = arg + strlen(argv[i]) + 1; - } - input_str[strlen(input_str) - 1] = 0; -+ - arr_size = HIKP_ARRAY_SIZE(log_info); - for (i = 0; i < arr_size; i++) { - ret = snprintf(g_input_buf + offset, (OP_LOG_FILE_W_MAXSIZE + 1 - offset), -diff --git a/tool_lib/tool_cmd.c b/tool_lib/tool_cmd.c -index 43a3b61..db54f0f 100644 ---- a/tool_lib/tool_cmd.c -+++ b/tool_lib/tool_cmd.c -@@ -186,7 +186,6 @@ void command_parse_and_excute(const int argc, const char **argv) - { - struct major_cmd_ctrl *major_cmd = get_major_cmd(); - int lock_fd; -- int check; - int ret; - - major_cmd->err_no = check_command_length(argc, argv); -diff --git a/tool_lib/tool_lib.c b/tool_lib/tool_lib.c -index ad4bb68..180418f 100644 ---- a/tool_lib/tool_lib.c -+++ b/tool_lib/tool_lib.c -@@ -337,6 +337,9 @@ bool tool_can_print(uint32_t interval, uint32_t burst, uint32_t *print_num, uint - { - uint64_t cur_time; - -+ if (!print_num || !last_time) -+ return false; -+ - cur_time = (uint64_t)time(NULL); - if ((*last_time + interval) == cur_time) - *print_num = 0; --- -2.42.0.windows.2 - diff --git a/0053-hikptool-roce-Fix-the-infinite-loop-due-to-compatibi.patch b/0053-hikptool-roce-Fix-the-infinite-loop-due-to-compatibi.patch deleted file mode 100644 index 27662ab0cbdc64d68e5992d9acae0cc102cde1d6..0000000000000000000000000000000000000000 --- a/0053-hikptool-roce-Fix-the-infinite-loop-due-to-compatibi.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 15e5379c7a1e041d8ea384f55c6cf77698646ac7 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Tue, 7 Nov 2023 15:59:27 +0800 -Subject: hikptool/roce: Fix the infinite loop due to compatibility issue - -When a new-version hikptool sends a subcmd of caep ext registers to -an old-version FW which doesn't support the query of ext registers -yet, due to the lack of subcmd check in old-version FW, there will -be no error and register data will still be responsed to hikptool. - -In the new-version hikptool, a do-while loop is used to implement a -multi-round query, and the loop variable is updated based on the -cur_block_num responsed from FW. Since there is no error reported, -the new-version hikptool will parse the old-version data based on the -new-version data structure. This may cause the parsed cur_block_num -remains 0, and the loop becomes infinite. - -To fix this problem, add a check of the responsed cur_block_num. -If it's 0, return with an error code. - -Fixes: 8b3b68347165 ("hikptool/roce: Add a common frame for hikptool roce register query") -Signed-off-by: Junxian Huang ---- - net/roce/roce_ext_common/hikp_roce_ext_common.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -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 3a0c1ae..5bc3ce6 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -131,7 +131,7 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - } - - cur_size = res_head->cur_block_num * sizeof(uint32_t); -- if (cur_size > max_size) { -+ if (!cur_size || cur_size > max_size) { - printf("hikptool roce_%s log data copy size error, data size: 0x%zx, max size: 0x%zx\n", - cmd_name, cur_size, max_size); - ret = -EINVAL; --- -2.30.0 - diff --git a/0054-hikptool-roh-fix-the-display-information-for-roh-mac.patch b/0054-hikptool-roh-fix-the-display-information-for-roh-mac.patch deleted file mode 100644 index 0aa10802632ad07294217c3e932503fb8a7b8caf..0000000000000000000000000000000000000000 --- a/0054-hikptool-roh-fix-the-display-information-for-roh-mac.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 93c9cd4501edc9fc487af78ea4fd4c0f37bc4dc1 Mon Sep 17 00:00:00 2001 -From: Ke Chen -Date: Fri, 15 Dec 2023 10:20:53 +0800 -Subject: [PATCH] hikptool/roh: fix the display information for roh mac mib - statistics - -Add a prompt head information "ROH MAC MIB INFO" - -Fixes: 99d48570419c ("support querying the RoH module information") -Signed-off-by: Ke Chen ---- - net/roh/hikp_roh_show_mib.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/net/roh/hikp_roh_show_mib.c b/net/roh/hikp_roh_show_mib.c -index 425a0e6..7267fe5 100644 ---- a/net/roh/hikp_roh_show_mib.c -+++ b/net/roh/hikp_roh_show_mib.c -@@ -232,6 +232,7 @@ static void hikp_roh_show_mib_in_multi_rounds(struct major_cmd_ctrl *self) - return; - } - -+ printf("**************ROH MAC MIB INFO*************\n"); - for (int i = 0; i < total_round; i++) { - ret = hikp_roh_fill_pmu_cnt(i); - if (ret != 0) { -@@ -239,6 +240,7 @@ static void hikp_roh_show_mib_in_multi_rounds(struct major_cmd_ctrl *self) - return; - } - } -+ printf("*****************************************\n"); - } - - static void hikp_roh_show_mib_execute(struct major_cmd_ctrl *self) --- -2.30.0 - diff --git a/0055-hikptool-augument-serdes-relationship-of-the-PCIe.patch b/0055-hikptool-augument-serdes-relationship-of-the-PCIe.patch deleted file mode 100644 index 5e8fe6a6c462e75172dc09195c614fd8ef65bb94..0000000000000000000000000000000000000000 --- a/0055-hikptool-augument-serdes-relationship-of-the-PCIe.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 51382f799643371ecfbe2e311923e9ebfac436ea Mon Sep 17 00:00:00 2001 -From: moubingquan -Date: Tue, 19 Dec 2023 11:09:35 +0800 -Subject: [PATCH] hikptool : augument serdes relationship of the PCIe - -The Ndie infomation is missing when different chips are adapted. -Add two Ndie to ensure that die information is properly printed. - -Fixes: 1d2a0bb9cddc ("hikptool : Querying the SerDes Relationship of the PCIe") -Signed-off-by: moubingquan ---- - pcie/func_lib/pcie_func/pcie_statistics.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c -index 5dff720..d2661a4 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.c -+++ b/pcie/func_lib/pcie_func/pcie_statistics.c -@@ -26,7 +26,7 @@ static const char *g_global_width_name[GLOBAL_WIDTH_TABLE_SIZE] = { - }; - - static const char *g_global_ndie_name[] = { -- "Ndie_A", "Ndie_B" -+ "Ndie_A", "Ndie_B", "Ndie_C", "Ndie_D" - }; - - static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, uint32_t *port_num) --- -2.33.0 - diff --git a/0056-hikptool-Supported-parsing-the-optical-module-that-u.patch b/0056-hikptool-Supported-parsing-the-optical-module-that-u.patch deleted file mode 100644 index 5394d90ba3743d13a1729143309d48a086186c4d..0000000000000000000000000000000000000000 --- a/0056-hikptool-Supported-parsing-the-optical-module-that-u.patch +++ /dev/null @@ -1,484 +0,0 @@ -From 32a3a456b701d9b82742bba5371d8d828c6fe309 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 4 Jan 2024 14:54:29 +0800 -Subject: [PATCH] hikptool: Supported parsing the optical module that use the - CMIS protocol - -Added support dump and parse optical modules -whose Identifier Values are 0x18, 0x1A, 0x1E, 0x1F, and 0x20. - -Signed-off-by: veega2022 ---- - net/nic/nic_mac/hikp_nic_xsfp.c | 250 ++++++++++++++++++++++++++++++++ - net/nic/nic_mac/hikp_nic_xsfp.h | 159 ++++++++++++++++++++ - 2 files changed, 409 insertions(+) - -diff --git a/net/nic/nic_mac/hikp_nic_xsfp.c b/net/nic/nic_mac/hikp_nic_xsfp.c -index d97a506..70ed589 100644 ---- a/net/nic/nic_mac/hikp_nic_xsfp.c -+++ b/net/nic/nic_mac/hikp_nic_xsfp.c -@@ -55,6 +55,108 @@ static struct sff_ext_comp g_sff_ext_spec_comp[] = { - {0x4A, "50GBASE-ER"}, - }; - -+static struct sff_host_media_id g_sff_host_ids[] = { -+ {0x0, "Undefined", 0x0, "Undefined"}, -+ {0x1, "1000BASE-CX", 0x1, "NRZ"}, -+ {0xC, "100GAUI-4 C2M", 0x4, "NRZ"}, -+ {0xD, "100GAUI-2 C2M", 0x2, "PAM4"}, -+ {0x4B, "100GAUI-1-S C2M", 0x1, "PAM4"}, -+ {0x4C, "100GAUI-1-L C2M", 0x1, "PAM4"}, -+ {0xE, "200GAUI-8 C2M", 0x8, "NRZ"}, -+ {0xF, "200GAUI-4 C2M", 0x4, "PAM4"}, -+ {0x4D, "200GAUI-2-S C2M", 0x2, "PAM4"}, -+ {0x4E, "200GAUI-2-L C2M", 0x2, "PAM4"}, -+ {0x11, "400GAUI-8 C2M", 0x8, "PAM4"}, -+ {0x4F, "400GAUI-4-S C2M", 0x4, "PAM4"}, -+ {0x50, "400GAUI-4-L C2M", 0x4, "PAM4"}, -+ {0x13, "10GBASE-CX4", 0x4, "NRZ"}, -+ {0x14, "25GBASE-CR CA-25G-L", 0x1, "NRZ"}, -+ {0x15, "25GBASE-CR or 25GBASE-CR-SCA-25G-S", 0x1, "NRZ"}, -+ {0x16, "25GBASE-CR or 25GBASE-CR-SCA-25G-N", 0x1, "NRZ"}, -+ {0x17, "40GBASE-CR4", 0x4, "NRZ"}, -+ {0x43, "50GBASE-CR2 with RS(528,514)FEC", 0x2, "NRZ"}, -+ {0x44, "50GBASE-CR2 with BASE-R, Fire code FEC", 0x2, "NRZ"}, -+ {0x45, "50GBASE-CR2 with no FEC", 0x2, "NRZ"}, -+ {0x18, "50GBASE-CR", 0x1, "PAM4"}, -+ {0x1A, "100GBASE-CR4", 0x4, "NRZ"}, -+ {0x1B, "100GBASE-CR2", 0x2, "PAM4"}, -+ {0x46, "100GBASE-CR1", 0x1, "PAM4"}, -+ {0x1C, "200GBASE-CR4", 0x4, "PAM4"}, -+ {0x47, "200GBASE-CR2", 0x2, "PAM4"}, -+ {0x1D, "400G CR8", 0x8, "PAM4"}, -+ {0x48, "400GBASE-CR4", 0x4, "PAM4"}, -+}; -+ -+static struct sff_host_media_id g_mmf_media_ids[] = { -+ {0x0, "Undefined", 0x0, "Undefined"}, -+ {0x2, "10GBASE-SR", 0x1, "NRZ"}, -+ {0x3, "25GBASE-SR", 0x1, "NRZ"}, -+ {0x4, "40GBASE-SR4", 0x4, "NRZ"}, -+ {0x5, "40GE SWDM4 MSA", 0x4, "NRZ"}, -+ {0x7, "50GBASE-SR", 0x1, "PAM4"}, -+ {0x9, "100GBASE-SR4", 0x4, "NRZ"}, -+ {0xA, "100GE SWDM4 MSA", 0x4, "NRZ"}, -+ {0xC, "100GBASE-SR2", 0x2, "PAM4"}, -+ {0xD, "100GBASE-SR1", 0x1, "PAM4"}, -+ {0x1D, "100GBASE-VR1", 0x1, "PAM4"}, -+ {0xE, "200GBASE-SR4", 0x4, "PAM4"}, -+ {0x1B, "200GBASE-SR2", 0x2, "PAM4"}, -+ {0x1E, "200GBASE-VR2", 0x2, "PAM4"}, -+ {0x10, "400GBASE-SR8", 0x8, "PAM4"}, -+ {0x11, "400GBASE-SR4", 0x4, "PAM4"}, -+ {0x1F, "400GBASE-VR4", 0x4, "PAM4"}, -+}; -+ -+static struct sff_host_media_id g_smf_media_ids[] = { -+ {0x0, "Undefined", 0x0, "Undefined"}, -+ {0x4, "10GBASE-LR", 0x1, "NRZ"}, -+ {0x5, "10GBASE-ER", 0x1, "NRZ"}, -+ {0x4E, "10GBASE-BR", 0x1, "NRZ"}, -+ {0x6, "10G-ZR", 0x1, "NRZ"}, -+ {0x7, "25GBASE-LR", 0x1, "NRZ"}, -+ {0x8, "25GBASE-ER", 0x1, "NRZ"}, -+ {0x4F, "25GBASE-BR", 0x1, "NRZ"}, -+ {0x9, "40GBASE-LR4", 0x4, "NRZ"}, -+ {0xB, "50GBASE-FR", 0x1, "PAM4"}, -+ {0xC, "50GBASE-LR", 0x1, "PAM4"}, -+ {0x40, "50GBASE-ER", 0x1, "PAM4"}, -+ {0x50, "50GBASE-BR", 0x1, "PAM4"}, -+ {0xD, "100GBASE-LR4", 0x4, "NRZ"}, -+ {0xE, "100GBASE-ER4", 0x4, "NRZ"}, -+ {0xF, "100G PSM4 MSA", 0x4, "NRZ"}, -+ {0x34, "100G CWDM4-OCP", 0x4, "NRZ"}, -+ {0x10, "100G CWDM4 MSA", 0x4, "NRZ"}, -+ {0x11, "100G 4WDM-10 MSA", 0x4, "NRZ"}, -+ {0x12, "100G 4WDM-20 MSA", 0x4, "NRZ"}, -+ {0x13, "100G 4WDM-40 MSA", 0x4, "NRZ"}, -+ {0x14, "100GBASE-DR", 0x1, "PAM4"}, -+ {0x17, "200GBASE-DR4", 0x4, "PAM4"}, -+ {0x18, "200GBASE-FR4", 0x4, "PAM4"}, -+ {0x19, "200GBASE-LR4", 0x4, "PAM4"}, -+ {0x41, "200GBASE-ER4", 0x4, "PAM4"}, -+ {0x1A, "400GBASE-FR8", 0x8, "PAM4"}, -+ {0x1B, "400GBASE-LR8", 0x8, "PAM4"}, -+ {0x42, "400GBASE-ER8", 0x8, "PAM4"}, -+ {0x1C, "400GBASE-DR4", 0x4, "PAM4"}, -+ {0x55, "400GBASE-DR4-2", 0x4, "PAM4"}, -+ {0x43, "400GBASE-LR4-6", 0x4, "PAM4"}, -+}; -+ -+static struct sff_media_cable_id g_passive_cable_ids[] = { -+ {0x0, "Undefined"}, -+ {0x1, "Copper cable"}, -+ {0xBF, "Passive Loopback module"}, -+}; -+ -+static struct sff_media_cable_id g_active_cable_ids[] = { -+ {0x0, "Undefined"}, -+ {0x1, "Active Cable assembly"}, -+ {0x2, "Active Cable assembly"}, -+ {0x3, "Active Cable assembly"}, -+ {0x4, "Active Cable assembly"}, -+ {0xBF, "Active Loopback module"}, -+}; -+ - static int hikp_xsfp_get_cmd_data(struct hikp_cmd_ret **cmd_resp, uint32_t sub_cmd, uint32_t blk_id) - { - struct hikp_xsfp_req req = {0}; -@@ -320,6 +422,148 @@ static void hikp_show_qsfp_info(const uint8_t *data, uint32_t size) - printf("--------------------------------------------------------------\n"); - } - -+static void cmis_print_media_optical(const struct cmis_app_desc *desc, -+ struct sff_host_media_id *ids, size_t len) -+{ -+ for (uint8_t i = 0; i < len; i++) { -+ if (desc->media_id == ids[i].id) { -+ printf("%s(%s)\n", ids[i].int_spec, ids[i].modulation); -+ return; -+ } -+ } -+ printf("0x%x\n", desc->media_id); -+} -+ -+static void cmis_print_media_cable(const struct cmis_app_desc *desc, -+ struct sff_media_cable_id *ids, size_t len) -+{ -+ for (uint8_t i = 0; i < len; i++) { -+ if (desc->media_id == ids[i].id) { -+ printf("%s\n", ids[i].app_name); -+ return; -+ } -+ } -+ printf("0x%x\n", desc->media_id); -+} -+ -+static void cmis_print_host_int_spec(const struct cmis_app_desc *desc) -+{ -+ size_t size = HIKP_ARRAY_SIZE(g_sff_host_ids); -+ -+ for (uint8_t i = 0; i < size; i++) { -+ if (desc->host_id == g_sff_host_ids[i].id) { -+ printf("%s(%s) | ", -+ g_sff_host_ids[i].int_spec, g_sff_host_ids[i].modulation); -+ return; -+ } -+ } -+ -+ printf("0x%x | ", desc->host_id); -+} -+ -+static void cmis_print_host_and_media_int(const struct cmis_page_info *info, uint8_t app_id) -+{ -+ const struct cmis_app_desc *desc = &info->page0_lower.apps[app_id]; -+ uint8_t media_type = info->page0_lower.media_type; -+ -+ printf("%s %-9u: %s", "app_descriptor", app_id, "host and media int: "); -+ cmis_print_host_int_spec(desc); -+ -+ switch (media_type) { -+ case OPT_MMF: -+ cmis_print_media_optical(desc, g_mmf_media_ids, HIKP_ARRAY_SIZE(g_mmf_media_ids)); -+ break; -+ case OPT_SMF: -+ cmis_print_media_optical(desc, g_smf_media_ids, HIKP_ARRAY_SIZE(g_smf_media_ids)); -+ break; -+ case PASSIVE_COPPER: -+ cmis_print_media_cable(desc, g_passive_cable_ids, -+ HIKP_ARRAY_SIZE(g_passive_cable_ids)); -+ break; -+ case ACTIVE_CABLE: -+ cmis_print_media_cable(desc, g_active_cable_ids, -+ HIKP_ARRAY_SIZE(g_active_cable_ids)); -+ break; -+ default: -+ printf("0x%x\n", desc->media_id); -+ break; -+ } -+} -+ -+static void cmis_print_application_desc(const struct cmis_page_info *info) -+{ -+ for (uint8_t i = 0; i < CMIS_LOW_MEM_APP_DESC_NUM; i++) { -+ /* Undefined or unused, not print */ -+ if ((info->page0_lower.apps[i].host_id == 0xFF) || -+ (!info->page0_lower.apps[i].host_id && !info->page0_lower.apps[i].media_id)) -+ continue; -+ -+ cmis_print_host_and_media_int(info, i); -+ } -+} -+ -+static void cmis_print_base_id_info(const struct cmis_page_info *info) -+{ -+ /* page00h reg 202: bit6-7 */ -+ float cab_len_mul[] = {0.1f, 1.0f, 10.0f, 100.0f}; -+ /* page01h reg 132: bit6-7 */ -+ float smf_len_mul[] = {0.1f, 1.0f, 10.0f, 1.0f}; -+ const char *type[MEDIA_TYPE_RSVD] = { -+ "Undefined", "MMF Optical Interfaces", "SMF Optical Interfaces", -+ "Passive Copper Cables", "Active Cables", "BASE-T" -+ }; -+ -+ printf("%-24s: 0x%02x\n", "identifier", info->page0_lower.identifier); -+ printf("%-24s: 0x%02x\n", "connector", info->page0_upper.connector_type); -+ -+ if (info->page0_lower.media_type >= MEDIA_TYPE_RSVD) -+ printf("%-24s: 0x%02x\n", "media_type", info->page0_lower.media_type); -+ else -+ printf("%-24s: %s\n", "media_type", type[info->page0_lower.media_type]); -+ -+ printf("%-24s: %0.2f (m)\n", "cable_len", (float)info->page0_upper.cab_base_len * -+ cab_len_mul[info->page0_upper.len_multiplier]); -+ printf("%-24s: %0.2f (km)\n", "smf_len_km", -+ (float)info->page1.smf_len * smf_len_mul[info->page1.smf_len_multip]); -+ printf("%-24s: %u (m)\n", "om5_len", info->page1.om5_len * 0x2); -+ printf("%-24s: %u (m)\n", "om4_len", info->page1.om4_len * 0x2); -+ printf("%-24s: %u (m)\n", "om3_len", info->page1.om3_len * 0x2); -+ printf("%-24s: %u (m)\n", "om2_len", info->page1.om2_len); -+ printf("%-24s: %u (nm)\n", "wavelength", -+ (((uint16_t)info->page1.nominal_wave_len[0] << 8U) | -+ (uint16_t)info->page1.nominal_wave_len[1]) / CMIS_WAVE_LEN_DIV); -+ printf("%-24s: %u (nm)\n", "wavelength_tolerance", -+ (((uint16_t)info->page1.wave_len_tolerance[0] << 8U) | -+ (uint16_t)info->page1.wave_len_tolerance[1]) / CMIS_TOL_WAVE_LEN_DIV); -+ printf("%-24s: 0x%02x\n", "media_technology", info->page0_upper.media_int_tech); -+ xsfp_print_data("vendor_name", VEND_NAME_LEN, info->page0_upper.vend_name, PRINT_ASCII); -+ xsfp_print_data("vendor_oui", VEND_OUI_LEN, info->page0_upper.vend_oui, PRINT_HEX); -+ xsfp_print_data("vendor_pn", VEND_PN_LEN, info->page0_upper.vend_pn, PRINT_ASCII); -+ xsfp_print_data("vendor_rev", CMIS_VEND_REV_LEN, info->page0_upper.vend_rev, PRINT_ASCII); -+ xsfp_print_data("vendor_sn", VEND_SN_LEN, info->page0_upper.vend_sn, PRINT_ASCII); -+ xsfp_print_data("vendor_date_code", VEND_DATE_CODE_LEN, -+ info->page0_upper.date_code, PRINT_ASCII); -+ -+ cmis_print_application_desc(info); -+} -+ -+static void cmis_print_dom_info(const struct cmis_page_info *info) -+{ -+ if (!info->page0_lower.mem_model && info->page1.temp_mon_supp) -+ printf("%-24s: %d.%02u\n", "temperature", (int8_t)info->page0_lower.module_temp[0], -+ info->page0_lower.module_temp[1]); -+} -+ -+static void hikp_show_cmis_info(const uint8_t *data, uint32_t size) -+{ -+ struct cmis_page_info *cmis_data = (struct cmis_page_info *)data; -+ -+ printf("------------------------show cmis info------------------------\n"); -+ cmis_print_base_id_info(cmis_data); -+ cmis_print_dom_info(cmis_data); -+ printf("--------------------------------------------------------------\n"); -+} -+ - static void hikp_xsfp_parse_info(const uint8_t *data, uint32_t size) - { - if (data[SFF_ID_OFFSET] == ID_SFP) { -@@ -328,6 +572,12 @@ static void hikp_xsfp_parse_info(const uint8_t *data, uint32_t size) - data[SFF_ID_OFFSET] == ID_QSFP_PLUS || - data[SFF_ID_OFFSET] == ID_QSFP28) { - hikp_show_qsfp_info(data, size); -+ } else if (data[SFF_ID_OFFSET] == ID_QSFP_DD || -+ data[SFF_ID_OFFSET] == ID_SFP_DD || -+ data[SFF_ID_OFFSET] == ID_QSFP_P_CMIS || -+ data[SFF_ID_OFFSET] == ID_SFP_DD_CMIS || -+ data[SFF_ID_OFFSET] == ID_SFP_P_CMIS) { -+ hikp_show_cmis_info(data, size); - } else { - /* unknown type just dump hex data */ - hikp_xsfp_dump_hex(data, size); -diff --git a/net/nic/nic_mac/hikp_nic_xsfp.h b/net/nic/nic_mac/hikp_nic_xsfp.h -index a378197..6f5e38f 100644 ---- a/net/nic/nic_mac/hikp_nic_xsfp.h -+++ b/net/nic/nic_mac/hikp_nic_xsfp.h -@@ -75,6 +75,11 @@ - #define QSFP_10GBASE_LR_MASK HI_BIT(5) - #define QSFP_10GBASE_LRM_MASK HI_BIT(6) - -+#define CMIS_WAVE_LEN_DIV 20 -+#define CMIS_TOL_WAVE_LEN_DIV 200 -+ -+#define CMIS_VEND_REV_LEN 2 -+ - enum print_type { - PRINT_ASCII = 0, - PRINT_HEX, -@@ -87,6 +92,11 @@ enum sff_id_val { - ID_QSFP = 0x0C, - ID_QSFP_PLUS = 0x0D, - ID_QSFP28 = 0x11, -+ ID_QSFP_DD = 0x18, -+ ID_SFP_DD = 0x1A, -+ ID_QSFP_P_CMIS = 0x1E, -+ ID_SFP_DD_CMIS = 0x1F, -+ ID_SFP_P_CMIS = 0x20, - }; - - struct sff_comp_info { -@@ -99,6 +109,18 @@ struct sff_ext_comp { - const char *module_cap; - }; - -+struct sff_host_media_id { -+ uint8_t id; -+ const char *int_spec; -+ uint8_t lane_cnt; -+ const char *modulation; -+}; -+ -+struct sff_media_cable_id { -+ uint8_t id; -+ const char *app_name; -+}; -+ - struct sfp_a0_page { - uint8_t identifier; /* reg 0: Identifier */ - uint8_t ext_identifier; /* reg 1: Ext. Identifier */ -@@ -358,6 +380,143 @@ struct qsfp_page0_info { - struct qsfp_page0_upper page_upper; - }; - -+enum cmis_media_type { -+ UNDEFINED = 0, -+ OPT_MMF, -+ OPT_SMF, -+ PASSIVE_COPPER, -+ ACTIVE_CABLE, -+ BASE_T, -+ MEDIA_TYPE_RSVD, -+}; -+ -+#define CMIS_LOW_MEM_APP_DESC_NUM 8 -+struct cmis_app_desc { -+ uint8_t host_id; /* host electrical interface id */ -+ uint8_t media_id; /* module media electrical interface id */ -+ uint8_t media_lane_cnt : 4, -+ host_lane_cnt : 4; /* host and media lane counts */ -+ uint8_t host_assign; /* Host Lane Assignment Options */ -+}; -+ -+struct cmis_page0_lower { -+ uint8_t identifier; /* reg 0: Identifier */ -+ uint8_t rev_compliance; /* reg 1: CMIS revision */ -+ /* reg 2: Module Management Characteristics */ -+ uint8_t rsv0 : 2, -+ mci_max_speed : 2, -+ rsv1 : 2, -+ step_cfg_only : 1, -+ mem_model : 1; -+ /* reg 3: Global Status Information */ -+ uint8_t intr_deasserted : 1, -+ module_state : 3, -+ rsv2 : 4; -+ uint8_t flags_sum[4]; /* reg 4-7: Lane-Level Flags Summary */ -+ uint8_t module_flags[6]; /* reg 8-13: Module-Level Flags */ -+ uint8_t module_temp[2]; /* reg 14-15: TempMonValue */ -+ uint8_t module_vcc[2]; /* reg 16-17: VccMonVoltage */ -+ uint8_t module_mon_val[8]; /* reg 18-25: Module-Level Mon Value */ -+ /* reg 26: Module Global Controls */ -+ uint8_t rsv3 : 3, -+ sw_reset : 1, -+ lowpwr_req_sw : 1, -+ squ_method_sel : 1, -+ lowpwr_allow_req_hw : 1, -+ bank_bc_enable : 1; -+ uint8_t rsv4[14]; /* reg 27-40: */ -+ uint8_t module_fault; /* reg 41: Module Fault Information */ -+ uint8_t rsv5[22]; /* reg 42-63: Reserved */ -+ uint8_t custom[21]; /* reg 64-84: Custom */ -+ uint8_t media_type; /* reg 85: Media Type Encodings */ -+ /* reg 86-117: Application Descriptor */ -+ struct cmis_app_desc apps[CMIS_LOW_MEM_APP_DESC_NUM]; -+ uint8_t pwd_area[8]; /* reg 118-125: Password Facilities */ -+ uint8_t bank_sel; /* reg 126: Bank Index of Page mapped to Upper Memory */ -+ uint8_t page_sel; /* reg 127: Page Index of Page mapped to Upper Memory */ -+}; -+ -+struct cmis_page0_upper { -+ uint8_t identifier_cp; /* reg 128: The Same Byte 00h:0 */ -+ uint8_t vend_name[16]; /* reg 129-144: Vendor name (ASCII) */ -+ uint8_t vend_oui[3]; /* reg 145-147: Vendor IEEE company ID */ -+ uint8_t vend_pn[16]; /* reg 148-163: Part number provided by vendor (ASCII) */ -+ /* reg 164-165: Revision level for part number provided by vendor (ASCII) */ -+ uint8_t vend_rev[2]; -+ uint8_t vend_sn[16]; /* reg 166-181: Vendor Serial Number (ASCII) */ -+ uint8_t date_code[8]; /* reg 182-189: Manufacturing Date Code (ASCII) */ -+ /* reg 190-199: Common Language Equipment Identification Code (ASCII) */ -+ uint8_t clei_code[10]; -+ uint8_t module_pwr_class; /* reg 200: Module Power Class */ -+ /* reg 201: Maximum power consumption in multiples of 0.25 W -+ * rounded up to the next whole multiple of 0.25 W -+ */ -+ uint8_t max_power; -+ /* reg 202: Cable Assembly Link Length */ -+ uint8_t cab_base_len : 6, -+ len_multiplier : 2; -+ uint8_t connector_type; /* reg 203: Media Connector Type */ -+ uint8_t copp_attenuation[6]; /* reg 204-209: Copper Cable Attenuation */ -+ uint8_t media_lanes; /* reg 210: Media Lane Information */ -+ uint8_t cable_assembly_lane; /* reg 211: Cable Assembly Lane Information */ -+ uint8_t media_int_tech; /* reg 212: Media Interface Technology */ -+ uint8_t rsv0[8]; /* reg 213-220: Reserved */ -+ uint8_t rsv1; /* reg 221: Custom1 */ -+ uint8_t page_check_sum; /* reg 222: Page Checksum over bytes 128-221 */ -+ uint8_t rsv[33]; /* reg 223-255: Custom Info (non-volatile) */ -+}; -+ -+struct cmis_page1_info { -+ uint8_t inac_fw_hw_ver[4]; /* reg 128-131: Inactive FW revision and HW revision */ -+ uint8_t smf_len : 6, /* reg 132: Base link length for SMF fiber in km */ -+ smf_len_multip : 2; /* Link length multiplier for SMF fiber */ -+ uint8_t om5_len; /* reg 133: Link length supported for OM5 fiber */ -+ uint8_t om4_len; /* reg 134: Link length supported for OM4 fiber */ -+ uint8_t om3_len; /* reg 135: Link length supported for EBW 50/125 µm fiber (OM3) */ -+ uint8_t om2_len; /* reg 136: Link length supported for 50/125 µm fiber (OM2) */ -+ uint8_t rsv0; /* reg 137: Reserved */ -+ uint8_t nominal_wave_len[2]; /* reg 138-139: NominalWavelength */ -+ uint8_t wave_len_tolerance[2]; /* reg 140-141: WavelengthTolerance */ -+ uint8_t pages_support; /* reg 142: Supported Pages Advertising */ -+ uint8_t duration_adv[2]; /* reg 143-144: Durations Advertising */ -+ uint8_t module_char[10]; /* reg 145-154: Module Characteristics Advertising */ -+ uint8_t contrl_support[2]; /* reg 155-156: Supported Controls Advertisement */ -+ uint8_t flags_support[2]; /* reg 157-158: Supported Flags Advertisement */ -+ /* reg 159: Supported Mon Advertisement */ -+ uint8_t temp_mon_supp : 1, -+ vcc_mon_supp : 1, -+ aux1_mon_supp : 1, -+ aux2_mon_supp : 1, -+ aux3_mon_supp : 1, -+ custom_mon_supp : 1, -+ rsv1 : 2; -+ /* reg 160: Supported Power Mon Advertisement */ -+ uint8_t txbias_mon_supp : 1, -+ tx_pwr_mon_supp : 1, -+ rx_pwr_mon_supp : 1, -+ txbias_curr_scal : 2, -+ rsv2 : 3; -+ /* reg 161-162: Supported Configuration and Signal Integrity Controls Advertisement */ -+ uint8_t sig_intr_support[2]; -+ uint8_t cdb_func_support[4]; /* reg 163-166: CDB Messaging Support Advertisement */ -+ uint8_t add_dura_adv[3]; /* reg 167-169: Additional Durations Advertising */ -+ uint8_t rsv3[7]; /* reg 170-175: Reserved */ -+ uint8_t media_lane_adv[15]; /* reg 176-190: Media Lane Assignment Advertising */ -+ uint8_t custom[32]; /* reg 191-222: Custom */ -+ uint8_t add_app_desc[28]; /* reg 223-250: Additional Application Descriptor Registers */ -+ uint8_t rsv4[4]; /* reg 251-254: Reserved */ -+ uint8_t page_check_sum; /* reg 255: Page Checksum */ -+}; -+ -+/* Current support max 640 bytes data */ -+struct cmis_page_info { -+ struct cmis_page0_lower page0_lower; -+ struct cmis_page0_upper page0_upper; -+ struct cmis_page1_info page1; -+ uint8_t page2_data[128]; -+ uint8_t page3_data[128]; -+}; -+ - #define XSFP_TARGET_BIT HI_BIT(0) - #define XSFP_RAW_DATA_BIT HI_BIT(1) - --- -2.33.0 - diff --git a/0057-hikptool-Fixed-an-issue-where-the-MAC-type-is-incorr.patch b/0057-hikptool-Fixed-an-issue-where-the-MAC-type-is-incorr.patch deleted file mode 100644 index 138b37e328092ebfd4d2a55da6ed1fd7224f4b07..0000000000000000000000000000000000000000 --- a/0057-hikptool-Fixed-an-issue-where-the-MAC-type-is-incorr.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 88a34af2338c4b49d6e2af846b9b7cd0d01068d2 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Mon, 15 Jan 2024 17:55:58 +0800 -Subject: [PATCH] hikptool: Fixed an issue where the MAC type is incorrectly - displayed - -Currently, only the ETH and ROH types can be displayed, add the UB -mac type to be displayed - -Fixes: e05c70e1ff25 ("support querying NIC module information") -Signed-off-by: veega2022 ---- - net/nic/nic_info/hikp_nic_info.c | 11 +++++++++-- - net/nic/nic_info/hikp_nic_info.h | 7 +++++++ - 2 files changed, 16 insertions(+), 2 deletions(-) - -diff --git a/net/nic/nic_info/hikp_nic_info.c b/net/nic/nic_info/hikp_nic_info.c -index cd78bc7..992bbf0 100644 ---- a/net/nic/nic_info/hikp_nic_info.c -+++ b/net/nic/nic_info/hikp_nic_info.c -@@ -98,6 +98,13 @@ static int hikp_nic_get_curr_die_info(void) - return 0; - } - -+static const char *hikp_nic_info_get_mac_type(uint8_t type_val) -+{ -+ const char *mac_type[MAC_TYPE_MAX] = {"ETH", "ROH", "UB"}; -+ -+ return (type_val >= MAC_TYPE_MAX) ? "UNKNOWN" : mac_type[type_val]; -+} -+ - static void hikp_nic_info_print_cur_pf(const struct bdf_t *bdf) - { - struct tool_target *pf_target = &g_info_param.target; -@@ -113,7 +120,7 @@ static void hikp_nic_info_print_cur_pf(const struct bdf_t *bdf) - bdf->domain, bdf->bus_id, bdf->dev_id, bdf->fun_id); - printf("\t%-16s %u\n", "mac id:", g_info_param.info.pf_info[pf_id].mac_id); - printf("\t%-16s %s\n", "mac type:", -- g_info_param.info.pf_info[pf_id].mac_type ? "ROH" : "ETH"); -+ hikp_nic_info_get_mac_type(g_info_param.info.pf_info[pf_id].mac_type)); - printf("\t%-16s %u\n", "func_num:", g_info_param.info.pf_info[pf_id].func_num); - printf("\t%-16s %u\n", "tqp_num:", g_info_param.info.pf_info[pf_id].tqp_num); - printf("\t%-16s 0x%x\n", "pf_cap_flag:", g_info_param.info.pf_info[pf_id].pf_cap_flag); -@@ -162,7 +169,7 @@ static void hikp_nic_info_print_cur_die(void) - - printf("\n%-16s", "mac type:"); - for (i = 0; i < g_info_param.info.pf_num; i++) -- printf("%s\t", g_info_param.info.pf_info[i].mac_type ? "ROH" : "ETH"); -+ printf("%s\t", hikp_nic_info_get_mac_type(g_info_param.info.pf_info[i].mac_type)); - - printf("\n%-16s", "func num:"); - for (i = 0; i < g_info_param.info.pf_num; i++) -diff --git a/net/nic/nic_info/hikp_nic_info.h b/net/nic/nic_info/hikp_nic_info.h -index 7419209..194146e 100644 ---- a/net/nic/nic_info/hikp_nic_info.h -+++ b/net/nic/nic_info/hikp_nic_info.h -@@ -70,4 +70,11 @@ struct nic_info_param { - bool have_interface; - }; - -+enum nic_info_mac_type { -+ MAC_TYPE_ETH = 0, -+ MAC_TYPE_ROH, -+ MAC_TYPE_UB, -+ MAC_TYPE_MAX, -+}; -+ - #endif --- -2.30.0 - diff --git a/0058-hikptool-The-nic_port-command-is-adapted-to-display-.patch b/0058-hikptool-The-nic_port-command-is-adapted-to-display-.patch deleted file mode 100644 index d9f044dca9bf128e6f3e13182c3613fdb1dad6f1..0000000000000000000000000000000000000000 --- a/0058-hikptool-The-nic_port-command-is-adapted-to-display-.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 9bdcedb5d634b438139daf6de851a0f40e8708fe Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 22 Feb 2024 10:34:09 +0800 -Subject: [PATCH] hikptool: The nic_port command is adapted to display the DFX - of the ROH MAC - -ROH MAC is different from ETH MAC. For ROH MAC, -the following DFX parameters are added: -tx link lanes, rx link lanes, pcs link, mac link, tx retry count, etc. - -For the firmware of earlier versions, -the MAC DFX of the ETH type is displayed by default. - -Signed-off-by: veega2022 ---- - net/nic/nic_mac/hikp_mac_cmd.h | 1 + - net/nic/nic_mac/hikp_nic_port.c | 63 +++++++++++++++++++++++++++++++-- - net/nic/nic_mac/hikp_nic_port.h | 25 +++++++++++++ - 3 files changed, 86 insertions(+), 3 deletions(-) - -diff --git a/net/nic/nic_mac/hikp_mac_cmd.h b/net/nic/nic_mac/hikp_mac_cmd.h -index f74fd2a..9a3f0d9 100644 ---- a/net/nic/nic_mac/hikp_mac_cmd.h -+++ b/net/nic/nic_mac/hikp_mac_cmd.h -@@ -32,6 +32,7 @@ enum mac_port_sub_cmd { - QUERY_HOT_PLUG_CARD_DFX, - QUERY_PORT_CDR_DFX, - QUERY_PORT_INFO_DFX_CAP, -+ QUERY_PORT_ROH_MAC_DFX, - }; - - enum mac_dump_reg_sub_cmd { -diff --git a/net/nic/nic_mac/hikp_nic_port.c b/net/nic/nic_mac/hikp_nic_port.c -index 5ba6927..725ef95 100644 ---- a/net/nic/nic_mac/hikp_nic_port.c -+++ b/net/nic/nic_mac/hikp_nic_port.c -@@ -174,7 +174,7 @@ static void mac_show_speed(uint32_t speed, uint32_t lanes) - printf("speed: %s_%s\n", speed_str, lanes_str); - } - --static void mac_cmd_disp_mac_info(const struct mac_cmd_mac_dfx *mac_dfx) -+static void mac_cmd_disp_eth_mac_info(const struct mac_cmd_mac_dfx *mac_dfx) - { - printf("\n========================== MAC INFO ==========================\n"); - mac_show_speed(mac_dfx->speed, mac_dfx->lanes); -@@ -192,7 +192,7 @@ static void mac_cmd_disp_mac_info(const struct mac_cmd_mac_dfx *mac_dfx) - printf("pcs_err = 0x%x\n", mac_dfx->pcs_err_cnt); - } - --static void mac_cmd_show_mac(struct major_cmd_ctrl *self) -+static void mac_cmd_show_eth_mac(struct major_cmd_ctrl *self) - { - struct mac_cmd_mac_dfx *mac_dfx = NULL; - struct hikp_cmd_ret *cmd_ret = NULL; -@@ -206,8 +206,65 @@ static void mac_cmd_show_mac(struct major_cmd_ctrl *self) - } - - mac_dfx = (struct mac_cmd_mac_dfx *)(cmd_ret->rsp_data); -- mac_cmd_disp_mac_info(mac_dfx); -+ mac_cmd_disp_eth_mac_info(mac_dfx); -+ free(cmd_ret); -+ cmd_ret = NULL; -+} -+ -+static void mac_cmd_disp_roh_mac_info(const struct mac_cmd_roh_mac_dfx *mac_dfx) -+{ -+ printf("\n========================== MAC INFO ==========================\n"); -+ mac_show_speed(mac_dfx->speed, mac_dfx->lanes); -+ mac_print_enum("fec", mac_dfx->fec, g_fec_table, HIKP_ARRAY_SIZE(g_fec_table), "unknown"); -+ mac_print_enum("sds_rate", mac_dfx->sds_rate, g_sds_rate_table, -+ HIKP_ARRAY_SIZE(g_sds_rate_table), "unknown"); -+ printf("tx_link_lanes: %u\n", mac_dfx->tx_link_lanes); -+ printf("rx_link_lanes: %u\n", mac_dfx->rx_link_lanes); -+ mac_print_link("pcs_link", mac_dfx->pcs_link); -+ mac_print_link("mac_link", mac_dfx->mac_link); -+ printf("tx_retry_cnt: %u\n", mac_dfx->tx_retry_cnt); -+} -+ -+static void mac_cmd_show_roh_mac(struct major_cmd_ctrl *self) -+{ -+ struct mac_cmd_roh_mac_dfx *mac_dfx = NULL; -+ struct hikp_cmd_ret *cmd_ret = NULL; -+ int ret; -+ -+ ret = mac_cmd_get_dfx_cfg(QUERY_PORT_ROH_MAC_DFX, &cmd_ret); -+ if (ret) { -+ snprintf(self->err_str, sizeof(self->err_str), "mac get roh mac dfx failed."); -+ self->err_no = -ENOSPC; -+ return; -+ } -+ -+ mac_dfx = (struct mac_cmd_roh_mac_dfx *)(cmd_ret->rsp_data); -+ mac_cmd_disp_roh_mac_info(mac_dfx); - free(cmd_ret); -+ cmd_ret = NULL; -+} -+ -+static void mac_cmd_show_mac(struct major_cmd_ctrl *self) -+{ -+ struct mac_cmd_port_hardware *hw = NULL; -+ struct hikp_cmd_ret *hw_cmd_ret = NULL; -+ int ret; -+ -+ ret = mac_cmd_get_dfx_cfg(QUERY_PORT_HARDWARE, &hw_cmd_ret); -+ if (ret) { -+ snprintf(self->err_str, sizeof(self->err_str), "mac get hardware dfx failed."); -+ self->err_no = -ENOSPC; -+ return; -+ } -+ -+ hw = (struct mac_cmd_port_hardware *)(hw_cmd_ret->rsp_data); -+ if (hw->cmd_mac_type == CMD_MAC_TYPE_ROH || hw->cmd_mac_type == CMD_MAC_TYPE_UB) -+ mac_cmd_show_roh_mac(self); -+ else -+ mac_cmd_show_eth_mac(self); -+ -+ free(hw_cmd_ret); -+ hw_cmd_ret = NULL; - } - - static void mac_cmd_disp_link_info(struct mac_cmd_link_dfx *link_dfx) -diff --git a/net/nic/nic_mac/hikp_nic_port.h b/net/nic/nic_mac/hikp_nic_port.h -index 78928b3..cb72ebc 100644 ---- a/net/nic/nic_mac/hikp_nic_port.h -+++ b/net/nic/nic_mac/hikp_nic_port.h -@@ -107,6 +107,9 @@ struct mac_item { - struct mac_cmd_port_hardware { - uint8_t port_type; - uint8_t media_type; -+ uint8_t cmd_mac_type : 4, -+ rsv0 : 4; -+ uint8_t rsv1; - }; - - struct mac_cmd_mac_dfx { -@@ -230,6 +233,28 @@ struct mac_cmd_port_dfx_cap { - uint32_t rsvd[3]; - }; - -+enum cmd_mac_type { -+ CMD_MAC_TYPE_ETH = 0, -+ CMD_MAC_TYPE_ROH, -+ CMD_MAC_TYPE_UB, -+ CMD_MAC_TYPE_MAX, -+}; -+ -+struct mac_cmd_roh_mac_dfx { -+ uint8_t speed; -+ uint8_t fec; -+ uint8_t lanes; -+ uint8_t sds_rate; -+ uint8_t tx_link_lanes : 4, -+ rx_link_lanes : 4; -+ uint8_t pcs_link : 1, -+ mac_link : 1, -+ rsv0 : 6; -+ uint8_t rsv1[2]; -+ uint32_t tx_retry_cnt; -+ uint32_t rsv2[4]; -+}; -+ - struct mac_cmd_dfx_callback { - uint32_t mask; - void (*show_dfx)(struct major_cmd_ctrl *self); --- -2.30.0 - diff --git a/0059-hikptool-fix-cleancode-codecheck-alarm.patch b/0059-hikptool-fix-cleancode-codecheck-alarm.patch deleted file mode 100644 index 7321cee69903436a857f641b97a4601a48f57d32..0000000000000000000000000000000000000000 --- a/0059-hikptool-fix-cleancode-codecheck-alarm.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 84eb49f12133a4938805462940eaa2847492bdfb Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 28 Feb 2024 11:23:59 +0800 -Subject: [PATCH] hikptool: fix cleancode codecheck alarm - -1. invalid case style for macro definition __HIKPTDEV_PLUG_H -fix it to HIKPTDEV_PLUG_H - -2. Please do not mix signed and unsigned numbers -Modify the operator to ensure that the types on both sides are consistent. - -Signed-off-by: veega2022 ---- - libhikptdev/include/hikptdev_plug.h | 6 +++--- - tool_lib/op_logs.c | 2 +- - tool_lib/tool_lib.c | 4 ++-- - 3 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/libhikptdev/include/hikptdev_plug.h b/libhikptdev/include/hikptdev_plug.h -index 34fd783..8b242d3 100644 ---- a/libhikptdev/include/hikptdev_plug.h -+++ b/libhikptdev/include/hikptdev_plug.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKPTDEV_PLUG_H --#define __HIKPTDEV_PLUG_H -+#ifndef HIKPTDEV_PLUG_H -+#define HIKPTDEV_PLUG_H - - #include - -@@ -57,4 +57,4 @@ void hikp_dev_uninit(void); - int hikp_rsp_normal_check(const struct hikp_cmd_ret *cmd_ret); - int hikp_rsp_normal_check_with_version(const struct hikp_cmd_ret *cmd_ret, uint32_t version); - --#endif -+#endif /* HIKPTDEV_PLUG_H */ -diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c -index f57f5fd..9fb91d8 100644 ---- a/tool_lib/op_logs.c -+++ b/tool_lib/op_logs.c -@@ -283,7 +283,7 @@ void op_log_record_input(const int argc, const char **argv) - arg = input_str; - for (i = 0; i < argc; i++) { - ret = snprintf(arg, (sizeof(input_str) - (arg - input_str)), "%s ", argv[i]); -- if (ret < 0 || ret >= (sizeof(input_str) - (arg - input_str))) -+ if (ret < 0 || ret >= (int)(sizeof(input_str) - (arg - input_str))) - return; - - arg = arg + strlen(argv[i]) + 1; -diff --git a/tool_lib/tool_lib.c b/tool_lib/tool_lib.c -index 180418f..5c1a02d 100644 ---- a/tool_lib/tool_lib.c -+++ b/tool_lib/tool_lib.c -@@ -281,9 +281,9 @@ static int get_rand_str(char *str, int length) - [TYPE_LOWERCASE] = {'a', 26}, - }; - uint32_t r[RANDOM_NUM]; -+ uint32_t type; - int fd, size; - int i, j; -- int type; - - fd = open("/dev/urandom", O_RDONLY); - if (fd < 0) { -@@ -325,7 +325,7 @@ int generate_file_name(unsigned char *file_name, - ret = snprintf((char *)file_name, file_name_len, "%s_%d_%d_%d_%d_%d_%d_%s.log", prefix, - timeinfo.tm_year + START_YEAR, timeinfo.tm_mon + 1, timeinfo.tm_mday, - timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec, str_r); -- if (ret < 0 || ret >= file_name_len) { -+ if (ret < 0 || (uint32_t)ret >= file_name_len) { - HIKP_ERROR_PRINT("generate file name failed, errno is %d\n", errno); - return -errno; - } --- -2.30.0 - diff --git a/0060-hikptool-Delete-meaningless-printing.patch b/0060-hikptool-Delete-meaningless-printing.patch deleted file mode 100644 index 2bf6a3f9cee1639472e50d65154f4334f113ccfc..0000000000000000000000000000000000000000 --- a/0060-hikptool-Delete-meaningless-printing.patch +++ /dev/null @@ -1,32 +0,0 @@ -From c28e333b43508b4037cba59a6ce8bb3912f63939 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Mon, 18 Mar 2024 17:36:40 +0800 -Subject: [PATCH] hikptool: Delete meaningless printing - -The revision IDs of different chips may be different. -Therefore, the print of revision ID mismatch is deleted. -It is normal that the revision IDs are different. - -Signed-off-by: veega2022 ---- - libhikptdev/src/rciep/hikpt_rciep.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/libhikptdev/src/rciep/hikpt_rciep.c b/libhikptdev/src/rciep/hikpt_rciep.c -index f673dd0..75ec224 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.c -+++ b/libhikptdev/src/rciep/hikpt_rciep.c -@@ -366,8 +366,8 @@ static int hikp_iep_check(const char *tmp_vendor_dir, - return ret; - - ret = hikp_iep_check_item(revision_dir, MAX_PCI_REVISION_LEN, HIKP_IEP_REVISION); -- if (ret != 0) -- printf("Revision id not match %s.\n", HIKP_IEP_REVISION); -+ if (ret != 0 && ret != -ENXIO) -+ return ret; - - return 0; - } --- -2.30.0 - diff --git a/0061-hikptool-Update-the-tool-version-number-to-1.1.1.patch b/0061-hikptool-Update-the-tool-version-number-to-1.1.1.patch deleted file mode 100644 index d595982c996428ccc3df23d29e397f1cfd578494..0000000000000000000000000000000000000000 --- a/0061-hikptool-Update-the-tool-version-number-to-1.1.1.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 1354eaf629ac399a4f0789a0cdc460a4293ec905 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Tue, 23 Apr 2024 21:45:02 +0800 -Subject: [PATCH] hikptool: Update the tool version number to 1.1.1 - -Update the tool version number to 1.1.1 - -Signed-off-by: veega2022 ---- - tool_lib/tool_lib.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index 14b3db5..72a99c6 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.0" -+#define TOOL_VER "1.1.1" - - #define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask)) - #define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift)) --- -2.42.0.windows.2 - diff --git a/0062-hikptool-The-ecam-register-is-added-to-the-PCIe-dump.patch b/0062-hikptool-The-ecam-register-is-added-to-the-PCIe-dump.patch deleted file mode 100644 index fb25a30e4d91cb3a5994fb17c17d4120ef834ced..0000000000000000000000000000000000000000 --- a/0062-hikptool-The-ecam-register-is-added-to-the-PCIe-dump.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 87b58805e41ccb47c313266e76219d9b0bb5f05e Mon Sep 17 00:00:00 2001 -From: moubingquan -Date: Mon, 20 May 2024 14:13:24 +0800 -Subject: [PATCH] hikptool: The ecam register is added to the PCIe dumpreg. - -The ecam register is added to facilitate fault locating. - -Updated the tool version to 1.1.2. - -Signed-off-by: moubingquan ---- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 2 ++ - tool_lib/tool_lib.h | 2 +- - 2 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index b8c2241..535807c 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -144,6 +144,8 @@ struct pcie_dumpreg_info g_reg_table_pcs[] = { - }; - - struct pcie_dumpreg_info g_reg_table_iob_tx[] = { -+ {0, "IOB_TX_ECAM_CONTROL0"}, -+ {0, "IOB_TX_ECAM_CONTROL1"}, - {0, "IOB_TX_ECAM_BASE_ADDR_L"}, - {0, "IOB_TX_ECAM_BASE_ADDR_H"}, - {0, "IOB_TX_CXL_BASE_BUS_0"}, -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index 72a99c6..644a08e 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.1" -+#define TOOL_VER "1.1.2" - - #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/0063-hikptool-roce-Print-names-of-registers-for-gmv-mdb-p.patch b/0063-hikptool-roce-Print-names-of-registers-for-gmv-mdb-p.patch deleted file mode 100644 index 15a960d711bb773dac85c39040687636cc2784e0..0000000000000000000000000000000000000000 --- a/0063-hikptool-roce-Print-names-of-registers-for-gmv-mdb-p.patch +++ /dev/null @@ -1,739 +0,0 @@ -From f1664742cfa1cae3872d412b09f0c6865f553711 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Sat, 22 Jun 2024 14:01:10 +0800 -Subject: [PATCH 01/27] hikptool/roce: Print names of registers for - gmv/mdb/pkt/qmm/scc/timer/trp/tsp - -Print names of registers for gmv/mdb/pkt/qmm/scc/timer/trp/tsp to -improve usability. - -Signed-off-by: Junxian Huang ---- - net/roce/roce_gmv/hikp_roce_gmv.c | 18 +++- - net/roce/roce_mdb/hikp_roce_mdb.c | 33 +++++- - net/roce/roce_pkt/hikp_roce_pkt.c | 26 ++++- - net/roce/roce_qmm/hikp_roce_qmm.c | 80 ++++++++++++++- - net/roce/roce_scc/hikp_roce_scc.c | 116 ++++++++++++++++++++- - net/roce/roce_timer/hikp_roce_timer.c | 58 ++++++++++- - net/roce/roce_trp/hikp_roce_trp.c | 140 +++++++++++++++++++++++++- - net/roce/roce_tsp/hikp_roce_tsp.c | 84 +++++++++++++++- - 8 files changed, 541 insertions(+), 14 deletions(-) - -diff --git a/net/roce/roce_gmv/hikp_roce_gmv.c b/net/roce/roce_gmv/hikp_roce_gmv.c -index 36ba665..bc01ccf 100644 ---- a/net/roce/roce_gmv/hikp_roce_gmv.c -+++ b/net/roce/roce_gmv/hikp_roce_gmv.c -@@ -58,14 +58,28 @@ static int hikp_roce_gmv_idxget(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - -+/* DON'T change the order of this array or add entries between! */ -+static const char *g_gmv_reg_name[] = { -+ "ROCEE_VF_GMV_RO0", -+ "ROCEE_VF_GMV_RO1", -+ "ROCEE_VF_GMV_RO2", -+ "ROCEE_VF_GMV_RO3", -+ "ROCEE_VF_GMV_RO4", -+ "ROCEE_VF_GMV_RO5", -+ "ROCEE_VF_GMV_RO6", -+}; -+ - static void hikp_roce_gmv_print(uint32_t reg_num, struct roce_gmv_rsp_data *gmv_rsp) - { -+ uint8_t arr_len = HIKP_ARRAY_SIZE(g_gmv_reg_name); - uint32_t i; - - printf("*******************GMV INFO****************\n"); -- printf("addr_offset : reg_data\n"); -+ printf("%-40s[addr_offset] : reg_data\n", "reg_name"); - for (i = 0; i < reg_num; i++) -- printf("0x%08X : 0x%08X\n", gmv_rsp->reg_offset[i], gmv_rsp->reg_data[i]); -+ printf("%-40s[0x%08X] : 0x%08X\n", -+ i < arr_len ? g_gmv_reg_name[i] : "", -+ gmv_rsp->reg_offset[i], gmv_rsp->reg_data[i]); - printf("*******************************************\n"); - } - -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.c b/net/roce/roce_mdb/hikp_roce_mdb.c -index 374f100..b2b2c41 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.c -+++ b/net/roce/roce_mdb/hikp_roce_mdb.c -@@ -48,14 +48,43 @@ static int hikp_roce_mdb_clear_set(struct major_cmd_ctrl *self, const char *argv - return 0; - } - -+/* DON'T change the order of this array or add entries between! */ -+static const char *g_mdb_reg_name[] = { -+ "ROCEE_DWQE_WQE_ISSUE_CNT", -+ "ROCEE_DWQE_WQE_EXEC_CNT", -+ "ROCEE_DWQE_WQE_DROP_CNT", -+ "ROCEE_DWQE_SQDB_ISSUE_CNT", -+ "ROCEE_DWQE_SQDB_EXEC_CNT", -+ "ROCEE_MBX_ISSUE_CNT", -+ "ROCEE_MBX_EXEC_CNT", -+ "ROCEE_DB_ISSUE_CNT", -+ "ROCEE_DB_EXEC_CNT", -+ "ROCEE_EQDB_ISSUE_CNT", -+ "MDB_ALM", -+ "ROCEE_MDB_EMPTY", -+ "ROCEE_MDB_FULL", -+ "MDB_STA_0", -+ "MDB_STA_1", -+ "MDB_STA_2", -+ "MDB_MEM_INIT_DONE", -+ "ROCEE_MDB_ECC_ERR", -+ "ROCEE_MDB_ECC_ERR_INFO", -+ "MDB_STA_3", -+ "MDB_STA_4", -+ "MDB_STA_5", -+}; -+ - static void hikp_roce_mdb_print(uint32_t reg_num, struct roce_mdb_rsp_data *mdb_rsp) - { -+ uint8_t arr_len = HIKP_ARRAY_SIZE(g_mdb_reg_name); - uint32_t i; - - printf("**************MDB INFO*************\n"); -- printf("addr_offset : reg_data\n"); -+ printf("%-40s[addr_offset] : reg_data\n", "reg_name"); - for (i = 0; i < reg_num; i++) -- printf("0x%08X : 0x%08X\n", mdb_rsp->reg_offset[i], mdb_rsp->reg_data[i]); -+ printf("%-40s[0x%08X] : 0x%08X\n", -+ i < arr_len ? g_mdb_reg_name[i] : "", -+ mdb_rsp->reg_offset[i], mdb_rsp->reg_data[i]); - printf("***********************************\n"); - } - -diff --git a/net/roce/roce_pkt/hikp_roce_pkt.c b/net/roce/roce_pkt/hikp_roce_pkt.c -index e710e08..74294c6 100644 ---- a/net/roce/roce_pkt/hikp_roce_pkt.c -+++ b/net/roce/roce_pkt/hikp_roce_pkt.c -@@ -62,14 +62,38 @@ static int hikp_roce_pkt_get_data(struct hikp_cmd_ret **cmd_ret, struct roce_pkt - return ret; - } - -+/* DON'T change the order of this array or add entries between! */ -+static const char *g_pkt_reg_name[] = { -+ "ROCEE_RC_PKT_RX_CNT", -+ "ROCEE_UD_PKT_RX_CNT", -+ "ROCEE_XRC_PKT_RX_CNT", -+ "ROCEE_PKT_RX_CNT", -+ "ROCEE_ERR_PKT_RX_CNT", -+ "ROCEE_CNP_PKT_RX_CNT", -+ "TRP_RX_ERR_FLAG", -+ "RX_BUFF_CNT", -+ "ROCEE_RC_PKT_TX_CNT", -+ "ROCEE_UD_PKT_TX_CNT", -+ "ROCEE_XRC_PKT_TX_CNT", -+ "ROCEE_PKT_TX_CNT", -+ "ROCEE_ERR_PKT_TX_CNT", -+ "ROCEE_CNP_PKT_TX_CNT", -+ "TRP_GET_MPT_ERR_PKT_CNT", -+ "TRP_GET_IRRL_ERR_PKT_CNT", -+}; -+ - static void hikp_roce_pkt_print(uint32_t total_block_num, - const uint32_t *offset, const uint32_t *data) - { -+ uint8_t arr_len = HIKP_ARRAY_SIZE(g_pkt_reg_name); - uint32_t i; - - printf("**************PKT INFO*************\n"); -+ printf("%-40s[addr_offset] : reg_data\n", "reg_name"); - for (i = 0; i < total_block_num; i++) -- printf("[0x%08X] : 0x%08X\n", offset[i], data[i]); -+ printf("%-40s[0x%08X] : 0x%08X\n", -+ i < arr_len ? g_pkt_reg_name[i] : "", -+ offset[i], data[i]); - printf("***********************************\n"); - } - -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.c b/net/roce/roce_qmm/hikp_roce_qmm.c -index e440b82..fa4e18a 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.c -+++ b/net/roce/roce_qmm/hikp_roce_qmm.c -@@ -58,14 +58,90 @@ static int hikp_roce_qmm_bank_get(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - -+/* DON'T change the order of these arrays or add entries between! */ -+static const char *g_qmm_top_reg_name[] = { -+ "ROCEE_QMM_SRQC_ALM", -+ "ROCEE_QMM_MPT_ALM", -+ "ROCEE_QMM_ECC_ERR", -+ "QMM_AXI_RESP_ERR", -+ "ROCEE_LPRC_RO", -+ "ROCEE_LPRC_RC", -+ "QMM_LPRC_EMPTY_RD", -+ "QPC_DMAE_EMPTY_RD", -+ "QMM_LPRC_FULL_WR", -+ "QPC_DMAE_FULL_WR", -+ "ROCEE_QMM_QPC_ALM", -+ "ROCEE_QMM_GMV_ALM", -+}; -+ -+static const char *g_qmm_cqc_reg_name[] = { -+ "ROCEE_CQC_SRH_REQ_RO_BK0", -+ "ROCEE_CQC_SRH_REQ_RO_BK1", -+ "ROCEE_CQC_ECC_ERR", -+ "ROCEE_CQC_RESP_ERR", -+ "CQC_RW_REQ_RO_BK0", -+ "CQC_RW_REQ_RO_BK1", -+ "ROCEE_QMM_CQC_ALM", -+}; -+ -+static const char *g_qmm_qpc_reg_name[] = { -+ "QMM_QPC_SRH_CNT_0", -+ "QMM_QPC_SRH_CNT_1", -+ "ROCEE_QPC_EMPTY_RD", -+ "ROCEE_QPC_FULL_WR", -+ "ROCEE_QPC_SRH_REQ_RO_0", -+ "ROCEE_QPC_SRH_REQ_RO_1", -+ "QMM_QPC_CLR_CNT0_0", -+ "QMM_QPC_CLR_CNT1_0", -+ "QMM_QPC_CLR_CNT2_0", -+ "QMM_QPC_CLR_CNT3_0", -+ "QMM_QPC_CLR_CNT0_1", -+ "QMM_QPC_CLR_CNT1_1", -+ "QMM_QPC_CLR_CNT2_1", -+ "QMM_QPC_CLR_CNT3_1", -+ "QPC_RW_REQ_RO_0", -+ "QPC_RW_REQ_RO_1", -+ "QPC_WQE_ECC_ERR", -+}; -+ -+static const struct reg_name_info { -+ enum roce_qmm_cmd_type sub_cmd; -+ const char **reg_name; -+ uint8_t arr_len; -+} g_qmm_reg_name_info_table[] = { -+ {QMM_SHOW_CQC, g_qmm_cqc_reg_name, HIKP_ARRAY_SIZE(g_qmm_cqc_reg_name)}, -+ {QMM_SHOW_QPC, g_qmm_qpc_reg_name, HIKP_ARRAY_SIZE(g_qmm_qpc_reg_name)}, -+ {QMM_SHOW_TOP, g_qmm_top_reg_name, HIKP_ARRAY_SIZE(g_qmm_top_reg_name)}, -+}; -+ - static void hikp_roce_qmm_print(struct roce_qmm_rsp_data *qmm_rsp) - { -+ const char **reg_name; -+ uint8_t arr_len; - int index = 0; - -+ for (index = 0; index < HIKP_ARRAY_SIZE(g_qmm_reg_name_info_table); index++) { -+ if (g_qmm_reg_name_info_table[index].sub_cmd != g_roce_qmm_param.sub_cmd) -+ continue; -+ arr_len = g_qmm_reg_name_info_table[index].arr_len; -+ reg_name = g_qmm_reg_name_info_table[index].reg_name; -+ break; -+ } -+ -+ if (index == HIKP_ARRAY_SIZE(g_qmm_reg_name_info_table)) { -+ printf("can't find reg name table for roce_qmm sub_cmd %u.\n", -+ g_roce_qmm_param.sub_cmd); -+ return; -+ } -+ - printf("**************QMM %s INFO*************\n", - g_roce_qmm_param.sub_name); -+ printf("%-40s[addr_offset] : reg_data\n", "reg_name"); -+ index = 0; - while (index < qmm_rsp->reg_num) { -- printf("0x%08X : 0x%08X\n", qmm_rsp->qmm_content[index][0], -+ printf("%-40s[0x%08X] : 0x%08X\n", -+ index < arr_len ? reg_name[index] : "", -+ qmm_rsp->qmm_content[index][0], - qmm_rsp->qmm_content[index][1]); - index++; - } -@@ -125,7 +201,7 @@ exec_error: - - static void hikp_roce_qmm_execute(struct major_cmd_ctrl *self) - { -- const struct cmd_type_info { -+ static const struct cmd_type_info { - enum roce_qmm_cmd_type sub_cmd; - enum roce_qmm_cmd_type sub_ext_cmd; - const char *sub_name; -diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c -index fe08873..76c0ca6 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.c -+++ b/net/roce/roce_scc/hikp_roce_scc.c -@@ -208,14 +208,128 @@ static int hikp_roce_scc_get_next_data(struct roce_scc_head *res_head, - return 0; - } - -+/* DON'T change the order of these arrays or add entries between! */ -+static const char *g_scc_common_reg_name[] = { -+ "SCC_MODE_SEL", -+ "SCC_OUTSTANDING_CTRL", -+ "SCC_FW_BASE_ADDR", -+ "SCC_MEM_START_INIT", -+ "SCC_MEM_INIT_DONE", -+ "SCC_FW_REQ_CNT", -+ "SCC_FW_RSP_CNT", -+ "SCC_FW_CNT_CTRL", -+ "SCC_GLB_OUTSTANDING", -+ "SCC_AXI_OUTSTANDING", -+ "SCC_FW_REQRSP_CNT0", -+ "SCC_FW_REQRSP_CNT1", -+ "SCC_OUTSTANDING_ID", -+ "SCC_OUTSTANDING_STS", -+ "SCC_CACHEMISS_LOAD_CNT", -+ "SCC_CACHEMISS_STORE_CNT", -+ "FW_PROCESS_TIME", -+ "SCC_INT_EN", -+ "SCC_INT_SRC", -+ "SCC_ECC_1BIT_CNT", -+ "SCC_ECC_1BIT_INFO", -+ "SCC_ECC_MBIT_INFO", -+ "ECC_ERR_INJ_SEL", -+ "CTX_RDWR_ERR_INFO", -+ "SCC_FW_REQRSP_CNT2", -+ "SCC_LOAD_CAL_CFG_0", -+ "SCC_LOAD_CAL_CFG_1", -+ "SCC_LOAD_CAL_CFG_2", -+ "SCC_LOAD_CAL_CFG_3", -+ "SCC_LOAD_CAL_CFG_4", -+ "SCC_LOAD_CAL_CFG_5", -+ "SCC_LOAD_CAL_CFG_6", -+ "SCC_LOAD_CAL_CFG_7", -+ "SCC_MAX_PROCESS_TIME", -+ "SCC_TIMEOUT_SET", -+ "SCC_TIMEOUT_CNT", -+ "SCC_TIME_STA_EN", -+ "SCC_INPUT_REQ_CNT", -+ "SCC_OUTPUT_RSP_CNT", -+ "SCC_INOUT_CNT_CFG", -+}; -+ -+static const char *g_scc_dcqcn_reg_name[] = { -+ "SCC_TEMP_CFG0", -+ "SCC_TEMP_CFG1", -+ "SCC_TEMP_CFG2", -+ "SCC_TEMP_CFG3", -+ "ROCEE_CNP_PKT_RX_CNT", -+ "ROCEE_CNP_PKT_TX_CNT", -+ "ROCEE_ECN_DB_CNT0", -+ "ROCEE_ECN_DB_CNT1", -+ "ROCEE_ECN_DB_CNT2", -+ "ROCEE_ECN_DB_CNT3", -+}; -+ -+static const char *g_scc_dip_reg_name[] = { -+ "SCC_TEMP_CFG0", -+ "SCC_TEMP_CFG1", -+ "SCC_TEMP_CFG2", -+ "SCC_TEMP_CFG3", -+}; -+ -+static const char *g_scc_hc3_reg_name[] = { -+ "SCC_TEMP_CFG0", -+ "SCC_TEMP_CFG1", -+ "SCC_TEMP_CFG2", -+ "SCC_TEMP_CFG3", -+}; -+ -+static const char *g_scc_ldcp_reg_name[] = { -+ "SCC_TEMP_CFG0", -+ "SCC_TEMP_CFG1", -+ "SCC_TEMP_CFG2", -+ "SCC_TEMP_CFG3", -+}; -+ -+static const char *g_scc_cfg_reg_name[] = { -+ "ROCEE_TM_CFG", -+}; -+ -+static const struct reg_name_info { -+ enum roce_scc_type sub_cmd; -+ const char **reg_name; -+ uint8_t arr_len; -+} g_scc_reg_name_info_table[] = { -+ {COMMON, g_scc_common_reg_name, HIKP_ARRAY_SIZE(g_scc_common_reg_name)}, -+ {DCQCN, g_scc_dcqcn_reg_name, HIKP_ARRAY_SIZE(g_scc_dcqcn_reg_name)}, -+ {DIP, g_scc_dip_reg_name, HIKP_ARRAY_SIZE(g_scc_dip_reg_name)}, -+ {HC3, g_scc_hc3_reg_name, HIKP_ARRAY_SIZE(g_scc_hc3_reg_name)}, -+ {LDCP, g_scc_ldcp_reg_name, HIKP_ARRAY_SIZE(g_scc_ldcp_reg_name)}, -+ {CFG, g_scc_cfg_reg_name, HIKP_ARRAY_SIZE(g_scc_cfg_reg_name)}, -+}; -+ - static void hikp_roce_scc_print(uint8_t total_block_num, - const uint32_t *offset, const uint32_t *data) - { -+ const char **reg_name; -+ uint8_t arr_len; - uint32_t i; - -+ for (i = 0; i < HIKP_ARRAY_SIZE(g_scc_reg_name_info_table); i++) { -+ if (g_scc_reg_name_info_table[i].sub_cmd != g_roce_scc_param_t.sub_cmd) -+ continue; -+ arr_len = g_scc_reg_name_info_table[i].arr_len; -+ reg_name = g_scc_reg_name_info_table[i].reg_name; -+ break; -+ } -+ -+ if (i == HIKP_ARRAY_SIZE(g_scc_reg_name_info_table)) { -+ printf("can't find reg name table for roce_scc sub_cmd %u.\n", -+ g_roce_scc_param_t.sub_cmd); -+ return; -+ } -+ - printf("**************SCC INFO*************\n"); -+ printf("%-40s[addr_offset] : reg_data\n", "reg_name"); - for (i = 0; i < total_block_num; i++) -- printf("[0x%08X] : 0x%08X\n", offset[i], data[i]); -+ printf("%-40s[0x%08X] : 0x%08X\n", -+ i < arr_len ? reg_name[i] : "", -+ offset[i], data[i]); - printf("***********************************\n"); - } - -diff --git a/net/roce/roce_timer/hikp_roce_timer.c b/net/roce/roce_timer/hikp_roce_timer.c -index 05ad3e1..a36257e 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.c -+++ b/net/roce/roce_timer/hikp_roce_timer.c -@@ -44,12 +44,62 @@ static int hikp_roce_timer_clear_set(struct major_cmd_ctrl *self, const char *ar - return 0; - } - --static void hikp_roce_timer_print(struct roce_timer_rsp_data *timer_rsp) -+/* DON'T change the order of these arrays or add entries between! */ -+static const char *g_timer_qpc_reg_name[] = { -+ "QPC_AXI_ERR", -+ "QPC_SEARCH_CNT", -+ "QPC_DB_SEND_CNT", -+ "FIFO_FILL0", -+ "FIFO_FILL1", -+ "FIFO_FILL2", -+ "FIFO_OVER_FLOW", -+ "QPC_START_CNT", -+ "QPC_DB_SEND_NUM_CNT", -+ "ROCEE_TIMER_QPC_ECC_ERR", -+ "ROCEE_TIMER_QPC_ECC_ERR_INFO", -+ "START_TYPE_ERR_CNT", -+}; -+ -+static const char *g_timer_cqc_reg_name[] = { -+ "TIMER_MEM_INIT_DONE", -+ "CQC_AXI_ERR", -+ "CQC_SEARCH_CNT", -+ "CQC_DB_SEND_CNT", -+ "CQC_FIFO_FILL0", -+ "CQC_FIFO_FILL1", -+ "CQC_FIFO_FILL2", -+ "CQC_START_CNT", -+ "CQC_DB_SEND_NUM_CNT", -+ "FLR_DONE_STATE", -+ "ZERO_ADDR_ACC", -+ "ROCEE_TIMER_CQC_ECC_ERR", -+ "ROCEE_TIMER_CQC_ECC_ERR_INFO", -+ "TIMER_STA_0", -+ "CQC_LOSE_DB_CNT", -+ "TIMER_TDP_DONE_CNT", -+ "CQC_PAGE_OVER_CNT", -+}; -+ -+static void hikp_roce_timer_print(struct roce_timer_rsp_data *timer_rsp, -+ enum roce_timer_cmd_type cmd_type) - { -+ const char **reg_name; -+ uint8_t arr_len; - int index = 0; - -+ if (cmd_type == TIMER_SHOW_QPC) { -+ reg_name = g_timer_qpc_reg_name; -+ arr_len = HIKP_ARRAY_SIZE(g_timer_qpc_reg_name); -+ } else { -+ reg_name = g_timer_cqc_reg_name; -+ arr_len = HIKP_ARRAY_SIZE(g_timer_cqc_reg_name); -+ } -+ -+ printf("%-40s[addr_offset] : reg_data\n", "reg_name"); - while (index < timer_rsp->reg_num) { -- printf("0x%08X : 0x%08X\n", timer_rsp->timer_content[index][0], -+ printf("%-40s[0x%08X] : 0x%08X\n", -+ index < arr_len ? reg_name[index] : "", -+ timer_rsp->timer_content[index][0], - timer_rsp->timer_content[index][1]); - index++; - } -@@ -83,7 +133,7 @@ static int hikp_roce_timer_show_qpc(struct major_cmd_ctrl *self) - } - - printf("**************QPC TIMER INFO*************\n"); -- hikp_roce_timer_print(timer_rsp); -+ hikp_roce_timer_print(timer_rsp, TIMER_SHOW_QPC); - out: - free(cmd_ret); - cmd_ret = NULL; -@@ -117,7 +167,7 @@ static int hikp_roce_timer_show_cqc(struct major_cmd_ctrl *self) - } - - printf("**************CQC TIMER INFO*************\n"); -- hikp_roce_timer_print(timer_rsp); -+ hikp_roce_timer_print(timer_rsp, TIMER_SHOW_CQC); - out: - free(cmd_ret); - cmd_ret = NULL; -diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c -index fad3317..61f0511 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.c -+++ b/net/roce/roce_trp/hikp_roce_trp.c -@@ -231,14 +231,152 @@ static int hikp_roce_trp_get_next_data(struct roce_trp_head *res_head, - return 0; - } - -+/* DON'T change the order of these arrays or add entries between! */ -+static const char *g_trp_common_reg_name[] = { -+ "GEN_AC_QP_FIFO_FULL", -+ "GEN_AC_QP_FIFO_EMPTY", -+ "GEN_AC_QP_INNER_STA_0", -+ "GEN_AC_QP_INNER_STA_1", -+ "GEN_AC_QP_ALM", -+ "GEN_AC_QP_TSP_CQE_CNT", -+ "TRP_GET_PBL_FULL", -+ "TRP_GET_PBL_EMPTY", -+ "TRP_GET_PBL_INNER_ALM", -+ "TRP_GET_PBL_INNER_STA", -+ "TRP_GET_MPT_FSM", -+ "TRP_GET_MPT_EMPTY", -+ "TRP_GET_MPT_INNER_ALM", -+ "TRP_GET_MPT_INNER_STA", -+ "TRP_GET_SGE_FSM", -+ "TRP_GET_SGE_EMPTY", -+ "TRP_GET_SGE_INNER_ALM", -+ "TRP_GET_SGE_INNER_STA", -+ "TRP_GET_BA_EMPTY", -+ "TRP_GET_BA_INNER_ALM", -+ "TRP_GET_BA_INNER_STA", -+ "TRP_DMAECMD_EMPTY_0", -+ "TRP_DMAECMD_EMPTY_1", -+ "TRP_DMAECMD_FULL", -+ "TRP_GET_IRRL_FSM", -+ "TRP_GET_IRRL_FULL", -+ "TRP_GET_IRRL_EMPTY", -+ "TRP_GET_IRRL_INNER_ALM", -+ "TRP_GET_IRRL_INNER_STA", -+ "TRP_GET_QPC_FSM", -+ "TRP_GET_QPC_INNER_ALM", -+ "TRP_GET_QPC_INNER_STA", -+ "ROCEE_TRP_ECC_ERR_INFO", -+ "ROCEE_TRP_ECC1B", -+ "ROCEE_TRP_ECC2B", -+ "ROCEE_TRP_FUN_RST_DFX", -+ "TRP_GET_MPT_ERR_FLG", -+ "TRP_GET_IRRL_ERR_FLG", -+ "TRP_GET_QPC_ERR_FLG", -+ "ROCEE_ECN_DB_CNT", -+ "GEN_AC_QP_TSP_AE_CNT", -+ "GEN_AC_QP_MDB_CQE_CNT", -+ "GEN_AC_QP_LPRC_CQE_CNT", -+ "TRP_CNP_CNT", -+ "TRP_SGE_ERR_DROP_LEN", -+ "TRP_SGE_AXI_CNT", -+}; -+ -+static const char *g_trp_trp_rx_reg_name[] = { -+ "TRP_RX_CHECK_EN", -+ "TRP_RX_WR_PAYL_AXI_ERR", -+ "ROCEE_TRP_RX_STA", -+ "RX_FIFO_FULL", -+ "RX_FIFO_EMPTY_0", -+ "RX_FIFO_EMPTY_1", -+ "HEAD_BUFF_ECC", -+ "HEAD_BUFF_ECC_ADDR", -+ "TRP_RX_FIFO_EMPTY_0", -+ "TRP_RX_FIFO_EMPTY_1", -+ "TRP_RX_FIFO_EMPTY_2", -+ "TRP_RX_FIFO_EMPTY_3", -+}; -+ -+static const char *g_trp_gen_ac_reg_name[] = { -+ "GEN_AC_CQ_FIFO_FULL", -+ "GEN_AC_CQ_FIFO_EMPTY", -+ "GEN_AC_CQ_INNER_STA", -+ "GEN_AC_CQ_ALM", -+ "GEN_AC_CQ_CQE_CNT_0", -+ "GEN_AC_CQ_CQE_CNT_1", -+ "GEN_AC_CQ_CQE_CNT_2", -+ "GEN_AC_CQ_CQE_CNT_3", -+ "ROCEE_GENAC_ECC_ERR_INFO", -+ "ROCEE_GENAC_ECC1B", -+ "ROCEE_GENAC_ECC2B", -+ "GEN_AC_DMAECMD_STA", -+ "GEN_AC_DMAECMD_ALM", -+ "SWQE_LINK_STA", -+ "SWQE_LINK_ALM", -+ "GEN_AC_CQ_MAIN_STA_0", -+ "GEN_AC_CQ_MAIN_ALM", -+ "GEN_AC_CQ_MAIN_STA_1", -+ "POE_DFX_0", -+ "POE_DFX_1", -+ "POE_DFX_2", -+}; -+ -+static const char *g_trp_payl_reg_name[] = { -+ "ROCEE_EXT_ATOMIC_DFX_0", -+ "ROCEE_EXT_ATOMIC_DFX_1", -+ "ROCEE_EXT_ATOMIC_DFX_2", -+ "ROCEE_EXT_ATOMIC_DFX_3", -+ "ATOMIC_DFX_0", -+ "ATOMIC_DFX_1", -+ "ATOMIC_DFX_2", -+ "WR_PAYL_DFX_1", -+ "PAYL_BUFF_DFX_0", -+ "PAYL_BUFF_DFX_1", -+ "PAYL_BUFF_DFX_2", -+ "PAYL_BUFF_DFX_3", -+ "PAYL_BUFF_DFX_4", -+ "WR_PAYL_DFX_RC", -+ "WR_PAYL_DFX_RO", -+ "WR_PAYL_1_OST_NUM", -+}; -+ -+static const struct reg_name_info { -+ enum roce_trp_type sub_cmd; -+ const char **reg_name; -+ uint8_t arr_len; -+} g_trp_reg_name_info_table[] = { -+ {COMMON, g_trp_common_reg_name, HIKP_ARRAY_SIZE(g_trp_common_reg_name)}, -+ {TRP_RX, g_trp_trp_rx_reg_name, HIKP_ARRAY_SIZE(g_trp_trp_rx_reg_name)}, -+ {GEN_AC, g_trp_gen_ac_reg_name, HIKP_ARRAY_SIZE(g_trp_gen_ac_reg_name)}, -+ {PAYL, g_trp_payl_reg_name, HIKP_ARRAY_SIZE(g_trp_payl_reg_name)}, -+}; -+ - static void hikp_roce_trp_print(uint8_t total_block_num, - const uint32_t *offset, const uint32_t *data) - { -+ const char **reg_name; -+ uint8_t arr_len; - uint32_t i; - -+ for (i = 0; i < HIKP_ARRAY_SIZE(g_trp_reg_name_info_table); i++) { -+ if (g_trp_reg_name_info_table[i].sub_cmd != g_roce_trp_param_t.sub_cmd) -+ continue; -+ arr_len = g_trp_reg_name_info_table[i].arr_len; -+ reg_name = g_trp_reg_name_info_table[i].reg_name; -+ break; -+ } -+ -+ if (i == HIKP_ARRAY_SIZE(g_trp_reg_name_info_table)) { -+ printf("can't find reg name table for roce_trp sub_cmd %u.\n", -+ g_roce_trp_param_t.sub_cmd); -+ return; -+ } -+ - printf("**************TRP INFO*************\n"); -+ printf("%-40s[addr_offset] : reg_data\n", "reg_name"); - for (i = 0; i < total_block_num; i++) -- printf("[0x%08X] : 0x%08X\n", offset[i], data[i]); -+ printf("%-40s[0x%08X] : 0x%08X\n", -+ i < arr_len ? reg_name[i] : "", -+ offset[i], data[i]); - printf("***********************************\n"); - } - -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.c b/net/roce/roce_tsp/hikp_roce_tsp.c -index 5bb2649..b16f0a4 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.c -+++ b/net/roce/roce_tsp/hikp_roce_tsp.c -@@ -137,14 +137,96 @@ static int hikp_roce_tsp_get_data(struct hikp_cmd_ret **cmd_ret, - return ret; - } - -+/* DON'T change the order of these arrays or add entries between! */ -+static const char *g_tsp_common_reg_name[] = { -+ "ROCEE_TPP_ECC_ERR", -+ "ROCEE_TWP_STA", -+ "ROCEE_TWP_ALM", -+ "ROCEE_TWP_STA1", -+ "TSP_INDRECT_RW_STA", -+ "TSP_INDRECT_RD_CTRL", -+ "TSP_INDRECT_RD_DATA", -+ "ROCEE_TSP_OVF", -+}; -+ -+static const char *g_tsp_tdp_reg_name[] = { -+ "TDP_M_MEM_INIT_DONE", -+ "TDP_M_ECC1B", -+ "TDP_M_ECC2B", -+ "TDP_M_ECC_ERR_INFO", -+ "TDP_M_ALM", -+ "ROCEE_TDP_CNT_CFG0", -+ "ROCEE_TDP_CNT_CFG1", -+ "ROCEE_TDP_IN_CNT_ENB", -+ "ROCEE_TDP_TWP_CNT0_CFG", -+ "ROCEE_TDP_TWP_CNT1_CFG", -+ "ROCEE_TDP_TRP_CNT", -+ "ROCEE_TDP_MDB_CNT", -+ "ROCEE_TDP_LP_CNT", -+ "ROCEE_TDP_QMM_CNT", -+ "ROCEE_TDP_TWP_CNT0", -+ "ROCEE_TDP_TWP_CNT1", -+ "TDP_V_ECC1B", -+ "TDP_V_ECC2B", -+ "TDP_V_ECC_ERR_INFO", -+ "TDP_V_ALM", -+ "TDP_V_STA", -+ "ROCEE_TSP_OOO_ERR", -+ "TDP_M_STA", -+ "TDP_M_STA1", -+}; -+ -+static const char *g_tsp_tgp_tmp_reg_name[] = { -+ "ROCEE_TGP_ALM0", -+ "ROCEE_TGP_ALM1", -+ "ROCEE_TGP_STA0", -+ "ROCEE_TGP_STA1", -+ "TGP_INDRECT_RD_CTRL", -+ "TGP_INDRECT_RD_STA", -+ "TGP_INDRECT_RD_DATA", -+ "ROCEE_TMP_ALM0", -+ "ROCEE_TMP_ALM1", -+ "ROCEE_TMP_STA0", -+ "ROCEE_TMP_STA1", -+}; -+ -+static const struct reg_name_info { -+ enum roce_tsp_sub_cmd_code sub_cmd; -+ const char **reg_name; -+ uint8_t arr_len; -+} g_tsp_reg_name_info_table[] = { -+ {COMMON, g_tsp_common_reg_name, HIKP_ARRAY_SIZE(g_tsp_common_reg_name)}, -+ {TDP, g_tsp_tdp_reg_name, HIKP_ARRAY_SIZE(g_tsp_tdp_reg_name)}, -+ {TGP_TMP, g_tsp_tgp_tmp_reg_name, HIKP_ARRAY_SIZE(g_tsp_tgp_tmp_reg_name)}, -+}; -+ - static void hikp_roce_tsp_print(uint32_t total_block_num, - const uint32_t *offset, const uint32_t *data) - { -+ const char **reg_name; -+ uint8_t arr_len; - uint32_t i; - -+ for (i = 0; i < HIKP_ARRAY_SIZE(g_tsp_reg_name_info_table); i++) { -+ if (g_tsp_reg_name_info_table[i].sub_cmd != g_roce_tsp_param_t.sub_cmd_code) -+ continue; -+ arr_len = g_tsp_reg_name_info_table[i].arr_len; -+ reg_name = g_tsp_reg_name_info_table[i].reg_name; -+ break; -+ } -+ -+ if (i == HIKP_ARRAY_SIZE(g_tsp_reg_name_info_table)) { -+ printf("can't find reg name table for roce_tsp sub_cmd %u.\n", -+ g_roce_tsp_param_t.sub_cmd_code); -+ return; -+ } -+ - printf("**************TSP INFO*************\n"); -+ printf("%-40s[addr_offset] : reg_data\n", "reg_name"); - for (i = 0; i < total_block_num; i++) -- printf("[0x%08X] : 0x%08X\n", offset[i], data[i]); -+ printf("%-40s[0x%08X] : 0x%08X\n", -+ i < arr_len ? reg_name[i] : "", -+ offset[i], data[i]); - printf("***********************************\n"); - } - --- -2.45.0.windows.1 - diff --git a/0064-hikptool-roce-Support-exposing-names-of-extend-regis.patch b/0064-hikptool-roce-Support-exposing-names-of-extend-regis.patch deleted file mode 100644 index 081b1422be27b3602c58d6707b0e16de9f5e0a2d..0000000000000000000000000000000000000000 --- a/0064-hikptool-roce-Support-exposing-names-of-extend-regis.patch +++ /dev/null @@ -1,354 +0,0 @@ -From 217cdce3822eb68343807b80a3bc3c9b1530f9bb Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Sat, 22 Jun 2024 16:23:52 +0800 -Subject: [PATCH 02/27] hikptool/roce: Support exposing names of extend - registers - -Add support for exposing names of extend registers through the common -frame. To use this feature, the new-added input param reg_name should -be set inside the get_data() callback of each sub modules. For now only -mdb and qmm are supported. - -Signed-off-by: Junxian Huang ---- - net/roce/roce_bond/hikp_roce_bond.c | 3 +- - net/roce/roce_caep/hikp_roce_caep.c | 5 +- - .../roce_ext_common/hikp_roce_ext_common.c | 43 ++++++++------ - .../roce_ext_common/hikp_roce_ext_common.h | 14 ++++- - .../roce_global_cfg/hikp_roce_global_cfg.c | 3 +- - net/roce/roce_mdb/hikp_roce_mdb.c | 20 ++++++- - net/roce/roce_qmm/hikp_roce_qmm.c | 57 ++++++++++++++++++- - net/roce/roce_rst/hikp_roce_rst.c | 3 +- - 8 files changed, 121 insertions(+), 27 deletions(-) - -diff --git a/net/roce/roce_bond/hikp_roce_bond.c b/net/roce/roce_bond/hikp_roce_bond.c -index 89f8bab..8434a0b 100644 ---- a/net/roce/roce_bond/hikp_roce_bond.c -+++ b/net/roce/roce_bond/hikp_roce_bond.c -@@ -37,7 +37,8 @@ static int hikp_roce_bond_target(struct major_cmd_ctrl *self, const char *argv) - } - - static int hikp_roce_bond_get_data(struct hikp_cmd_ret **cmd_ret, -- uint32_t block_id) -+ uint32_t block_id, -+ struct roce_ext_reg_name *reg_name) - { - struct hikp_cmd_header req_header = { 0 }; - struct roce_bond_req_param req_data; -diff --git a/net/roce/roce_caep/hikp_roce_caep.c b/net/roce/roce_caep/hikp_roce_caep.c -index 126551a..0453bc4 100644 ---- a/net/roce/roce_caep/hikp_roce_caep.c -+++ b/net/roce/roce_caep/hikp_roce_caep.c -@@ -40,7 +40,8 @@ static int hikp_roce_caep_target(struct major_cmd_ctrl *self, const char *argv) - } - - static int hikp_roce_caep_get_data(struct hikp_cmd_ret **cmd_ret, -- uint32_t block_id) -+ uint32_t block_id, -+ struct roce_ext_reg_name *reg_name) - { - struct roce_caep_req_param_ext req_data_ext; - struct hikp_cmd_header req_header = { 0 }; -@@ -80,7 +81,7 @@ static void hikp_roce_caep_execute_origin(struct major_cmd_ctrl *self) - struct roce_caep_res_param *roce_caep_res; - struct hikp_cmd_ret *cmd_ret; - -- self->err_no = hikp_roce_caep_get_data(&cmd_ret, 0); -+ self->err_no = hikp_roce_caep_get_data(&cmd_ret, 0, NULL); - if (self->err_no) { - printf("hikptool roce_caep get data failed.\n"); - goto exec_error; -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 5bc3ce6..c22303f 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -89,14 +89,17 @@ static int get_cmd_reg_array_length(enum roce_cmd_type cmd_type) - - static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - uint32_t block_id, -- struct roce_ext_head *res_head, -- struct reg_data *reg, -+ struct roce_ext_res_output *output, - int (*get_data)(struct hikp_cmd_ret **cmd_ret, -- uint32_t block_id)) -+ uint32_t block_id, -+ struct roce_ext_reg_name *reg_name)) - { - int reg_array_length = get_cmd_reg_array_length(cmd_type); -+ struct roce_ext_reg_name *reg_name = &output->reg_name; -+ struct roce_ext_head *res_head = &output->res_head; - const char *cmd_name = get_cmd_name(cmd_type); - struct roce_ext_res_param *roce_ext_res; -+ struct reg_data *reg = &output->reg; - struct hikp_cmd_ret *cmd_ret; - size_t max_size; - size_t cur_size; -@@ -108,7 +111,7 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - if (reg_array_length < 0) - return reg_array_length; - -- ret = get_data(&cmd_ret, block_id); -+ ret = get_data(&cmd_ret, block_id, reg_name); - if (ret) { - printf("hikptool roce_%s get data failed!\n", cmd_name); - goto get_data_error; -@@ -149,37 +152,45 @@ get_data_error: - return ret; - } - --static void hikp_roce_ext_print(const char *cmd_name, uint32_t total_block_num, -- const uint32_t *offset, const uint32_t *data) -+static void hikp_roce_ext_print(enum roce_cmd_type cmd_type, -+ struct roce_ext_res_output *output) - { -+ uint32_t total_block_num = output->res_head.total_block_num; -+ const char **reg_name = output->reg_name.reg_name; -+ 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; - int 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("[0x%08X] : 0x%08X\n", offset[i], data[i]); -+ printf("%-40s[0x%08X] : 0x%08X\n", -+ i < arr_len ? reg_name[i] : "", -+ offset[i], data[i]); - printf("************************************\n"); - } - - void hikp_roce_ext_execute(struct major_cmd_ctrl *self, - enum roce_cmd_type cmd_type, - int (*get_data)(struct hikp_cmd_ret **cmd_ret, -- uint32_t block_id)) -+ uint32_t block_id, -+ struct roce_ext_reg_name *reg_name)) - { -+ struct roce_ext_res_output output = { 0 }; - uint32_t queried_block_id = 0; -- struct roce_ext_head res_head; -- struct reg_data reg = { 0 }; - - do { - self->err_no = hikp_roce_ext_get_res(cmd_type, queried_block_id, -- &res_head, ®, get_data); -+ &output, get_data); - if (self->err_no) - return; - -- queried_block_id += res_head.cur_block_num; -- } while (queried_block_id < res_head.total_block_num); -+ queried_block_id += output.res_head.cur_block_num; -+ } while (queried_block_id < output.res_head.total_block_num); - -- hikp_roce_ext_print(get_cmd_name(cmd_type), res_head.total_block_num, -- reg.offset, reg.data); -+ hikp_roce_ext_print(cmd_type, &output); - -- hikp_roce_ext_reg_data_free(®); -+ hikp_roce_ext_reg_data_free(&output.reg); - } -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 a600449..4930bed 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.h -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.h -@@ -47,9 +47,21 @@ struct reg_data { - uint32_t *data; - }; - -+struct roce_ext_reg_name { -+ const char **reg_name; -+ uint8_t arr_len; -+}; -+ -+struct roce_ext_res_output { -+ struct roce_ext_head res_head; -+ struct reg_data reg; -+ struct roce_ext_reg_name reg_name; -+}; -+ - void hikp_roce_ext_execute(struct major_cmd_ctrl *self, - enum roce_cmd_type cmd_type, - int (*get_data)(struct hikp_cmd_ret **cmd_ret, -- uint32_t block_id)); -+ uint32_t block_id, -+ struct roce_ext_reg_name *reg_name)); - - #endif /* __HIKP_ROCE_EXT_COMMON_H__ */ -diff --git a/net/roce/roce_global_cfg/hikp_roce_global_cfg.c b/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -index 49a4a2c..18df065 100644 ---- a/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -+++ b/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -@@ -40,7 +40,8 @@ static int hikp_roce_global_cfg_target(struct major_cmd_ctrl *self, - } - - static int hikp_roce_global_cfg_get_data(struct hikp_cmd_ret **cmd_ret, -- uint32_t block_id) -+ uint32_t block_id, -+ struct roce_ext_reg_name *reg_name) - { - struct hikp_cmd_header req_header = { 0 }; - struct roce_global_cfg_req_param req_data; -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.c b/net/roce/roce_mdb/hikp_roce_mdb.c -index b2b2c41..e811bec 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.c -+++ b/net/roce/roce_mdb/hikp_roce_mdb.c -@@ -74,6 +74,16 @@ static const char *g_mdb_reg_name[] = { - "MDB_STA_5", - }; - -+static const char *g_mdb_ext_reg_name[] = { -+ "ROCEE_EQDB_EXEC_CNT", -+ "MDB_STA_6", -+ "MDB_DFX_CNT_0", -+ "MDB_DFX_CNT_1", -+ "MDB_DFX_CNT_2", -+ "MDB_DFX_CNT_3", -+ "MDB_DFX_CNT_4", -+}; -+ - static void hikp_roce_mdb_print(uint32_t reg_num, struct roce_mdb_rsp_data *mdb_rsp) - { - uint8_t arr_len = HIKP_ARRAY_SIZE(g_mdb_reg_name); -@@ -89,13 +99,19 @@ static void hikp_roce_mdb_print(uint32_t reg_num, struct roce_mdb_rsp_data *mdb_ - } - - static int hikp_roce_mdb_get_data(struct hikp_cmd_ret **cmd_ret, -- uint32_t block_id) -+ uint32_t block_id, -+ struct roce_ext_reg_name *reg_name) - { - struct roce_mdb_req_param_ext req_data_ext; - struct hikp_cmd_header req_header = { 0 }; - uint32_t req_size; - int ret; - -+ if (reg_name) { -+ reg_name->reg_name = g_mdb_ext_reg_name; -+ reg_name->arr_len = HIKP_ARRAY_SIZE(g_mdb_ext_reg_name); -+ } -+ - req_data_ext.origin_param.bdf = g_roce_mdb_param.target.bdf; - req_data_ext.block_id = block_id; - -@@ -119,7 +135,7 @@ static void hikp_roce_mdb_execute_origin(struct major_cmd_ctrl *self) - struct hikp_cmd_ret *cmd_ret = NULL; - uint32_t reg_num; - -- self->err_no = hikp_roce_mdb_get_data(&cmd_ret, 0); -+ self->err_no = hikp_roce_mdb_get_data(&cmd_ret, 0, NULL); - if (self->err_no) { - printf("hikptool roce_mdb get data failed\n"); - goto exec_error; -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.c b/net/roce/roce_qmm/hikp_roce_qmm.c -index fa4e18a..9189f88 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.c -+++ b/net/roce/roce_qmm/hikp_roce_qmm.c -@@ -104,6 +104,40 @@ static const char *g_qmm_qpc_reg_name[] = { - "QPC_WQE_ECC_ERR", - }; - -+static const char *g_qmm_top_ext_reg_name[] = { -+ "ROCEE_QMM_SRQC_CACHE_RO", -+ "ROCEE_QMM_SRQC_DMAE_RO", -+ "ROCEE_QMM_SRQC_SRH_DFX", -+ "ROCEE_QMM_SRQC_SRH_REQ_RO", -+ "ROCEE_QMM_SRQC_RW_REQ_RO", -+ "ROCEE_QMM_MPT_CACHE_RO", -+ "ROCEE_QMM_MPT_DMAE_RO", -+ "ROCEE_QMM_MPT_SRH_DFX", -+ "ROCEE_QMM_MPT_SRH_REQ_RO", -+ "QPC_DMAE_INTF_RO", -+}; -+ -+static const char *g_qmm_cqc_ext_reg_name[] = { -+ "ROCEE_CQC_SRH_DFX_BK0", -+ "ROCEE_CQC_SRH_DFX_BK1", -+ "ROCEE_CQC_EMPTY_RD", -+ "ROCEE_CQC_FULL_WR", -+ "ROCEE_CQC_CACHE_RO_BK0", -+ "ROCEE_CQC_CACHE_RO_BK1", -+ "ROCEE_CQC_DMAE_RO", -+}; -+ -+static const char *g_qmm_qpc_ext_reg_name[] = { -+ "ROCEE_QPC_SRH_DFX_0", -+ "ROCEE_QPC_SRH_DFX_1", -+ "ROCEE_QPC_SRH_REQ_RO_0", -+ "ROCEE_QPC_SRH_REQ_RO_1", -+ "ROCEE_QMM_QPC_CACHE_RO_0", -+ "ROCEE_QMM_QPC_CACHE_RO_0", -+ "QMM_WQE_CACHE_RO", -+ "IRRL_CACHE_RO", -+}; -+ - static const struct reg_name_info { - enum roce_qmm_cmd_type sub_cmd; - const char **reg_name; -@@ -112,6 +146,9 @@ static const struct reg_name_info { - {QMM_SHOW_CQC, g_qmm_cqc_reg_name, HIKP_ARRAY_SIZE(g_qmm_cqc_reg_name)}, - {QMM_SHOW_QPC, g_qmm_qpc_reg_name, HIKP_ARRAY_SIZE(g_qmm_qpc_reg_name)}, - {QMM_SHOW_TOP, g_qmm_top_reg_name, HIKP_ARRAY_SIZE(g_qmm_top_reg_name)}, -+ {QMM_SHOW_CQC_EXT, g_qmm_cqc_ext_reg_name, HIKP_ARRAY_SIZE(g_qmm_cqc_ext_reg_name)}, -+ {QMM_SHOW_QPC_EXT, g_qmm_qpc_ext_reg_name, HIKP_ARRAY_SIZE(g_qmm_qpc_ext_reg_name)}, -+ {QMM_SHOW_TOP_EXT, g_qmm_top_ext_reg_name, HIKP_ARRAY_SIZE(g_qmm_top_ext_reg_name)}, - }; - - static void hikp_roce_qmm_print(struct roce_qmm_rsp_data *qmm_rsp) -@@ -149,12 +186,26 @@ static void hikp_roce_qmm_print(struct roce_qmm_rsp_data *qmm_rsp) - } - - static int hikp_roce_qmm_get_data(struct hikp_cmd_ret **cmd_ret, -- uint32_t block_id) -+ uint32_t block_id, -+ struct roce_ext_reg_name *reg_name) - { - struct roce_qmm_req_para_ext req_data_ext; - struct hikp_cmd_header req_header = { 0 }; - uint32_t req_size; -- int ret; -+ int ret, i; -+ -+ if (reg_name) { -+ for (i = 0; i < HIKP_ARRAY_SIZE(g_qmm_reg_name_info_table); i++) { -+ if (g_qmm_reg_name_info_table[i].sub_cmd != g_roce_qmm_param.sub_cmd) -+ continue; -+ reg_name->arr_len = g_qmm_reg_name_info_table[i].arr_len; -+ reg_name->reg_name = g_qmm_reg_name_info_table[i].reg_name; -+ break; -+ } -+ -+ if (i == HIKP_ARRAY_SIZE(g_qmm_reg_name_info_table)) -+ return -EINVAL; -+ } - - req_data_ext.origin_param.bdf = g_roce_qmm_param.target.bdf; - req_data_ext.origin_param.bank_id = g_roce_qmm_param.bank_id; -@@ -179,7 +230,7 @@ static void hikp_roce_qmm_execute_origin(struct major_cmd_ctrl *self) - struct roce_qmm_rsp_data *roce_qmm_res; - struct hikp_cmd_ret *cmd_ret; - -- self->err_no = hikp_roce_qmm_get_data(&cmd_ret, 0); -+ self->err_no = hikp_roce_qmm_get_data(&cmd_ret, 0, NULL); - if (self->err_no) { - printf("hikptool roce_qmm get data failed.\n"); - goto exec_error; -diff --git a/net/roce/roce_rst/hikp_roce_rst.c b/net/roce/roce_rst/hikp_roce_rst.c -index ad4dd0c..570e7f4 100644 ---- a/net/roce/roce_rst/hikp_roce_rst.c -+++ b/net/roce/roce_rst/hikp_roce_rst.c -@@ -37,7 +37,8 @@ static int hikp_roce_rst_target(struct major_cmd_ctrl *self, const char *argv) - } - - static int hikp_roce_rst_get_data(struct hikp_cmd_ret **cmd_ret, -- uint32_t block_id) -+ uint32_t block_id, -+ struct roce_ext_reg_name *reg_name) - { - struct hikp_cmd_header req_header = { 0 }; - struct roce_rst_req_param req_data; --- -2.45.0.windows.1 - diff --git a/0065-hikptool-roce-Fix-the-validation-check-of-cur_block_.patch b/0065-hikptool-roce-Fix-the-validation-check-of-cur_block_.patch deleted file mode 100644 index 50861bda15cf5167be7bb9d46cff9b81e93cc586..0000000000000000000000000000000000000000 --- a/0065-hikptool-roce-Fix-the-validation-check-of-cur_block_.patch +++ /dev/null @@ -1,70 +0,0 @@ -From a5846b63d1f987242bd33a563c15d91dbdcd8273 Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Mon, 5 Aug 2024 19:39:12 +0800 -Subject: [PATCH 03/27] hikptool/roce: Fix the validation check of - cur_block_num - -hikp_roce_ext_get_res() will be called multiple times within a loop, -and each time the remaining space of register array will become less. -So the cur_block_num from FW should be check against remaining block -number, but not the total one. - -Fixes: 8b3b68347165 ("hikptool/roce: Add a common frame for hikptool roce register query") -Signed-off-by: Junxian Huang ---- - net/roce/roce_ext_common/hikp_roce_ext_common.c | 15 ++++++++------- - 1 file changed, 8 insertions(+), 7 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 c22303f..e90720c 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -101,7 +101,7 @@ 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 max_size; -+ uint32_t remain_block; - size_t cur_size; - int ret; - -@@ -119,29 +119,30 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - - roce_ext_res = (struct roce_ext_res_param *)cmd_ret->rsp_data; - *res_head = roce_ext_res->head; -- max_size = res_head->total_block_num * sizeof(uint32_t); - - if (block_id == 0) { - 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)); - if ((reg->offset == NULL) || (reg->data == NULL)) { - printf("hikptool roce_%s alloc log memmory 0x%zx failed!\n", -- cmd_name, max_size); -+ cmd_name, res_head->total_block_num * sizeof(uint32_t)); - ret = -ENOMEM; - hikp_roce_ext_reg_data_free(reg); - goto get_data_error; - } - } - -- cur_size = res_head->cur_block_num * sizeof(uint32_t); -- if (!cur_size || cur_size > max_size) { -- printf("hikptool roce_%s log data copy size error, data size: 0x%zx, max size: 0x%zx\n", -- cmd_name, cur_size, max_size); -+ remain_block = res_head->total_block_num - block_id; -+ if (!res_head->cur_block_num || res_head->cur_block_num > remain_block) { -+ printf("hikptool roce_%s block size error, cur: %u, total: %u, remain: %u.\n", -+ cmd_name, res_head->cur_block_num, -+ res_head->total_block_num, remain_block); - ret = -EINVAL; - hikp_roce_ext_reg_data_free(reg); - goto get_data_error; - } - -+ cur_size = res_head->cur_block_num * sizeof(uint32_t); - memcpy(reg->offset + block_id, - (uint32_t *)&roce_ext_res->reg_data, cur_size); - memcpy(reg->data + block_id, --- -2.45.0.windows.1 - diff --git a/0066-hikptool-roce-Fix-redundant-update-of-total_block_nu.patch b/0066-hikptool-roce-Fix-redundant-update-of-total_block_nu.patch deleted file mode 100644 index 23137e9745ddd8cf84aea0f531ae08f9749a44cd..0000000000000000000000000000000000000000 --- a/0066-hikptool-roce-Fix-redundant-update-of-total_block_nu.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 53a9e2244b16196681e96a1cbaf9e23eef22f56d Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Mon, 5 Aug 2024 19:47:31 +0800 -Subject: [PATCH 04/27] hikptool/roce: Fix redundant update of total_block_num - -total_block_num needs to be updated only in the first loop of query, -and should stay constant from then on. Otherwise there may be -out-of-bound accessing problems if subsequent update value from FW -is larger than the first one, with which the memory of the register -array is allocated. - -Fixes: 8b3b68347165 ("hikptool/roce: Add a common frame for hikptool roce register query") -Signed-off-by: Junxian Huang ---- - net/roce/roce_ext_common/hikp_roce_ext_common.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -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 e90720c..049b64a 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -118,9 +118,10 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - } - - roce_ext_res = (struct roce_ext_res_param *)cmd_ret->rsp_data; -- *res_head = roce_ext_res->head; -+ res_head->cur_block_num = roce_ext_res->head.cur_block_num; - - if (block_id == 0) { -+ res_head->total_block_num = roce_ext_res->head.total_block_num; - 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)); - if ((reg->offset == NULL) || (reg->data == NULL)) { --- -2.45.0.windows.1 - diff --git a/0067-hikptool-roce-Add-check-for-total_block_num-from-FW.patch b/0067-hikptool-roce-Add-check-for-total_block_num-from-FW.patch deleted file mode 100644 index b46a7cc592890a79bd953931eeb144d86ecb5897..0000000000000000000000000000000000000000 --- a/0067-hikptool-roce-Add-check-for-total_block_num-from-FW.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 31b9eb2f181ff9275ccbba787a8c1f991a70f69d Mon Sep 17 00:00:00 2001 -From: Junxian Huang -Date: Mon, 5 Aug 2024 19:59:19 +0800 -Subject: [PATCH 05/27] hikptool/roce: Add check for total_block_num from FW - -total_block_num is used to allocate memory for register array. -Check whether it is 0 to prevent calloc() error. - -Fixes: 8b3b68347165 ("hikptool/roce: Add a common frame for hikptool roce register query") -Signed-off-by: Junxian Huang ---- - net/roce/roce_ext_common/hikp_roce_ext_common.c | 6 ++++++ - net/roce/roce_scc/hikp_roce_scc.c | 6 ++++++ - net/roce/roce_trp/hikp_roce_trp.c | 6 ++++++ - 3 files changed, 18 insertions(+) - -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 049b64a..bc3b883 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -122,6 +122,12 @@ 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; -+ if (!res_head->total_block_num) { -+ printf("hikptool roce_%s total_block_num error!\n", -+ cmd_name); -+ ret = -EINVAL; -+ 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)); - if ((reg->offset == NULL) || (reg->data == NULL)) { -diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c -index 76c0ca6..0ecb8cf 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.c -+++ b/net/roce/roce_scc/hikp_roce_scc.c -@@ -146,6 +146,12 @@ static int hikp_roce_scc_get_total_data_num(struct roce_scc_head *res_head, - } - - roce_scc_res = (struct roce_scc_res_param *)cmd_ret->rsp_data; -+ if (!roce_scc_res->head.total_block_num) { -+ printf("hikptool roce_scc total_block_num error!\n"); -+ ret = -EINVAL; -+ goto get_data_error; -+ } -+ - max_size = roce_scc_res->head.total_block_num * sizeof(uint32_t); - *offset = (uint32_t *)calloc(1, max_size); - *data = (uint32_t *)calloc(1, max_size); -diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c -index 61f0511..486bbe3 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.c -+++ b/net/roce/roce_trp/hikp_roce_trp.c -@@ -166,6 +166,12 @@ static int hikp_roce_trp_get_total_data_num(struct roce_trp_head *res_head, - } - - roce_trp_res = (struct roce_trp_res_param *)cmd_ret->rsp_data; -+ if (!roce_trp_res->head.total_block_num) { -+ printf("hikptool roce_trp total_block_num error!\n"); -+ ret = -EINVAL; -+ goto get_data_error; -+ } -+ - max_size = roce_trp_res->head.total_block_num * sizeof(uint32_t); - *offset = (uint32_t *)calloc(1, max_size); - *data = (uint32_t *)calloc(1, max_size); --- -2.45.0.windows.1 - diff --git a/0068-hikptool-Resolve-the-review-problems-found-in-the-R-.patch b/0068-hikptool-Resolve-the-review-problems-found-in-the-R-.patch deleted file mode 100644 index 9e663f769850e38a26e4c65fc1e591efcbbdcccf..0000000000000000000000000000000000000000 --- a/0068-hikptool-Resolve-the-review-problems-found-in-the-R-.patch +++ /dev/null @@ -1,1376 +0,0 @@ -From 023d3890ce1ba9bd9b4ce5f2f1f2a60a8219e015 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Tue, 12 Nov 2024 17:58:25 +0800 -Subject: [PATCH 06/27] hikptool: Resolve the review problems found in the R&D - self-check. - -Code review comments are rectified. - -Signed-off-by: veega2022 ---- - cxl/func_lib/cxl_func/cxl_feature.c | 12 ++- - cxl/func_lib/cxl_func/cxl_feature.h | 1 + - hikp_init_main.c | 3 +- - libhikptdev/src/rciep/hikpt_rciep.c | 12 ++- - libhikptdev/src/rciep/hikpt_rciep.h | 1 + - net/nic/nic_mac/hikp_nic_xsfp.c | 8 ++ - net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c | 2 +- - net/nic/nic_ppp/hikp_nic_ppp.c | 8 +- - net/ub/ub_bp/hikp_ub_bp.c | 3 +- - net/ub/ub_crd/hikp_ub_crd.c | 6 +- - net/ub/ub_dfx/hikp_ub_dfx.c | 26 +++--- - net/ub/ub_ppp/hikp_unic_ppp.c | 54 +++++++++--- - net/ub/ub_ppp/hikp_unic_ppp.h | 2 +- - ossl/ossl_user_linux.c | 4 +- - pcie/func_lib/osal/os_common.c | 29 ------- - pcie/func_lib/osal/os_common.h | 22 ++--- - pcie/func_lib/pcie_func/pcie_link_ltssm.c | 87 +++++++++----------- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 24 +++--- - pcie/func_lib/pcie_func/pcie_reg_read.c | 6 +- - pcie/func_lib/pcie_func/pcie_statistics.c | 54 ++++++------ - pcie/usr_cmd/cmd_analysis/pcie_cmd_dumpreg.c | 2 +- - sas/sas_func/sas_analy_queue.c | 6 +- - sas/sas_func/sas_analy_queue.h | 2 + - sas/sas_func/sas_common.h | 4 + - sas/sas_func/sas_dump_reg.c | 2 +- - sas/sas_func/sas_read_dev.c | 4 +- - sas/sas_func/sas_read_dqe.c | 4 +- - sas/sas_func/sas_read_errcode.c | 16 ++-- - sata/sata_func/sata_dump_reg.c | 2 +- - tool_lib/op_logs.c | 14 ++-- - tool_lib/tool_lib.c | 12 +-- - 31 files changed, 226 insertions(+), 206 deletions(-) - delete mode 100644 pcie/func_lib/osal/os_common.c - -diff --git a/cxl/func_lib/cxl_func/cxl_feature.c b/cxl/func_lib/cxl_func/cxl_feature.c -index cd41b09..12fadbd 100644 ---- a/cxl/func_lib/cxl_func/cxl_feature.c -+++ b/cxl/func_lib/cxl_func/cxl_feature.c -@@ -342,7 +342,7 @@ int cxl_reg_show_execute(uint32_t port_id, uint32_t mode_code, uint32_t cmd_type - uint32_t i; - size_t data_unit_len; - struct hikp_cmd_header req_header; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - struct cxl_cmd_paras_in req_para; - struct cxl_out_data *data_head = NULL; - struct cxl_data_unit *data_unit_buf = NULL; -@@ -359,8 +359,14 @@ int cxl_reg_show_execute(uint32_t port_id, uint32_t mode_code, uint32_t cmd_type - return ret; - } - -+ if (cmd_ret->rsp_data_num < CXL_DATA_OFFSET) { -+ printf("cxl_cmd mode_code: %u cmd_type: %u," -+ "The value of rsp data num is less than 2, rsp data num: %u\n", -+ mode_code, cmd_type, cmd_ret->rsp_data_num); -+ free(cmd_ret); -+ return -EINVAL; -+ } - data_head = (struct cxl_out_data *)cmd_ret->rsp_data; -- data_unit_buf = (struct cxl_data_unit *)(cmd_ret->rsp_data + data_head->data_offset); - data_unit_len = data_head->length / sizeof(struct cxl_data_unit); - - ret = cxl_data_unit_buf_check(data_head->data_offset, data_unit_len, cmd_ret->rsp_data_num); -@@ -369,6 +375,8 @@ int cxl_reg_show_execute(uint32_t port_id, uint32_t mode_code, uint32_t cmd_type - return ret; - } - -+ data_unit_buf = (struct cxl_data_unit *)(cmd_ret->rsp_data + data_head->data_offset); -+ - for (i = 0; i < (sizeof(g_prtf) / sizeof((g_prtf)[0])); i++) { - if (mode_code == g_prtf[i].mode_code && - cmd_type == g_prtf[i].cmd_type && g_prtf[i].cxl_prt_handle) { -diff --git a/cxl/func_lib/cxl_func/cxl_feature.h b/cxl/func_lib/cxl_func/cxl_feature.h -index 4d30ebe..3ac6f75 100644 ---- a/cxl/func_lib/cxl_func/cxl_feature.h -+++ b/cxl/func_lib/cxl_func/cxl_feature.h -@@ -28,6 +28,7 @@ - #define CXL_HDM_CNT_EACH_PORT 2 - #define CXL_DATA_UNIT_SIZE 2 // reg addr + data - #define CXL_MEM_HEADER_LOG_UNIT 4 -+#define CXL_DATA_OFFSET 2 - - enum cxl_cmd_type { - CXL_CPA = 0, -diff --git a/hikp_init_main.c b/hikp_init_main.c -index 4629b40..e159ad9 100644 ---- a/hikp_init_main.c -+++ b/hikp_init_main.c -@@ -92,7 +92,8 @@ static int parse_and_init_cmd(const char *arg) - if (strnlen(cmd_ptr->name, MAX_CMD_LEN) != strnlen(arg, MAX_CMD_LEN)) - continue; - -- if (strncmp(arg, cmd_ptr->name, strnlen(cmd_ptr->name, MAX_CMD_LEN - 1) + 1) == 0) { -+ if ((strncmp(arg, cmd_ptr->name, -+ strnlen(cmd_ptr->name, MAX_CMD_LEN - 1) + 1) == 0) && cmd_ptr->cmd_init) { - g_tool.p_major_cmd.cmd_ptr = cmd_ptr; - cmd_ptr->cmd_init(); - return 0; -diff --git a/libhikptdev/src/rciep/hikpt_rciep.c b/libhikptdev/src/rciep/hikpt_rciep.c -index 75ec224..0210f3d 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.c -+++ b/libhikptdev/src/rciep/hikpt_rciep.c -@@ -208,8 +208,11 @@ static int hikp_multi_round_interact(struct hikp_cmd_ret **cmd_ret, uint32_t sta - return -EINVAL; - } - -- p_cmd_ret = (struct hikp_cmd_ret *)malloc(sizeof(struct hikp_cmd_ret) + -- rsp_num * REP_DATA_BLK_SIZE); -+ /* By default, the memory is applied for based on the supported maximum length. -+ * The memory buffer is converted into the corresponding data structure inside the module. -+ */ -+ p_cmd_ret = (struct hikp_cmd_ret *)calloc(1, -+ (sizeof(struct hikp_cmd_ret) + HIKP_RSP_DATA_SIZE_MAX)); - if (p_cmd_ret == NULL) { - printf("response memory malloc fail.\n"); - return -ENOMEM; -@@ -509,7 +512,8 @@ out_free_iep: - static void hikp_munmap(void) - { - g_unmap_flag = 1; -- munmap((void *)g_hikp_req, sizeof(union hikp_space_req)); -+ if (munmap((void *)g_hikp_req, sizeof(union hikp_space_req)) == -1) -+ printf("failed to munmap, errno %d.\n", errno); - g_hikp_req = NULL; - g_hikp_rsp = NULL; - } -@@ -538,7 +542,7 @@ int hikp_dev_init(void) - - g_hikp_req = (union hikp_space_req *)mmap(0, sizeof(union hikp_space_req), - PROT_READ | PROT_WRITE, MAP_SHARED, g_iep_fd, 0); -- if (!g_hikp_req) { -+ if (g_hikp_req == MAP_FAILED) { - printf("failed to mmap %s.\n", iep); - ret = -errno; - goto out_close_fd; -diff --git a/libhikptdev/src/rciep/hikpt_rciep.h b/libhikptdev/src/rciep/hikpt_rciep.h -index 296d235..c64e4dd 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.h -+++ b/libhikptdev/src/rciep/hikpt_rciep.h -@@ -43,6 +43,7 @@ - #define WAIT_CPL_MAX_MS 8000 - - #define REP_DATA_BLK_SIZE sizeof(uint32_t) -+#define HIKP_RSP_DATA_SIZE_MAX (HIKP_RSP_ALL_DATA_MAX * REP_DATA_BLK_SIZE) - - enum { - HIKP_RESOURCE_DIR, -diff --git a/net/nic/nic_mac/hikp_nic_xsfp.c b/net/nic/nic_mac/hikp_nic_xsfp.c -index 70ed589..a1294a8 100644 ---- a/net/nic/nic_mac/hikp_nic_xsfp.c -+++ b/net/nic/nic_mac/hikp_nic_xsfp.c -@@ -602,6 +602,14 @@ static int hikp_xsfp_get_raw_data(uint8_t *buf, uint32_t size, uint32_t blk_num) - return ret; - } - -+ if (cmd_resp->rsp_data_num == 0) { -+ HIKP_ERROR_PRINT("get eeprom data rsp_data_num %u error\n", -+ cmd_resp->rsp_data_num); -+ free(cmd_resp); -+ cmd_resp = NULL; -+ return -EINVAL; -+ } -+ - len = HIKP_MIN(left_size, (cmd_resp->rsp_data_num * sizeof(uint32_t))); - memcpy(buf + offset, (uint8_t *)(cmd_resp->rsp_data), len); - left_size -= len; -diff --git a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -index 307d336..56b8257 100644 ---- a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -+++ b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -@@ -74,7 +74,7 @@ static void hikp_nic_notify_pkt_show(const struct nic_notify_pkt_info *info) - static void hikp_nic_notify_pkt_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_notify_pkt_target.bdf; -- struct nic_notify_pkt_info info; -+ struct nic_notify_pkt_info info = {0}; - - self->err_no = hikp_nic_notify_pkt_query(self, bdf, &info); - if (self->err_no) -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index 7968ac3..4dbe8d6 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -129,9 +129,9 @@ static void hikp_nic_ppp_get_overflow_mac(struct nic_mac_tbl *of_tbl, struct nic - - static void hikp_nic_ppp_show_key_mem(struct nic_mac_tbl *tbl, bool is_key_mem) - { -+ char mac_str[HIKP_NIC_ETH_ADDR_FMT_SIZE] = {0}; - struct mac_vlan_uc_tbl *uc_tbl = &tbl->uc_tbl; - struct mac_vlan_mc_tbl *mc_tbl = &tbl->mc_tbl; -- char mac_str[HIKP_NIC_ETH_ADDR_FMT_SIZE]; - struct mac_vlan_uc_entry *uc_entry; - struct mac_vlan_mc_entry *mc_entry; - uint32_t idx; -@@ -178,7 +178,7 @@ static void hikp_nic_ppp_show_key_mem(struct nic_mac_tbl *tbl, bool is_key_mem) - static void hikp_nic_ppp_show_func_uc_mac_addr(struct mac_vlan_uc_tbl *uc_tbl, - const struct bdf_t *bdf, uint16_t func_id) - { -- char mac_str[HIKP_NIC_ETH_ADDR_FMT_SIZE]; -+ char mac_str[HIKP_NIC_ETH_ADDR_FMT_SIZE] = {0}; - struct mac_vlan_uc_entry *uc_entry; - uint8_t pf_id; - uint8_t vf_id; -@@ -202,7 +202,7 @@ static void hikp_nic_ppp_show_func_uc_mac_addr(struct mac_vlan_uc_tbl *uc_tbl, - static void hikp_nic_ppp_show_func_mc_mac_addr(struct mac_vlan_mc_tbl *mc_tbl, - const struct bdf_t *bdf, uint16_t func_id) - { -- char mac_str[HIKP_NIC_ETH_ADDR_FMT_SIZE]; -+ char mac_str[HIKP_NIC_ETH_ADDR_FMT_SIZE] = {0}; - struct mac_vlan_mc_entry *mc_entry; - uint16_t abs_func_id; - uint8_t offset; -@@ -394,7 +394,7 @@ static void hikp_nic_ppp_show_vlan_tbl(const void *data) - static void hikp_nic_ppp_show_manager_tbl(const void *data) - { - struct nic_mng_tbl *tbl = (struct nic_mng_tbl *)data; -- char mac_str[HIKP_NIC_ETH_ADDR_FMT_SIZE]; -+ char mac_str[HIKP_NIC_ETH_ADDR_FMT_SIZE] = {0}; - struct manager_entry *entry; - uint32_t i; - -diff --git a/net/ub/ub_bp/hikp_ub_bp.c b/net/ub/ub_bp/hikp_ub_bp.c -index 70a9a4b..f5f50ff 100644 ---- a/net/ub/ub_bp/hikp_ub_bp.c -+++ b/net/ub/ub_bp/hikp_ub_bp.c -@@ -41,7 +41,7 @@ static void hikp_ub_bp_info_show(const struct ub_bp_rsp *info) - { - int bp_val_offset; - -- printf("%-28s : %u\n", "mac id", info->mac_id); -+ printf("%-28s : %hhu\n", "mac id", info->mac_id); - printf("%-28s : ", "back pressure status"); - - for (bp_val_offset = MAX_VL_NUM; bp_val_offset >= 0; bp_val_offset--) { -@@ -50,7 +50,6 @@ static void hikp_ub_bp_info_show(const struct ub_bp_rsp *info) - printf("\n"); - } - -- - static int hikp_ub_query_bp(const struct bdf_t *bdf) - { - struct hikp_cmd_header header = { 0 }; -diff --git a/net/ub/ub_crd/hikp_ub_crd.c b/net/ub/ub_crd/hikp_ub_crd.c -index 0e47b5b..91e1cb7 100644 ---- a/net/ub/ub_crd/hikp_ub_crd.c -+++ b/net/ub/ub_crd/hikp_ub_crd.c -@@ -37,8 +37,8 @@ static int hikp_ub_crd_target(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - --static int hikp_ub_show_crd(uint32_t off, struct ub_crd_rsp *crd_rsp, uint32_t num_rows, -- char const *crds[][2]) -+static uint32_t hikp_ub_show_crd(uint32_t off, struct ub_crd_rsp *crd_rsp, uint32_t num_rows, -+ char const *crds[][2]) - { - int reg_index; - int i; -@@ -63,7 +63,7 @@ static int hikp_ub_query_crd(void) - struct ub_crd_req_para req_data = { 0 }; - struct hikp_cmd_ret *cmd_ret = NULL; - struct ub_crd_rsp *crd_rsp = NULL; -- int offset; -+ uint32_t offset; - - char const *init_crds[][2] = { - {"CFG_REMOTE_ICRD", "CFG_REMOTE_LCRD"}, -diff --git a/net/ub/ub_dfx/hikp_ub_dfx.c b/net/ub/ub_dfx/hikp_ub_dfx.c -index c50f555..00205fe 100644 ---- a/net/ub/ub_dfx/hikp_ub_dfx.c -+++ b/net/ub/ub_dfx/hikp_ub_dfx.c -@@ -13,6 +13,7 @@ - - #include "tool_cmd.h" - #include "hikp_net_lib.h" -+#include "hikpt_rciep.h" - #include "hikp_ub_dfx.h" - - struct ub_dfx_param g_ub_dfx_param = { 0 }; -@@ -100,6 +101,7 @@ static int hikp_ub_get_first_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t - { - struct ub_dfx_rsp *dfx_rsp = NULL; - struct hikp_cmd_ret *cmd_ret; -+ uint32_t rsp_data_size; - int ret; - - ret = hikp_ub_dfx_get_blk_data(&cmd_ret, 0, g_ub_dfx_param.sub_cmd_code); -@@ -122,11 +124,13 @@ static int hikp_ub_get_first_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t - goto err_out; - } - -- if (rsp_head->cur_blk_size > *max_dfx_size) { -+ rsp_data_size = cmd_ret->rsp_data_num * REP_DATA_BLK_SIZE; -+ if (rsp_data_size - sizeof(dfx_rsp->rsp_head) < rsp_head->cur_blk_size || -+ *max_dfx_size < rsp_head->cur_blk_size) { -+ HIKP_ERROR_PRINT("blk0 reg_data copy size error, rsp data size: %u, data size: %hhu, max size: %u\n", -+ rsp_data_size, rsp_head->cur_blk_size, *max_dfx_size); - free(*reg_data); - *reg_data = NULL; -- HIKP_ERROR_PRINT("blk0 reg_data copy size error, data size: 0x%x, max size: 0x%x\n", -- rsp_head->cur_blk_size, *max_dfx_size); - ret = -EINVAL; - goto err_out; - } -@@ -145,6 +149,7 @@ static int hikp_ub_get_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t blk_id - { - struct ub_dfx_rsp *dfx_rsp = NULL; - struct hikp_cmd_ret *cmd_ret; -+ uint32_t rsp_data_size; - int ret; - - ret = hikp_ub_dfx_get_blk_data(&cmd_ret, blk_id, g_ub_dfx_param.sub_cmd_code); -@@ -153,10 +158,11 @@ static int hikp_ub_get_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t blk_id - - dfx_rsp = (struct ub_dfx_rsp *)(cmd_ret->rsp_data); - *rsp_head = dfx_rsp->rsp_head; -- if (rsp_head->cur_blk_size > *max_dfx_size) { -- HIKP_ERROR_PRINT("blk%u reg_data copy size error, " -- "data size: 0x%x, max size: 0x%x\n", -- blk_id, rsp_head->cur_blk_size, *max_dfx_size); -+ rsp_data_size = cmd_ret->rsp_data_num * REP_DATA_BLK_SIZE; -+ if (rsp_data_size - sizeof(dfx_rsp->rsp_head) < rsp_head->cur_blk_size || -+ rsp_head->cur_blk_size > *max_dfx_size) { -+ HIKP_ERROR_PRINT("blk%u reg_data copy size error, rsp data size: %u, data size: %hhu, max size: %u\n", -+ blk_id, rsp_data_size, rsp_head->cur_blk_size, *max_dfx_size); - ret = -EINVAL; - goto err_out; - } -@@ -194,7 +200,7 @@ static void hikp_ub_dfx_print_type_head(uint8_t type_id, uint8_t *last_type_id) - if (is_type_found(type_id, &index)) - printf("type name: %s\n\n", g_dfx_type_parse[index].type_name); - else -- HIKP_WARN_PRINT("type name: unknown type, type id is %u\n\n", type_id); -+ HIKP_WARN_PRINT("type name: unknown type, type id is %hhu\n\n", type_id); - - *last_type_id = type_id; - } -@@ -244,7 +250,7 @@ static void hikp_ub_dfx_print(const struct ub_dfx_rsp_head *rsp_head, uint32_t * - for (i = 0; i < rsp_head->total_type_num; i++) { - type_head = (struct ub_dfx_type_head *)ptr; - if (type_head->type_id == INCORRECT_REG_TYPE) { -- HIKP_ERROR_PRINT("No.%u type is incorrect reg type\n", i + 1u); -+ HIKP_ERROR_PRINT("No.%u type is incorrect reg type\n", (uint32_t)(i + 1u)); - break; - } - hikp_ub_dfx_print_type_head(type_head->type_id, &last_type_id); -@@ -254,7 +260,7 @@ static void hikp_ub_dfx_print(const struct ub_dfx_rsp_head *rsp_head, uint32_t * - } else if (type_head->bit_width == WIDTH_64_BIT) { - hikp_ub_dfx_print_b64((uint32_t)type_head->reg_num, ptr); - } else { -- HIKP_ERROR_PRINT("type%u's bit width error.\n", type_head->type_id); -+ HIKP_ERROR_PRINT("type%hhu's bit width error.\n", type_head->type_id); - break; - } - ptr += (uint32_t)type_head->reg_num * WORD_NUM_PER_REG; -diff --git a/net/ub/ub_ppp/hikp_unic_ppp.c b/net/ub/ub_ppp/hikp_unic_ppp.c -index bf0c026..2164f04 100644 ---- a/net/ub/ub_ppp/hikp_unic_ppp.c -+++ b/net/ub/ub_ppp/hikp_unic_ppp.c -@@ -16,6 +16,7 @@ - #include - #include - #include -+#include "hikpt_rciep.h" - #include "hikp_unic_ppp.h" - - static struct hikp_unic_ppp_hw_resources g_unic_ppp_hw_res = { 0 }; -@@ -86,6 +87,7 @@ static int hikp_unic_ppp_get_blk(struct hikp_cmd_header *req_header, - { - struct hikp_cmd_ret *cmd_ret; - struct unic_ppp_rsp *rsp; -+ uint32_t rsp_data_size; - int ret = 0; - - cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data)); -@@ -95,10 +97,11 @@ static int hikp_unic_ppp_get_blk(struct hikp_cmd_header *req_header, - } - - rsp = (struct unic_ppp_rsp *)cmd_ret->rsp_data; -- if (rsp->rsp_head.cur_blk_size > buf_len) { -- HIKP_ERROR_PRINT("unic_ppp block context copy size error, " -- "buffer size=%llu, data size=%u.\n", -- buf_len, rsp->rsp_head.cur_blk_size); -+ rsp_data_size = cmd_ret->rsp_data_num * REP_DATA_BLK_SIZE; -+ if (rsp_data_size - sizeof(rsp->rsp_head) < rsp->rsp_head.cur_blk_size || -+ buf_len < rsp->rsp_head.cur_blk_size) { -+ HIKP_ERROR_PRINT("block context copy size error, data size: %u, buffer size: %zu, blk size: %hhu.\n", -+ rsp_data_size, buf_len, rsp->rsp_head.cur_blk_size); - ret = -EINVAL; - goto out; - } -@@ -123,17 +126,24 @@ static int hikp_unic_query_ppp_by_blkid(struct hikp_cmd_header *req_header, cons - req_data.block_id = blk_id; - ret = hikp_unic_ppp_get_blk(req_header, &req_data, data, len, &rsp_head); - if (ret != 0) { -- HIKP_ERROR_PRINT("Fail to get block-%u context.\n", blk_id); -+ HIKP_ERROR_PRINT("Fail to get block-%hhu context.\n", blk_id); - return ret; - } - total_blk_size = rsp_head.cur_blk_size; - - for (blk_id = 1; blk_id < rsp_head.total_blk_num; blk_id++) { - req_data.block_id = blk_id; -+ if (len < total_blk_size) { -+ HIKP_ERROR_PRINT("block-%hhu invalid total blk size, " -+ "len: %zu, total blk size: %u", -+ blk_id, len, total_blk_size); -+ return -EINVAL; -+ } -+ - ret = hikp_unic_ppp_get_blk(req_header, &req_data, (uint8_t *)data + total_blk_size, - len - total_blk_size, &rsp_head); - if (ret != 0) { -- HIKP_ERROR_PRINT("Fail to get block-%u context.\n", blk_id); -+ HIKP_ERROR_PRINT("Fail to get block-%hhu context.\n", blk_id); - return ret; - } - total_blk_size += rsp_head.cur_blk_size; -@@ -175,7 +185,7 @@ static int hikp_unic_ppp_alloc_ip_tbl_entry(const struct hikp_unic_ppp_hw_resour - static int hikp_unic_ppp_alloc_guid_tbl_entry(const struct hikp_unic_ppp_hw_resources *hw_res, - struct unic_guid_tbl *guid_tbl) - { -- if (hw_res->uc_guid_tbl_size == 0 && hw_res->mc_guid_tbl_size == 0) { -+ if (hw_res->uc_guid_tbl_size == 0 || hw_res->mc_guid_tbl_size == 0) { - HIKP_ERROR_PRINT("guid tbl query is not supported\n"); - return -EIO; - } -@@ -243,6 +253,12 @@ static int hikp_unic_query_ppp_ip_tbl(struct hikp_cmd_header *req_header, const - max_ip_entry_size = g_unic_ppp_hw_res.ip_max_mem_size + g_unic_ppp_hw_res.ip_overflow_size; - req_data.bdf = *bdf; - while (index < max_ip_entry_size) { -+ if (max_ip_entry_size < entry_size) { -+ HIKP_ERROR_PRINT("invalid ip table entry size, max entry size: %u, entry size: %u\n", -+ max_ip_entry_size, entry_size); -+ return -EINVAL; -+ } -+ - req_data.cur_entry_idx = index; - left_buf_len = sizeof(struct unic_ip_entry) * (max_ip_entry_size - entry_size); - ret = hikp_unic_ppp_get_blk(req_header, &req_data, ip_tbl->entry + entry_size, -@@ -268,15 +284,22 @@ static int hikp_unic_query_ppp_guid_tbl(struct hikp_cmd_header *req_header, - struct unic_ppp_req_para req_data = { 0 }; - uint32_t entry_size = 0; - size_t left_buf_len = 0; -+ uint32_t guid_tbl_size; - uint32_t index = 0; - int ret = -1; - - req_data.bdf = *bdf; - req_data.is_unicast = 1; -- while (index < g_unic_ppp_hw_res.uc_guid_tbl_size) { -+ guid_tbl_size = g_unic_ppp_hw_res.uc_guid_tbl_size; -+ while (index < guid_tbl_size) { -+ if (guid_tbl_size < entry_size) { -+ HIKP_ERROR_PRINT("invalid uc guid table entry size, uc guid tbl size: %u, entry size: %u\n", -+ guid_tbl_size, entry_size); -+ return -EINVAL; -+ } -+ - req_data.cur_entry_idx = index; -- left_buf_len = sizeof(struct unic_guid_uc_entry) * -- (g_unic_ppp_hw_res.uc_guid_tbl_size - entry_size); -+ left_buf_len = sizeof(struct unic_guid_uc_entry) * (guid_tbl_size - entry_size); - ret = hikp_unic_ppp_get_blk(req_header, &req_data, - guid_tbl->uc_tbl.entry + entry_size, - left_buf_len, &unic_rsp_head); -@@ -294,11 +317,16 @@ static int hikp_unic_query_ppp_guid_tbl(struct hikp_cmd_header *req_header, - entry_size = 0; - index = 0; - req_data.is_unicast = 0; -+ guid_tbl_size = g_unic_ppp_hw_res.mc_guid_tbl_size; -+ while (index < guid_tbl_size) { -+ if (guid_tbl_size < entry_size) { -+ HIKP_ERROR_PRINT("invalid mc guid table entry size, mc guid tbl size: %u, entry size: %u\n", -+ guid_tbl_size, entry_size); -+ return -EINVAL; -+ } - -- while (index < g_unic_ppp_hw_res.mc_guid_tbl_size) { - req_data.cur_entry_idx = index; -- left_buf_len = sizeof(struct unic_guid_mc_entry) * -- (g_unic_ppp_hw_res.mc_guid_tbl_size - entry_size); -+ left_buf_len = sizeof(struct unic_guid_mc_entry) * (guid_tbl_size - entry_size); - ret = hikp_unic_ppp_get_blk(req_header, &req_data, - guid_tbl->mc_tbl.entry + entry_size, - left_buf_len, &unic_rsp_head); -diff --git a/net/ub/ub_ppp/hikp_unic_ppp.h b/net/ub/ub_ppp/hikp_unic_ppp.h -index c25fabd..0771415 100644 ---- a/net/ub/ub_ppp/hikp_unic_ppp.h -+++ b/net/ub/ub_ppp/hikp_unic_ppp.h -@@ -19,7 +19,7 @@ - #define HIKP_UNIC_IP_ADDR_FMT_SIZE 50 - #define MAX_IP_ADDR_STR_LEN 50 - #define IP_ADDR_LEN 16 --#define IP_ADDR_TBL_LEN 8 -+#define IP_ADDR_TBL_LEN 8 - - #define HIKP_UNIC_IP_ADDR_LEN 4 - #define HIKP_UNIC_GUID_BITMAP_LEN 8 -diff --git a/ossl/ossl_user_linux.c b/ossl/ossl_user_linux.c -index 9dee61c..a369c68 100644 ---- a/ossl/ossl_user_linux.c -+++ b/ossl/ossl_user_linux.c -@@ -26,7 +26,7 @@ int uda_access(const char *file_dir) - { - char path[PATH_MAX + 1] = { 0 }; - -- if (strlen(file_dir) > PATH_MAX || realpath(file_dir, path) == NULL) -+ if (file_dir == NULL || strlen(file_dir) > PATH_MAX || realpath(file_dir, path) == NULL) - return -ENOENT; - - return faccessat(AT_FDCWD, path, F_OK, AT_EACCESS) ? (-ENOENT) : 0; -@@ -53,7 +53,7 @@ int uda_fcntl(const char *lock_file, uint32_t operation, int *fd) - if ((fd == NULL) || (lock_file == NULL)) - return -EFAULT; - -- fd_t = open(lock_file, O_WRONLY | O_CREAT, 0700); -+ fd_t = open(lock_file, O_WRONLY | O_CREAT, 0600); - if (fd_t < 0) - return -errno; - -diff --git a/pcie/func_lib/osal/os_common.c b/pcie/func_lib/osal/os_common.c -deleted file mode 100644 -index 3ebf10c..0000000 ---- a/pcie/func_lib/osal/os_common.c -+++ /dev/null -@@ -1,29 +0,0 @@ --/* -- * Copyright (c) 2022 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 --#include --#include "os_common.h" -- --void hilog(int pri, const char *module, const char *fun, int line, const char *fmt, ...) --{ -- va_list ap; -- (void)pri; -- (void)module; -- (void)fun; -- (void)line; -- -- va_start(ap, fmt); -- (void)vprintf(fmt, ap); -- va_end(ap); --} -diff --git a/pcie/func_lib/osal/os_common.h b/pcie/func_lib/osal/os_common.h -index 480202c..de2a517 100644 ---- a/pcie/func_lib/osal/os_common.h -+++ b/pcie/func_lib/osal/os_common.h -@@ -14,28 +14,16 @@ - #ifndef _OS_COMMON_H_ - #define _OS_COMMON_H_ - --enum { -- HW_LOG_TIPS = 0, -- HW_LOG_DBG, -- HW_LOG_INFO, -- HW_LOG_WARN, -- HW_LOG_ERR --}; -- - #define LOG_PCIE "[PCIE]" - --void hilog(int pri, const char *module, const char *fun, int line, const char *fmt, ...); -- --#define Log(pri, module, fmt, args...) hilog(pri, module, __func__, __LINE__, fmt, ##args) -- --#define Err(module, fmt, args...) hilog(HW_LOG_ERR, module, __func__, __LINE__, fmt, ##args) -+#define Info(x, args...) printf(x, ##args) - --#define Warn(module, fmt, args...) hilog(HW_LOG_WARN, module, __func__, __LINE__, fmt, ##args) -+#define Err(x, args...) Info("[ ERROE ] " x, ##args) - --#define Info(module, fmt, args...) hilog(HW_LOG_INFO, module, __func__, __LINE__, fmt, ##args) -+#define Warn(x, args...) Info("[ WARN ] " x, ##args) - --#define Debug(module, fmt, args...) hilog(HW_LOG_DBG, module, __func__, __LINE__, fmt, ##args) -+#define Debug(x, args...) Info("[ DEBUG ] " x, ##args) - --#define Tips(module, fmt, args...) hilog(HW_LOG_TIPS, module, __func__, __LINE__, fmt, ##args) -+#define Tips(x, args...) Info("[ TIPS ] " x, ##args) - - #endif -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.c b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -index 66226e0..5834612 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.c -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -@@ -81,37 +81,36 @@ static int pcie_get_ltssm_trace(uint32_t port_id, uint64_t *ltssm_status, uint32 - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - ret = hikp_rsp_normal_check(cmd_ret); - if (ret) { -- Err("PCIe Base", "pcie trace cmd_ret check failed, ret: %d.\n", ret); -+ Err("pcie trace cmd_ret check failed, ret: %d.\n", ret); - goto free_cmd_ret; - } - - if (cmd_ret->rsp_data_num == 0) { -- Err("PCIe Base", "without rsp data.\n"); -+ Err("without rsp data.\n"); - ret = -EINVAL; - goto free_cmd_ret; - } - /* 0: First uint32_t is ltssm trace num received from TF */ - *ltssm_num = cmd_ret->rsp_data[0]; -- -- if ((cmd_ret->rsp_data_num - 1) * sizeof(uint32_t) != (*ltssm_num) * sizeof(uint64_t)) { -- Err("PCIe Base", "rsp data number check failed, rsp_data_num: %u, ltssm_num: %u.\n", -- cmd_ret->rsp_data_num, *ltssm_num); -+ src_size = (*ltssm_num) * sizeof(uint64_t); -+ dst_size = TRACER_DEPTH * sizeof(uint64_t); -+ if (src_size > dst_size) { -+ Err("size check failed, %u > %u.\n", src_size, dst_size); - ret = -EINVAL; - goto free_cmd_ret; - } - -- src_size = (*ltssm_num) * sizeof(uint64_t); -- dst_size = TRACER_DEPTH * sizeof(uint64_t); -- if (src_size > dst_size) { -- Err("PCIe Base", "size check failed, %u > %u.\n", src_size, dst_size); -+ if ((cmd_ret->rsp_data_num - 1) * sizeof(uint32_t) != (*ltssm_num) * sizeof(uint64_t)) { -+ Err("rsp data number check failed, rsp_data_num: %u, ltssm_num: %u.\n", -+ cmd_ret->rsp_data_num, *ltssm_num); - ret = -EINVAL; - goto free_cmd_ret; - } -+ - memcpy(ltssm_status, (cmd_ret->rsp_data + 1), src_size); - - free_cmd_ret: - free(cmd_ret); -- - return ret; - } - -@@ -184,19 +183,17 @@ static int pcie_print_ltssm_trace(const uint64_t *ltssm_input, uint32_t ltssm_nu - union ltssm_state_reg ltssm_val; - - if (ltssm_num > TRACER_DEPTH || ltssm_num == 0) { -- Err("PCIe Base", "ltssm_num(%u) is over range or zero\n", ltssm_num); -+ Err("ltssm_num(%u) is over range or zero\n", ltssm_num); - return -EINVAL; - } -- Info("PCIe Base", "ltssm tracer:\n"); -- Info("PCIe Base", "\ttrace mode: %llx\n", *ltssm_input); -- Info("PCIe Base", -- "\tltssm[ii]: 63:48 47:32 31 30 29 28 27 26 25 24 23 22 21:" -+ Info("ltssm tracer:\n"); -+ Info("\ttrace mode: %llx\n", *ltssm_input); -+ Info("\tltssm[ii]: 63:48 47:32 31 30 29 28 27 26 25 24 23 22 21:" - "20 19:12 11:10 9:6 5:0 ltssm\n"); - for (i = 1; i < ltssm_num; i++) { - ltssm_val.val = ltssm_input[i]; - ltssm_c = hisi_pcie_ltssm_string_get((uint32_t)ltssm_val.bits.ltssm_state); -- Info("PCIe Base", -- "\tltssm[%02u]: 0x%04x %04x %x %x %x %x %x %x %x " -+ Info("\tltssm[%02u]: 0x%04x %04x %x %x %x %x %x %x %x " - "%x %x %x %x %02x %x %x %02x %s\n", - i, - (uint32_t)ltssm_val.bits.txdetrx, -@@ -239,7 +236,7 @@ int pcie_ltssm_trace_show(uint32_t port_id) - int pcie_ltssm_trace_mode_set(uint32_t port_id, uint32_t mode) - { - struct hikp_cmd_header req_header; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - struct pcie_trace_req_para req_data = { 0 }; - int ret; - -@@ -256,7 +253,7 @@ int pcie_ltssm_trace_mode_set(uint32_t port_id, uint32_t mode) - int pcie_ltssm_trace_clear(uint32_t port_id) - { - struct hikp_cmd_header req_header; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - struct pcie_trace_req_para req_data = { 0 }; - int ret; - -@@ -273,9 +270,9 @@ int pcie_ltssm_link_status_get(uint32_t port_id) - { - union pcie_link_info reg_val; - struct hikp_cmd_header req_header; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - struct pcie_trace_req_para req_data = { 0 }; -- char *ltssm_sts; -+ char *ltssm_sts = NULL; - int ret; - - req_data.port_id = port_id; -@@ -286,7 +283,7 @@ int pcie_ltssm_link_status_get(uint32_t port_id) - goto free_cmd_ret; - - if (cmd_ret->rsp_data_num == 0) { -- Err("PCIe Base", "rsp data number check failed, rsp_data_num: %u.\n", -+ Err("rsp data number check failed, rsp_data_num: %u.\n", - cmd_ret->rsp_data_num); - ret = -EINVAL; - goto free_cmd_ret; -@@ -294,12 +291,12 @@ int pcie_ltssm_link_status_get(uint32_t port_id) - reg_val.u32 = cmd_ret->rsp_data[0]; - ltssm_sts = hisi_pcie_ltssm_string_get(reg_val.bits.mac_ltssm_st); - -- Info(LOG_PCIE, "Port[%u] mac link information:\n", port_id); -- Info(LOG_PCIE, " ltssm status: %s\n", ltssm_sts); -- Info(LOG_PCIE, " speed: Gen%u\n", reg_val.bits.mac_cur_link_speed); -- Info(LOG_PCIE, " width: X%u\n", reg_val.bits.mac_cur_link_width); -- Info(LOG_PCIE, " link_up: %u\n", reg_val.bits.mac_link_up); -- Info(LOG_PCIE, " lane_reverse: %u\n", reg_val.bits.lane_reverse); -+ Info("Port[%u] mac link information:\n", port_id); -+ Info(" ltssm status: %s\n", ltssm_sts); -+ Info(" speed: Gen%u\n", reg_val.bits.mac_cur_link_speed); -+ Info(" width: X%u\n", reg_val.bits.mac_cur_link_width); -+ Info(" link_up: %u\n", reg_val.bits.mac_link_up); -+ Info(" lane_reverse: %u\n", reg_val.bits.lane_reverse); - free_cmd_ret: - free(cmd_ret); - -@@ -319,32 +316,32 @@ static int pcie_get_pm_trace(uint32_t port_id, uint64_t *pm_status, uint32_t *pm - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - ret = hikp_rsp_normal_check(cmd_ret); - if (ret) { -- Err("PCIe Base", "pcie pm trace cmd_ret check failed, ret: %d.\n", ret); -+ Err("pcie pm trace cmd_ret check failed, ret: %d.\n", ret); - goto free_cmd_ret; - } - - if (cmd_ret->rsp_data_num == 0) { -- Err("PCIe Base", "without rsp data.\n"); -+ Err("without rsp data.\n"); - ret = -EINVAL; - goto free_cmd_ret; - } - /* 0: First uint32_t is pm trace num received from TF */ - *pm_num = cmd_ret->rsp_data[0]; -- -- if ((cmd_ret->rsp_data_num - 1) * sizeof(uint32_t) != (*pm_num) * sizeof(uint64_t)) { -- Err("PCIe Base", "rsp data number check failed, rsp_data_num: %u, pm_num: %u.\n", -- cmd_ret->rsp_data_num, *pm_num); -+ src_size = (*pm_num) * sizeof(uint64_t); -+ dst_size = TRACER_DEPTH * sizeof(uint64_t); -+ if (src_size > dst_size) { -+ Err("size check failed, %u > %u.\n", src_size, dst_size); - ret = -EINVAL; - goto free_cmd_ret; - } - -- src_size = (*pm_num) * sizeof(uint64_t); -- dst_size = TRACER_DEPTH * sizeof(uint64_t); -- if (src_size > dst_size) { -- Err("PCIe Base", "size check failed, %u > %u.\n", src_size, dst_size); -+ if ((cmd_ret->rsp_data_num - 1) * sizeof(uint32_t) != (*pm_num) * sizeof(uint64_t)) { -+ Err("rsp data number check failed, rsp_data_num: %u, pm_num: %u.\n", -+ cmd_ret->rsp_data_num, *pm_num); - ret = -EINVAL; - goto free_cmd_ret; - } -+ - memcpy(pm_status, (cmd_ret->rsp_data + 1), src_size); - - free_cmd_ret: -@@ -411,19 +408,17 @@ static int pcie_print_pm_trace(const uint64_t *pm_status, uint32_t pm_num) - union pm_state_reg pm_val; - - if (pm_num > TRACER_DEPTH || pm_num == 0) { -- Err("PCIe Base", "pm_num(%u) is over range or zero\n", pm_num); -+ Err("pm_num(%u) is over range or zero\n", pm_num); - return -EINVAL; - } -- Info("PCIe Base", "pm tracer:\n"); -- Info("PCIe Base", "\ttrace state: %llx\n", pm_status[0]); -- Info("PCIe Base", -- "\tpm[ii]: BE8: 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 " -+ Info("pm tracer:\n"); -+ Info("\ttrace state: %llx\n", pm_status[0]); -+ Info("\tpm[ii]: BE8: 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 " - "BD8: 23:6 5:0 : pm state\n"); - for (i = 1; i < pm_num; i++) { - pm_val.val = pm_status[i]; - pm_c = hisi_pcie_pm_string_get((uint32_t)pm_val.bits.pm_state); -- Info("PCIe Base", -- "\tpm[%02u]:\t %x %x %x %x %x %x %x %x %x %x %x " -+ Info("\tpm[%02u]:\t %x %x %x %x %x %x %x %x %x %x %x " - "%x %x %x %x 0x%06x 0x%02x %s\n", - i, - (uint32_t)pm_val.bits.pm_t_dfe_time_meet, -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index 535807c..856aebe 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -409,7 +409,7 @@ static int pcie_create_dumpreg_log_file(uint32_t port_id, uint32_t dump_level) - /* Add write permission to the file */ - fd_file = open(file_name, O_RDWR | O_SYNC | O_CREAT, 0600); - if (fd_file < 0) { -- Err("PCIe DUMPREG", "open %s failed.\n", file_name); -+ Err("open %s failed.\n", file_name); - return -EPERM; - } - g_pcie_dumpreg_fd = fd_file; -@@ -437,11 +437,11 @@ static void pcie_dumpreg_write_value_to_file(const char *reg_name, uint32_t val) - - ret = snprintf(str, sizeof(str), " %-40s : 0x%x\n", reg_name, val); - if (ret < 0 || ret >= sizeof(str)) { -- Err("PCIe DUMPREG", "pcie dumpreg write info to logfile failed.\n"); -+ Err("pcie dumpreg write info to logfile failed.\n"); - } else { - wr_ret = write(g_pcie_dumpreg_fd, str, strlen(str)); - if (wr_ret == -1) -- Err("PCIe DUMPREG", "write info to logfile failed.\n"); -+ Err("write info to logfile failed.\n"); - } - } - -@@ -485,13 +485,13 @@ static int pcie_dumpreg_write_header_to_file(uint32_t version, - ret = snprintf(str, sizeof(str), "Command Version[%u], dump_level[%u], port_id[%u]\n\n", - version, req_data->level, req_data->port_id); - if (ret < 0) { -- Err("PCIe DUMPREG", "pcie dumpreg write header to logfile failed.\n"); -+ Err("pcie dumpreg write header to logfile failed.\n"); - return -EIO; - } - - wr_ret = write(g_pcie_dumpreg_fd, str, strlen(str)); - if (wr_ret == -1) { -- Err("PCIe DUMPREG", "write header to logfile failed.\n"); -+ Err("write header to logfile failed.\n"); - return -EIO; - } - -@@ -506,7 +506,9 @@ static int pcie_dumpreg_save_log(uint32_t *data, uint32_t data_num, - uint32_t i; - int ret; - -- (void)pcie_dumpreg_write_header_to_file(version, req_data); -+ ret = pcie_dumpreg_write_header_to_file(version, req_data); -+ if (ret < 0) -+ return ret; - - switch (req_data->level) { - case DUMP_GLOBAL_LEVEL: -@@ -520,7 +522,7 @@ static int pcie_dumpreg_save_log(uint32_t *data, uint32_t data_num, - } - break; - default: -- Err("PCIe DUMPREG", "check dump level failed.\n"); -+ Err("check dump level failed.\n"); - return -EINVAL; - } - -@@ -528,7 +530,7 @@ static int pcie_dumpreg_save_log(uint32_t *data, uint32_t data_num, - for (i = 0; i < data_num; i++) { - ret = snprintf(reg_name, sizeof(reg_name), "REG_%03u", i); - if (ret < 0) -- Err("PCIe DUMPREG", "save log snprintf failed.\n"); -+ Err("save log snprintf failed.\n"); - pcie_dumpreg_write_value_to_file(reg_name, data[i]); - } - } else if (req_data->level == DUMP_GLOBAL_LEVEL) { -@@ -549,7 +551,7 @@ int pcie_dumpreg_do_dump(uint32_t port_id, uint32_t dump_level) - struct pcie_dump_req_para req_data = { 0 }; - int ret = 0; - -- Info("PCIe DUMPREG", "pcie reg dump start.\n"); -+ Info("pcie reg dump start.\n"); - - req_data.port_id = port_id; - req_data.level = dump_level; -@@ -567,11 +569,11 @@ int pcie_dumpreg_do_dump(uint32_t port_id, uint32_t dump_level) - ret = pcie_dumpreg_save_log(cmd_ret->rsp_data, - cmd_ret->rsp_data_num, cmd_ret->version, &req_data); - if (ret) { -- Err("PCIe DUMPREG", "pcie dump save log failed, ret: %d.\n", ret); -+ Err("pcie dump save log failed, ret: %d.\n", ret); - goto close_file_ret; - } - -- Info("PCIe DUMPREG", "pcie reg dump finish.\n"); -+ Info("pcie reg dump finish.\n"); - close_file_ret: - (void)pcie_close_dumpreg_log_file(); - free_cmd_ret: -diff --git a/pcie/func_lib/pcie_func/pcie_reg_read.c b/pcie/func_lib/pcie_func/pcie_reg_read.c -index b3d4643..1578056 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_read.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_read.c -@@ -66,11 +66,11 @@ int pcie_read_name2module_id(const char *module_name, uint32_t *module_id) - static int pcie_reg_read_result_show(const struct hikp_cmd_ret *cmd_ret) - { - if (cmd_ret->rsp_data_num != 1) { /* 1 uint32_t data for reg read cmd */ -- Err("PCIe REGREAD", "pcie reg read data num check failed, num: %u.\n", -+ Err("pcie reg read data num check failed, num: %u.\n", - cmd_ret->rsp_data_num); - return -EINVAL; - } -- Info("PCIe REGREAD", "RIGISTER VALUE[0x%08x].\n", cmd_ret->rsp_data[0]); -+ Info("RIGISTER VALUE[0x%08x].\n", cmd_ret->rsp_data[0]); - - return 0; - } -@@ -89,7 +89,7 @@ int pcie_reg_read(uint32_t port_id, uint32_t module_id, uint32_t offset) - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - ret = hikp_rsp_normal_check(cmd_ret); - if (ret) { -- Err("PCIe REGREAD", "pcie reg read cmd_ret check failed, ret: %d.\n", ret); -+ Err("pcie reg read cmd_ret check failed, ret: %d.\n", ret); - goto free_cmd_ret; - } - ret = pcie_reg_read_result_show(cmd_ret); -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c -index badf3d1..e2bfcb4 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.c -+++ b/pcie/func_lib/pcie_func/pcie_statistics.c -@@ -32,18 +32,18 @@ static const char *g_global_ndie_name[] = { - static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, uint32_t *port_num) - { - size_t rsp_data_size, expect_data_size; -- struct pcie_port_info *port_info; -+ struct pcie_port_info *port_info = NULL; - int ret; - - ret = hikp_rsp_normal_check(cmd_ret); - if (ret) { -- Err("PCIe Base", "port distribution cmd_ret normal check failed, ret: %d.\n", ret); -+ Err("port distribution cmd_ret normal check failed, ret: %d.\n", ret); - return ret; - } - rsp_data_size = cmd_ret->rsp_data_num * sizeof(uint32_t); - /* Check whether enough data of a port unit */ - if (rsp_data_size < sizeof(struct pcie_port_info)) { -- Err("PCIe Base", "port distribution rsp check failed, size: %u.\n", -+ Err("port distribution rsp check failed, size: %u.\n", - rsp_data_size); - return -EINVAL; - } -@@ -53,8 +53,7 @@ static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, - expect_data_size = sizeof(struct pcie_port_info) + - sizeof(struct pcie_info_distribution_pair) * (*port_num); - if (expect_data_size > rsp_data_size) { -- Err("PCIe Base", -- "port distribution data size check failed, size: %u, expect size: %u.\n", -+ Err("port distribution data size check failed, size: %u, expect size: %u.\n", - rsp_data_size, expect_data_size); - return -EINVAL; - } -@@ -68,19 +67,19 @@ static int pcie_portid_serdes_relation(const struct pcie_macro_info *macro_info, - uint32_t i, j; - - if (ndie_id >= HIKP_ARRAY_SIZE(g_global_ndie_name)) { -- Info("PCIe Base", "ndie_id [%u]: %s\n", ndie_id, "UNKNOWN_NDIE"); -+ Info("ndie_id [%u]: %s\n", ndie_id, "UNKNOWN_NDIE"); - return -1; - } - - if (macro_num >= MAX_MACRO_ONEPORT) { -- Info("PCIe Base", "macro_num [%u] exceeds the maximum array length\n", macro_num); -+ Info("macro_num [%u] exceeds the maximum array length\n", macro_num); - return -1; - } - -- Info("PCIe Base", "\tndie_id: %s\n", g_global_ndie_name[ndie_id]); -+ Info("\tndie_id: %s\n", g_global_ndie_name[ndie_id]); - for (i = 0; i < macro_num; i++) { - for (j = macro_info[i].lane_s; j <= macro_info[i].lane_e; j++) -- Info("PCIe Base", "\t\tmacro %d \t lane: %d\n", macro_info[i].id, j); -+ Info("\t\tmacro %d \t lane: %d\n", macro_info[i].id, j); - } - return 0; - } -@@ -88,10 +87,10 @@ static int pcie_portid_serdes_relation(const struct pcie_macro_info *macro_info, - int pcie_port_distribution_get(uint32_t chip_id) - { - struct hikp_cmd_header req_header; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - struct pcie_info_req_para req_data = { 0 }; - uint32_t pair_num; -- struct pcie_port_info *port_info; -+ struct pcie_port_info *port_info = NULL; - uint32_t i; - int ret; - -@@ -104,14 +103,14 @@ int pcie_port_distribution_get(uint32_t chip_id) - goto free_cmd_ret; - - port_info = (struct pcie_port_info *)cmd_ret->rsp_data; -- Info("PCIe Base", "Port Distribution Info (CHIP : 0x%x)Port_id Port_width\n", chip_id); -+ Info("Port Distribution Info (CHIP : 0x%x)Port_id Port_width\n", chip_id); - for (i = 0; i < pair_num; i++) { - if (port_info->info_pair[i].port_width >= HIKP_ARRAY_SIZE(g_global_width_name)) { -- Info("PCIe Base", "port_id[%u] %s\n", port_info->info_pair[i].port_id, -+ Info("port_id[%u] %s\n", port_info->info_pair[i].port_id, - "UNKNOWN_WIDTH"); - continue; - } -- Info("PCIe Base", "port_id[%u] %s\n", port_info->info_pair[i].port_id, -+ Info("port_id[%u] %s\n", port_info->info_pair[i].port_id, - g_global_width_name[port_info->info_pair[i].port_width]); - pcie_portid_serdes_relation(port_info->info_pair[i].macro_info, - port_info->info_pair[i].macro_num, -@@ -130,13 +129,12 @@ static int port_err_state_rsp_data_check(struct hikp_cmd_ret *cmd_ret) - - ret = hikp_rsp_normal_check(cmd_ret); - if (ret) { -- Err("PCIe Base", "error state get cmd_ret normal check failed, ret: %d.\n", ret); -+ Err("error state get cmd_ret normal check failed, ret: %d.\n", ret); - return ret; - } - rsp_data_size = cmd_ret->rsp_data_num * sizeof(uint32_t); - if (rsp_data_size < sizeof(struct pcie_err_state)) { -- Err("PCIe Base", -- "err state get rsp size check failed, rsp size: %u, expect size:%u.\n", -+ Err("err state get rsp size check failed, rsp size: %u, expect size:%u.\n", - rsp_data_size, sizeof(struct pcie_err_state)); - return -EINVAL; - } -@@ -147,9 +145,9 @@ static int port_err_state_rsp_data_check(struct hikp_cmd_ret *cmd_ret) - int pcie_error_state_get(uint32_t port_id) - { - struct hikp_cmd_header req_header; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - struct pcie_info_req_para req_data = { 0 }; -- struct pcie_err_state *state; -+ struct pcie_err_state *state = NULL; - int ret; - - req_data.interface_id = port_id; -@@ -162,17 +160,17 @@ int pcie_error_state_get(uint32_t port_id) - - state = (struct pcie_err_state *)cmd_ret->rsp_data; - -- Info("PCIe Base", "phy_lane_err_counter = %u\n", state->test_cnt.bits.phy_lane_err_counter); -- Info("PCIe Base", "symbol_unlock_counter = %u\n", -+ Info("phy_lane_err_counter = %u\n", state->test_cnt.bits.phy_lane_err_counter); -+ Info("symbol_unlock_counter = %u\n", - state->symbol_unlock_cnt.bits.symbol_unlock_counter); -- Info("PCIe Base", "mac_int_status = 0x%x\n", state->mac_int_status); -- Info("PCIe Base", "loop_back_link_data_err_cnt = %u\n", -+ Info("mac_int_status = 0x%x\n", state->mac_int_status); -+ Info("loop_back_link_data_err_cnt = %u\n", - state->loop_link_data_err_cnt.bits.loop_back_link_data_err_cnt); -- Info("PCIe Base", "pcs_rx_err_cnt = %u\n", state->rx_err_cnt.bits.pcs_rx_err_cnt); -- Info("PCIe Base", "reg_framing_err_count = %u\n", -+ Info("pcs_rx_err_cnt = %u\n", state->rx_err_cnt.bits.pcs_rx_err_cnt); -+ Info("reg_framing_err_count = %u\n", - state->framing_err_cnt.bits.reg_framing_err_count); -- Info("PCIe Base", "dl_lcrc_err_num = %u\n", state->lcrc_err_num.bits.dl_lcrc_err_num); -- Info("PCIe Base", "dl_dcrc_err_num = %u\n", state->dcrc_err_num.bits.dl_dcrc_err_num); -+ Info("dl_lcrc_err_num = %u\n", state->lcrc_err_num.bits.dl_lcrc_err_num); -+ Info("dl_dcrc_err_num = %u\n", state->dcrc_err_num.bits.dl_dcrc_err_num); - free_cmd_ret: - free(cmd_ret); - -@@ -182,7 +180,7 @@ free_cmd_ret: - int pcie_error_state_clear(uint32_t port_id) - { - struct hikp_cmd_header req_header; -- struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_ret *cmd_ret = NULL; - struct pcie_info_req_para req_data = { 0 }; - int ret; - -diff --git a/pcie/usr_cmd/cmd_analysis/pcie_cmd_dumpreg.c b/pcie/usr_cmd/cmd_analysis/pcie_cmd_dumpreg.c -index f6399b4..6d1c674 100644 ---- a/pcie/usr_cmd/cmd_analysis/pcie_cmd_dumpreg.c -+++ b/pcie/usr_cmd/cmd_analysis/pcie_cmd_dumpreg.c -@@ -60,7 +60,7 @@ static int pcie_port_set(struct major_cmd_ctrl *self, const char *argv) - - static int dump_level_set(struct major_cmd_ctrl *self, const char *argv) - { -- uint32_t val; -+ uint32_t val = 0; - int ret; - - ret = string_toui(argv, &val); -diff --git a/sas/sas_func/sas_analy_queue.c b/sas/sas_func/sas_analy_queue.c -index 8fca197..b27ba60 100644 ---- a/sas/sas_func/sas_analy_queue.c -+++ b/sas/sas_func/sas_analy_queue.c -@@ -40,7 +40,7 @@ static int sas_get_res(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - hikp_cmd_init(&req_header, SAS_MOD, SAS_ANACQ, ANACQ_PRT); - - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL || cmd_ret->status != 0) { -+ if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_analy excutes hikp_cmd_alloc err\n"); - free(cmd_ret); - return -EINVAL; -@@ -57,7 +57,7 @@ static void sas_print_prt(const uint32_t *reg_save, uint32_t reg_num) - { - uint32_t i; - -- if (reg_num == 0) { -+ if (reg_num < REG_NUM_PTR_MAX) { - printf("SAS get queue pointer is failed\n"); - return; - } -@@ -80,7 +80,7 @@ static void sas_print_dqnum(const uint32_t *reg_save, uint32_t reg_num) - - static void sas_print_cqnum(const uint32_t *reg_save, uint32_t reg_num) - { -- if (reg_num < CQ_COAL_CNT) { -+ if (reg_num < REG_NUM_CQ_MAX) { - printf("SAS get cq number is failed\n"); - return; - } -diff --git a/sas/sas_func/sas_analy_queue.h b/sas/sas_func/sas_analy_queue.h -index a6e2223..59100f4 100644 ---- a/sas/sas_func/sas_analy_queue.h -+++ b/sas/sas_func/sas_analy_queue.h -@@ -18,6 +18,8 @@ - - #define REG_NUM_DQ 2 - #define REG_NUM_CQ 2 -+#define REG_NUM_CQ_MAX 4 -+#define REG_NUM_PTR_MAX 32 - #define CQE_NUM_BYTE 0 - #define DQE_NUM_REG 2 - #define CQ_COAL 1 -diff --git a/sas/sas_func/sas_common.h b/sas/sas_func/sas_common.h -index 1bace0c..c33a2fe 100644 ---- a/sas/sas_func/sas_common.h -+++ b/sas/sas_func/sas_common.h -@@ -22,6 +22,10 @@ - #define IPTT_ICT_STATUS 29 - #define LINK_SPEED_OFFSET 8 - #define LINK_SPEED_WIDTH 4 -+#define REG_NUM_DEV_LINK_MAX 3 -+#define REG_NUM_DQE_MAX 8 -+#define REG_NUM_ERR_CODE_ALL_MAX 32 -+#define REG_NUM_ERR_CODE_MAX 8 - - #define DWS_LOST 0 - #define RESET_PROB 1 -diff --git a/sas/sas_func/sas_dump_reg.c b/sas/sas_func/sas_dump_reg.c -index 5736726..9a1da3a 100644 ---- a/sas/sas_func/sas_dump_reg.c -+++ b/sas/sas_func/sas_dump_reg.c -@@ -32,7 +32,7 @@ static int sas_get_reg(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - - hikp_cmd_init(&req_header, SAS_MOD, SAS_DUMP, cmd->sas_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL || cmd_ret->status != 0) { -+ if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_dump excutes hikp_cmd_alloc err\n"); - free(cmd_ret); - return -1; -diff --git a/sas/sas_func/sas_read_dev.c b/sas/sas_func/sas_read_dev.c -index 670e2d4..ede5d74 100644 ---- a/sas/sas_func/sas_read_dev.c -+++ b/sas/sas_func/sas_read_dev.c -@@ -33,7 +33,7 @@ static int sas_get_dev(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - - hikp_cmd_init(&req_header, SAS_MOD, SAS_DEV, cmd->sas_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL || cmd_ret->status != 0) { -+ if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_dqe excutes hikp_cmd_alloc err\n"); - free(cmd_ret); - return -EINVAL; -@@ -78,7 +78,7 @@ static void print_dev_link(const uint32_t *reg_save, uint32_t reg_num) - - static void sas_print_dev(const uint32_t *reg_save, uint32_t reg_num, uint32_t cmd_type) - { -- if (reg_num == 0) { -+ if (reg_num < REG_NUM_DEV_LINK_MAX) { - printf("SAS device is failed\n"); - return; - } -diff --git a/sas/sas_func/sas_read_dqe.c b/sas/sas_func/sas_read_dqe.c -index 7d49c0a..072c1dc 100644 ---- a/sas/sas_func/sas_read_dqe.c -+++ b/sas/sas_func/sas_read_dqe.c -@@ -33,7 +33,7 @@ static int sas_get_dqe(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - - hikp_cmd_init(&req_header, SAS_MOD, SAS_DQE, cmd->sas_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL || cmd_ret->status != 0) { -+ if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_dqe excutes hikp_cmd_alloc err\n"); - free(cmd_ret); - return -EINVAL; -@@ -105,7 +105,7 @@ int sas_dqe(const struct tool_sas_cmd *cmd) - if (ret) - return ret; - -- if (reg_num == 0) { -+ if (reg_num < REG_NUM_DQE_MAX) { - printf("SAS dqe is failed\n"); - return -EINVAL; - } -diff --git a/sas/sas_func/sas_read_errcode.c b/sas/sas_func/sas_read_errcode.c -index 6c7850e..da1157b 100644 ---- a/sas/sas_func/sas_read_errcode.c -+++ b/sas/sas_func/sas_read_errcode.c -@@ -31,7 +31,7 @@ static int sas_get_errcode(const struct tool_sas_cmd *cmd, uint32_t *reg_save, u - - hikp_cmd_init(&req_header, SAS_MOD, SAS_ERRCODE, cmd->sas_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL || cmd_ret->status != 0) { -+ if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_errcode excutes hikp_cmd_alloc err\n"); - free(cmd_ret); - return -EINVAL; -@@ -55,11 +55,12 @@ static void sas_print_errcode(uint32_t cmd_type, const uint32_t *reg_save, uint3 - "OPEN_REJ" - }; - -- if (reg_num == 0) { -- printf("SAS error code read is failed\n"); -- return; -- } - if (cmd_type == ERRCODE_ALL) { -+ if (reg_num < REG_NUM_ERR_CODE_ALL_MAX) { -+ printf("SAS error code read is failed\n"); -+ return; -+ } -+ - printf(" DWS_LOST RESET_PROB CRC_FAIL OPEN_REJ\n"); - for (i = 0; i < reg_num; i += SAS_ERR_NUM) { - printf("phy%u 0x%08x 0x%08x 0x%08x 0x%08x\n", i / SAS_ERR_NUM, -@@ -67,6 +68,11 @@ static void sas_print_errcode(uint32_t cmd_type, const uint32_t *reg_save, uint3 - reg_save[i + CRC_FAIL], reg_save[i + OPEN_REJ]); - } - } else { -+ if (reg_num < REG_NUM_ERR_CODE_MAX) { -+ printf("SAS error code read is failed\n"); -+ return; -+ } -+ - printf(" %s\n", errcode_type[cmd_type]); - for (i = 0; i < reg_num; i++) - printf("phy%u 0x%08x\n", i, reg_save[i]); -diff --git a/sata/sata_func/sata_dump_reg.c b/sata/sata_func/sata_dump_reg.c -index b4ff35f..691989e 100644 ---- a/sata/sata_func/sata_dump_reg.c -+++ b/sata/sata_func/sata_dump_reg.c -@@ -33,7 +33,7 @@ static int sata_get_reg(const struct tool_sata_cmd *cmd, uint32_t *reg_save, uin - - hikp_cmd_init(&req_header, SATA_MOD, SATA_DUMP, cmd->sata_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL || cmd_ret->status != 0) { -+ if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("hikp_data_proc err\n"); - free(cmd_ret); - return -1; -diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c -index 9fb91d8..b6ecc48 100644 ---- a/tool_lib/op_logs.c -+++ b/tool_lib/op_logs.c -@@ -57,7 +57,7 @@ static int op_log_write_buffer(const char *log_data, const char *log_dir) - int ret; - - sigfillset(&sigset); -- sigprocmask(SIG_BLOCK, &sigset, NULL); -+ (void)sigprocmask(SIG_BLOCK, &sigset, NULL); - ret = tool_flock(OP_LOG_LOCK_NAME, UDA_FLOCK_BLOCK, &op_lock_fd, log_dir); - if (ret == -ENOENT) { - HIKP_ERROR_PRINT("Folder or file required by the operation is not exist.\n"); -@@ -73,7 +73,7 @@ static int op_log_write_buffer(const char *log_data, const char *log_dir) - op_log_write(log_data); - tool_unlock(&op_lock_fd, UDA_FLOCK_BLOCK); - g_log_info = true; -- sigprocmask(SIG_UNBLOCK, &sigset, NULL); -+ (void)sigprocmask(SIG_UNBLOCK, &sigset, NULL); - return 0; - } - -@@ -104,13 +104,13 @@ static double op_log_diff_timeval(const struct timeval *now, const struct timeva - static int op_log_add_time_to_log(char *log_base, int *offset, uint32_t flag) - { - static struct timeval g_tv; -- struct timeval tv; -- struct tm ptm; -+ struct timeval tv = {0}; -+ struct tm ptm = {0}; - int len = 0; - int ret; - - (void)gettimeofday(&tv, NULL); -- localtime_r(&tv.tv_sec, &ptm); -+ (void)localtime_r(&tv.tv_sec, &ptm); - if (flag == LOG_FLAG_DATE_TIME) { - g_tv = tv; - len = (int)strftime(log_base + *offset, (OP_LOG_FILE_W_MAXSIZE + 1 - *offset), -@@ -186,9 +186,7 @@ static int op_log_file_rollback(const char *op_log_backup, const char *log_dir) - snprintf(rollback_log + offset, - (uint32_t)(OP_LOG_FILE_W_MAXSIZE + 1 - offset), OP_LOG_ITEM_END); - -- op_log_write_buffer(rollback_log, log_dir); -- -- return ret; -+ return op_log_write_buffer(rollback_log, log_dir); - } - - static int op_log_dir_mk(const char *log_path) -diff --git a/tool_lib/tool_lib.c b/tool_lib/tool_lib.c -index 5c1a02d..4d02bdd 100644 ---- a/tool_lib/tool_lib.c -+++ b/tool_lib/tool_lib.c -@@ -21,7 +21,7 @@ int string_toui(const char *nptr, uint32_t *value) - char *endptr = NULL; - int64_t tmp_value; - -- if (nptr == NULL) -+ if (nptr == NULL || value == NULL) - return -EINVAL; - - tmp_value = strtol(nptr, &endptr, 0); -@@ -37,7 +37,7 @@ int string_toub(const char *nptr, uint8_t *value) - char *endptr = NULL; - int64_t tmp_value; - -- if (nptr == NULL) -+ if (nptr == NULL || value == NULL) - return -EINVAL; - - tmp_value = strtol(nptr, &endptr, 0); -@@ -141,14 +141,14 @@ int check_file_access(const char *file_dir) - - static uint32_t get_file_size(const char *file_dir) - { -- char format_dir[TOOL_REAL_PATH_MAX_LEN] = {0}; -+ char format_dir[PATH_MAX + 1] = {0}; - struct stat file_stat = { 0 }; - int ret; - - if (file_dir == NULL) - return 0; - -- ret = check_file_path_dir(file_dir, format_dir, TOOL_REAL_PATH_MAX_LEN); -+ ret = check_file_path_dir(file_dir, format_dir, (PATH_MAX + 1)); - if (ret) { - HIKP_ERROR_PRINT("This file path[%s] is not exist.\n", file_dir); - return 0; -@@ -313,7 +313,7 @@ int generate_file_name(unsigned char *file_name, - #define RANDOM_STR_LENGTH 7 - char str_r[RANDOM_STR_LENGTH] = {0}; - time_t time_seconds = time(0); -- struct tm timeinfo; -+ struct tm timeinfo = {0}; - int ret; - - ret = get_rand_str(str_r, RANDOM_STR_LENGTH); -@@ -321,7 +321,7 @@ int generate_file_name(unsigned char *file_name, - HIKP_ERROR_PRINT("get randrom string failed.\n"); - return ret; - } -- localtime_r(&time_seconds, &timeinfo); -+ (void)localtime_r(&time_seconds, &timeinfo); - ret = snprintf((char *)file_name, file_name_len, "%s_%d_%d_%d_%d_%d_%d_%s.log", prefix, - timeinfo.tm_year + START_YEAR, timeinfo.tm_mon + 1, timeinfo.tm_mday, - timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec, str_r); --- -2.45.0.windows.1 - diff --git a/0069-hikptool-Support-static-compilation-for-hikptool.patch b/0069-hikptool-Support-static-compilation-for-hikptool.patch deleted file mode 100644 index d8ea37025b6d12e55950f6aa3ca2c785a9b0e979..0000000000000000000000000000000000000000 --- a/0069-hikptool-Support-static-compilation-for-hikptool.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 0f262056cdc114738a8da3947185a89d10ade581 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Tue, 12 Nov 2024 19:23:50 +0800 -Subject: [PATCH 07/27] hikptool: Support static compilation for hikptool - -Support static compilation by add the option ENABLE_STATIC, -Please refer to the following usage methods: - -``` -cmake ${src} -DENABLE_STATIC=1 -``` - -Signed-off-by: Chengchang Tang ---- - CMakeLists.txt | 14 +++++++++++++- - libhikptdev/src/rciep/CMakeLists.txt | 6 +++++- - 2 files changed, 18 insertions(+), 2 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index cbd063c..f2ffe6c 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -26,6 +26,8 @@ macro(get_header_dir_recurse HEADER_DIR_LIST) - set(${HEADER_DIR_LIST} ${DIR_LIST}) - endmacro() - -+option(ENABLE_STATIC "Make tool run as independently as possible" off) -+ - file(GLOB_RECURSE HIKPTOOL_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/cxl/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/net/*.c -@@ -38,13 +40,23 @@ file(GLOB_RECURSE HIKPTOOL_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/tool_lib/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/hikp_init_main.c - ) -+ - add_subdirectory(libhikptdev) - add_executable(hikptool ${HIKPTOOL_SRC}) - get_header_dir_recurse(HIKPTOOL_HEADER_DIR) - target_include_directories(hikptool PRIVATE ${HIKPTOOL_HEADER_DIR}) - target_link_directories(hikptool PRIVATE ${CMAKE_INSTALL_PREFIX}/lib) - target_link_libraries(hikptool PRIVATE KPTDEV_SO) -+if (ENABLE_STATIC) -+ # I don¡¯t know why, but once you add double quotes to these -+ # link parameters, an error will be reported. -+ set(EXT_LINK_FLAGS -static-libgcc -static-libstdc++ -static) -+ set_target_properties(hikptool PROPERTIES LINK_SEARCH_START_STATIC ON) -+ set_target_properties(hikptool PROPERTIES LINK_SEARCH_END_STATIC ON) -+else() -+ set(EXT_LINK_FLAGS "-fPIE") -+endif() - target_link_options(hikptool PRIVATE -- -Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIE -pie -+ -Wl,-z,relro,-z,now -Wl,-z,noexecstack -pie ${EXT_LINK_FLAGS} - -s -lpthread -ldl -lm -lrt -T ${CMAKE_CURRENT_SOURCE_DIR}/hikp_register.ld) - install(TARGETS hikptool RUNTIME DESTINATION bin OPTIONAL) -diff --git a/libhikptdev/src/rciep/CMakeLists.txt b/libhikptdev/src/rciep/CMakeLists.txt -index 5017f5b..e3f96c0 100644 ---- a/libhikptdev/src/rciep/CMakeLists.txt -+++ b/libhikptdev/src/rciep/CMakeLists.txt -@@ -13,7 +13,11 @@ cmake_minimum_required(VERSION 3.0.0) - - set(KPTDEV_SO_NAME hikptdev) - --add_library(KPTDEV_SO SHARED hikpt_rciep.c) -+if (ENABLE_STATIC) -+ add_library(KPTDEV_SO STATIC hikpt_rciep.c) -+else() -+ add_library(KPTDEV_SO SHARED hikpt_rciep.c) -+endif() - - target_include_directories(KPTDEV_SO PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include) - --- -2.45.0.windows.1 - diff --git a/0070-hikptool-nic-Fix-the-Code-review-comments.patch b/0070-hikptool-nic-Fix-the-Code-review-comments.patch deleted file mode 100644 index ffc2ef00dab29854d2ccacb629f8aea4cd44d752..0000000000000000000000000000000000000000 --- a/0070-hikptool-nic-Fix-the-Code-review-comments.patch +++ /dev/null @@ -1,265 +0,0 @@ -From 2994a8d169adc6ba5b543a2f35b579e437044beb Mon Sep 17 00:00:00 2001 -From: Jie Hai -Date: Tue, 6 Aug 2024 16:43:24 +0800 -Subject: [PATCH 08/27] hikptool/nic: Fix the Code review comments - -The value got from the firmware may cause the following problem. - 1. Out-of-bounds access may occur. - 2. Apply for memory of size 0. - 3. Integer overflow may happen. -This patch fixes it. - -Signed-off-by: Jie Hai ---- - net/nic/nic_ppp/hikp_nic_ppp.c | 142 +++++++++++++++++++++++++++++++-- - 1 file changed, 137 insertions(+), 5 deletions(-) - -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index 4dbe8d6..c070666 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -42,6 +42,8 @@ static int hikp_nic_query_ppp_by_entryid(struct hikp_cmd_header *req_header, - #define NIC_PPP_VLAN_TBL_NAME "vlan" - #define NIC_PPP_MNG_TBL_NAME "mng" - -+#define HIKP_PPP_MAX_MAC_ID_NUM 8 -+ - static const struct ppp_feature_cmd g_ppp_feature_cmd[] = { - {NIC_PPP_MAC_TBL_NAME, NIC_MAC_TBL_DUMP, true, - hikp_nic_query_ppp_by_entryid, hikp_nic_ppp_show_mac_tbl}, -@@ -259,6 +261,9 @@ static void hikp_nic_ppp_show_mac_tbl(const void *data) - - hikp_nic_ppp_show_key_mem((struct nic_mac_tbl *)data, true); - -+ if (g_ppp_hw_res.overflow_cam_size == 0) -+ return; -+ - of_uc_entry = (struct mac_vlan_uc_entry *)calloc(g_ppp_hw_res.overflow_cam_size, - sizeof(struct mac_vlan_uc_entry)); - if (of_uc_entry == NULL) { -@@ -326,8 +331,9 @@ static void hikp_nic_ppp_show_vf_vlan_info(const struct vf_vlan_tbl *vf_tbl, uin - offset = abs_func_id % HIKP_NIC_PPP_FUNC_BITMAP_SIZE; - hikp_nic_ppp_get_func_name(func_name, sizeof(func_name), func_id); - printf("%s_abs_func_id: %u\n", func_name, -- (uint32_t)(g_ppp_hw_res.abs_func_id_base + func_id - 1)); -+ (uint32_t)(hw_res->abs_func_id_base + func_id - 1)); - printf("%s VLAN id:\n\t", func_name); -+ - for (i = 0; i < vf_tbl->entry_size; i++) { - vf_entry = &vf_tbl->entry[i]; - if (hikp_get_bit(vf_entry->func_bitmap[idx], offset) != 0) { -@@ -490,10 +496,11 @@ static int hikp_nic_ppp_get_blk(struct hikp_cmd_header *req_header, - goto out; - - rsp = (struct nic_ppp_rsp *)cmd_ret->rsp_data; -- if (rsp->rsp_head.cur_blk_size > buf_len) { -+ if (rsp->rsp_head.cur_blk_size > buf_len || -+ rsp->rsp_head.cur_blk_size > sizeof(rsp->rsp_data)) { - HIKP_ERROR_PRINT("nic_ppp block context copy size error, " -- "buffer size=%zu, data size=%u.\n", -- buf_len, rsp->rsp_head.cur_blk_size); -+ "dst buffer size=%zu, src buffer size=%zu, data size=%u.\n", -+ buf_len, sizeof(rsp->rsp_data), rsp->rsp_head.cur_blk_size); - ret = -EINVAL; - goto out; - } -@@ -532,6 +539,17 @@ static int hikp_nic_ppp_query_uc_mac_addr(struct hikp_cmd_header *req_header, - idx, ret); - return ret; - } -+ if (rsp_head.next_entry_idx <= idx) { -+ HIKP_ERROR_PRINT("Next entry index (%u) should be greater than current (%u).\n", -+ rsp_head.next_entry_idx, idx); -+ return -EINVAL; -+ } -+ if (entry_size + rsp_head.cur_blk_entry_cnt > max_hw_entry_size) { -+ HIKP_ERROR_PRINT("The sum of entry number (%lu) after block-%u " -+ "is over the maximum entry nubmer (%u) of unicast MAC table.\n", -+ entry_size + rsp_head.cur_blk_entry_cnt, idx, max_hw_entry_size); -+ return -EINVAL; -+ } - entry_size += rsp_head.cur_blk_entry_cnt; - idx = rsp_head.next_entry_idx; - } -@@ -563,6 +581,17 @@ static int hikp_nic_ppp_query_mc_mac_addr(struct hikp_cmd_header *req_header, - idx, ret); - return ret; - } -+ if (rsp_head.next_entry_idx <= idx) { -+ HIKP_ERROR_PRINT("Next entry index (%u) should be greater than current (%u).\n", -+ rsp_head.next_entry_idx, idx); -+ return -EINVAL; -+ } -+ if (entry_size + rsp_head.cur_blk_entry_cnt > max_hw_entry_size) { -+ HIKP_ERROR_PRINT("The sum of entry number (%lu) after block-%u " -+ "is over the maximum entry nubmer (%u) of multicast MAC table.\n", -+ entry_size + rsp_head.cur_blk_entry_cnt, idx, max_hw_entry_size); -+ return -EINVAL; -+ } - entry_size += rsp_head.cur_blk_entry_cnt; - idx = rsp_head.next_entry_idx; - } -@@ -623,6 +652,17 @@ static int hikp_nic_ppp_query_vf_vlan_tbl(struct hikp_cmd_header *req_header, - idx, ret); - return ret; - } -+ if (rsp_head.next_entry_idx <= idx) { -+ HIKP_ERROR_PRINT("Next entry index (%u) should be greater than current (%u).\n", -+ rsp_head.next_entry_idx, idx); -+ return -EINVAL; -+ } -+ if (entry_size + rsp_head.cur_blk_entry_cnt > hw_entry_size) { -+ HIKP_ERROR_PRINT("The sum of entry number (%lu) after block-%u " -+ "is over the maximum entry nubmer (%u) of VF VLAN table.\n", -+ entry_size + rsp_head.cur_blk_entry_cnt, idx, hw_entry_size); -+ return -EINVAL; -+ } - entry_size += rsp_head.cur_blk_entry_cnt; - idx = rsp_head.next_entry_idx; - } -@@ -653,6 +693,17 @@ static int hikp_nic_ppp_query_port_vlan_tbl(struct hikp_cmd_header *req_header, - idx, ret); - return ret; - } -+ if (rsp_head.next_entry_idx <= idx) { -+ HIKP_ERROR_PRINT("Next entry index (%u) should be greater than current (%u).\n", -+ rsp_head.next_entry_idx, idx); -+ return -EINVAL; -+ } -+ if (entry_size + rsp_head.cur_blk_entry_cnt > hw_entry_size) { -+ HIKP_ERROR_PRINT("The sum of entry number (%lu) after block-%u " -+ "is over the maximum entry nubmer (%u) of port VLAN table.\n", -+ entry_size + rsp_head.cur_blk_entry_cnt, idx, hw_entry_size); -+ return -EINVAL; -+ } - entry_size += rsp_head.cur_blk_entry_cnt; - idx = rsp_head.next_entry_idx; - } -@@ -704,6 +755,17 @@ static int hikp_nic_query_mng_tbl(struct hikp_cmd_header *req_header, - idx, ret); - return ret; - } -+ if (rsp_head.next_entry_idx <= idx) { -+ HIKP_ERROR_PRINT("Next entry index (%u) should be greater than current (%u).\n", -+ rsp_head.next_entry_idx, idx); -+ return -EINVAL; -+ } -+ if (entry_size + rsp_head.cur_blk_entry_cnt > g_ppp_hw_res.mng_tbl_size) { -+ HIKP_ERROR_PRINT("The sum of entry number (%lu) after block-%u " -+ "is over the maximum entry nubmer (%u) of manager table.\n", -+ entry_size + rsp_head.cur_blk_entry_cnt, idx, g_ppp_hw_res.mng_tbl_size); -+ return -EINVAL; -+ } - entry_size += rsp_head.cur_blk_entry_cnt; - idx = rsp_head.next_entry_idx; - } -@@ -729,6 +791,24 @@ static int hikp_nic_query_ppp_by_entryid(struct hikp_cmd_header *req_header, - return hikp_nic_query_mng_tbl(req_header, &req_data, (struct nic_mng_tbl *)data); - } - -+static int hikp_nic_ppp_check_func_num(void *data) -+{ -+ const struct ppp_feature_cmd *ppp_cmd; -+ uint16_t func_num = 0; -+ -+ ppp_cmd = &g_ppp_feature_cmd[g_ppp_param.feature_idx]; -+ if (ppp_cmd->sub_cmd_code == NIC_PROMISCUOUS_TBL_DUMP) -+ func_num = ((struct nic_promisc_tbl *)data)->func_num; -+ else if (ppp_cmd->sub_cmd_code == NIC_VLAN_OFFLOAD_DUMP) -+ func_num = ((struct nic_vlan_offload_cfg *)data)->func_num; -+ -+ if (func_num > HIKP_NIC_MAX_FUNC_NUM) { -+ HIKP_ERROR_PRINT("Illegal function num(%u) from firmware.\n", func_num); -+ return -EINVAL; -+ } -+ return 0; -+} -+ - static int hikp_nic_query_ppp_by_blkid(struct hikp_cmd_header *req_header, const struct bdf_t *bdf, - void *data, size_t len) - { -@@ -752,6 +832,10 @@ static int hikp_nic_query_ppp_by_blkid(struct hikp_cmd_header *req_header, const - /* Copy the remaining block content if total block number is greater than 1. */ - for (blk_id = 1; blk_id < total_blk_num; blk_id++) { - req_data.block_id = blk_id; -+ if (len <= total_blk_size) { -+ HIKP_ERROR_PRINT("No enough buffer to get block-%u context.\n", blk_id); -+ return -ENOMEM; -+ } - ret = hikp_nic_ppp_get_blk(req_header, &req_data, (uint8_t *)data + total_blk_size, - len - total_blk_size, &rsp_head); - if (ret != 0) { -@@ -761,7 +845,7 @@ static int hikp_nic_query_ppp_by_blkid(struct hikp_cmd_header *req_header, const - total_blk_size += rsp_head.cur_blk_size; - } - -- return ret; -+ return hikp_nic_ppp_check_func_num(data); - } - - static int hikp_nic_ppp_get_hw_resources(const struct bdf_t *bdf, -@@ -975,6 +1059,46 @@ static int hikp_nic_check_func_id_valid(struct major_cmd_ctrl *self, - return 0; - } - -+static int hikp_nic_check_hw_res(struct hikp_nic_ppp_hw_resources *hw_res) -+{ -+ if (!g_ppp_feature_cmd[g_ppp_param.feature_idx].need_query_hw_res) -+ return 0; -+ -+ if (hw_res->max_key_mem_size == 0) { -+ HIKP_ERROR_PRINT("Max key memory size should not be zero!\n"); -+ return -EINVAL; -+ } -+ if (hw_res->port_vlan_tbl_size == 0) { -+ HIKP_ERROR_PRINT("PORT VLAN Table size should not be zero!\n"); -+ return -EINVAL; -+ } -+ if (hw_res->vf_vlan_tbl_size == 0) { -+ HIKP_ERROR_PRINT("VF VLAN Table size should not be zero!\n"); -+ return -EINVAL; -+ } -+ if (hw_res->mng_tbl_size == 0) { -+ HIKP_ERROR_PRINT("VF VLAN Table size (%u)is zero!\n"); -+ return -EINVAL; -+ } -+ if (hw_res->mac_id >= HIKP_PPP_MAX_MAC_ID_NUM) { -+ HIKP_ERROR_PRINT("MAC ID (%u) should be less than %u.\n", -+ hw_res->mac_id, HIKP_PPP_MAX_MAC_ID_NUM); -+ return -EINVAL; -+ } -+ if (hw_res->total_func_num == 0 || hw_res->total_func_num > HIKP_NIC_MAX_FUNC_NUM) { -+ HIKP_ERROR_PRINT("Total_func_num (%u)should be in [1, %u].\n", -+ hw_res->total_func_num, HIKP_NIC_MAX_FUNC_NUM); -+ return -EINVAL; -+ } -+ if (hw_res->abs_func_id_base >= HIKP_NIC_MAX_FUNC_NUM) { -+ HIKP_ERROR_PRINT("Function ID base (%u) should be less than %u.\n", -+ hw_res->abs_func_id_base, HIKP_NIC_MAX_FUNC_NUM); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ - static void hikp_nic_ppp_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_ppp_param.target.bdf; -@@ -995,6 +1119,14 @@ static void hikp_nic_ppp_cmd_execute(struct major_cmd_ctrl *self) - return; - } - -+ ret = hikp_nic_check_hw_res(&g_ppp_hw_res); -+ if (ret != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "ppp hardware resources obtained is invalid."); -+ self->err_no = ret; -+ return; -+ } -+ - ppp_cmd = &g_ppp_feature_cmd[g_ppp_param.feature_idx]; - ret = hikp_nic_check_func_id_valid(self, ppp_cmd, &g_ppp_param, &g_ppp_hw_res); - if (ret != 0) --- -2.45.0.windows.1 - diff --git a/0071-hikptool-nic-add-check-for-the-value-from-FW.patch b/0071-hikptool-nic-add-check-for-the-value-from-FW.patch deleted file mode 100644 index 8a0dbe12a1fcb8f8803e2661d9ff2d6ea03d6c01..0000000000000000000000000000000000000000 --- a/0071-hikptool-nic-add-check-for-the-value-from-FW.patch +++ /dev/null @@ -1,172 +0,0 @@ -From a2514156dfd5ec10fa30e72dbc6496e0b8c87846 Mon Sep 17 00:00:00 2001 -From: Dengdui Huang -Date: Thu, 15 Aug 2024 17:29:32 +0800 -Subject: [PATCH 09/27] hikptool/nic: add check for the value from FW - -The value obtained from the firmware is unreliable, -and the software needs to verify the validity. - -Signed-off-by: Dengdui Huang ---- - net/nic/nic_fd/hikp_nic_fd.c | 44 +++++++++++++++++++++++++++--- - net/nic/nic_qos/hikp_nic_qos.c | 8 ++++-- - net/nic/nic_queue/hikp_nic_queue.c | 8 ++++-- - net/nic/nic_rss/hikp_nic_rss.c | 8 ++++-- - 4 files changed, 55 insertions(+), 13 deletions(-) - -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index e699bf9..3d6a9dc 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -550,7 +550,7 @@ static void hikp_nic_show_fd_counter(const void *data) - - static int hikp_nic_fd_get_blk(struct hikp_cmd_header *req_header, - const struct nic_fd_req_para *req_data, -- void *buf, uint32_t buf_len, struct nic_fd_rsp_head *rsp_head) -+ void *buf, size_t buf_len, struct nic_fd_rsp_head *rsp_head) - { - struct hikp_cmd_ret *cmd_ret; - struct nic_fd_rsp *rsp; -@@ -563,10 +563,12 @@ static int hikp_nic_fd_get_blk(struct hikp_cmd_header *req_header, - } - - rsp = (struct nic_fd_rsp *)cmd_ret->rsp_data; -- if (rsp->rsp_head.cur_blk_size > buf_len) { -+ if (rsp->rsp_head.cur_blk_size > buf_len || -+ rsp->rsp_head.cur_blk_size > sizeof(rsp->rsp_data)) { - HIKP_ERROR_PRINT("nic_fd block context copy size error, " -- "buffer size=%u, data size=%u.\n", -- buf_len, rsp->rsp_head.cur_blk_size); -+ "dst buffer size=%zu, src buffer size=%zu, " -+ "data size=%u.\n", buf_len, sizeof(rsp->rsp_data), -+ rsp->rsp_head.cur_blk_size); - ret = -EINVAL; - goto out; - } -@@ -657,7 +659,19 @@ static int hikp_nic_query_fd_rules(struct hikp_cmd_header *req_header, const str - idx, ret); - return ret; - } -+ if (rsp_head.cur_blk_entry_cnt + entry_cnt > g_fd_hw_info.alloc.stage_entry_num[stage]) { -+ HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " -+ "is over the maximum entry nubmer (%u) of this stage.", -+ rsp_head.cur_blk_entry_cnt + entry_cnt, idx, -+ g_fd_hw_info.alloc.stage_entry_num[stage]); -+ return -EINVAL; -+ } - entry_cnt += rsp_head.cur_blk_entry_cnt; -+ if (rsp_head.next_entry_idx <= idx) { -+ HIKP_ERROR_PRINT("The next entry index (%u) is less than or equal with the curent(%u).\n", -+ rsp_head.next_entry_idx, idx); -+ return -EINVAL; -+ } - idx = rsp_head.next_entry_idx; - if (req_data.query_single_entry == 1) - break; -@@ -702,7 +716,19 @@ static int hikp_nic_query_fd_counter(struct hikp_cmd_header *req_header, const s - idx, ret); - return ret; - } -+ if (rsp_head.cur_blk_entry_cnt + entry_size > g_fd_hw_info.alloc.stage_counter_num[stage]) { -+ HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " -+ "is over the maximum counter nubmer (%u) of this stage.", -+ rsp_head.cur_blk_entry_cnt + entry_size, idx, -+ g_fd_hw_info.alloc.stage_counter_num[stage]); -+ return -EINVAL; -+ } - entry_size += rsp_head.cur_blk_entry_cnt; -+ if (rsp_head.next_entry_idx <= idx) { -+ HIKP_ERROR_PRINT("The next entry index (%u) is less than or equal with the curent(%u).\n", -+ rsp_head.next_entry_idx, idx); -+ return -EINVAL; -+ } - idx = rsp_head.next_entry_idx; - if (req_data.query_single_entry == 1) - break; -@@ -808,6 +834,11 @@ static int hikp_nic_check_fd_hw_info(const struct nic_fd_hw_info *hw_info, - uint16_t i; - - if (strcmp(fd_cmd->feature_name, NIC_FD_RULES_NAME) == 0) { -+ /* Stage2 does not support query. So only stage1 is verified. */ -+ if(hw_info->alloc.stage_entry_num[NIC_FD_STAGE_1] == 0) { -+ HIKP_ERROR_PRINT("The stage1's entry number is zero.\n"); -+ return -EINVAL; -+ } - if (hw_info->mode > FD_MODE_DEPTH_2K_WIDTH_200B_STAGE_2) - HIKP_WARN_PRINT("Unknown fd mode(%u), " - "unsupport for displaying meta data info.\n", -@@ -822,6 +853,11 @@ static int hikp_nic_check_fd_hw_info(const struct nic_fd_hw_info *hw_info, - return -EOPNOTSUPP; - } - } -+ } else if (strcmp(fd_cmd->feature_name, NIC_FD_COUNTER_NAME) == 0) { -+ if (hw_info->alloc.stage_counter_num[NIC_FD_STAGE_1] == 0) { -+ HIKP_ERROR_PRINT("The stage1's counter number is zero.\n"); -+ return -EINVAL; -+ } - } - - return 0; -diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c -index a09b4f1..9e997e4 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.c -+++ b/net/nic/nic_qos/hikp_nic_qos.c -@@ -174,10 +174,12 @@ static int hikp_nic_qos_get_blk(struct hikp_cmd_header *req_header, - } - - rsp = (struct nic_qos_rsp *)cmd_ret->rsp_data; -- if (rsp->rsp_head.cur_blk_size > buf_len) { -+ if (rsp->rsp_head.cur_blk_size > buf_len || -+ rsp->rsp_head.cur_blk_size > sizeof(rsp->rsp_data)) { - HIKP_ERROR_PRINT("nic_qos block-%u copy size error, " -- "buffer size=%zu, data size=%u.\n", -- req_data->block_id, buf_len, rsp->rsp_head.cur_blk_size); -+ "dst buffer size=%zu, src buffer size=%zu, " -+ "data size=%u.\n", req_data->block_id, buf_len, -+ sizeof(rsp->rsp_data), rsp->rsp_head.cur_blk_size); - ret = -EINVAL; - goto out; - } -diff --git a/net/nic/nic_queue/hikp_nic_queue.c b/net/nic/nic_queue/hikp_nic_queue.c -index fa3b9d3..c73c8f7 100644 ---- a/net/nic/nic_queue/hikp_nic_queue.c -+++ b/net/nic/nic_queue/hikp_nic_queue.c -@@ -246,10 +246,12 @@ static int hikp_nic_queue_get_blk(struct hikp_cmd_header *req_header, - } - - rsp = (struct nic_queue_rsp *)cmd_ret->rsp_data; -- if (rsp->rsp_head.cur_blk_size > buf_len) { -+ if (rsp->rsp_head.cur_blk_size > buf_len || -+ rsp->rsp_head.cur_blk_size > sizeof(rsp->rsp_data)) { - HIKP_ERROR_PRINT("nic_queue block-%u copy size error, " -- "buffer size=%zu, data size=%u.\n", -- req_data->block_id, buf_len, rsp->rsp_head.cur_blk_size); -+ "dst buffer size=%zu, src buffer size=%zu, " -+ "data size=%u.\n", req_data->block_id, buf_len, -+ sizeof(rsp->rsp_data), rsp->rsp_head.cur_blk_size); - ret = -EINVAL; - goto out; - } -diff --git a/net/nic/nic_rss/hikp_nic_rss.c b/net/nic/nic_rss/hikp_nic_rss.c -index ff1cfd2..558f931 100644 ---- a/net/nic/nic_rss/hikp_nic_rss.c -+++ b/net/nic/nic_rss/hikp_nic_rss.c -@@ -364,10 +364,12 @@ static int hikp_nic_rss_get_blk(struct hikp_cmd_header *req_header, - } - - rsp = (struct nic_rss_rsp *)cmd_ret->rsp_data; -- if (rsp->rsp_head.cur_blk_size > buf_len) { -+ if (rsp->rsp_head.cur_blk_size > buf_len || -+ rsp->rsp_head.cur_blk_size > sizeof(rsp->rsp_data)) { - HIKP_ERROR_PRINT("nic_rss block-%u copy size error, " -- "buffer size=%zu, data size=%u.\n", -- req_data->block_id, buf_len, rsp->rsp_head.cur_blk_size); -+ "dst buffer size=%zu, src buffer size=%zu, " -+ "data size=%u.\n", req_data->block_id, buf_len, -+ sizeof(rsp->rsp_data), rsp->rsp_head.cur_blk_size); - ret = -EINVAL; - goto out; - } --- -2.45.0.windows.1 - diff --git a/0072-hikptool-nic-Fix-the-Code-review-comments-in-NIC-mod.patch b/0072-hikptool-nic-Fix-the-Code-review-comments-in-NIC-mod.patch deleted file mode 100644 index 22712a79ab28bdf2b23598aaf0b14c412f65c879..0000000000000000000000000000000000000000 --- a/0072-hikptool-nic-Fix-the-Code-review-comments-in-NIC-mod.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 54d612f78a417090bc0449658426d9180b84b2e9 Mon Sep 17 00:00:00 2001 -From: Jijie Shao -Date: Wed, 14 Aug 2024 16:16:57 +0800 -Subject: [PATCH 10/27] hikptool: nic: Fix the Code review comments in NIC - modules - -Fix issue of Out-of-bounds access may occur. - -Signed-off-by: Jijie Shao ---- - net/nic/nic_dfx/hikp_nic_dfx.c | 20 +++++++++++++++++++- - net/nic/nic_mac/hikp_nic_port.c | 7 +++++++ - 2 files changed, 26 insertions(+), 1 deletion(-) - -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c -index 4095229..2cc4367 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.c -+++ b/net/nic/nic_dfx/hikp_nic_dfx.c -@@ -21,6 +21,9 @@ - #include "hikp_net_lib.h" - #include "hikp_nic_dfx.h" - -+#define dfx_get_max_reg_bffer_size(rsp_head) \ -+ (uint32_t)((rsp_head)->total_blk_num * MAX_DFX_DATA_NUM * sizeof(uint32_t)) -+ - struct nic_dfx_param g_dfx_param = { 0 }; - - static const struct dfx_module_cmd g_dfx_module_parse[] = { -@@ -138,7 +141,7 @@ static int hikp_nic_get_first_blk_dfx(struct nic_dfx_rsp_head_t *rsp_head, uint3 - rsp_head->total_type_num = 0; - goto err_out; - } -- *max_dfx_size = (uint32_t)(rsp_head->total_blk_num * MAX_DFX_DATA_NUM * sizeof(uint32_t)); -+ *max_dfx_size = dfx_get_max_reg_bffer_size(rsp_head); - *reg_data = (uint32_t *)calloc(1, *max_dfx_size); - if (*reg_data == NULL) { - HIKP_ERROR_PRINT("malloc log memory 0x%x failed.\n", *max_dfx_size); -@@ -284,8 +287,23 @@ static void hikp_nic_dfx_print(const struct nic_dfx_rsp_head_t *rsp_head, uint32 - struct nic_dfx_type_head *type_head; - uint8_t last_type_id = 0; - uint32_t *ptr = reg_data; -+ uint32_t max_size; -+ uint32_t num_u32; - uint8_t i; - -+ max_size = dfx_get_max_reg_bffer_size(rsp_head); -+ for (i = 0; i < rsp_head->total_type_num; i++) { -+ type_head = (struct nic_dfx_type_head *)ptr; -+ num_u32 = type_head->reg_num * WORD_NUM_PER_REG + 1; /* including type_head */ -+ if (max_size < num_u32 * sizeof(uint32_t)) { -+ HIKP_ERROR_PRINT("register real size exceeds the max size\n"); -+ return; -+ } -+ ptr += num_u32; -+ max_size -= num_u32 * sizeof(uint32_t); -+ } -+ -+ ptr = reg_data; - printf("****************** module %s reg dump start ********************\n", - g_dfx_module_parse[g_dfx_param.module_idx].module_name); - for (i = 0; i < rsp_head->total_type_num; i++) { -diff --git a/net/nic/nic_mac/hikp_nic_port.c b/net/nic/nic_mac/hikp_nic_port.c -index 725ef95..f818001 100644 ---- a/net/nic/nic_mac/hikp_nic_port.c -+++ b/net/nic/nic_mac/hikp_nic_port.c -@@ -498,9 +498,16 @@ static void mac_cmd_print_cdr_dfx(struct mac_cmd_cdr_dfx *cdr_dfx, struct mac_po - - static void mac_cmd_disp_cdr_info(struct mac_cmd_cdr_dfx *cdr_dfx) - { -+ uint8_t cdr_max_num = HIKP_ARRAY_SIZE(cdr_dfx->wire_cdr.dfx); -+ - if (!cdr_dfx->cdr_num) - return; - -+ if (cdr_dfx->cdr_num > cdr_max_num) { -+ printf("the cdr_num(%u) exceeds %u\n", cdr_dfx->cdr_num, cdr_max_num); -+ return; -+ } -+ - printf("\n======================== PORT CDR INFO =======================\n"); - printf("direct\t|addr |lane |type |mode |status \n"); - printf("----------------------------------------------------------------------------\n"); --- -2.45.0.windows.1 - diff --git a/0073-hikptool-nic-return-real-errno-if-realpath-failed-in.patch b/0073-hikptool-nic-return-real-errno-if-realpath-failed-in.patch deleted file mode 100644 index 0c3df09ab62a0ecb9718d69e44d120acc8d93f7f..0000000000000000000000000000000000000000 --- a/0073-hikptool-nic-return-real-errno-if-realpath-failed-in.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0a53156f7281337ac037ea334f7011b54a6f5655 Mon Sep 17 00:00:00 2001 -From: Peiyang Wang -Date: Tue, 20 Aug 2024 16:33:35 +0800 -Subject: [PATCH 11/27] hikptool: nic: return real errno if realpath failed in - NIC module - -Return real errno if realpath failed. - -Signed-off-by: Peiyang Wang ---- - net/hikp_net_lib.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/net/hikp_net_lib.c b/net/hikp_net_lib.c -index 8db4ad5..32b278b 100644 ---- a/net/hikp_net_lib.c -+++ b/net/hikp_net_lib.c -@@ -25,7 +25,7 @@ - - static int hikp_read_net_pci_info(const char *file_path, char *content, size_t len) - { -- char path[PATH_MAX + 1] = { 0 }; -+ char path[PATH_MAX] = { 0 }; /* PATH_MAX includes the \0 so +1 is not required */ - int ret; - int fd; - -@@ -35,9 +35,12 @@ static int hikp_read_net_pci_info(const char *file_path, char *content, size_t l - if (len > MAX_PCI_ID_LEN + 1 || len < 1) - return -EINVAL; - -- if (strlen(file_path) > PATH_MAX || realpath(file_path, path) == NULL) -+ if (strlen(file_path) > PATH_MAX) - return -ENOENT; - -+ if (!realpath(file_path, path)) -+ return -errno; -+ - fd = open(path, O_RDONLY); - if (fd < 0) - return -EPERM; --- -2.45.0.windows.1 - diff --git a/0074-hikptool-nic-return-real-cmd-status-if-alloc-failed-.patch b/0074-hikptool-nic-return-real-cmd-status-if-alloc-failed-.patch deleted file mode 100644 index 98e93c216bdca214aa76b739d4fe28c9f3fe5b3a..0000000000000000000000000000000000000000 --- a/0074-hikptool-nic-return-real-cmd-status-if-alloc-failed-.patch +++ /dev/null @@ -1,165 +0,0 @@ -From 40f0b1281cb66cbd19c7ffdab7746857a4d89409 Mon Sep 17 00:00:00 2001 -From: Peiyang Wang -Date: Tue, 20 Aug 2024 16:46:41 +0800 -Subject: [PATCH 12/27] hikptool: nic: return real cmd status if alloc failed - in NIC module - -return real cmd status if alloc failed - -Signed-off-by: Peiyang Wang ---- - net/nic/nic_fec/hikp_nic_fec.c | 11 ++++++----- - net/nic/nic_ft/hikp_nic_port_fault.c | 9 +++++---- - net/nic/nic_gro/hikp_nic_gro.c | 11 ++++++----- - net/nic/nic_torus/hikp_nic_torus.c | 9 +++++---- - 4 files changed, 22 insertions(+), 18 deletions(-) - -diff --git a/net/nic/nic_fec/hikp_nic_fec.c b/net/nic/nic_fec/hikp_nic_fec.c -index 342b3eb..edea28b 100644 ---- a/net/nic/nic_fec/hikp_nic_fec.c -+++ b/net/nic/nic_fec/hikp_nic_fec.c -@@ -22,19 +22,20 @@ static struct tool_target g_fec_target; - - static int hikp_nic_fec_err_query(const struct bdf_t *bdf, struct nic_fec_err_info *info) - { -- struct nic_fec_req_para req = { 0 }; - struct hikp_cmd_header header = { 0 }; -+ struct nic_fec_req_para req = { 0 }; - struct hikp_cmd_ret *cmd_ret; - struct nic_fec_rsp *rsp; -+ int ret; - - req.bdf = *bdf; - hikp_cmd_init(&header, NIC_MOD, GET_FEC_INFO_CMD, NIC_FEC_ERR_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- HIKP_ERROR_PRINT("fail to get fec info, retcode: %u\n", -- cmd_ret ? cmd_ret->status : EIO); -+ ret = cmd_ret ? -cmd_ret->status : -EIO; -+ HIKP_ERROR_PRINT("fail to get fec info, retcode: %d\n", ret); - free(cmd_ret); -- return -EIO; -+ return ret; - } - - rsp = (struct nic_fec_rsp *)cmd_ret->rsp_data; -@@ -111,7 +112,7 @@ static void hikp_nic_fec_err_show(const struct nic_fec_err_info *info) - static void hikp_nic_fec_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_fec_target.bdf; -- struct nic_fec_err_info info; -+ struct nic_fec_err_info info = { 0 }; - int ret; - - ret = hikp_nic_fec_err_query(bdf, &info); -diff --git a/net/nic/nic_ft/hikp_nic_port_fault.c b/net/nic/nic_ft/hikp_nic_port_fault.c -index fd94214..85fa874 100644 ---- a/net/nic/nic_ft/hikp_nic_port_fault.c -+++ b/net/nic/nic_ft/hikp_nic_port_fault.c -@@ -26,18 +26,19 @@ static int hikp_nic_port_fault_query(const struct bdf_t *bdf, - struct hikp_cmd_header header = { 0 }; - struct nic_port_fault_rsp *rsp; - struct hikp_cmd_ret *cmd_ret; -+ int ret = 0; - - req.bdf = *bdf; - hikp_cmd_init(&header, NIC_MOD, GET_PORT_FAULT_STATUS, - NIC_PORT_FAULT_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- HIKP_ERROR_PRINT("fail to get port fault, retcode: %u\n", -- cmd_ret ? cmd_ret->status : EIO); -+ ret = cmd_ret ? -cmd_ret->status : -EIO; -+ HIKP_ERROR_PRINT("fail to get port fault, retcode: %d\n", ret); - if (cmd_ret != NULL) - free(cmd_ret); - -- return -EIO; -+ return ret; - } - - rsp = (struct nic_port_fault_rsp *)cmd_ret->rsp_data; -@@ -83,7 +84,7 @@ static void hikp_nic_port_fault_show(struct nic_port_fault_status *info) - static void hikp_nic_port_fault_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_port_fault_target.bdf; -- struct nic_port_fault_status info; -+ struct nic_port_fault_status info = { 0 }; - int ret; - - ret = hikp_nic_port_fault_query(bdf, &info); -diff --git a/net/nic/nic_gro/hikp_nic_gro.c b/net/nic/nic_gro/hikp_nic_gro.c -index 84b54c8..d897f11 100644 ---- a/net/nic/nic_gro/hikp_nic_gro.c -+++ b/net/nic/nic_gro/hikp_nic_gro.c -@@ -22,19 +22,20 @@ static struct tool_target g_gro_target; - - static int hikp_nic_gro_query(const struct bdf_t *bdf, struct nic_gro_info *info) - { -- struct nic_gro_req_para req = { 0 }; - struct hikp_cmd_header header = { 0 }; -+ struct nic_gro_req_para req = { 0 }; - struct hikp_cmd_ret *cmd_ret; - struct nic_gro_rsp *rsp; -+ int ret = 0; - - req.bdf = *bdf; - hikp_cmd_init(&header, NIC_MOD, GET_GRO_INFO_CMD, NIC_GRO_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- HIKP_ERROR_PRINT("fail to get gro info, retcode: %u\n", -- cmd_ret ? cmd_ret->status : EIO); -+ ret = cmd_ret ? -cmd_ret->status : -EIO; -+ HIKP_ERROR_PRINT("fail to get gro info, retcode: %d\n", ret); - free(cmd_ret); -- return -EIO; -+ return ret; - } - - rsp = (struct nic_gro_rsp *)cmd_ret->rsp_data; -@@ -55,7 +56,7 @@ static void hikp_nic_gro_show(const struct nic_gro_info *info) - static void hikp_nic_gro_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_gro_target.bdf; -- struct nic_gro_info info; -+ struct nic_gro_info info = { 0 }; - int ret; - - ret = hikp_nic_gro_query(bdf, &info); -diff --git a/net/nic/nic_torus/hikp_nic_torus.c b/net/nic/nic_torus/hikp_nic_torus.c -index 4baede6..9483bfe 100644 ---- a/net/nic/nic_torus/hikp_nic_torus.c -+++ b/net/nic/nic_torus/hikp_nic_torus.c -@@ -27,16 +27,17 @@ static int hikp_nic_torus_query(const struct bdf_t *bdf, - struct hikp_cmd_header header = { 0 }; - struct hikp_cmd_ret *cmd_ret; - struct nic_torus_rsp *rsp; -+ int ret = 0; - - req.bdf = *bdf; - hikp_cmd_init(&header, NIC_MOD, GET_TORUS_INFO_CMD, NIC_TORUS_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- HIKP_ERROR_PRINT("fail to get torus info, retcode: %u\n", -- cmd_ret ? cmd_ret->status : EIO); -+ ret = cmd_ret ? -cmd_ret->status : -EIO; -+ HIKP_ERROR_PRINT("fail to get torus info, retcode: %d\n", ret); - if (cmd_ret) - free(cmd_ret); -- return -EIO; -+ return ret; - } - - rsp = (struct nic_torus_rsp *)cmd_ret->rsp_data; -@@ -133,7 +134,7 @@ static void hikp_nic_torus_show(const struct nic_torus_info *info) - static void hikp_nic_torus_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_torus_target.bdf; -- struct nic_torus_info info; -+ struct nic_torus_info info = { 0 }; - int ret; - - ret = hikp_nic_torus_query(bdf, &info); --- -2.45.0.windows.1 - diff --git a/0075-hikptool-nic-check-path-before-used-it-in-function-h.patch b/0075-hikptool-nic-check-path-before-used-it-in-function-h.patch deleted file mode 100644 index 0c9fd5c473340101a83510237458c099ea48c29b..0000000000000000000000000000000000000000 --- a/0075-hikptool-nic-check-path-before-used-it-in-function-h.patch +++ /dev/null @@ -1,40 +0,0 @@ -From e6127d30663daef7cb847265006b592eebbfc152 Mon Sep 17 00:00:00 2001 -From: Peiyang Wang -Date: Tue, 20 Aug 2024 17:02:33 +0800 -Subject: [PATCH 13/27] hikptool: nic: check path before used it in function - hikp_get_dir_name_of_device - -check path before used it in hikp_get_dir_name_of_device - -Signed-off-by: Peiyang Wang ---- - net/hikp_net_lib.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/net/hikp_net_lib.c b/net/hikp_net_lib.c -index 32b278b..4e1e305 100644 ---- a/net/hikp_net_lib.c -+++ b/net/hikp_net_lib.c -@@ -238,13 +238,17 @@ int get_revision_id_by_bdf(const struct bdf_t *bdf, char *revision_id, size_t id - - static int hikp_get_dir_name_of_device(const char *path, size_t len, char *dir_name) - { -+ char file_path[PATH_MAX] = { 0 }; /* PATH_MAX includes the \0 so +1 is not required */ - struct dirent *ptr; - DIR *dir = NULL; - -- if (len > PCI_MAX_DIR_NAME_LEN) -+ if (len > PCI_MAX_DIR_NAME_LEN || strlen(path) > PATH_MAX) - return -EINVAL; - -- dir = opendir(path); -+ if (!realpath(path, file_path)) -+ return -errno; -+ -+ dir = opendir(file_path); - if (dir == NULL) { - HIKP_ERROR_PRINT("read path %s fail.\n", path); - return -EINVAL; --- -2.45.0.windows.1 - diff --git a/0076-hikptool-nic-check-strtol-if-it-failed-in-get_numvfs.patch b/0076-hikptool-nic-check-strtol-if-it-failed-in-get_numvfs.patch deleted file mode 100644 index 4e43195f886555bc899990d4e0eb3dd57d6c5873..0000000000000000000000000000000000000000 --- a/0076-hikptool-nic-check-strtol-if-it-failed-in-get_numvfs.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 043c7d14e8b09bfe1b242bfcf2b0a3342e3d18da Mon Sep 17 00:00:00 2001 -From: Peiyang Wang -Date: Tue, 20 Aug 2024 17:16:53 +0800 -Subject: [PATCH 14/27] hikptool: nic: check strtol if it failed in - get_numvfs_by_bdf - -Since strtol() can legitimately return 0, LONG_MAX, or LONG_MIN (LLONG_MAX -or LLONG_MIN for strtoll()) on both success and failure. So set errno to 0 -and check it after calling. - -Signed-off-by: Peiyang Wang ---- - net/hikp_net_lib.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/net/hikp_net_lib.c b/net/hikp_net_lib.c -index 4e1e305..23adbdc 100644 ---- a/net/hikp_net_lib.c -+++ b/net/hikp_net_lib.c -@@ -366,7 +366,12 @@ int get_numvfs_by_bdf(const struct bdf_t *bdf, uint8_t *numvfs) - if (ret != 0) - return ret; - -+ errno = 0; - ret = (int)strtol(numvf, NULL, 0); -+ if (errno) { -+ HIKP_ERROR_PRINT("get numvfs by bdf failed, ret=%d\n", -errno); -+ return -errno; -+ } - if ((ret > UCHAR_MAX) || (ret < 0)) { - HIKP_ERROR_PRINT("get numvfs by bdf fail.\n"); - return -EINVAL; --- -2.45.0.windows.1 - diff --git a/0077-hikptool-nic-adding-NUL-at-the-end-of-the-buffer-len.patch b/0077-hikptool-nic-adding-NUL-at-the-end-of-the-buffer-len.patch deleted file mode 100644 index ed4a543e60365ea1b0918dc1a5525f45696073f4..0000000000000000000000000000000000000000 --- a/0077-hikptool-nic-adding-NUL-at-the-end-of-the-buffer-len.patch +++ /dev/null @@ -1,43 +0,0 @@ -From f24d89b76811f7b2bbfea787bb403358f960f097 Mon Sep 17 00:00:00 2001 -From: Peiyang Wang -Date: Wed, 21 Aug 2024 10:30:09 +0800 -Subject: [PATCH 15/27] hikptool: nic: adding NUL at the end of the buffer - length that is actually read. - -When pread is called, the return value may be smaller than the length that -want to read, the position of adding NUL is too much and memory might be -exposed. To avoid that case, to add NUL at the end of the buffer length -that is actually read. - -Signed-off-by: Peiyang Wang ---- - net/hikp_net_lib.c | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -diff --git a/net/hikp_net_lib.c b/net/hikp_net_lib.c -index 23adbdc..fbf03bd 100644 ---- a/net/hikp_net_lib.c -+++ b/net/hikp_net_lib.c -@@ -47,13 +47,14 @@ static int hikp_read_net_pci_info(const char *file_path, char *content, size_t l - - ret = pread(fd, content, len - 1, 0); - if (ret < 0) { -- close(fd); -- return -EIO; -+ ret = -errno; -+ } else { -+ content[ret] = '\0'; // The invoker ensures that the bounds are not crossed. -+ ret = 0; - } -- content[len - 1] = '\0'; // The invoker ensures that the bounds are not crossed. -- close(fd); - -- return 0; -+ close(fd); -+ return ret; - } - - int hikp_net_creat_sock(void) --- -2.45.0.windows.1 - diff --git a/0078-hikptool-nic-avoid-array-boundary-exceeded-in-hikp_n.patch b/0078-hikptool-nic-avoid-array-boundary-exceeded-in-hikp_n.patch deleted file mode 100644 index 6187f6e8103573f3bfa7d58446e12eda6f43a228..0000000000000000000000000000000000000000 --- a/0078-hikptool-nic-avoid-array-boundary-exceeded-in-hikp_n.patch +++ /dev/null @@ -1,59 +0,0 @@ -From bc4420a4c0cb1fa85b15d671c7ebabbe534a0196 Mon Sep 17 00:00:00 2001 -From: Peiyang Wang -Date: Wed, 21 Aug 2024 10:28:27 +0800 -Subject: [PATCH 16/27] hikptool: nic: avoid array boundary exceeded in - hikp_nic_info.c - -In hikp_nic_info.c, when using pf id or die id, the value should be not -bigger than the max value. Otherwise, array boundary exceeded might be -occurred. - -Signed-off-by: Peiyang Wang ---- - net/nic/nic_info/hikp_nic_info.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/net/nic/nic_info/hikp_nic_info.c b/net/nic/nic_info/hikp_nic_info.c -index 992bbf0..cd07b13 100644 ---- a/net/nic/nic_info/hikp_nic_info.c -+++ b/net/nic/nic_info/hikp_nic_info.c -@@ -113,6 +113,11 @@ static void hikp_nic_info_print_cur_pf(const struct bdf_t *bdf) - uint8_t i; - int ret; - -+ if (pf_id >= HIKP_MAX_PF_NUM) { -+ HIKP_ERROR_PRINT("pf_id(%u) is invalid.\n", pf_id); -+ return; -+ } -+ - printf("Current function: pf%u\n", pf_id); - printf("\t%-16s %s\n", "pf mode:", - g_info_param.info.pf_info[pf_id].pf_mode ? "X86" : "ARM"); -@@ -148,6 +153,11 @@ static void hikp_nic_info_print_cur_die(void) - { - uint8_t i; - -+ if (g_info_param.info.pf_num > HIKP_MAX_PF_NUM) { -+ HIKP_ERROR_PRINT("pf_num(%u) is invalid.\n", g_info_param.info.pf_num); -+ return; -+ } -+ - printf("Current die(chip%u-die%u) info:\n", - g_info_param.info.chip_id, g_info_param.info.die_id); - printf("revision id: %s", g_info_param.revision_id); -@@ -186,6 +196,12 @@ static bool is_bus_id_accessed(void) - { - uint8_t i; - -+ if (g_info_param.accessed_die_num >= MAX_DIE_NUM) { -+ HIKP_ERROR_PRINT("accessed_die_num(%u) is invalid.\n", -+ g_info_param.accessed_die_num); -+ return false; -+ } -+ - for (i = 0; i < g_info_param.accessed_die_num; i++) { - if (g_info_param.accessed_bus_id[i] == g_info_param.target.bdf.bus_id) - return true; --- -2.45.0.windows.1 - diff --git a/0079-hikptool-nic-Fix-bad-usage-of-format-string.patch b/0079-hikptool-nic-Fix-bad-usage-of-format-string.patch deleted file mode 100644 index f532a66cc680b56934a9f57304f594b12c171a67..0000000000000000000000000000000000000000 --- a/0079-hikptool-nic-Fix-bad-usage-of-format-string.patch +++ /dev/null @@ -1,31 +0,0 @@ -From dd185f7120e3a55af2ef4fc061aa3a271a986a1d Mon Sep 17 00:00:00 2001 -From: Jie Hai -Date: Thu, 29 Aug 2024 10:11:47 +0800 -Subject: [PATCH 17/27] hikptool/nic: Fix bad usage of format string - -The format string lacks parameters, which may cause -information leakage. This patch fixes it. - -Fixes: 8244390e29a3 ("hikptool/nic: Fix the Code review comments") - -Signed-off-by: Jie Hai ---- - net/nic/nic_ppp/hikp_nic_ppp.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index c070666..96f317b 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -1077,7 +1077,7 @@ static int hikp_nic_check_hw_res(struct hikp_nic_ppp_hw_resources *hw_res) - return -EINVAL; - } - if (hw_res->mng_tbl_size == 0) { -- HIKP_ERROR_PRINT("VF VLAN Table size (%u)is zero!\n"); -+ HIKP_ERROR_PRINT("Manager Table size should not be zero!\n"); - return -EINVAL; - } - if (hw_res->mac_id >= HIKP_PPP_MAX_MAC_ID_NUM) { --- -2.45.0.windows.1 - diff --git a/0080-hikptool-nic-Fix-potential-dead-loop.patch b/0080-hikptool-nic-Fix-potential-dead-loop.patch deleted file mode 100644 index aa791231d94676c9d288ba7aacfc12594dbc6cc5..0000000000000000000000000000000000000000 --- a/0080-hikptool-nic-Fix-potential-dead-loop.patch +++ /dev/null @@ -1,43 +0,0 @@ -From c89df2898b19f1a1503bd41c065aa163a1900b53 Mon Sep 17 00:00:00 2001 -From: Jie Hai -Date: Thu, 29 Aug 2024 10:08:55 +0800 -Subject: [PATCH 18/27] hikptool/nic: Fix potential dead loop - -When the loop variable range does not cover the upper bound -of the loop, an infinite loop occurs. This patch fixes it. - -Signed-off-by: Jie Hai ---- - net/nic/nic_fd/hikp_nic_fd.c | 2 +- - net/nic/nic_ppp/hikp_nic_ppp.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index 3d6a9dc..7125699 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -503,7 +503,7 @@ static void hikp_nic_show_fd_rules(const void *data) - struct nic_fd_rule_info *rule; - uint16_t max_key_bytes; - size_t one_rule_size; -- uint16_t i; -+ uint32_t i; - - key_cfg = &g_fd_hw_info.key_cfg[stage_no]; - stage_rules = &rules[stage_no]; -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index 96f317b..67a3be6 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -184,7 +184,7 @@ static void hikp_nic_ppp_show_func_uc_mac_addr(struct mac_vlan_uc_tbl *uc_tbl, - struct mac_vlan_uc_entry *uc_entry; - uint8_t pf_id; - uint8_t vf_id; -- uint8_t i; -+ uint32_t i; - - for (i = 0; i < uc_tbl->entry_size; i++) { - uc_entry = &uc_tbl->entry[i]; --- -2.45.0.windows.1 - diff --git a/0081-hikptool-Rectify-the-cleancode-issue.patch b/0081-hikptool-Rectify-the-cleancode-issue.patch deleted file mode 100644 index 2bfb188d21db1e3c662a48e51f91f3fd31814ec0..0000000000000000000000000000000000000000 --- a/0081-hikptool-Rectify-the-cleancode-issue.patch +++ /dev/null @@ -1,482 +0,0 @@ -From 90e86309519707998fa9b2b79df9734ea43f1304 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Tue, 12 Nov 2024 19:38:31 +0800 -Subject: [PATCH 19/27] hikptool: Rectify the cleancode issue. - -Rectify some cleancode alarms.Includes: -1. Add the function return value verification. -2. The logic for assigning values to output parameters of functions is optimized. -3. Use of parentheses. -4. Fix potential dead loop. -5. Fix unsigned-signed mixed use. - -Signed-off-by: veega2022 ---- - net/nic/nic_fd/hikp_nic_fd.c | 2 +- - net/nic/nic_log/hikp_nic_log.c | 7 +++-- - net/nic/nic_mac/hikp_nic_xsfp.h | 4 +-- - net/nic/nic_ppp/hikp_nic_ppp.c | 10 +++--- - .../roce_ext_common/hikp_roce_ext_common.c | 2 +- - net/roce/roce_qmm/hikp_roce_qmm.c | 2 +- - net/roce/roce_timer/hikp_roce_timer.c | 2 +- - net/roh/hikp_roh_mac.c | 24 ++++++-------- - net/roh/hikp_roh_show_bp.c | 2 +- - net/roh/hikp_roh_show_mib.c | 2 +- - net/ub/ub_crd/hikp_ub_crd.c | 4 +-- - net/ub/ub_ppp/hikp_unic_ppp.c | 4 +-- - ossl/ossl_user_linux.c | 10 +++--- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 2 +- - pcie/func_lib/pcie_func/pcie_statistics.c | 2 +- - serdes/hikp_serdes.c | 5 ++- - tool_lib/op_logs.c | 31 +++++++++++++------ - 17 files changed, 63 insertions(+), 52 deletions(-) - -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index 7125699..d4a9678 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -630,7 +630,7 @@ static int hikp_nic_query_fd_rules(struct hikp_cmd_header *req_header, const str - uint16_t max_key_bytes; - uint32_t left_buf_len; - size_t one_rule_size; -- uint16_t idx; -+ uint32_t idx; - int ret = 0; - - if (stage >= NIC_FD_STAGE_NUM) { -diff --git a/net/nic/nic_log/hikp_nic_log.c b/net/nic/nic_log/hikp_nic_log.c -index 893aef1..dc622e0 100644 ---- a/net/nic/nic_log/hikp_nic_log.c -+++ b/net/nic/nic_log/hikp_nic_log.c -@@ -106,7 +106,9 @@ static int hikp_nic_get_first_blk_info(uint32_t *total_blk_num, - - log_rsp = (struct nic_log_rsp_data *)(cmd_ret->rsp_data); - log_size = (uint32_t)(log_rsp->total_blk_num * MAX_LOG_DATA_NUM * sizeof(uint32_t)); -- if (log_size < log_rsp->cur_blk_size) { -+ if (log_rsp->cur_blk_size == 0 || -+ log_size < log_rsp->cur_blk_size || -+ log_rsp->cur_blk_size > sizeof(log_rsp->log_data)) { - HIKP_ERROR_PRINT("log size must bigger than current block size.\n"); - ret = -EINVAL; - goto err_out; -@@ -142,7 +144,8 @@ static int hikp_nic_get_log_info(uint32_t blk_id, uint32_t *cur_blk_size, uint8_ - log_rsp = (struct nic_log_rsp_data *)(cmd_ret->rsp_data); - *cur_blk_size = (uint32_t)log_rsp->cur_blk_size; - *blk_num = (uint32_t)log_rsp->total_blk_num; -- if (max_log_size < *cur_blk_size) { -+ if (max_log_size < *cur_blk_size || -+ *cur_blk_size > sizeof(log_rsp->log_data)) { - HIKP_ERROR_PRINT("log size must bigger than current block(%u) size.\n", blk_id); - ret = -EINVAL; - goto err_out; -diff --git a/net/nic/nic_mac/hikp_nic_xsfp.h b/net/nic/nic_mac/hikp_nic_xsfp.h -index 6f5e38f..a04ecdc 100644 ---- a/net/nic/nic_mac/hikp_nic_xsfp.h -+++ b/net/nic/nic_mac/hikp_nic_xsfp.h -@@ -176,7 +176,7 @@ struct sfp_a0_page { - uint8_t rsvd_dm : 1; - }; - uint8_t enhanced_options; /* reg 93: Enhanced Options */ -- uint8_t Sff_8472_compliance; /* reg 94: SFF-8472 Compliance */ -+ uint8_t sff_8472_compliance; /* reg 94: SFF-8472 Compliance */ - uint8_t cc_ext; /* reg 95: Check code for the Extended ID Fields (addresses 64 to 94) */ - - /* 96~255 */ -@@ -247,7 +247,7 @@ struct sfp_page_info { - #define QSFP_TRANS_OPTICAL_MAX 0x9 - - struct qsfp_page0_lower { -- uint8_t Identifier; /* reg 0: Identifier (1 Byte) */ -+ uint8_t identifier; /* reg 0: Identifier (1 Byte) */ - uint8_t revision_comp; /* reg 1: Revision Compliance */ - uint8_t status_indicator; /* reg 2: Status Indicators */ - uint8_t tx_rx_los; /* reg 3: Latched Tx/Rx LOS indicator */ -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index 67a3be6..3f777b3 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -519,13 +519,13 @@ out: - static int hikp_nic_ppp_query_uc_mac_addr(struct hikp_cmd_header *req_header, - struct nic_ppp_req_para *req_data, - struct mac_vlan_uc_tbl *uc_tbl, -- uint16_t max_hw_entry_size) -+ uint32_t max_hw_entry_size) - { - struct mac_vlan_uc_entry *uc_entry = uc_tbl->entry; - struct nic_ppp_rsp_head rsp_head = {0}; - uint32_t entry_size = 0; - size_t left_buf_len; -- uint16_t idx = 0; -+ uint32_t idx = 0; - int ret = 0; - - while (idx < max_hw_entry_size) { -@@ -561,13 +561,13 @@ static int hikp_nic_ppp_query_uc_mac_addr(struct hikp_cmd_header *req_header, - static int hikp_nic_ppp_query_mc_mac_addr(struct hikp_cmd_header *req_header, - struct nic_ppp_req_para *req_data, - struct mac_vlan_mc_tbl *mc_tbl, -- uint16_t max_hw_entry_size) -+ uint32_t max_hw_entry_size) - { - struct mac_vlan_mc_entry *mc_entry = mc_tbl->entry; - struct nic_ppp_rsp_head rsp_head = {0}; - uint32_t entry_size = 0; - size_t left_buf_len; -- uint16_t idx = 0; -+ uint32_t idx = 0; - int ret = 0; - - while (idx < max_hw_entry_size) { -@@ -1086,7 +1086,7 @@ static int hikp_nic_check_hw_res(struct hikp_nic_ppp_hw_resources *hw_res) - return -EINVAL; - } - if (hw_res->total_func_num == 0 || hw_res->total_func_num > HIKP_NIC_MAX_FUNC_NUM) { -- HIKP_ERROR_PRINT("Total_func_num (%u)should be in [1, %u].\n", -+ HIKP_ERROR_PRINT("Total_func_num (%u) should be in [1, %u].\n", - hw_res->total_func_num, HIKP_NIC_MAX_FUNC_NUM); - return -EINVAL; - } -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 bc3b883..cc9f509 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -169,7 +169,7 @@ static void hikp_roce_ext_print(enum roce_cmd_type cmd_type, - uint8_t arr_len = output->reg_name.arr_len; - uint32_t *offset = output->reg.offset; - uint32_t *data = output->reg.data; -- int i; -+ uint32_t i; - - printf("**************%s INFO*************\n", cmd_name); - printf("%-40s[addr_offset] : reg_data\n", "reg_name"); -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.c b/net/roce/roce_qmm/hikp_roce_qmm.c -index 9189f88..6ab2c84 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.c -+++ b/net/roce/roce_qmm/hikp_roce_qmm.c -@@ -154,8 +154,8 @@ static const struct reg_name_info { - static void hikp_roce_qmm_print(struct roce_qmm_rsp_data *qmm_rsp) - { - const char **reg_name; -+ uint32_t index = 0; - uint8_t arr_len; -- int index = 0; - - for (index = 0; index < HIKP_ARRAY_SIZE(g_qmm_reg_name_info_table); index++) { - if (g_qmm_reg_name_info_table[index].sub_cmd != g_roce_qmm_param.sub_cmd) -diff --git a/net/roce/roce_timer/hikp_roce_timer.c b/net/roce/roce_timer/hikp_roce_timer.c -index a36257e..ea35241 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.c -+++ b/net/roce/roce_timer/hikp_roce_timer.c -@@ -84,8 +84,8 @@ static void hikp_roce_timer_print(struct roce_timer_rsp_data *timer_rsp, - enum roce_timer_cmd_type cmd_type) - { - const char **reg_name; -+ uint32_t index = 0; - uint8_t arr_len; -- int index = 0; - - if (cmd_type == TIMER_SHOW_QPC) { - reg_name = g_timer_qpc_reg_name; -diff --git a/net/roh/hikp_roh_mac.c b/net/roh/hikp_roh_mac.c -index 43f954c..4a8cf7b 100644 ---- a/net/roh/hikp_roh_mac.c -+++ b/net/roh/hikp_roh_mac.c -@@ -39,34 +39,29 @@ static int hikp_roh_mac_target(struct major_cmd_ctrl *self, const char *argv) - return self->err_no; - } - --static int cmd_show_mac_type_parse(void) -+static void cmd_show_mac_type_parse(void) - { - g_roh_mac_param.flag |= CMD_SHOW_MAC_TYPE_FLAG; -- return 0; - } - --static int cmd_show_cam_parse(void) -+static void cmd_show_cam_parse(void) - { - g_roh_mac_param.flag |= CMD_SHOW_CAM_FLAG; -- return 0; - } - --static int cmd_show_credit_parse(void) -+static void cmd_show_credit_parse(void) - { - g_roh_mac_param.flag |= CMD_SHOW_CREDIT_CNT; -- return 0; - } - - static int hikp_roh_mac_show_parse(struct major_cmd_ctrl *self, const char *argv) - { -- int ret; -- - if (strncmp(argv, "cam", sizeof("cam")) == 0) { -- ret = cmd_show_cam_parse(); -+ cmd_show_cam_parse(); - } else if (strncmp(argv, "mac_type", sizeof("mac_type")) == 0) { -- ret = cmd_show_mac_type_parse(); -+ cmd_show_mac_type_parse(); - } else if (strncmp(argv, "credit", sizeof("credit")) == 0) { -- ret = cmd_show_credit_parse(); -+ cmd_show_credit_parse(); - } else { - hikp_roh_mac_help(self, NULL); - snprintf(self->err_str, sizeof(self->err_str), -@@ -74,7 +69,7 @@ static int hikp_roh_mac_show_parse(struct major_cmd_ctrl *self, const char *argv - self->err_no = -EINVAL; - return -EINVAL; - } -- return ret; -+ return 0; - } - - int hikp_roh_get_mac_type(struct major_cmd_ctrl *self, struct bdf_t bdf) -@@ -180,7 +175,7 @@ static int hikp_roh_build_cam(struct major_cmd_ctrl *self, struct cam_table_entr - - for (int i = 0; i < block_num; i++) { - req_data.bdf = g_roh_mac_param.target.bdf; -- req_data.cam_block_index = i; -+ req_data.cam_block_index = (uint32_t)i; - hikp_cmd_init(&req_header, ROH_MOD, HIKP_ROH_MAC, CMD_BUILD_CAM_TABLE); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -@@ -249,6 +244,7 @@ static int hikp_roh_query_crd(uint8_t crd_type, uint32_t num_rows, char const *c - struct roh_mac_req_para req_data = { 0 }; - struct hikp_cmd_header req_header = { 0 }; - struct hikp_cmd_ret *cmd_ret = NULL; -+ uint32_t i; - int ret; - - hikp_cmd_init(&req_header, ROH_MOD, HIKP_ROH_MAC, CMD_SHOW_CREDIT); -@@ -262,7 +258,7 @@ static int hikp_roh_query_crd(uint8_t crd_type, uint32_t num_rows, char const *c - return ret; - } - mac_rsp = (struct roh_mac_credit_data *)(cmd_ret->rsp_data); -- for (int i = 0; i < num_rows; i++) { -+ for (i = 0; i < num_rows; i++) { - union cut_reg reg; - - reg.value = (mac_rsp->cut_reg_value)[i]; -diff --git a/net/roh/hikp_roh_show_bp.c b/net/roh/hikp_roh_show_bp.c -index 73a53d8..3f3f622 100644 ---- a/net/roh/hikp_roh_show_bp.c -+++ b/net/roh/hikp_roh_show_bp.c -@@ -39,7 +39,7 @@ static int hikp_roh_show_bp_target(struct major_cmd_ctrl *self, const char *argv - - static int hikp_roh_show_bp(struct major_cmd_ctrl *self) - { -- uint8_t pfc[8] = { 0 }; -+ uint8_t pfc[BP_SIZE] = { 0 }; - uint8_t egu_tx_bp; - union bp_val res; - uint8_t flit_bp; -diff --git a/net/roh/hikp_roh_show_mib.c b/net/roh/hikp_roh_show_mib.c -index 7267fe5..91e8344 100644 ---- a/net/roh/hikp_roh_show_mib.c -+++ b/net/roh/hikp_roh_show_mib.c -@@ -184,7 +184,7 @@ static int hikp_roh_fill_pmu_cnt(int round) - - hikp_cmd_init(&req_header, ROH_MOD, HIKP_ROH_SHOW_MIB, CMD_SHOW_MIB_FILL_CNT); - req_data.bdf = roh_show_mib_param.target.bdf; -- req_data.round = round; -+ req_data.round = (uint32_t)round; - - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - ret = hikp_rsp_normal_check(cmd_ret); -diff --git a/net/ub/ub_crd/hikp_ub_crd.c b/net/ub/ub_crd/hikp_ub_crd.c -index 91e1cb7..d564800 100644 ---- a/net/ub/ub_crd/hikp_ub_crd.c -+++ b/net/ub/ub_crd/hikp_ub_crd.c -@@ -40,8 +40,8 @@ static int hikp_ub_crd_target(struct major_cmd_ctrl *self, const char *argv) - static uint32_t hikp_ub_show_crd(uint32_t off, struct ub_crd_rsp *crd_rsp, uint32_t num_rows, - char const *crds[][2]) - { -- int reg_index; -- int i; -+ uint32_t reg_index; -+ uint32_t i; - - for (i = 0; i < num_rows; i++) { - union cut_reg reg; -diff --git a/net/ub/ub_ppp/hikp_unic_ppp.c b/net/ub/ub_ppp/hikp_unic_ppp.c -index 2164f04..105253f 100644 ---- a/net/ub/ub_ppp/hikp_unic_ppp.c -+++ b/net/ub/ub_ppp/hikp_unic_ppp.c -@@ -69,7 +69,7 @@ static int hikp_unic_cmd_ppp_feature_select(struct major_cmd_ctrl *self, const c - for (i = 0; i < feat_size; i++) { - if (strncmp(argv, g_unic_ppp_feature_cmd[i].feature_name, - HIKP_UNIC_PPP_MAX_FEATURE_NAME_LEN) == 0) { -- g_unic_ppp_param.feature_idx = i; -+ g_unic_ppp_param.feature_idx = (int)i; - return 0; - } - } -@@ -348,7 +348,7 @@ static void hikp_unic_ppp_show_ip_tbl(const void *data) - struct unic_ip_tbl *ip_tbl = (struct unic_ip_tbl *)data; - struct unic_ip_entry *entry; - uint16_t *ip_addr_tbl_str; -- int i, j; -+ uint32_t i, j; - - printf("ip_table_size = %u\n", ip_tbl->entry_size); - printf("index\t| func_id\t| ip_addr\n"); -diff --git a/ossl/ossl_user_linux.c b/ossl/ossl_user_linux.c -index a369c68..dc682dd 100644 ---- a/ossl/ossl_user_linux.c -+++ b/ossl/ossl_user_linux.c -@@ -47,7 +47,7 @@ int uda_realpath(const char *file_dir, char *format_dir) - - int uda_fcntl(const char *lock_file, uint32_t operation, int *fd) - { -- int fd_t = 0; -+ int fd_t; - int ret; - - if ((fd == NULL) || (lock_file == NULL)) -@@ -57,15 +57,17 @@ int uda_fcntl(const char *lock_file, uint32_t operation, int *fd) - if (fd_t < 0) - return -errno; - -- *fd = fd_t; -- - g_fcntl_lock.l_type = F_WRLCK; - if (operation == UDA_FLOCK_NOBLOCK) - ret = fcntl(fd_t, F_SETLK, &g_fcntl_lock); - else - ret = fcntl(fd_t, F_SETLKW, &g_fcntl_lock); -- if (ret != 0) -+ if (ret != 0) { - close(fd_t); -+ *fd = -1; /* Assignment -1 is an invalid value */ -+ } else { -+ *fd = fd_t; -+ } - - return ret; - } -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index 856aebe..58fcbea 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -559,7 +559,7 @@ int pcie_dumpreg_do_dump(uint32_t port_id, uint32_t dump_level) - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - ret = hikp_rsp_normal_check(cmd_ret); - if (ret) { -- Err("PCIe DUMPREG", "pcie dump cmd_ret check failed, ret: %d.\n", ret); -+ Err("pcie dump cmd_ret check failed, ret: %d.\n", ret); - goto free_cmd_ret; - } - ret = pcie_create_dumpreg_log_file(port_id, dump_level); -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c -index e2bfcb4..6cf7a61 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.c -+++ b/pcie/func_lib/pcie_func/pcie_statistics.c -@@ -79,7 +79,7 @@ static int pcie_portid_serdes_relation(const struct pcie_macro_info *macro_info, - Info("\tndie_id: %s\n", g_global_ndie_name[ndie_id]); - for (i = 0; i < macro_num; i++) { - for (j = macro_info[i].lane_s; j <= macro_info[i].lane_e; j++) -- Info("\t\tmacro %d \t lane: %d\n", macro_info[i].id, j); -+ Info("\t\tmacro %u \t lane: %u\n", macro_info[i].id, j); - } - return 0; - } -diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c -index 4afcb9b..23a7946 100644 ---- a/serdes/hikp_serdes.c -+++ b/serdes/hikp_serdes.c -@@ -11,7 +11,6 @@ - * See the Mulan PSL v2 for more details. - */ - --#include - #include - #include - #include -@@ -75,7 +74,7 @@ static int cmd_serdes_start_lane_id(struct major_cmd_ctrl *self, const char *arg - - ptr++; - macro_id = strtol(ptr, &endptr, 10); /* 10:decimal */ -- if (endptr <= ptr) -+ if ((endptr <= ptr) || (macro_id < 0) || (macro_id > UCHAR_MAX)) - goto _START_LANE_ID_ERR_PRO_; - - ptr = endptr; -@@ -87,7 +86,7 @@ static int cmd_serdes_start_lane_id(struct major_cmd_ctrl *self, const char *arg - if ((endptr <= ptr) || (*endptr != 0)) - goto _START_LANE_ID_ERR_PRO_; - -- if ((macro_id < 0) || (macro_id > UCHAR_MAX) || (ds_id < 0) || (ds_id > UCHAR_MAX)) -+ if ((ds_id < 0) || (ds_id > UCHAR_MAX)) - goto _START_LANE_ID_ERR_PRO_; - - g_serdes_param.macro_id = (uint8_t)macro_id; -diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c -index b6ecc48..6f28ecd 100644 ---- a/tool_lib/op_logs.c -+++ b/tool_lib/op_logs.c -@@ -25,29 +25,38 @@ static bool g_record = true; - static bool g_log_info; - static char g_input_buf[OP_LOG_FILE_W_MAXSIZE + 1] = {0}; - --static void op_log_write(const char *log_data) -+static int op_log_write(const char *log_data) - { - size_t w_size; - FILE *fd; - - if (strlen(g_op_log) == 0) -- return; -+ return -EINVAL; - - if (!is_file_exist(g_op_log)) -- return; -+ return -EPERM; - - fd = fopen(g_op_log, "a"); - if (fd == NULL) { - HIKP_ERROR_PRINT("Can not open operation log file[%s], errno is %d\n", - g_op_log, errno); -- return; -+ return -errno; - } -- (void)chmod(g_op_log, 0640); -+ -+ if (chmod(g_op_log, 0640)) { -+ HIKP_ERROR_PRINT("Can not chmod log file[%s], errno is %d\n", g_op_log, errno); -+ (void)fclose(fd); -+ return -errno; -+ } -+ - w_size = fwrite((void *)log_data, 1U, strlen(log_data), fd); -- if (strlen(log_data) > ((uint32_t)w_size)) -+ if (strlen(log_data) > ((uint32_t)w_size)) { - HIKP_ERROR_PRINT("Error data size write to file, errno is %d\n", errno); -+ (void)fclose(fd); -+ return -errno; -+ } - -- (void)fclose(fd); -+ return fclose(fd); - } - - static int op_log_write_buffer(const char *log_data, const char *log_dir) -@@ -70,11 +79,13 @@ static int op_log_write_buffer(const char *log_data, const char *log_dir) - return ret; - } - -- op_log_write(log_data); -+ ret = op_log_write(log_data); -+ if (ret == 0) -+ g_log_info = true; -+ - tool_unlock(&op_lock_fd, UDA_FLOCK_BLOCK); -- g_log_info = true; - (void)sigprocmask(SIG_UNBLOCK, &sigset, NULL); -- return 0; -+ return ret; - } - - void op_log_on(void) --- -2.45.0.windows.1 - diff --git a/0082-hikptool-Modify-the-macro-definition-of-the-header-f.patch b/0082-hikptool-Modify-the-macro-definition-of-the-header-f.patch deleted file mode 100644 index da3df978252c391c948aa0df5f32cfec361aa004..0000000000000000000000000000000000000000 --- a/0082-hikptool-Modify-the-macro-definition-of-the-header-f.patch +++ /dev/null @@ -1,1097 +0,0 @@ -From a172993cb9084795a0cc8abdacf6e06574f88922 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 28 Aug 2024 11:44:18 +0800 -Subject: [PATCH 20/27] hikptool: Modify the macro definition of the header - file - -Modify the macro definition of the header file and -delete the underscores at the beginning. - -Signed-off-by: veega2022 ---- - cxl/func_lib/cxl_func/cxl_feature.h | 6 +++--- - cxl/usr_cmd/cmd_analysis/cxl_tool_include.h | 6 +++--- - libhikptdev/src/rciep/hikpt_rciep.h | 6 +++--- - net/hikp_net_lib.h | 6 +++--- - net/nic/nic_dfx/hikp_nic_dfx.h | 6 +++--- - net/nic/nic_info/hikp_nic_info.h | 6 +++--- - net/nic/nic_log/hikp_nic_log.h | 6 +++--- - net/nic/nic_mac/hikp_mac_cmd.h | 2 +- - net/nic/nic_mac/hikp_nic_mac_dump.h | 2 +- - net/nic/nic_mac/hikp_nic_port.h | 2 +- - net/nic/nic_mac/hikp_nic_xsfp.h | 2 +- - net/nic/nic_qos/hikp_nic_qos.c | 3 +-- - net/roce/roce_bond/hikp_roce_bond.h | 6 +++--- - net/roce/roce_caep/hikp_roce_caep.h | 6 +++--- - net/roce/roce_ext_common/hikp_roce_ext_common.h | 6 +++--- - net/roce/roce_global_cfg/hikp_roce_global_cfg.h | 6 +++--- - net/roce/roce_gmv/hikp_roce_gmv.h | 6 +++--- - net/roce/roce_mdb/hikp_roce_mdb.h | 6 +++--- - net/roce/roce_pkt/hikp_roce_pkt.h | 6 +++--- - net/roce/roce_qmm/hikp_roce_qmm.h | 6 +++--- - net/roce/roce_rst/hikp_roce_rst.h | 6 +++--- - net/roce/roce_scc/hikp_roce_scc.h | 6 +++--- - net/roce/roce_timer/hikp_roce_timer.h | 6 +++--- - net/roce/roce_trp/hikp_roce_trp.h | 6 +++--- - net/roce/roce_tsp/hikp_roce_tsp.h | 6 +++--- - net/roh/hikp_roh_cmd.h | 6 +++--- - net/roh/hikp_roh_mac.h | 6 +++--- - net/roh/hikp_roh_show_bp.h | 6 +++--- - net/roh/hikp_roh_show_mib.h | 6 +++--- - ossl/ossl_user_linux.h | 2 +- - pcie/func_lib/osal/os_common.h | 6 +++--- - pcie/func_lib/pcie_func/pcie_common.h | 6 +++--- - pcie/func_lib/pcie_func/pcie_link_ltssm.h | 6 +++--- - pcie/func_lib/pcie_func/pcie_reg_dump.h | 6 +++--- - pcie/func_lib/pcie_func/pcie_reg_read.h | 6 +++--- - pcie/func_lib/pcie_func/pcie_statistics.h | 6 +++--- - pcie/usr_cmd/cmd_analysis/pcie_tools_include.h | 6 +++--- - pcie/usr_cmd/interface/pcie_common_api.h | 6 +++--- - sas/sas_func/sas_analy_queue.h | 6 +++--- - sas/sas_func/sas_common.h | 6 +++--- - sas/sas_func/sas_dump_reg.h | 6 +++--- - sas/sas_func/sas_read_dev.h | 6 +++--- - sas/sas_func/sas_read_dqe.h | 6 +++--- - sas/sas_func/sas_read_errcode.h | 6 +++--- - sas/user_cmd/cmd_code/sas_tools_include.h | 6 +++--- - sata/sata_func/sata_common.h | 6 +++--- - sata/sata_func/sata_dump_reg.h | 6 +++--- - sata/user_cmd/cmd_code/sata_tools_include.h | 6 +++--- - serdes/hikp_serdes.h | 8 +++----- - socip/hikp_socip.h | 6 +++--- - tool_lib/tool_cmd.h | 2 +- - tool_lib/tool_lib.h | 6 +++--- - 52 files changed, 142 insertions(+), 145 deletions(-) - -diff --git a/cxl/func_lib/cxl_func/cxl_feature.h b/cxl/func_lib/cxl_func/cxl_feature.h -index 3ac6f75..339ccee 100644 ---- a/cxl/func_lib/cxl_func/cxl_feature.h -+++ b/cxl/func_lib/cxl_func/cxl_feature.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __CXL_FEATURE_H_ --#define __CXL_FEATURE_H_ -+#ifndef CXL_FEATURE_H -+#define CXL_FEATURE_H - - #include "tool_cmd.h" - -@@ -408,4 +408,4 @@ union cxl_mem_error_ctrl { - uint32_t val; - }; - --#endif -+#endif /* CXL_FEATURE_H */ -diff --git a/cxl/usr_cmd/cmd_analysis/cxl_tool_include.h b/cxl/usr_cmd/cmd_analysis/cxl_tool_include.h -index 5028056..6ba0f0d 100644 ---- a/cxl/usr_cmd/cmd_analysis/cxl_tool_include.h -+++ b/cxl/usr_cmd/cmd_analysis/cxl_tool_include.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __CXL_TOOL_INCLUDE_H_ --#define __CXL_TOOL_INCLUDE_H_ -+#ifndef CXL_TOOL_INCLUDE_H -+#define CXL_TOOL_INCLUDE_H - - #include - -@@ -21,4 +21,4 @@ struct tool_cxl_cmd { - uint32_t port_id; - }; - --#endif -+#endif /* CXL_TOOL_INCLUDE_H */ -diff --git a/libhikptdev/src/rciep/hikpt_rciep.h b/libhikptdev/src/rciep/hikpt_rciep.h -index c64e4dd..bf2a2d7 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.h -+++ b/libhikptdev/src/rciep/hikpt_rciep.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __KPT_RCIEP_H__ --#define __KPT_RCIEP_H__ -+#ifndef KPT_RCIEP_H -+#define KPT_RCIEP_H - - #include - #include "hikptdev_plug.h" -@@ -104,4 +104,4 @@ union hikp_space_req { - }; - #pragma pack() - --#endif -+#endif /* KPT_RCIEP_H */ -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index 8a0958f..7ebabfa 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -10,8 +10,8 @@ - * - * See the Mulan PSL v2 for more details. - */ --#ifndef __HIKP_NET_LIB_H__ --#define __HIKP_NET_LIB_H__ -+#ifndef HIKP_NET_LIB_H -+#define HIKP_NET_LIB_H - - #include "ossl_user_linux.h" - #include "tool_cmd.h" -@@ -138,4 +138,4 @@ int get_vf_dev_info_by_pf_dev_name(const char *pf_dev_name, - int get_pf_dev_info_by_vf_dev_name(const char *vf_dev_name, struct tool_target *pf_target); - void hikp_ether_format_addr(char *buf, uint16_t size, const uint8_t *mac_addr, uint8_t mac_len); - --#endif -+#endif /* HIKP_NET_LIB_H */ -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.h b/net/nic/nic_dfx/hikp_nic_dfx.h -index 3f23b59..d46d290 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.h -+++ b/net/nic/nic_dfx/hikp_nic_dfx.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_NIC_DFX_H__ --#define __HIKP_NIC_DFX_H__ -+#ifndef HIKP_NIC_DFX_H -+#define HIKP_NIC_DFX_H - - #include "hikp_net_lib.h" - -@@ -138,4 +138,4 @@ struct nic_dfx_rsp_t { - uint32_t reg_data[MAX_DFX_DATA_NUM]; - }; - --#endif -+#endif /* HIKP_NIC_DFX_H */ -diff --git a/net/nic/nic_info/hikp_nic_info.h b/net/nic/nic_info/hikp_nic_info.h -index 194146e..b1dd7dc 100644 ---- a/net/nic/nic_info/hikp_nic_info.h -+++ b/net/nic/nic_info/hikp_nic_info.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_NIC_INFO_H__ --#define __HIKP_NIC_INFO_H__ -+#ifndef HIKP_NIC_INFO_H -+#define HIKP_NIC_INFO_H - - #include "hikp_net_lib.h" - -@@ -77,4 +77,4 @@ enum nic_info_mac_type { - MAC_TYPE_MAX, - }; - --#endif -+#endif /* HIKP_NIC_INFO_H */ -diff --git a/net/nic/nic_log/hikp_nic_log.h b/net/nic/nic_log/hikp_nic_log.h -index ff2bb87..2998464 100644 ---- a/net/nic/nic_log/hikp_nic_log.h -+++ b/net/nic/nic_log/hikp_nic_log.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_NIC_LOG_H__ --#define __HIKP_NIC_LOG_H__ -+#ifndef HIKP_NIC_LOG_H -+#define HIKP_NIC_LOG_H - - #include "hikp_net_lib.h" - -@@ -38,4 +38,4 @@ struct log_param { - struct tool_target target; - }; - --#endif -+#endif /* HIKP_NIC_LOG_H */ -diff --git a/net/nic/nic_mac/hikp_mac_cmd.h b/net/nic/nic_mac/hikp_mac_cmd.h -index 9a3f0d9..0cd209f 100644 ---- a/net/nic/nic_mac/hikp_mac_cmd.h -+++ b/net/nic/nic_mac/hikp_mac_cmd.h -@@ -62,4 +62,4 @@ enum mac_dump_xsfp_sub_cmd { - NIC_XSFP_GET_EEPROM_DATA, - }; - --#endif -+#endif /* HIKP_MAC_CMD_H */ -diff --git a/net/nic/nic_mac/hikp_nic_mac_dump.h b/net/nic/nic_mac/hikp_nic_mac_dump.h -index f82762e..0c58ad5 100644 ---- a/net/nic/nic_mac/hikp_nic_mac_dump.h -+++ b/net/nic/nic_mac/hikp_nic_mac_dump.h -@@ -60,4 +60,4 @@ struct cmd_mac_dump { - uint32_t blk_num[MOD_ID_MAX]; - const char *module_name; - }; --#endif -+#endif /* HIKP_NIC_MAC_DUMP_H */ -diff --git a/net/nic/nic_mac/hikp_nic_port.h b/net/nic/nic_mac/hikp_nic_port.h -index cb72ebc..69ebb53 100644 ---- a/net/nic/nic_mac/hikp_nic_port.h -+++ b/net/nic/nic_mac/hikp_nic_port.h -@@ -271,4 +271,4 @@ struct cmd_hot_plug_card_info { - uint8_t cur_type; - }; - --#endif -+#endif /* HIKP_NIC_PORT_H */ -diff --git a/net/nic/nic_mac/hikp_nic_xsfp.h b/net/nic/nic_mac/hikp_nic_xsfp.h -index a04ecdc..50cbb2d 100644 ---- a/net/nic/nic_mac/hikp_nic_xsfp.h -+++ b/net/nic/nic_mac/hikp_nic_xsfp.h -@@ -549,4 +549,4 @@ struct hikp_xsfp_ctrl { - uint32_t dump_param; - }; - --#endif -+#endif /* HIKP_NIC_XSFP_H */ -diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c -index 9e997e4..2de0972 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.c -+++ b/net/nic/nic_qos/hikp_nic_qos.c -@@ -15,9 +15,8 @@ - #include - #include - #include -- --#include "hikp_nic_qos.h" - #include "hikpt_rciep.h" -+#include "hikp_nic_qos.h" - - static struct nic_qos_param g_qos_param = { 0 }; - -diff --git a/net/roce/roce_bond/hikp_roce_bond.h b/net/roce/roce_bond/hikp_roce_bond.h -index 14bd233..5e18723 100644 ---- a/net/roce/roce_bond/hikp_roce_bond.h -+++ b/net/roce/roce_bond/hikp_roce_bond.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_BOND_H__ --#define __HIKP_ROCE_BOND_H__ -+#ifndef HIKP_ROCE_BOND_H -+#define HIKP_ROCE_BOND_H - - #include "hikp_roce_ext_common.h" - -@@ -26,4 +26,4 @@ struct roce_bond_req_param { - uint32_t block_id; - }; - --#endif /* __HIKP_ROCE_BOND_H__ */ -+#endif /* HIKP_ROCE_BOND_H */ -diff --git a/net/roce/roce_caep/hikp_roce_caep.h b/net/roce/roce_caep/hikp_roce_caep.h -index 547a4d6..becb332 100644 ---- a/net/roce/roce_caep/hikp_roce_caep.h -+++ b/net/roce/roce_caep/hikp_roce_caep.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_CAEP_H__ --#define __HIKP_ROCE_CAEP_H__ -+#ifndef HIKP_ROCE_CAEP_H -+#define HIKP_ROCE_CAEP_H - - #include "hikp_roce_ext_common.h" - -@@ -48,4 +48,4 @@ enum roce_caep_cmd_type { - CAEP_EXT, - }; - --#endif /* __HIKP_ROCE_CAEP_H__ */ -+#endif /* HIKP_ROCE_CAEP_H */ -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 4930bed..8568556 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.h -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_EXT_COMMON_H__ --#define __HIKP_ROCE_EXT_COMMON_H__ -+#ifndef HIKP_ROCE_EXT_COMMON_H -+#define HIKP_ROCE_EXT_COMMON_H - - #include "hikp_net_lib.h" - -@@ -64,4 +64,4 @@ void hikp_roce_ext_execute(struct major_cmd_ctrl *self, - uint32_t block_id, - struct roce_ext_reg_name *reg_name)); - --#endif /* __HIKP_ROCE_EXT_COMMON_H__ */ -+#endif /* HIKP_ROCE_EXT_COMMON_H */ -diff --git a/net/roce/roce_global_cfg/hikp_roce_global_cfg.h b/net/roce/roce_global_cfg/hikp_roce_global_cfg.h -index 66e7fb8..aa1db92 100644 ---- a/net/roce/roce_global_cfg/hikp_roce_global_cfg.h -+++ b/net/roce/roce_global_cfg/hikp_roce_global_cfg.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_GLOBAL_CFG_H__ --#define __HIKP_ROCE_GLOBAL_CFG_H__ -+#ifndef HIKP_ROCE_GLOBAL_CFG_H -+#define HIKP_ROCE_GLOBAL_CFG_H - - #include "hikp_roce_ext_common.h" - -@@ -37,4 +37,4 @@ enum roce_global_cfg_cmd_type { - ROCE_GLB_NICL, - }; - --#endif /* __HIKP_ROCE_GLOBAL_CFG_H__ */ -+#endif /* HIKP_ROCE_GLOBAL_CFG_H */ -diff --git a/net/roce/roce_gmv/hikp_roce_gmv.h b/net/roce/roce_gmv/hikp_roce_gmv.h -index a02b960..8bc49d0 100644 ---- a/net/roce/roce_gmv/hikp_roce_gmv.h -+++ b/net/roce/roce_gmv/hikp_roce_gmv.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_GMV_H__ --#define __HIKP_ROCE_GMV_H__ -+#ifndef HIKP_ROCE_GMV_H -+#define HIKP_ROCE_GMV_H - - #include "hikp_roce_ext_common.h" - -@@ -38,4 +38,4 @@ enum roce_gmv_cmd_type { - GMV_SHOW = 0x0, - }; - --#endif /* __HIKP_ROCE_GMV_H__ */ -+#endif /* HIKP_ROCE_GMV_H */ -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.h b/net/roce/roce_mdb/hikp_roce_mdb.h -index 26fc549..e8dfcca 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.h -+++ b/net/roce/roce_mdb/hikp_roce_mdb.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_MDB_H__ --#define __HIKP_ROCE_MDB_H__ -+#ifndef HIKP_ROCE_MDB_H -+#define HIKP_ROCE_MDB_H - - #include "hikp_roce_ext_common.h" - -@@ -49,4 +49,4 @@ enum roce_mdb_cmd_type { - MDB_CLEAR_EXT, - }; - --#endif /* __HIKP_ROCE_MDB_H__ */ -+#endif /* HIKP_ROCE_MDB_H */ -diff --git a/net/roce/roce_pkt/hikp_roce_pkt.h b/net/roce/roce_pkt/hikp_roce_pkt.h -index 0200c44..05d464e 100644 ---- a/net/roce/roce_pkt/hikp_roce_pkt.h -+++ b/net/roce/roce_pkt/hikp_roce_pkt.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_PKT_H__ --#define __HIKP_ROCE_PKT_H__ -+#ifndef HIKP_ROCE_PKT_H -+#define HIKP_ROCE_PKT_H - - #include "hikp_roce_ext_common.h" - -@@ -39,4 +39,4 @@ struct roce_pkt_res_param { - struct roce_pkt_res reg_data; - }; - --#endif /* __HIKP_ROCE_PKT_H__ */ -+#endif /* HIKP_ROCE_PKT_H */ -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.h b/net/roce/roce_qmm/hikp_roce_qmm.h -index 06e6bcf..eb7722b 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.h -+++ b/net/roce/roce_qmm/hikp_roce_qmm.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_QMM_H__ --#define __HIKP_ROCE_QMM_H__ -+#ifndef HIKP_ROCE_QMM_H -+#define HIKP_ROCE_QMM_H - - #include "hikp_roce_ext_common.h" - -@@ -51,4 +51,4 @@ enum roce_qmm_cmd_type { - QMM_SHOW_TOP_EXT, - }; - --#endif /* __HIKP_ROCE_QMM_H__ */ -+#endif /* HIKP_ROCE_QMM_H */ -diff --git a/net/roce/roce_rst/hikp_roce_rst.h b/net/roce/roce_rst/hikp_roce_rst.h -index 731effc..e864b68 100644 ---- a/net/roce/roce_rst/hikp_roce_rst.h -+++ b/net/roce/roce_rst/hikp_roce_rst.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_RST_H__ --#define __HIKP_ROCE_RST_H__ -+#ifndef HIKP_ROCE_RST_H -+#define HIKP_ROCE_RST_H - - #include "hikp_roce_ext_common.h" - -@@ -26,4 +26,4 @@ struct roce_rst_req_param { - uint32_t block_id; - }; - --#endif /* __HIKP_ROCE_RST_H__ */ -+#endif /* HIKP_ROCE_RST_H */ -diff --git a/net/roce/roce_scc/hikp_roce_scc.h b/net/roce/roce_scc/hikp_roce_scc.h -index 5d37a11..9b5c0c5 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.h -+++ b/net/roce/roce_scc/hikp_roce_scc.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_SCC_H__ --#define __HIKP_ROCE_SCC_H__ -+#ifndef HIKP_ROCE_SCC_H -+#define HIKP_ROCE_SCC_H - - #include "hikp_roce_ext_common.h" - -@@ -66,4 +66,4 @@ enum roce_scc_type { - CFG, - }; - --#endif /* __HIKP_ROCE_SCC_H__ */ -+#endif /* HIKP_ROCE_SCC_H */ -diff --git a/net/roce/roce_timer/hikp_roce_timer.h b/net/roce/roce_timer/hikp_roce_timer.h -index 7f7deb6..314547e 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.h -+++ b/net/roce/roce_timer/hikp_roce_timer.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_TIMER_H__ --#define __HIKP_ROCE_TIMER_H__ -+#ifndef HIKP_ROCE_TIMER_H -+#define HIKP_ROCE_TIMER_H - - #include "hikp_roce_ext_common.h" - -@@ -40,4 +40,4 @@ struct roce_timer_rsp_data { - uint32_t timer_content[ROCE_HIKP_TIMER_REG_NUM][2]; - }; - --#endif /* __HIKP_ROCE_TIMER_H__ */ -+#endif /* HIKP_ROCE_TIMER_H */ -diff --git a/net/roce/roce_trp/hikp_roce_trp.h b/net/roce/roce_trp/hikp_roce_trp.h -index 97f1838..212d36f 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.h -+++ b/net/roce/roce_trp/hikp_roce_trp.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_TRP_H__ --#define __HIKP_ROCE_TRP_H__ -+#ifndef HIKP_ROCE_TRP_H -+#define HIKP_ROCE_TRP_H - - #include "hikp_roce_ext_common.h" - -@@ -70,4 +70,4 @@ enum roce_trp_type { - COMMON, - }; - --#endif /* __HIKP_ROCE_TRP_H__ */ -+#endif /* HIKP_ROCE_TRP_H */ -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.h b/net/roce/roce_tsp/hikp_roce_tsp.h -index 43d0d0d..a35f869 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.h -+++ b/net/roce/roce_tsp/hikp_roce_tsp.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROCE_TSP_H__ --#define __HIKP_ROCE_TSP_H__ -+#ifndef HIKP_ROCE_TSP_H -+#define HIKP_ROCE_TSP_H - - #include "hikp_roce_ext_common.h" - -@@ -61,4 +61,4 @@ enum roce_tsp_sub_cmd_code { - TGP_TMP, - }; - --#endif /* __HIKP_ROCE_TSP_H__ */ -+#endif /* HIKP_ROCE_TSP_H */ -diff --git a/net/roh/hikp_roh_cmd.h b/net/roh/hikp_roh_cmd.h -index 5aea6ac..1fb19d0 100644 ---- a/net/roh/hikp_roh_cmd.h -+++ b/net/roh/hikp_roh_cmd.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROH_CMD_H__ --#define __HIKP_ROH_CMD_H__ -+#ifndef HIKP_ROH_CMD_H -+#define HIKP_ROH_CMD_H - - #include "hikp_net_lib.h" - -@@ -35,4 +35,4 @@ enum roh_show_bp_subcmd { - }; - - int hikp_roh_get_mac_type(struct major_cmd_ctrl *self, struct bdf_t bdf); --#endif /* __HIKP_ROH_CMD_H__ */ -+#endif /* HIKP_ROH_CMD_H */ -diff --git a/net/roh/hikp_roh_mac.h b/net/roh/hikp_roh_mac.h -index 88115cf..c9037f0 100644 ---- a/net/roh/hikp_roh_mac.h -+++ b/net/roh/hikp_roh_mac.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROH_MAC_H__ --#define __HIKP_ROH_MAC_H__ -+#ifndef HIKP_ROH_MAC_H -+#define HIKP_ROH_MAC_H - - #include "tool_lib.h" - #include "hikp_net_lib.h" -@@ -104,4 +104,4 @@ struct roh_mac_credit_data { - uint32_t cut_reg_value[MAX_CRD_SIZE]; - }; - --#endif /* __HIKP_ROH_MAC_H__ */ -+#endif /* HIKP_ROH_MAC_H */ -diff --git a/net/roh/hikp_roh_show_bp.h b/net/roh/hikp_roh_show_bp.h -index e7a3894..411bd23 100644 ---- a/net/roh/hikp_roh_show_bp.h -+++ b/net/roh/hikp_roh_show_bp.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROH_SHOW_BP_H__ --#define __HIKP_ROH_SHOW_BP_H__ -+#ifndef HIKP_ROH_SHOW_BP_H -+#define HIKP_ROH_SHOW_BP_H - - #include "hikp_net_lib.h" - -@@ -47,4 +47,4 @@ struct roh_show_bp_rsp_t { - #define VERIFY_MAC_ID 2 - #define BP_SIZE 8 - --#endif /* __HIKP_ROH_SHOW_BP_H__ */ -+#endif /* HIKP_ROH_SHOW_BP_H */ -diff --git a/net/roh/hikp_roh_show_mib.h b/net/roh/hikp_roh_show_mib.h -index fc7c308..f8c4855 100644 ---- a/net/roh/hikp_roh_show_mib.h -+++ b/net/roh/hikp_roh_show_mib.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_ROH_SHOW_MIB_H__ --#define __HIKP_ROH_SHOW_MIB_H__ -+#ifndef HIKP_ROH_SHOW_MIB_H -+#define HIKP_ROH_SHOW_MIB_H - - #include "hikp_net_lib.h" - -@@ -83,4 +83,4 @@ enum target_addr { - #define ROH_CMD_SHOW_MIB (1 << 0) - #define RESPONSE_MIB_NUMBER_MAX 15 - --#endif /* __HIKP_ROH_SHOW_MIB_H__ */ -+#endif /* HIKP_ROH_SHOW_MIB_H */ -diff --git a/ossl/ossl_user_linux.h b/ossl/ossl_user_linux.h -index 16fc2d2..c2173e2 100644 ---- a/ossl/ossl_user_linux.h -+++ b/ossl/ossl_user_linux.h -@@ -69,4 +69,4 @@ int uda_unfcntl(const int *fd, const uint32_t operation); - - extern void record_syslog(const char *ident, const int priority, const char *logs); - --#endif -+#endif /* OSSL_USER_LINUX_H */ -diff --git a/pcie/func_lib/osal/os_common.h b/pcie/func_lib/osal/os_common.h -index de2a517..45ae343 100644 ---- a/pcie/func_lib/osal/os_common.h -+++ b/pcie/func_lib/osal/os_common.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef _OS_COMMON_H_ --#define _OS_COMMON_H_ -+#ifndef OS_COMMON_H -+#define OS_COMMON_H - - #define LOG_PCIE "[PCIE]" - -@@ -26,4 +26,4 @@ - - #define Tips(x, args...) Info("[ TIPS ] " x, ##args) - --#endif -+#endif /* OS_COMMON_H */ -diff --git a/pcie/func_lib/pcie_func/pcie_common.h b/pcie/func_lib/pcie_func/pcie_common.h -index 98d9e25..1a5ab3a 100644 ---- a/pcie/func_lib/pcie_func/pcie_common.h -+++ b/pcie/func_lib/pcie_func/pcie_common.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __PCIE_COMMON_H_ --#define __PCIE_COMMON_H_ -+#ifndef PCIE_COMMON_H -+#define PCIE_COMMON_H - - /* PCIe command code */ - enum pcie_cmd_type { -@@ -48,4 +48,4 @@ enum pcie_reg_read_cmd_type { - REGRD_READ = 1, - }; - --#endif -+#endif /* PCIE_COMMON_H */ -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.h b/pcie/func_lib/pcie_func/pcie_link_ltssm.h -index cc51501..9986f7a 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.h -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __PCIE_LINK_LTSSM_H_ --#define __PCIE_LINK_LTSSM_H_ -+#ifndef PCIE_LINK_LTSSM_H -+#define PCIE_LINK_LTSSM_H - - #include "pcie_common_api.h" - -@@ -60,4 +60,4 @@ int pcie_ltssm_trace_mode_set(uint32_t port_id, uint32_t mode); - int pcie_ltssm_link_status_get(uint32_t port_id); - int pcie_pm_trace(uint32_t port_id); - --#endif -+#endif /* PCIE_LINK_LTSSM_H */ -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.h b/pcie/func_lib/pcie_func/pcie_reg_dump.h -index cbea2f6..aaf22ba 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.h -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __PCIE_REG_DUMP_H_ --#define __PCIE_REG_DUMP_H_ -+#ifndef PCIE_REG_DUMP_H -+#define PCIE_REG_DUMP_H - - #include "pcie_common_api.h" - -@@ -56,4 +56,4 @@ struct pcie_dumpreg_table { - - int pcie_dumpreg_do_dump(uint32_t port_id, uint32_t dump_level); - --#endif -+#endif /* PCIE_REG_DUMP_H */ -diff --git a/pcie/func_lib/pcie_func/pcie_reg_read.h b/pcie/func_lib/pcie_func/pcie_reg_read.h -index 05d509a..ec01083 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_read.h -+++ b/pcie/func_lib/pcie_func/pcie_reg_read.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __PCIE_REG_READ_H_ --#define __PCIE_REG_READ_H_ -+#ifndef PCIE_REG_READ_H -+#define PCIE_REG_READ_H - - #include "pcie_common_api.h" - -@@ -57,4 +57,4 @@ enum pcie_module_id_list { - int pcie_reg_read(uint32_t port_id, uint32_t module_id, uint32_t offset); - int pcie_read_name2module_id(const char *module_name, uint32_t *module_id); - --#endif -+#endif /* PCIE_REG_READ_H */ -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.h b/pcie/func_lib/pcie_func/pcie_statistics.h -index 3e3916b..c373573 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.h -+++ b/pcie/func_lib/pcie_func/pcie_statistics.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __PCIE_STATISTICS_H_ --#define __PCIE_STATISTICS_H_ -+#ifndef PCIE_STATISTICS_H -+#define PCIE_STATISTICS_H - - #include "pcie_common_api.h" - -@@ -127,4 +127,4 @@ int pcie_port_distribution_get(uint32_t chip_id); - int pcie_error_state_get(uint32_t port_id); - int pcie_error_state_clear(uint32_t port_id); - --#endif -+#endif /* PCIE_STATISTICS_H */ -diff --git a/pcie/usr_cmd/cmd_analysis/pcie_tools_include.h b/pcie/usr_cmd/cmd_analysis/pcie_tools_include.h -index 83b7349..823f8b5 100644 ---- a/pcie/usr_cmd/cmd_analysis/pcie_tools_include.h -+++ b/pcie/usr_cmd/cmd_analysis/pcie_tools_include.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __PCIE_TOOLS_INCLUDE_H_ --#define __PCIE_TOOLS_INCLUDE_H_ -+#ifndef PCIE_TOOLS_INCLUDE_H -+#define PCIE_TOOLS_INCLUDE_H - - #include "hikptdev_plug.h" - #include "tool_lib.h" -@@ -29,4 +29,4 @@ struct tool_pcie_cmd { - uint32_t read_module_val; - }; - --#endif -+#endif /* PCIE_TOOLS_INCLUDE_H */ -diff --git a/pcie/usr_cmd/interface/pcie_common_api.h b/pcie/usr_cmd/interface/pcie_common_api.h -index 08d4403..59d41ed 100644 ---- a/pcie/usr_cmd/interface/pcie_common_api.h -+++ b/pcie/usr_cmd/interface/pcie_common_api.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __PCIE_COMMON_API_H_ --#define __PCIE_COMMON_API_H_ -+#ifndef PCIE_COMMON_API_H -+#define PCIE_COMMON_API_H - - #include - #include -@@ -42,4 +42,4 @@ struct pcie_comm_api { - - struct pcie_comm_api *pcie_get_comm_api(void); - --#endif -+#endif /* PCIE_COMMON_API_H */ -diff --git a/sas/sas_func/sas_analy_queue.h b/sas/sas_func/sas_analy_queue.h -index 59100f4..7107b5c 100644 ---- a/sas/sas_func/sas_analy_queue.h -+++ b/sas/sas_func/sas_analy_queue.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __SAS_ANALY_DQ_H_ --#define __SAS_ANALY_DQ_H_ -+#ifndef SAS_ANALY_DQ_H -+#define SAS_ANALY_DQ_H - - #include "sas_tools_include.h" - -@@ -35,4 +35,4 @@ struct sas_analy_para { - - int sas_analy_cmd(struct tool_sas_cmd *cmd); - --#endif -+#endif /* SAS_ANALY_DQ_H */ -diff --git a/sas/sas_func/sas_common.h b/sas/sas_func/sas_common.h -index c33a2fe..eed0fa5 100644 ---- a/sas/sas_func/sas_common.h -+++ b/sas/sas_func/sas_common.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __SAS_COMMON_H_ --#define __SAS_COMMON_H_ -+#ifndef SAS_COMMON_H -+#define SAS_COMMON_H - - #define RESP_MAX_NUM 60 - #define SAS_MAX_PHY_NUM 7 -@@ -84,4 +84,4 @@ enum sas_dqe_cmd_type { - DQE_UNKNOWN_TYPE, - }; - --#endif -+#endif /* SAS_COMMON_H */ -diff --git a/sas/sas_func/sas_dump_reg.h b/sas/sas_func/sas_dump_reg.h -index 06dca72..f2c2e69 100644 ---- a/sas/sas_func/sas_dump_reg.h -+++ b/sas/sas_func/sas_dump_reg.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __SAS_DUMP_REG_H_ --#define __SAS_DUMP_REG_H_ -+#ifndef SAS_DUMP_REG_H -+#define SAS_DUMP_REG_H - - #include "sas_tools_include.h" - -@@ -24,4 +24,4 @@ struct sas_dump_req_para { - - int sas_reg_dump(struct tool_sas_cmd *cmd); - --#endif -+#endif /* SAS_DUMP_REG_H */ -diff --git a/sas/sas_func/sas_read_dev.h b/sas/sas_func/sas_read_dev.h -index 47d984f..7049994 100644 ---- a/sas/sas_func/sas_read_dev.h -+++ b/sas/sas_func/sas_read_dev.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __SAS_DEV_H_ --#define __SAS_DEV_H_ -+#ifndef SAS_DEV_H -+#define SAS_DEV_H - - #include "sas_tools_include.h" - -@@ -48,4 +48,4 @@ struct hikp_sas_itct { - - int sas_dev(const struct tool_sas_cmd *cmd); - --#endif -+#endif /* SAS_DEV_H */ -diff --git a/sas/sas_func/sas_read_dqe.h b/sas/sas_func/sas_read_dqe.h -index 28c0592..95e1ff3 100644 ---- a/sas/sas_func/sas_read_dqe.h -+++ b/sas/sas_func/sas_read_dqe.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __SAS_DQE_H_ --#define __SAS_DQE_H_ -+#ifndef SAS_DQE_H -+#define SAS_DQE_H - - #include "sas_tools_include.h" - -@@ -82,4 +82,4 @@ struct hisi_sas_dq_info { - - int sas_dqe(const struct tool_sas_cmd *cmd); - --#endif -+#endif /* SAS_DQE_H */ -diff --git a/sas/sas_func/sas_read_errcode.h b/sas/sas_func/sas_read_errcode.h -index c597c16..3ee7f11 100644 ---- a/sas/sas_func/sas_read_errcode.h -+++ b/sas/sas_func/sas_read_errcode.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __SAS_ERRCODE_REG_H_ --#define __SAS_ERRCODE_REG_H_ -+#ifndef SAS_ERRCODE_REG_H -+#define SAS_ERRCODE_REG_H - - #include "sas_tools_include.h" - -@@ -23,4 +23,4 @@ struct sas_errcode_req_para { - - int sas_errcode_read(struct tool_sas_cmd *cmd); - --#endif -+#endif /* SAS_ERRCODE_REG_H */ -diff --git a/sas/user_cmd/cmd_code/sas_tools_include.h b/sas/user_cmd/cmd_code/sas_tools_include.h -index 0aa7703..a0e4b1b 100644 ---- a/sas/user_cmd/cmd_code/sas_tools_include.h -+++ b/sas/user_cmd/cmd_code/sas_tools_include.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __SAS_TOOLS_INCLUDE_H_ --#define __SAS_TOOLS_INCLUDE_H_ -+#ifndef SAS_TOOLS_INCLUDE_H -+#define SAS_TOOLS_INCLUDE_H - - #include "hikptdev_plug.h" - #include "tool_lib.h" -@@ -42,4 +42,4 @@ int sas_set_die_id(struct major_cmd_ctrl *self, const char *argv); - int sas_set_que_id(struct major_cmd_ctrl *self, const char *argv); - int sas_set_dqe_id(struct major_cmd_ctrl *self, const char *argv); - --#endif -+#endif /* SAS_TOOLS_INCLUDE_H */ -diff --git a/sata/sata_func/sata_common.h b/sata/sata_func/sata_common.h -index 82e39c0..01ea13c 100644 ---- a/sata/sata_func/sata_common.h -+++ b/sata/sata_func/sata_common.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __SATA_COMMON_H_ --#define __SATA_COMMON_H_ -+#ifndef SATA_COMMON_H -+#define SATA_COMMON_H - - #define SATA_MAX_PORT_NUM 1 - #define RESP_MAX_NUM 60 -@@ -28,4 +28,4 @@ enum sata_dump_cmd_type { - DUMP_PORTX, - }; - --#endif -+#endif /* SATA_COMMON_H */ -diff --git a/sata/sata_func/sata_dump_reg.h b/sata/sata_func/sata_dump_reg.h -index 972ab71..8ea93ad 100644 ---- a/sata/sata_func/sata_dump_reg.h -+++ b/sata/sata_func/sata_dump_reg.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __SATA_DUMP_REG_H_ --#define __SATA_DUMP_REG_H_ -+#ifndef SATA_DUMP_REG_H -+#define SATA_DUMP_REG_H - - #include "sata_tools_include.h" - -@@ -24,4 +24,4 @@ struct sata_dump_req_para { - - int sata_reg_dump(struct tool_sata_cmd *cmd); - --#endif -+#endif /* SATA_DUMP_REG_H */ -diff --git a/sata/user_cmd/cmd_code/sata_tools_include.h b/sata/user_cmd/cmd_code/sata_tools_include.h -index a9671a9..bafb52a 100644 ---- a/sata/user_cmd/cmd_code/sata_tools_include.h -+++ b/sata/user_cmd/cmd_code/sata_tools_include.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __SATA_TOOLS_INCLUDE_H_ --#define __SATA_TOOLS_INCLUDE_H_ -+#ifndef SATA_TOOLS_INCLUDE_H -+#define SATA_TOOLS_INCLUDE_H - - #include "hikptdev_plug.h" - #include "tool_lib.h" -@@ -26,4 +26,4 @@ struct tool_sata_cmd { - uint32_t die_id; - }; - --#endif -+#endif /* SATA_TOOLS_INCLUDE_H */ -diff --git a/serdes/hikp_serdes.h b/serdes/hikp_serdes.h -index 83c28b8..2c04e8a 100644 ---- a/serdes/hikp_serdes.h -+++ b/serdes/hikp_serdes.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __HIKP_SERDES_H__ --#define __HIKP_SERDES_H__ -+#ifndef HIKP_SERDES_H -+#define HIKP_SERDES_H - - #include - #include -@@ -21,8 +21,6 @@ - #include - #include "tool_lib.h" - --#define __SERDES_DESC(x) 1 -- - enum serdes_cmd_type_e { - SERDES_SYS_RESERVE0 = 0, - SERDES_SYS_RESERVE1 = 1, -@@ -212,4 +210,4 @@ struct hilink_brief_info { - uint32_t rsvd_1; - }; - --#endif -+#endif /* HIKP_SERDES_H */ -diff --git a/socip/hikp_socip.h b/socip/hikp_socip.h -index c98f136..8d3f31b 100644 ---- a/socip/hikp_socip.h -+++ b/socip/hikp_socip.h -@@ -10,8 +10,8 @@ - * - * See the Mulan PSL v2 for more details. - */ --#ifndef __HIKP_SOCIP_H__ --#define __HIKP_SOCIP_H__ -+#ifndef HIKP_SOCIP_H -+#define HIKP_SOCIP_H - - #include - -@@ -46,4 +46,4 @@ struct socip_dump_reg_req_data_t { - uint8_t controller_id; - }; - --#endif /* __HIKP_SOCIP_H__ */ -+#endif /* HIKP_SOCIP_H */ -diff --git a/tool_lib/tool_cmd.h b/tool_lib/tool_cmd.h -index 566b2a3..1aaaf22 100644 ---- a/tool_lib/tool_cmd.h -+++ b/tool_lib/tool_cmd.h -@@ -79,4 +79,4 @@ extern void cmd_option_register(const char *little, const char *large, uint8_t h - extern void command_parse_and_excute(const int argc, const char **argv); - extern struct major_cmd_ctrl *get_major_cmd(void); - --#endif -+#endif /* TOOL_CMD_H */ -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index 644a08e..15dac74 100644 ---- a/tool_lib/tool_lib.h -+++ b/tool_lib/tool_lib.h -@@ -11,8 +11,8 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef __TOOL_LIB_H__ --#define __TOOL_LIB_H__ -+#ifndef TOOL_LIB_H -+#define TOOL_LIB_H - - #include "ossl_user_linux.h" - -@@ -105,4 +105,4 @@ int generate_file_name(unsigned char *file_name, uint32_t file_name_len, - const unsigned char *prefix); - bool tool_can_print(uint32_t interval, uint32_t burst, uint32_t *print_num, uint64_t *last_time); - --#endif -+#endif /* TOOL_LIB_H */ --- -2.45.0.windows.1 - diff --git a/0083-hikptool-The-memory-release-interface-is-added.patch b/0083-hikptool-The-memory-release-interface-is-added.patch deleted file mode 100644 index 14448761504accee5944c47c31d9a9f4f93c534d..0000000000000000000000000000000000000000 --- a/0083-hikptool-The-memory-release-interface-is-added.patch +++ /dev/null @@ -1,1557 +0,0 @@ -From 2dccd3b70f9b262f541147f61ffed8cd9b7a079b Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Tue, 3 Sep 2024 20:26:16 +0800 -Subject: [PATCH 21/27] hikptool: The memory release interface is added. - -The memory release interface hikp_cmd_free is -added to work with hikp_cmd_alloc. - -Signed-off-by: veega2022 ---- - cxl/func_lib/cxl_func/cxl_feature.c | 11 +++---- - libhikptdev/include/hikptdev_plug.h | 1 + - libhikptdev/src/rciep/hikpt_rciep.c | 8 +++++ - net/nic/nic_dfx/hikp_nic_dfx.c | 6 ++-- - net/nic/nic_fd/hikp_nic_fd.c | 4 +-- - net/nic/nic_fec/hikp_nic_fec.c | 7 ++-- - net/nic/nic_ft/hikp_nic_port_fault.c | 7 ++-- - net/nic/nic_gro/hikp_nic_gro.c | 6 ++-- - net/nic/nic_info/hikp_nic_info.c | 6 ++-- - net/nic/nic_log/hikp_nic_log.c | 6 ++-- - net/nic/nic_mac/hikp_nic_mac_dump.c | 8 ++--- - net/nic/nic_mac/hikp_nic_port.c | 32 ++++++++----------- - net/nic/nic_mac/hikp_nic_xsfp.c | 12 +++---- - net/nic/nic_ncsi/hikp_nic_ncsi.c | 3 +- - net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c | 5 ++- - net/nic/nic_ppp/hikp_nic_ppp.c | 15 ++++----- - net/nic/nic_qos/hikp_nic_qos.c | 2 +- - net/nic/nic_queue/hikp_nic_queue.c | 2 +- - net/nic/nic_rss/hikp_nic_rss.c | 2 +- - net/nic/nic_torus/hikp_nic_torus.c | 7 ++-- - net/roce/roce_caep/hikp_roce_caep.c | 3 +- - .../roce_ext_common/hikp_roce_ext_common.c | 8 +---- - net/roce/roce_gmv/hikp_roce_gmv.c | 3 +- - net/roce/roce_mdb/hikp_roce_mdb.c | 3 +- - net/roce/roce_pkt/hikp_roce_pkt.c | 6 ++-- - net/roce/roce_qmm/hikp_roce_qmm.c | 3 +- - net/roce/roce_scc/hikp_roce_scc.c | 17 +++------- - net/roce/roce_timer/hikp_roce_timer.c | 6 ++-- - net/roce/roce_trp/hikp_roce_trp.c | 17 +++------- - net/roce/roce_tsp/hikp_roce_tsp.c | 6 ++-- - net/roh/hikp_roh_mac.c | 26 ++++++--------- - net/roh/hikp_roh_show_bp.c | 3 +- - net/roh/hikp_roh_show_mib.c | 6 ++-- - net/ub/ub_bp/hikp_ub_bp.c | 6 ++-- - net/ub/ub_crd/hikp_ub_crd.c | 6 ++-- - net/ub/ub_dfx/hikp_ub_dfx.c | 6 ++-- - net/ub/ub_info/hikp_ub_info.c | 6 ++-- - net/ub/ub_link/hikp_ub_link.c | 6 ++-- - net/ub/ub_ppp/hikp_unic_ppp.c | 2 +- - pcie/func_lib/pcie_func/pcie_link_ltssm.c | 19 +++++------ - pcie/func_lib/pcie_func/pcie_reg_dump.c | 2 +- - pcie/func_lib/pcie_func/pcie_reg_read.c | 2 +- - pcie/func_lib/pcie_func/pcie_statistics.c | 13 ++++---- - sas/sas_func/sas_analy_queue.c | 4 +-- - sas/sas_func/sas_dump_reg.c | 4 +-- - sas/sas_func/sas_read_dev.c | 4 +-- - sas/sas_func/sas_read_dqe.c | 4 +-- - sas/sas_func/sas_read_errcode.c | 4 +-- - sata/sata_func/sata_dump_reg.c | 4 +-- - serdes/hikp_serdes.c | 4 +-- - socip/hikp_socip_dumpreg.c | 6 ++-- - 51 files changed, 144 insertions(+), 215 deletions(-) - -diff --git a/cxl/func_lib/cxl_func/cxl_feature.c b/cxl/func_lib/cxl_func/cxl_feature.c -index 12fadbd..afe3895 100644 ---- a/cxl/func_lib/cxl_func/cxl_feature.c -+++ b/cxl/func_lib/cxl_func/cxl_feature.c -@@ -354,8 +354,7 @@ int cxl_reg_show_execute(uint32_t port_id, uint32_t mode_code, uint32_t cmd_type - if (ret) { - printf("cxl_cmd mode_code: %u cmd_type: %u, hikp_get_data_proc err, ret : %d\n", - mode_code, cmd_type, ret); -- if (cmd_ret) -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -@@ -363,7 +362,7 @@ int cxl_reg_show_execute(uint32_t port_id, uint32_t mode_code, uint32_t cmd_type - printf("cxl_cmd mode_code: %u cmd_type: %u," - "The value of rsp data num is less than 2, rsp data num: %u\n", - mode_code, cmd_type, cmd_ret->rsp_data_num); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -EINVAL; - } - data_head = (struct cxl_out_data *)cmd_ret->rsp_data; -@@ -371,7 +370,7 @@ int cxl_reg_show_execute(uint32_t port_id, uint32_t mode_code, uint32_t cmd_type - - ret = cxl_data_unit_buf_check(data_head->data_offset, data_unit_len, cmd_ret->rsp_data_num); - if (ret) { -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -@@ -381,11 +380,11 @@ int cxl_reg_show_execute(uint32_t port_id, uint32_t mode_code, uint32_t cmd_type - if (mode_code == g_prtf[i].mode_code && - cmd_type == g_prtf[i].cmd_type && g_prtf[i].cxl_prt_handle) { - g_prtf[i].cxl_prt_handle(data_unit_buf, data_unit_len); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return 0; - } - } - -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -EINVAL; - } -diff --git a/libhikptdev/include/hikptdev_plug.h b/libhikptdev/include/hikptdev_plug.h -index 5ea02ca..2123935 100644 ---- a/libhikptdev/include/hikptdev_plug.h -+++ b/libhikptdev/include/hikptdev_plug.h -@@ -51,6 +51,7 @@ void hikp_cmd_init(struct hikp_cmd_header *req_header, uint32_t mod_code, uint32 - uint32_t sub_cmd_code); - struct hikp_cmd_ret *hikp_cmd_alloc(struct hikp_cmd_header *req_header, - const void *req_data, uint32_t req_size); -+void hikp_cmd_free(struct hikp_cmd_ret **cmd_ret); - int hikp_dev_init(void); - void hikp_dev_uninit(void); - int hikp_rsp_normal_check(const struct hikp_cmd_ret *cmd_ret); -diff --git a/libhikptdev/src/rciep/hikpt_rciep.c b/libhikptdev/src/rciep/hikpt_rciep.c -index 0210f3d..5a38b3b 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.c -+++ b/libhikptdev/src/rciep/hikpt_rciep.c -@@ -285,6 +285,14 @@ free_req_data: - return cmd_ret; - } - -+void hikp_cmd_free(struct hikp_cmd_ret **cmd_ret) -+{ -+ if (*cmd_ret) { -+ free(*cmd_ret); -+ *cmd_ret = NULL; -+ } -+} -+ - int hikp_rsp_normal_check(const struct hikp_cmd_ret *cmd_ret) - { - if (cmd_ret == NULL) -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c -index 2cc4367..318d85f 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.c -+++ b/net/nic/nic_dfx/hikp_nic_dfx.c -@@ -161,8 +161,7 @@ static int hikp_nic_get_first_blk_dfx(struct nic_dfx_rsp_head_t *rsp_head, uint3 - - *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; - err_out: -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -@@ -191,8 +190,7 @@ static int hikp_nic_get_blk_dfx(struct nic_dfx_rsp_head_t *rsp_head, uint32_t bl - *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; - - err_out: -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index d4a9678..fb9333a 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -579,7 +579,7 @@ static int hikp_nic_fd_get_blk(struct hikp_cmd_header *req_header, - rsp_head->cur_blk_entry_cnt = rsp->rsp_head.cur_blk_entry_cnt; - - out: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -@@ -929,7 +929,6 @@ static void hikp_nic_fd_cmd_execute(struct major_cmd_ctrl *self) - const struct fd_feature_cmd *fd_cmd; - union nic_fd_feature_info *fd_data; - struct hikp_cmd_header req_header = {0}; -- uint8_t stage_no; - int ret; - - ret = hikp_nic_fd_check_input_param(self, &g_fd_param); -@@ -967,7 +966,6 @@ static void hikp_nic_fd_cmd_execute(struct major_cmd_ctrl *self) - /* The 'hw_info' cmd no need to input stage number, - * because it queries all stages information. - */ -- stage_no = fd_cmd->sub_cmd_code == NIC_FD_HW_INFO_DUMP ? 0 : g_fd_param.stage_no - 1; - hikp_cmd_init(&req_header, NIC_MOD, GET_FD_INFO_CMD, fd_cmd->sub_cmd_code); - ret = fd_cmd->query(&req_header, bdf, g_fd_param.stage_no - 1, fd_data, sizeof(*fd_data)); - if (ret != 0) { -diff --git a/net/nic/nic_fec/hikp_nic_fec.c b/net/nic/nic_fec/hikp_nic_fec.c -index edea28b..5a34bfd 100644 ---- a/net/nic/nic_fec/hikp_nic_fec.c -+++ b/net/nic/nic_fec/hikp_nic_fec.c -@@ -32,16 +32,15 @@ static int hikp_nic_fec_err_query(const struct bdf_t *bdf, struct nic_fec_err_in - hikp_cmd_init(&header, NIC_MOD, GET_FEC_INFO_CMD, NIC_FEC_ERR_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- ret = cmd_ret ? -cmd_ret->status : -EIO; -+ ret = cmd_ret ? (int)(-cmd_ret->status) : -EIO; - HIKP_ERROR_PRINT("fail to get fec info, retcode: %d\n", ret); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - - rsp = (struct nic_fec_rsp *)cmd_ret->rsp_data; - *info = *(struct nic_fec_err_info *)rsp->data; -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - - if (info->fec_mode >= NIC_FEC_MODE_BUTT) { - HIKP_ERROR_PRINT("unknown fec mode: %u\n", info->fec_mode); -diff --git a/net/nic/nic_ft/hikp_nic_port_fault.c b/net/nic/nic_ft/hikp_nic_port_fault.c -index 85fa874..6561e3e 100644 ---- a/net/nic/nic_ft/hikp_nic_port_fault.c -+++ b/net/nic/nic_ft/hikp_nic_port_fault.c -@@ -33,17 +33,16 @@ static int hikp_nic_port_fault_query(const struct bdf_t *bdf, - NIC_PORT_FAULT_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- ret = cmd_ret ? -cmd_ret->status : -EIO; -+ ret = cmd_ret ? (int)(-cmd_ret->status) : -EIO; - HIKP_ERROR_PRINT("fail to get port fault, retcode: %d\n", ret); -- if (cmd_ret != NULL) -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return ret; - } - - rsp = (struct nic_port_fault_rsp *)cmd_ret->rsp_data; - *info = *(struct nic_port_fault_status *)rsp->data; -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return 0; - } -diff --git a/net/nic/nic_gro/hikp_nic_gro.c b/net/nic/nic_gro/hikp_nic_gro.c -index d897f11..19395af 100644 ---- a/net/nic/nic_gro/hikp_nic_gro.c -+++ b/net/nic/nic_gro/hikp_nic_gro.c -@@ -32,15 +32,15 @@ static int hikp_nic_gro_query(const struct bdf_t *bdf, struct nic_gro_info *info - hikp_cmd_init(&header, NIC_MOD, GET_GRO_INFO_CMD, NIC_GRO_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- ret = cmd_ret ? -cmd_ret->status : -EIO; -+ ret = cmd_ret ? (int)(-cmd_ret->status) : -EIO; - HIKP_ERROR_PRINT("fail to get gro info, retcode: %d\n", ret); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - - rsp = (struct nic_gro_rsp *)cmd_ret->rsp_data; - *info = *(struct nic_gro_info *)rsp->data; -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return 0; - } -diff --git a/net/nic/nic_info/hikp_nic_info.c b/net/nic/nic_info/hikp_nic_info.c -index cd07b13..49f143f 100644 ---- a/net/nic/nic_info/hikp_nic_info.c -+++ b/net/nic/nic_info/hikp_nic_info.c -@@ -70,14 +70,12 @@ static int hikp_nic_get_curr_die_info(void) - ret = hikp_nic_get_hw_info(&cmd_ret); - if (ret != 0) { - HIKP_ERROR_PRINT("Get chip info fail.\n"); -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return ret; - } - info_rsp = (struct nic_info_rsp_t *)(cmd_ret->rsp_data); - g_info_param.info = *info_rsp; -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - - ret = get_revision_id_by_bdf(&g_info_param.target.bdf, g_info_param.revision_id, - sizeof(g_info_param.revision_id)); -diff --git a/net/nic/nic_log/hikp_nic_log.c b/net/nic/nic_log/hikp_nic_log.c -index dc622e0..f182d25 100644 ---- a/net/nic/nic_log/hikp_nic_log.c -+++ b/net/nic/nic_log/hikp_nic_log.c -@@ -124,8 +124,7 @@ static int hikp_nic_get_first_blk_info(uint32_t *total_blk_num, - *cur_blk_size = (uint32_t)log_rsp->cur_blk_size; - memcpy(*log_data, log_rsp->log_data, log_rsp->cur_blk_size); - err_out: -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -@@ -152,8 +151,7 @@ static int hikp_nic_get_log_info(uint32_t blk_id, uint32_t *cur_blk_size, uint8_ - } - memcpy(log_data, log_rsp->log_data, log_rsp->cur_blk_size); - err_out: -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -diff --git a/net/nic/nic_mac/hikp_nic_mac_dump.c b/net/nic/nic_mac/hikp_nic_mac_dump.c -index 3e818cd..5439c71 100644 ---- a/net/nic/nic_mac/hikp_nic_mac_dump.c -+++ b/net/nic/nic_mac/hikp_nic_mac_dump.c -@@ -40,7 +40,7 @@ static int mac_dump_module_reg(struct major_cmd_ctrl *self, uint32_t cur_blk_id, - return self->err_no; - } - if (cmd_ret->status != 0) { -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - self->err_no = -EINVAL; - return self->err_no; - } -@@ -53,7 +53,7 @@ static int mac_dump_module_reg(struct major_cmd_ctrl *self, uint32_t cur_blk_id, - rsp_data++; - } - -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return 0; - } -@@ -156,13 +156,13 @@ static int mac_cmd_get_dump_blk_num(struct major_cmd_ctrl *self) - if (cmd_ret->status != 0 || cmd_ret->rsp_data_num < MOD_ID_MAX) { - HIKP_ERROR_PRINT("nic_mac reg blk num error, rsp_num:%u\n", cmd_ret->rsp_data_num); - self->err_no = -EINVAL; -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return self->err_no; - } - - memcpy(g_dump_reg_info.blk_num, cmd_ret->rsp_data, sizeof(g_dump_reg_info.blk_num)); - -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return 0; - } -diff --git a/net/nic/nic_mac/hikp_nic_port.c b/net/nic/nic_mac/hikp_nic_port.c -index f818001..e28a040 100644 ---- a/net/nic/nic_mac/hikp_nic_port.c -+++ b/net/nic/nic_mac/hikp_nic_port.c -@@ -148,8 +148,7 @@ static int mac_cmd_get_dfx_cfg(uint32_t sub_cmd, struct hikp_cmd_ret **cmd_ret) - return -ENOSPC; - - if ((*cmd_ret)->status != 0) { -- free(*cmd_ret); -- *cmd_ret = NULL; -+ hikp_cmd_free(cmd_ret); - return -EAGAIN; - } - -@@ -207,8 +206,7 @@ static void mac_cmd_show_eth_mac(struct major_cmd_ctrl *self) - - mac_dfx = (struct mac_cmd_mac_dfx *)(cmd_ret->rsp_data); - mac_cmd_disp_eth_mac_info(mac_dfx); -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - } - - static void mac_cmd_disp_roh_mac_info(const struct mac_cmd_roh_mac_dfx *mac_dfx) -@@ -240,8 +238,7 @@ static void mac_cmd_show_roh_mac(struct major_cmd_ctrl *self) - - mac_dfx = (struct mac_cmd_roh_mac_dfx *)(cmd_ret->rsp_data); - mac_cmd_disp_roh_mac_info(mac_dfx); -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - } - - static void mac_cmd_show_mac(struct major_cmd_ctrl *self) -@@ -263,8 +260,7 @@ static void mac_cmd_show_mac(struct major_cmd_ctrl *self) - else - mac_cmd_show_eth_mac(self); - -- free(hw_cmd_ret); -- hw_cmd_ret = NULL; -+ hikp_cmd_free(&hw_cmd_ret); - } - - static void mac_cmd_disp_link_info(struct mac_cmd_link_dfx *link_dfx) -@@ -304,7 +300,7 @@ static void mac_cmd_show_link(struct major_cmd_ctrl *self) - - link_dfx = (struct mac_cmd_link_dfx *)(cmd_ret->rsp_data); - mac_cmd_disp_link_info(link_dfx); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - } - - static void mac_cmd_disp_phy_reg(const uint16_t *reg, uint32_t num) -@@ -372,13 +368,13 @@ static void mac_cmd_show_phy(struct major_cmd_ctrl *self) - if (ret != 0) { - printf("hikp_data_proc get phy dfx failed.\n"); - self->err_no = -ENOSPC; -- free(phy_cfg_ret); -+ hikp_cmd_free(&phy_cfg_ret); - return; - } - phy_dfx = (struct mac_cmd_phy_dfx *)(phy_dfx_ret->rsp_data); - mac_cmd_disp_phy_info(phy_cfg, phy_dfx); -- free(phy_cfg_ret); -- free(phy_dfx_ret); -+ hikp_cmd_free(&phy_cfg_ret); -+ hikp_cmd_free(&phy_dfx_ret); - } - - static void mac_cmd_disp_port_param(const char *label, const struct mac_port_param *port) -@@ -442,7 +438,7 @@ static void mac_cmd_show_arb(struct major_cmd_ctrl *self) - - arb_dfx = (struct mac_cmd_arb_dfx *)(cmd_ret->rsp_data); - mac_cmd_disp_arb_info(arb_dfx); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - } - - static void mac_cmd_show_hot_plug_card(struct major_cmd_ctrl *self) -@@ -460,7 +456,7 @@ static void mac_cmd_show_hot_plug_card(struct major_cmd_ctrl *self) - - hpc_dfx = (struct cmd_hot_plug_card_info *)(cmd_ret->rsp_data); - mac_cmd_disp_hot_plug_card_info(hpc_dfx); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - } - - static void mac_cmd_print_cdr_dfx(struct mac_cmd_cdr_dfx *cdr_dfx, struct mac_port_cdr_dfx *info) -@@ -534,7 +530,7 @@ static void mac_cmd_show_cdr(struct major_cmd_ctrl *self) - - cdr_dfx = (struct mac_cmd_cdr_dfx *)(cmd_ret->rsp_data); - mac_cmd_disp_cdr_info(cdr_dfx); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - } - - static void mac_cmd_show_port_dfx(struct major_cmd_ctrl *self, uint32_t mask) -@@ -568,8 +564,7 @@ static int mac_cmd_get_port_dfx_cap(uint32_t *cap) - if (ret == 0) { - dfx_cap = (struct mac_cmd_port_dfx_cap *)dfx_cap_resp->rsp_data; - *cap = dfx_cap->cap_bit_map; -- free(dfx_cap_resp); -- dfx_cap_resp = NULL; -+ hikp_cmd_free(&dfx_cap_resp); - return ret; - } - -@@ -585,8 +580,7 @@ static int mac_cmd_get_port_dfx_cap(uint32_t *cap) - port_hw->port_type == HIKP_PORT_TYPE_PHY_SDS) - *cap |= MAC_LSPORT_PHY; - -- free(hw_cmd_ret); -- hw_cmd_ret = NULL; -+ hikp_cmd_free(&hw_cmd_ret); - return ret; - } - -diff --git a/net/nic/nic_mac/hikp_nic_xsfp.c b/net/nic/nic_mac/hikp_nic_xsfp.c -index a1294a8..573837b 100644 ---- a/net/nic/nic_mac/hikp_nic_xsfp.c -+++ b/net/nic/nic_mac/hikp_nic_xsfp.c -@@ -597,16 +597,14 @@ static int hikp_xsfp_get_raw_data(uint8_t *buf, uint32_t size, uint32_t blk_num) - ret = hikp_xsfp_get_cmd_data(&cmd_resp, NIC_XSFP_GET_EEPROM_DATA, i); - if (ret != 0) { - HIKP_ERROR_PRINT("get optical module eeprom data failed\n"); -- free(cmd_resp); -- cmd_resp = NULL; -+ hikp_cmd_free(&cmd_resp); - return ret; - } - - if (cmd_resp->rsp_data_num == 0) { - HIKP_ERROR_PRINT("get eeprom data rsp_data_num %u error\n", - cmd_resp->rsp_data_num); -- free(cmd_resp); -- cmd_resp = NULL; -+ hikp_cmd_free(&cmd_resp); - return -EINVAL; - } - -@@ -616,8 +614,7 @@ static int hikp_xsfp_get_raw_data(uint8_t *buf, uint32_t size, uint32_t blk_num) - offset += len; - - /* current cmd interaction is complete, so free cmd_buf */ -- free(cmd_resp); -- cmd_resp = NULL; -+ hikp_cmd_free(&cmd_resp); - } - - return 0; -@@ -700,8 +697,7 @@ static void hikp_xsfp_get_info(struct major_cmd_ctrl *self) - hikp_xsfp_get_eeprom_data(self, info->data_size, info->total_blk_num); - - ERR_OUT: -- free(cmd_resp); -- cmd_resp = NULL; -+ hikp_cmd_free(&cmd_resp); - } - - static int hikp_xsfp_show_help(struct major_cmd_ctrl *self, const char *argv) -diff --git a/net/nic/nic_ncsi/hikp_nic_ncsi.c b/net/nic/nic_ncsi/hikp_nic_ncsi.c -index d09e16f..2e1ea11 100644 ---- a/net/nic/nic_ncsi/hikp_nic_ncsi.c -+++ b/net/nic/nic_ncsi/hikp_nic_ncsi.c -@@ -72,8 +72,7 @@ static void nic_ncsi_cmd_execute(struct major_cmd_ctrl *self) - nic_ncsi_cmd_print_dfx_info((struct nic_ncsi_cmd_resp *)cmd_resp->rsp_data); - - ERR_OUT: -- free(cmd_resp); -- cmd_resp = NULL; -+ hikp_cmd_free(&cmd_resp); - } - - static int nic_ncsi_cmd_get_port_info(struct major_cmd_ctrl *self, const char *argv) -diff --git a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -index 56b8257..5cd8bfa 100644 ---- a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -+++ b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -@@ -33,14 +33,13 @@ static int hikp_nic_notify_pkt_query(struct major_cmd_ctrl *self, const struct b - self->err_no = hikp_rsp_normal_check(cmd_resp); - if (self->err_no) { - snprintf(self->err_str, sizeof(self->err_str), "get notify pkt failed."); -- if (cmd_resp) -- free(cmd_resp); -+ hikp_cmd_free(&cmd_resp); - return self->err_no; - } - - rsp = (struct nic_notify_pkt_rsp *)cmd_resp->rsp_data; - *info = *(struct nic_notify_pkt_info *)rsp->data; -- free(cmd_resp); -+ hikp_cmd_free(&cmd_resp); - - return 0; - } -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index 3f777b3..aa63f12 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -512,7 +512,7 @@ static int hikp_nic_ppp_get_blk(struct hikp_cmd_header *req_header, - rsp_head->cur_blk_entry_cnt = rsp->rsp_head.cur_blk_entry_cnt; - - out: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -@@ -545,7 +545,7 @@ static int hikp_nic_ppp_query_uc_mac_addr(struct hikp_cmd_header *req_header, - return -EINVAL; - } - if (entry_size + rsp_head.cur_blk_entry_cnt > max_hw_entry_size) { -- HIKP_ERROR_PRINT("The sum of entry number (%lu) after block-%u " -+ HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " - "is over the maximum entry nubmer (%u) of unicast MAC table.\n", - entry_size + rsp_head.cur_blk_entry_cnt, idx, max_hw_entry_size); - return -EINVAL; -@@ -587,7 +587,7 @@ static int hikp_nic_ppp_query_mc_mac_addr(struct hikp_cmd_header *req_header, - return -EINVAL; - } - if (entry_size + rsp_head.cur_blk_entry_cnt > max_hw_entry_size) { -- HIKP_ERROR_PRINT("The sum of entry number (%lu) after block-%u " -+ HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " - "is over the maximum entry nubmer (%u) of multicast MAC table.\n", - entry_size + rsp_head.cur_blk_entry_cnt, idx, max_hw_entry_size); - return -EINVAL; -@@ -658,7 +658,7 @@ static int hikp_nic_ppp_query_vf_vlan_tbl(struct hikp_cmd_header *req_header, - return -EINVAL; - } - if (entry_size + rsp_head.cur_blk_entry_cnt > hw_entry_size) { -- HIKP_ERROR_PRINT("The sum of entry number (%lu) after block-%u " -+ HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " - "is over the maximum entry nubmer (%u) of VF VLAN table.\n", - entry_size + rsp_head.cur_blk_entry_cnt, idx, hw_entry_size); - return -EINVAL; -@@ -699,7 +699,7 @@ static int hikp_nic_ppp_query_port_vlan_tbl(struct hikp_cmd_header *req_header, - return -EINVAL; - } - if (entry_size + rsp_head.cur_blk_entry_cnt > hw_entry_size) { -- HIKP_ERROR_PRINT("The sum of entry number (%lu) after block-%u " -+ HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " - "is over the maximum entry nubmer (%u) of port VLAN table.\n", - entry_size + rsp_head.cur_blk_entry_cnt, idx, hw_entry_size); - return -EINVAL; -@@ -761,7 +761,7 @@ static int hikp_nic_query_mng_tbl(struct hikp_cmd_header *req_header, - return -EINVAL; - } - if (entry_size + rsp_head.cur_blk_entry_cnt > g_ppp_hw_res.mng_tbl_size) { -- HIKP_ERROR_PRINT("The sum of entry number (%lu) after block-%u " -+ HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " - "is over the maximum entry nubmer (%u) of manager table.\n", - entry_size + rsp_head.cur_blk_entry_cnt, idx, g_ppp_hw_res.mng_tbl_size); - return -EINVAL; -@@ -1044,7 +1044,6 @@ static int hikp_nic_ppp_check_input_param(struct major_cmd_ctrl *self, - } - - static int hikp_nic_check_func_id_valid(struct major_cmd_ctrl *self, -- const struct ppp_feature_cmd *ppp_cmd, - const struct nic_ppp_param *ppp_param, - const struct hikp_nic_ppp_hw_resources *hw_res) - { -@@ -1128,7 +1127,7 @@ static void hikp_nic_ppp_cmd_execute(struct major_cmd_ctrl *self) - } - - ppp_cmd = &g_ppp_feature_cmd[g_ppp_param.feature_idx]; -- ret = hikp_nic_check_func_id_valid(self, ppp_cmd, &g_ppp_param, &g_ppp_hw_res); -+ ret = hikp_nic_check_func_id_valid(self, &g_ppp_param, &g_ppp_hw_res); - if (ret != 0) - return; - -diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c -index 2de0972..81eb0ba 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.c -+++ b/net/nic/nic_qos/hikp_nic_qos.c -@@ -187,7 +187,7 @@ static int hikp_nic_qos_get_blk(struct hikp_cmd_header *req_header, - rsp_head->cur_blk_size = rsp->rsp_head.cur_blk_size; - - out: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -diff --git a/net/nic/nic_queue/hikp_nic_queue.c b/net/nic/nic_queue/hikp_nic_queue.c -index c73c8f7..dafa05e 100644 ---- a/net/nic/nic_queue/hikp_nic_queue.c -+++ b/net/nic/nic_queue/hikp_nic_queue.c -@@ -260,7 +260,7 @@ static int hikp_nic_queue_get_blk(struct hikp_cmd_header *req_header, - rsp_head->cur_blk_size = rsp->rsp_head.cur_blk_size; - - out: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -diff --git a/net/nic/nic_rss/hikp_nic_rss.c b/net/nic/nic_rss/hikp_nic_rss.c -index 558f931..65336ff 100644 ---- a/net/nic/nic_rss/hikp_nic_rss.c -+++ b/net/nic/nic_rss/hikp_nic_rss.c -@@ -378,7 +378,7 @@ static int hikp_nic_rss_get_blk(struct hikp_cmd_header *req_header, - rsp_head->cur_blk_size = rsp->rsp_head.cur_blk_size; - - out: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -diff --git a/net/nic/nic_torus/hikp_nic_torus.c b/net/nic/nic_torus/hikp_nic_torus.c -index 9483bfe..5208bdc 100644 ---- a/net/nic/nic_torus/hikp_nic_torus.c -+++ b/net/nic/nic_torus/hikp_nic_torus.c -@@ -33,16 +33,15 @@ static int hikp_nic_torus_query(const struct bdf_t *bdf, - hikp_cmd_init(&header, NIC_MOD, GET_TORUS_INFO_CMD, NIC_TORUS_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- ret = cmd_ret ? -cmd_ret->status : -EIO; -+ ret = cmd_ret ? (int)(-cmd_ret->status) : -EIO; - HIKP_ERROR_PRINT("fail to get torus info, retcode: %d\n", ret); -- if (cmd_ret) -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - - rsp = (struct nic_torus_rsp *)cmd_ret->rsp_data; - *info = *(struct nic_torus_info *)rsp->data; -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return 0; - } -diff --git a/net/roce/roce_caep/hikp_roce_caep.c b/net/roce/roce_caep/hikp_roce_caep.c -index 0453bc4..a52cd54 100644 ---- a/net/roce/roce_caep/hikp_roce_caep.c -+++ b/net/roce/roce_caep/hikp_roce_caep.c -@@ -99,8 +99,7 @@ static void hikp_roce_caep_execute_origin(struct major_cmd_ctrl *self) - roce_caep_res->reg_data.data); - - exec_error: -- if (cmd_ret) -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - } - - static void hikp_roce_caep_execute(struct major_cmd_ctrl *self) -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 cc9f509..9c844f4 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -26,12 +26,6 @@ static void hikp_roce_ext_reg_data_free(struct reg_data *reg) - } - } - --static void hikp_roce_ext_cmd_ret_free(struct hikp_cmd_ret *cmd_ret) --{ -- if (cmd_ret) -- free(cmd_ret); --} -- - static const struct cmd_type_info { - enum roce_cmd_type cmd_type; - const char *cmd_name; -@@ -156,7 +150,7 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - (uint32_t *)&roce_ext_res->reg_data + reg_array_length, cur_size); - - get_data_error: -- hikp_roce_ext_cmd_ret_free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -diff --git a/net/roce/roce_gmv/hikp_roce_gmv.c b/net/roce/roce_gmv/hikp_roce_gmv.c -index bc01ccf..1b7db32 100644 ---- a/net/roce/roce_gmv/hikp_roce_gmv.c -+++ b/net/roce/roce_gmv/hikp_roce_gmv.c -@@ -113,8 +113,7 @@ static void hikp_roce_gmv_execute(struct major_cmd_ctrl *self) - gmv_rsp = (struct roce_gmv_rsp_data *)(cmd_ret->rsp_data); - hikp_roce_gmv_print(reg_num, gmv_rsp); - exec_error: -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - } - - static void cmd_roce_gmv_init(void) -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.c b/net/roce/roce_mdb/hikp_roce_mdb.c -index e811bec..a578c87 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.c -+++ b/net/roce/roce_mdb/hikp_roce_mdb.c -@@ -152,8 +152,7 @@ static void hikp_roce_mdb_execute_origin(struct major_cmd_ctrl *self) - hikp_roce_mdb_print(reg_num, mdb_rsp); - - exec_error: -- if (cmd_ret) -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - } - - static void hikp_roce_mdb_execute(struct major_cmd_ctrl *self) -diff --git a/net/roce/roce_pkt/hikp_roce_pkt.c b/net/roce/roce_pkt/hikp_roce_pkt.c -index 74294c6..81bdae6 100644 ---- a/net/roce/roce_pkt/hikp_roce_pkt.c -+++ b/net/roce/roce_pkt/hikp_roce_pkt.c -@@ -55,8 +55,7 @@ static int hikp_roce_pkt_get_data(struct hikp_cmd_ret **cmd_ret, struct roce_pkt - ret = hikp_rsp_normal_check(*cmd_ret); - if (ret) { - printf("hikptool roce_pkt get cmd data failed, ret: %d\n", ret); -- free(*cmd_ret); -- *cmd_ret = NULL; -+ hikp_cmd_free(cmd_ret); - } - - return ret; -@@ -122,8 +121,7 @@ static void hikp_roce_pkt_execute(struct major_cmd_ctrl *self) - hikp_roce_pkt_print(roce_pkt_res->total_block_num, - roce_pkt_res->reg_data.offset, roce_pkt_res->reg_data.data); - -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - } - - static void cmd_roce_pkt_init(void) -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.c b/net/roce/roce_qmm/hikp_roce_qmm.c -index 6ab2c84..8140080 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.c -+++ b/net/roce/roce_qmm/hikp_roce_qmm.c -@@ -246,8 +246,7 @@ static void hikp_roce_qmm_execute_origin(struct major_cmd_ctrl *self) - hikp_roce_qmm_print(roce_qmm_res); - - exec_error: -- if (cmd_ret) -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - } - - static void hikp_roce_qmm_execute(struct major_cmd_ctrl *self) -diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c -index 0ecb8cf..f330e97 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.c -+++ b/net/roce/roce_scc/hikp_roce_scc.c -@@ -103,8 +103,7 @@ static int hikp_roce_scc_get_data(struct hikp_cmd_ret **cmd_ret, const uint32_t - ret = hikp_rsp_normal_check(*cmd_ret); - if (ret) { - printf("hikptool roce_scc get cmd data failed, ret: %d\n", ret); -- free(*cmd_ret); -- *cmd_ret = NULL; -+ hikp_cmd_free(cmd_ret); - } - - return ret; -@@ -122,14 +121,6 @@ static void hikp_roce_scc_reg_data_free(uint32_t **offset, uint32_t **data) - } - } - --static void hikp_roce_scc_cmd_ret_free(struct hikp_cmd_ret **cmd_ret) --{ -- if (*cmd_ret) { -- free(*cmd_ret); -- *cmd_ret = NULL; -- } --} -- - static int hikp_roce_scc_get_total_data_num(struct roce_scc_head *res_head, - uint32_t **offset, uint32_t **data, uint32_t *block_id) - { -@@ -176,7 +167,7 @@ static int hikp_roce_scc_get_total_data_num(struct roce_scc_head *res_head, - ret = 0; - - get_data_error: -- hikp_roce_scc_cmd_ret_free(&cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -@@ -198,7 +189,7 @@ 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) { -- hikp_roce_scc_cmd_ret_free(&cmd_ret); -+ 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); - return -EINVAL; -@@ -209,7 +200,7 @@ static int hikp_roce_scc_get_next_data(struct roce_scc_head *res_head, - *block_id = roce_scc_res->block_id; - res_head->cur_block_num = roce_scc_res->head.cur_block_num; - res_head->total_block_num = res_head->total_block_num - roce_scc_res->head.cur_block_num; -- hikp_roce_scc_cmd_ret_free(&cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return 0; - } -diff --git a/net/roce/roce_timer/hikp_roce_timer.c b/net/roce/roce_timer/hikp_roce_timer.c -index ea35241..962127b 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.c -+++ b/net/roce/roce_timer/hikp_roce_timer.c -@@ -135,8 +135,7 @@ static int hikp_roce_timer_show_qpc(struct major_cmd_ctrl *self) - printf("**************QPC TIMER INFO*************\n"); - hikp_roce_timer_print(timer_rsp, TIMER_SHOW_QPC); - out: -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -@@ -169,8 +168,7 @@ static int hikp_roce_timer_show_cqc(struct major_cmd_ctrl *self) - printf("**************CQC TIMER INFO*************\n"); - hikp_roce_timer_print(timer_rsp, TIMER_SHOW_CQC); - out: -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c -index 486bbe3..68c4cf2 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.c -+++ b/net/roce/roce_trp/hikp_roce_trp.c -@@ -123,8 +123,7 @@ static int hikp_roce_trp_get_data(struct hikp_cmd_ret **cmd_ret, const uint32_t - ret = hikp_rsp_normal_check(*cmd_ret); - if (ret) { - printf("hikptool roce_trp get cmd data failed, ret: %d\n", ret); -- free(*cmd_ret); -- *cmd_ret = NULL; -+ hikp_cmd_free(cmd_ret); - } - - return ret; -@@ -142,14 +141,6 @@ static void hikp_roce_trp_reg_data_free(uint32_t **offset, uint32_t **data) - } - } - --static void hikp_roce_trp_cmd_ret_free(struct hikp_cmd_ret **cmd_ret) --{ -- if (*cmd_ret) { -- free(*cmd_ret); -- *cmd_ret = NULL; -- } --} -- - static int hikp_roce_trp_get_total_data_num(struct roce_trp_head *res_head, - uint32_t **offset, uint32_t **data, uint32_t *block_id) - { -@@ -198,7 +189,7 @@ static int hikp_roce_trp_get_total_data_num(struct roce_trp_head *res_head, - ret = 0; - - get_data_error: -- hikp_roce_trp_cmd_ret_free(&cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -@@ -221,7 +212,7 @@ static int hikp_roce_trp_get_next_data(struct roce_trp_head *res_head, - cur_size = roce_trp_res->head.cur_block_num * sizeof(uint32_t); - - if (cur_size > data_size) { -- hikp_roce_trp_cmd_ret_free(&cmd_ret); -+ hikp_cmd_free(&cmd_ret); - printf("hikptool roce_trp next log data copy size error, " - "data size: 0x%zx, max size: 0x%zx\n", cur_size, data_size); - return -EINVAL; -@@ -232,7 +223,7 @@ static int hikp_roce_trp_get_next_data(struct roce_trp_head *res_head, - *block_id = roce_trp_res->block_id; - res_head->cur_block_num = roce_trp_res->head.cur_block_num; - res_head->total_block_num = res_head->total_block_num - roce_trp_res->head.cur_block_num; -- hikp_roce_trp_cmd_ret_free(&cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return 0; - } -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.c b/net/roce/roce_tsp/hikp_roce_tsp.c -index b16f0a4..9dd7956 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.c -+++ b/net/roce/roce_tsp/hikp_roce_tsp.c -@@ -130,8 +130,7 @@ static int hikp_roce_tsp_get_data(struct hikp_cmd_ret **cmd_ret, - ret = hikp_rsp_normal_check(*cmd_ret); - if (ret) { - printf("hikptool roce_tsp get cmd data failed, ret: %d\n", ret); -- free(*cmd_ret); -- *cmd_ret = NULL; -+ hikp_cmd_free(cmd_ret); - } - - return ret; -@@ -272,8 +271,7 @@ static void hikp_roce_tsp_execute(struct major_cmd_ctrl *self) - hikp_roce_tsp_print(roce_tsp_res->total_block_num, - roce_tsp_res->reg_data.offset, roce_tsp_res->reg_data.data); - -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - } - - static void cmd_roce_tsp_init(void) -diff --git a/net/roh/hikp_roh_mac.c b/net/roh/hikp_roh_mac.c -index 4a8cf7b..aa13f92 100644 ---- a/net/roh/hikp_roh_mac.c -+++ b/net/roh/hikp_roh_mac.c -@@ -87,13 +87,12 @@ int hikp_roh_get_mac_type(struct major_cmd_ctrl *self, struct bdf_t bdf) - HIKP_ERROR_PRINT("failed to get roh info, retcode: %u\n", - cmd_ret ? cmd_ret->status : EIO); - self->err_no = -EIO; -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -EIO; - } - mac_rsp = (struct roh_mac_get_type *)(cmd_ret->rsp_data); - is_roh = mac_rsp->mac_type; -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return is_roh; - } - -@@ -145,13 +144,12 @@ static int hikp_roh_get_cam_reg_num(struct major_cmd_ctrl *self) - HIKP_ERROR_PRINT("fail to get cam reg num, retcode: %u\n", - cmd_ret ? cmd_ret->status : EIO); - self->err_no = -EIO; -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -EIO; - } - mac_rsp = (struct roh_mac_cam_reg_num *)(cmd_ret->rsp_data); - cam_reg_num = mac_rsp->cam_reg_num; -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return cam_reg_num; - } - -@@ -182,7 +180,7 @@ static int hikp_roh_build_cam(struct major_cmd_ctrl *self, struct cam_table_entr - HIKP_ERROR_PRINT("fail to get cam table info, retcode: %u\n", - cmd_ret ? cmd_ret->status : EIO); - self->err_no = -EIO; -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -EIO; - } - mac_rsp = (struct roh_mac_cam_table *)(cmd_ret->rsp_data); -@@ -198,8 +196,7 @@ static int hikp_roh_build_cam(struct major_cmd_ctrl *self, struct cam_table_entr - (unsigned long)(mac_rsp->cam_mac_high16[j])) << - ROH_MAC_CAM_OFFSET); - } -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - } - return 0; - } -@@ -222,14 +219,13 @@ static void hikp_roh_show_cam(struct major_cmd_ctrl *self) - HIKP_ERROR_PRINT("fail to get cam info, retcode: %u\n", - cmd_ret ? cmd_ret->status : EIO); - self->err_no = -EIO; -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return; - } - mac_rsp = (struct roh_mac_cam_caps *)cmd_ret->rsp_data; - convert_enable = mac_rsp->convert_enable; - cam_convert_enable = mac_rsp->cam_convert_enable; -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - - ret = hikp_roh_build_cam(self, cam_table); - if (ret != 0) -@@ -253,8 +249,7 @@ static int hikp_roh_query_crd(uint8_t crd_type, uint32_t num_rows, char const *c - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - ret = hikp_rsp_normal_check(cmd_ret); - if (ret != 0) { -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return ret; - } - mac_rsp = (struct roh_mac_credit_data *)(cmd_ret->rsp_data); -@@ -268,8 +263,7 @@ static int hikp_roh_query_crd(uint8_t crd_type, uint32_t num_rows, char const *c - if ((strcmp(crds[i][1], "NULL") != 0) && (reg.cut)[1] != 0) - printf("%-28s : %#x\n", crds[i][1], (reg.cut)[1]); - } -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/net/roh/hikp_roh_show_bp.c b/net/roh/hikp_roh_show_bp.c -index 3f3f622..0b53eda 100644 ---- a/net/roh/hikp_roh_show_bp.c -+++ b/net/roh/hikp_roh_show_bp.c -@@ -86,8 +86,7 @@ static int hikp_roh_show_bp(struct major_cmd_ctrl *self) - printf("MAC%d_flit_bp : 0x%x\n", mac_id, flit_bp); - - out: -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -diff --git a/net/roh/hikp_roh_show_mib.c b/net/roh/hikp_roh_show_mib.c -index 91e8344..5f03355 100644 ---- a/net/roh/hikp_roh_show_mib.c -+++ b/net/roh/hikp_roh_show_mib.c -@@ -189,8 +189,7 @@ static int hikp_roh_fill_pmu_cnt(int round) - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - ret = hikp_rsp_normal_check(cmd_ret); - if (ret != 0) { -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return ret; - } - mib_rsp = (struct roh_show_mib_rsp_t *)(cmd_ret->rsp_data); -@@ -207,8 +206,7 @@ static int hikp_roh_fill_pmu_cnt(int round) - if (mac2_pmu_cnt) - printf("MAC2_%-28s : 0x%lx\n", g_roh_mac_mib_name[index], mac2_pmu_cnt); - } -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -diff --git a/net/ub/ub_bp/hikp_ub_bp.c b/net/ub/ub_bp/hikp_ub_bp.c -index f5f50ff..179aa22 100644 ---- a/net/ub/ub_bp/hikp_ub_bp.c -+++ b/net/ub/ub_bp/hikp_ub_bp.c -@@ -61,16 +61,14 @@ static int hikp_ub_query_bp(const struct bdf_t *bdf) - hikp_cmd_init(&header, UB_MOD, GET_UB_BP_INFO_CMD, UB_BP_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return -EIO; - } - - rsp = (struct ub_bp_rsp *)cmd_ret->rsp_data; - hikp_ub_bp_info_show(rsp); - -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/net/ub/ub_crd/hikp_ub_crd.c b/net/ub/ub_crd/hikp_ub_crd.c -index d564800..6d2ba21 100644 ---- a/net/ub/ub_crd/hikp_ub_crd.c -+++ b/net/ub/ub_crd/hikp_ub_crd.c -@@ -85,8 +85,7 @@ static int hikp_ub_query_crd(void) - req_data.bdf = g_ub_crd_param.target.bdf; - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return -EIO; - } - -@@ -101,8 +100,7 @@ static int hikp_ub_query_crd(void) - printf("------------------- TEMP CREDIT END --------------------\n"); - printf("********************* CREDIT CNT END *********************\n"); - -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/net/ub/ub_dfx/hikp_ub_dfx.c b/net/ub/ub_dfx/hikp_ub_dfx.c -index 00205fe..dd3a713 100644 ---- a/net/ub/ub_dfx/hikp_ub_dfx.c -+++ b/net/ub/ub_dfx/hikp_ub_dfx.c -@@ -138,8 +138,7 @@ static int hikp_ub_get_first_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t - - *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; - err_out: -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -@@ -170,8 +169,7 @@ static int hikp_ub_get_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t blk_id - *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; - - err_out: -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -diff --git a/net/ub/ub_info/hikp_ub_info.c b/net/ub/ub_info/hikp_ub_info.c -index 3b354dd..d113f7c 100644 ---- a/net/ub/ub_info/hikp_ub_info.c -+++ b/net/ub/ub_info/hikp_ub_info.c -@@ -56,16 +56,14 @@ static int hikp_ub_query_basic_info(const struct bdf_t *bdf) - hikp_cmd_init(&header, UB_MOD, GET_UB_BASIC_INFO_CMD, UB_BASIC_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return -EIO; - } - - rsp = (struct ub_info_rsp *)cmd_ret->rsp_data; - hikp_ub_basic_info_show(rsp); - -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/net/ub/ub_link/hikp_ub_link.c b/net/ub/ub_link/hikp_ub_link.c -index b6353f7..1cc1879 100644 ---- a/net/ub/ub_link/hikp_ub_link.c -+++ b/net/ub/ub_link/hikp_ub_link.c -@@ -58,16 +58,14 @@ static int hikp_ub_query_link_info(const struct bdf_t *bdf) - hikp_cmd_init(&header, UB_MOD, GET_UB_LINK_INFO_CMD, UB_LINK_INFO_DUMP); - cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return -EIO; - } - - rsp = (struct ub_link_rsp *)cmd_ret->rsp_data; - hikp_ub_link_info_show(rsp); - -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/net/ub/ub_ppp/hikp_unic_ppp.c b/net/ub/ub_ppp/hikp_unic_ppp.c -index 105253f..01c1624 100644 ---- a/net/ub/ub_ppp/hikp_unic_ppp.c -+++ b/net/ub/ub_ppp/hikp_unic_ppp.c -@@ -109,7 +109,7 @@ static int hikp_unic_ppp_get_blk(struct hikp_cmd_header *req_header, - memcpy(rsp_head, &rsp->rsp_head, sizeof(struct unic_ppp_rsp_head)); - - out: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.c b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -index 5834612..1bc2edb 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.c -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - #include "os_common.h" - #include "pcie_common.h" - #include "hikptdev_plug.h" -@@ -95,7 +96,7 @@ static int pcie_get_ltssm_trace(uint32_t port_id, uint64_t *ltssm_status, uint32 - src_size = (*ltssm_num) * sizeof(uint64_t); - dst_size = TRACER_DEPTH * sizeof(uint64_t); - if (src_size > dst_size) { -- Err("size check failed, %u > %u.\n", src_size, dst_size); -+ Err("size check failed, %zu > %zu.\n", src_size, dst_size); - ret = -EINVAL; - goto free_cmd_ret; - } -@@ -110,7 +111,7 @@ static int pcie_get_ltssm_trace(uint32_t port_id, uint64_t *ltssm_status, uint32 - memcpy(ltssm_status, (cmd_ret->rsp_data + 1), src_size); - - free_cmd_ret: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -@@ -187,7 +188,7 @@ static int pcie_print_ltssm_trace(const uint64_t *ltssm_input, uint32_t ltssm_nu - return -EINVAL; - } - Info("ltssm tracer:\n"); -- Info("\ttrace mode: %llx\n", *ltssm_input); -+ Info("\ttrace mode: %" PRIx64 "\n", *ltssm_input); - Info("\tltssm[ii]: 63:48 47:32 31 30 29 28 27 26 25 24 23 22 21:" - "20 19:12 11:10 9:6 5:0 ltssm\n"); - for (i = 1; i < ltssm_num; i++) { -@@ -245,7 +246,7 @@ int pcie_ltssm_trace_mode_set(uint32_t port_id, uint32_t mode) - hikp_cmd_init(&req_header, PCIE_MOD, PCIE_TRACE, TRACE_MODE); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - ret = hikp_rsp_normal_check(cmd_ret); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -@@ -261,7 +262,7 @@ int pcie_ltssm_trace_clear(uint32_t port_id) - hikp_cmd_init(&req_header, PCIE_MOD, PCIE_TRACE, TRACE_CLEAR); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - ret = hikp_rsp_normal_check(cmd_ret); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -@@ -298,7 +299,7 @@ int pcie_ltssm_link_status_get(uint32_t port_id) - Info(" link_up: %u\n", reg_val.bits.mac_link_up); - Info(" lane_reverse: %u\n", reg_val.bits.lane_reverse); - free_cmd_ret: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -@@ -330,7 +331,7 @@ static int pcie_get_pm_trace(uint32_t port_id, uint64_t *pm_status, uint32_t *pm - src_size = (*pm_num) * sizeof(uint64_t); - dst_size = TRACER_DEPTH * sizeof(uint64_t); - if (src_size > dst_size) { -- Err("size check failed, %u > %u.\n", src_size, dst_size); -+ Err("size check failed, %zu > %zu.\n", src_size, dst_size); - ret = -EINVAL; - goto free_cmd_ret; - } -@@ -345,7 +346,7 @@ static int pcie_get_pm_trace(uint32_t port_id, uint64_t *pm_status, uint32_t *pm - memcpy(pm_status, (cmd_ret->rsp_data + 1), src_size); - - free_cmd_ret: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return ret; - } - -@@ -412,7 +413,7 @@ static int pcie_print_pm_trace(const uint64_t *pm_status, uint32_t pm_num) - return -EINVAL; - } - Info("pm tracer:\n"); -- Info("\ttrace state: %llx\n", pm_status[0]); -+ Info("\ttrace state: %" PRIx64 "\n", pm_status[0]); - Info("\tpm[ii]: BE8: 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 " - "BD8: 23:6 5:0 : pm state\n"); - for (i = 1; i < pm_num; i++) { -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index 58fcbea..9444f64 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -577,7 +577,7 @@ int pcie_dumpreg_do_dump(uint32_t port_id, uint32_t dump_level) - close_file_ret: - (void)pcie_close_dumpreg_log_file(); - free_cmd_ret: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -diff --git a/pcie/func_lib/pcie_func/pcie_reg_read.c b/pcie/func_lib/pcie_func/pcie_reg_read.c -index 1578056..c04c3d9 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_read.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_read.c -@@ -95,7 +95,7 @@ int pcie_reg_read(uint32_t port_id, uint32_t module_id, uint32_t offset) - ret = pcie_reg_read_result_show(cmd_ret); - - free_cmd_ret: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c -index 6cf7a61..54d4edb 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.c -+++ b/pcie/func_lib/pcie_func/pcie_statistics.c -@@ -43,8 +43,7 @@ static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, - rsp_data_size = cmd_ret->rsp_data_num * sizeof(uint32_t); - /* Check whether enough data of a port unit */ - if (rsp_data_size < sizeof(struct pcie_port_info)) { -- Err("port distribution rsp check failed, size: %u.\n", -- rsp_data_size); -+ Err("port distribution rsp check failed, size: %zu.\n", rsp_data_size); - return -EINVAL; - } - /* Check whether enough data of n pairs */ -@@ -53,7 +52,7 @@ static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, - expect_data_size = sizeof(struct pcie_port_info) + - sizeof(struct pcie_info_distribution_pair) * (*port_num); - if (expect_data_size > rsp_data_size) { -- Err("port distribution data size check failed, size: %u, expect size: %u.\n", -+ Err("port distribution data size check failed, size: %zu, expect size: %zu.\n", - rsp_data_size, expect_data_size); - return -EINVAL; - } -@@ -117,7 +116,7 @@ int pcie_port_distribution_get(uint32_t chip_id) - port_info->info_pair[i].ndie_id); - } - free_cmd_ret: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -@@ -134,7 +133,7 @@ static int port_err_state_rsp_data_check(struct hikp_cmd_ret *cmd_ret) - } - rsp_data_size = cmd_ret->rsp_data_num * sizeof(uint32_t); - if (rsp_data_size < sizeof(struct pcie_err_state)) { -- Err("err state get rsp size check failed, rsp size: %u, expect size:%u.\n", -+ Err("err state get rsp size check failed, rsp size: %zu, expect size:%zu.\n", - rsp_data_size, sizeof(struct pcie_err_state)); - return -EINVAL; - } -@@ -172,7 +171,7 @@ int pcie_error_state_get(uint32_t port_id) - Info("dl_lcrc_err_num = %u\n", state->lcrc_err_num.bits.dl_lcrc_err_num); - Info("dl_dcrc_err_num = %u\n", state->dcrc_err_num.bits.dl_dcrc_err_num); - free_cmd_ret: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -@@ -188,7 +187,7 @@ int pcie_error_state_clear(uint32_t port_id) - hikp_cmd_init(&req_header, PCIE_MOD, PCIE_INFO, INFO_ERR_STATE_CLEAR); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - ret = hikp_rsp_normal_check(cmd_ret); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - - return ret; - } -diff --git a/sas/sas_func/sas_analy_queue.c b/sas/sas_func/sas_analy_queue.c -index b27ba60..f1d2e7e 100644 ---- a/sas/sas_func/sas_analy_queue.c -+++ b/sas/sas_func/sas_analy_queue.c -@@ -42,14 +42,14 @@ static int sas_get_res(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_analy excutes hikp_cmd_alloc err\n"); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; - for (int i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/sas/sas_func/sas_dump_reg.c b/sas/sas_func/sas_dump_reg.c -index 9a1da3a..39fa5ed 100644 ---- a/sas/sas_func/sas_dump_reg.c -+++ b/sas/sas_func/sas_dump_reg.c -@@ -34,14 +34,14 @@ static int sas_get_reg(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_dump excutes hikp_cmd_alloc err\n"); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -1; - } - *reg_num = cmd_ret->rsp_data_num; - for (int i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/sas/sas_func/sas_read_dev.c b/sas/sas_func/sas_read_dev.c -index ede5d74..b5d7e18 100644 ---- a/sas/sas_func/sas_read_dev.c -+++ b/sas/sas_func/sas_read_dev.c -@@ -35,14 +35,14 @@ static int sas_get_dev(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_dqe excutes hikp_cmd_alloc err\n"); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; - for (i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/sas/sas_func/sas_read_dqe.c b/sas/sas_func/sas_read_dqe.c -index 072c1dc..dac2546 100644 ---- a/sas/sas_func/sas_read_dqe.c -+++ b/sas/sas_func/sas_read_dqe.c -@@ -35,14 +35,14 @@ static int sas_get_dqe(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_dqe excutes hikp_cmd_alloc err\n"); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; - for (int i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/sas/sas_func/sas_read_errcode.c b/sas/sas_func/sas_read_errcode.c -index da1157b..d451a98 100644 ---- a/sas/sas_func/sas_read_errcode.c -+++ b/sas/sas_func/sas_read_errcode.c -@@ -33,14 +33,14 @@ static int sas_get_errcode(const struct tool_sas_cmd *cmd, uint32_t *reg_save, u - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_errcode excutes hikp_cmd_alloc err\n"); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; - for (int i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/sata/sata_func/sata_dump_reg.c b/sata/sata_func/sata_dump_reg.c -index 691989e..d63a14b 100644 ---- a/sata/sata_func/sata_dump_reg.c -+++ b/sata/sata_func/sata_dump_reg.c -@@ -35,14 +35,14 @@ static int sata_get_reg(const struct tool_sata_cmd *cmd, uint32_t *reg_save, uin - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("hikp_data_proc err\n"); -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return -1; - } - *reg_num = cmd_ret->rsp_data_num; - for (i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - return 0; - } - -diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c -index 23a7946..92e380e 100644 ---- a/serdes/hikp_serdes.c -+++ b/serdes/hikp_serdes.c -@@ -342,7 +342,7 @@ static void hikp_serdes_info_cmd_execute(struct major_cmd_ctrl *self) - } - - err_out: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - } - - static void cmd_serdes_maininfo_init(void) -@@ -496,7 +496,7 @@ static void hikp_serdes_dump_cmd_execute(struct major_cmd_ctrl *self) - dump_data = (uint32_t *)out_put.out_str; - hikp_serdes_dump_print(self, dump_data, out_put.result_offset / sizeof(uint32_t)); - err_out: -- free(cmd_ret); -+ hikp_cmd_free(&cmd_ret); - } - - static void cmd_serdes_dump_init(void) -diff --git a/socip/hikp_socip_dumpreg.c b/socip/hikp_socip_dumpreg.c -index 7b11523..4b6b70c 100644 ---- a/socip/hikp_socip_dumpreg.c -+++ b/socip/hikp_socip_dumpreg.c -@@ -143,14 +143,12 @@ static void hikp_socip_dumpreg_execute(struct major_cmd_ctrl *self) - if (!cmd_ret || cmd_ret->status != 0) { - self->err_no = -EINVAL; - HIKP_ERROR_PRINT("hikp_cmd_alloc\n"); -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - return; - } - - dump_reg_info(&cmd_ret->rsp_data[0], cmd_ret->rsp_data_num); -- free(cmd_ret); -- cmd_ret = NULL; -+ hikp_cmd_free(&cmd_ret); - } - - static void cmd_socip_dump_reg_init(void) --- -2.45.0.windows.1 - diff --git a/0084-hikptool-nic-Dump-register-names-for-SSU-and-PPP-mod.patch b/0084-hikptool-nic-Dump-register-names-for-SSU-and-PPP-mod.patch deleted file mode 100644 index 1d66d5a11b9e7e9a78ae137e0f5bf41bcf59b381..0000000000000000000000000000000000000000 --- a/0084-hikptool-nic-Dump-register-names-for-SSU-and-PPP-mod.patch +++ /dev/null @@ -1,519 +0,0 @@ -From 3a36fc8f5e079656823a8093c0233500a4959ac0 Mon Sep 17 00:00:00 2001 -From: Jie Hai -Date: Mon, 12 Aug 2024 10:55:15 +0800 -Subject: [PATCH 22/27] hikptool/nic: Dump register names for SSU and PPP - module - -This patch supports dumping name-offset-values for registers -of SSU and PPP modules. An example is shown: - - hikptool nic_dfx -i 0000:37:00.0 -m SSU - DFX cmd version: 0x0 - - ****************** module SSU reg dump start ******* \ - ************* - ----------------------------------------------------- - type name: 32 bit running status - - name offset value - FULL_DROP_NUM 0x0350 0x00000000 - PART_DROP_NUM 0x0354 0x00000000 - ...... - ----------------------------------------------------- - type name: 64 bit common statistics - - name offset value - SSU_PPP_MAC_KEY_NUM 0x0330 0x00000000000000f7 - SSU_PPP_HOST_KEY_NUM 0x0338 0x000000000000002f - ...... - -Signed-off-by: Jie Hai ---- - net/nic/nic_dfx/hikp_nic_dfx.c | 400 ++++++++++++++++++++++++++++++++- - net/nic/nic_dfx/hikp_nic_dfx.h | 11 + - 2 files changed, 405 insertions(+), 6 deletions(-) - -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c -index 318d85f..67a5fe1 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.c -+++ b/net/nic/nic_dfx/hikp_nic_dfx.c -@@ -80,6 +80,329 @@ static const struct dfx_type_parse g_dfx_type_parse[] = { - {TYPE_64_TX_PF_NORMAL_STATS, WIDTH_64_BIT, "64 bit TX pf statistics"}, - }; - -+static const struct dfx_reg_name dfx_ppp_type_32_common_drop_stats1[] = { -+ { "DROP_FROM_PRT_PKT_CNT"}, -+ { "DROP_FROM_HOST_PKT_CNT"}, -+ { "DROP_TX_VLAN_PROC_CNT"}, -+ { "DROP_MNG_CNT"}, -+ { "DROP_FD_CNT"}, -+ { "DROP_NO_DST_CNT"}, -+ { "DROP_MC_MBID_FULL_CNT"}, -+ { "DROP_SC_FILTERED"}, -+}; -+ -+static const struct dfx_reg_name dfx_ppp_type_32_common_drop_stats2[] = { -+ { "PPP_MC_DROP_PKT_CNT"}, -+ { "DROP_PT_CNT"}, -+ { "DROP_MAC_ANTI_SPOOF_CNT"}, -+ { "DROP_IG_VFV_CNT"}, -+ { "DROP_IG_PRTV_CNT"}, -+ { "DROP_CNM_PFC_PAUSE_CNT"}, -+ { "DROP_TORUS_TC_CNT"}, -+ { "DROP_TORUS_LPBK_CNT"}, -+ { "FWD_BONDING_PRT_EG_VLAN_DROP_CNT"}, -+ { "UMV_UPLINK_EG_VLAN_DROP_CNT"}, -+ { "BONDING_UPLINK_VLAN_FILTER_FAIL_CNT"}, -+ { "PROMIS_PRUNE_DROP_CNT"}, -+ { "UMV_UC_SRC_PRUNE_DROP_CNT"}, -+ { "PPP_GRO_DROP_CNT"}, -+}; -+ -+static const struct dfx_reg_name dfx_ppp_type_32_rx_normal_stats[] = { -+ { "PPP_GRO_KEY_CNT" }, -+ { "PPP_GRO_INFO_CNT" }, -+ { "PPP_GRO_OUT_CNT" }, -+ { "PPP_GRO_KEY_MATCH_DATA_CNT" }, -+ { "PPP_GRO_KEY_MATCH_TCAM_CNT" }, -+ { "PPP_GRO_INFO_MATCH_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ppp_type_64_rx_normal_stats1[] = { -+ { "GET_RX_PKT_CNT" }, -+ { "SEND_UC_PRT2HOST_PKT_CNT" }, -+ { "SEND_UC_PRT2PRT_PKT_CNT" }, -+ { "SEND_MC_FROM_PRT_CNT" }, -+ { "SSU_MC_RD_CNT" }, -+ { "SSU_MC_DROP_CNT" }, -+ { "SSU_MC_RD_PKT_CNT" }, -+ { "PPP_MC_2HOST_PKT_CNT" }, -+ { "NR_PKT_CNT" }, -+ { "RR_PKT_CNT" }, -+ { "MNG_TBL_HIT_CNT" }, -+ { "FD_TBL_HIT_CNT" }, -+ { "FD_LKUP_CNT" }, -+ { "UM_TBL_UC_HIT_CNT" }, -+ { "UM_TBL_MC_HIT_CNT" }, -+ { "UM_TBL_MC_HIT_PKT_CNT" }, -+ { "UM_TBL_VMDQ1_HIT_CNT" }, -+ { "MTA_TBL_HIT_CNT" }, -+ { "MTA_TBL_HIT_PKT_CNT" }, -+ { "FWD_BONDING_HIT_CNT" }, -+ { "GET_BMC_PKT_CNT" }, -+ { "SEND_UC_PRT2BMC_PKT_CNT" }, -+ { "SEND_UC_HOST2BMC_PKT_CNT" }, -+ { "PROMIS_TBL_HIT_CNT" }, -+ { "PROMIS_TBL_HIT_PKT_CNT" }, -+ { "GET_TUNL_PKT_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ppp_type_64_rx_normal_stats2[] = { -+ { "SEND_UC_BMC2PRT_PKT_CNT" }, -+ { "RX_DEFAULT_HOST_HIT_CNT" }, -+ { "LAN_PAIR_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ppp_type_64_tx_normal_stats1[] = { -+ { "GET_TX_PKT_CNT" }, -+ { "SEND_UC_HOST2HOST_PKT_CNT" }, -+ { "SEND_UC_HOST2PRT_PKT_CNT" }, -+ { "SEND_MC_FROM_HOST_CNT" }, -+ { "PPP_MC_2PRT_PKT_CNT" }, -+ { "NTSNOS_PKT_CNT" }, -+ { "NTUP_PKT_CNT" }, -+ { "NTLCL_PKT_CNT" }, -+ { "NTTGT_PKT_CNT" }, -+ { "RTNS_PKT_CNT" }, -+ { "RTLPBK_PKT_CNT" }, -+ { "BC_HIT_CNT" }, -+ { "SEND_UC_HOST2BMC_PKT_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ppp_type_64_tx_normal_stats2[] = { -+ { "PPP_MC_2BMC_PKT_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ppp_type_64_tx_drop_stats[] = { -+ { "PPP_TX_TAG_DROP_CNT_0" }, -+ { "PPP_TX_TAG_DROP_CNT_1" }, -+ { "PPP_TX_TAG_DROP_CNT_2" }, -+ { "PPP_TX_TAG_DROP_CNT_3" }, -+}; -+ -+static const struct dfx_reg_name dfx_ppp_type_32_running_stats[] = { -+ { "PPP_HFS_STS" }, -+ { "PPP_MC_RSLT_STS" }, -+ { "PPP_RSLT_DESCR_STS" }, -+ { "PPP_UMV_STS_0" }, -+ { "PPP_UMV_STS_1" }, -+ { "PPP_VFV_STS" }, -+}; -+ -+static const struct dfx_type_name_parse g_dfx_ppp_name_parse[] = { -+ { TYPE_32_COMM_DROP_STATS, -+ dfx_ppp_type_32_common_drop_stats1, HIKP_ARRAY_SIZE(dfx_ppp_type_32_common_drop_stats1)}, -+ { TYPE_32_COMM_DROP_STATS, -+ dfx_ppp_type_32_common_drop_stats2, HIKP_ARRAY_SIZE(dfx_ppp_type_32_common_drop_stats2)}, -+ { TYPE_32_RX_NORMAL_STATS, -+ dfx_ppp_type_32_rx_normal_stats, HIKP_ARRAY_SIZE(dfx_ppp_type_32_rx_normal_stats)}, -+ { TYPE_64_RX_NORMAL_STATS, -+ dfx_ppp_type_64_rx_normal_stats1, HIKP_ARRAY_SIZE(dfx_ppp_type_64_rx_normal_stats1)}, -+ { TYPE_64_RX_NORMAL_STATS, -+ dfx_ppp_type_64_rx_normal_stats2, HIKP_ARRAY_SIZE(dfx_ppp_type_64_rx_normal_stats2)}, -+ { TYPE_64_TX_NORMAL_STATS, -+ dfx_ppp_type_64_tx_normal_stats1, HIKP_ARRAY_SIZE(dfx_ppp_type_64_tx_normal_stats1)}, -+ { TYPE_64_TX_NORMAL_STATS, -+ dfx_ppp_type_64_tx_normal_stats2, HIKP_ARRAY_SIZE(dfx_ppp_type_64_tx_normal_stats2)}, -+ { TYPE_64_TX_DROP_STATS, -+ dfx_ppp_type_64_tx_drop_stats, HIKP_ARRAY_SIZE(dfx_ppp_type_64_tx_drop_stats)}, -+ { TYPE_32_RUNNING_STATUS, -+ dfx_ppp_type_32_running_stats, HIKP_ARRAY_SIZE(dfx_ppp_type_32_running_stats)}, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_rx_drop_stats[] = { -+ { "RX_OQ_DROP_PKT_CNT" }, -+ { "RX_OQ_GLB_DROP_PKT_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_rx_normal_stats[] = { -+ { "NCSI_RX_PACKET_IN_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_tx_drop_stats[] = { -+ { "TX_OQ_DROP_PKT_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_tx_normal_stats[] = { -+ { "NCSI_TX_PACKET_OUT_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_rx_port_drop_stats1[] = { -+ { "RX_FULL_DROP_NUM" }, -+ { "RX_PART_DROP_NUM" }, -+ { "ROCE_RX_BYPASS_5NS_DROP_NUM" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_rx_port_drop_stats2[] = { -+ { "RX_OQ_GLB_DROP_PKT_CNT_PORT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_tx_port_drop_stats1[] = { -+ { "TX_FULL_DROP_NUM" }, -+ { "TX_PART_DROP_NUM" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_tx_port_drop_stats2[] = { -+ { "TX_OQ_GLB_DROP_PKT_CNT_PORT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_running_stats[] = { -+ { "SSU_BP_STATUS_0" }, -+ { "SSU_BP_STATUS_1" }, -+ { "SSU_BP_STATUS_2" }, -+ { "SSU_BP_STATUS_3" }, -+ { "SSU_BP_STATUS_4" }, -+ { "SSU_BP_STATUS_5" }, -+ { "SSU_MAC_TX_PFC_IND" }, -+ { "MAC_SSU_RX_PFC_IND" }, -+ { "ROH_SSU_PFC" }, -+ { "SSU_ETS_PORT_STATUS" }, -+ { "SSU_ETS_TCG_STATUS" }, -+ { "BTMP_AGEING_ST" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_port_running_stats[] = { -+ { "PKT_TC_0_CURR_BUF_CNT" }, -+ { "PKT_TC_1_CURR_BUF_CNT" }, -+ { "PKT_TC_2_CURR_BUF_CNT" }, -+ { "PKT_TC_3_CURR_BUF_CNT" }, -+ { "PKT_TC_4_CURR_BUF_CNT" }, -+ { "PKT_TC_5_CURR_BUF_CNT" }, -+ { "PKT_TC_6_CURR_BUF_CNT" }, -+ { "PKT_TC_7_CURR_BUF_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_comm_stats[] = { -+ { "LO_PRI_UNICAST_CUR_CNT" }, -+ { "HI_PRI_MULTICAST_CUR_CNT" }, -+ { "LO_PRI_MULTICAST_CUR_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_comm_drop_stats[] = { -+ { "FULL_DROP_NUM" }, -+ { "PART_DROP_NUM" }, -+ { "PPP_KEY_DROP_NUM" }, -+ { "PPP_RLT_DROP_NUM" }, -+ { "MB_UNCOPY_NUM" }, -+ { "LO_PRI_UNICAST_RLT_DROP_NUM" }, -+ { "HI_PRI_MULTICAST_RLT_DROP_NUM" }, -+ { "LO_PRI_MULTICAST_RLT_DROP_NUM" }, -+ { "NIC_L2_ERR_DROP_PKT_CNT" }, -+ { "ROC_L2_ERR_DROP_PKT_CNT" }, -+ { "BANK_UNBALANCE_DROP_CNT" }, -+ { "SSU_MB_RD_RLT_DROP_CNT" }, -+ { "NCSI_FULL_DROP_NUM" }, -+ { "NCSI_PART_DROP_NUM" }, -+ { "NCSI_OQ_GLB_DROP_PKT_CNT_PORT" }, -+ { "LO_MB_DROP_FOR_CNT_MEM_EMPTY" }, -+ { "HI_MB_DROP_FOR_CNT_MEM_EMPTY" }, -+ { "SSU_OVERSIZE_DROP_NUM" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_32_comm_err_stats[] = { -+ { "SSU_ECC_1BIT_ERR_CNT" }, -+ { "SSU_ECC_MULTI_BIT_ERR_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_64_rx_port_drop_stats[] = { -+ { "RX_PACKET_IN_ERR_CNT" }, -+ { "RX_PACKET_OUT_ERR_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_64_tx_port_drop_stats[] = { -+ { "TX_PACKET_IN_ERR_CNT" }, -+ { "TX_PACKET_OUT_ERR_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_64_rx_port_normal_stats[] = { -+ { "RX_PKT_IN_CNT" }, -+ { "RX_PACKET_OUT_CNT" }, -+ { "RX_PKT_TC_0_IN_CNT" }, -+ { "RX_PKT_TC_1_IN_CNT" }, -+ { "RX_PKT_TC_2_IN_CNT" }, -+ { "RX_PKT_TC_3_IN_CNT" }, -+ { "RX_PKT_TC_4_IN_CNT" }, -+ { "RX_PKT_TC_5_IN_CNT" }, -+ { "RX_PKT_TC_6_IN_CNT" }, -+ { "RX_PKT_TC_7_IN_CNT" }, -+ { "RX_PACKET_TC_0_OUT_CNT" }, -+ { "RX_PACKET_TC_1_OUT_CNT" }, -+ { "RX_PACKET_TC_2_OUT_CNT" }, -+ { "RX_PACKET_TC_3_OUT_CNT" }, -+ { "RX_PACKET_TC_4_OUT_CNT" }, -+ { "RX_PACKET_TC_5_OUT_CNT" }, -+ { "RX_PACKET_TC_6_OUT_CNT" }, -+ { "RX_PACKET_TC_7_OUT_CNT" }, -+ { "ROC_RX_PACKET_IN_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_64_tx_port_normal_stats[] = { -+ { "TX_PKT_IN_CNT" }, -+ { "TX_PKT_OUT_CNT" }, -+ { "TX_PKT_TC_0_IN_CNT" }, -+ { "TX_PKT_TC_1_IN_CNT" }, -+ { "TX_PKT_TC_2_IN_CNT" }, -+ { "TX_PKT_TC_3_IN_CNT" }, -+ { "TX_PKT_TC_4_IN_CNT" }, -+ { "TX_PKT_TC_5_IN_CNT" }, -+ { "TX_PKT_TC_6_IN_CNT" }, -+ { "TX_PKT_TC_7_IN_CNT" }, -+ { "TX_PACKET_TC_0_OUT_CNT" }, -+ { "TX_PACKET_TC_1_OUT_CNT" }, -+ { "TX_PACKET_TC_2_OUT_CNT" }, -+ { "TX_PACKET_TC_3_OUT_CNT" }, -+ { "TX_PACKET_TC_4_OUT_CNT" }, -+ { "TX_PACKET_TC_5_OUT_CNT" }, -+ { "TX_PACKET_TC_6_OUT_CNT" }, -+ { "TX_PACKET_TC_7_OUT_CNT" }, -+ { "ROC_TX_PACKET_OUT_CNT" }, -+}; -+ -+static const struct dfx_reg_name dfx_ssu_type_64_tx_comm_stats[] = { -+ { "SSU_PPP_MAC_KEY_NUM" }, -+ { "SSU_PPP_HOST_KEY_NUM" }, -+ { "PPP_SSU_MAC_RLT_NUM" }, -+ { "PPP_SSU_HOST_RLT_NUM" }, -+}; -+ -+static const struct dfx_type_name_parse g_dfx_ssu_name_parse[] = { -+ { TYPE_32_RX_DROP_STATS, -+ dfx_ssu_type_32_rx_drop_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_32_rx_drop_stats)}, -+ { TYPE_32_RX_NORMAL_STATS, -+ dfx_ssu_type_32_rx_normal_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_32_rx_normal_stats)}, -+ { TYPE_32_TX_DROP_STATS, -+ dfx_ssu_type_32_tx_drop_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_32_tx_drop_stats)}, -+ { TYPE_32_TX_NORMAL_STATS, -+ dfx_ssu_type_32_tx_normal_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_32_tx_normal_stats)}, -+ { TYPE_32_RX_PORT_DROP_STATS, -+ dfx_ssu_type_32_rx_port_drop_stats1, HIKP_ARRAY_SIZE(dfx_ssu_type_32_rx_port_drop_stats1)}, -+ { TYPE_32_RX_PORT_DROP_STATS, -+ dfx_ssu_type_32_rx_port_drop_stats2, HIKP_ARRAY_SIZE(dfx_ssu_type_32_rx_port_drop_stats2)}, -+ { TYPE_32_TX_PORT_DROP_STATS, -+ dfx_ssu_type_32_tx_port_drop_stats1, HIKP_ARRAY_SIZE(dfx_ssu_type_32_tx_port_drop_stats1)}, -+ { TYPE_32_TX_PORT_DROP_STATS, -+ dfx_ssu_type_32_tx_port_drop_stats2, HIKP_ARRAY_SIZE(dfx_ssu_type_32_tx_port_drop_stats2)}, -+ { TYPE_32_RUNNING_STATUS, -+ dfx_ssu_type_32_running_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_32_running_stats)}, -+ { TYPE_32_PORT_RUNNING_STATUS, -+ dfx_ssu_type_32_port_running_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_32_port_running_stats)}, -+ { TYPE_32_COMM_STATS, -+ dfx_ssu_type_32_comm_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_32_comm_stats)}, -+ { TYPE_32_COMM_DROP_STATS, -+ dfx_ssu_type_32_comm_drop_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_32_comm_drop_stats)}, -+ { TYPE_32_COMM_ERROR_STATS, -+ dfx_ssu_type_32_comm_err_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_32_comm_err_stats)}, -+ { TYPE_64_RX_PORT_DROP_STATS, -+ dfx_ssu_type_64_rx_port_drop_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_64_rx_port_drop_stats)}, -+ { TYPE_64_TX_PORT_DROP_STATS, -+ dfx_ssu_type_64_tx_port_drop_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_64_tx_port_drop_stats)}, -+ { TYPE_64_RX_PORT_NORMAL_STATS, -+ dfx_ssu_type_64_rx_port_normal_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_64_rx_port_normal_stats)}, -+ { TYPE_64_TX_PORT_NORMAL_STATS, -+ dfx_ssu_type_64_tx_port_normal_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_64_tx_port_normal_stats)}, -+ { TYPE_64_COMM_STATS, -+ dfx_ssu_type_64_tx_comm_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_64_tx_comm_stats)}, -+}; -+ - static void dfx_help_info(const struct major_cmd_ctrl *self) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -218,35 +541,96 @@ static int cmd_dfx_module_select(struct major_cmd_ctrl *self, const char *argv) - return -EINVAL; - } - --static void hikp_nic_dfx_print_b32(uint32_t num, uint32_t *reg_data) -+static const struct dfx_reg_name *hikp_nic_get_ssu_list(uint8_t type_id, uint32_t reg_num) - { -+ uint32_t i; -+ -+ for (i = 0; i < HIKP_ARRAY_SIZE(g_dfx_ssu_name_parse); i++) { -+ if (g_dfx_ssu_name_parse[i].type_id != type_id) -+ continue; -+ if (reg_num != g_dfx_ssu_name_parse[i].reg_num) -+ continue; -+ -+ return g_dfx_ssu_name_parse[i].reg_list; -+ } -+ return NULL; -+} -+ -+static const struct dfx_reg_name *hikp_nic_get_ppp_list(uint8_t type_id, uint32_t reg_num) -+{ -+ uint32_t i; -+ -+ for (i = 0; i < HIKP_ARRAY_SIZE(g_dfx_ppp_name_parse); i++) { -+ if (g_dfx_ppp_name_parse[i].type_id != type_id) -+ continue; -+ if (reg_num != g_dfx_ppp_name_parse[i].reg_num) -+ continue; -+ -+ return g_dfx_ppp_name_parse[i].reg_list; -+ } -+ return NULL; -+} -+ -+static const struct dfx_reg_name *hikp_nic_dfx_get_reg_list(uint8_t type_id, -+ uint32_t sub_cmd_code, -+ uint32_t reg_num) -+{ -+ if (sub_cmd_code == SSU_DFX_REG_DUMP) -+ return hikp_nic_get_ssu_list(type_id, reg_num); -+ else if (sub_cmd_code == PPP_DFX_REG_DUMP) -+ return hikp_nic_get_ppp_list(type_id, reg_num); -+ return NULL; -+} -+ -+static void hikp_nic_dfx_print_b32(struct nic_dfx_type_head *type_head, uint32_t *reg_data) -+{ -+ uint32_t num = (uint32_t)type_head->reg_num; - uint32_t word_num = num * WORD_NUM_PER_REG; -+ const struct dfx_reg_name *reg_list; -+ uint32_t sub_cmd_code; - uint16_t offset; - uint32_t value; - uint32_t index; - uint32_t i; - -+ sub_cmd_code = g_dfx_module_parse[g_dfx_param.module_idx].sub_cmd_code; -+ reg_list = hikp_nic_dfx_get_reg_list(type_head->type_id, sub_cmd_code, num); - for (i = 0, index = 1; i < word_num; i = i + WORD_NUM_PER_REG, index++) { - offset = (uint16_t)HI_GET_BITFIELD(reg_data[i], 0, DFX_REG_ADDR_MASK); - value = reg_data[i + 1]; -- printf("%03u: 0x%04x\t0x%08x\n", index, offset, value); -+ if (reg_list != NULL) { -+ printf("%-30s\t0x%04x\t0x%08x\n", reg_list->name, offset, value); -+ reg_list++; -+ } else { -+ printf("%-30s\t0x%04x\t0x%08x\n", "", offset, value); -+ } - } - } - --static void hikp_nic_dfx_print_b64(uint32_t num, uint32_t *reg_data) -+static void hikp_nic_dfx_print_b64(struct nic_dfx_type_head *type_head, uint32_t *reg_data) - { -+ uint32_t num = (uint32_t)type_head->reg_num; - uint32_t word_num = num * WORD_NUM_PER_REG; -+ const struct dfx_reg_name *reg_list; -+ uint32_t sub_cmd_code; - uint16_t offset; - uint64_t value; - uint32_t index; - uint32_t i; - -+ sub_cmd_code = g_dfx_module_parse[g_dfx_param.module_idx].sub_cmd_code; -+ reg_list = hikp_nic_dfx_get_reg_list(type_head->type_id, sub_cmd_code, num); - for (i = 0, index = 1; i < word_num; i = i + WORD_NUM_PER_REG, index++) { - offset = (uint16_t)HI_GET_BITFIELD(reg_data[i], 0, DFX_REG_ADDR_MASK); - value = (uint64_t)reg_data[i + 1] | - (HI_GET_BITFIELD((uint64_t)reg_data[i], DFX_REG_VALUE_OFF, - DFX_REG_VALUE_MASK) << BIT_NUM_OF_WORD); -- printf("%03u: 0x%04x\t0x%016lx\n", index, offset, value); -+ if (reg_list != NULL) { -+ printf("%-30s\t0x%04x\t0x%016lx\n", reg_list->name, offset, value); -+ reg_list++; -+ } else { -+ printf("%-30s\t0x%04x\t0x%08x\n", "", offset, value); -+ } - } - } - -@@ -287,6 +671,7 @@ static void hikp_nic_dfx_print(const struct nic_dfx_rsp_head_t *rsp_head, uint32 - uint32_t *ptr = reg_data; - uint32_t max_size; - uint32_t num_u32; -+ bool show_title; - uint8_t i; - - max_size = dfx_get_max_reg_bffer_size(rsp_head); -@@ -310,12 +695,15 @@ static void hikp_nic_dfx_print(const struct nic_dfx_rsp_head_t *rsp_head, uint32 - HIKP_ERROR_PRINT("No.%u type is incorrect reg type\n", i + 1u); - break; - } -+ show_title = type_head->type_id != last_type_id; - hikp_nic_dfx_print_type_head(type_head->type_id, &last_type_id); - ptr++; -+ if (show_title) -+ printf("%-30s\t%s\t%s\n", "name", "offset", "value"); - if (type_head->bit_width == WIDTH_32_BIT) { -- hikp_nic_dfx_print_b32((uint32_t)type_head->reg_num, ptr); -+ hikp_nic_dfx_print_b32(type_head, ptr); - } else if (type_head->bit_width == WIDTH_64_BIT) { -- hikp_nic_dfx_print_b64((uint32_t)type_head->reg_num, ptr); -+ hikp_nic_dfx_print_b64(type_head, ptr); - } else { - HIKP_ERROR_PRINT("type%u's bit width error.\n", type_head->type_id); - break; -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.h b/net/nic/nic_dfx/hikp_nic_dfx.h -index d46d290..38f76aa 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.h -+++ b/net/nic/nic_dfx/hikp_nic_dfx.h -@@ -138,4 +138,15 @@ struct nic_dfx_rsp_t { - uint32_t reg_data[MAX_DFX_DATA_NUM]; - }; - -+#define MAX_REG_NAME_LEN 64 -+struct dfx_reg_name { -+ const char name[MAX_REG_NAME_LEN]; -+}; -+ -+struct dfx_type_name_parse { -+ uint8_t type_id; -+ const struct dfx_reg_name *reg_list; -+ uint32_t reg_num; -+}; -+ - #endif /* HIKP_NIC_DFX_H */ --- -2.45.0.windows.1 - diff --git a/0085-hikptool-Added-the-dfx-register-for-PCIe-dump.patch b/0085-hikptool-Added-the-dfx-register-for-PCIe-dump.patch deleted file mode 100644 index 283080dd68501422743414e679e366bef8188b17..0000000000000000000000000000000000000000 --- a/0085-hikptool-Added-the-dfx-register-for-PCIe-dump.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 2aa68f56a13a74d4398f1cb51c67747a04e84146 Mon Sep 17 00:00:00 2001 -From: Bingquan Mou -Date: Mon, 30 Sep 2024 10:02:39 +0800 -Subject: [PATCH 23/27] hikptool: Added the dfx register for PCIe dump. - -category: feature -bugzilla: NA -CVE: NA - -This register is added for PCIe dump. -MAC: MAC_REG_PHY_RXDATA_TS_REG/MAC_LTSSM_TRACER_CFG0_REG/MAC_POWERDOWN_VALUE_REG -PCS: DETECT_CLK_FLG_REG/SDS_CFG_REG_REG -GLB: PCIE_LINK_DOWN_CLR_PORT_EN_REG/CORE_CLK_FLG_REG - -Signed-off-by: Bingquan Mou ---- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index 9444f64..abf0e26 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -129,6 +129,9 @@ struct pcie_dumpreg_info g_reg_table_mac[] = { - {0, "MAC_LEAVE_L0_INFO"}, - {0, "DFX_APB_LANE_ERROR_STATUS_0"}, - {0, "DFX_APB_LANE_ERROR_STATUS_1"}, -+ {0, "MAC_REG_PHY_RXDATA_TS_REG"}, -+ {0, "MAC_LTSSM_TRACER_CFG0_REG"}, -+ {0, "MAC_POWERDOWN_VALUE_REG"}, - }; - - struct pcie_dumpreg_info g_reg_table_pcs[] = { -@@ -141,6 +144,8 @@ struct pcie_dumpreg_info g_reg_table_pcs[] = { - HIKP_PCIE_PCS_LANE_TBL_ENTRY(LANE_INTR_STATUS), - HIKP_PCIE_PCS_LANE_TBL_ENTRY(M_PCS_RPT_REG), - HIKP_PCIE_PCS_LANE_TBL_ENTRY(MSG_BUS_DFX), -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(DETECT_CLK_FLG_REG), -+ HIKP_PCIE_PCS_LANE_TBL_ENTRY(SDS_CFG_REG_REG), - }; - - struct pcie_dumpreg_info g_reg_table_iob_tx[] = { -@@ -364,6 +369,8 @@ struct pcie_dumpreg_info g_reg_table_core_glb[] = { - {0, "CORE_INT_FE_RO_2"}, - {0, "PORT07_LINK_MODE"}, - {0, "PORT815_LINK_MODE"}, -+ {0, "PCIE_LINK_DOWN_CLR_PORT_EN_REG"}, -+ {0, "CORE_CLK_FLG_REG"}, - }; - - struct pcie_dumpreg_info g_reg_table_core_tl[] = { --- -2.45.0.windows.1 - diff --git a/0086-hikptool-The-macro_num-error-is-rectified-and-the-of.patch b/0086-hikptool-The-macro_num-error-is-rectified-and-the-of.patch deleted file mode 100644 index 4e4de78bb1e348d2506ea252e041914ff691e16b..0000000000000000000000000000000000000000 --- a/0086-hikptool-The-macro_num-error-is-rectified-and-the-of.patch +++ /dev/null @@ -1,62 +0,0 @@ -From f8edb8f7f8882aaa68b24d7bb37659f2589c90ca Mon Sep 17 00:00:00 2001 -From: Bingquan Mou -Date: Sat, 12 Oct 2024 17:11:38 +0800 -Subject: [PATCH 24/27] hikptool: The macro_num error is rectified, and the - offset writing is incorrect. - -category: feature -bugzilla: NA -CVE: NA - -1.It is reasonable that core0 has three macros. Therefore, macro_num == 3 is reasonable. -2.The offset writing is incorrect. - -Signed-off-by: Bingquan Mou ---- - pcie/func_lib/pcie_func/pcie_link_ltssm.c | 2 +- - pcie/func_lib/pcie_func/pcie_link_ltssm.h | 2 +- - pcie/func_lib/pcie_func/pcie_statistics.c | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.c b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -index 1bc2edb..d3534f5 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.c -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -@@ -211,7 +211,7 @@ static int pcie_print_ltssm_trace(const uint64_t *ltssm_input, uint32_t ltssm_nu - (uint32_t)ltssm_val.bits.any_change_pipe_req, - (uint32_t)ltssm_val.bits.rxl0s_st, - (uint32_t)ltssm_val.bits.train_bit_map1, -- (((uint32_t)ltssm_val.bits.rxl0s_st) << GEN5_BIT_OFFEST) | -+ (((uint32_t)ltssm_val.bits.rxl0s_st) << GEN5_BIT_OFFSET) | - ((uint32_t)ltssm_val.bits.mac_rate), - (uint32_t)ltssm_val.bits.duration_counter, - (uint32_t)ltssm_val.bits.ltssm_state, -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.h b/pcie/func_lib/pcie_func/pcie_link_ltssm.h -index 9986f7a..278f3e4 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.h -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.h -@@ -19,7 +19,7 @@ - #define TRACE_STR_NUM 0x20 - #define TRACER_DEPTH 65 - #define PM_TRACE_STR_NUM 0x28 --#define GEN5_BIT_OFFEST 2 -+#define GEN5_BIT_OFFSET 2 - - struct pcie_ltssm_num_string { - int ltssm; -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c -index 54d4edb..be187f2 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.c -+++ b/pcie/func_lib/pcie_func/pcie_statistics.c -@@ -70,7 +70,7 @@ static int pcie_portid_serdes_relation(const struct pcie_macro_info *macro_info, - return -1; - } - -- if (macro_num >= MAX_MACRO_ONEPORT) { -+ if (macro_num > MAX_MACRO_ONEPORT) { - Info("macro_num [%u] exceeds the maximum array length\n", macro_num); - return -1; - } --- -2.45.0.windows.1 - diff --git a/0087-Fix-the-logic-of-obtaining-statistics-on-flow-contro.patch b/0087-Fix-the-logic-of-obtaining-statistics-on-flow-contro.patch deleted file mode 100644 index 251b0e3fe2733c186ee8af881ba39e27c04b3491..0000000000000000000000000000000000000000 --- a/0087-Fix-the-logic-of-obtaining-statistics-on-flow-contro.patch +++ /dev/null @@ -1,185 +0,0 @@ -From 261fdd1cc832989c60b3940cd8b2aa6593bc94ea Mon Sep 17 00:00:00 2001 -From: Yuyu Li -Date: Tue, 12 Nov 2024 20:17:06 +0800 -Subject: [PATCH 25/27] Fix the logic of obtaining statistics on flow control - storm suppression - -Previously, regardless of the direction specified by -d, FW would return the statistics -of flow control storm suppression in both directions. Now it only returns the statistic -in the specified direction. An example is shown: - -hikptool nic_qos -i eth6 -g pfc_storm_para -d rx - -before: -PFC STORM Information: -direction: rx -enabled: on -period: 2000ms -pfc threshold: 1000ms -recovery period: 500ms -rx storm suppression count: 14 - -after: -PFC STORM Information: -direction: rx -enabled: on -period: 2000ms -pfc threshold: 1000ms -recovery period: 500ms -storm count: 14 - -Signed-off-by: Yuyu Li ---- - net/nic/nic_qos/hikp_nic_qos.c | 32 ++++++++++++++++++++++---------- - net/nic/nic_qos/hikp_nic_qos.h | 14 +++++++++----- - 2 files changed, 31 insertions(+), 15 deletions(-) - -diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c -index 81eb0ba..32f251e 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.c -+++ b/net/nic/nic_qos/hikp_nic_qos.c -@@ -56,7 +56,8 @@ static int hikp_nic_qos_cmd_help(struct major_cmd_ctrl *self, const char *argv) - - static void hikp_nic_qos_show_pkt_buf(const void *data) - { -- struct nic_pkt_buf_info *pkt_buf = (struct nic_pkt_buf_info *)data; -+ struct qos_cmd_info *qos_info_pkt = (struct qos_cmd_info *)data; -+ struct nic_pkt_buf_info *pkt_buf = (struct nic_pkt_buf_info *)&qos_info_pkt->info; - struct nic_shared_buf *share_buf = &pkt_buf->share_buf; - struct nic_priv_buf *priv_buf = pkt_buf->priv_buf; - uint16_t tc_no; -@@ -88,11 +89,12 @@ static void hikp_nic_qos_show_pkt_buf(const void *data) - - static void hikp_nic_qos_show_dcb_info(const void *data) - { -- struct nic_dcb_info *dcb = (struct nic_dcb_info *)data; -+ struct qos_cmd_info *qos_info_dcb = (struct qos_cmd_info *)data; -+ struct nic_dcb_info *dcb = (struct nic_dcb_info *)&qos_info_dcb->info; - struct nic_pfc_info *pfc = &dcb->pfc; - struct nic_ets_info *ets = &dcb->ets; -- uint16_t up; - uint16_t tc_no; -+ uint16_t up; - - printf("PFC configuration\n"); - printf(" PFC enable:"); -@@ -125,7 +127,8 @@ static void hikp_nic_qos_show_dcb_info(const void *data) - - static void hikp_nic_qos_show_pause_info(const void *data) - { -- struct nic_pause_info *pause = (struct nic_pause_info *)data; -+ struct qos_cmd_info *qos_info_pause = (struct qos_cmd_info *)data; -+ struct nic_pause_info *pause = (struct nic_pause_info *)&qos_info_pause->info; - - printf("PAUSE Information\n"); - if (pause->type == HIKP_NONE_PAUSE) -@@ -143,8 +146,10 @@ static void hikp_nic_qos_show_pause_info(const void *data) - - static void hikp_nic_qos_show_pfc_storm_para(const void *data) - { -+ struct qos_cmd_info *qos_info_pfc = (struct qos_cmd_info *)data; - struct nic_pfc_storm_para *pfc_storm_para = -- (struct nic_pfc_storm_para *)data; -+ (struct nic_pfc_storm_para *)&qos_info_pfc->info; -+ uint32_t length = qos_info_pfc->length; - - printf("PFC STORM Information:\n"); - printf("direction: %s\n", pfc_storm_para->dir ? "tx" : "rx"); -@@ -155,6 +160,11 @@ static void hikp_nic_qos_show_pfc_storm_para(const void *data) - printf("check times: %u\n", pfc_storm_para->times) : - printf("pfc threshold: %ums\n", pfc_storm_para->times); - printf("recovery period: %ums\n", pfc_storm_para->recovery_period_ms); -+ -+ if (length < sizeof(struct nic_pfc_storm_para)) -+ return; -+ -+ printf("storm count: %u\n", pfc_storm_para->storm_count); - } - - static int hikp_nic_qos_get_blk(struct hikp_cmd_header *req_header, -@@ -192,11 +202,11 @@ out: - } - - static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const struct bdf_t *bdf, -- union nic_qos_feature_info *data) -+ struct qos_cmd_info *qcmd_info) - { -+ size_t buf_len = sizeof(qcmd_info->info); - struct nic_qos_rsp_head rsp_head = {0}; - struct nic_qos_req_para req_data; -- size_t buf_len = sizeof(*data); - uint32_t total_blk_size; - uint8_t total_blk_num; - uint8_t blk_id = 0; -@@ -207,7 +217,7 @@ static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const - req_data.block_id = blk_id; - req_data.dir = g_qos_param.dir; - -- ret = hikp_nic_qos_get_blk(req_header, &req_data, data, buf_len, &rsp_head); -+ ret = hikp_nic_qos_get_blk(req_header, &req_data, &qcmd_info->info, buf_len, &rsp_head); - if (ret != 0) - return ret; - -@@ -220,13 +230,15 @@ static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const - req_data.dir = g_qos_param.dir; - - ret = hikp_nic_qos_get_blk(req_header, &req_data, -- (uint8_t *)data + total_blk_size, -+ (uint8_t *)&qcmd_info->info + total_blk_size, - buf_len - total_blk_size, &rsp_head); - if (ret != 0) - return ret; - total_blk_size += rsp_head.cur_blk_size; - } - -+ qcmd_info->length = total_blk_size; -+ - return ret; - } - -@@ -234,9 +246,9 @@ static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self) - { - char *revision_id = g_qos_param.revision_id; - struct bdf_t *bdf = &g_qos_param.target.bdf; -- union nic_qos_feature_info qos_data = {0}; - struct hikp_cmd_header req_header = {0}; - const struct qos_feature_cmd *qos_cmd; -+ struct qos_cmd_info qos_data = {0}; - int ret; - - if (bdf->dev_id != 0) { -diff --git a/net/nic/nic_qos/hikp_nic_qos.h b/net/nic/nic_qos/hikp_nic_qos.h -index d55970a..77fbdd9 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.h -+++ b/net/nic/nic_qos/hikp_nic_qos.h -@@ -57,6 +57,7 @@ struct nic_pfc_storm_para { - uint32_t period_ms; - uint32_t times; - uint32_t recovery_period_ms; -+ uint32_t storm_count; - }; - - struct nic_ets_info { -@@ -87,11 +88,14 @@ struct nic_pause_info { - uint16_t rsv; - }; - --union nic_qos_feature_info { -- struct nic_pkt_buf_info pkt_buf; -- struct nic_dcb_info dcb; -- struct nic_pause_info pause; -- struct nic_pfc_storm_para pfc_storm_para; -+struct qos_cmd_info { -+ uint32_t length; -+ union nic_qos_feature_info { -+ struct nic_pkt_buf_info pkt_buf; -+ struct nic_dcb_info dcb; -+ struct nic_pause_info pause; -+ struct nic_pfc_storm_para pfc_storm_para; -+ } info; - }; - - struct nic_qos_rsp_head { --- -2.45.0.windows.1 - diff --git a/0088-hikptool-Rectify-the-compilation-alarm.patch b/0088-hikptool-Rectify-the-compilation-alarm.patch deleted file mode 100644 index af82b0f017eb6ac611124ce3f272daf09afd4bf0..0000000000000000000000000000000000000000 --- a/0088-hikptool-Rectify-the-compilation-alarm.patch +++ /dev/null @@ -1,102 +0,0 @@ -From de71b27c71022e1051b1c3e85f849aedb13ec644 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 24 Oct 2024 20:52:48 +0800 -Subject: [PATCH 26/27] hikptool: Rectify the compilation alarm. - -Replace -Wextra with -Werror option. - -Signed-off-by: veega2022 ---- - CMakeLists.txt | 2 +- - net/hikp_net_lib.c | 3 ++- - net/nic/nic_dfx/hikp_nic_dfx.c | 5 +++-- - net/nic/nic_ft/hikp_nic_port_fault.c | 2 +- - net/nic/nic_qos/hikp_nic_qos.c | 7 ++++--- - 5 files changed, 11 insertions(+), 8 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index f2ffe6c..4fb82ca 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -11,7 +11,7 @@ - - project(hikptool C) - --set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -fPIC -fPIE -Wall -Wextra -fno-common -std=gnu11") -+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -fPIC -fPIE -Wall -Werror -fno-common -std=gnu11") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-equal -fstack-protector-strong -D_FORTIFY_SOURCE=2") - set(CMAKE_SKIP_RPATH TRUE) - -diff --git a/net/hikp_net_lib.c b/net/hikp_net_lib.c -index fbf03bd..f4d4c2a 100644 ---- a/net/hikp_net_lib.c -+++ b/net/hikp_net_lib.c -@@ -142,7 +142,8 @@ static bool check_dev_name_and_get_bdf(int sockfd, struct tool_target *target) - ifr.ifr_data = (char *)&drvinfo; - drvinfo.cmd = ETHTOOL_GDRVINFO; - -- strncpy(ifr.ifr_name, target->dev_name, IFNAMSIZ - 1); -+ strncpy(ifr.ifr_name, target->dev_name, IFNAMSIZ); -+ ifr.ifr_name[IFNAMSIZ - 1] = '\0'; - - if (ioctl(sockfd, SIOCETHTOOL, &ifr) < 0) - return false; -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c -index 67a5fe1..c42b8e7 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.c -+++ b/net/nic/nic_dfx/hikp_nic_dfx.c -@@ -17,6 +17,7 @@ - #include - #include - #include -+#include - #include "tool_cmd.h" - #include "hikp_net_lib.h" - #include "hikp_nic_dfx.h" -@@ -626,10 +627,10 @@ static void hikp_nic_dfx_print_b64(struct nic_dfx_type_head *type_head, uint32_t - (HI_GET_BITFIELD((uint64_t)reg_data[i], DFX_REG_VALUE_OFF, - DFX_REG_VALUE_MASK) << BIT_NUM_OF_WORD); - if (reg_list != NULL) { -- printf("%-30s\t0x%04x\t0x%016lx\n", reg_list->name, offset, value); -+ printf("%-30s\t0x%04x\t0x%" PRIx64 "\n", reg_list->name, offset, value); - reg_list++; - } else { -- printf("%-30s\t0x%04x\t0x%08x\n", "", offset, value); -+ printf("%-30s\t0x%04x\t0x%" PRIx64 "\n", "", offset, value); - } - } - } -diff --git a/net/nic/nic_ft/hikp_nic_port_fault.c b/net/nic/nic_ft/hikp_nic_port_fault.c -index 6561e3e..5f78cdd 100644 ---- a/net/nic/nic_ft/hikp_nic_port_fault.c -+++ b/net/nic/nic_ft/hikp_nic_port_fault.c -@@ -41,7 +41,7 @@ static int hikp_nic_port_fault_query(const struct bdf_t *bdf, - } - - rsp = (struct nic_port_fault_rsp *)cmd_ret->rsp_data; -- *info = *(struct nic_port_fault_status *)rsp->data; -+ memcpy(info, rsp->data, sizeof(struct nic_port_fault_status)); - hikp_cmd_free(&cmd_ret); - - return 0; -diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c -index 32f251e..c620a08 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.c -+++ b/net/nic/nic_qos/hikp_nic_qos.c -@@ -286,9 +286,10 @@ static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self) - memset(revision_id, 0, MAX_PCI_ID_LEN + 1); - ret = get_revision_id_by_bdf(bdf, revision_id, sizeof(g_qos_param.revision_id)); - // show pfc threshold as default if get revision_id error -- if (ret) -- strncpy(g_qos_param.revision_id, HIKP_IEP_REVISION, -- MAX_PCI_REVISION_LEN); -+ if (ret) { -+ strncpy(g_qos_param.revision_id, HIKP_IEP_REVISION, MAX_PCI_REVISION_LEN); -+ g_qos_param.revision_id[MAX_PCI_ID_LEN] = '\0'; -+ } - - printf("############## NIC QOS: %s info ############\n", qos_cmd->feature_name); - qos_cmd->show(&qos_data); --- -2.45.0.windows.1 - diff --git a/0089-hikptool-Update-the-tool-version-number-to-1.1.3.patch b/0089-hikptool-Update-the-tool-version-number-to-1.1.3.patch deleted file mode 100644 index da0387aaa83d8c9685aafcf7b08b1bf432df43d4..0000000000000000000000000000000000000000 --- a/0089-hikptool-Update-the-tool-version-number-to-1.1.3.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 43577e52be8f24eff1eab81d6474f0b66edc6a21 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Tue, 12 Nov 2024 20:28:55 +0800 -Subject: [PATCH 27/27] hikptool: Update the tool version number to 1.1.3 - -Update the tool version number to 1.1.3 - -Signed-off-by: veega2022 ---- - tool_lib/tool_lib.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index 15dac74..34cc3e8 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.2" -+#define TOOL_VER "1.1.3" - - #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/0090-hikptool-Support-for-info-collect.patch b/0090-hikptool-Support-for-info-collect.patch deleted file mode 100644 index d23fcace71cd8c271bf842228f58534da92ef12e..0000000000000000000000000000000000000000 --- a/0090-hikptool-Support-for-info-collect.patch +++ /dev/null @@ -1,6084 +0,0 @@ -From 513a68f332d9a40b3ee800d85bba335dacc22212 Mon Sep 17 00:00:00 2001 -From: Xingui Yang -Date: Tue, 27 Aug 2024 11:02:55 +0800 -Subject: [PATCH] hikptool: Support for info collect - -Add the option of information collection and used to collect -full information from each module, such as imp, serdes, pcie -sas, sata, nic, roce, acc, socip, as follow. -1. Help for collect info, e.g. hikptool info_collect -h/--help -2. Collect imp info, e.g. hikptool info_collect -/--imp -3. Collect all info, e.g. hikptool info_collect -/--all - -Signed-off-by: Xingui Yang ---- - CMakeLists.txt | 1 + - info_collect/hikp_collect.h | 53 ++ - info_collect/hikp_collect_acc.c | 237 ++++++++ - info_collect/hikp_collect_common.c | 258 +++++++++ - info_collect/hikp_collect_imp.c | 133 +++++ - info_collect/hikp_collect_lib.c | 508 ++++++++++++++++++ - info_collect/hikp_collect_lib.h | 61 +++ - info_collect/hikp_collect_main.c | 274 ++++++++++ - info_collect/hikp_collect_nic.c | 368 +++++++++++++ - info_collect/hikp_collect_pcie.c | 215 ++++++++ - info_collect/hikp_collect_roce.c | 489 +++++++++++++++++ - info_collect/hikp_collect_sas.c | 453 ++++++++++++++++ - info_collect/hikp_collect_serdes.c | 244 +++++++++ - info_collect/hikp_collect_socip.c | 272 ++++++++++ - info_collect/hikp_collect_socip.h | 238 ++++++++ - net/nic/nic_dfx/hikp_nic_dfx.c | 11 +- - net/nic/nic_dfx/hikp_nic_dfx.h | 3 + - net/nic/nic_fd/hikp_nic_fd.c | 11 +- - net/nic/nic_fd/hikp_nic_fd.h | 4 + - net/nic/nic_fec/hikp_nic_fec.c | 4 +- - net/nic/nic_fec/hikp_nic_fec.h | 2 + - net/nic/nic_ft/hikp_nic_port_fault.c | 4 +- - net/nic/nic_ft/hikp_nic_port_fault.h | 2 + - net/nic/nic_gro/hikp_nic_gro.c | 4 +- - net/nic/nic_gro/hikp_nic_gro.h | 2 + - net/nic/nic_info/hikp_nic_info.c | 4 +- - net/nic/nic_info/hikp_nic_info.h | 2 + - net/nic/nic_log/hikp_nic_log.c | 39 +- - net/nic/nic_log/hikp_nic_log.h | 7 + - net/nic/nic_mac/hikp_nic_mac_dump.c | 28 +- - net/nic/nic_mac/hikp_nic_mac_dump.h | 11 + - net/nic/nic_mac/hikp_nic_port.c | 18 + - net/nic/nic_mac/hikp_nic_port.h | 6 + - net/nic/nic_mac/hikp_nic_xsfp.c | 23 + - net/nic/nic_mac/hikp_nic_xsfp.h | 6 + - net/nic/nic_ncsi/hikp_nic_ncsi.c | 18 + - net/nic/nic_ncsi/hikp_nic_ncsi.h | 6 + - net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c | 4 +- - net/nic/nic_notify_pkt/hikp_nic_notify_pkt.h | 2 + - net/nic/nic_ppp/hikp_nic_ppp.c | 11 +- - net/nic/nic_ppp/hikp_nic_ppp.h | 3 + - net/nic/nic_qos/hikp_nic_qos.c | 22 +- - net/nic/nic_qos/hikp_nic_qos.h | 10 +- - net/nic/nic_queue/hikp_nic_queue.c | 12 +- - net/nic/nic_queue/hikp_nic_queue.h | 4 + - net/nic/nic_rss/hikp_nic_rss.c | 9 +- - net/nic/nic_rss/hikp_nic_rss.h | 3 + - net/nic/nic_torus/hikp_nic_torus.c | 4 +- - net/nic/nic_torus/hikp_nic_torus.h | 2 + - net/roce/roce_bond/hikp_roce_bond.c | 8 +- - net/roce/roce_bond/hikp_roce_bond.h | 3 + - net/roce/roce_caep/hikp_roce_caep.c | 13 +- - net/roce/roce_caep/hikp_roce_caep.h | 4 + - .../roce_global_cfg/hikp_roce_global_cfg.c | 8 +- - .../roce_global_cfg/hikp_roce_global_cfg.h | 3 + - net/roce/roce_gmv/hikp_roce_gmv.c | 13 +- - net/roce/roce_gmv/hikp_roce_gmv.h | 4 + - net/roce/roce_mdb/hikp_roce_mdb.c | 13 +- - net/roce/roce_mdb/hikp_roce_mdb.h | 5 + - net/roce/roce_pkt/hikp_roce_pkt.c | 8 +- - net/roce/roce_pkt/hikp_roce_pkt.h | 3 + - net/roce/roce_qmm/hikp_roce_qmm.c | 18 +- - net/roce/roce_qmm/hikp_roce_qmm.h | 5 + - net/roce/roce_rst/hikp_roce_rst.c | 8 +- - net/roce/roce_rst/hikp_roce_rst.h | 3 + - net/roce/roce_scc/hikp_roce_scc.c | 19 +- - net/roce/roce_scc/hikp_roce_scc.h | 6 +- - net/roce/roce_timer/hikp_roce_timer.c | 8 +- - net/roce/roce_timer/hikp_roce_timer.h | 3 + - net/roce/roce_trp/hikp_roce_trp.c | 24 +- - net/roce/roce_trp/hikp_roce_trp.h | 7 +- - net/roce/roce_tsp/hikp_roce_tsp.c | 28 +- - net/roce/roce_tsp/hikp_roce_tsp.h | 7 +- - pcie/func_lib/pcie_func/pcie_link_ltssm.c | 2 +- - pcie/func_lib/pcie_func/pcie_link_ltssm.h | 1 + - pcie/func_lib/pcie_func/pcie_reg_dump.c | 7 +- - pcie/func_lib/pcie_func/pcie_reg_dump.h | 4 + - pcie/func_lib/pcie_func/pcie_statistics.c | 2 +- - pcie/func_lib/pcie_func/pcie_statistics.h | 2 + - sas/sas_func/sas_common.h | 2 +- - serdes/hikp_serdes.c | 215 ++++---- - serdes/hikp_serdes.h | 4 +- - socip/hikp_socip.h | 1 + - socip/hikp_socip_dumpreg.c | 2 +- - tool_lib/tool_lib.c | 40 ++ - tool_lib/tool_lib.h | 16 + - 86 files changed, 4434 insertions(+), 190 deletions(-) - create mode 100644 info_collect/hikp_collect.h - create mode 100644 info_collect/hikp_collect_acc.c - create mode 100644 info_collect/hikp_collect_common.c - create mode 100644 info_collect/hikp_collect_imp.c - create mode 100644 info_collect/hikp_collect_lib.c - create mode 100644 info_collect/hikp_collect_lib.h - create mode 100644 info_collect/hikp_collect_main.c - create mode 100644 info_collect/hikp_collect_nic.c - create mode 100644 info_collect/hikp_collect_pcie.c - create mode 100644 info_collect/hikp_collect_roce.c - create mode 100644 info_collect/hikp_collect_sas.c - create mode 100644 info_collect/hikp_collect_serdes.c - create mode 100644 info_collect/hikp_collect_socip.c - create mode 100644 info_collect/hikp_collect_socip.h - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 4fb82ca..f28a870 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -38,6 +38,7 @@ file(GLOB_RECURSE HIKPTOOL_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/serdes/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/socip/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/tool_lib/*.c -+ ${CMAKE_CURRENT_SOURCE_DIR}/info_collect/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/hikp_init_main.c - ) - -diff --git a/info_collect/hikp_collect.h b/info_collect/hikp_collect.h -new file mode 100644 -index 0000000..28aa5a4 ---- /dev/null -+++ b/info_collect/hikp_collect.h -@@ -0,0 +1,53 @@ -+/* -+ * Copyright (c) 2024 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_COLLECT_H -+#define HIKP_COLLECT_H -+ -+#define GROUP_SAS "sas" -+#define GROUP_SATA "sata" -+#define GROUP_ACC "acc" -+#define GROUP_SOCIP "socip" -+#define GROUP_NIC "nic" -+#define GROUP_ROCE "roce" -+#define GROUP_PCIE "pcie" -+#define GROUP_IMP "imp" -+#define GROUP_COMMON "common" -+#define GROUP_SERDES "serdes" -+ -+enum info_collect_type { -+ COLLECT_ACC, -+ COLLECT_IMP, -+ COLLECT_NIC, -+ COLLECT_PCIE, -+ COLLECT_ROCE, -+ COLLECT_SAS, -+ COLLECT_SATA, -+ COLLECT_SERDES, -+ COLLECT_SOCIP, -+ COLLECT_ALL, -+ COLLECT_UNKNOWN_TYPE, -+}; -+ -+void collect_sas_log(void); -+void collect_sata_log(void); -+void collect_acc_log(void); -+void collect_socip_log(void); -+void collect_common_log(void); -+void collect_nic_log(void); -+void collect_roce_log(void); -+void collect_pcie_info(void); -+void collect_imp_log(void); -+void collect_serdes_log(void); -+ -+#endif /* HIKP_COLLECT_H */ -diff --git a/info_collect/hikp_collect_acc.c b/info_collect/hikp_collect_acc.c -new file mode 100644 -index 0000000..e0f3918 ---- /dev/null -+++ b/info_collect/hikp_collect_acc.c -@@ -0,0 +1,237 @@ -+/* -+ * Copyright (c) 2024 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 -+#include -+ -+#include "hikp_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+ -+struct info_collect_cmd acc_cmd_arr[] = { -+ { -+ .group = GROUP_ACC, -+ .log_name = "uadk_version", -+ .args = {"uadk_tool", "dfx", "--version", NULL}, -+ }, -+ { -+ .group = GROUP_ACC, -+ .log_name = "openssl_version", -+ .args = {"openssl", "version", NULL}, -+ }, -+ { -+ .group = GROUP_ACC, -+ .log_name = "openssl3_version", -+ .args = {"openssl3", "version", NULL}, -+ }, -+ { -+ .group = GROUP_ACC, -+ .log_name = "qemu_version", -+ .args = {"qemu-system-aarch64", "-version", NULL}, -+ }, -+}; -+ -+struct info_collect_cmd acc_cmd_copy[] = { -+ { -+ .group = GROUP_ACC, -+ .log_name = "uadk", -+ .args = {"cp", "-rf", "/var/log/uadk.log", NULL}, -+ }, -+ { -+ .group = GROUP_ACC, -+ .log_name = "acc_sec", -+ .args = {"cp", "-rf", "/sys/kernel/debug/hisi_sec2/", NULL}, -+ }, -+ { -+ .group = GROUP_ACC, -+ .log_name = "acc_sec", -+ .args = {"cp", "-rf", "/sys/module/hisi_sec2/parameters/", NULL}, -+ }, -+ { -+ .group = GROUP_ACC, -+ .log_name = "acc_hpre", -+ .args = {"cp", "-rf", "/sys/kernel/debug/hisi_hpre/", NULL}, -+ }, -+ { -+ .group = GROUP_ACC, -+ .log_name = "acc_hpre", -+ .args = {"cp", "-rf", "/sys/module/hisi_hpre/parameters/", NULL}, -+ }, -+ { -+ .group = GROUP_ACC, -+ .log_name = "acc_zip", -+ .args = {"cp", "-rf", "/sys/kernel/debug/hisi_zip/", NULL}, -+ }, -+ { -+ .group = GROUP_ACC, -+ .log_name = "acc_zip", -+ .args = {"cp", "-rf", "/sys/module/hisi_zip/parameters/", NULL}, -+ }, -+ { -+ .group = GROUP_ACC, -+ .log_name = "acc_trng", -+ .args = {"cp", "-rf", "/sys/module/hisi_trng_v2/parameters/", NULL}, -+ }, -+}; -+ -+struct info_collect_cmd acc_copy_link[] = { -+ { -+ .group = GROUP_ACC, -+ .log_name = "uacce", -+ .args = {"cp", "-rf", "/sys/class/uacce", NULL}, -+ } -+}; -+ -+static int acc_cmd_mkdir(char *root_path, char *src_patch) -+{ -+ char dir_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ int ret; -+ -+ /* mkdir for log sub source */ -+ ret = snprintf(dir_path, LOG_FILE_PATH_MAX_LEN, "%s/%s", -+ root_path, src_patch); -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) { -+ HIKP_ERROR_PRINT("create dir path failed: %d\n", ret); -+ return -EINVAL; -+ } -+ -+ ret = tool_mk_dir((const char *)dir_path); -+ if (ret) -+ return ret; -+ -+ return 0; -+} -+ -+static int acc_collect_file(struct info_collect_cmd *acc_cmd, char *root_path, char *dev_path) -+{ -+ char sub_src_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ char save_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ struct info_collect_cmd tmp_cmd = {0}; -+ char *source_path = acc_cmd->args[ARGS_IDX2]; -+ char *sub_group = acc_cmd->log_name; -+ int ret; -+ -+ ret = snprintf(sub_src_path, LOG_FILE_PATH_MAX_LEN, "%s/%s/", -+ source_path, dev_path); -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) { -+ HIKP_ERROR_PRINT("create sub source path failed: %d\n", ret); -+ return -EINVAL; -+ } -+ if (access(sub_src_path, F_OK) != 0) { -+ HIKP_ERROR_PRINT("Can't access sub source path: %s\n", sub_src_path); -+ return -ENOENT; -+ } -+ -+ ret = snprintf(save_path, LOG_FILE_PATH_MAX_LEN, "%s/%s/%s/", -+ root_path, sub_group, dev_path); -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) { -+ HIKP_ERROR_PRINT("create save path failed: %d\n", ret); -+ return -EINVAL; -+ } -+ -+ tmp_cmd.group = acc_cmd->group; -+ tmp_cmd.log_name = acc_cmd->log_name; -+ tmp_cmd.args[ARGS_IDX0] = acc_cmd->args[ARGS_IDX0]; -+ tmp_cmd.args[ARGS_IDX1] = acc_cmd->args[ARGS_IDX1]; -+ tmp_cmd.args[ARGS_IDX2] = sub_src_path; -+ tmp_cmd.args[ARGS_IDX3] = save_path; -+ tmp_cmd.args[ARGS_IDX4] = NULL; -+ -+ ret = hikp_collect_exec((void *)&tmp_cmd); -+ if (ret) -+ return ret; -+ -+ return 0; -+} -+ -+static int acc_save_link_files(struct info_collect_cmd *link_cmd) -+{ -+ char root_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ char *source_path = link_cmd->args[ARGS_IDX2]; -+ char *sub_group = link_cmd->log_name; -+ struct dirent *dev_dir; -+ DIR *link_dir; -+ int ret; -+ -+ if (strcmp(link_cmd->args[ARGS_IDX0], "cp") != 0) { -+ HIKP_ERROR_PRINT("input cmd failed: %s.\n", link_cmd->args[ARGS_IDX0]); -+ return -EINVAL; -+ } -+ -+ ret = hikp_get_file_path(root_path, LOG_FILE_PATH_MAX_LEN, link_cmd->group); -+ if (ret < 0) { -+ HIKP_ERROR_PRINT("get save path fail: %d\n", ret); -+ return ret; -+ } -+ -+ if (source_path == NULL || access(source_path, F_OK) != 0) { -+ HIKP_ERROR_PRINT("Can't access source path: %s\n", source_path); -+ return -ENOENT; -+ } -+ -+ ret = acc_cmd_mkdir(root_path, sub_group); -+ if (ret) -+ return ret; -+ -+ link_dir = opendir(source_path); -+ if (!link_dir) { -+ HIKP_ERROR_PRINT("input source file dir is error!\n"); -+ return -ENOENT; -+ } -+ -+ /* 1 is sizeof ".", 2 is sizeof ".." */ -+ while ((dev_dir = readdir(link_dir)) != NULL) { -+ if (!strncmp(dev_dir->d_name, ".", 1) || -+ !strncmp(dev_dir->d_name, "..", sizeof(".."))) -+ continue; -+ -+ ret = acc_collect_file(link_cmd, root_path, dev_dir->d_name); -+ if (ret) -+ goto free_dir; -+ } -+ -+ closedir(link_dir); -+ return 0; -+ -+free_dir: -+ closedir(link_dir); -+ return ret; -+} -+ -+void collect_acc_log(void) -+{ -+ int i, asize; -+ int ret; -+ -+ asize = (int)HIKP_ARRAY_SIZE(acc_cmd_arr); -+ for (i = 0; i < asize; i++) { -+ ret = hikp_collect_log(acc_cmd_arr[i].group, acc_cmd_arr[i].log_name, -+ hikp_collect_exec, (void *)&acc_cmd_arr[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("collect_acc_log arr failed: %d\n", ret); -+ } -+ -+ asize = (int)HIKP_ARRAY_SIZE(acc_copy_link); -+ for (i = 0; i < asize; i++) { -+ ret = acc_save_link_files(&acc_copy_link[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("collect_acc_log link copy failed: %d\n", ret); -+ } -+ -+ asize = (int)HIKP_ARRAY_SIZE(acc_cmd_copy); -+ for (i = 0; i < asize; i++) { -+ ret = hikp_save_files(&acc_cmd_copy[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("collect_acc_log copy failed: %d\n", ret); -+ } -+} -diff --git a/info_collect/hikp_collect_common.c b/info_collect/hikp_collect_common.c -new file mode 100644 -index 0000000..413aac1 ---- /dev/null -+++ b/info_collect/hikp_collect_common.c -@@ -0,0 +1,258 @@ -+/* -+ * Copyright (c) 2024 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_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+ -+static int software_version_exec(void *data) -+{ -+ const struct info_collect_cmd software_version_cmds[] = { -+ { -+ .args = {"uname", "-a", NULL}, -+ }, -+ { -+ .log_name = "os-release", -+ .args = {"cat", "/etc/*release", NULL}, -+ }, -+ { -+ .log_name = "os-latest", -+ .args = {"cat", "/etc/*latest", NULL}, -+ }, -+ }; -+ HIKP_SET_USED(data); -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(software_version_cmds); -+ for (i = 0; i < size; i++) { -+ if (!strcmp(software_version_cmds[i].args[ARGS_IDX0], "cat")) -+ ret = hikp_collect_cat_glob_exec((void *)&software_version_cmds[i]); -+ else -+ ret = hikp_collect_exec((void *)&software_version_cmds[i]); -+ -+ if (ret) -+ HIKP_ERROR_PRINT("collect software_version_cmds[%zu] log failed: %d\n", -+ i, ret); -+ } -+ -+ return 0; -+} -+ -+static int mem_info_exec(void *data) -+{ -+ const struct info_collect_cmd mem_info_cmds[] = { -+ { -+ .args = {"cat", "/proc/meminfo", NULL}, -+ }, -+ { -+ .args = {"free", "-m", NULL}, -+ }, -+ { -+ .args = {"vmstat", NULL}, -+ }, -+ { -+ .args = {"cat", "/proc/iomem", NULL}, -+ }, -+ }; -+ HIKP_SET_USED(data); -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(mem_info_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_collect_exec((void *)&mem_info_cmds[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("collect mem_info_cmds[%zu] log failed: %d\n", i, ret); -+ } -+ -+ return 0; -+} -+ -+static int process_info_exec(void *data) -+{ -+ const struct info_collect_cmd process_info_cmds[] = { -+ { -+ .args = {"ps", "euf", NULL}, -+ }, -+ { -+ .args = {"ps", "aux", NULL}, -+ }, -+ { -+ .args = {"top", "-bn", "1", NULL}, -+ }, -+ { -+ .args = {"mpstat", NULL}, -+ }, -+ }; -+ HIKP_SET_USED(data); -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(process_info_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_collect_exec((void *)&process_info_cmds[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("collect process_info_cmds[%zu] log failed: %d\n", -+ i, ret); -+ } -+ -+ return 0; -+} -+ -+static int config_info_exec(void *data) -+{ -+ struct info_collect_cmd config_info_cmds[] = { -+ { -+ .args = {"cat", "/proc/cmdline", NULL}, -+ }, -+ { -+ .args = {"getconf", "PAGE_SIZE", NULL}, -+ }, -+ { -+ .group = GROUP_COMMON, -+ .log_name = "config", -+ .args = {"cp", "-f", "/boot/config-*", NULL}, -+ }, -+ { -+ .group = GROUP_COMMON, -+ .log_name = "smmu", -+ .args = {"cp", "-rf", "/sys/class/iommu", NULL}, -+ }, -+ }; -+ HIKP_SET_USED(data); -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(config_info_cmds); -+ for (i = 0; i < size; i++) { -+ char *log_name = config_info_cmds[i].log_name; -+ -+ if (log_name && !strcmp(log_name, "config")) -+ ret = hikp_collect_cp_glob_exec((void *)&config_info_cmds[i]); -+ else if (log_name && !strcmp(log_name, "smmu")) -+ ret = hikp_save_files(&config_info_cmds[i]); -+ else -+ ret = hikp_collect_exec((void *)&config_info_cmds[i]); -+ -+ if (ret) -+ HIKP_ERROR_PRINT("collect process_info_cmds[%zu] log failed: %d\n", -+ i, ret); -+ } -+ -+ return 0; -+} -+ -+static int service_info_exec(void *data) -+{ -+ const struct info_collect_cmd service_info_cmds[] = { -+ { -+ .args = {"service", "iptables", "status", NULL}, -+ }, -+ { -+ .args = {"service", "irqbalance", "status", NULL}, -+ }, -+ }; -+ HIKP_SET_USED(data); -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(service_info_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_collect_exec((void *)&service_info_cmds[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("collect service_info_cmds[%zu] log failed: %d\n", -+ i, ret); -+ } -+ -+ return 0; -+} -+ -+static void collect_software_info(void) -+{ -+ int ret; -+ -+ ret = hikp_collect_log(GROUP_COMMON, "software_version", software_version_exec, (void *)NULL); -+ if (ret) -+ HIKP_ERROR_PRINT("software_version_exec failed: %d\n", ret); -+ -+ ret = hikp_collect_log(GROUP_COMMON, "mem_info", mem_info_exec, (void *)NULL); -+ if (ret) -+ HIKP_ERROR_PRINT("mem_info_exec failed: %d\n", ret); -+ -+ ret = hikp_collect_log(GROUP_COMMON, "process_info", process_info_exec, (void *)NULL); -+ if (ret) -+ HIKP_ERROR_PRINT("process_info_exec failed: %d\n", ret); -+ -+ ret = hikp_collect_log(GROUP_COMMON, "config_info", config_info_exec, (void *)NULL); -+ if (ret) -+ HIKP_ERROR_PRINT("config_info_exec failed: %d\n", ret); -+ -+ ret = hikp_collect_log(GROUP_COMMON, "service_info", service_info_exec, (void *)NULL); -+ if (ret) -+ HIKP_ERROR_PRINT("service_info_exec failed: %d\n", ret); -+} -+ -+static int hardware_info_exec(void *data) -+{ -+ const struct info_collect_cmd hardware_cmds[] = { -+ { -+ .args = {"cat", MIDR_EL1_PATH, NULL}, -+ }, -+ { -+ .args = {"cat", "/sys/bus/cpu/devices/cpu0/cpufreq/scaling_governor", NULL}, -+ }, -+ { -+ .args = {"cat", "/sys/devices/system/cpu/online", NULL}, -+ }, -+ { -+ .args = {"numactl", "-H", NULL}, -+ }, -+ { -+ .args = {"numastat", NULL}, -+ }, -+ { -+ .args = {"lscpu", NULL}, -+ }, -+ { -+ .args = {"dmidecode", NULL}, -+ }, -+ }; -+ HIKP_SET_USED(data); -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(hardware_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_collect_exec((void *)&hardware_cmds[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("collect hardware_cmds[%zu] log failed: %d\n", i, ret); -+ } -+ -+ return 0; -+} -+ -+static void collect_hardware_info(void) -+{ -+ int ret; -+ -+ ret = hikp_collect_log(GROUP_COMMON, "hardware_info", hardware_info_exec, (void *)NULL); -+ if (ret) -+ HIKP_ERROR_PRINT("hardware_info_exec failed: %d\n", ret); -+} -+ -+void collect_common_log(void) -+{ -+ collect_software_info(); -+ collect_hardware_info(); -+} -diff --git a/info_collect/hikp_collect_imp.c b/info_collect/hikp_collect_imp.c -new file mode 100644 -index 0000000..296cf07 ---- /dev/null -+++ b/info_collect/hikp_collect_imp.c -@@ -0,0 +1,133 @@ -+/* -+ * Copyright (c) 2024 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_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+#include "hikp_nic_log.h" -+#include "hikp_nic_mac_dump.h" -+#include "hikp_nic_port.h" -+#include "hikp_nic_xsfp.h" -+#include "hikp_nic_ncsi.h" -+ -+static int hikp_collect_nic_log_info(void *dev_name) -+{ -+ struct info_collect_cmd nic_log_cmd = { -+ .group = GROUP_IMP, -+ .log_name = NULL, -+ .args = {"mv", NULL, NULL}, -+ }; -+ struct nic_log_collect_param param = {0}; -+ char log_name[MAX_LOG_NAME_LEN] = {0}; -+ int ret; -+ -+ param.net_dev_name = (const char *)dev_name; -+ ret = snprintf(log_name, MAX_LOG_NAME_LEN, "%s_nic_log", (char *)dev_name); -+ if (ret < 0 || (uint32_t)ret >= MAX_LOG_NAME_LEN) -+ return -EINVAL; -+ -+ ret = hikp_collect_log(GROUP_IMP, log_name, hikp_info_collect_nic_log, (void *)¶m); -+ if (ret) { -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", log_name, ret); -+ return ret; -+ } -+ -+ nic_log_cmd.args[ARGS_IDX1] = (char *)hikp_info_collect_get_log_path(); -+ ret = hikp_move_files(&nic_log_cmd); -+ if (ret) -+ HIKP_ERROR_PRINT("collect imp log failed, %d\n", ret); -+ -+ return ret; -+} -+ -+static int hikp_collect_nic_port_info(void *dev_name) -+{ -+ struct nic_port_collect_param param = {0}; -+ char log_name[MAX_LOG_NAME_LEN] = {0}; -+ int ret; -+ -+ param.net_dev_name = (const char *)dev_name; -+ ret = snprintf(log_name, MAX_LOG_NAME_LEN, "%s_nic_port", (char *)dev_name); -+ if (ret < 0 || (uint32_t)ret >= MAX_LOG_NAME_LEN) -+ return -EINVAL; -+ -+ ret = hikp_collect_log(GROUP_IMP, log_name, hikp_info_collect_nic_port, (void *)¶m); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", log_name, ret); -+ -+ return ret; -+} -+ -+static int hikp_collect_nic_xsfp_info(void *dev_name) -+{ -+ struct nic_xsfp_collect_param param = {0}; -+ char log_name[MAX_LOG_NAME_LEN] = {0}; -+ int ret; -+ -+ param.net_dev_name = (const char *)dev_name; -+ ret = snprintf(log_name, MAX_LOG_NAME_LEN, "%s_nic_xsfp", (char *)dev_name); -+ if (ret < 0 || (uint32_t)ret >= MAX_LOG_NAME_LEN) -+ return -EINVAL; -+ -+ ret = hikp_collect_log(GROUP_IMP, log_name, hikp_info_collect_nic_xsfp, (void *)¶m); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", log_name, ret); -+ -+ return ret; -+} -+ -+static int hikp_collect_nic_mac_info(void *dev_name) -+{ -+ struct nic_mac_collect_param param = {0}; -+ char log_name[MAX_LOG_NAME_LEN] = {0}; -+ int ret; -+ -+ param.net_dev_name = (const char *)dev_name; -+ param.module_name = "ALL"; -+ ret = snprintf(log_name, MAX_LOG_NAME_LEN, "%s_nic_mac", (char *)dev_name); -+ if (ret < 0 || (uint32_t)ret >= MAX_LOG_NAME_LEN) -+ return -EINVAL; -+ -+ ret = hikp_collect_log(GROUP_IMP, log_name, hikp_info_collect_nic_mac, (void *)¶m); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", log_name, ret); -+ -+ return ret; -+} -+ -+static int hikp_collect_nic_ncsi_info(void *dev_name) -+{ -+ struct nic_ncsi_collect_param param = {0}; -+ char log_name[MAX_LOG_NAME_LEN] = {0}; -+ int ret; -+ -+ param.net_dev_name = (const char *)dev_name; -+ ret = snprintf(log_name, MAX_LOG_NAME_LEN, "%s_nic_ncsi", (char *)dev_name); -+ if (ret < 0 || (uint32_t)ret >= MAX_LOG_NAME_LEN) -+ return -EINVAL; -+ -+ ret = hikp_collect_log(GROUP_IMP, log_name, hikp_info_collect_nic_ncsi, (void *)¶m); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", log_name, ret); -+ -+ return ret; -+} -+ -+void collect_imp_log(void) -+{ -+ hikp_collect_all_nic_cmd_log(hikp_collect_nic_log_info); -+ hikp_collect_all_nic_cmd_log(hikp_collect_nic_port_info); -+ hikp_collect_all_nic_cmd_log(hikp_collect_nic_xsfp_info); -+ hikp_collect_all_nic_cmd_log(hikp_collect_nic_mac_info); -+ hikp_collect_all_nic_cmd_log(hikp_collect_nic_ncsi_info); -+} -diff --git a/info_collect/hikp_collect_lib.c b/info_collect/hikp_collect_lib.c -new file mode 100644 -index 0000000..bada846 ---- /dev/null -+++ b/info_collect/hikp_collect_lib.c -@@ -0,0 +1,508 @@ -+/* -+ * Copyright (c) 2024 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_collect_lib.h" -+#include -+#include -+#include -+#include -+#include -+#include -+#include "tool_lib.h" -+ -+static char log_save_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+static char g_collect_name[MAX_LOG_NAME_LEN] = {0}; -+ -+static bool hikp_nic_drv_check(char *nic_name) -+{ -+ char drv_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ struct dirent *ptr = NULL; -+ bool hns3_if = false; -+ DIR *dir = NULL; -+ int ret; -+ -+ ret = snprintf(drv_path, LOG_FILE_PATH_MAX_LEN, "%s%s/%s", HIKP_NIC_NAME_DIR, -+ nic_name, HIKP_NIC_DRV_DIR); -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) -+ return false; -+ -+ if ((dir = opendir(drv_path)) == NULL) -+ return false; -+ -+ while ((ptr = readdir(dir)) != NULL) { -+ if (strcmp(ptr->d_name, HIKP_NIC_DRV_NAME) == 0) { -+ hns3_if = true; -+ break; -+ } -+ } -+ -+ closedir(dir); -+ return hns3_if; -+} -+ -+void hikp_collect_all_nic_cmd_log(collect_cmd_handler_t hikp_collect_one_nic_log) -+{ -+ struct dirent *ptr = NULL; -+ DIR *dir = NULL; -+ int ret; -+ -+ if (!hikp_collect_one_nic_log) { -+ HIKP_ERROR_PRINT("Invalid parameters!\n"); -+ return; -+ } -+ -+ dir = opendir(HIKP_NIC_NAME_DIR); -+ if (!dir) { -+ HIKP_ERROR_PRINT("failed to open path!\n"); -+ return; -+ } -+ -+ while ((ptr = readdir(dir)) != NULL) { -+ if ((strcmp(ptr->d_name, ".") == 0) || (strcmp(ptr->d_name, "..") == 0)) { -+ continue; -+ } else if (ptr->d_type == DT_LNK) { -+ if (hikp_nic_drv_check(ptr->d_name)) { -+ ret = hikp_collect_one_nic_log((void *)ptr->d_name); -+ if (ret) { -+ HIKP_WARN_PRINT("failed to collect log for: %s", ptr->d_name); -+ break; -+ } -+ } -+ } -+ } -+ -+ closedir(dir); -+} -+ -+static bool is_cmd_valid(struct info_collect_cmd *cmd, unsigned int args_num) -+{ -+ unsigned int i; -+ -+ if (cmd == NULL || cmd->log_name == NULL || args_num == 0 || args_num >= ARGS_MAX_NUM) -+ return false; -+ -+ for (i = 0; i < args_num; i++) -+ if (cmd->args[i] == NULL) -+ return false; -+ -+ return true; -+} -+ -+int hikp_create_save_path(const char *name) -+{ -+ char collect_name[MAX_LOG_NAME_LEN] = {0}; -+ time_t time_seconds = time(0); -+ struct tm timeinfo; -+ int ret; -+ -+ localtime_r(&time_seconds, &timeinfo); -+ if (name != NULL) -+ (void)snprintf((char *)collect_name, MAX_LOG_NAME_LEN, -+ "collect_%s_%04d%02d%02d%02d%02d%02d", -+ name, timeinfo.tm_year + START_YEAR, -+ timeinfo.tm_mon + 1, timeinfo.tm_mday, -+ timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); -+ else -+ (void)snprintf((char *)collect_name, MAX_LOG_NAME_LEN, -+ "collect_%04d%02d%02d%02d%02d%02d", -+ timeinfo.tm_year + START_YEAR, timeinfo.tm_mon + 1, -+ timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, -+ timeinfo.tm_sec); -+ -+ ret = snprintf((char *)log_save_path, LOG_FILE_PATH_MAX_LEN, -+ HIKP_COLLECT_LOG_DIR_PATH"%s", collect_name); -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) -+ return -EINVAL; -+ -+ if (!is_dir_exist((const char*)log_save_path)) { -+ if (tool_mk_dir((const char*)log_save_path)) { -+ HIKP_ERROR_PRINT("mkdir %s failed, errno is %d\n", -+ log_save_path, errno); -+ memset(log_save_path, 0, LOG_FILE_PATH_MAX_LEN); -+ return -ENOENT; -+ } -+ } -+ -+ ret = snprintf((char *)g_collect_name, MAX_LOG_NAME_LEN, "%s", collect_name); -+ if (ret < 0 || (uint32_t)(ret) >= MAX_LOG_NAME_LEN) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+static int hikp_get_save_path(char *file_path, unsigned int file_path_len) -+{ -+ int ret; -+ -+ if (access(log_save_path, F_OK) != 0) -+ return -ENOENT; -+ -+ ret = snprintf((char *)file_path, file_path_len, "%s", log_save_path); -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+int hikp_get_file_path(char *file_path, uint32_t file_path_len, -+ char *group) -+{ -+ char tmp_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ int ret; -+ -+ ret = hikp_get_save_path(tmp_path, LOG_FILE_PATH_MAX_LEN); -+ if (ret < 0) { -+ HIKP_ERROR_PRINT("get file save path failed: %d\n", ret); -+ return ret; -+ } -+ -+ if (group != NULL) -+ ret = snprintf(file_path, file_path_len, "%s/%s", -+ tmp_path, group); -+ else -+ ret = snprintf(file_path, file_path_len, "%s", -+ tmp_path); -+ -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) { -+ HIKP_ERROR_PRINT("create file path fail: %d\n", ret); -+ return -EINVAL; -+ } -+ -+ if (!is_dir_exist((const char*)file_path)) { -+ if (tool_mk_dir((const char*)file_path)) { -+ HIKP_ERROR_PRINT("mkdir %s failed: %d\n", -+ file_path, errno); -+ return -ENOENT; -+ } -+ } -+ -+ return 0; -+} -+ -+static int hikp_collect_cmd_exec(const struct info_collect_cmd *cmd) -+{ -+ pid_t pid; -+ int status; -+ -+ pid = fork(); -+ if (pid == 0) { -+ /* -+ * When the command execution fails, exit the child -+ * process just like when it succeeds. -+ * */ -+ if (execvp(cmd->args[ARGS_IDX0], cmd->args) < 0) { -+ HIKP_ERROR_PRINT("execvp failed: %d\n", errno); -+ exit(EXIT_FAILURE); -+ } -+ } else if (pid > 0) { -+ /* Parent process */ -+ waitpid(pid, &status, 0); -+ } else { -+ HIKP_ERROR_PRINT("fork failed!\n"); -+ return -ECHILD; -+ } -+ -+ return 0; -+} -+ -+int hikp_collect_exec(void *data) -+{ -+ struct info_collect_cmd *cmd = (struct info_collect_cmd *)data; -+ struct info_collect_cmd echo_cmd = {0}; -+ char result[MAX_LOG_NAME_LEN] = {0}; -+ int len = 0; -+ int ret; -+ int i; -+ -+ echo_cmd.args[ARGS_IDX0] = "echo"; -+ echo_cmd.args[ARGS_IDX1] = result; -+ echo_cmd.args[ARGS_IDX2] = NULL; -+ for (i = 0; i < ARGS_MAX_NUM && cmd->args[i] != NULL; i++) { -+ ret = snprintf(result + len, -+ MAX_LOG_NAME_LEN - len - 1, -+ "%s ", cmd->args[i]); -+ len += ret; -+ if (ret < 0 || len >= (MAX_LOG_NAME_LEN - 1)) { -+ HIKP_INFO_PRINT("Error getting command args"); -+ break; -+ } -+ } -+ -+ ret = hikp_collect_cmd_exec(&echo_cmd); -+ if (ret) -+ return ret; -+ -+ return hikp_collect_cmd_exec(cmd); -+} -+ -+int hikp_collect_log(char *group, char *log_name, collect_cmd_handler_t func, void *data) -+{ -+ unsigned char file_name[MAX_LOG_NAME_LEN] = {0}; -+ char file_dir[LOG_FILE_PATH_MAX_LEN] = {0}; -+ char file_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ int stdout_fd = dup(STDOUT_FILENO); -+ int stderr_fd = dup(STDERR_FILENO); -+ FILE *log_file; -+ int ret; -+ -+ if (log_name == NULL) { -+ HIKP_ERROR_PRINT("log name is NULL"); -+ return -EINVAL; -+ } -+ -+ ret = generate_file_name(file_name, MAX_LOG_NAME_LEN, -+ (const unsigned char*)log_name); -+ if (ret < 0) -+ return ret; -+ -+ ret = hikp_get_file_path(file_dir, LOG_FILE_PATH_MAX_LEN, group); -+ if (ret < 0) -+ return ret; -+ -+ ret = snprintf(file_path, LOG_FILE_PATH_MAX_LEN, "%s/%s", file_dir, file_name); -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) { -+ HIKP_ERROR_PRINT("create log file path fail: %d\n", ret); -+ return -EINVAL; -+ } -+ -+ log_file = fopen(file_path, "a"); -+ if (log_file == NULL) { -+ HIKP_ERROR_PRINT("open %s failed.", file_path); -+ return -ENOENT; -+ } -+ -+ (void)chmod(file_path, S_IRUSR | S_IWUSR | S_IRGRP); -+ -+ fflush(stdout); -+ fflush(stderr); -+ -+ /* Copy the standard output and error information to log_file */ -+ dup2(fileno(log_file), STDOUT_FILENO); -+ dup2(fileno(log_file), STDERR_FILENO); -+ -+ ret = func(data); -+ -+ fflush(stdout); -+ fflush(stderr); -+ -+ /* Redirect stdout and stderr back to the terminal */ -+ dup2(stdout_fd, STDOUT_FILENO); -+ dup2(stderr_fd, STDERR_FILENO); -+ -+ fclose(log_file); -+ close(stdout_fd); -+ close(stderr_fd); -+ -+ return ret; -+} -+ -+int hikp_compress_log(void) -+{ -+ char file_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ char tar_name[LOG_FILE_PATH_MAX_LEN] = {0}; -+ struct info_collect_cmd tar_cmd = {0}; -+ struct info_collect_cmd rm_cmd = {0}; -+ int ret; -+ -+ ret = hikp_get_save_path(file_path, LOG_FILE_PATH_MAX_LEN); -+ if (ret < 0) { -+ HIKP_ERROR_PRINT("get save path fail: %d\n", ret); -+ return ret; -+ } -+ -+ ret = snprintf((char *)tar_name, LOG_FILE_PATH_MAX_LEN, "%s.tar.gz", -+ file_path); -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) { -+ HIKP_ERROR_PRINT("create tar path fail: %d\n", ret); -+ return -EINVAL; -+ } -+ -+ tar_cmd.args[ARGS_IDX0] = "tar"; -+ tar_cmd.args[ARGS_IDX1] = "-zPcf"; -+ tar_cmd.args[ARGS_IDX2] = tar_name; -+ tar_cmd.args[ARGS_IDX3] = "-C"; -+ tar_cmd.args[ARGS_IDX4] = HIKP_COLLECT_LOG_DIR_PATH; -+ tar_cmd.args[ARGS_IDX5] = g_collect_name; -+ tar_cmd.args[ARGS_IDX6] = NULL; -+ -+ ret = hikp_collect_exec(&tar_cmd); -+ if (ret) -+ return ret; -+ -+ /* Delete the original log after the log is packaged. */ -+ rm_cmd.args[ARGS_IDX0] = "rm"; -+ rm_cmd.args[ARGS_IDX1] = "-rf"; -+ rm_cmd.args[ARGS_IDX2] = file_path; -+ rm_cmd.args[ARGS_IDX3] = NULL; -+ -+ return hikp_collect_exec(&rm_cmd); -+} -+ -+int hikp_move_files(struct info_collect_cmd *mv_cmd) -+{ -+ char dest_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ char tmp_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ char *src_path = mv_cmd->args[ARGS_IDX1]; -+ char *sub_group = mv_cmd->log_name; -+ int ret; -+ -+ if (strcmp(mv_cmd->args[ARGS_IDX0], "mv") != 0) { -+ HIKP_ERROR_PRINT("input cmd failed: %s.\n", mv_cmd->args[ARGS_IDX0]); -+ return -EINVAL; -+ } -+ -+ if (src_path == NULL || access(src_path, F_OK) != 0) { -+ HIKP_ERROR_PRINT("Can't access source path: %s\n", src_path); -+ return -ENOENT; -+ } -+ -+ ret = hikp_get_file_path(tmp_path, LOG_FILE_PATH_MAX_LEN, mv_cmd->group); -+ if (ret < 0) { -+ HIKP_ERROR_PRINT("get destination path fail: %d\n", ret); -+ return ret; -+ } -+ -+ if (sub_group == NULL) -+ ret = snprintf(dest_path, LOG_FILE_PATH_MAX_LEN, "%s", tmp_path); -+ else -+ ret = snprintf(dest_path, LOG_FILE_PATH_MAX_LEN, "%s/%s", -+ tmp_path, sub_group); -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) { -+ HIKP_ERROR_PRINT("create destination path failed: %d\n", ret); -+ return -EINVAL; -+ } -+ -+ mv_cmd->args[ARGS_IDX2] = dest_path; -+ mv_cmd->args[ARGS_IDX3] = NULL; -+ -+ return hikp_collect_exec((void *)mv_cmd); -+} -+ -+int hikp_save_files(struct info_collect_cmd *save_cmd) -+{ -+ char save_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ char tmp_path[LOG_FILE_PATH_MAX_LEN] = {0}; -+ char *source_path = save_cmd->args[ARGS_IDX2]; -+ char *sub_group = save_cmd->log_name; -+ int ret; -+ -+ if (strcmp(save_cmd->args[ARGS_IDX0], "cp") != 0) { -+ HIKP_ERROR_PRINT("input cmd failed: %s.\n", save_cmd->args[ARGS_IDX0]); -+ return -EINVAL; -+ } -+ -+ if (source_path == NULL || access(source_path, F_OK) != 0) { -+ HIKP_ERROR_PRINT("Can't access source path: %s\n", source_path); -+ return -ENOENT; -+ } -+ -+ ret = hikp_get_file_path(tmp_path, LOG_FILE_PATH_MAX_LEN, save_cmd->group); -+ if (ret < 0) { -+ HIKP_ERROR_PRINT("get save path fail: %d\n", ret); -+ return ret; -+ } -+ -+ if (sub_group == NULL) -+ ret = snprintf(save_path, LOG_FILE_PATH_MAX_LEN, "%s", tmp_path); -+ else -+ ret = snprintf(save_path, LOG_FILE_PATH_MAX_LEN, "%s/%s", -+ tmp_path, sub_group); -+ if (ret < 0 || (uint32_t)(ret) >= LOG_FILE_PATH_MAX_LEN) { -+ HIKP_ERROR_PRINT("create save path failed: %d\n", ret); -+ return -EINVAL; -+ } -+ -+ save_cmd->args[ARGS_IDX3] = save_path; -+ save_cmd->args[ARGS_IDX4] = NULL; -+ -+ return hikp_collect_exec((void *)save_cmd); -+} -+ -+int hikp_collect_cat_glob_exec(void *data) -+{ -+ struct info_collect_cmd *cmd = (struct info_collect_cmd *)data; -+ glob_t glb_buff; -+ size_t i; -+ int ret; -+ -+ if (!is_cmd_valid(cmd, ARGS_IDX2)) -+ return -EINVAL; -+ -+ if (strcmp(cmd->args[ARGS_IDX0], "cat")) -+ return -EINVAL; -+ -+ ret = glob(cmd->args[ARGS_IDX1], GLOB_TILDE, NULL, &glb_buff); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to generate cat paths: %s\n", cmd->args[ARGS_IDX1]); -+ return ret; -+ } -+ -+ for (i = 0; i < glb_buff.gl_pathc; i++) { -+ cmd->args[ARGS_IDX1] = glb_buff.gl_pathv[i]; -+ ret = hikp_collect_exec((void *)cmd); -+ if(ret) -+ HIKP_INFO_PRINT("cat %s failed\n", glb_buff.gl_pathv[i]); -+ } -+ -+ globfree(&glb_buff); -+ -+ return 0; -+} -+ -+int hikp_collect_cp_glob_exec(void *data) -+{ -+ struct info_collect_cmd *cmd = (struct info_collect_cmd *)data; -+ char log_name[MAX_LOG_NAME_LEN] = {0}; -+ char tmp[MAX_LOG_NAME_LEN] = {0}; -+ glob_t glb_buff; -+ size_t i; -+ int ret; -+ -+ if (!is_cmd_valid(cmd, ARGS_IDX3)) -+ return -EINVAL; -+ -+ if (strcmp(cmd->args[ARGS_IDX0], "cp")) -+ return -EINVAL; -+ -+ ret = glob(cmd->args[ARGS_IDX2], GLOB_TILDE, NULL, &glb_buff); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to generate cp paths: %s\n", cmd->args[ARGS_IDX2]); -+ return ret; -+ } -+ -+ ret = snprintf(tmp, MAX_LOG_NAME_LEN, "%s", cmd->log_name); -+ if (ret < 0 || (uint32_t)(ret) >= MAX_LOG_NAME_LEN) { -+ HIKP_ERROR_PRINT("log name is invalid\n"); -+ globfree(&glb_buff); -+ return -EINVAL; -+ } -+ -+ for (i = 0; i < glb_buff.gl_pathc; i++) { -+ ret = snprintf(log_name, MAX_LOG_NAME_LEN, "%s_%zu", tmp, i); -+ if (ret < 0 || (uint32_t)(ret) >= MAX_LOG_NAME_LEN) { -+ HIKP_ERROR_PRINT("create log name failed\n"); -+ globfree(&glb_buff); -+ return -EINVAL; -+ } -+ -+ cmd->log_name = log_name; -+ cmd->args[ARGS_IDX2] = glb_buff.gl_pathv[i]; -+ ret = hikp_save_files(cmd); -+ if(ret) -+ HIKP_INFO_PRINT("cp %s failed\n", glb_buff.gl_pathv[i]); -+ } -+ -+ globfree(&glb_buff); -+ -+ return 0; -+} -diff --git a/info_collect/hikp_collect_lib.h b/info_collect/hikp_collect_lib.h -new file mode 100644 -index 0000000..2c59bf0 ---- /dev/null -+++ b/info_collect/hikp_collect_lib.h -@@ -0,0 +1,61 @@ -+/* -+ * Copyright (c) 2024 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_COLLECT_LIB_H -+#define HIKP_COLLECT_LIB_H -+ -+#ifndef NULL -+#define NULL ((void *)0) -+#endif -+ -+#define ARGS_IDX0 0 -+#define ARGS_IDX1 1 -+#define ARGS_IDX2 2 -+#define ARGS_IDX3 3 -+#define ARGS_IDX4 4 -+#define ARGS_IDX5 5 -+#define ARGS_IDX6 6 -+#define ARGS_IDX7 7 -+#define ARGS_IDX8 8 -+#define ARGS_IDX9 9 -+#define ARGS_IDX10 10 -+#define ARGS_IDX11 11 -+#define ARGS_MAX_NUM 12 -+#define LOG_FILE_PATH_MAX_LEN 512 -+#define HIKP_COLLECT_LOG_DIR_PATH "/var/log/hikp/" -+#define HIKP_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) -+#define HIKP_NIC_NAME_DIR "/sys/class/net/" -+#define HIKP_NIC_DRV_DIR "device/driver/module/drivers/" -+#define HIKP_NIC_DRV_NAME "pci:hns3" -+ -+typedef int (*collect_cmd_handler_t)(void *); -+ -+struct info_collect_cmd { -+ char *group; -+ char *log_name; -+ char *args[ARGS_MAX_NUM]; -+}; -+ -+int hikp_compress_log(void); -+int hikp_create_save_path(const char *name); -+int hikp_get_file_path(char *file_path, unsigned int file_path_len, -+ char *group); -+int hikp_collect_exec(void *data); -+int hikp_collect_log(char *group, char *log_name, -+ collect_cmd_handler_t func, void *data); -+int hikp_move_files(struct info_collect_cmd *mv_cmd); -+int hikp_save_files(struct info_collect_cmd *save_cmd); -+int hikp_collect_cat_glob_exec(void *data); -+int hikp_collect_cp_glob_exec(void *data); -+void hikp_collect_all_nic_cmd_log(collect_cmd_handler_t hikp_collect_one_nic_log); -+#endif /* HIKP_COLLECT_LIB_H */ -diff --git a/info_collect/hikp_collect_main.c b/info_collect/hikp_collect_main.c -new file mode 100644 -index 0000000..c413346 ---- /dev/null -+++ b/info_collect/hikp_collect_main.c -@@ -0,0 +1,274 @@ -+/* -+ * Copyright (c) 2024 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_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+#include "tool_cmd.h" -+ -+static enum info_collect_type g_info_collect_type = COLLECT_UNKNOWN_TYPE; -+static enum info_collect_type get_info_collect_type(void) -+{ -+ return g_info_collect_type; -+} -+ -+static void set_info_collect_type(enum info_collect_type type) -+{ -+ g_info_collect_type = type; -+} -+ -+static int info_collect_acc(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_ACC); -+ return 0; -+} -+ -+static int info_collect_imp(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_IMP); -+ return 0; -+} -+ -+static int info_collect_nic(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_NIC); -+ return 0; -+} -+ -+static int info_collect_pcie(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_PCIE); -+ return 0; -+} -+ -+static int info_collect_roce(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_ROCE); -+ return 0; -+} -+ -+static int info_collect_sas(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_SAS); -+ return 0; -+} -+ -+static int info_collect_sata(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_SATA); -+ return 0; -+} -+ -+static int info_collect_serdes(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_SERDES); -+ return 0; -+} -+ -+static int info_collect_socip(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_SOCIP); -+ return 0; -+} -+ -+static int info_collect_all(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_ALL); -+ return 0; -+} -+ -+static void collect_all_log(void) -+{ -+ collect_pcie_info(); -+ collect_acc_log(); -+ collect_imp_log(); -+ collect_nic_log(); -+ collect_roce_log(); -+ collect_sas_log(); -+ collect_sata_log(); -+ collect_serdes_log(); -+ collect_socip_log(); -+} -+ -+static int info_collect_excute_funs_call(uint32_t collect_type) -+{ -+ const char *type_name[] = {"acc", "imp", "nic", "pcie", "roce", "sas", -+ "sata", "serdes", "socip", "all"}; -+ int ret; -+ -+ if (collect_type == COLLECT_UNKNOWN_TYPE) -+ return -EINVAL; -+ -+ ret = hikp_create_save_path(type_name[collect_type]); -+ if (ret) { -+ HIKP_ERROR_PRINT("create save path fail: %d\n", ret); -+ return ret; -+ } -+ -+ switch (collect_type) { -+ case COLLECT_ACC: -+ collect_acc_log(); -+ break; -+ case COLLECT_IMP: -+ collect_imp_log(); -+ break; -+ case COLLECT_NIC: -+ collect_nic_log(); -+ break; -+ case COLLECT_PCIE: -+ collect_pcie_info(); -+ break; -+ case COLLECT_ROCE: -+ collect_roce_log(); -+ break; -+ case COLLECT_SAS: -+ collect_sas_log(); -+ break; -+ case COLLECT_SATA: -+ collect_sata_log(); -+ break; -+ case COLLECT_SERDES: -+ collect_serdes_log(); -+ break; -+ case COLLECT_SOCIP: -+ collect_socip_log(); -+ break; -+ case COLLECT_ALL: -+ collect_all_log(); -+ break; -+ default: -+ return -EINVAL; -+ } -+ -+ collect_common_log(); -+ ret = hikp_compress_log(); -+ -+ return ret; -+} -+ -+ -+static void info_collect_execute(struct major_cmd_ctrl *self) -+{ -+ const char *suc_msg[] = { -+ "collect acc info success.", -+ "collect imp info success.", -+ "collect nic info success.", -+ "collect pcie info success.", -+ "collect roce info success.", -+ "collect sas info success.", -+ "collect sata info success.", -+ "collect serdes info success.", -+ "collect socip info success.", -+ "collect all info success.", -+ }; -+ const char *err_msg[] = { -+ "collect acc info error.", -+ "collect imp info error.", -+ "collect nic info error.", -+ "collect pcie info error.", -+ "collect roce info error.", -+ "collect sas info error.", -+ "collect sata info error.", -+ "collect serdes info error.", -+ "collect socip info error.", -+ "collect all info error.", -+ "collect info failed, unknown type.", -+ }; -+ enum info_collect_type type; -+ int ret; -+ -+ type = get_info_collect_type(); -+ ret = info_collect_excute_funs_call(type); -+ set_info_collect_type(COLLECT_UNKNOWN_TYPE); -+ if (ret == 0) { -+ printf("%s\n", suc_msg[type]); -+ } else { -+ (void)snprintf(self->err_str, sizeof(self->err_str), "%s\n", err_msg[type]); -+ self->err_no = ret; -+ } -+} -+ -+static int info_collect_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(argv); -+ -+ printf("\n Usage: %s\n", self->cmd_ptr->name); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); -+ printf(" %s, %-25s %s\n", "-acc", "--acc", "collect acc info\n"); -+ printf(" %s, %-25s %s\n", "-imp", "--imp", "collect imp info\n"); -+ printf(" %s, %-25s %s\n", "-nic", "--nic", "collect nic info\n"); -+ printf(" %s, %-25s %s\n", "-pcie", "--pcie", "collect pcie info\n"); -+ printf(" %s, %-25s %s\n", "-roce", "--roce", "collect roce info\n"); -+ printf(" %s, %-25s %s\n", "-sas", "--sas", "collect sas info\n"); -+ printf(" %s, %-25s %s\n", "-sata", "--sata", "collect sata info\n"); -+ printf(" %s, %-25s %s\n", "-serdes", "--serdes", "collect serdes info\n"); -+ printf(" %s, %-25s %s\n", "-socip", "--socip", "collect socip info\n"); -+ printf(" %s, %-25s %s\n", "-all", "--all", "collect all info\n"); -+ printf("\n"); -+ -+ return 0; -+} -+ -+static void cmd_info_collect_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = info_collect_execute; -+ -+ cmd_option_register("-h", "--help", false, info_collect_help); -+ cmd_option_register("-acc", "--acc", false, info_collect_acc); -+ cmd_option_register("-imp", "--imp", false, info_collect_imp); -+ cmd_option_register("-nic", "--nic", false, info_collect_nic); -+ cmd_option_register("-pcie", "--pcie", false, info_collect_pcie); -+ cmd_option_register("-roce", "--roce", false, info_collect_roce); -+ cmd_option_register("-sas", "--sas", false, info_collect_sas); -+ cmd_option_register("-sata", "--sata", false, info_collect_sata); -+ cmd_option_register("-serdes", "--serdes", false, info_collect_serdes); -+ cmd_option_register("-socip", "--socip", false, info_collect_socip); -+ cmd_option_register("-all", "--all", false, info_collect_all); -+} -+ -+HIKP_CMD_DECLARE("info_collect", "information collect", cmd_info_collect_init); -diff --git a/info_collect/hikp_collect_nic.c b/info_collect/hikp_collect_nic.c -new file mode 100644 -index 0000000..23c4e49 ---- /dev/null -+++ b/info_collect/hikp_collect_nic.c -@@ -0,0 +1,368 @@ -+/* -+ * Copyright (c) 2024 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_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+#include "hikp_nic_fd.h" -+#include "hikp_nic_gro.h" -+#include "hikp_nic_ppp.h" -+#include "hikp_nic_qos.h" -+#include "hikp_nic_queue.h" -+#include "hikp_nic_rss.h" -+#include "hikp_nic_torus.h" -+#include "hikp_nic_fec.h" -+#include "hikp_nic_dfx.h" -+#include "hikp_nic_info.h" -+#include "hikp_nic_notify_pkt.h" -+#include "hikp_nic_port_fault.h" -+#include "hikp_nic_mac_dump.h" -+ -+static void collect_nic_debugfs_log(void) -+{ -+ struct info_collect_cmd nic_cmd_copy = { -+ .group = GROUP_NIC, -+ .log_name = "debugfs", -+ .args = {"cp", "-rf", "/sys/kernel/debug/hns3/", NULL}, -+ }; -+ int ret; -+ -+ ret = hikp_save_files(&nic_cmd_copy); -+ if (ret) -+ HIKP_ERROR_PRINT("collect_nic_log debugfs failed, %d\n", ret); -+} -+ -+static int collect_hikp_nic_fd_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int ret; -+ -+ /* collect nic_fd hw_info */ -+ printf("hikptool nic_fd -i %s -du hw_info\n", (char *)nic_name); -+ hikp_nic_set_fd_idx(NIC_FD_HW_INFO_DUMP, -1); -+ self.cmd_ptr = &type; -+ ret = hikp_nic_cmd_get_fd_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ hikp_nic_fd_cmd_execute(&self); -+ -+ /* collect nic_fd rules and counters */ -+ printf("hikptool nic_fd -i %s -du rules -st 1\n", (char *)nic_name); -+ hikp_nic_set_fd_idx(NIC_FD_RULES_INFO_DUMP, 1); -+ hikp_nic_fd_cmd_execute(&self); -+ printf("hikptool nic_fd -i %s -du counter -st 1\n", (char *)nic_name); -+ hikp_nic_set_fd_idx(NIC_FD_COUNTER_STATS_DUMP, 1); -+ hikp_nic_fd_cmd_execute(&self); -+ -+ return 0; -+} -+ -+static int collect_hikp_nic_gro_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int ret; -+ -+ printf("hikptool nic_gro -i %s\n", (char *)nic_name); -+ self.cmd_ptr = &type; -+ ret = hikp_nic_gro_get_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ -+ hikp_nic_gro_cmd_execute(&self); -+ return 0; -+} -+ -+static int collect_hikp_nic_ppp_log(void *nic_name) -+{ -+ const char *sub_cmd_name[] = {"mac", "vlan", "mng", "promisc", "vlan_offload"}; -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int i, ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_nic_cmd_get_ppp_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ -+ for (i = NIC_MAC_TBL_DUMP; i <= NIC_VLAN_OFFLOAD_DUMP; ++i) { -+ printf("hikptool nic_ppp -i %s -du %s\n", (char *)nic_name, -+ sub_cmd_name[i - NIC_MAC_TBL_DUMP]); -+ hikp_nic_ppp_set_cmd_param(i-1); -+ hikp_nic_ppp_cmd_execute(&self); -+ } -+ -+ return 0; -+} -+ -+static int collect_hikp_nic_qos_log(void *nic_name) -+{ -+ const char *sub_cmd_name[] = {"pkt_buf", "dcb", "pause"}; -+ const char *dir_name[] = {"rx", "tx"}; -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int i, ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_nic_cmd_get_qos_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ -+ for (i = NIC_PACKET_BUFFER_DUMP; i <= NIC_PAUSE_DUMP; ++i) { -+ printf("hikptool nic_qos -i %s -g %s\n", (char *)nic_name, sub_cmd_name[i]); -+ hikp_nic_qos_set_cmd_feature_idx(i); -+ hikp_nic_qos_cmd_execute(&self); -+ } -+ -+ hikp_nic_qos_set_cmd_feature_idx(NIC_PFC_STORM_PARA_DUMP); -+ for (i = NIC_RX_QOS; i <= NIC_TX_QOS; ++i) { -+ printf("hikptool nic_qos -i %s -g pfc_storm_para -d %s\n", (char *)nic_name, -+ dir_name[i]); -+ hikp_nic_qos_set_cmd_direction(i); -+ hikp_nic_qos_cmd_execute(&self); -+ } -+ -+ return 0; -+} -+ -+static int collect_hikp_nic_queue_log(void *nic_name) -+{ -+ const char *dir_name[] = {"tx", "rx"}; -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int j, ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_nic_cmd_get_queue_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool nic_queue -i %s -du queue_en -a on\n", (char *)nic_name); -+ hikp_nic_queue_cmd_set_param(QUEUE_EN_INFO, -1, NIC_QUEUE_DIR_UNKNOWN); -+ hikp_nic_queue_cmd_execute(&self); -+ printf("hikptool nic_queue -i %s -du func_map\n", (char *)nic_name); -+ hikp_nic_queue_cmd_set_param(QUEUE_FUNC_MAP, -1, NIC_QUEUE_DIR_UNKNOWN); -+ hikp_nic_queue_cmd_execute(&self); -+ -+ for (j = NIC_TX_QUEUE; j <= NIC_RX_QUEUE; ++j) { -+ printf("hikptool nic_queue -i %s -du basic_info -d %s -q 0\n", (char *)nic_name, -+ dir_name[j]); -+ hikp_nic_queue_cmd_set_param(QUEUE_BASIC_INFO, 0, j); -+ hikp_nic_queue_cmd_execute(&self); -+ printf("hikptool nic_queue -i %s -du intr_map -d %s -a on\n", (char *)nic_name, -+ dir_name[j]); -+ hikp_nic_queue_cmd_set_param(QUEUE_INTR_MAP, -1, j); -+ hikp_nic_queue_cmd_execute(&self); -+ } -+ -+ return 0; -+} -+ -+static int collect_hikp_nic_rss_log(void *nic_name) -+{ -+ const char *sub_cmd_name[] = {"algo", "key", "tuple", "reta", "tc_mode"}; -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int i, ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_nic_cmd_get_rss_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ -+ for (i = RSS_ALGO_DUMP; i <= RSS_TC_MODE_DUMP; ++i) { -+ printf("hikptool nic_rss -i %s -g %s\n", (char *)nic_name, sub_cmd_name[i]); -+ hikp_nic_rss_cmd_set_feature_idx(i); -+ hikp_nic_rss_cmd_execute(&self); -+ } -+ -+ return 0; -+} -+ -+static int collect_hikp_nic_torus_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_nic_torus_get_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool nic_torus -i %s\n", (char *)nic_name); -+ hikp_nic_torus_cmd_execute(&self); -+ return 0; -+} -+ -+static int collect_hikp_nic_fec_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_nic_fec_get_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool nic_fec -i %s\n", (char *)nic_name); -+ hikp_nic_fec_cmd_execute(&self); -+ return 0; -+} -+ -+static int collect_hikp_nic_dfx_log(void *nic_name) -+{ -+ const char *sub_cmd_name[] = {"SSU", "IGU_EGU", "PPP", "NCSI", "BIOS", "RCB", "TXDMA", -+ "MASTER"}; -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int i, ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_nic_cmd_dfx_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ for (i = SSU_DFX_REG_DUMP; i <= MASTER_DFX_REG_DUMP; ++i) { -+ printf("hikptool nic_dfx -i %s -m %s\n", (char *)nic_name, sub_cmd_name[i]); -+ hikp_nic_dfx_set_cmd_para(i); -+ hikp_nic_dfx_cmd_execute(&self); -+ } -+ -+ return 0; -+} -+ -+static int collect_hikp_nic_info_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int ret; -+ -+ printf("hikptool nic_info -i %s\n", (char *)nic_name); -+ self.cmd_ptr = &type; -+ ret = hikp_nic_cmd_get_info_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ -+ hikp_nic_info_cmd_execute(&self); -+ return 0; -+} -+ -+static int collect_hikp_nic_notify_pkt_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int ret; -+ -+ printf("hikptool nic_notify_pkt -i %s\n", (char *)nic_name); -+ self.cmd_ptr = &type; -+ ret = hikp_nic_notify_pkt_get_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ -+ hikp_nic_notify_pkt_cmd_execute(&self); -+ return 0; -+} -+ -+static int collect_hikp_nic_port_fault_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ int ret; -+ -+ printf("hikptool nic_port_fault -i %s\n", (char *)nic_name); -+ self.cmd_ptr = &type; -+ ret = hikp_nic_port_fault_get_target(&self, (char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to get bdf for %s.\n", (char *)nic_name); -+ return ret; -+ } -+ -+ hikp_nic_port_fault_cmd_execute(&self); -+ return 0; -+} -+ -+static int collect_one_nic_hikp_log_compact(char *net_name, char *module, collect_cmd_handler_t hikp_pfn) -+{ -+ char log_name[LOG_FILE_PATH_MAX_LEN] = {0}; -+ int ret; -+ -+ ret = snprintf(log_name, LOG_FILE_PATH_MAX_LEN, "%s_%s", net_name, module); -+ if (ret < 0 || (uint32_t)ret >= LOG_FILE_PATH_MAX_LEN) -+ return -EINVAL; -+ -+ return hikp_collect_log(GROUP_NIC, log_name, hikp_pfn, (void *)net_name); -+} -+ -+static int collect_one_nic_hikp_log(void *net_name) -+{ -+ struct collect_nic_hikp_log_meta { -+ const char *module_name; -+ collect_cmd_handler_t hikp_pfn; -+ } nic_hikp_log_meta[] = { -+ { "nic_fd", collect_hikp_nic_fd_log }, -+ { "nic_gro", collect_hikp_nic_gro_log }, -+ { "nic_ppp", collect_hikp_nic_ppp_log }, -+ { "nic_qos", collect_hikp_nic_qos_log }, -+ { "nic_queue", collect_hikp_nic_queue_log }, -+ { "nic_rss", collect_hikp_nic_rss_log }, -+ { "nic_torus", collect_hikp_nic_torus_log }, -+ { "nic_fec", collect_hikp_nic_fec_log }, -+ { "nic_dfx", collect_hikp_nic_dfx_log }, -+ { "nic_info", collect_hikp_nic_info_log }, -+ { "nic_notify_pkt", collect_hikp_nic_notify_pkt_log }, -+ { "nic_port_fault", collect_hikp_nic_port_fault_log }, -+ }; -+ size_t i; -+ int ret; -+ -+ for (i = 0; i < HIKP_ARRAY_SIZE(nic_hikp_log_meta); ++i) { -+ ret = collect_one_nic_hikp_log_compact((char *)net_name, -+ nic_hikp_log_meta[i].module_name, -+ nic_hikp_log_meta[i].hikp_pfn); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", -+ nic_hikp_log_meta[i].module_name, ret); -+ } -+ -+ return 0; -+} -+ -+void collect_nic_log(void) -+{ -+ collect_nic_debugfs_log(); -+ hikp_collect_all_nic_cmd_log(collect_one_nic_hikp_log); -+} -diff --git a/info_collect/hikp_collect_pcie.c b/info_collect/hikp_collect_pcie.c -new file mode 100644 -index 0000000..d3cd7ad ---- /dev/null -+++ b/info_collect/hikp_collect_pcie.c -@@ -0,0 +1,215 @@ -+/* -+ * Copyright (c) 2024 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 -+#include -+#include -+#include "hikp_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+#include "hikptdev_plug.h" -+#include "pcie_link_ltssm.h" -+#include "pcie_statistics.h" -+#include "pcie_common.h" -+#include "pcie_reg_dump.h" -+ -+#define PCIE_DEV_LEN 512 -+#define PCIE_DEV_PATH "/sys/bus/pci/devices" -+#define MAX_NIMBUS_NUM_ALL 8 -+ -+/* Optimization barrier */ -+#ifndef barrier -+/* The "volatile" is due to gcc bugs */ -+# define barrier() __asm__ __volatile__("": : :"memory") -+#endif -+ -+struct pcie_id_info { -+ uint32_t chip_id; -+ uint32_t port_id; -+}; -+ -+/* get pcie config space info */ -+static void collect_pcie_common(char *pcie_dev_name) -+{ -+ struct info_collect_cmd pcie_cmd_arr = {0}; -+ int ret; -+ -+ pcie_cmd_arr.group = GROUP_PCIE; -+ pcie_cmd_arr.log_name = pcie_dev_name; -+ pcie_cmd_arr.args[ARGS_IDX0] = "lspci"; -+ pcie_cmd_arr.args[ARGS_IDX1] = "-vvvxxxx"; -+ pcie_cmd_arr.args[ARGS_IDX2] = "-s"; -+ pcie_cmd_arr.args[ARGS_IDX3] = pcie_dev_name; -+ pcie_cmd_arr.args[ARGS_IDX4] = NULL; -+ ret = hikp_collect_log(pcie_cmd_arr.group, pcie_cmd_arr.log_name, -+ hikp_collect_exec, (void *)&pcie_cmd_arr); -+ if (ret) -+ HIKP_ERROR_PRINT("collect_pcie_common failed: %d\n", ret); -+} -+ -+static void collect_pcie_single_cfg(void) -+{ -+ char dev_name[PCIE_DEV_LEN]; -+ struct dirent *ptr = NULL; -+ DIR *dir = NULL; -+ -+ if ((dir = opendir(PCIE_DEV_PATH)) == NULL) { -+ perror("failed to open path \n"); -+ return; -+ } -+ -+ while ((ptr = readdir(dir)) != NULL) { -+ if ((strcmp(ptr->d_name, ".") == 0) || (strcmp(ptr->d_name, "..") == 0)) { -+ continue; -+ } else if (ptr->d_type == DT_LNK) { -+ memset(dev_name, 0, sizeof(dev_name)); -+ strncpy(dev_name, ptr->d_name, sizeof(dev_name) - 1); -+ dev_name[sizeof(dev_name) - 1] = '\0'; -+ collect_pcie_common(dev_name); -+ } -+ } -+ -+ closedir(dir); -+} -+ -+/* get pcie config tree info */ -+static void collect_pcie_cfg_tree(void) -+{ -+ struct info_collect_cmd pcie_cmd_arr = { -+ .group = GROUP_PCIE, -+ .log_name = "pcie_tree", -+ .args = {"lspci", "-tv", NULL}, -+ }; -+ int ret; -+ -+ ret = hikp_collect_log(pcie_cmd_arr.group, pcie_cmd_arr.log_name, -+ hikp_collect_exec, (void *)&pcie_cmd_arr); -+ if (ret) -+ HIKP_ERROR_PRINT("collect_pcie_cfg_tree failed: %d\n", ret); -+} -+ -+static int pcie_mv_dumplog(void) -+{ -+ struct info_collect_cmd pcie_cmd_arr = { 0 }; -+ -+ pcie_cmd_arr.group = GROUP_PCIE; -+ pcie_cmd_arr.args[ARGS_IDX0] = "mv"; -+ pcie_cmd_arr.args[ARGS_IDX1] = dumpreg_log_file; -+ -+ return hikp_move_files(&pcie_cmd_arr); -+} -+ -+static int collect_pcie_local_info(void *data) -+{ -+ struct pcie_id_info *info = (struct pcie_id_info *)data; -+ uint32_t port_id; -+ -+ port_id = info->port_id; -+ printf("chip_id:%u, port_id:%u\n", info->chip_id, port_id); -+ /* do dump action for each port */ -+ /* step 1 pcie trace */ -+ printf("hikptool pcie_trace -i %u -s\n", port_id); -+ (void)pcie_ltssm_trace_show(port_id); -+ /* step 2 pcie link status */ -+ printf("hikptool pcie_trace -i %u -f\n", port_id); -+ (void)pcie_ltssm_link_status_get(port_id); -+ /* step 3 pcie err cnt */ -+ printf("hikptool pcie_info -i %u -es\n", port_id); -+ (void)pcie_error_state_get(port_id); -+ /* step 4 pcie pm trace */ -+ printf("hikptool pcie_trace -i %u -pm\n", port_id); -+ (void)pcie_pm_trace(port_id); -+ -+ return 0; -+} -+ -+static int pcie_port_distribution_info(void *data) -+{ -+ uint32_t chip_id = *(uint32_t *)(data); -+ int ret; -+ -+ printf("hikptool pcie_info -i %u -d\n", chip_id); -+ ret = pcie_port_distribution_get(chip_id); -+ if (ret) -+ HIKP_ERROR_PRINT("pcie_port_distribution_get failed: %d\n", ret); -+ return ret; -+} -+ -+static void collect_pcie_local(void) -+{ -+ struct pcie_info_req_para req_data = { 0 }; -+ char name[MAX_LOG_NAME_LEN + 1] = { 0 }; -+ struct pcie_port_info *port_info = NULL; -+ struct hikp_cmd_ret *cmd_ret = NULL; -+ struct hikp_cmd_header req_header; -+ struct pcie_id_info info; -+ uint32_t port_num; -+ uint32_t port_id; -+ uint32_t i, j; -+ int ret; -+ -+ for (i = 0; i < MAX_NIMBUS_NUM_ALL; i++) { -+ req_data.interface_id = i; -+ -+ memset(name, 0, MAX_LOG_NAME_LEN + 1); -+ (void)snprintf(name, MAX_LOG_NAME_LEN, "pcie_local_nimbus_%u", i); -+ -+ ret = hikp_collect_log(GROUP_PCIE, name, pcie_port_distribution_info, (void *)&i); -+ if (ret) { -+ HIKP_INFO_PRINT("Nimbus:%u hikp_collect_log pcie_port_distribution_info unsuccessful!\n", i); -+ return; -+ } -+ -+ hikp_cmd_init(&req_header, PCIE_MOD, PCIE_INFO, INFO_DISTRIBUTION); -+ cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -+ ret = port_distribution_rsp_data_check(cmd_ret, &port_num); -+ if (ret) { -+ HIKP_ERROR_PRINT("port_distribution_rsp_data_check failed: %d\n", ret); -+ hikp_cmd_free(&cmd_ret); -+ return; -+ } -+ -+ port_info = (struct pcie_port_info *)cmd_ret->rsp_data; -+ for (j = 0; j < port_num; j++) { -+ port_id = port_info->info_pair[j].port_id; -+ info.chip_id = i; -+ info.port_id = port_info->info_pair[j].port_id; -+ -+ memset(name, 0, MAX_LOG_NAME_LEN + 1); -+ (void)snprintf(name, MAX_LOG_NAME_LEN, "pcie_local_port_%u", j); -+ -+ ret = hikp_collect_log(GROUP_PCIE, name, collect_pcie_local_info, (void *)&info); -+ if (ret) { -+ HIKP_ERROR_PRINT("hikp_collect_log collect_pcie_local_info failed: %d\n", ret); -+ hikp_cmd_free(&cmd_ret); -+ return; -+ } -+ /* step 1 pcie dumpreg core level */ -+ (void)pcie_dumpreg_do_dump(port_id, DUMP_GLOBAL_LEVEL); -+ (void)pcie_mv_dumplog(); -+ /* step 2 pcie dumpreg port level */ -+ (void)pcie_dumpreg_do_dump(port_id, DUMP_PORT_LEVEL); -+ (void)pcie_mv_dumplog(); -+ } -+ hikp_cmd_free(&cmd_ret); -+ } -+} -+ -+void collect_pcie_info(void) -+{ -+ collect_pcie_cfg_tree(); -+ -+ collect_pcie_single_cfg(); -+ -+ collect_pcie_local(); -+} -diff --git a/info_collect/hikp_collect_roce.c b/info_collect/hikp_collect_roce.c -new file mode 100644 -index 0000000..baf2899 ---- /dev/null -+++ b/info_collect/hikp_collect_roce.c -@@ -0,0 +1,489 @@ -+/* -+ * Copyright (c) 2024 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_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+#include "hikp_roce_bond.h" -+#include "hikp_roce_global_cfg.h" -+#include "hikp_roce_rst.h" -+#include "hikp_roce_timer.h" -+#include "hikp_roce_pkt.h" -+#include "hikp_roce_mdb.h" -+#include "hikp_roce_caep.h" -+#include "hikp_roce_qmm.h" -+#include "hikp_roce_trp.h" -+#include "hikp_roce_tsp.h" -+#include "hikp_roce_scc.h" -+#include "hikp_roce_gmv.h" -+ -+static void collect_roce_devinfo_log(void) -+{ -+ const struct info_collect_cmd roce_devinfo_cmd = { -+ .group = GROUP_ROCE, -+ .log_name = "ibv_devinfo", -+ .args = {"ibv_devinfo", NULL}, -+ }; -+ int ret; -+ -+ ret = hikp_collect_log(roce_devinfo_cmd.group, -+ roce_devinfo_cmd.log_name, -+ hikp_collect_exec, -+ (void *)&roce_devinfo_cmd); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", -+ roce_devinfo_cmd.log_name, ret); -+} -+ -+static void collect_roce_cc_param_log(void) -+{ -+ struct info_collect_cmd roce_cc_param_cmd = { -+ .group = GROUP_ROCE, -+ .log_name = "cc_param", -+ .args = {"cp", "-rf", -+ "/sys/class/infiniband/*/ports/1/cc_param", NULL}, -+ }; -+ int ret; -+ -+ ret = hikp_collect_log(roce_cc_param_cmd.group, -+ roce_cc_param_cmd.log_name, -+ hikp_collect_cp_glob_exec, -+ (void *)&roce_cc_param_cmd); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", -+ roce_cc_param_cmd.log_name, ret); -+} -+ -+static void collect_roce_sw_stats_log(void) -+{ -+ struct info_collect_cmd roce_sw_stats_cmd = { -+ .group = GROUP_ROCE, -+ .log_name = "sw_stat", -+ .args = {"cat", "/sys/kernel/debug/hns_roce/*/sw_stat/sw_stat", -+ NULL}, -+ }; -+ int ret; -+ -+ ret = hikp_collect_log(roce_sw_stats_cmd.group, -+ roce_sw_stats_cmd.log_name, -+ hikp_collect_cat_glob_exec, -+ (void *)&roce_sw_stats_cmd); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", -+ roce_sw_stats_cmd.log_name, ret); -+} -+ -+static void collect_roce_res_stats_log(void) -+{ -+ const struct info_collect_cmd roce_res_stats_cmd = { -+ .group = GROUP_ROCE, -+ .log_name = "rdma_res_show", -+ .args = {"rdma", "res", "show", NULL}, -+ }; -+ int ret; -+ -+ ret = hikp_collect_log(roce_res_stats_cmd.group, -+ roce_res_stats_cmd.log_name, -+ hikp_collect_exec, -+ (void *)&roce_res_stats_cmd); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", -+ roce_res_stats_cmd.log_name, ret); -+} -+ -+static int collect_hikp_roce_gmv_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ uint32_t gmv_index; -+ int ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_roce_set_gmv_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce_gmv bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ for (gmv_index = 0; gmv_index < ROCE_MAX_HIKPTOOL_GMV; gmv_index++) { -+ printf("hikptool roce_gmv -i %s -x %u\n", (char *)nic_name, gmv_index); -+ hikp_roce_set_gmv_index(gmv_index); -+ hikp_roce_gmv_execute(&self); -+ } -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_scc_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_scc_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce_scc bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool roce_scc -i %s -m COMMON\n", (char *)nic_name); -+ hikp_roce_set_scc_submodule(SCC_COMMON); -+ hikp_roce_scc_execute(&self); -+ -+ printf("hikptool roce_scc -i %s -m DCQCN\n", (char *)nic_name); -+ hikp_roce_set_scc_submodule(DCQCN); -+ hikp_roce_scc_execute(&self); -+ -+ printf("hikptool roce_scc -i %s -m DIP\n", (char *)nic_name); -+ hikp_roce_set_scc_submodule(DIP); -+ hikp_roce_scc_execute(&self); -+ -+ printf("hikptool roce_scc -i %s -m HC3\n", (char *)nic_name); -+ hikp_roce_set_scc_submodule(HC3); -+ hikp_roce_scc_execute(&self); -+ -+ printf("hikptool roce_scc -i %s -m LDCP\n", (char *)nic_name); -+ hikp_roce_set_scc_submodule(LDCP); -+ hikp_roce_scc_execute(&self); -+ -+ printf("hikptool roce_scc -i %s -m CFG\n", (char *)nic_name); -+ hikp_roce_set_scc_submodule(CFG); -+ hikp_roce_scc_execute(&self); -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_tsp_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ uint32_t bankid; -+ int ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_roce_set_tsp_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce_tsp bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ hikp_roce_set_tsp_submodule(TSP_COMMON); -+ for (bankid = 0; bankid <= MAX_TSP_BANK_NUM; bankid++) { -+ hikp_roce_set_tsp_bankid(bankid); -+ -+ printf("hikptool roce_tsp -i %s -m COMMON -b %u\n", (char *)nic_name, bankid); -+ hikp_roce_tsp_execute(&self); -+ } -+ -+ hikp_roce_set_tsp_submodule(TGP_TMP); -+ for (bankid = 0; bankid <= MAX_TGP_TMP_BANK_NUM; bankid++) { -+ hikp_roce_set_tsp_bankid(bankid); -+ -+ printf("hikptool roce_tsp -i %s -m TGP_TMP -b %u\n", (char *)nic_name, bankid); -+ hikp_roce_tsp_execute(&self); -+ } -+ -+ printf("hikptool roce_tsp -i %s -m TDP\n", (char *)nic_name); -+ hikp_roce_set_tsp_submodule(TDP); -+ hikp_roce_tsp_execute(&self); -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_trp_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ uint32_t bankid; -+ int ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_roce_set_trp_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce_trp bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ hikp_roce_set_trp_submodule(TRP_COMMON); -+ for (bankid = 0; bankid <= TRP_MAX_BANK_NUM; bankid++) { -+ hikp_roce_set_trp_bankid(bankid); -+ -+ printf("hikptool roce_trp -i %s -m COMMON -b %u\n", (char *)nic_name, bankid); -+ hikp_roce_trp_execute(&self); -+ } -+ -+ printf("hikptool roce_trp -i %s -m TRP_RX\n", (char *)nic_name); -+ hikp_roce_set_trp_submodule(TRP_RX); -+ hikp_roce_trp_execute(&self); -+ -+ hikp_roce_set_trp_submodule(GEN_AC); -+ for (bankid = 0; bankid <= GAC_MAX_BANK_NUM; bankid++) { -+ hikp_roce_set_trp_bankid(bankid); -+ -+ printf("hikptool roce_trp -i %s -m GEN_AC -b %u\n", (char *)nic_name, bankid); -+ hikp_roce_trp_execute(&self); -+ } -+ -+ hikp_roce_set_trp_submodule(PAYL); -+ for (bankid = 0; bankid <= PAYL_MAX_BANK_NUM; bankid++) { -+ hikp_roce_set_trp_bankid(bankid); -+ -+ printf("hikptool roce_trp -i %s -m PAYL -b %u\n", (char *)nic_name, bankid); -+ hikp_roce_trp_execute(&self); -+ } -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_qmm_log(void *nic_name) -+{ -+ struct major_cmd_ctrl self = {0}; -+ struct hikp_cmd_type type = {0}; -+ uint32_t bankid; -+ int ret; -+ -+ self.cmd_ptr = &type; -+ ret = hikp_roce_set_qmm_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce_qmm bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ for (bankid = 0; bankid <= QMM_BANK_NUM; bankid++) { -+ hikp_roce_set_qmm_bankid(bankid); -+ -+ printf("hikptool roce_qmm -i %s -b %u\n", (char *)nic_name, bankid); -+ hikp_roce_set_qmm_ext_flag(false); -+ hikp_roce_qmm_execute(&self); -+ -+ printf("hikptool roce_qmm -i %s -b %u -e\n", (char *)nic_name, bankid); -+ hikp_roce_set_qmm_ext_flag(true); -+ hikp_roce_qmm_execute(&self); -+ } -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_caep_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_caep_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce_caep bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool roce_caep -i %s\n", (char *)nic_name); -+ hikp_roce_set_caep_mode(CAEP_ORIGIN); -+ hikp_roce_caep_execute(&self); -+ -+ printf("hikptool roce_caep -i %s -e\n", (char *)nic_name); -+ hikp_roce_set_caep_mode(CAEP_EXT); -+ hikp_roce_caep_execute(&self); -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_mdb_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_mdb_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce_mdb bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool roce_mdb -i %s\n", (char *)nic_name); -+ hikp_roce_set_mdb_mode(ROCE_MDB_CMD); -+ hikp_roce_mdb_execute(&self); -+ -+ printf("hikptool roce_mdb -i %s -e\n", (char *)nic_name); -+ hikp_roce_set_mdb_mode(ROCE_MDB_CMD_EXT); -+ hikp_roce_mdb_execute(&self); -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_pkt_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_pkt_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce_pkt bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool roce_pkt -i %s\n", (char *)nic_name); -+ hikp_roce_pkt_execute(&self); -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_timer_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_timer_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce_timer bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool roce_timer -i %s\n", (char *)nic_name); -+ hikp_roce_timer_execute(&self); -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_rst_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_rst_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce_rst bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool roce_rst -i %s\n", (char *)nic_name); -+ hikp_roce_rst_execute(&self); -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_global_cfg_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_global_cfg_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce global_cfg bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool roce_global_cfg -i %s\n", (char *)nic_name); -+ hikp_roce_global_cfg_execute(&self); -+ -+ return 0; -+} -+ -+static int collect_hikp_roce_bond_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_bond_bdf((char *)nic_name); -+ if (ret) { -+ HIKP_ERROR_PRINT("failed to set roce bond bdf for %s.\n", -+ (char *)nic_name); -+ return ret; -+ } -+ -+ printf("hikptool roce_bond -i %s\n", (char *)nic_name); -+ hikp_roce_bond_execute(&self); -+ -+ return 0; -+} -+ -+static void collect_one_roce_hikp_log_compact(char *net_name, char *module, -+ collect_cmd_handler_t hikp_pfn) -+{ -+ char log_name[LOG_FILE_PATH_MAX_LEN] = {0}; -+ int ret; -+ -+ ret = snprintf(log_name, LOG_FILE_PATH_MAX_LEN, "%s_%s", net_name, -+ module); -+ if (ret < 0 || (uint32_t)ret >= LOG_FILE_PATH_MAX_LEN) { -+ HIKP_ERROR_PRINT("failed to set %s path %d\n", net_name, ret); -+ return; -+ } -+ -+ ret = hikp_collect_log(GROUP_ROCE, log_name, hikp_pfn, (void *)net_name); -+ if (ret) -+ HIKP_ERROR_PRINT("failed to get %s info %d\n", net_name, ret); -+} -+ -+static int collect_one_roce_hikp_log(void *net_name) -+{ -+ struct collect_roce_hikp_log_meta { -+ const char *module_name; -+ collect_cmd_handler_t hikp_pfn; -+ } roce_hikp_log_meta[] = { -+ { "roce_bond", collect_hikp_roce_bond_log }, -+ { "roce_global_cfg", collect_hikp_roce_global_cfg_log }, -+ { "roce_rst", collect_hikp_roce_rst_log }, -+ { "roce_timer", collect_hikp_roce_timer_log }, -+ { "roce_pkt", collect_hikp_roce_pkt_log }, -+ { "roce_mdb", collect_hikp_roce_mdb_log }, -+ { "roce_caep", collect_hikp_roce_caep_log }, -+ { "roce_qmm", collect_hikp_roce_qmm_log }, -+ { "roce_trp", collect_hikp_roce_trp_log }, -+ { "roce_tsp", collect_hikp_roce_tsp_log }, -+ { "roce_scc", collect_hikp_roce_scc_log }, -+ { "roce_gmv", collect_hikp_roce_gmv_log }, -+ }; -+ size_t i; -+ -+ for (i = 0; i < HIKP_ARRAY_SIZE(roce_hikp_log_meta); ++i) { -+ collect_one_roce_hikp_log_compact((char *)net_name, -+ roce_hikp_log_meta[i].module_name, -+ roce_hikp_log_meta[i].hikp_pfn); -+ } -+ -+ return 0; -+} -+ -+void collect_roce_log(void) -+{ -+ collect_roce_devinfo_log(); -+ collect_roce_cc_param_log(); -+ collect_roce_sw_stats_log(); -+ collect_roce_res_stats_log(); -+ hikp_collect_all_nic_cmd_log(collect_one_roce_hikp_log); -+} -+ -diff --git a/info_collect/hikp_collect_sas.c b/info_collect/hikp_collect_sas.c -new file mode 100644 -index 0000000..11022dc ---- /dev/null -+++ b/info_collect/hikp_collect_sas.c -@@ -0,0 +1,453 @@ -+/* -+ * Copyright (c) 2024 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_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+#include "sas_tools_include.h" -+#include "sas_common.h" -+#include "sas_analy_queue.h" -+#include "sas_dump_reg.h" -+#include "sas_read_dev.h" -+#include "sas_read_errcode.h" -+#include "sata_dump_reg.h" -+ -+#define CHIP_MAX_SIZE 10 -+#define DIE_MAX_SIZE 10 -+ -+typedef int (*reg_info_func_t)(uint32_t, uint32_t); -+ -+enum sata_dump_type { -+ SATA_DUMP_UNKNOWN = 0, -+ SATA_DUMP_GLOBAL, -+ SATA_DUMP_PORTX, -+}; -+ -+struct reg_op { -+ char *func_name; -+ reg_info_func_t func; -+}; -+ -+static int sas_sata_reg_log(void *data) -+{ -+ struct reg_op *op = (struct reg_op *)data; -+ bool stop_flag = false; -+ uint32_t i, j; -+ int ret; -+ -+ for (i = 0; i < CHIP_MAX_SIZE; i++) { -+ for (j = 0; j < DIE_MAX_SIZE; j++) { -+ ret = op->func(i, j); -+ if (ret) { -+ HIKP_ERROR_PRINT("%s chip%u die%u failed: %d\n", op->func_name, -+ i, j, ret); -+ /* -+ * Stop collection when the die id is 0, indicating that the -+ * current chip id is not supported. -+ * */ -+ if (j == 0) -+ stop_flag = true; -+ -+ break; -+ } -+ } -+ -+ if (stop_flag) -+ break; -+ } -+ -+ return 0; -+} -+ -+static void collect_sas_path_log(char *group) -+{ -+ struct info_collect_cmd sas_path_cmd = { -+ .log_name = "ls_by-path", -+ .args = {"ls", "-l", "/dev/disk/by-path/", NULL}, -+ }; -+ int ret; -+ -+ ret = hikp_collect_log(group, sas_path_cmd.log_name, -+ hikp_collect_exec, (void *)&sas_path_cmd); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", sas_path_cmd.log_name, ret); -+} -+ -+static void collect_sas_phy_log(void) -+{ -+ struct info_collect_cmd sas_phy_cmds[] = { -+ { -+ .log_name = "phy-invalid_dword_count", -+ .args = {"cat", "/sys/class/sas_phy/*/invalid_dword_count", NULL}, -+ }, -+ { -+ .log_name = "phy-negotiated_linkrate", -+ .args = {"cat", "/sys/class/sas_phy/*/negotiated_linkrate", NULL}, -+ }, -+ { -+ .log_name = "phy-enable", -+ .args = {"cat", "/sys/class/sas_phy/*/enable", NULL}, -+ }, -+ }; -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(sas_phy_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_collect_log(GROUP_SAS, sas_phy_cmds[i].log_name, -+ hikp_collect_cat_glob_exec, (void *)&sas_phy_cmds[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", -+ sas_phy_cmds[i].log_name, ret); -+ } -+} -+ -+static void collect_sas_host_log(void) -+{ -+ struct info_collect_cmd sas_host_cmds[] = { -+ { -+ .log_name = "host-nr_hw_queues", -+ .args = {"cat", "/sys/class/scsi_host/host*/nr_hw_queues", NULL}, -+ }, -+ { -+ .log_name = "host-intr", -+ .args = {"cat", "/sys/class/scsi_host/host*/intr*", NULL}, -+ }, -+ }; -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(sas_host_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_collect_log(GROUP_SAS, sas_host_cmds[i].log_name, -+ hikp_collect_cat_glob_exec, (void *)&sas_host_cmds[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", -+ sas_host_cmds[i].log_name, ret); -+ } -+} -+ -+static void collect_sas_disk_log(void) -+{ -+ struct info_collect_cmd sas_disk_cmds[] = { -+ { -+ .log_name = "disk-scheduler", -+ .args = {"cat", "/sys/block/sd*/queue/scheduler", NULL}, -+ }, -+ { -+ .log_name = "disk-max", -+ .args = {"cat", "/sys/block/sd*/queue/max*", NULL}, -+ }, -+ { -+ .log_name = "disk-state", -+ .args = {"cat", "/sys/block/sd*/device/state", NULL}, -+ }, -+ }; -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(sas_disk_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_collect_log(GROUP_SAS, sas_disk_cmds[i].log_name, -+ hikp_collect_cat_glob_exec, (void *)&sas_disk_cmds[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", -+ sas_disk_cmds[i].log_name, ret); -+ } -+} -+ -+static int collect_sas_lsscsi_log_exec(void *data) -+{ -+ const struct info_collect_cmd sas_lsscsi_cmds[] = { -+ { -+ .args = {"lsscsi", "-lg", NULL}, -+ }, -+ { -+ .args = {"lsscsi", "-pvt", NULL}, -+ }, -+ { -+ .args = {"lsscsi", "-H", NULL}, -+ }, -+ }; -+ size_t i, size; -+ (void)data; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(sas_lsscsi_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_collect_exec((void *)&sas_lsscsi_cmds[i]); -+ if (ret) -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static void collect_sas_lsscsi_log(char *group) -+{ -+ int ret; -+ -+ ret = hikp_collect_log(group, "lsscsi", collect_sas_lsscsi_log_exec, (void *)NULL); -+ if (ret) -+ HIKP_ERROR_PRINT("collect lsscsi log failed: %d\n", ret); -+} -+ -+static void collect_sas_copy_files(void) -+{ -+ struct info_collect_cmd sas_copy_cmds[] = { -+ { -+ .group = GROUP_SAS, -+ .log_name = "debugfs", -+ .args = {"cp", "-rf", "/sys/kernel/debug/hisi_sas/", NULL}, -+ }, -+ { -+ .group = GROUP_SAS, -+ .log_name = "parameters_hw", -+ .args = {"cp", "-rf", "/sys/module/hisi_sas_v3_hw/parameters/", NULL}, -+ }, -+ { -+ .group = GROUP_SAS, -+ .log_name = "parameters_main", -+ .args = {"cp", "-rf", "/sys/module/hisi_sas_main/parameters/", NULL}, -+ }, -+ }; -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(sas_copy_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_save_files(&sas_copy_cmds[i]); -+ if (ret) -+ HIKP_ERROR_PRINT("cp %s failed: %d\n", -+ sas_copy_cmds[i].args[ARGS_IDX2], ret); -+ } -+} -+ -+static int sas_anacq_info(uint32_t chip_id, uint32_t die_id) -+{ -+ struct tool_sas_cmd cmd = { -+ .chip_id = chip_id, -+ .die_id = die_id, -+ }; -+ int ret; -+ -+ printf("hikptool sas_anacq -c %u -d %u -s\n", cmd.chip_id, cmd.die_id); -+ cmd.sas_cmd_type = ANACQ_NUM; -+ ret = sas_analy_cmd(&cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("collect cq number failed: %d\n", ret); -+ return ret; -+ } -+ -+ printf("hikptool sas_anacq -c %u -d %u -p\n", cmd.chip_id, cmd.die_id); -+ cmd.sas_cmd_type = ANACQ_PRT; -+ ret = sas_analy_cmd(&cmd); -+ if (ret) -+ HIKP_ERROR_PRINT("collect cq read/write pointer failed: %d\n", ret); -+ -+ return ret; -+} -+ -+static int sas_anadq_info(uint32_t chip_id, uint32_t die_id) -+{ -+ struct tool_sas_cmd cmd = { -+ .chip_id = chip_id, -+ .die_id = die_id, -+ }; -+ int ret; -+ -+ printf("hikptool sas_anadq -c %u -d %u -s\n", cmd.chip_id, cmd.die_id); -+ cmd.sas_cmd_type = ANADQ_NUM; -+ ret = sas_analy_cmd(&cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("collect dq num failed: %d\n", ret); -+ return ret; -+ } -+ -+ printf("hikptool sas_anadq -c %u -d %u -p\n", cmd.chip_id, cmd.die_id); -+ cmd.sas_cmd_type = ANADQ_PRT; -+ ret = sas_analy_cmd(&cmd); -+ if (ret) -+ HIKP_ERROR_PRINT("collect dq read/write pointer failed: %d\n", ret); -+ -+ return ret; -+} -+ -+static int sas_dump_info(uint32_t chip_id, uint32_t die_id) -+{ -+ struct tool_sas_cmd cmd = { -+ .chip_id = chip_id, -+ .die_id = die_id, -+ }; -+ uint32_t i; -+ int ret; -+ -+ printf("hikptool sas_dump -c %u -d %u -g\n", cmd.chip_id, cmd.die_id); -+ cmd.sas_cmd_type = DUMP_GLOBAL; -+ ret = sas_reg_dump(&cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("dump global failed: %d\n", ret); -+ return ret; -+ } -+ -+ for (i = 0; i <= SAS_MAX_PHY_NUM; i++) { -+ printf("hikptool sas_dump -c %u -d %u -p %u\n", cmd.chip_id, cmd.die_id, i); -+ cmd.sas_cmd_type = DUMP_PHYX; -+ cmd.phy_id = i; -+ ret = sas_reg_dump(&cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("dump phy %u failed: %d\n", i, ret); -+ return ret; -+ } -+ } -+ -+ printf("hikptool sas_dump -c %u -d %u -b\n", cmd.chip_id, cmd.die_id); -+ cmd.sas_cmd_type = DUMP_AXI; -+ ret = sas_reg_dump(&cmd); -+ if (ret) -+ HIKP_ERROR_PRINT("dump axi failed: %d\n", ret); -+ -+ return ret; -+} -+ -+static int sas_dev_info(uint32_t chip_id, uint32_t die_id) -+{ -+ struct tool_sas_cmd cmd = { -+ .chip_id = chip_id, -+ .die_id = die_id, -+ }; -+ -+ printf("hikptool sas_dev -c %u -d %u -l\n", cmd.chip_id, cmd.die_id); -+ cmd.sas_cmd_type = DEV_LINK; -+ return sas_dev(&cmd); -+} -+ -+static int sas_errcode_info(uint32_t chip_id, uint32_t die_id) -+{ -+ struct tool_sas_cmd cmd = { -+ .chip_id = chip_id, -+ .die_id = die_id, -+ }; -+ uint32_t i; -+ int ret; -+ -+ for (i = 0; i < SAS_MAX_ERR_NUM; i++) { -+ printf("hikptool sas_errcode -c %u -d %u -t %u\n", cmd.chip_id, cmd.die_id, i); -+ cmd.sas_cmd_type = i; -+ ret = sas_errcode_read(&cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("collect errcode %u info failed: %d\n", i, ret); -+ return ret; -+ } -+ } -+ -+ return 0; -+} -+ -+static void collect_sas_reg_log(void) -+{ -+ struct reg_op op = {0}; -+ int ret; -+ -+ op.func = sas_anacq_info; -+ op.func_name = "sas_anacq_info"; -+ ret = hikp_collect_log(GROUP_SAS, "sas_anacq", sas_sata_reg_log, (void *)&op); -+ if (ret) -+ HIKP_INFO_PRINT("%s failed: %d\n", op.func_name, ret); -+ -+ op.func = sas_anadq_info; -+ op.func_name = "sas_anadq_info"; -+ ret = hikp_collect_log(GROUP_SAS, "sas_anadq", sas_sata_reg_log, (void *)&op); -+ if (ret) -+ HIKP_INFO_PRINT("%s failed: %d\n", op.func_name, ret); -+ -+ op.func = sas_dump_info; -+ op.func_name = "sas_dump_info"; -+ ret = hikp_collect_log(GROUP_SAS, "sas_dump", sas_sata_reg_log, (void *)&op); -+ if (ret) -+ HIKP_INFO_PRINT("%s failed: %d\n", op.func_name, ret); -+ -+ op.func = sas_dev_info; -+ op.func_name = "sas_dev_info"; -+ ret = hikp_collect_log(GROUP_SAS, "sas_dev", sas_sata_reg_log, (void *)&op); -+ if (ret) -+ HIKP_INFO_PRINT("%s failed: %d\n", op.func_name, ret); -+ -+ op.func = sas_errcode_info; -+ op.func_name = "sas_errcode_info"; -+ ret = hikp_collect_log(GROUP_SAS, "sas_errcode", sas_sata_reg_log, (void *)&op); -+ if (ret) -+ HIKP_INFO_PRINT("%s failed: %d\n", op.func_name, ret); -+} -+ -+void collect_sas_log(void) -+{ -+ collect_sas_phy_log(); -+ collect_sas_host_log(); -+ collect_sas_disk_log(); -+ collect_sas_copy_files(); -+ collect_sas_path_log(GROUP_SAS); -+ collect_sas_lsscsi_log(GROUP_SAS); -+ collect_sas_reg_log(); -+} -+ -+static int sata_reg_dump_info(uint32_t chip_id, uint32_t die_id) -+{ -+ struct tool_sata_cmd cmd = { -+ .chip_id = chip_id, -+ .die_id = die_id, -+ }; -+ uint32_t i; -+ int ret; -+ -+ printf("hikptool sata_dump -c %u -d %u -g\n", cmd.chip_id, cmd.die_id); -+ cmd.sata_cmd_type = SATA_DUMP_GLOBAL; -+ ret = sata_reg_dump(&cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("dump global failed: %d\n", ret); -+ return ret; -+ } -+ -+ cmd.sata_cmd_type = SATA_DUMP_PORTX; -+ for (i = 0; i <= 1; i++) { -+ printf("hikptool sata_dump -c %u -d %u -p %u\n", cmd.chip_id, cmd.die_id, i); -+ cmd.phy_id = i; -+ ret = sata_reg_dump(&cmd); -+ if (ret) { -+ HIKP_INFO_PRINT("dump port%u reg failed: %d\n", i, ret); -+ return ret; -+ } -+ } -+ -+ return 0; -+} -+ -+static void collect_sata_reg_log(void) -+{ -+ struct reg_op op = { -+ .func = sata_reg_dump_info, -+ .func_name = "sata_reg_dump_info", -+ }; -+ int ret; -+ -+ ret = hikp_collect_log(GROUP_SATA, "reg_dump", sas_sata_reg_log, (void *)&op); -+ if (ret) -+ HIKP_INFO_PRINT("%s failed: %d\n", op.func_name, ret); -+} -+ -+void collect_sata_log(void) -+{ -+ collect_sas_path_log(GROUP_SATA); -+ collect_sas_lsscsi_log(GROUP_SATA); -+ collect_sata_reg_log(); -+} -diff --git a/info_collect/hikp_collect_serdes.c b/info_collect/hikp_collect_serdes.c -new file mode 100644 -index 0000000..31f29b3 ---- /dev/null -+++ b/info_collect/hikp_collect_serdes.c -@@ -0,0 +1,244 @@ -+/* -+ * Copyright (c) 2024 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_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+#include "hikp_serdes.h" -+ -+#define MAX_CHIP_NUM_SUPPORT 8 -+#define HIP10_DIE_NUM 2 -+#define HIP11_DIE_NUM 4 -+#define HIP10_DIE_MACRO_NUM 7 -+#define HIP11_DIE_MACRO_NUM 4 -+ -+struct serdes_macro_info { -+ uint8_t macro_id; -+ uint8_t ds_num; -+}; -+ -+struct serdes_log_cmd { -+ struct cmd_serdes_param *cmd; -+ unsigned char die_id; -+}; -+ -+struct serdes_macro_info g_hip10[] = { -+ {0, 4}, /* 0, 4: macro_id, ds_num */ -+ {1, 4}, /* 1, 4: macro_id, ds_num */ -+ {2, 8}, /* 2, 8: macro_id, ds_num */ -+ {3, 8}, /* 3, 8: macro_id, ds_num */ -+ {4, 8}, /* 4, 8: macro_id, ds_num */ -+ {5, 8}, /* 5, 8: macro_id, ds_num */ -+ {6, 8}, /* 6, 8: macro_id, ds_num */ -+}; -+ -+struct serdes_macro_info g_hip11[] = { -+ {0, 4}, /* 0, 4: macro_id, ds_num */ -+ {1, 8}, /* 1, 8: macro_id, ds_num */ -+ {2, 4}, /* 2, 4: macro_id, ds_num */ -+ {3, 4}, /* 3, 4: macro_id, ds_num */ -+}; -+ -+static int is_chip_hip11(void) -+{ -+ return get_chip_type() == CHIP_HIP11; -+} -+ -+static unsigned char serdes_get_die_num(void) -+{ -+ return is_chip_hip11() ? HIP11_DIE_NUM : HIP10_DIE_NUM; -+} -+ -+static unsigned char serdes_get_die_macro_num(void) -+{ -+ return is_chip_hip11() ? HIP11_DIE_MACRO_NUM : HIP10_DIE_MACRO_NUM; -+} -+ -+static struct serdes_macro_info *serdes_get_macro_info(void) -+{ -+ return is_chip_hip11() ? g_hip11 : g_hip10; -+} -+ -+static int collect_serdes_info_process(void *data) -+{ -+ struct serdes_log_cmd *log_cmd = (struct serdes_log_cmd *)data; -+ struct serdes_macro_info *macro_info = serdes_get_macro_info(); -+ unsigned char die_macro_num = serdes_get_die_macro_num(); -+ struct cmd_serdes_param *cmd = log_cmd->cmd; -+ const char *info_cmd_str[] = {"", "-k"}; -+ unsigned char die_id = log_cmd->die_id; -+ /* 0, 1: brief info, detail info */ -+ unsigned char subcmd_list[] = {0, 1}; -+ unsigned char k, p; -+ int ret; -+ -+ for (k = 0; k < die_macro_num; k++) { -+ cmd->macro_id = die_id * die_macro_num + k; -+ cmd->start_sds_id = 0; -+ cmd->sds_num = macro_info[k].ds_num; -+ for (p = 0; p < sizeof(subcmd_list) / sizeof(subcmd_list[0]); p++) { -+ cmd->sub_cmd = subcmd_list[p]; -+ printf("hikptool serdes_info -i %u -s m%ud%u -n %u %s\n", -+ cmd->chip_id, cmd->macro_id, cmd->start_sds_id, -+ cmd->sds_num, info_cmd_str[cmd->sub_cmd]); -+ ret = hikp_serdes_get_reponse(cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("collect chip%u die%u macro%u " -+ "serdes_info%u failed: %d\n", -+ cmd->chip_id, die_id, k, subcmd_list[p], ret); -+ -+ if (ret == -EINVAL) -+ return ret; -+ } -+ } -+ } -+ -+ return 0; -+} -+ -+static void collect_serdes_info_log(void) -+{ -+ struct cmd_serdes_param serdes_info_cmd = {0}; -+ unsigned char chip_num = MAX_CHIP_NUM_SUPPORT; -+ unsigned char die_num = serdes_get_die_num(); -+ char log_name[MAX_LOG_NAME_LEN] = {0}; -+ struct serdes_log_cmd log_cmd = {0}; -+ bool stop = false; -+ unsigned char i, j; -+ int ret; -+ -+ serdes_info_cmd.cmd_type = SERDES_KEY_INFO; -+ for (i = 0; i < chip_num; i++) { -+ for (j = 0; j < die_num; j++) { -+ serdes_info_cmd.chip_id = i; -+ log_cmd.cmd = &serdes_info_cmd; -+ log_cmd.die_id = j; -+ ret = snprintf(log_name, MAX_LOG_NAME_LEN, "serdes_info_c%ud%u", i, j); -+ if (ret < 0 || (uint32_t)(ret) >= MAX_LOG_NAME_LEN) { -+ HIKP_ERROR_PRINT("create serdes_info log name failed\n"); -+ break; -+ } -+ ret = hikp_collect_log(GROUP_SERDES, log_name, -+ collect_serdes_info_process, -+ (void *)&log_cmd); -+ if (ret) { -+ /* -+ * Stop collection when the die id is 0 and ret is -EINVAL, -+ * indicating that the current chip id is not supported. -+ */ -+ if (j == 0 && ret == -EINVAL) -+ stop = true; -+ -+ if (ret == -EINVAL) -+ break; -+ -+ HIKP_ERROR_PRINT("%s chip%u die%u failed: %d\n", __func__, -+ i, j, ret); -+ } -+ } -+ -+ if (stop) -+ break; -+ } -+} -+ -+static int collect_serdes_dump_process(void *data) -+{ -+ const char *dump_cmd_str[HILINK_DUMP_TYPE_END] = {"cs", "ds", "csds", "ram", "subctrl"}; -+ struct serdes_log_cmd *log_cmd = (struct serdes_log_cmd *)data; -+ struct serdes_macro_info *macro_info = serdes_get_macro_info(); -+ unsigned char die_macro_num = serdes_get_die_macro_num(); -+ struct cmd_serdes_param *cmd = log_cmd->cmd; -+ unsigned char die_id = log_cmd->die_id; -+ unsigned char subcmd_list[] = {0, 1, 4}; /* 0, 1, 4: cs, ds, subctrl reg */ -+ unsigned char k, p, q; -+ int ret; -+ -+ for (k = 0; k < die_macro_num; k++) { -+ cmd->macro_id = die_id * die_macro_num + k; -+ for (q = 0; q < macro_info[k].ds_num; q++) { -+ cmd->start_sds_id = q; -+ cmd->sds_num = 1; -+ for (p = 0; p < sizeof(subcmd_list) / sizeof(subcmd_list[0]); p++) { -+ cmd->sub_cmd = subcmd_list[p]; -+ printf("hikptool serdes_dump -i %u -s m%ud%u -c %s\n", -+ cmd->chip_id, cmd->macro_id, cmd->start_sds_id, -+ dump_cmd_str[cmd->sub_cmd]); -+ ret = hikp_serdes_get_reponse(cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("collect chip%u die%u macro%u lane%u " -+ "serdes_dump%u failed: %d\n", -+ cmd->chip_id, die_id, k, q, -+ subcmd_list[p], ret); -+ -+ if (ret == -EINVAL) -+ return ret; -+ } -+ } -+ } -+ } -+ -+ return 0; -+} -+ -+static void collect_serdes_dump_log(void) -+{ -+ struct cmd_serdes_param serdes_dump_cmd = {0}; -+ unsigned char chip_num = MAX_CHIP_NUM_SUPPORT; -+ unsigned char die_num = serdes_get_die_num(); -+ struct serdes_log_cmd log_cmd = {0}; -+ char log_name[MAX_LOG_NAME_LEN] = {0}; -+ unsigned char i, j; -+ bool stop = false; -+ int ret; -+ -+ serdes_dump_cmd.cmd_type = SERDES_DUMP_REG; -+ for (i = 0; i < chip_num; i++) { -+ for (j = 0; j < die_num; j++) { -+ serdes_dump_cmd.chip_id = i; -+ log_cmd.cmd = &serdes_dump_cmd; -+ log_cmd.die_id = j; -+ ret = snprintf(log_name, MAX_LOG_NAME_LEN, "serdes_dump_c%ud%u", i, j); -+ if (ret < 0 || (uint32_t)(ret) >= MAX_LOG_NAME_LEN) { -+ HIKP_ERROR_PRINT("create serdes_info log name failed\n"); -+ break; -+ } -+ ret = hikp_collect_log(GROUP_SERDES, log_name, -+ collect_serdes_dump_process, -+ (void *)&log_cmd); -+ if (ret) { -+ /* -+ * Stop collection when the die id is 0 and ret is -EINVAL, -+ * indicating that the current chip id is not supported. -+ */ -+ if (j == 0 && ret == -EINVAL) -+ stop = true; -+ -+ if (ret == -EINVAL) -+ break; -+ -+ HIKP_ERROR_PRINT("%s chip%u die%u failed: %d\n", __func__, -+ i, j, ret); -+ } -+ } -+ -+ if (stop) -+ break; -+ } -+} -+ -+void collect_serdes_log(void) -+{ -+ collect_serdes_info_log(); -+ collect_serdes_dump_log(); -+} -diff --git a/info_collect/hikp_collect_socip.c b/info_collect/hikp_collect_socip.c -new file mode 100644 -index 0000000..6bccf6a ---- /dev/null -+++ b/info_collect/hikp_collect_socip.c -@@ -0,0 +1,272 @@ -+/* -+ * Copyright (c) 2024 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 -+#include "hikp_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+#include "hikptdev_plug.h" -+#include "hikp_socip.h" -+#include "hikp_collect_socip.h" -+ -+#define SOCIP_MODULENUM 7 -+#define MAX_CHIPNUM 30 -+ -+enum socip_collect_type { -+ GPIO, -+ SPI, -+ I2C, -+ SFC, -+ USB, -+ UART, -+ BT, -+}; -+ -+const char *g_socip_modulename[SOCIP_MODULENUM] = { -+ "gpio", -+ "spi", -+ "i2c", -+ "sfc", -+ "usb", -+ "uart", -+ "bt", -+}; -+ -+struct info_collect_cmd gpio_cmd_arr[] = { -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "gpio", -+ .args = {"cat", "/sys/kernel/debug/gpio", NULL}, -+ }, -+}; -+ -+struct info_collect_cmd spi_cmd_arr[] = { -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "spi", -+ .args = {"cat", "/sys/kernel/debug/dw_spi*/registers", NULL}, -+ }, -+ -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "spi", -+ .args = {"cat", "/sys/kernel/debug/hisi_spi*/registers", NULL}, -+ }, -+ -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "spi", -+ .args = {"cat", "/sys/class/spi_master/spi*/statistics/bytes", NULL}, -+ }, -+ -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "spi", -+ .args = {"cat", "/sys/class/spi_master/spi*/statistics/bytes_rx", NULL}, -+ }, -+ -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "spi", -+ .args = {"cat", "/sys/class/spi_master/spi*/statistics/bytes_tx", NULL}, -+ }, -+}; -+ -+struct info_collect_cmd i2c_cmd_arr[] = { -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "i2c", -+ .args = {"ls", "/sys/class/i2c-adapter", NULL}, -+ }, -+ -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "i2c", -+ .args = {"ls", "/sys/class/i2c-dev", NULL}, -+ }, -+}; -+ -+struct info_collect_cmd sfc_cmd_arr[] = { -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "sfc", -+ .args = {"mtd_debug", "info", "/dev/mtd0", NULL}, -+ }, -+}; -+ -+struct info_collect_cmd usb_cmd_arr[] = { -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "usb", -+ .args = {"cat", "/sys/kernel/debug/usb/devices", NULL}, -+ }, -+}; -+ -+struct info_collect_cmd uart_cmd_arr[] = { -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "uart", -+ .args = {"stty", "-F", "/dev/ttyAMA0", "-a", NULL}, -+ }, -+ -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "uart", -+ .args = {"cat", "/proc/tty/driver/ttyAMA", NULL}, -+ }, -+}; -+ -+struct info_collect_cmd bt_cmd_arr[] = { -+ { -+ .group = GROUP_SOCIP, -+ .log_name = "bt", -+ .args = {"ls", "/dev/ipmi0", NULL}, -+ }, -+}; -+ -+static int socip_get_dumpregparam(struct socip_collect_dumpreg_req req_struct, -+ struct socip_dump_reg_req_data_t *req_data_ptr, uint8_t chip_id, int controller_num) -+{ -+ req_data_ptr->controller_id = req_struct.controller_id[controller_num]; -+ if (req_data_ptr->controller_id == CONTROLLER_MAX_NUM) -+ return -EINVAL; -+ -+ req_data_ptr->chip_id = chip_id; -+ req_data_ptr->die_id = req_struct.die_id; -+ return 0; -+} -+ -+static int collect_socip_dumpreglog(void *version) -+{ -+ size_t i, msize; -+ uint8_t chip_id; -+ uint32_t cpu_version = *(uint32_t *)version; -+ int controller_num, ret; -+ struct hikp_cmd_ret *cmd_ret; -+ struct socip_collect_dumpreg_req *req_struct; -+ struct socip_dump_reg_req_data_t req_data = {0}; -+ struct hikp_cmd_header req_header = {0}; -+ -+ switch (cpu_version) { -+ case CHIP_HIP09: -+ case CHIP_HIP10: -+ case CHIP_HIP10C: -+ req_struct = socip_hip09_hip10x_reg_arr; -+ msize = HIKP_ARRAY_SIZE(socip_hip09_hip10x_reg_arr); -+ break; -+ case CHIP_HIP11: -+ req_struct = socip_hip11_reg_arr; -+ msize = HIKP_ARRAY_SIZE(socip_hip11_reg_arr); -+ break; -+ default: -+ HIKP_ERROR_PRINT("Cpu version not support.\n"); -+ return 0; -+ } -+ -+ for (chip_id = 0; chip_id < MAX_CHIPNUM; chip_id++) { -+ for (i = 0; i < msize; i++) { -+ controller_num = 0; -+ while(controller_num < CONTROLLER_MAX_NUM) { -+ struct socip_dump_reg_req_data_t *req_data_ptr = &req_data; -+ ret = socip_get_dumpregparam(req_struct[i], req_data_ptr, chip_id, controller_num); -+ if (ret) -+ break; -+ -+ hikp_cmd_init(&req_header, SOCIP_MOD, HIKP_SOCIP_CMD_DUMPREG, -+ req_struct[i].module); -+ cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -+ if (!cmd_ret || cmd_ret->status != 0) { -+ HIKP_ERROR_PRINT("hikp_cmd_alloc failed\n"); -+ hikp_cmd_free(&cmd_ret); -+ return 0; -+ } -+ printf("%s\n", req_struct[i].reg_info); -+ printf("hikptool socip_dumpreg -c %u -d %u -m %u -i %u\n",req_data.chip_id, -+ req_data.die_id, req_struct[i].module, req_data.controller_id); -+ dump_reg_info(&cmd_ret->rsp_data[0], cmd_ret->rsp_data_num); -+ hikp_cmd_free(&cmd_ret); -+ controller_num++; -+ } -+ } -+ } -+ -+ return 0; -+} -+ -+static int collect_socip_modulelog(void *module) -+{ -+ size_t i, msize; -+ int ret; -+ -+ switch (*(int *)module) { -+ case GPIO: -+ msize = HIKP_ARRAY_SIZE(gpio_cmd_arr); -+ for (i = 0; i < msize; i++) -+ ret = hikp_collect_exec((void *)&gpio_cmd_arr[i]); -+ break; -+ case SPI: -+ msize = HIKP_ARRAY_SIZE(spi_cmd_arr); -+ for (i = 0; i < msize; i++) -+ ret = hikp_collect_cat_glob_exec((void *)&spi_cmd_arr[i]); -+ break; -+ case I2C: -+ msize = HIKP_ARRAY_SIZE(i2c_cmd_arr); -+ for (i = 0; i < msize; i++) -+ ret = hikp_collect_exec((void *)&i2c_cmd_arr[i]); -+ break; -+ case SFC: -+ msize = HIKP_ARRAY_SIZE(sfc_cmd_arr); -+ for (i = 0; i < msize; i++) -+ ret = hikp_collect_exec((void *)&sfc_cmd_arr[i]); -+ break; -+ case USB: -+ msize = HIKP_ARRAY_SIZE(usb_cmd_arr); -+ for (i = 0; i < msize; i++) -+ ret = hikp_collect_exec((void *)&usb_cmd_arr[i]); -+ break; -+ case UART: -+ msize = HIKP_ARRAY_SIZE(uart_cmd_arr); -+ for (i = 0; i < msize; i++) -+ ret = hikp_collect_exec((void *)&uart_cmd_arr[i]); -+ break; -+ case BT: -+ msize = HIKP_ARRAY_SIZE(bt_cmd_arr); -+ for (i = 0; i < msize; i++) -+ ret = hikp_collect_exec((void *)&bt_cmd_arr[i]); -+ break; -+ default: -+ ret = 0; -+ break; -+ } -+ -+ return ret; -+} -+ -+void collect_socip_log(void) -+{ -+ int i, ret; -+ uint32_t cpu_version = get_chip_type(); -+ -+ for (i = 0; i < SOCIP_MODULENUM; i++) { -+ ret = hikp_collect_log(GROUP_SOCIP, (char *)g_socip_modulename[i], -+ collect_socip_modulelog, (void *)&i); -+ if (ret) { -+ HIKP_ERROR_PRINT("collect_socip_log %s arr failed: %d\n", -+ g_socip_modulename[i], ret); -+ } -+ } -+ -+ ret = hikp_collect_log(GROUP_SOCIP, "dumpreg", collect_socip_dumpreglog, (void *)&cpu_version); -+ if (ret) -+ HIKP_ERROR_PRINT("collect_socip_log dumpreg failed: %d\n", ret); -+} -diff --git a/info_collect/hikp_collect_socip.h b/info_collect/hikp_collect_socip.h -new file mode 100644 -index 0000000..b8bb879 ---- /dev/null -+++ b/info_collect/hikp_collect_socip.h -@@ -0,0 +1,238 @@ -+/* -+ * Copyright (c) 2024 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_COLLECT_SOCIP_H -+#define HIKP_COLLECT_SOCIP_H -+ -+#define MIN_DIE_ID 0 -+#define NIMBUS_A_ID 0 -+#define TOTEM_A_ID 1 -+#define NIMBUS_B_ID 2 -+#define TOTEM_C_ID 2 -+#define TOTEM_B_ID 3 -+#define INVALID_DIE_ID 0xFF -+#define MAX_DIE_ID 3 -+#define CONTROLLER_MAX_NUM 12 -+ -+#define DIE_MIN_INDEX 0 -+#define CPUDIE_MIN_INDEX 0 -+#define CPUDIE_A_INDEX 0 -+#define CPUDIE_B_INDEX 1 -+#define CPUDIE_MAX_INDEX 1 -+#define IODIE_MIN_INDEX 2 -+#define IODIE_A0_INDEX 2 -+#define IODIE_A1_INDEX 3 -+#define IODIE_B0_INDEX 4 -+#define IODIE_B1_INDEX 5 -+#define IODIE_MAX_INDEX 5 -+#define DIE_MAX_INDEX 5 -+ -+struct socip_collect_dumpreg_req { -+ char *reg_info; -+ uint8_t module; -+ uint8_t die_id; -+ uint8_t controller_id[CONTROLLER_MAX_NUM]; -+}; -+ -+struct socip_collect_dumpreg_req socip_hip09_hip10x_reg_arr[] = { -+ { -+ .reg_info = "gpio_NA", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_GPIO, -+ .die_id = NIMBUS_A_ID, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "gpio_NB", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_GPIO, -+ .die_id = NIMBUS_B_ID, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "gpio_TA", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_GPIO, -+ .die_id = TOTEM_A_ID, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "gpio_TB", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_GPIO, -+ .die_id = TOTEM_B_ID, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "i2c_NA", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_I2C, -+ .die_id = NIMBUS_A_ID, -+ .controller_id = {0, 1, 5, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "i2c_NB", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_I2C, -+ .die_id = NIMBUS_A_ID, -+ .controller_id = {0, 1, 5, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "spi_NA", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_SPI, -+ .die_id = NIMBUS_A_ID, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "spi_NB", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_SPI, -+ .die_id = NIMBUS_B_ID, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "sfc_NA", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_SFC, -+ .die_id = NIMBUS_A_ID, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "sfc_NB", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_SFC, -+ .die_id = NIMBUS_B_ID, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "btc_NA", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_SFC, -+ .die_id = NIMBUS_A_ID, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "btc_NB", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_SFC, -+ .die_id = NIMBUS_B_ID, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+}; -+ -+struct socip_collect_dumpreg_req socip_hip11_reg_arr[] = { -+ { -+ .reg_info = "gpio_IOA0", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_GPIO, -+ .die_id = IODIE_A0_INDEX, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "gpio_IOA1", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_GPIO, -+ .die_id = IODIE_A1_INDEX, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "gpio_IOB0", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_GPIO, -+ .die_id = IODIE_B0_INDEX, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "gpio_IOB1", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_GPIO, -+ .die_id = IODIE_B1_INDEX, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "gpio_CA", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_GPIO, -+ .die_id = CPUDIE_A_INDEX, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "gpio_CB", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_GPIO, -+ .die_id = CPUDIE_B_INDEX, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "i2c_IOA0", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_I2C, -+ .die_id = IODIE_A0_INDEX, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "i2c_IOA1", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_I2C, -+ .die_id = IODIE_A1_INDEX, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "i2c_IOB0", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_I2C, -+ .die_id = IODIE_B0_INDEX, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "i2c_IOB1", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_I2C, -+ .die_id = IODIE_B1_INDEX, -+ .controller_id = {0, 1, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "i2c_CA", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_I2C, -+ .die_id = CPUDIE_A_INDEX, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "i2c_CB", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_I2C, -+ .die_id = CPUDIE_B_INDEX, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "spi_CB", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_SPI, -+ .die_id = CPUDIE_B_INDEX, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "sfc_CA", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_SFC, -+ .die_id = CPUDIE_A_INDEX, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+ -+ { -+ .reg_info = "BTC_IOB0", -+ .module = HIKP_SOCIP_SUBCMD_DUMPREG_SFC, -+ .die_id = IODIE_B0_INDEX, -+ .controller_id = {0, CONTROLLER_MAX_NUM}, -+ }, -+}; -+#endif /* HIKP_COLLECT_SOCIP_H */ -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c -index c42b8e7..3bc4e05 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.c -+++ b/net/nic/nic_dfx/hikp_nic_dfx.c -@@ -404,6 +404,13 @@ static const struct dfx_type_name_parse g_dfx_ssu_name_parse[] = { - dfx_ssu_type_64_tx_comm_stats, HIKP_ARRAY_SIZE(dfx_ssu_type_64_tx_comm_stats)}, - }; - -+void hikp_nic_dfx_set_cmd_para(int idx) -+{ -+ g_dfx_param.sub_cmd_code = g_dfx_module_parse[idx].sub_cmd_code; -+ g_dfx_param.module_idx = idx; -+ g_dfx_param.flag |= MODULE_SET_FLAG; -+} -+ - static void dfx_help_info(const struct major_cmd_ctrl *self) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -421,7 +428,7 @@ static int hikp_cmd_dfx_help(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - --static int hikp_nic_cmd_dfx_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_cmd_dfx_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_dfx_param.target)); - if (self->err_no != 0) { -@@ -714,7 +721,7 @@ static void hikp_nic_dfx_print(const struct nic_dfx_rsp_head_t *rsp_head, uint32 - printf("################### ====== dump end ====== ######################\n"); - } - --static void hikp_nic_dfx_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_dfx_cmd_execute(struct major_cmd_ctrl *self) - { - struct nic_dfx_rsp_head_t rsp_head = { 0 }; - struct nic_dfx_rsp_head_t tmp_head = { 0 }; -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.h b/net/nic/nic_dfx/hikp_nic_dfx.h -index 38f76aa..d77bbc3 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.h -+++ b/net/nic/nic_dfx/hikp_nic_dfx.h -@@ -149,4 +149,7 @@ struct dfx_type_name_parse { - uint32_t reg_num; - }; - -+int hikp_nic_cmd_dfx_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_dfx_cmd_execute(struct major_cmd_ctrl *self); -+void hikp_nic_dfx_set_cmd_para(int idx); - #endif /* HIKP_NIC_DFX_H */ -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index fb9333a..d19d7c8 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -109,6 +109,13 @@ static const struct fd_feature_cmd g_fd_feature_cmd[] = { - hikp_nic_query_fd_counter, hikp_nic_show_fd_counter}, - }; - -+void hikp_nic_set_fd_idx(int feature_idx, int stage_no) -+{ -+ g_fd_param.id = -1; -+ g_fd_param.feature_idx = feature_idx; -+ g_fd_param.stage_no = stage_no; -+} -+ - static int hikp_nic_fd_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -@@ -923,7 +930,7 @@ static int hikp_nic_fd_check_input_param(struct major_cmd_ctrl *self, - return 0; - } - --static void hikp_nic_fd_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_fd_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_fd_param.target.bdf; - const struct fd_feature_cmd *fd_cmd; -@@ -983,7 +990,7 @@ out: - hikp_nic_fd_data_free(fd_data); - } - --static int hikp_nic_cmd_get_fd_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_cmd_get_fd_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_fd_param.target)); - if (self->err_no != 0) { -diff --git a/net/nic/nic_fd/hikp_nic_fd.h b/net/nic/nic_fd/hikp_nic_fd.h -index 3f409d0..ce363c9 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.h -+++ b/net/nic/nic_fd/hikp_nic_fd.h -@@ -224,4 +224,8 @@ struct fd_feature_cmd { - void (*show)(const void *data); - }; - -+int hikp_nic_cmd_get_fd_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_fd_cmd_execute(struct major_cmd_ctrl *self); -+void hikp_nic_set_fd_idx(int feature_idx, int stage_no); -+ - #endif /* HIKP_NIC_FD_H */ -diff --git a/net/nic/nic_fec/hikp_nic_fec.c b/net/nic/nic_fec/hikp_nic_fec.c -index 5a34bfd..13c6e13 100644 ---- a/net/nic/nic_fec/hikp_nic_fec.c -+++ b/net/nic/nic_fec/hikp_nic_fec.c -@@ -108,7 +108,7 @@ static void hikp_nic_fec_err_show(const struct nic_fec_err_info *info) - printf("#################### END #######################\n"); - } - --static void hikp_nic_fec_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_fec_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_fec_target.bdf; - struct nic_fec_err_info info = { 0 }; -@@ -136,7 +136,7 @@ static int hikp_nic_fec_cmd_help(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - --static int hikp_nic_fec_get_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_fec_get_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_fec_target); - if (self->err_no != 0) { -diff --git a/net/nic/nic_fec/hikp_nic_fec.h b/net/nic/nic_fec/hikp_nic_fec.h -index 7996273..79a87b5 100644 ---- a/net/nic/nic_fec/hikp_nic_fec.h -+++ b/net/nic/nic_fec/hikp_nic_fec.h -@@ -69,4 +69,6 @@ struct nic_fec_err_info { - }; - }; - -+int hikp_nic_fec_get_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_fec_cmd_execute(struct major_cmd_ctrl *self); - #endif /* HIKP_NIC_FEC_H */ -diff --git a/net/nic/nic_ft/hikp_nic_port_fault.c b/net/nic/nic_ft/hikp_nic_port_fault.c -index 5f78cdd..331b1ec 100644 ---- a/net/nic/nic_ft/hikp_nic_port_fault.c -+++ b/net/nic/nic_ft/hikp_nic_port_fault.c -@@ -80,7 +80,7 @@ static void hikp_nic_port_fault_show(struct nic_port_fault_status *info) - printf("#################### END #######################\n"); - } - --static void hikp_nic_port_fault_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_port_fault_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_port_fault_target.bdf; - struct nic_port_fault_status info = { 0 }; -@@ -108,7 +108,7 @@ static int hikp_nic_port_fault_cmd_help(struct major_cmd_ctrl *self, const char - return 0; - } - --static int hikp_nic_port_fault_get_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_port_fault_get_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_port_fault_target); - if (self->err_no != 0) { -diff --git a/net/nic/nic_ft/hikp_nic_port_fault.h b/net/nic/nic_ft/hikp_nic_port_fault.h -index 7db54f7..9c7e4b2 100644 ---- a/net/nic/nic_ft/hikp_nic_port_fault.h -+++ b/net/nic/nic_ft/hikp_nic_port_fault.h -@@ -51,4 +51,6 @@ struct nic_port_fault_status { - uint8_t hilink_ref_status; - }; - -+int hikp_nic_port_fault_get_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_port_fault_cmd_execute(struct major_cmd_ctrl *self); - #endif /* HIKP_NIC_PORT_FAULT_H */ -diff --git a/net/nic/nic_gro/hikp_nic_gro.c b/net/nic/nic_gro/hikp_nic_gro.c -index 19395af..d821a47 100644 ---- a/net/nic/nic_gro/hikp_nic_gro.c -+++ b/net/nic/nic_gro/hikp_nic_gro.c -@@ -53,7 +53,7 @@ static void hikp_nic_gro_show(const struct nic_gro_info *info) - printf("#################### END #######################\n"); - } - --static void hikp_nic_gro_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_gro_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_gro_target.bdf; - struct nic_gro_info info = { 0 }; -@@ -81,7 +81,7 @@ static int hikp_nic_gro_cmd_help(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - --static int hikp_nic_gro_get_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_gro_get_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_gro_target); - if (self->err_no != 0) { -diff --git a/net/nic/nic_gro/hikp_nic_gro.h b/net/nic/nic_gro/hikp_nic_gro.h -index 49328e6..ae58703 100644 ---- a/net/nic/nic_gro/hikp_nic_gro.h -+++ b/net/nic/nic_gro/hikp_nic_gro.h -@@ -43,4 +43,6 @@ struct nic_gro_info { - uint32_t max_coal_bd_num; - }; - -+int hikp_nic_gro_get_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_gro_cmd_execute(struct major_cmd_ctrl *self); - #endif /* HIKP_NIC_GRO_H */ -diff --git a/net/nic/nic_info/hikp_nic_info.c b/net/nic/nic_info/hikp_nic_info.c -index 49f143f..6fb17a2 100644 ---- a/net/nic/nic_info/hikp_nic_info.c -+++ b/net/nic/nic_info/hikp_nic_info.c -@@ -37,7 +37,7 @@ static int hikp_nic_cmd_get_info_help(struct major_cmd_ctrl *self, const char *a - return 0; - } - --static int hikp_nic_cmd_get_info_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_cmd_get_info_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_info_param.target)); - if (self->err_no != 0) { -@@ -305,7 +305,7 @@ static void hikp_nic_info_print_cur_vf(const struct bdf_t *bdf) - } - } - --static void hikp_nic_info_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_info_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_info_param.target.bdf; - -diff --git a/net/nic/nic_info/hikp_nic_info.h b/net/nic/nic_info/hikp_nic_info.h -index b1dd7dc..83323e8 100644 ---- a/net/nic/nic_info/hikp_nic_info.h -+++ b/net/nic/nic_info/hikp_nic_info.h -@@ -77,4 +77,6 @@ enum nic_info_mac_type { - MAC_TYPE_MAX, - }; - -+void hikp_nic_info_cmd_execute(struct major_cmd_ctrl *self); -+int hikp_nic_cmd_get_info_target(struct major_cmd_ctrl *self, const char *argv); - #endif /* HIKP_NIC_INFO_H */ -diff --git a/net/nic/nic_log/hikp_nic_log.c b/net/nic/nic_log/hikp_nic_log.c -index f182d25..be23ca3 100644 ---- a/net/nic/nic_log/hikp_nic_log.c -+++ b/net/nic/nic_log/hikp_nic_log.c -@@ -23,6 +23,7 @@ - #include "hikp_nic_log.h" - - static struct log_param g_log_param = { 0 }; -+static char g_log_path[OP_LOG_FILE_PATH_MAXLEN] = {0}; - - static int hikp_nic_cmd_log_help(struct major_cmd_ctrl *self, const char *argv) - { -@@ -49,7 +50,6 @@ static int hikp_nic_cmd_log_target(struct major_cmd_ctrl *self, const char *argv - - static int hikp_nic_write_data_to_file(uint8_t *data, uint32_t len) - { -- uint8_t file_path[OP_LOG_FILE_PATH_MAXLEN] = { 0 }; - uint8_t file_name[MAX_LOG_NAME_LEN] = { 0 }; - size_t write_cnt; - FILE *fp = NULL; -@@ -59,23 +59,23 @@ static int hikp_nic_write_data_to_file(uint8_t *data, uint32_t len) - if (ret < 0) - return ret; - -- ret = snprintf((char *)file_path, sizeof(file_path), HIKP_LOG_DIR_PATH"%s", file_name); -+ ret = snprintf(g_log_path, sizeof(g_log_path), HIKP_LOG_DIR_PATH"%s", file_name); - if (ret < 0) { - HIKP_ERROR_PRINT("creat log file path fail.\n"); - return -EIO; - } -- (void)remove((const char *)file_path); -- fp = fopen((char *)file_path, "w+"); -+ (void)remove((const char *)g_log_path); -+ fp = fopen(g_log_path, "w+"); - if (fp == NULL) { -- HIKP_ERROR_PRINT("open %s failed, errno is %d\n", file_path, errno); -+ HIKP_ERROR_PRINT("open %s failed, errno is %d\n", g_log_path, errno); - return -errno; - } - write_cnt = fwrite(data, 1, len, fp); - if (write_cnt != len) -- HIKP_ERROR_PRINT("write %s failed, write cnt %lu.\n", file_path, write_cnt); -+ HIKP_ERROR_PRINT("write %s failed, write cnt %lu.\n", g_log_path, write_cnt); - -- printf("dump m7 log completed, log file: %s.\n", file_path); -- (void)chmod((char *)file_path, 0440); -+ printf("dump m7 log completed, log file: %s.\n", g_log_path); -+ (void)chmod(g_log_path, 0440); - (void)fclose(fp); - return 0; - } -@@ -199,6 +199,29 @@ static void hikp_nic_log_cmd_execute(struct major_cmd_ctrl *self) - self->err_no = hikp_nic_dump_m7_log(self); - } - -+const char *hikp_info_collect_get_log_path(void) -+{ -+ return (const char *)g_log_path; -+} -+ -+int hikp_info_collect_nic_log(void *data) -+{ -+ struct nic_log_collect_param *param = (struct nic_log_collect_param *)data; -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ int ret; -+ -+ memset(&g_log_param, 0, sizeof(g_log_param)); -+ -+ ret = hikp_nic_cmd_log_target(major_cmd, param->net_dev_name); -+ if (ret) -+ return ret; -+ -+ printf("hikptool nic_log -i %s\n", param->net_dev_name); -+ hikp_nic_log_cmd_execute(major_cmd); -+ -+ return ret; -+} -+ - static void cmd_nic_log_init(void) - { - struct major_cmd_ctrl *major_cmd = get_major_cmd(); -diff --git a/net/nic/nic_log/hikp_nic_log.h b/net/nic/nic_log/hikp_nic_log.h -index 2998464..cff1980 100644 ---- a/net/nic/nic_log/hikp_nic_log.h -+++ b/net/nic/nic_log/hikp_nic_log.h -@@ -38,4 +38,11 @@ struct log_param { - struct tool_target target; - }; - -+struct nic_log_collect_param { -+ const char *net_dev_name; -+}; -+ -+const char *hikp_info_collect_get_log_path(void); -+int hikp_info_collect_nic_log(void *data); -+ - #endif /* HIKP_NIC_LOG_H */ -diff --git a/net/nic/nic_mac/hikp_nic_mac_dump.c b/net/nic/nic_mac/hikp_nic_mac_dump.c -index 5439c71..751953c 100644 ---- a/net/nic/nic_mac/hikp_nic_mac_dump.c -+++ b/net/nic/nic_mac/hikp_nic_mac_dump.c -@@ -184,7 +184,7 @@ static int mac_cmd_dump_para_check(struct major_cmd_ctrl *self) - return 0; - } - --static void mac_cmd_dump_execute(struct major_cmd_ctrl *self) -+void mac_cmd_dump_execute(struct major_cmd_ctrl *self) - { - int ret; - -@@ -203,7 +203,7 @@ static void mac_cmd_dump_execute(struct major_cmd_ctrl *self) - mac_cmd_dump_module(self, g_dump_reg_info.module_name); - } - --static int mac_cmd_dump_reg_target(struct major_cmd_ctrl *self, const char *argv) -+int mac_cmd_dump_reg_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_dump_reg_info.target); - if (self->err_no) { -@@ -233,13 +233,35 @@ static int mac_cmd_dump_reg_help(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - --static int mac_cmd_dump_module_cfg(struct major_cmd_ctrl *self, const char *argv) -+int mac_cmd_dump_module_cfg(struct major_cmd_ctrl *self, const char *argv) - { - g_dump_reg_info.module_name = argv; - - return 0; - } - -+int hikp_info_collect_nic_mac(void *data) -+{ -+ struct nic_mac_collect_param *param = (struct nic_mac_collect_param *)data; -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ int ret; -+ -+ memset(&g_dump_reg_info, 0, sizeof(g_dump_reg_info)); -+ -+ ret = mac_cmd_dump_reg_target(major_cmd, param->net_dev_name); -+ if (ret) -+ return ret; -+ -+ ret = mac_cmd_dump_module_cfg(major_cmd, param->module_name); -+ if (ret) -+ return ret; -+ -+ printf("hikptool nic_mac -i %s -m %s\n", param->net_dev_name, param->module_name); -+ mac_cmd_dump_execute(major_cmd); -+ -+ return ret; -+} -+ - static void cmd_mac_dump_reg_init(void) - { - struct major_cmd_ctrl *major_cmd = get_major_cmd(); -diff --git a/net/nic/nic_mac/hikp_nic_mac_dump.h b/net/nic/nic_mac/hikp_nic_mac_dump.h -index 0c58ad5..f74a99e 100644 ---- a/net/nic/nic_mac/hikp_nic_mac_dump.h -+++ b/net/nic/nic_mac/hikp_nic_mac_dump.h -@@ -60,4 +60,15 @@ struct cmd_mac_dump { - uint32_t blk_num[MOD_ID_MAX]; - const char *module_name; - }; -+ -+struct nic_mac_collect_param { -+ const char *net_dev_name; -+ const char *module_name; -+}; -+ -+int hikp_info_collect_nic_mac(void *data); -+ -+int mac_cmd_dump_module_cfg(struct major_cmd_ctrl *self, const char *argv); -+int mac_cmd_dump_reg_target(struct major_cmd_ctrl *self, const char *argv); -+void mac_cmd_dump_execute(struct major_cmd_ctrl *self); - #endif /* HIKP_NIC_MAC_DUMP_H */ -diff --git a/net/nic/nic_mac/hikp_nic_port.c b/net/nic/nic_mac/hikp_nic_port.c -index e28a040..737de07 100644 ---- a/net/nic/nic_mac/hikp_nic_port.c -+++ b/net/nic/nic_mac/hikp_nic_port.c -@@ -630,6 +630,24 @@ static int mac_cmd_port_show_help(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - -+int hikp_info_collect_nic_port(void *data) -+{ -+ struct nic_port_collect_param *param = (struct nic_port_collect_param *)data; -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ int ret; -+ -+ memset(&g_port_info, 0, sizeof(g_port_info)); -+ -+ ret = mac_cmd_get_port_target(major_cmd, param->net_dev_name); -+ if (ret) -+ return ret; -+ -+ printf("hikptool nic_port -i %s\n", param->net_dev_name); -+ mac_cmd_port_execute(major_cmd); -+ -+ return ret; -+} -+ - static void cmd_mac_get_port_init(void) - { - struct major_cmd_ctrl *major_cmd = get_major_cmd(); -diff --git a/net/nic/nic_mac/hikp_nic_port.h b/net/nic/nic_mac/hikp_nic_port.h -index 69ebb53..433eba4 100644 ---- a/net/nic/nic_mac/hikp_nic_port.h -+++ b/net/nic/nic_mac/hikp_nic_port.h -@@ -271,4 +271,10 @@ struct cmd_hot_plug_card_info { - uint8_t cur_type; - }; - -+struct nic_port_collect_param { -+ const char *net_dev_name; -+}; -+ -+int hikp_info_collect_nic_port(void *data); -+ - #endif /* HIKP_NIC_PORT_H */ -diff --git a/net/nic/nic_mac/hikp_nic_xsfp.c b/net/nic/nic_mac/hikp_nic_xsfp.c -index 573837b..91daa52 100644 ---- a/net/nic/nic_mac/hikp_nic_xsfp.c -+++ b/net/nic/nic_mac/hikp_nic_xsfp.c -@@ -734,6 +734,29 @@ static int hikp_xsfp_dump_raw_data(struct major_cmd_ctrl *self, const char *argv - return 0; - } - -+int hikp_info_collect_nic_xsfp(void *data) -+{ -+ struct nic_xsfp_collect_param *param = (struct nic_xsfp_collect_param *)data; -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ int ret; -+ -+ memset(&g_xsfp_dump, 0, sizeof(g_xsfp_dump)); -+ -+ ret = hikp_xsfp_get_target(major_cmd, param->net_dev_name); -+ if (ret) -+ return ret; -+ -+ printf("hikptool nic_xsfp -i %s\n", param->net_dev_name); -+ hikp_xsfp_get_info(major_cmd); -+ -+ printf("hikptool nic_xsfp -i %s -d\n", param->net_dev_name); -+ /* No need to judge the return value */ -+ (void)hikp_xsfp_dump_raw_data(major_cmd, NULL); -+ hikp_xsfp_get_info(major_cmd); -+ -+ return ret; -+} -+ - static void cmd_get_xsfp_info(void) - { - struct major_cmd_ctrl *major_cmd = get_major_cmd(); -diff --git a/net/nic/nic_mac/hikp_nic_xsfp.h b/net/nic/nic_mac/hikp_nic_xsfp.h -index 50cbb2d..7db9693 100644 ---- a/net/nic/nic_mac/hikp_nic_xsfp.h -+++ b/net/nic/nic_mac/hikp_nic_xsfp.h -@@ -549,4 +549,10 @@ struct hikp_xsfp_ctrl { - uint32_t dump_param; - }; - -+struct nic_xsfp_collect_param { -+ const char *net_dev_name; -+}; -+ -+int hikp_info_collect_nic_xsfp(void *data); -+ - #endif /* HIKP_NIC_XSFP_H */ -diff --git a/net/nic/nic_ncsi/hikp_nic_ncsi.c b/net/nic/nic_ncsi/hikp_nic_ncsi.c -index 2e1ea11..84f6337 100644 ---- a/net/nic/nic_ncsi/hikp_nic_ncsi.c -+++ b/net/nic/nic_ncsi/hikp_nic_ncsi.c -@@ -100,6 +100,24 @@ static int nic_ncsi_cmd_show_help(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - -+int hikp_info_collect_nic_ncsi(void *data) -+{ -+ struct nic_ncsi_collect_param *param = (struct nic_ncsi_collect_param *)data; -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ int ret; -+ -+ memset(&g_ncsi_cmd_info, 0, sizeof(g_ncsi_cmd_info)); -+ -+ ret = nic_ncsi_cmd_get_port_info(major_cmd, param->net_dev_name); -+ if (ret) -+ return ret; -+ -+ printf("hikptool nic_ncsi -i %s\n", param->net_dev_name); -+ nic_ncsi_cmd_execute(major_cmd); -+ -+ return ret; -+} -+ - static void cmd_nic_get_ncsi_init(void) - { - struct major_cmd_ctrl *major_cmd = get_major_cmd(); -diff --git a/net/nic/nic_ncsi/hikp_nic_ncsi.h b/net/nic/nic_ncsi/hikp_nic_ncsi.h -index a391d20..56ab653 100644 ---- a/net/nic/nic_ncsi/hikp_nic_ncsi.h -+++ b/net/nic/nic_ncsi/hikp_nic_ncsi.h -@@ -54,4 +54,10 @@ struct nic_ncsi_cmd_info { - bool port_flag; - }; - -+struct nic_ncsi_collect_param { -+ const char *net_dev_name; -+}; -+ -+int hikp_info_collect_nic_ncsi(void *data); -+ - #endif /* HIKP_NIC_NCSI_H */ -diff --git a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -index 5cd8bfa..4efaadc 100644 ---- a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -+++ b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -@@ -70,7 +70,7 @@ static void hikp_nic_notify_pkt_show(const struct nic_notify_pkt_info *info) - printf("####################### END ###########################\n"); - } - --static void hikp_nic_notify_pkt_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_notify_pkt_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_notify_pkt_target.bdf; - struct nic_notify_pkt_info info = {0}; -@@ -94,7 +94,7 @@ static int hikp_nic_notify_pkt_cmd_help(struct major_cmd_ctrl *self, const char - return 0; - } - --static int hikp_nic_notify_pkt_get_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_notify_pkt_get_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_notify_pkt_target); - if (self->err_no != 0) { -diff --git a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.h b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.h -index 8bdb795..26a86fe 100644 ---- a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.h -+++ b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.h -@@ -49,4 +49,6 @@ struct nic_notify_pkt_info { - #define HIKP_NOTIFY_PKT_CFG_PKT_NUM_M GENMASK(5, 2) - #define HIKP_NOTIFY_PKT_CFG_PKT_NUM_S 2 - -+int hikp_nic_notify_pkt_get_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_notify_pkt_cmd_execute(struct major_cmd_ctrl *self); - #endif /* HIKP_NIC_NOTIFY_PKT_H */ -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index aa63f12..24f41ee 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -57,6 +57,13 @@ static const struct ppp_feature_cmd g_ppp_feature_cmd[] = { - hikp_nic_query_ppp_by_blkid, hikp_nic_ppp_show_vlan_offload}, - }; - -+void hikp_nic_ppp_set_cmd_param(int feature_idx) -+{ -+ g_ppp_param.func_id = -1; -+ g_ppp_param.is_uc = -1; -+ g_ppp_param.feature_idx = feature_idx; -+} -+ - static int hikp_nic_ppp_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -@@ -1098,7 +1105,7 @@ static int hikp_nic_check_hw_res(struct hikp_nic_ppp_hw_resources *hw_res) - return 0; - } - --static void hikp_nic_ppp_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_ppp_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_ppp_param.target.bdf; - const struct ppp_feature_cmd *ppp_cmd; -@@ -1157,7 +1164,7 @@ out: - hikp_nic_ppp_data_free(ppp_data); - } - --static int hikp_nic_cmd_get_ppp_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_cmd_get_ppp_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ppp_param.target)); - if (self->err_no != 0) { -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.h b/net/nic/nic_ppp/hikp_nic_ppp.h -index 033ca4d..229e019 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.h -+++ b/net/nic/nic_ppp/hikp_nic_ppp.h -@@ -246,4 +246,7 @@ struct ppp_feature_cmd { - void (*show)(const void *data); - }; - -+void hikp_nic_ppp_set_cmd_param(int feature_idx); -+int hikp_nic_cmd_get_ppp_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_ppp_cmd_execute(struct major_cmd_ctrl *self); - #endif /* HIKP_NIC_PPP_H */ -diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c -index c620a08..dc6f63e 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.c -+++ b/net/nic/nic_qos/hikp_nic_qos.c -@@ -33,6 +33,16 @@ static const struct qos_feature_cmd g_qos_feature_cmd[] = { - hikp_nic_qos_show_pfc_storm_para}, - }; - -+void hikp_nic_qos_set_cmd_feature_idx(int feature_idx) -+{ -+ g_qos_param.feature_idx = feature_idx; -+} -+ -+void hikp_nic_qos_set_cmd_direction(enum nic_pfc_dir dir) -+{ -+ g_qos_param.dir = dir; -+} -+ - static int hikp_nic_qos_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -@@ -242,7 +252,7 @@ static int hikp_nic_query_qos_feature(struct hikp_cmd_header *req_header, const - return ret; - } - --static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self) - { - char *revision_id = g_qos_param.revision_id; - struct bdf_t *bdf = &g_qos_param.target.bdf; -@@ -265,7 +275,7 @@ static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self) - } - - if (g_qos_param.feature_idx == NIC_PFC_STORM_PARA_DUMP && -- g_qos_param.dir == NIC_QUEUE_DIR_NONE) { -+ g_qos_param.dir == NIC_QOS_DIR_NONE) { - hikp_nic_qos_cmd_help(self, NULL); - snprintf(self->err_str, sizeof(self->err_str), - "-d/--dir param error!"); -@@ -296,7 +306,7 @@ static void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self) - printf("#################### END #######################\n"); - } - --static int hikp_nic_cmd_get_qos_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_cmd_get_qos_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_qos_param.target)); - if (self->err_no != 0) { -@@ -330,11 +340,11 @@ static int hikp_nic_cmd_qos_direct(struct major_cmd_ctrl *self, - const char *argv) - { - if (strcmp(argv, "rx") == 0) { -- g_qos_param.dir = NIC_RX_QUEUE; -+ g_qos_param.dir = NIC_RX_QOS; - return 0; - } - if (strcmp(argv, "tx") == 0) { -- g_qos_param.dir = NIC_TX_QUEUE; -+ g_qos_param.dir = NIC_TX_QOS; - return 0; - } - -@@ -350,7 +360,7 @@ static void cmd_nic_get_qos_init(void) - struct major_cmd_ctrl *major_cmd = get_major_cmd(); - - g_qos_param.feature_idx = -1; -- g_qos_param.dir = NIC_QUEUE_DIR_NONE; -+ g_qos_param.dir = NIC_QOS_DIR_NONE; - - major_cmd->option_count = 0; - major_cmd->execute = hikp_nic_qos_cmd_execute; -diff --git a/net/nic/nic_qos/hikp_nic_qos.h b/net/nic/nic_qos/hikp_nic_qos.h -index 77fbdd9..6ff4e05 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.h -+++ b/net/nic/nic_qos/hikp_nic_qos.h -@@ -118,9 +118,9 @@ struct nic_qos_req_para { - }; - - enum nic_pfc_dir { -- NIC_RX_QUEUE = 0, -- NIC_TX_QUEUE, -- NIC_QUEUE_DIR_NONE, -+ NIC_RX_QOS = 0, -+ NIC_TX_QOS, -+ NIC_QOS_DIR_NONE, - }; - - struct nic_qos_param { -@@ -137,4 +137,8 @@ struct qos_feature_cmd { - void (*show)(const void *data); - }; - -+int hikp_nic_cmd_get_qos_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_qos_cmd_execute(struct major_cmd_ctrl *self); -+void hikp_nic_qos_set_cmd_feature_idx(int feature_idx); -+void hikp_nic_qos_set_cmd_direction(enum nic_pfc_dir dir); - #endif /* HIKP_NIC_QOS_H */ -diff --git a/net/nic/nic_queue/hikp_nic_queue.c b/net/nic/nic_queue/hikp_nic_queue.c -index dafa05e..5bb4335 100644 ---- a/net/nic/nic_queue/hikp_nic_queue.c -+++ b/net/nic/nic_queue/hikp_nic_queue.c -@@ -32,6 +32,14 @@ static const struct queue_feature_cmd g_queue_feature_cmd[] = { - {"func_map", QUEUE_FUNC_MAP, hikp_nic_queue_show_func_map}, - }; - -+void hikp_nic_queue_cmd_set_param(int feature_idx, int qid, enum nic_queue_dir dir) -+{ -+ g_queue_param.is_display_all = true; -+ g_queue_param.qid = qid; -+ g_queue_param.dir = dir; -+ g_queue_param.feature_idx = feature_idx; -+} -+ - static int hikp_nic_queue_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -@@ -340,7 +348,7 @@ static bool hikp_nic_queue_check_feature_para_vaild(const struct queue_feature_c - return valid; - } - --static void hikp_nic_queue_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_queue_cmd_execute(struct major_cmd_ctrl *self) - { - const struct queue_feature_cmd *queue_cmd; - union nic_queue_feature_info *queue_data; -@@ -387,7 +395,7 @@ out: - free(queue_data); - } - --static int hikp_nic_cmd_get_queue_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_cmd_get_queue_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_queue_param.target)); - if (self->err_no != 0) { -diff --git a/net/nic/nic_queue/hikp_nic_queue.h b/net/nic/nic_queue/hikp_nic_queue.h -index fac39a0..ca3541a 100644 ---- a/net/nic/nic_queue/hikp_nic_queue.h -+++ b/net/nic/nic_queue/hikp_nic_queue.h -@@ -152,4 +152,8 @@ struct queue_feature_cmd { - uint32_t sub_cmd_code; - void (*show)(const void *data); - }; -+ -+int hikp_nic_cmd_get_queue_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_queue_cmd_execute(struct major_cmd_ctrl *self); -+void hikp_nic_queue_cmd_set_param(int feature_idx, int qid, enum nic_queue_dir dir); - #endif /* HIKP_NIC_QUEUE_H */ -diff --git a/net/nic/nic_rss/hikp_nic_rss.c b/net/nic/nic_rss/hikp_nic_rss.c -index 65336ff..a7448e4 100644 ---- a/net/nic/nic_rss/hikp_nic_rss.c -+++ b/net/nic/nic_rss/hikp_nic_rss.c -@@ -132,6 +132,11 @@ static const struct rss_feature_cmd g_rss_feature_cmd[] = { - {"tc_mode", RSS_TC_MODE_DUMP, hikp_nic_rss_show_tc_mode}, - }; - -+void hikp_nic_rss_cmd_set_feature_idx(int feature_idx) -+{ -+ g_rss_param.feature_idx = feature_idx; -+} -+ - static int hikp_nic_rss_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -@@ -417,7 +422,7 @@ static int hikp_nic_query_rss_feature(struct hikp_cmd_header *req_header, const - return ret; - } - --static void hikp_nic_rss_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_rss_cmd_execute(struct major_cmd_ctrl *self) - { - union nic_rss_feature_info rss_data = {0}; - const struct rss_feature_cmd *rss_cmd; -@@ -446,7 +451,7 @@ static void hikp_nic_rss_cmd_execute(struct major_cmd_ctrl *self) - printf("#################### END #######################\n"); - } - --static int hikp_nic_cmd_get_rss_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_cmd_get_rss_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_rss_param.target)); - if (self->err_no != 0) { -diff --git a/net/nic/nic_rss/hikp_nic_rss.h b/net/nic/nic_rss/hikp_nic_rss.h -index 39b3300..47aa2b9 100644 ---- a/net/nic/nic_rss/hikp_nic_rss.h -+++ b/net/nic/nic_rss/hikp_nic_rss.h -@@ -91,4 +91,7 @@ struct rss_feature_cmd { - void (*show)(const void *data); - }; - -+int hikp_nic_cmd_get_rss_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_rss_cmd_execute(struct major_cmd_ctrl *self); -+void hikp_nic_rss_cmd_set_feature_idx(int feature_idx); - #endif /* HIKP_NIC_RSS_H */ -diff --git a/net/nic/nic_torus/hikp_nic_torus.c b/net/nic/nic_torus/hikp_nic_torus.c -index 5208bdc..d5e22b1 100644 ---- a/net/nic/nic_torus/hikp_nic_torus.c -+++ b/net/nic/nic_torus/hikp_nic_torus.c -@@ -130,7 +130,7 @@ static void hikp_nic_torus_show(const struct nic_torus_info *info) - printf("#################### END ##########################\n"); - } - --static void hikp_nic_torus_cmd_execute(struct major_cmd_ctrl *self) -+void hikp_nic_torus_cmd_execute(struct major_cmd_ctrl *self) - { - struct bdf_t *bdf = &g_torus_target.bdf; - struct nic_torus_info info = { 0 }; -@@ -158,7 +158,7 @@ static int hikp_nic_torus_cmd_help(struct major_cmd_ctrl *self, const char *argv - return 0; - } - --static int hikp_nic_torus_get_target(struct major_cmd_ctrl *self, const char *argv) -+int hikp_nic_torus_get_target(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_torus_target); - if (self->err_no != 0) { -diff --git a/net/nic/nic_torus/hikp_nic_torus.h b/net/nic/nic_torus/hikp_nic_torus.h -index e6b6552..064ffa3 100644 ---- a/net/nic/nic_torus/hikp_nic_torus.h -+++ b/net/nic/nic_torus/hikp_nic_torus.h -@@ -73,4 +73,6 @@ struct nic_torus_info { - uint32_t ets_tcg0_mapping; - }; - -+int hikp_nic_torus_get_target(struct major_cmd_ctrl *self, const char *argv); -+void hikp_nic_torus_cmd_execute(struct major_cmd_ctrl *self); - #endif /* HIKP_NIC_TORUS_H */ -diff --git a/net/roce/roce_bond/hikp_roce_bond.c b/net/roce/roce_bond/hikp_roce_bond.c -index 8434a0b..5256804 100644 ---- a/net/roce/roce_bond/hikp_roce_bond.c -+++ b/net/roce/roce_bond/hikp_roce_bond.c -@@ -15,6 +15,12 @@ - - static struct cmd_roce_bond_param g_roce_bond_param = { 0 }; - -+int hikp_roce_set_bond_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_bond_param.target); -+} -+ - static int hikp_roce_bond_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -60,7 +66,7 @@ static int hikp_roce_bond_get_data(struct hikp_cmd_ret **cmd_ret, - return ret; - } - --static void hikp_roce_bond_execute(struct major_cmd_ctrl *self) -+void hikp_roce_bond_execute(struct major_cmd_ctrl *self) - { - hikp_roce_ext_execute(self, GET_ROCEE_BOND_CMD, hikp_roce_bond_get_data); - } -diff --git a/net/roce/roce_bond/hikp_roce_bond.h b/net/roce/roce_bond/hikp_roce_bond.h -index 5e18723..2f61727 100644 ---- a/net/roce/roce_bond/hikp_roce_bond.h -+++ b/net/roce/roce_bond/hikp_roce_bond.h -@@ -26,4 +26,7 @@ struct roce_bond_req_param { - uint32_t block_id; - }; - -+int hikp_roce_set_bond_bdf(char *nic_name); -+void hikp_roce_bond_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_BOND_H */ -diff --git a/net/roce/roce_caep/hikp_roce_caep.c b/net/roce/roce_caep/hikp_roce_caep.c -index a52cd54..95795d1 100644 ---- a/net/roce/roce_caep/hikp_roce_caep.c -+++ b/net/roce/roce_caep/hikp_roce_caep.c -@@ -15,6 +15,17 @@ - - static struct cmd_roce_caep_param_t g_roce_caep_param_t = { 0 }; - -+int hikp_roce_set_caep_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_caep_param_t.target); -+} -+ -+void hikp_roce_set_caep_mode(uint32_t mode) -+{ -+ g_roce_caep_param_t.sub_cmd = mode; -+} -+ - static int hikp_roce_caep_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -102,7 +113,7 @@ exec_error: - hikp_cmd_free(&cmd_ret); - } - --static void hikp_roce_caep_execute(struct major_cmd_ctrl *self) -+void hikp_roce_caep_execute(struct major_cmd_ctrl *self) - { - if (g_roce_caep_param_t.sub_cmd == CAEP_ORIGIN) - hikp_roce_caep_execute_origin(self); -diff --git a/net/roce/roce_caep/hikp_roce_caep.h b/net/roce/roce_caep/hikp_roce_caep.h -index becb332..770e2ab 100644 ---- a/net/roce/roce_caep/hikp_roce_caep.h -+++ b/net/roce/roce_caep/hikp_roce_caep.h -@@ -48,4 +48,8 @@ enum roce_caep_cmd_type { - CAEP_EXT, - }; - -+int hikp_roce_set_caep_bdf(char *nic_name); -+void hikp_roce_set_caep_mode(uint32_t mode); -+void hikp_roce_caep_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_CAEP_H */ -diff --git a/net/roce/roce_global_cfg/hikp_roce_global_cfg.c b/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -index 18df065..ca42dfa 100644 ---- a/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -+++ b/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -@@ -15,6 +15,12 @@ - - static struct cmd_roce_global_cfg_param g_roce_global_cfg_param = { 0 }; - -+int hikp_roce_set_global_cfg_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_global_cfg_param.target); -+} -+ - static int hikp_roce_global_cfg_help(struct major_cmd_ctrl *self, - const char *argv) - { -@@ -63,7 +69,7 @@ static int hikp_roce_global_cfg_get_data(struct hikp_cmd_ret **cmd_ret, - return ret; - } - --static void hikp_roce_global_cfg_execute(struct major_cmd_ctrl *self) -+void hikp_roce_global_cfg_execute(struct major_cmd_ctrl *self) - { - enum roce_global_cfg_cmd_type sub_cmds[] = { - ROCE_GLB_GENAC, -diff --git a/net/roce/roce_global_cfg/hikp_roce_global_cfg.h b/net/roce/roce_global_cfg/hikp_roce_global_cfg.h -index aa1db92..eb6f359 100644 ---- a/net/roce/roce_global_cfg/hikp_roce_global_cfg.h -+++ b/net/roce/roce_global_cfg/hikp_roce_global_cfg.h -@@ -37,4 +37,7 @@ enum roce_global_cfg_cmd_type { - ROCE_GLB_NICL, - }; - -+int hikp_roce_set_global_cfg_bdf(char *nic_name); -+void hikp_roce_global_cfg_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_GLOBAL_CFG_H */ -diff --git a/net/roce/roce_gmv/hikp_roce_gmv.c b/net/roce/roce_gmv/hikp_roce_gmv.c -index 1b7db32..5f96451 100644 ---- a/net/roce/roce_gmv/hikp_roce_gmv.c -+++ b/net/roce/roce_gmv/hikp_roce_gmv.c -@@ -16,6 +16,17 @@ - - static struct cmd_roce_gmv_param g_roce_gmv_param = { 0 }; - -+int hikp_roce_set_gmv_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_gmv_param.target); -+} -+ -+void hikp_roce_set_gmv_index(uint32_t gmv_index) -+{ -+ g_roce_gmv_param.gmv_index = gmv_index; -+} -+ - static int hikp_roce_gmv_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -83,7 +94,7 @@ static void hikp_roce_gmv_print(uint32_t reg_num, struct roce_gmv_rsp_data *gmv_ - printf("*******************************************\n"); - } - --static void hikp_roce_gmv_execute(struct major_cmd_ctrl *self) -+void hikp_roce_gmv_execute(struct major_cmd_ctrl *self) - { - struct roce_gmv_req_para req_data = { 0 }; - struct roce_gmv_rsp_data *gmv_rsp = NULL; -diff --git a/net/roce/roce_gmv/hikp_roce_gmv.h b/net/roce/roce_gmv/hikp_roce_gmv.h -index 8bc49d0..29c2e6d 100644 ---- a/net/roce/roce_gmv/hikp_roce_gmv.h -+++ b/net/roce/roce_gmv/hikp_roce_gmv.h -@@ -38,4 +38,8 @@ enum roce_gmv_cmd_type { - GMV_SHOW = 0x0, - }; - -+int hikp_roce_set_gmv_bdf(char *nic_name); -+void hikp_roce_set_gmv_index(uint32_t gmv_index); -+void hikp_roce_gmv_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_GMV_H */ -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.c b/net/roce/roce_mdb/hikp_roce_mdb.c -index a578c87..e0a7cc5 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.c -+++ b/net/roce/roce_mdb/hikp_roce_mdb.c -@@ -16,6 +16,17 @@ - - static struct cmd_roce_mdb_param g_roce_mdb_param = { 0 }; - -+int hikp_roce_set_mdb_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_mdb_param.target); -+} -+ -+void hikp_roce_set_mdb_mode(uint8_t mode) -+{ -+ g_roce_mdb_param.flag = mode; -+} -+ - static int hikp_roce_mdb_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -155,7 +166,7 @@ exec_error: - hikp_cmd_free(&cmd_ret); - } - --static void hikp_roce_mdb_execute(struct major_cmd_ctrl *self) -+void hikp_roce_mdb_execute(struct major_cmd_ctrl *self) - { - if (g_roce_mdb_param.flag & ROCE_MDB_CMD_EXT) { - g_roce_mdb_param.sub_cmd = (g_roce_mdb_param.flag & ROCE_MDB_CMD_CLEAR) ? -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.h b/net/roce/roce_mdb/hikp_roce_mdb.h -index e8dfcca..b95bb56 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.h -+++ b/net/roce/roce_mdb/hikp_roce_mdb.h -@@ -20,6 +20,7 @@ - #define ROCE_HIKP_REG_SWICTH 2 - - #define ROCE_MDB_CMD_CLEAR (1 << 0) -+#define ROCE_MDB_CMD 0 - #define ROCE_MDB_CMD_EXT (1 << 1) - - struct cmd_roce_mdb_param { -@@ -49,4 +50,8 @@ enum roce_mdb_cmd_type { - MDB_CLEAR_EXT, - }; - -+int hikp_roce_set_mdb_bdf(char *nic_name); -+void hikp_roce_set_mdb_mode(uint8_t mode); -+void hikp_roce_mdb_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_MDB_H */ -diff --git a/net/roce/roce_pkt/hikp_roce_pkt.c b/net/roce/roce_pkt/hikp_roce_pkt.c -index 81bdae6..5a6b268 100644 ---- a/net/roce/roce_pkt/hikp_roce_pkt.c -+++ b/net/roce/roce_pkt/hikp_roce_pkt.c -@@ -15,6 +15,12 @@ - - static struct cmd_roce_pkt_param_t g_roce_pkt_param_t = { 0 }; - -+int hikp_roce_set_pkt_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_pkt_param_t.target); -+} -+ - static int hikp_roce_pkt_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -96,7 +102,7 @@ static void hikp_roce_pkt_print(uint32_t total_block_num, - printf("***********************************\n"); - } - --static void hikp_roce_pkt_execute(struct major_cmd_ctrl *self) -+void hikp_roce_pkt_execute(struct major_cmd_ctrl *self) - { - struct roce_pkt_req_param req_data = { 0 }; - struct roce_pkt_res_param *roce_pkt_res; -diff --git a/net/roce/roce_pkt/hikp_roce_pkt.h b/net/roce/roce_pkt/hikp_roce_pkt.h -index 05d464e..7d23c8f 100644 ---- a/net/roce/roce_pkt/hikp_roce_pkt.h -+++ b/net/roce/roce_pkt/hikp_roce_pkt.h -@@ -39,4 +39,7 @@ struct roce_pkt_res_param { - struct roce_pkt_res reg_data; - }; - -+int hikp_roce_set_pkt_bdf(char *nic_name); -+void hikp_roce_pkt_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_PKT_H */ -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.c b/net/roce/roce_qmm/hikp_roce_qmm.c -index 8140080..30caa5a 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.c -+++ b/net/roce/roce_qmm/hikp_roce_qmm.c -@@ -16,6 +16,22 @@ - - static struct cmd_roce_qmm_param_t g_roce_qmm_param = { 0 }; - -+int hikp_roce_set_qmm_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_qmm_param.target); -+} -+ -+void hikp_roce_set_qmm_ext_flag(bool ext_flag) -+{ -+ g_roce_qmm_param.ext_flag = ext_flag; -+} -+ -+void hikp_roce_set_qmm_bankid(uint32_t bank_id) -+{ -+ g_roce_qmm_param.bank_id = bank_id; -+} -+ - static int hikp_roce_qmm_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -249,7 +265,7 @@ exec_error: - hikp_cmd_free(&cmd_ret); - } - --static void hikp_roce_qmm_execute(struct major_cmd_ctrl *self) -+void hikp_roce_qmm_execute(struct major_cmd_ctrl *self) - { - static const struct cmd_type_info { - enum roce_qmm_cmd_type sub_cmd; -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.h b/net/roce/roce_qmm/hikp_roce_qmm.h -index eb7722b..b13a716 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.h -+++ b/net/roce/roce_qmm/hikp_roce_qmm.h -@@ -51,4 +51,9 @@ enum roce_qmm_cmd_type { - QMM_SHOW_TOP_EXT, - }; - -+int hikp_roce_set_qmm_bdf(char *nic_name); -+void hikp_roce_set_qmm_ext_flag(bool ext_flag); -+void hikp_roce_set_qmm_bankid(uint32_t bank_id); -+void hikp_roce_qmm_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_QMM_H */ -diff --git a/net/roce/roce_rst/hikp_roce_rst.c b/net/roce/roce_rst/hikp_roce_rst.c -index 570e7f4..cfccc47 100644 ---- a/net/roce/roce_rst/hikp_roce_rst.c -+++ b/net/roce/roce_rst/hikp_roce_rst.c -@@ -15,6 +15,12 @@ - - static struct cmd_roce_rst_param g_roce_rst_param = { 0 }; - -+int hikp_roce_set_rst_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_rst_param.target); -+} -+ - static int hikp_roce_rst_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -60,7 +66,7 @@ static int hikp_roce_rst_get_data(struct hikp_cmd_ret **cmd_ret, - return ret; - } - --static void hikp_roce_rst_execute(struct major_cmd_ctrl *self) -+void hikp_roce_rst_execute(struct major_cmd_ctrl *self) - { - hikp_roce_ext_execute(self, GET_ROCEE_RST_CMD, hikp_roce_rst_get_data); - } -diff --git a/net/roce/roce_rst/hikp_roce_rst.h b/net/roce/roce_rst/hikp_roce_rst.h -index e864b68..782d0ff 100644 ---- a/net/roce/roce_rst/hikp_roce_rst.h -+++ b/net/roce/roce_rst/hikp_roce_rst.h -@@ -26,4 +26,7 @@ struct roce_rst_req_param { - uint32_t block_id; - }; - -+int hikp_roce_set_rst_bdf(char *nic_name); -+void hikp_roce_rst_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_RST_H */ -diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c -index f330e97..c660799 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.c -+++ b/net/roce/roce_scc/hikp_roce_scc.c -@@ -15,7 +15,7 @@ - - struct cmd_roce_scc_param_t g_roce_scc_param_t = { 0 }; - struct roce_scc_module g_roce_scc_module[] = { -- ROCE_SCC_HANDLE(COMMON), -+ { "COMMON", SCC_COMMON }, - ROCE_SCC_HANDLE(DCQCN), - ROCE_SCC_HANDLE(DIP), - ROCE_SCC_HANDLE(HC3), -@@ -23,6 +23,17 @@ struct roce_scc_module g_roce_scc_module[] = { - ROCE_SCC_HANDLE(CFG), - }; - -+int hikp_roce_set_scc_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_scc_param_t.target); -+} -+ -+void hikp_roce_set_scc_submodule(uint32_t module) -+{ -+ g_roce_scc_param_t.sub_cmd = module; -+} -+ - static int hikp_roce_scc_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -78,7 +89,7 @@ static int hikp_roce_scc_clear_set(struct major_cmd_ctrl *self, const char *argv - - static int hikp_roce_scc_clear_module_check(void) - { -- if (g_roce_scc_param_t.sub_cmd == COMMON) -+ if (g_roce_scc_param_t.sub_cmd == SCC_COMMON) - return 0; - - return -EINVAL; -@@ -292,7 +303,7 @@ static const struct reg_name_info { - const char **reg_name; - uint8_t arr_len; - } g_scc_reg_name_info_table[] = { -- {COMMON, g_scc_common_reg_name, HIKP_ARRAY_SIZE(g_scc_common_reg_name)}, -+ {SCC_COMMON, g_scc_common_reg_name, HIKP_ARRAY_SIZE(g_scc_common_reg_name)}, - {DCQCN, g_scc_dcqcn_reg_name, HIKP_ARRAY_SIZE(g_scc_dcqcn_reg_name)}, - {DIP, g_scc_dip_reg_name, HIKP_ARRAY_SIZE(g_scc_dip_reg_name)}, - {HC3, g_scc_hc3_reg_name, HIKP_ARRAY_SIZE(g_scc_hc3_reg_name)}, -@@ -330,7 +341,7 @@ static void hikp_roce_scc_print(uint8_t total_block_num, - printf("***********************************\n"); - } - --static void hikp_roce_scc_execute(struct major_cmd_ctrl *self) -+void hikp_roce_scc_execute(struct major_cmd_ctrl *self) - { - struct roce_scc_head res_head; - uint32_t *offset_start = NULL; -diff --git a/net/roce/roce_scc/hikp_roce_scc.h b/net/roce/roce_scc/hikp_roce_scc.h -index 9b5c0c5..b86b59a 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.h -+++ b/net/roce/roce_scc/hikp_roce_scc.h -@@ -58,7 +58,7 @@ struct roce_scc_module { - }; - - enum roce_scc_type { -- COMMON = 1, -+ SCC_COMMON = 1, - DCQCN, - DIP, - HC3, -@@ -66,4 +66,8 @@ enum roce_scc_type { - CFG, - }; - -+int hikp_roce_set_scc_bdf(char *nic_name); -+void hikp_roce_set_scc_submodule(uint32_t module); -+void hikp_roce_scc_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_SCC_H */ -diff --git a/net/roce/roce_timer/hikp_roce_timer.c b/net/roce/roce_timer/hikp_roce_timer.c -index 962127b..a6af959 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.c -+++ b/net/roce/roce_timer/hikp_roce_timer.c -@@ -15,6 +15,12 @@ - - static struct cmd_roce_timer_params g_roce_timer_param = { 0 }; - -+int hikp_roce_set_timer_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_timer_param.target); -+} -+ - static int hikp_roce_timer_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -192,7 +198,7 @@ static int hikp_roce_timer_clear(struct major_cmd_ctrl *self) - return 0; - } - --static void hikp_roce_timer_execute(struct major_cmd_ctrl *self) -+void hikp_roce_timer_execute(struct major_cmd_ctrl *self) - { - int (*func[])(struct major_cmd_ctrl *self) = { - hikp_roce_timer_show_cqc, hikp_roce_timer_show_qpc -diff --git a/net/roce/roce_timer/hikp_roce_timer.h b/net/roce/roce_timer/hikp_roce_timer.h -index 314547e..f82afe1 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.h -+++ b/net/roce/roce_timer/hikp_roce_timer.h -@@ -40,4 +40,7 @@ struct roce_timer_rsp_data { - uint32_t timer_content[ROCE_HIKP_TIMER_REG_NUM][2]; - }; - -+int hikp_roce_set_timer_bdf(char *nic_name); -+void hikp_roce_timer_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_TIMER_H */ -diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c -index 68c4cf2..9b1ddb1 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.c -+++ b/net/roce/roce_trp/hikp_roce_trp.c -@@ -18,9 +18,25 @@ struct roce_trp_module g_roce_trp_module[] = { - ROCE_TRP_HANDLE(TRP_RX), - ROCE_TRP_HANDLE(GEN_AC), - ROCE_TRP_HANDLE(PAYL), -- ROCE_TRP_HANDLE(COMMON), -+ { "COMMON", TRP_COMMON }, - }; - -+int hikp_roce_set_trp_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_trp_param_t.target); -+} -+ -+void hikp_roce_set_trp_bankid(uint32_t bank_id) -+{ -+ g_roce_trp_param_t.bank_id = bank_id; -+} -+ -+void hikp_roce_set_trp_submodule(uint32_t module) -+{ -+ g_roce_trp_param_t.sub_cmd = module; -+} -+ - static int hikp_roce_trp_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -86,7 +102,7 @@ static int hikp_roce_trp_bank_get(struct major_cmd_ctrl *self, const char *argv) - static int hikp_roce_trp_bank_check(void) - { - switch (g_roce_trp_param_t.sub_cmd) { -- case (COMMON): -+ case (TRP_COMMON): - if (g_roce_trp_param_t.bank_id > TRP_MAX_BANK_NUM) - return -EINVAL; - break; -@@ -341,7 +357,7 @@ static const struct reg_name_info { - const char **reg_name; - uint8_t arr_len; - } g_trp_reg_name_info_table[] = { -- {COMMON, g_trp_common_reg_name, HIKP_ARRAY_SIZE(g_trp_common_reg_name)}, -+ {TRP_COMMON, g_trp_common_reg_name, HIKP_ARRAY_SIZE(g_trp_common_reg_name)}, - {TRP_RX, g_trp_trp_rx_reg_name, HIKP_ARRAY_SIZE(g_trp_trp_rx_reg_name)}, - {GEN_AC, g_trp_gen_ac_reg_name, HIKP_ARRAY_SIZE(g_trp_gen_ac_reg_name)}, - {PAYL, g_trp_payl_reg_name, HIKP_ARRAY_SIZE(g_trp_payl_reg_name)}, -@@ -377,7 +393,7 @@ static void hikp_roce_trp_print(uint8_t total_block_num, - printf("***********************************\n"); - } - --static void hikp_roce_trp_execute(struct major_cmd_ctrl *self) -+void hikp_roce_trp_execute(struct major_cmd_ctrl *self) - { - struct roce_trp_head res_head; - uint32_t *offset_start = NULL; -diff --git a/net/roce/roce_trp/hikp_roce_trp.h b/net/roce/roce_trp/hikp_roce_trp.h -index 212d36f..023e290 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.h -+++ b/net/roce/roce_trp/hikp_roce_trp.h -@@ -67,7 +67,12 @@ enum roce_trp_type { - TRP_RX = 1, - GEN_AC, - PAYL, -- COMMON, -+ TRP_COMMON, - }; - -+void hikp_roce_set_trp_submodule(uint32_t module); -+void hikp_roce_set_trp_bankid(uint32_t bank_id); -+int hikp_roce_set_trp_bdf(char *nic_name); -+void hikp_roce_trp_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_TRP_H */ -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.c b/net/roce/roce_tsp/hikp_roce_tsp.c -index 9dd7956..e07e882 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.c -+++ b/net/roce/roce_tsp/hikp_roce_tsp.c -@@ -15,11 +15,27 @@ - - static struct cmd_roce_tsp_param_t g_roce_tsp_param_t = { 0 }; - static struct roce_tsp_module g_roce_tsp_module[] = { -- TSP_HANDLE(COMMON), -+ { "COMMON", TSP_COMMON }, - TSP_HANDLE(TDP), - TSP_HANDLE(TGP_TMP), - }; - -+int hikp_roce_set_tsp_bdf(char *nic_name) -+{ -+ return tool_check_and_get_valid_bdf_id(nic_name, -+ &g_roce_tsp_param_t.target); -+} -+ -+void hikp_roce_set_tsp_bankid(uint32_t bank_id) -+{ -+ g_roce_tsp_param_t.bank_id = bank_id; -+} -+ -+void hikp_roce_set_tsp_submodule(uint32_t module) -+{ -+ g_roce_tsp_param_t.sub_cmd_code = module; -+} -+ - static int hikp_roce_tsp_help(struct major_cmd_ctrl *self, const char *argv) - { - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); -@@ -85,7 +101,7 @@ static int hikp_roce_tsp_bank_get(struct major_cmd_ctrl *self, const char *argv) - static int hikp_roce_tsp_bank_check(void) - { - switch (g_roce_tsp_param_t.sub_cmd_code) { -- case (COMMON): -+ case (TSP_COMMON): - if (g_roce_tsp_param_t.bank_id > MAX_TSP_BANK_NUM) - return -EINVAL; - break; -@@ -194,9 +210,11 @@ static const struct reg_name_info { - const char **reg_name; - uint8_t arr_len; - } g_tsp_reg_name_info_table[] = { -- {COMMON, g_tsp_common_reg_name, HIKP_ARRAY_SIZE(g_tsp_common_reg_name)}, -+ {TSP_COMMON, g_tsp_common_reg_name, -+ HIKP_ARRAY_SIZE(g_tsp_common_reg_name)}, - {TDP, g_tsp_tdp_reg_name, HIKP_ARRAY_SIZE(g_tsp_tdp_reg_name)}, -- {TGP_TMP, g_tsp_tgp_tmp_reg_name, HIKP_ARRAY_SIZE(g_tsp_tgp_tmp_reg_name)}, -+ {TGP_TMP, g_tsp_tgp_tmp_reg_name, -+ HIKP_ARRAY_SIZE(g_tsp_tgp_tmp_reg_name)}, - }; - - static void hikp_roce_tsp_print(uint32_t total_block_num, -@@ -229,7 +247,7 @@ static void hikp_roce_tsp_print(uint32_t total_block_num, - printf("***********************************\n"); - } - --static void hikp_roce_tsp_execute(struct major_cmd_ctrl *self) -+void hikp_roce_tsp_execute(struct major_cmd_ctrl *self) - { - struct roce_tsp_res_param *roce_tsp_res; - struct roce_tsp_req_param req_data; -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.h b/net/roce/roce_tsp/hikp_roce_tsp.h -index a35f869..12bd0a3 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.h -+++ b/net/roce/roce_tsp/hikp_roce_tsp.h -@@ -56,9 +56,14 @@ struct roce_tsp_module { - }; - - enum roce_tsp_sub_cmd_code { -- COMMON = 1, -+ TSP_COMMON = 1, - TDP, - TGP_TMP, - }; - -+int hikp_roce_set_tsp_bdf(char *nic_name); -+void hikp_roce_set_tsp_bankid(uint32_t bank_id); -+void hikp_roce_set_tsp_submodule(uint32_t module); -+void hikp_roce_tsp_execute(struct major_cmd_ctrl *self); -+ - #endif /* HIKP_ROCE_TSP_H */ -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.c b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -index d3534f5..695d40f 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.c -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.c -@@ -69,7 +69,7 @@ union pm_state_reg { - uint64_t val; - }; - --static int pcie_get_ltssm_trace(uint32_t port_id, uint64_t *ltssm_status, uint32_t *ltssm_num) -+int pcie_get_ltssm_trace(uint32_t port_id, uint64_t *ltssm_status, uint32_t *ltssm_num) - { - struct hikp_cmd_header req_header; - struct hikp_cmd_ret *cmd_ret = NULL; -diff --git a/pcie/func_lib/pcie_func/pcie_link_ltssm.h b/pcie/func_lib/pcie_func/pcie_link_ltssm.h -index 278f3e4..9d02557 100644 ---- a/pcie/func_lib/pcie_func/pcie_link_ltssm.h -+++ b/pcie/func_lib/pcie_func/pcie_link_ltssm.h -@@ -59,5 +59,6 @@ int pcie_ltssm_trace_clear(uint32_t port_id); - int pcie_ltssm_trace_mode_set(uint32_t port_id, uint32_t mode); - int pcie_ltssm_link_status_get(uint32_t port_id); - int pcie_pm_trace(uint32_t port_id); -+int pcie_get_ltssm_trace(uint32_t port_id, uint64_t *ltssm_status, uint32_t *ltssm_num); - - #endif /* PCIE_LINK_LTSSM_H */ -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index abf0e26..0ce2e5d 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -17,13 +17,13 @@ - #include - #include - #include --#include "tool_lib.h" - #include "hikptdev_plug.h" - #include "os_common.h" - #include "pcie_common.h" - #include "pcie_reg_dump.h" - - int g_pcie_dumpreg_fd; -+char dumpreg_log_file[MAX_LOG_NAME_LEN + 1] = {0}; - - struct pcie_dumpreg_info g_reg_table_tl[] = { - {0, "TL_ASPM_IDLE_CNT"}, -@@ -412,6 +412,9 @@ static int pcie_create_dumpreg_log_file(uint32_t port_id, uint32_t dump_level) - if (ret) - return -EINVAL; - -+ memset(dumpreg_log_file, 0, sizeof(dumpreg_log_file)); -+ (void)strncpy((char *)dumpreg_log_file, file_name, MAX_LOG_NAME_LEN + 1); -+ - (void)remove((const char *)file_name); - /* Add write permission to the file */ - fd_file = open(file_name, O_RDWR | O_SYNC | O_CREAT, 0600); -@@ -558,7 +561,7 @@ int pcie_dumpreg_do_dump(uint32_t port_id, uint32_t dump_level) - struct pcie_dump_req_para req_data = { 0 }; - int ret = 0; - -- Info("pcie reg dump start.\n"); -+ Info("hikptool pcie_dumpreg -i %u -l %u -d\n", port_id, dump_level); - - req_data.port_id = port_id; - req_data.level = dump_level; -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.h b/pcie/func_lib/pcie_func/pcie_reg_dump.h -index aaf22ba..3c52a6e 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.h -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.h -@@ -15,10 +15,12 @@ - #define PCIE_REG_DUMP_H - - #include "pcie_common_api.h" -+#include "tool_lib.h" - - #define PCIE_REG_NAME_LEN 60 - #define MAX_STR_LEN 80 - #define PCIE_DUMPREG_LOGFILE_NAME "pcie_dumpreg" -+#define LOG_FILE_PATH_MAX_LEN 512 - - #define HIKP_PCIE_PCS_LANE_TBL_ENTRY(name) \ - {0, STR(CONTACT(name, _00))}, {0, STR(CONTACT(name, _01))}, \ -@@ -54,6 +56,8 @@ struct pcie_dumpreg_table { - struct pcie_dumpreg_info *dump_info; - }; - -+extern char dumpreg_log_file[MAX_LOG_NAME_LEN + 1]; - int pcie_dumpreg_do_dump(uint32_t port_id, uint32_t dump_level); - -+ - #endif /* PCIE_REG_DUMP_H */ -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c -index be187f2..c7fee0b 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.c -+++ b/pcie/func_lib/pcie_func/pcie_statistics.c -@@ -29,7 +29,7 @@ static const char *g_global_ndie_name[] = { - "Ndie_A", "Ndie_B", "Ndie_C", "Ndie_D" - }; - --static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, uint32_t *port_num) -+int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, uint32_t *port_num) - { - size_t rsp_data_size, expect_data_size; - struct pcie_port_info *port_info = NULL; -diff --git a/pcie/func_lib/pcie_func/pcie_statistics.h b/pcie/func_lib/pcie_func/pcie_statistics.h -index c373573..d7a68e2 100644 ---- a/pcie/func_lib/pcie_func/pcie_statistics.h -+++ b/pcie/func_lib/pcie_func/pcie_statistics.h -@@ -15,6 +15,7 @@ - #define PCIE_STATISTICS_H - - #include "pcie_common_api.h" -+#include "hikptdev_plug.h" - - #define GLOBAL_WIDTH_TABLE_SIZE 5 - #define MAX_MACRO_ONEPORT 3 -@@ -126,5 +127,6 @@ struct pcie_info_req_para { - int pcie_port_distribution_get(uint32_t chip_id); - int pcie_error_state_get(uint32_t port_id); - int pcie_error_state_clear(uint32_t port_id); -+int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, uint32_t *port_num); - - #endif /* PCIE_STATISTICS_H */ -diff --git a/sas/sas_func/sas_common.h b/sas/sas_func/sas_common.h -index eed0fa5..78edf2e 100644 ---- a/sas/sas_func/sas_common.h -+++ b/sas/sas_func/sas_common.h -@@ -16,7 +16,7 @@ - - #define RESP_MAX_NUM 60 - #define SAS_MAX_PHY_NUM 7 --#define SAS_MAX_ERR_NUM 6 -+#define SAS_MAX_ERR_NUM 5 - #define SAS_ERR_NUM 4 - #define SAS_QUEUE_NUM 16 - #define IPTT_ICT_STATUS 29 -diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c -index 92e380e..2367382 100644 ---- a/serdes/hikp_serdes.c -+++ b/serdes/hikp_serdes.c -@@ -24,6 +24,10 @@ static struct cmd_serdes_param g_serdes_param = {0xff, 0xff, 0xff, 0xff, 0xff, 0 - - #define SERDES_OUTPUT_MAX_SIZE 2560 - static char g_serdes_data_out_buf[SERDES_OUTPUT_MAX_SIZE] = {0}; -+static struct hilink_cmd_out g_out_put = {0}; -+ -+static void hikp_serdes_info_print(struct cmd_serdes_param *cmd); -+static void hikp_serdes_dump_print(struct cmd_serdes_param *cmd); - - static int cmd_serdes_maininfo_help(struct major_cmd_ctrl *self, const char *argv) - { -@@ -120,12 +124,12 @@ static int cmd_serdes_key_info_pro(struct major_cmd_ctrl *self, const char *argv - } - - #define USEMODE_SSC_STR_MAXLEN 20 --static void hikp_serdes_brief_info_print(struct major_cmd_ctrl *self, -- const struct hilink_brief_info *data, uint32_t data_size) -+static void hikp_serdes_brief_info_print(struct cmd_serdes_param *cmd, -+ const struct hilink_brief_info *data, uint32_t data_size) - { - uint8_t ds_id; -- uint8_t start_sds_id = g_serdes_param.start_sds_id; -- uint8_t sds_num = g_serdes_param.sds_num; -+ uint8_t start_sds_id = cmd->start_sds_id; -+ uint8_t sds_num = cmd->sds_num; - char usemode_ssc_str[USEMODE_SSC_STR_MAXLEN] = {0}; - const char *usemode_array[HILINK_USE_MODE_END] = { - "default", "pcie", "sata", "sas", "hccs", -@@ -136,26 +140,20 @@ static void hikp_serdes_brief_info_print(struct major_cmd_ctrl *self, - }; - - if (data_size != sds_num) { -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), -- "serdes brief info data size is wrong."); -+ printf("serdes brief info data size is wrong.\n"); - return; - } - - for (ds_id = 0; ds_id < sds_num; ds_id++) { - if (data[ds_id].usemode >= HILINK_USE_MODE_END) { -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), -- "usemode[%u] is out of range.", data[ds_id].usemode); -+ printf("usemode[%u] is out of range.\n", data[ds_id].usemode); - return; - } - strncpy(usemode_ssc_str, usemode_array[data[ds_id].usemode], - sizeof(usemode_ssc_str) - 1); - - if (data[ds_id].ssc_type >= HILINK_SSC_TYPE_END) { -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), -- "ssc_type[%u] is out of range.", data[ds_id].ssc_type); -+ printf("ssc_type[%u] is out of range.\n", data[ds_id].ssc_type); - return; - } - if (data[ds_id].usemode < HILINK_USE_MODE_HCCS) { -@@ -165,7 +163,7 @@ static void hikp_serdes_brief_info_print(struct major_cmd_ctrl *self, - } - printf("chip%u (M%u,ds%d) pll(%u, %u) pn(%u, %u) power(%u, %u)" - "(refclk_sel:%u) rate(%u, %u Mhz) usemode(%s)\n", -- g_serdes_param.chip_id, g_serdes_param.macro_id, -+ cmd->chip_id, cmd->macro_id, - ds_id + start_sds_id, data[ds_id].tx_cs_sel, data[ds_id].rx_cs_sel, - data[ds_id].tx_pn, data[ds_id].rx_pn, - data[ds_id].tx_power, data[ds_id].rx_power, -@@ -200,25 +198,22 @@ static void hikp_serdes_brief_info_print(struct major_cmd_ctrl *self, - "-------------------------------------------------" \ - "--------------------------------\n") - --static void hikp_serdes_detail_info_print(struct major_cmd_ctrl *self, -- const struct hilink_detail_info *data, -- uint32_t data_size) -+static void hikp_serdes_detail_info_print(struct cmd_serdes_param *cmd, -+ const struct hilink_detail_info *data, uint32_t data_size) - { - uint32_t i; - uint8_t ds_id; -- uint8_t start_sds_id = g_serdes_param.start_sds_id; -- uint8_t sds_num = g_serdes_param.sds_num; -+ uint8_t start_sds_id = cmd->start_sds_id; -+ uint8_t sds_num = cmd->sds_num; - - if (data_size != sds_num) { -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), -- "serdes detail info data size is wrong."); -+ printf("serdes detail info data size is wrong.\n"); - return; - } - printf(KEY_INFO_TITLE); - for (ds_id = 0; ds_id < sds_num; ds_id++) { - printf("chip%u (M%u,ds%d) [%3d,%3d,%3u,%3d,%3d]", -- g_serdes_param.chip_id, g_serdes_param.macro_id, ds_id + start_sds_id, -+ cmd->chip_id, cmd->macro_id, ds_id + start_sds_id, - data[ds_id].tx_cfg.fir_pre2, data[ds_id].tx_cfg.fir_pre1, - data[ds_id].tx_cfg.fir_main, data[ds_id].tx_cfg.fir_post1, - data[ds_id].tx_cfg.fir_post2); -@@ -243,6 +238,8 @@ static void hikp_serdes_detail_info_print(struct major_cmd_ctrl *self, - static void hikp_serdes_logout_init(struct hilink_cmd_out *logout, char *buffer, - uint32_t size, uint32_t type) - { -+ memset(buffer, 0, size); -+ - logout->str_len = size; - logout->result_offset = 0; - logout->out_str = buffer; -@@ -282,67 +279,88 @@ static int hikp_serdes_info_para_check(struct major_cmd_ctrl *self) - return 0; - } - --static void hikp_serdes_info_cmd_execute(struct major_cmd_ctrl *self) -+static void hikp_serdes_print(struct cmd_serdes_param *cmd) -+{ -+ if (cmd->cmd_type == SERDES_KEY_INFO) -+ hikp_serdes_info_print(cmd); -+ else if (cmd->cmd_type == SERDES_DUMP_REG) -+ hikp_serdes_dump_print(cmd); -+} -+ -+int hikp_serdes_get_reponse(struct cmd_serdes_param *cmd) - { - struct hikp_cmd_header req_header = {0}; - struct hikp_cmd_ret *cmd_ret; - struct hilink_cmd_in hilink_cmd = {0}; -- struct hilink_brief_info *brief_info_data = NULL; -- struct hilink_detail_info *detail_info_data = NULL; -- struct hilink_cmd_out out_put; - size_t out_out_header_size; -- int ret; -- -- ret = hikp_serdes_info_para_check(self); -- if (ret != 0) -- return; - -- hikp_serdes_logout_init(&out_put, g_serdes_data_out_buf, SERDES_OUTPUT_MAX_SIZE, 0); -+ hilink_cmd.cmd_type = cmd->cmd_type; -+ hilink_cmd.sub_cmd = cmd->sub_cmd; -+ hilink_cmd.cmd_para.chip_id = cmd->chip_id; -+ hilink_cmd.cmd_para.macro_id = cmd->macro_id; -+ hilink_cmd.cmd_para.start_sds_id = cmd->start_sds_id; -+ hilink_cmd.cmd_para.sds_num = cmd->sds_num; - -- hilink_cmd.cmd_type = SERDES_KEY_INFO; -- hilink_cmd.sub_cmd = g_serdes_param.sub_cmd; -- hilink_cmd.cmd_para.chip_id = g_serdes_param.chip_id; -- hilink_cmd.cmd_para.macro_id = g_serdes_param.macro_id; -- hilink_cmd.cmd_para.start_sds_id = g_serdes_param.start_sds_id; -- hilink_cmd.cmd_para.sds_num = g_serdes_param.sds_num; -+ hikp_serdes_logout_init(&g_out_put, g_serdes_data_out_buf, SERDES_OUTPUT_MAX_SIZE, 0); - -- hikp_cmd_init(&req_header, SERDES_MOD, SERDES_KEY_INFO, g_serdes_param.sub_cmd); -+ hikp_cmd_init(&req_header, SERDES_MOD, cmd->cmd_type, cmd->sub_cmd); - cmd_ret = hikp_cmd_alloc(&req_header, &hilink_cmd, sizeof(hilink_cmd)); - if (cmd_ret == NULL || cmd_ret->status != 0) { -- snprintf(self->err_str, sizeof(self->err_str), "hikp_cmd_alloc err."); -- self->err_no = -EINVAL; -- goto err_out; -+ printf("hikp_cmd_alloc err.\n"); -+ hikp_cmd_free(&cmd_ret); -+ return -EINVAL; - } -- out_out_header_size = sizeof(out_put.str_len) + sizeof(out_put.result_offset) + -- sizeof(out_put.type) + sizeof(out_put.ret_val); -- memcpy(&out_put, cmd_ret->rsp_data, out_out_header_size); -+ out_out_header_size = sizeof(g_out_put.str_len) + sizeof(g_out_put.result_offset) + -+ sizeof(g_out_put.type) + sizeof(g_out_put.ret_val); -+ memcpy(&g_out_put, cmd_ret->rsp_data, out_out_header_size); - -- if ((cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size) > -- SERDES_OUTPUT_MAX_SIZE) { -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), -- "serdes_info rsp_data data copy size error, data size:0x%zx max size:0x%x.", -+ if ((cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size) > SERDES_OUTPUT_MAX_SIZE) { -+ printf("serdes_info rsp_data data copy size error, data size:0x%zx max size:0x%x.", - (cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size), - SERDES_OUTPUT_MAX_SIZE); -- goto err_out; -+ hikp_cmd_free(&cmd_ret); -+ return -EINVAL; - } -- memcpy(out_put.out_str, cmd_ret->rsp_data + out_out_header_size / sizeof(uint32_t), -+ memcpy(g_out_put.out_str, cmd_ret->rsp_data + out_out_header_size / sizeof(uint32_t), - cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size); -+ hikp_cmd_free(&cmd_ret); -+ -+ hikp_serdes_print(cmd); -+ -+ return 0; -+} - -- if (g_serdes_param.sub_cmd > 0) { -- detail_info_data = (struct hilink_detail_info *)out_put.out_str; -- hikp_serdes_detail_info_print(self, detail_info_data, -- out_put.result_offset / -- sizeof(struct hilink_detail_info)); -+static void hikp_serdes_info_print(struct cmd_serdes_param *cmd) -+{ -+ struct hilink_brief_info *brief_info_data = NULL; -+ struct hilink_detail_info *detail_info_data = NULL; -+ -+ if (cmd->sub_cmd > 0) { -+ detail_info_data = (struct hilink_detail_info *)g_out_put.out_str; -+ hikp_serdes_detail_info_print(cmd, detail_info_data, -+ g_out_put.result_offset / sizeof(struct hilink_detail_info)); - } else { -- brief_info_data = (struct hilink_brief_info *)out_put.out_str; -- hikp_serdes_brief_info_print(self, brief_info_data, -- out_put.result_offset / -- sizeof(struct hilink_brief_info)); -+ brief_info_data = (struct hilink_brief_info *)g_out_put.out_str; -+ hikp_serdes_brief_info_print(cmd, brief_info_data, -+ g_out_put.result_offset / sizeof(struct hilink_brief_info)); - } -+} - --err_out: -- hikp_cmd_free(&cmd_ret); -+static void hikp_serdes_info_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ int ret; -+ -+ ret = hikp_serdes_info_para_check(self); -+ if (ret != 0) -+ return; -+ -+ g_serdes_param.cmd_type = SERDES_KEY_INFO; -+ ret = hikp_serdes_get_reponse(&g_serdes_param); -+ if (ret != 0) { -+ self->err_no = ret; -+ snprintf(self->err_str, sizeof(self->err_str), "serdes_info hikp_serdes_get_reponse err\n"); -+ return; -+ } - } - - static void cmd_serdes_maininfo_init(void) -@@ -393,22 +411,27 @@ _SERDES_DUMP_SUBCMD_PRO_: - return 0; - } - --static void hikp_serdes_dump_print(struct major_cmd_ctrl *self, -- const uint32_t *data, uint32_t data_size) -+static void hikp_serdes_dump_print(struct cmd_serdes_param *cmd) - { -+ uint32_t *dump_data = (uint32_t *)g_out_put.out_str; -+ uint32_t data_size = g_out_put.result_offset / sizeof(uint32_t); - uint32_t i; - -+ if (g_out_put.type == 1) { /* 0:data; 1:string */ -+ printf("serdes dump data type is string, buffer is not enough.\n"); -+ return; -+ } -+ - /* 2: Check whether addresses and values are paired */ - if (data_size == 0 || data_size % 2 != 0) { -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), "serdes dump data size is wrong."); -+ printf("serdes dump data size is wrong.\n"); - return; - } - - printf("\n[-------Macro%uCS/DS%u-------]\nAddr Value", -- g_serdes_param.macro_id, g_serdes_param.start_sds_id); -+ cmd->macro_id, cmd->start_sds_id); - for (i = 0; i < data_size; i += 2) { /* 2: Addresses and values are paired */ -- printf("\n0x%04x 0x%08x", data[i], data[i + 1]); -+ printf("\n0x%04x 0x%08x", dump_data[i], dump_data[i + 1]); - } - printf("\n"); - } -@@ -444,59 +467,19 @@ static int hikp_serdes_dump_para_check(struct major_cmd_ctrl *self) - - static void hikp_serdes_dump_cmd_execute(struct major_cmd_ctrl *self) - { -- struct hikp_cmd_header req_header = {0}; -- struct hikp_cmd_ret *cmd_ret; -- struct hilink_cmd_in hilink_cmd = {0}; -- uint32_t *dump_data = NULL; -- struct hilink_cmd_out out_put; -- size_t out_out_header_size; - int ret; - - ret = hikp_serdes_dump_para_check(self); - if (ret != 0) - return; - -- hikp_serdes_logout_init(&out_put, g_serdes_data_out_buf, SERDES_OUTPUT_MAX_SIZE, 0); -- -- hilink_cmd.cmd_type = SERDES_DUMP_REG; -- hilink_cmd.sub_cmd = g_serdes_param.sub_cmd; -- hilink_cmd.cmd_para.chip_id = g_serdes_param.chip_id; -- hilink_cmd.cmd_para.macro_id = g_serdes_param.macro_id; -- hilink_cmd.cmd_para.start_sds_id = g_serdes_param.start_sds_id; -- -- hikp_cmd_init(&req_header, SERDES_MOD, SERDES_DUMP_REG, g_serdes_param.sub_cmd); -- cmd_ret = hikp_cmd_alloc(&req_header, &hilink_cmd, sizeof(hilink_cmd)); -- if (cmd_ret == NULL || cmd_ret->status != 0) { -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), "hikp_cmd_alloc err."); -- goto err_out; -- } -- out_out_header_size = sizeof(out_put.str_len) + sizeof(out_put.result_offset) + -- sizeof(out_put.type) + sizeof(out_put.ret_val); -- memcpy(&out_put, cmd_ret->rsp_data, out_out_header_size); -- -- if ((cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size) > -- SERDES_OUTPUT_MAX_SIZE) { -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), -- "serdes_dump rsp_data data copy size error, data size:0x%zx max size:0x%x.", -- (cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size), -- SERDES_OUTPUT_MAX_SIZE); -- goto err_out; -- } -- memcpy(out_put.out_str, cmd_ret->rsp_data + out_out_header_size / sizeof(uint32_t), -- cmd_ret->rsp_data_num * sizeof(uint32_t) - out_out_header_size); -- if (out_put.type == 1) { /* 0:data; 1:string */ -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), -- "serdes dump data type is string, buffer is not enough."); -- goto err_out; -+ g_serdes_param.cmd_type = SERDES_DUMP_REG; -+ ret = hikp_serdes_get_reponse(&g_serdes_param); -+ if (ret != 0) { -+ self->err_no = ret; -+ snprintf(self->err_str, sizeof(self->err_str), "serdes_dump hikp_serdes_get_reponse err\n"); -+ return; - } -- -- dump_data = (uint32_t *)out_put.out_str; -- hikp_serdes_dump_print(self, dump_data, out_put.result_offset / sizeof(uint32_t)); --err_out: -- hikp_cmd_free(&cmd_ret); - } - - static void cmd_serdes_dump_init(void) -diff --git a/serdes/hikp_serdes.h b/serdes/hikp_serdes.h -index 2c04e8a..4ea969d 100644 ---- a/serdes/hikp_serdes.h -+++ b/serdes/hikp_serdes.h -@@ -113,7 +113,7 @@ struct cmd_serdes_param { - uint8_t sds_num; - uint8_t val; - uint8_t sub_cmd; -- uint8_t rsvd1; -+ uint8_t cmd_type; - uint8_t rsvd2; - }; - -@@ -210,4 +210,6 @@ struct hilink_brief_info { - uint32_t rsvd_1; - }; - -+int hikp_serdes_get_reponse(struct cmd_serdes_param *cmd); -+ - #endif /* HIKP_SERDES_H */ -diff --git a/socip/hikp_socip.h b/socip/hikp_socip.h -index 8d3f31b..0b82f90 100644 ---- a/socip/hikp_socip.h -+++ b/socip/hikp_socip.h -@@ -46,4 +46,5 @@ struct socip_dump_reg_req_data_t { - uint8_t controller_id; - }; - -+void dump_reg_info(const uint32_t *reg_data, uint32_t data_num); - #endif /* HIKP_SOCIP_H */ -diff --git a/socip/hikp_socip_dumpreg.c b/socip/hikp_socip_dumpreg.c -index 4b6b70c..a3a20cb 100644 ---- a/socip/hikp_socip_dumpreg.c -+++ b/socip/hikp_socip_dumpreg.c -@@ -105,7 +105,7 @@ static bool check_socip_dumpreg_param(void) - return ret; - } - --static void dump_reg_info(const uint32_t *reg_data, uint32_t data_num) -+void dump_reg_info(const uint32_t *reg_data, uint32_t data_num) - { - #define ONE_LINE_PRINT_DATA_NUM 4 - uint32_t i; -diff --git a/tool_lib/tool_lib.c b/tool_lib/tool_lib.c -index 4d02bdd..62f5fbb 100644 ---- a/tool_lib/tool_lib.c -+++ b/tool_lib/tool_lib.c -@@ -16,6 +16,46 @@ - #include - #include - -+uint32_t get_chip_type(void) -+{ -+ char part_num_str[MIDR_BUFFER_SIZE] = {0}; -+ char midr_buffer[MIDR_BUFFER_SIZE] = {0}; -+ uint32_t chip_type = CHIP_UNKNOW; -+ uint64_t midr_el1; -+ uint32_t part_num; -+ FILE *file; -+ -+ file = fopen(MIDR_EL1_PATH, "r"); -+ if (file == NULL) { -+ HIKP_ERROR_PRINT("Open file: %s failed\n", MIDR_EL1_PATH); -+ return chip_type; -+ } -+ -+ if (fgets(midr_buffer, MIDR_BUFFER_SIZE, file) == NULL) { -+ HIKP_ERROR_PRINT("Read file: %s failed\n", MIDR_EL1_PATH); -+ fclose(file); -+ return chip_type; -+ } -+ -+ fclose(file); -+ midr_el1 = strtoul(midr_buffer, NULL, MIDR_HEX_TYPE); -+ part_num = (midr_el1 & 0xffff) >> PART_NUM_OFFSET; -+ (void)snprintf(part_num_str, MIDR_BUFFER_SIZE, "%x", part_num); -+ -+ if (strcmp(part_num_str, "d02") == 0) -+ chip_type = CHIP_HIP09; -+ else if (strcmp(part_num_str, "d03") == 0) -+ chip_type = CHIP_HIP10; -+ else if (strcmp(part_num_str, "d45") == 0) -+ chip_type = CHIP_HIP10C; -+ else if (strcmp(part_num_str, "d22") == 0) -+ chip_type = CHIP_HIP11; -+ else -+ chip_type = CHIP_UNKNOW; -+ -+ return chip_type; -+} -+ - int string_toui(const char *nptr, uint32_t *value) - { - char *endptr = NULL; -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index 34cc3e8..3bf7bf8 100644 ---- a/tool_lib/tool_lib.h -+++ b/tool_lib/tool_lib.h -@@ -90,6 +90,22 @@ struct type_trans { - #define HIKP_WARN_PRINT(x, args...) HIKP_LOG_PRINT("[ WARN ] " x, ##args) - #define HIKP_INFO_PRINT(x, args...) HIKP_LOG_PRINT("[ INFO ] " x, ##args) - #define HIKP_DBG_PRINT(x, args...) HIKP_LOG_PRINT("[ DBG ] " x, ##args) -+#define HIKP_SET_USED(x) (void)(x) -+ -+#define MIDR_EL1_PATH "/sys/devices/system/cpu/cpu0/regs/identification/midr_el1" -+#define MIDR_BUFFER_SIZE 20 -+#define PART_NUM_OFFSET 4 -+#define MIDR_HEX_TYPE 16 -+ -+enum chip_type { -+ CHIP_HIP09, -+ CHIP_HIP10, -+ CHIP_HIP10C, -+ CHIP_HIP11, -+ CHIP_UNKNOW, -+}; -+ -+uint32_t get_chip_type(void); - - int string_toui(const char *nptr, uint32_t *value); - int string_toub(const char *nptr, uint8_t *value); --- -2.45.0.windows.1 - diff --git a/0091-hikptool-Added-compilation-options.patch b/0091-hikptool-Added-compilation-options.patch deleted file mode 100644 index 167363d9497cf855b59d15ca6d135ce780068f14..0000000000000000000000000000000000000000 --- a/0091-hikptool-Added-compilation-options.patch +++ /dev/null @@ -1,2007 +0,0 @@ -From f58af3995b2ce367210f0bf4cc8d1def791c88f9 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Fri, 14 Mar 2025 20:10:53 +0800 -Subject: [PATCH] hikptool: Added compilation options. - -The following compilation options are added: - --Wuninitialized -Wundef -Wunused -Wdate-time --Wshadow -Wvla -Wdisabled-optimization -Wempty-body -Wignored-qualifiers --Wimplicit-fallthrough=3 -Wtype-limits -Wshift-negative-value -Wswitch-default --Wframe-larger-than=8192 -Wshift-overflow=2 -Wwrite-strings -Wmissing-format-attribute --Wformat-nonliteral -Wduplicated-cond -Wtrampolines -Wlogical-op -Wsuggest-attribute=format --Wduplicated-branches -Wmissing-include-dirs -Wmissing-declarations --Wreturn-local-addr -Wredundant-decls -Wfloat-conversion -Wmissing-prototypes --Wno-discarded-qualifiers -Wstrict-prototypes - -And alos rectify compilation alarms and errors. - -Signed-off-by: veega2022 ---- - CMakeLists.txt | 10 +++++- - cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c | 16 ++++++++++ - cxl/usr_cmd/cmd_analysis/cxl_cmd_dl.c | 16 ++++++++++ - cxl/usr_cmd/cmd_analysis/cxl_cmd_membar.c | 10 ++++++ - cxl/usr_cmd/cmd_analysis/cxl_cmd_rcrb.c | 13 ++++++++ - libhikptdev/src/rciep/hikpt_rciep.c | 28 ++++++++++------ - net/hikp_net_lib.c | 4 +-- - net/nic/nic_dfx/hikp_nic_dfx.c | 2 ++ - net/nic/nic_fd/hikp_nic_fd.c | 23 +++++++------ - net/nic/nic_fec/hikp_nic_fec.c | 2 ++ - net/nic/nic_ft/hikp_nic_port_fault.c | 2 ++ - net/nic/nic_gro/hikp_nic_gro.c | 2 ++ - net/nic/nic_info/hikp_nic_info.c | 2 ++ - net/nic/nic_log/hikp_nic_log.c | 2 ++ - net/nic/nic_mac/hikp_nic_mac_dump.c | 4 +++ - net/nic/nic_mac/hikp_nic_port.c | 2 ++ - net/nic/nic_mac/hikp_nic_xsfp.c | 17 ++++++---- - net/nic/nic_ncsi/hikp_nic_ncsi.c | 2 ++ - net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c | 2 ++ - net/nic/nic_ppp/hikp_nic_ppp.c | 4 +++ - net/nic/nic_qos/hikp_nic_qos.c | 2 ++ - net/nic/nic_queue/hikp_nic_queue.c | 2 ++ - net/nic/nic_rss/hikp_nic_rss.c | 2 ++ - net/nic/nic_torus/hikp_nic_torus.c | 2 ++ - net/roce/roce_bond/hikp_roce_bond.c | 4 +++ - net/roce/roce_caep/hikp_roce_caep.c | 7 ++++ - .../roce_global_cfg/hikp_roce_global_cfg.c | 6 +++- - net/roce/roce_gmv/hikp_roce_gmv.c | 4 +++ - net/roce/roce_mdb/hikp_roce_mdb.c | 8 +++++ - net/roce/roce_pkt/hikp_roce_pkt.c | 5 +++ - net/roce/roce_qmm/hikp_roce_qmm.c | 10 ++++-- - net/roce/roce_rst/hikp_roce_rst.c | 4 +++ - net/roce/roce_scc/hikp_roce_scc.c | 5 +++ - net/roce/roce_timer/hikp_roce_timer.c | 11 ++++++- - net/roce/roce_trp/hikp_roce_trp.c | 2 ++ - net/roce/roce_tsp/hikp_roce_tsp.c | 5 +++ - net/roh/hikp_roh_mac.c | 6 ++-- - net/roh/hikp_roh_show_bp.c | 5 +++ - net/roh/hikp_roh_show_mib.c | 5 +++ - net/ub/ub_bp/hikp_ub_bp.c | 2 ++ - net/ub/ub_crd/hikp_ub_crd.c | 2 ++ - net/ub/ub_dfx/hikp_ub_dfx.c | 2 ++ - net/ub/ub_info/hikp_ub_info.c | 2 ++ - net/ub/ub_link/hikp_ub_link.c | 2 ++ - net/ub/ub_ppp/hikp_unic_ppp.c | 7 ++-- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 2 +- - pcie/usr_cmd/cmd_analysis/pcie_cmd_dumpreg.c | 9 ++++++ - pcie/usr_cmd/cmd_analysis/pcie_cmd_info.c | 13 ++++++++ - pcie/usr_cmd/cmd_analysis/pcie_cmd_reg_read.c | 11 +++++++ - pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c | 18 +++++++++++ - sas/sas_func/sas_analy_queue.c | 2 +- - sas/sas_func/sas_dump_reg.c | 6 ++-- - sas/sas_func/sas_read_dev.c | 6 ++-- - sas/sas_func/sas_read_dqe.c | 6 ++-- - sas/sas_func/sas_read_errcode.c | 2 +- - sas/user_cmd/cmd_code/sas_cmd_anacq.c | 8 +++++ - sas/user_cmd/cmd_code/sas_cmd_anadq.c | 8 +++++ - sas/user_cmd/cmd_code/sas_cmd_common.c | 2 +- - sas/user_cmd/cmd_code/sas_cmd_dev.c | 5 +++ - sas/user_cmd/cmd_code/sas_cmd_dqe.c | 4 ++- - sas/user_cmd/cmd_code/sas_cmd_dump.c | 8 +++++ - sas/user_cmd/cmd_code/sas_cmd_errcode.c | 2 ++ - sata/sata_func/sata_dump_reg.c | 4 +-- - sata/user_cmd/cmd_code/sata_cmd_dump.c | 11 +++++++ - serdes/hikp_serdes.c | 7 ++++ - socip/hikp_socip_dumpreg.c | 2 ++ - tool_lib/op_logs.c | 32 +++++++++---------- - tool_lib/tool_lib.c | 2 +- - tool_lib/tool_lib.h | 4 +++ - 69 files changed, 377 insertions(+), 72 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index f28a870..56cc932 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -11,7 +11,15 @@ - - project(hikptool C) - --set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -fPIC -fPIE -Wall -Werror -fno-common -std=gnu11") -+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \ -+ -O2 -fPIC -fPIE -Wall -Werror -Wextra -Wuninitialized -Wundef -Wunused -Wdate-time \ -+ -Wshadow -Wvla -Wdisabled-optimization -Wempty-body -Wignored-qualifiers \ -+ -Wimplicit-fallthrough=3 -Wtype-limits -Wshift-negative-value -Wswitch-default \ -+ -Wframe-larger-than=8192 -Wshift-overflow=2 -Wwrite-strings -Wmissing-format-attribute \ -+ -Wformat-nonliteral -Wduplicated-cond -Wtrampolines -Wlogical-op -Wsuggest-attribute=format \ -+ -Wduplicated-branches -Wmissing-include-dirs -Wmissing-declarations \ -+ -Wreturn-local-addr -Wredundant-decls -Wfloat-conversion -Wmissing-prototypes \ -+ -Wno-discarded-qualifiers -Wstrict-prototypes -fno-common -std=gnu11") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-equal -fstack-protector-strong -D_FORTIFY_SOURCE=2") - set(CMAKE_SKIP_RPATH TRUE) - -diff --git a/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c b/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c -index 2df9dc5..208a7d4 100644 ---- a/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c -+++ b/cxl/usr_cmd/cmd_analysis/cxl_cmd_cpa.c -@@ -25,6 +25,8 @@ struct tool_cxl_cmd g_cxl_cpa_cmd = { - - static int cxl_cpa_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf(" Usage: %s\n", self->cmd_ptr->name); - printf(" %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-i", "--interface", "please input port[x] first"); -@@ -44,6 +46,8 @@ static int cxl_port_id_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = string_toui(argv, &val); - if (ret) { - printf("cxl cpa set port id err %d\n", ret); -@@ -56,6 +60,9 @@ static int cxl_port_id_set(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_cpa_err_status_show(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_cpa_cmd.cmd_type = CPA_ERR; - - return 0; -@@ -63,6 +70,9 @@ static int cxl_cpa_err_status_show(struct major_cmd_ctrl *self, const char *argv - - static int cxl_cpa_mmrg_show(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_cpa_cmd.cmd_type = CPA_MMRG; - - return 0; -@@ -70,6 +80,9 @@ static int cxl_cpa_mmrg_show(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_cpa_dump(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_cpa_cmd.cmd_type = CPA_DUMP; - - return 0; -@@ -77,6 +90,9 @@ static int cxl_cpa_dump(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_cpa_config(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_cpa_cmd.cmd_type = CPA_CONFIG; - - return 0; -diff --git a/cxl/usr_cmd/cmd_analysis/cxl_cmd_dl.c b/cxl/usr_cmd/cmd_analysis/cxl_cmd_dl.c -index 226db1e..7ac0784 100644 ---- a/cxl/usr_cmd/cmd_analysis/cxl_cmd_dl.c -+++ b/cxl/usr_cmd/cmd_analysis/cxl_cmd_dl.c -@@ -25,6 +25,8 @@ struct tool_cxl_cmd g_cxl_dl_cmd = { - - static int cxl_dl_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf(" Usage: %s\n", self->cmd_ptr->name); - printf(" %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-i", "--interface", "please input port[x] first"); -@@ -44,6 +46,8 @@ static int cxl_dl_port_id_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = string_toui(argv, &val); - if (ret) { - printf("cxl dl set port id err %d\n", ret); -@@ -56,6 +60,9 @@ static int cxl_dl_port_id_set(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_dl_err_status(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_dl_cmd.cmd_type = CXL_DL_ERR; - - return 0; -@@ -63,6 +70,9 @@ static int cxl_dl_err_status(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_dl_dump(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_dl_cmd.cmd_type = CXL_DL_DUMP; - - return 0; -@@ -70,6 +80,9 @@ static int cxl_dl_dump(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_dl_dfx(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_dl_cmd.cmd_type = CXL_DL_DFX; - - return 0; -@@ -77,6 +90,9 @@ static int cxl_dl_dfx(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_dl_fsm_state(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_dl_cmd.cmd_type = CXL_DL_FSM_STATE; - - return 0; -diff --git a/cxl/usr_cmd/cmd_analysis/cxl_cmd_membar.c b/cxl/usr_cmd/cmd_analysis/cxl_cmd_membar.c -index f444b56..0ebca4f 100644 ---- a/cxl/usr_cmd/cmd_analysis/cxl_cmd_membar.c -+++ b/cxl/usr_cmd/cmd_analysis/cxl_cmd_membar.c -@@ -25,6 +25,8 @@ struct tool_cxl_cmd g_cxl_membar_cmd = { - - static int cxl_membar_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf(" Usage: %s\n", self->cmd_ptr->name); - printf(" %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-i", "--interface", "please input port[x] first"); -@@ -42,6 +44,8 @@ static int cxl_membar_port_id_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = string_toui(argv, &val); - if (ret) { - printf("cxl membar set port id err %d\n", ret); -@@ -54,6 +58,9 @@ static int cxl_membar_port_id_set(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_membar_err_info(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_membar_cmd.cmd_type = CXL_MEMBAR_ERR; - - return 0; -@@ -61,6 +68,9 @@ static int cxl_membar_err_info(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_membar_dump(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_membar_cmd.cmd_type = CXL_MEMBAR_DUMP; - - return 0; -diff --git a/cxl/usr_cmd/cmd_analysis/cxl_cmd_rcrb.c b/cxl/usr_cmd/cmd_analysis/cxl_cmd_rcrb.c -index f83b64d..0179605 100644 ---- a/cxl/usr_cmd/cmd_analysis/cxl_cmd_rcrb.c -+++ b/cxl/usr_cmd/cmd_analysis/cxl_cmd_rcrb.c -@@ -25,6 +25,8 @@ struct tool_cxl_cmd g_cxl_rcrb_cmd = { - - static int cxl_rcrb_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf(" Usage: %s\n", self->cmd_ptr->name); - printf(" %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-i", "--interface", "please input port[x] first"); -@@ -43,6 +45,8 @@ static int cxl_rcrb_port_id_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = string_toui(argv, &val); - if (ret) { - printf("cxl rcrb set port id err %d\n", ret); -@@ -55,6 +59,9 @@ static int cxl_rcrb_port_id_set(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_rcrb_link_status(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_rcrb_cmd.cmd_type = CXL_RCRB_LINK; - - return 0; -@@ -62,6 +69,9 @@ static int cxl_rcrb_link_status(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_rcrb_header_info(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_rcrb_cmd.cmd_type = CXL_RCRB_HDR; - - return 0; -@@ -69,6 +79,9 @@ static int cxl_rcrb_header_info(struct major_cmd_ctrl *self, const char *argv) - - static int cxl_rcrb_dump(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_cxl_rcrb_cmd.cmd_type = CXL_RCRB_DUMP; - - return 0; -diff --git a/libhikptdev/src/rciep/hikpt_rciep.c b/libhikptdev/src/rciep/hikpt_rciep.c -index 5a38b3b..88ac16e 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.c -+++ b/libhikptdev/src/rciep/hikpt_rciep.c -@@ -526,27 +526,35 @@ static void hikp_munmap(void) - g_hikp_rsp = NULL; - } - -+static int hikp_dev_set_iep_fd(char *iep) -+{ -+ char path[PATH_MAX + 1] = { 0 }; -+ -+ if (strlen(iep) > PATH_MAX || realpath(iep, path) == NULL) -+ return -ENOENT; -+ -+ g_iep_fd = open(path, O_RDWR | O_SYNC); -+ if (g_iep_fd < 0) { -+ printf("failed to open %s.\n", iep); -+ return -errno; -+ } -+ -+ return 0; -+} -+ - int hikp_dev_init(void) - { - size_t i, len; - int ret = 0; - char *iep; -- char path[PATH_MAX + 1] = { 0 }; - - iep = hikp_get_iep_dir(HIKP_RESOURCE_DIR); - if (iep == NULL) - return -ENOENT; - -- if (strlen(iep) > PATH_MAX || realpath(iep, path) == NULL) { -- ret = -ENOENT; -- goto out_free_iep; -- } -- g_iep_fd = open(path, O_RDWR | O_SYNC); -- if (g_iep_fd < 0) { -- printf("failed to open %s.\n", iep); -- ret = -errno; -+ ret = hikp_dev_set_iep_fd(iep); -+ if (ret) - goto out_free_iep; -- } - - g_hikp_req = (union hikp_space_req *)mmap(0, sizeof(union hikp_space_req), - PROT_READ | PROT_WRITE, MAP_SHARED, g_iep_fd, 0); -diff --git a/net/hikp_net_lib.c b/net/hikp_net_lib.c -index f4d4c2a..7646aad 100644 ---- a/net/hikp_net_lib.c -+++ b/net/hikp_net_lib.c -@@ -309,7 +309,7 @@ int get_vf_dev_info_by_pf_dev_name(const char *pf_dev_name, - - ret = snprintf(dev_name_dir, sizeof(dev_name_dir), "%s%s%s%u%s", HIKP_NET_DEV_PATH, - pf_dev_name, HIKP_VIRTFN_PATH, vf_id, HIKP_NET_PATH); -- if (ret < 0 || ret >= sizeof(dev_name_dir)) { -+ if (ret < 0 || ret >= MAX_BUS_PCI_DIR_LEN) { - HIKP_ERROR_PRINT("get vf dev_name dir fail.\n"); - return -EIO; - } -@@ -333,7 +333,7 @@ int get_pf_dev_info_by_vf_dev_name(const char *vf_dev_name, struct tool_target * - - ret = snprintf(dev_name_dir, sizeof(dev_name_dir), "%s%s%s", HIKP_NET_DEV_PATH, - vf_dev_name, HIKP_PHYSFN_PATH); -- if (ret < 0 || ret >= sizeof(dev_name_dir)) { -+ if (ret < 0 || ret >= MAX_BUS_PCI_DIR_LEN) { - HIKP_ERROR_PRINT("get vf dev_name dir fail.\n"); - return -EIO; - } -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c -index 3bc4e05..d6114de 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.c -+++ b/net/nic/nic_dfx/hikp_nic_dfx.c -@@ -424,6 +424,8 @@ static void dfx_help_info(const struct major_cmd_ctrl *self) - - static int hikp_cmd_dfx_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - dfx_help_info(self); - return 0; - } -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index d19d7c8..fb5f029 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -118,6 +118,8 @@ void hikp_nic_set_fd_idx(int feature_idx, int stage_no) - - static int hikp_nic_fd_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -@@ -640,6 +642,8 @@ static int hikp_nic_query_fd_rules(struct hikp_cmd_header *req_header, const str - uint32_t idx; - int ret = 0; - -+ HIKP_SET_USED(len); -+ - if (stage >= NIC_FD_STAGE_NUM) { - HIKP_ERROR_PRINT("The fd stage number(%d) is error!\n", stage + 1); - return -EIO; -@@ -700,6 +704,8 @@ static int hikp_nic_query_fd_counter(struct hikp_cmd_header *req_header, const s - uint16_t idx; - int ret = 0; - -+ HIKP_SET_USED(len); -+ - if (stage >= NIC_FD_STAGE_NUM) { - HIKP_ERROR_PRINT("The fd stage number(%d) is error!\n", stage + 1); - return -EIO; -@@ -757,7 +763,7 @@ static int hikp_nic_get_fd_hw_info(const struct bdf_t *bdf, struct nic_fd_hw_inf - sizeof(*hw_info)); - } - --static int hikp_nic_fd_alloc_rules_buf(struct nic_fd_rules *rules, uint8_t stage_num, -+static int hikp_nic_fd_alloc_rules_buf(struct nic_fd_rules *rules, - struct nic_fd_hw_info *hw_info, uint16_t stage_no) - { - uint16_t max_key_bytes; -@@ -775,7 +781,7 @@ static int hikp_nic_fd_alloc_rules_buf(struct nic_fd_rules *rules, uint8_t stage - return 0; - } - --static int hikp_nic_fd_alloc_counter_buf(struct nic_fd_counter *counter, uint8_t stage_num, -+static int hikp_nic_fd_alloc_counter_buf(struct nic_fd_counter *counter, - struct nic_fd_hw_info *hw_info, uint16_t stage_no) - { - counter[stage_no].entry = -@@ -789,8 +795,7 @@ static int hikp_nic_fd_alloc_counter_buf(struct nic_fd_counter *counter, uint8_t - return 0; - } - --static union nic_fd_feature_info *hikp_nic_fd_data_alloc(const struct fd_feature_cmd *fd_cmd, -- const struct nic_fd_hw_info *hw_cfg) -+static union nic_fd_feature_info *hikp_nic_fd_data_alloc(const struct fd_feature_cmd *fd_cmd) - { - uint16_t stage_no = g_fd_param.stage_no - 1; - union nic_fd_feature_info *fd_data; -@@ -803,11 +808,9 @@ static union nic_fd_feature_info *hikp_nic_fd_data_alloc(const struct fd_feature - } - - if (strcmp(fd_cmd->feature_name, NIC_FD_RULES_NAME) == 0) -- ret = hikp_nic_fd_alloc_rules_buf(fd_data->rules, NIC_FD_STAGE_NUM, -- &g_fd_hw_info, stage_no); -+ ret = hikp_nic_fd_alloc_rules_buf(fd_data->rules, &g_fd_hw_info, stage_no); - else if (strcmp(fd_cmd->feature_name, NIC_FD_COUNTER_NAME) == 0) -- ret = hikp_nic_fd_alloc_counter_buf(fd_data->counter, NIC_FD_STAGE_NUM, -- &g_fd_hw_info, stage_no); -+ ret = hikp_nic_fd_alloc_counter_buf(fd_data->counter, &g_fd_hw_info, stage_no); - if (ret != 0) - goto out; - -@@ -884,7 +887,7 @@ static int hikp_nic_fd_check_entry_index_valid(struct major_cmd_ctrl *self, - hw_entry_size = fd_cmd->sub_cmd_code == NIC_FD_RULES_INFO_DUMP ? - hw_info->alloc.stage_entry_num[stage_no] : - hw_info->alloc.stage_counter_num[stage_no]; -- if (fd_param->id >= hw_entry_size) { -+ if ((uint32_t)fd_param->id >= hw_entry_size) { - snprintf(self->err_str, sizeof(self->err_str), - "entry id(%d) must be less than hardware specifications(%u).", - fd_param->id, hw_entry_size); -@@ -963,7 +966,7 @@ void hikp_nic_fd_cmd_execute(struct major_cmd_ctrl *self) - if (ret != 0) - return; - -- fd_data = hikp_nic_fd_data_alloc(fd_cmd, &g_fd_hw_info); -+ fd_data = hikp_nic_fd_data_alloc(fd_cmd); - if (fd_data == NULL) { - HIKP_ERROR_PRINT("Fail to alloc fd data memory.\n"); - self->err_no = -ENOMEM; -diff --git a/net/nic/nic_fec/hikp_nic_fec.c b/net/nic/nic_fec/hikp_nic_fec.c -index 13c6e13..8de0b59 100644 ---- a/net/nic/nic_fec/hikp_nic_fec.c -+++ b/net/nic/nic_fec/hikp_nic_fec.c -@@ -126,6 +126,8 @@ void hikp_nic_fec_cmd_execute(struct major_cmd_ctrl *self) - - static int hikp_nic_fec_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/nic/nic_ft/hikp_nic_port_fault.c b/net/nic/nic_ft/hikp_nic_port_fault.c -index 331b1ec..7d15a07 100644 ---- a/net/nic/nic_ft/hikp_nic_port_fault.c -+++ b/net/nic/nic_ft/hikp_nic_port_fault.c -@@ -98,6 +98,8 @@ void hikp_nic_port_fault_cmd_execute(struct major_cmd_ctrl *self) - - static int hikp_nic_port_fault_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/nic/nic_gro/hikp_nic_gro.c b/net/nic/nic_gro/hikp_nic_gro.c -index d821a47..3e9b31a 100644 ---- a/net/nic/nic_gro/hikp_nic_gro.c -+++ b/net/nic/nic_gro/hikp_nic_gro.c -@@ -71,6 +71,8 @@ void hikp_nic_gro_cmd_execute(struct major_cmd_ctrl *self) - - static int hikp_nic_gro_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/nic/nic_info/hikp_nic_info.c b/net/nic/nic_info/hikp_nic_info.c -index 6fb17a2..b05d6ef 100644 ---- a/net/nic/nic_info/hikp_nic_info.c -+++ b/net/nic/nic_info/hikp_nic_info.c -@@ -25,6 +25,8 @@ static struct nic_info_param g_info_param = { 0 }; - - static int hikp_nic_cmd_get_info_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/nic/nic_log/hikp_nic_log.c b/net/nic/nic_log/hikp_nic_log.c -index be23ca3..0e2d556 100644 ---- a/net/nic/nic_log/hikp_nic_log.c -+++ b/net/nic/nic_log/hikp_nic_log.c -@@ -27,6 +27,8 @@ static char g_log_path[OP_LOG_FILE_PATH_MAXLEN] = {0}; - - static int hikp_nic_cmd_log_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -diff --git a/net/nic/nic_mac/hikp_nic_mac_dump.c b/net/nic/nic_mac/hikp_nic_mac_dump.c -index 751953c..e0d0891 100644 ---- a/net/nic/nic_mac/hikp_nic_mac_dump.c -+++ b/net/nic/nic_mac/hikp_nic_mac_dump.c -@@ -217,6 +217,8 @@ int mac_cmd_dump_reg_target(struct major_cmd_ctrl *self, const char *argv) - - static int mac_cmd_dump_reg_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i -m \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -235,6 +237,8 @@ static int mac_cmd_dump_reg_help(struct major_cmd_ctrl *self, const char *argv) - - int mac_cmd_dump_module_cfg(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ - g_dump_reg_info.module_name = argv; - - return 0; -diff --git a/net/nic/nic_mac/hikp_nic_port.c b/net/nic/nic_mac/hikp_nic_port.c -index 737de07..396c3ec 100644 ---- a/net/nic/nic_mac/hikp_nic_port.c -+++ b/net/nic/nic_mac/hikp_nic_port.c -@@ -619,6 +619,8 @@ static int mac_cmd_get_port_target(struct major_cmd_ctrl *self, const char *argv - - static int mac_cmd_port_show_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/nic/nic_mac/hikp_nic_xsfp.c b/net/nic/nic_mac/hikp_nic_xsfp.c -index 91daa52..fc24d59 100644 ---- a/net/nic/nic_mac/hikp_nic_xsfp.c -+++ b/net/nic/nic_mac/hikp_nic_xsfp.c -@@ -313,7 +313,7 @@ static void sfp_print_dom_info(const struct sfp_page_info *info) - (int8_t)info->page_a2.temperature[0], info->page_a2.temperature[1]); - } - --static void hikp_show_sfp_info(const uint8_t *data, uint32_t size) -+static void hikp_show_sfp_info(const uint8_t *data) - { - struct sfp_page_info *sfp_data = (struct sfp_page_info *)data; - -@@ -412,7 +412,7 @@ static void qsfp_print_dom_info(const struct qsfp_page0_info *info) - (int8_t)info->page_lower.temperature_msb, info->page_lower.temperature_lsb); - } - --static void hikp_show_qsfp_info(const uint8_t *data, uint32_t size) -+static void hikp_show_qsfp_info(const uint8_t *data) - { - struct qsfp_page0_info *qsfp_data = (struct qsfp_page0_info *)(data); - -@@ -554,7 +554,7 @@ static void cmis_print_dom_info(const struct cmis_page_info *info) - info->page0_lower.module_temp[1]); - } - --static void hikp_show_cmis_info(const uint8_t *data, uint32_t size) -+static void hikp_show_cmis_info(const uint8_t *data) - { - struct cmis_page_info *cmis_data = (struct cmis_page_info *)data; - -@@ -567,17 +567,17 @@ static void hikp_show_cmis_info(const uint8_t *data, uint32_t size) - static void hikp_xsfp_parse_info(const uint8_t *data, uint32_t size) - { - if (data[SFF_ID_OFFSET] == ID_SFP) { -- hikp_show_sfp_info(data, size); -+ hikp_show_sfp_info(data); - } else if (data[SFF_ID_OFFSET] == ID_QSFP || - data[SFF_ID_OFFSET] == ID_QSFP_PLUS || - data[SFF_ID_OFFSET] == ID_QSFP28) { -- hikp_show_qsfp_info(data, size); -+ hikp_show_qsfp_info(data); - } else if (data[SFF_ID_OFFSET] == ID_QSFP_DD || - data[SFF_ID_OFFSET] == ID_SFP_DD || - data[SFF_ID_OFFSET] == ID_QSFP_P_CMIS || - data[SFF_ID_OFFSET] == ID_SFP_DD_CMIS || - data[SFF_ID_OFFSET] == ID_SFP_P_CMIS) { -- hikp_show_cmis_info(data, size); -+ hikp_show_cmis_info(data); - } else { - /* unknown type just dump hex data */ - hikp_xsfp_dump_hex(data, size); -@@ -702,6 +702,8 @@ ERR_OUT: - - static int hikp_xsfp_show_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i [-d]"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -@@ -729,6 +731,9 @@ static int hikp_xsfp_get_target(struct major_cmd_ctrl *self, const char *argv) - - static int hikp_xsfp_dump_raw_data(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_xsfp_dump.dump_param |= XSFP_RAW_DATA_BIT; - - return 0; -diff --git a/net/nic/nic_ncsi/hikp_nic_ncsi.c b/net/nic/nic_ncsi/hikp_nic_ncsi.c -index 84f6337..955e456 100644 ---- a/net/nic/nic_ncsi/hikp_nic_ncsi.c -+++ b/net/nic/nic_ncsi/hikp_nic_ncsi.c -@@ -89,6 +89,8 @@ static int nic_ncsi_cmd_get_port_info(struct major_cmd_ctrl *self, const char *a - - static int nic_ncsi_cmd_show_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -index 4efaadc..c301dad 100644 ---- a/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -+++ b/net/nic/nic_notify_pkt/hikp_nic_notify_pkt.c -@@ -84,6 +84,8 @@ void hikp_nic_notify_pkt_cmd_execute(struct major_cmd_ctrl *self) - - static int hikp_nic_notify_pkt_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index 24f41ee..43a9000 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -66,6 +66,8 @@ void hikp_nic_ppp_set_cmd_param(int feature_idx) - - static int hikp_nic_ppp_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -@@ -788,6 +790,8 @@ static int hikp_nic_query_ppp_by_entryid(struct hikp_cmd_header *req_header, - const struct ppp_feature_cmd *ppp_cmd; - struct nic_ppp_req_para req_data = {0}; - -+ HIKP_SET_USED(len); -+ - req_data.bdf = *bdf; - ppp_cmd = &g_ppp_feature_cmd[g_ppp_param.feature_idx]; - if (strcmp(ppp_cmd->feature_name, NIC_PPP_MAC_TBL_NAME) == 0) -diff --git a/net/nic/nic_qos/hikp_nic_qos.c b/net/nic/nic_qos/hikp_nic_qos.c -index dc6f63e..6435f7c 100644 ---- a/net/nic/nic_qos/hikp_nic_qos.c -+++ b/net/nic/nic_qos/hikp_nic_qos.c -@@ -45,6 +45,8 @@ void hikp_nic_qos_set_cmd_direction(enum nic_pfc_dir dir) - - static int hikp_nic_qos_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/nic/nic_queue/hikp_nic_queue.c b/net/nic/nic_queue/hikp_nic_queue.c -index 5bb4335..dae634f 100644 ---- a/net/nic/nic_queue/hikp_nic_queue.c -+++ b/net/nic/nic_queue/hikp_nic_queue.c -@@ -42,6 +42,8 @@ void hikp_nic_queue_cmd_set_param(int feature_idx, int qid, enum nic_queue_dir d - - static int hikp_nic_queue_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/nic/nic_rss/hikp_nic_rss.c b/net/nic/nic_rss/hikp_nic_rss.c -index a7448e4..76cab8a 100644 ---- a/net/nic/nic_rss/hikp_nic_rss.c -+++ b/net/nic/nic_rss/hikp_nic_rss.c -@@ -139,6 +139,8 @@ void hikp_nic_rss_cmd_set_feature_idx(int feature_idx) - - static int hikp_nic_rss_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/nic/nic_torus/hikp_nic_torus.c b/net/nic/nic_torus/hikp_nic_torus.c -index d5e22b1..7ad5211 100644 ---- a/net/nic/nic_torus/hikp_nic_torus.c -+++ b/net/nic/nic_torus/hikp_nic_torus.c -@@ -148,6 +148,8 @@ void hikp_nic_torus_cmd_execute(struct major_cmd_ctrl *self) - - static int hikp_nic_torus_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -diff --git a/net/roce/roce_bond/hikp_roce_bond.c b/net/roce/roce_bond/hikp_roce_bond.c -index 5256804..244f29c 100644 ---- a/net/roce/roce_bond/hikp_roce_bond.c -+++ b/net/roce/roce_bond/hikp_roce_bond.c -@@ -23,6 +23,8 @@ int hikp_roce_set_bond_bdf(char *nic_name) - - static int hikp_roce_bond_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -51,6 +53,8 @@ static int hikp_roce_bond_get_data(struct hikp_cmd_ret **cmd_ret, - uint32_t req_size; - int ret; - -+ HIKP_SET_USED(reg_name); -+ - req_data.bdf = g_roce_bond_param.target.bdf; - req_data.block_id = block_id; - -diff --git a/net/roce/roce_caep/hikp_roce_caep.c b/net/roce/roce_caep/hikp_roce_caep.c -index 95795d1..290aa18 100644 ---- a/net/roce/roce_caep/hikp_roce_caep.c -+++ b/net/roce/roce_caep/hikp_roce_caep.c -@@ -28,6 +28,8 @@ void hikp_roce_set_caep_mode(uint32_t mode) - - static int hikp_roce_caep_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -59,6 +61,8 @@ static int hikp_roce_caep_get_data(struct hikp_cmd_ret **cmd_ret, - uint32_t req_size; - int ret; - -+ HIKP_SET_USED(reg_name); -+ - req_data_ext.origin_param.bdf = g_roce_caep_param_t.target.bdf; - req_data_ext.block_id = block_id; - -@@ -124,6 +128,9 @@ void hikp_roce_caep_execute(struct major_cmd_ctrl *self) - - static int hikp_roce_caep_ext_set(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_roce_caep_param_t.sub_cmd = CAEP_EXT; - - return 0; -diff --git a/net/roce/roce_global_cfg/hikp_roce_global_cfg.c b/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -index ca42dfa..8b0d93a 100644 ---- a/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -+++ b/net/roce/roce_global_cfg/hikp_roce_global_cfg.c -@@ -24,6 +24,8 @@ int hikp_roce_set_global_cfg_bdf(char *nic_name) - static int hikp_roce_global_cfg_help(struct major_cmd_ctrl *self, - const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -54,6 +56,8 @@ static int hikp_roce_global_cfg_get_data(struct hikp_cmd_ret **cmd_ret, - uint32_t req_size; - int ret; - -+ HIKP_SET_USED(reg_name); -+ - req_data.bdf = g_roce_global_cfg_param.target.bdf; - req_data.block_id = block_id; - -@@ -81,7 +85,7 @@ void hikp_roce_global_cfg_execute(struct major_cmd_ctrl *self) - ROCE_GLB_TDP_M, - ROCE_GLB_NICL, - }; -- int i; -+ size_t i; - - for (i = 0; i < HIKP_ARRAY_SIZE(sub_cmds); i++) { - g_roce_global_cfg_param.sub_cmd = sub_cmds[i]; -diff --git a/net/roce/roce_gmv/hikp_roce_gmv.c b/net/roce/roce_gmv/hikp_roce_gmv.c -index 5f96451..92bead1 100644 ---- a/net/roce/roce_gmv/hikp_roce_gmv.c -+++ b/net/roce/roce_gmv/hikp_roce_gmv.c -@@ -29,6 +29,8 @@ void hikp_roce_set_gmv_index(uint32_t gmv_index) - - static int hikp_roce_gmv_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -103,6 +105,8 @@ void hikp_roce_gmv_execute(struct major_cmd_ctrl *self) - uint32_t reg_num; - int ret; - -+ HIKP_SET_USED(self); -+ - req_data.bdf = g_roce_gmv_param.target.bdf; - req_data.gmv_index = g_roce_gmv_param.gmv_index; - hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_GMV_CMD, GMV_SHOW); -diff --git a/net/roce/roce_mdb/hikp_roce_mdb.c b/net/roce/roce_mdb/hikp_roce_mdb.c -index e0a7cc5..c0d028f 100644 ---- a/net/roce/roce_mdb/hikp_roce_mdb.c -+++ b/net/roce/roce_mdb/hikp_roce_mdb.c -@@ -29,6 +29,8 @@ void hikp_roce_set_mdb_mode(uint8_t mode) - - static int hikp_roce_mdb_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -54,6 +56,9 @@ static int hikp_roce_mdb_target(struct major_cmd_ctrl *self, const char *argv) - - static int hikp_roce_mdb_clear_set(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_roce_mdb_param.flag |= ROCE_MDB_CMD_CLEAR; - - return 0; -@@ -182,6 +187,9 @@ void hikp_roce_mdb_execute(struct major_cmd_ctrl *self) - - static int hikp_roce_mdb_ext_set(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_roce_mdb_param.flag |= ROCE_MDB_CMD_EXT; - - return 0; -diff --git a/net/roce/roce_pkt/hikp_roce_pkt.c b/net/roce/roce_pkt/hikp_roce_pkt.c -index 5a6b268..1538788 100644 ---- a/net/roce/roce_pkt/hikp_roce_pkt.c -+++ b/net/roce/roce_pkt/hikp_roce_pkt.c -@@ -23,6 +23,8 @@ int hikp_roce_set_pkt_bdf(char *nic_name) - - static int hikp_roce_pkt_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -47,6 +49,9 @@ static int hikp_roce_pkt_target(struct major_cmd_ctrl *self, const char *argv) - - static int hikp_roce_pkt_clear_set(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_roce_pkt_param_t.reset_flag = 1; - return 0; - } -diff --git a/net/roce/roce_qmm/hikp_roce_qmm.c b/net/roce/roce_qmm/hikp_roce_qmm.c -index 30caa5a..af327c2 100644 ---- a/net/roce/roce_qmm/hikp_roce_qmm.c -+++ b/net/roce/roce_qmm/hikp_roce_qmm.c -@@ -34,6 +34,8 @@ void hikp_roce_set_qmm_bankid(uint32_t bank_id) - - static int hikp_roce_qmm_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -208,7 +210,8 @@ static int hikp_roce_qmm_get_data(struct hikp_cmd_ret **cmd_ret, - struct roce_qmm_req_para_ext req_data_ext; - struct hikp_cmd_header req_header = { 0 }; - uint32_t req_size; -- int ret, i; -+ size_t i; -+ int ret; - - if (reg_name) { - for (i = 0; i < HIKP_ARRAY_SIZE(g_qmm_reg_name_info_table); i++) { -@@ -277,7 +280,7 @@ void hikp_roce_qmm_execute(struct major_cmd_ctrl *self) - {QMM_SHOW_TOP, QMM_SHOW_TOP_EXT, "TOP"}, - }; - -- for (int i = 0; i < HIKP_ARRAY_SIZE(sub_cmd_info_table); i++) { -+ for (size_t i = 0; i < HIKP_ARRAY_SIZE(sub_cmd_info_table); i++) { - g_roce_qmm_param.sub_name = sub_cmd_info_table[i].sub_name; - if (g_roce_qmm_param.ext_flag) { - g_roce_qmm_param.sub_cmd = sub_cmd_info_table[i].sub_ext_cmd; -@@ -298,6 +301,9 @@ void hikp_roce_qmm_execute(struct major_cmd_ctrl *self) - - static int hikp_roce_qmm_ext_set(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_roce_qmm_param.ext_flag = true; - - return 0; -diff --git a/net/roce/roce_rst/hikp_roce_rst.c b/net/roce/roce_rst/hikp_roce_rst.c -index cfccc47..c49074b 100644 ---- a/net/roce/roce_rst/hikp_roce_rst.c -+++ b/net/roce/roce_rst/hikp_roce_rst.c -@@ -23,6 +23,8 @@ int hikp_roce_set_rst_bdf(char *nic_name) - - static int hikp_roce_rst_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -51,6 +53,8 @@ static int hikp_roce_rst_get_data(struct hikp_cmd_ret **cmd_ret, - uint32_t req_size; - int ret; - -+ HIKP_SET_USED(reg_name); -+ - req_data.bdf = g_roce_rst_param.target.bdf; - req_data.block_id = block_id; - -diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c -index c660799..67a2a1e 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.c -+++ b/net/roce/roce_scc/hikp_roce_scc.c -@@ -36,6 +36,8 @@ void hikp_roce_set_scc_submodule(uint32_t module) - - static int hikp_roce_scc_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -82,6 +84,9 @@ static int hikp_roce_scc_module_select(struct major_cmd_ctrl *self, const char * - - static int hikp_roce_scc_clear_set(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_roce_scc_param_t.reset_flag = 1; - - return 0; -diff --git a/net/roce/roce_timer/hikp_roce_timer.c b/net/roce/roce_timer/hikp_roce_timer.c -index a6af959..927d8a6 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.c -+++ b/net/roce/roce_timer/hikp_roce_timer.c -@@ -23,6 +23,8 @@ int hikp_roce_set_timer_bdf(char *nic_name) - - static int hikp_roce_timer_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -46,6 +48,9 @@ static int hikp_roce_timer_target(struct major_cmd_ctrl *self, const char *argv) - - static int hikp_roce_timer_clear_set(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_roce_timer_param.flag = ROCE_TIMER_CMD_CLEAR; - return 0; - } -@@ -120,6 +125,8 @@ static int hikp_roce_timer_show_qpc(struct major_cmd_ctrl *self) - struct hikp_cmd_ret *cmd_ret = NULL; - int ret; - -+ HIKP_SET_USED(self); -+ - req_data.bdf = g_roce_timer_param.target.bdf; - if (g_roce_timer_param.flag) - hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_TIMER_CMD, TIMER_QPC_CLEAR); -@@ -153,6 +160,8 @@ static int hikp_roce_timer_show_cqc(struct major_cmd_ctrl *self) - struct hikp_cmd_ret *cmd_ret = NULL; - int ret; - -+ HIKP_SET_USED(self); -+ - req_data.bdf = g_roce_timer_param.target.bdf; - if (g_roce_timer_param.flag) - hikp_cmd_init(&req_header, ROCE_MOD, GET_ROCEE_TIMER_CMD, TIMER_CQC_CLEAR); -@@ -204,7 +213,7 @@ void hikp_roce_timer_execute(struct major_cmd_ctrl *self) - hikp_roce_timer_show_cqc, hikp_roce_timer_show_qpc - }; - const char *function[] = {"show cqc", "show qpc"}; -- int i = 0; -+ size_t i = 0; - int ret; - - if (g_roce_timer_param.flag) { -diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c -index 9b1ddb1..67dfb8e 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.c -+++ b/net/roce/roce_trp/hikp_roce_trp.c -@@ -39,6 +39,8 @@ void hikp_roce_set_trp_submodule(uint32_t module) - - static int hikp_roce_trp_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.c b/net/roce/roce_tsp/hikp_roce_tsp.c -index e07e882..5fe2104 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.c -+++ b/net/roce/roce_tsp/hikp_roce_tsp.c -@@ -38,6 +38,8 @@ void hikp_roce_set_tsp_submodule(uint32_t module) - - static int hikp_roce_tsp_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -118,6 +120,9 @@ static int hikp_roce_tsp_bank_check(void) - - static int hikp_roce_tsp_clear_set(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_roce_tsp_param_t.reset_flag = 1; - - return 0; -diff --git a/net/roh/hikp_roh_mac.c b/net/roh/hikp_roh_mac.c -index aa13f92..e16a3db 100644 ---- a/net/roh/hikp_roh_mac.c -+++ b/net/roh/hikp_roh_mac.c -@@ -18,6 +18,8 @@ static struct roh_mac_param g_roh_mac_param = { 0 }; - - static int hikp_roh_mac_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, - "-i -s \n"); - printf("\n %s\n", self->cmd_ptr->help_info); -@@ -96,7 +98,7 @@ int hikp_roh_get_mac_type(struct major_cmd_ctrl *self, struct bdf_t bdf) - return is_roh; - } - --static void hikp_roh_show_mac_type(struct major_cmd_ctrl *self, int mac_type) -+static void hikp_roh_show_mac_type(int mac_type) - { - if (mac_type) - printf("MAC_TYPE: ROH\n"); -@@ -382,7 +384,7 @@ static void hikp_roh_mac_execute_entry(struct major_cmd_ctrl *self) - HIKP_ERROR_PRINT("Failed get current mac type\n"); - return; - } -- hikp_roh_show_mac_type(self, mac_type); -+ hikp_roh_show_mac_type(mac_type); - break; - case (CMD_SHOW_CAM_FLAG): - if (hikp_roh_is_roh(self) > 0) -diff --git a/net/roh/hikp_roh_show_bp.c b/net/roh/hikp_roh_show_bp.c -index 0b53eda..edc1dc6 100644 ---- a/net/roh/hikp_roh_show_bp.c -+++ b/net/roh/hikp_roh_show_bp.c -@@ -17,6 +17,8 @@ static struct cmd_roh_show_bp_param g_roh_show_bp_param = { 0 }; - - static int hikp_roh_show_bp_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i -s\n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -115,6 +117,9 @@ static void hikp_roh_show_bp_execute(struct major_cmd_ctrl *self) - - static int hikp_roh_show_bp_parse(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_roh_show_bp_param.flag |= ROH_CMD_SHOW_BP; - return 0; - } -diff --git a/net/roh/hikp_roh_show_mib.c b/net/roh/hikp_roh_show_mib.c -index 5f03355..96dd688 100644 ---- a/net/roh/hikp_roh_show_mib.c -+++ b/net/roh/hikp_roh_show_mib.c -@@ -151,6 +151,8 @@ static char g_roh_mac_mib_name[MIB_EVENT_COUNT][ROH_NAME_MAX] = { - - static int hikp_roh_show_mib_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i -s\n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -@@ -253,6 +255,9 @@ static void hikp_roh_show_mib_execute(struct major_cmd_ctrl *self) - - static int hikp_roh_show_mib_parse(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - roh_show_mib_param.flag |= ROH_CMD_SHOW_MIB; - return 0; - } -diff --git a/net/ub/ub_bp/hikp_ub_bp.c b/net/ub/ub_bp/hikp_ub_bp.c -index 179aa22..2dfe69c 100644 ---- a/net/ub/ub_bp/hikp_ub_bp.c -+++ b/net/ub/ub_bp/hikp_ub_bp.c -@@ -17,6 +17,8 @@ static struct ub_bp_param g_ub_bp_param = { 0 }; - - static int hikp_ub_bp_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -diff --git a/net/ub/ub_crd/hikp_ub_crd.c b/net/ub/ub_crd/hikp_ub_crd.c -index 6d2ba21..678bc84 100644 ---- a/net/ub/ub_crd/hikp_ub_crd.c -+++ b/net/ub/ub_crd/hikp_ub_crd.c -@@ -17,6 +17,8 @@ static struct ub_crd_param g_ub_crd_param = { 0 }; - - static int hikp_ub_crd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -diff --git a/net/ub/ub_dfx/hikp_ub_dfx.c b/net/ub/ub_dfx/hikp_ub_dfx.c -index dd3a713..8a3e293 100644 ---- a/net/ub/ub_dfx/hikp_ub_dfx.c -+++ b/net/ub/ub_dfx/hikp_ub_dfx.c -@@ -44,6 +44,8 @@ static void dfx_help_info(const struct major_cmd_ctrl *self) - - static int hikp_ub_dfx_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - dfx_help_info(self); - return 0; - } -diff --git a/net/ub/ub_info/hikp_ub_info.c b/net/ub/ub_info/hikp_ub_info.c -index d113f7c..ef58ff5 100644 ---- a/net/ub/ub_info/hikp_ub_info.c -+++ b/net/ub/ub_info/hikp_ub_info.c -@@ -17,6 +17,8 @@ static struct ub_info_param g_ub_info_param = { 0 }; - - static int hikp_ub_info_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -diff --git a/net/ub/ub_link/hikp_ub_link.c b/net/ub/ub_link/hikp_ub_link.c -index 1cc1879..801e56e 100644 ---- a/net/ub/ub_link/hikp_ub_link.c -+++ b/net/ub/ub_link/hikp_ub_link.c -@@ -17,6 +17,8 @@ static struct ub_link_param g_ub_link_param = { 0 }; - - static int hikp_ub_link_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i \n"); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" Options:\n\n"); -diff --git a/net/ub/ub_ppp/hikp_unic_ppp.c b/net/ub/ub_ppp/hikp_unic_ppp.c -index 01c1624..4c48e70 100644 ---- a/net/ub/ub_ppp/hikp_unic_ppp.c -+++ b/net/ub/ub_ppp/hikp_unic_ppp.c -@@ -39,6 +39,8 @@ static const struct unic_ppp_feature_cmd g_unic_ppp_feature_cmd[] = { - - static int hikp_unic_ppp_cmd_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -@@ -209,8 +211,7 @@ static int hikp_unic_ppp_alloc_guid_tbl_entry(const struct hikp_unic_ppp_hw_reso - } - - static union unic_ppp_feature_info* --hikp_unic_ppp_data_alloc(const struct unic_ppp_feature_cmd *unic_ppp_cmd, -- const struct hikp_unic_ppp_hw_resources *hw_res) -+hikp_unic_ppp_data_alloc(const struct hikp_unic_ppp_hw_resources *hw_res) - { - union unic_ppp_feature_info *unic_ppp_data; - int ret = -1; -@@ -461,7 +462,7 @@ static void hikp_unic_ppp_cmd_execute(struct major_cmd_ctrl *self) - } - - unic_ppp_cmd = &g_unic_ppp_feature_cmd[g_unic_ppp_param.feature_idx]; -- unic_ppp_data = hikp_unic_ppp_data_alloc(unic_ppp_cmd, &g_unic_ppp_hw_res); -+ unic_ppp_data = hikp_unic_ppp_data_alloc(&g_unic_ppp_hw_res); - if (unic_ppp_data == NULL) { - snprintf(self->err_str, sizeof(self->err_str), - "failed to allocate unic_ppp_data memory!"); -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index 0ce2e5d..4172637 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -446,7 +446,7 @@ static void pcie_dumpreg_write_value_to_file(const char *reg_name, uint32_t val) - int ret; - - ret = snprintf(str, sizeof(str), " %-40s : 0x%x\n", reg_name, val); -- if (ret < 0 || ret >= sizeof(str)) { -+ if (ret < 0 || ret >= MAX_STR_LEN) { - Err("pcie dumpreg write info to logfile failed.\n"); - } else { - wr_ret = write(g_pcie_dumpreg_fd, str, strlen(str)); -diff --git a/pcie/usr_cmd/cmd_analysis/pcie_cmd_dumpreg.c b/pcie/usr_cmd/cmd_analysis/pcie_cmd_dumpreg.c -index 6d1c674..8ec0404 100644 ---- a/pcie/usr_cmd/cmd_analysis/pcie_cmd_dumpreg.c -+++ b/pcie/usr_cmd/cmd_analysis/pcie_cmd_dumpreg.c -@@ -29,6 +29,8 @@ struct tool_pcie_cmd g_dumpreg_cmd = { - - static int pcie_dumpreg_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-i", "--interface", "please input port[x] first\n"); -@@ -48,6 +50,8 @@ static int pcie_port_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = string_toui(argv, &val); - if (ret) { - printf("info set port id err %d.\n", ret); -@@ -63,6 +67,8 @@ static int dump_level_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val = 0; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = string_toui(argv, &val); - if (ret || val < DUMP_GLOBAL_LEVEL || val > DUMP_PORT_LEVEL) { - printf("info set id err, ret = %d, val = %u\n", ret, val); -@@ -75,6 +81,9 @@ static int dump_level_set(struct major_cmd_ctrl *self, const char *argv) - - static int pcie_dumpreg_dump(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_dumpreg_cmd.cmd_type = DUMPREG_DUMP; - - return 0; -diff --git a/pcie/usr_cmd/cmd_analysis/pcie_cmd_info.c b/pcie/usr_cmd/cmd_analysis/pcie_cmd_info.c -index aeab241..f3bd46f 100644 ---- a/pcie/usr_cmd/cmd_analysis/pcie_cmd_info.c -+++ b/pcie/usr_cmd/cmd_analysis/pcie_cmd_info.c -@@ -26,6 +26,8 @@ struct tool_pcie_cmd g_info_cmd = { - - static int pcie_info_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-i", "--interface", -@@ -42,6 +44,9 @@ static int pcie_info_help(struct major_cmd_ctrl *self, const char *argv) - - static int pcie_distribution_show(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_info_cmd.cmd_type = INFO_DISTRIBUTION; - - return 0; -@@ -49,6 +54,9 @@ static int pcie_distribution_show(struct major_cmd_ctrl *self, const char *argv) - - static int pcie_err_state_show(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_info_cmd.cmd_type = INFO_ERR_STATE_SHOW; - - return 0; -@@ -56,6 +64,9 @@ static int pcie_err_state_show(struct major_cmd_ctrl *self, const char *argv) - - static int pcie_err_state_clear(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_info_cmd.cmd_type = INFO_ERR_STATE_CLEAR; - - return 0; -@@ -66,6 +77,8 @@ static int pcie_port_chip_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = string_toui(argv, &val); - if (ret) { - printf("info set id err %d\n", ret); -diff --git a/pcie/usr_cmd/cmd_analysis/pcie_cmd_reg_read.c b/pcie/usr_cmd/cmd_analysis/pcie_cmd_reg_read.c -index 6e54516..a884604 100644 ---- a/pcie/usr_cmd/cmd_analysis/pcie_cmd_reg_read.c -+++ b/pcie/usr_cmd/cmd_analysis/pcie_cmd_reg_read.c -@@ -32,6 +32,8 @@ struct tool_pcie_cmd g_regread_cmd = { - - static int pcie_reg_read_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-i", "--interface", "please input port[x] first\n"); -@@ -50,6 +52,8 @@ static int pcie_port_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = string_toui(argv, &val); - if (ret) { - printf("info set port id err %d.\n", ret); -@@ -65,6 +69,8 @@ static int read_module_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = pcie_read_name2module_id(argv, &val); - if (ret) { - printf("undefined module \"%s\".\n", argv); -@@ -80,6 +86,8 @@ static int read_offset_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = string_toui(argv, &val); - if (ret) { - printf("info set offset err %d.\n", ret); -@@ -92,6 +100,9 @@ static int read_offset_set(struct major_cmd_ctrl *self, const char *argv) - - static int pcie_reg_read_exe(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_regread_cmd.cmd_type = REGRD_READ; - - return 0; -diff --git a/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c b/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c -index 8ceb85a..7b0efde 100644 ---- a/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c -+++ b/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c -@@ -27,6 +27,8 @@ struct tool_pcie_cmd g_trace_cmd = { - - static int pcie_trace_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-i", "--interface", "please input port[x] first\n"); -@@ -45,6 +47,9 @@ static int pcie_trace_help(struct major_cmd_ctrl *self, const char *argv) - - static int pcie_trace_clear(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_trace_cmd.cmd_type = TRACE_CLEAR; - - return 0; -@@ -53,6 +58,9 @@ static int pcie_trace_clear(struct major_cmd_ctrl *self, const char *argv) - - static int pcie_trace_show(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_trace_cmd.cmd_type = TRACE_SHOW; - - return 0; -@@ -60,6 +68,9 @@ static int pcie_trace_show(struct major_cmd_ctrl *self, const char *argv) - - static int pcie_pm_show(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_trace_cmd.cmd_type = TRACE_PM; - - return 0; -@@ -70,6 +81,8 @@ static int pcie_trace_mode_set(struct major_cmd_ctrl *self, const char *argv) - int ret; - uint32_t val = 0; - -+ HIKP_SET_USED(self); -+ - g_trace_cmd.cmd_type = TRACE_MODE; - ret = string_toui(argv, &val); - if (ret || val > 1) { -@@ -83,6 +96,9 @@ static int pcie_trace_mode_set(struct major_cmd_ctrl *self, const char *argv) - - static int pcie_link_information_get(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_trace_cmd.cmd_type = TRACE_INFO; - return 0; - } -@@ -92,6 +108,8 @@ static int pcie_port_id_set(struct major_cmd_ctrl *self, const char *argv) - uint32_t val; - int ret; - -+ HIKP_SET_USED(self); -+ - ret = string_toui(argv, &val); - if (ret) { - printf("trace set port id err %d\n", ret); -diff --git a/sas/sas_func/sas_analy_queue.c b/sas/sas_func/sas_analy_queue.c -index f1d2e7e..3411f67 100644 ---- a/sas/sas_func/sas_analy_queue.c -+++ b/sas/sas_func/sas_analy_queue.c -@@ -46,7 +46,7 @@ static int sas_get_res(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; -- for (int i = 0; i < *reg_num; i++) -+ for (uint32_t i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - - hikp_cmd_free(&cmd_ret); -diff --git a/sas/sas_func/sas_dump_reg.c b/sas/sas_func/sas_dump_reg.c -index 39fa5ed..4269822 100644 ---- a/sas/sas_func/sas_dump_reg.c -+++ b/sas/sas_func/sas_dump_reg.c -@@ -38,14 +38,14 @@ static int sas_get_reg(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - return -1; - } - *reg_num = cmd_ret->rsp_data_num; -- for (int i = 0; i < *reg_num; i++) -+ for (uint32_t i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - - hikp_cmd_free(&cmd_ret); - return 0; - } - --static void sas_print_reg(uint32_t cmd_type, const uint32_t *reg_save, uint32_t reg_num) -+static void sas_print_reg(const uint32_t *reg_save, uint32_t reg_num) - { - uint32_t i; - -@@ -71,7 +71,7 @@ int sas_reg_dump(struct tool_sas_cmd *cmd) - if (ret) - return ret; - -- sas_print_reg(cmd->sas_cmd_type, reg_save, reg_num); -+ sas_print_reg(reg_save, reg_num); - - return 0; - } -diff --git a/sas/sas_func/sas_read_dev.c b/sas/sas_func/sas_read_dev.c -index b5d7e18..dec2935 100644 ---- a/sas/sas_func/sas_read_dev.c -+++ b/sas/sas_func/sas_read_dev.c -@@ -22,7 +22,7 @@ - - static int sas_get_dev(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint32_t *reg_num) - { -- int i; -+ uint32_t i; - struct hikp_cmd_header req_header; - struct hikp_cmd_ret *cmd_ret; - struct sas_dev_req_para req_data = { 0 }; -@@ -46,7 +46,7 @@ static int sas_get_dev(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - return 0; - } - --static void print_dev_link(const uint32_t *reg_save, uint32_t reg_num) -+static void print_dev_link(const uint32_t *reg_save) - { - uint32_t i; - uint32_t index, index1; -@@ -84,7 +84,7 @@ static void sas_print_dev(const uint32_t *reg_save, uint32_t reg_num, uint32_t c - } - switch (cmd_type) { - case DEV_LINK: -- print_dev_link(reg_save, reg_num); -+ print_dev_link(reg_save); - break; - default: - printf("cmd_type is error\n"); -diff --git a/sas/sas_func/sas_read_dqe.c b/sas/sas_func/sas_read_dqe.c -index dac2546..ae4ef68 100644 ---- a/sas/sas_func/sas_read_dqe.c -+++ b/sas/sas_func/sas_read_dqe.c -@@ -39,14 +39,14 @@ static int sas_get_dqe(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; -- for (int i = 0; i < *reg_num; i++) -+ for (uint32_t i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - - hikp_cmd_free(&cmd_ret); - return 0; - } - --static void print_dqe_info(const void *reg_save, uint32_t reg_num) -+static void print_dqe_info(const void *reg_save) - { - volatile struct hisi_sas_dq_info *dqe = (volatile struct hisi_sas_dq_info *)(reg_save); - -@@ -109,6 +109,6 @@ int sas_dqe(const struct tool_sas_cmd *cmd) - printf("SAS dqe is failed\n"); - return -EINVAL; - } -- print_dqe_info(reg_save, reg_num); -+ print_dqe_info(reg_save); - return 0; - } -diff --git a/sas/sas_func/sas_read_errcode.c b/sas/sas_func/sas_read_errcode.c -index d451a98..8263550 100644 ---- a/sas/sas_func/sas_read_errcode.c -+++ b/sas/sas_func/sas_read_errcode.c -@@ -37,7 +37,7 @@ static int sas_get_errcode(const struct tool_sas_cmd *cmd, uint32_t *reg_save, u - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; -- for (int i = 0; i < *reg_num; i++) -+ for (uint32_t i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - - hikp_cmd_free(&cmd_ret); -diff --git a/sas/user_cmd/cmd_code/sas_cmd_anacq.c b/sas/user_cmd/cmd_code/sas_cmd_anacq.c -index 46bf5aa..bdaaa42 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_anacq.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_anacq.c -@@ -19,6 +19,8 @@ - - static int sas_anacq_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-c", "--chipid", "please input chip id[x] first\n"); -@@ -34,11 +36,17 @@ static int sas_anacq_help(struct major_cmd_ctrl *self, const char *argv) - - static int sas_anacq_prt(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - return sas_set_cmd_type(ANACQ_PRT); - } - - static int sas_anacq_num(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - return sas_set_cmd_type(ANACQ_NUM); - } - -diff --git a/sas/user_cmd/cmd_code/sas_cmd_anadq.c b/sas/user_cmd/cmd_code/sas_cmd_anadq.c -index e1b68b6..bff2c71 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_anadq.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_anadq.c -@@ -19,6 +19,8 @@ - - static int sas_anadq_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-c", "--chipid", "please input chip id[x] first\n"); -@@ -34,11 +36,17 @@ static int sas_anadq_help(struct major_cmd_ctrl *self, const char *argv) - - static int sas_anadq_prt(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - return sas_set_cmd_type(ANADQ_PRT); - } - - static int sas_anadq_num(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - return sas_set_cmd_type(ANADQ_NUM); - } - -diff --git a/sas/user_cmd/cmd_code/sas_cmd_common.c b/sas/user_cmd/cmd_code/sas_cmd_common.c -index 7d4ffbb..1dafc0a 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_common.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_common.c -@@ -23,7 +23,7 @@ static struct tool_sas_cmd g_sas_cmd = { - .dqe_id = (uint32_t)(-1), - }; - --int sas_set_id(struct major_cmd_ctrl *self, const char *argv, uint32_t *id) -+static int sas_set_id(struct major_cmd_ctrl *self, const char *argv, uint32_t *id) - { - int ret; - uint32_t val = 0; -diff --git a/sas/user_cmd/cmd_code/sas_cmd_dev.c b/sas/user_cmd/cmd_code/sas_cmd_dev.c -index 6a5eae0..879e764 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_dev.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_dev.c -@@ -19,6 +19,8 @@ - - static int sas_dev_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-c", "--chipid", "please input chip id[x] first\n"); -@@ -33,6 +35,9 @@ static int sas_dev_help(struct major_cmd_ctrl *self, const char *argv) - - static int sas_dev_link(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - return sas_set_cmd_type(DEV_LINK); - } - -diff --git a/sas/user_cmd/cmd_code/sas_cmd_dqe.c b/sas/user_cmd/cmd_code/sas_cmd_dqe.c -index 26bf0eb..5a85468 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_dqe.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_dqe.c -@@ -19,6 +19,8 @@ - - static int sas_dqe_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-c", "--chipid", "please input chip id[x] first\n"); -@@ -57,7 +59,7 @@ static int sas_set_queue_id(struct major_cmd_ctrl *self, const char *argv) - - static int sas_dqe_excute_funs_call(uint32_t cmd_type) - { -- if ((cmd_type != SAS_UNKNOW_CMD) && (sas_get_que_id() != (uint32_t)(-1))) -+ if ((cmd_type != SAS_UNKNOW_CMD) && (sas_get_que_id() != (-1))) - return sas_dqe(sas_get_cmd_p()); - - return -EINVAL; -diff --git a/sas/user_cmd/cmd_code/sas_cmd_dump.c b/sas/user_cmd/cmd_code/sas_cmd_dump.c -index e7dedf0..db7d2c8 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_dump.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_dump.c -@@ -19,6 +19,8 @@ - - static int sas_dump_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-c", "--chipid", "please input chip id[x] first\n"); -@@ -35,6 +37,9 @@ static int sas_dump_help(struct major_cmd_ctrl *self, const char *argv) - - static int sas_dump_global(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - (void)sas_set_cmd_type(DUMP_GLOBAL); - return 0; - } -@@ -56,6 +61,9 @@ static int sas_dump_phyx(struct major_cmd_ctrl *self, char const *argv) - - static int sas_dump_axi(struct major_cmd_ctrl *self, char const *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - (void)sas_set_cmd_type(DUMP_AXI); - return 0; - } -diff --git a/sas/user_cmd/cmd_code/sas_cmd_errcode.c b/sas/user_cmd/cmd_code/sas_cmd_errcode.c -index eb3c5e6..ebe7d1c 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_errcode.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_errcode.c -@@ -18,6 +18,8 @@ - - static int sas_errcode_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-c", "--chipid", "please input chip id[x] first\n"); -diff --git a/sata/sata_func/sata_dump_reg.c b/sata/sata_func/sata_dump_reg.c -index d63a14b..d9911d6 100644 ---- a/sata/sata_func/sata_dump_reg.c -+++ b/sata/sata_func/sata_dump_reg.c -@@ -46,7 +46,7 @@ static int sata_get_reg(const struct tool_sata_cmd *cmd, uint32_t *reg_save, uin - return 0; - } - --static void sata_print_reg(uint32_t cmd_type, const uint32_t *reg_save, uint32_t reg_num) -+static void sata_print_reg(const uint32_t *reg_save, uint32_t reg_num) - { - uint32_t i; - -@@ -72,7 +72,7 @@ int sata_reg_dump(struct tool_sata_cmd *cmd) - if (ret) - return ret; - -- sata_print_reg(cmd->sata_cmd_type, sata_reg_save, sata_reg_num); -+ sata_print_reg(sata_reg_save, sata_reg_num); - - return 0; - } -diff --git a/sata/user_cmd/cmd_code/sata_cmd_dump.c b/sata/user_cmd/cmd_code/sata_cmd_dump.c -index d38ff1c..2b74712 100644 ---- a/sata/user_cmd/cmd_code/sata_cmd_dump.c -+++ b/sata/user_cmd/cmd_code/sata_cmd_dump.c -@@ -26,6 +26,8 @@ struct tool_sata_cmd g_sata_dump_cmd = { - - static int sata_dump_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-c", "--chipid", "please input chip id[x] first\n"); -@@ -56,16 +58,25 @@ static int sata_set_id(struct major_cmd_ctrl *self, const char *argv, uint32_t * - - static int sata_set_chip_id(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - return sata_set_id(self, argv, &g_sata_dump_cmd.chip_id); - } - - static int sata_set_die_id(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - return sata_set_id(self, argv, &g_sata_dump_cmd.die_id); - } - - static int sata_dump_global(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_sata_dump_cmd.sata_cmd_type = DUMP_GLOBAL; - return 0; - } -diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c -index 2367382..01776df 100644 ---- a/serdes/hikp_serdes.c -+++ b/serdes/hikp_serdes.c -@@ -31,6 +31,8 @@ static void hikp_serdes_dump_print(struct cmd_serdes_param *cmd); - - static int cmd_serdes_maininfo_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, - "-i -s -n [-k]"); - printf("\n %s, e.g. hikptool serdes_info -i 0 -s m3d0 -n 4 -k\n", -@@ -119,6 +121,9 @@ static int cmd_serdes_lane_num(struct major_cmd_ctrl *self, const char *argv) - - static int cmd_serdes_key_info_pro(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ - g_serdes_param.sub_cmd = 1; - return 0; - } -@@ -379,6 +384,8 @@ static void cmd_serdes_maininfo_init(void) - - static int cmd_serdes_dump_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, - "-c -i -s "); - printf("\n %s, e.g. hikptool serdes_dump -c cs -i 0 -s m0d0\n", -diff --git a/socip/hikp_socip_dumpreg.c b/socip/hikp_socip_dumpreg.c -index a3a20cb..b3b3ed7 100644 ---- a/socip/hikp_socip_dumpreg.c -+++ b/socip/hikp_socip_dumpreg.c -@@ -39,6 +39,8 @@ static struct dump_reg_param_t g_dump_reg_param[SOCIP_DUMP_REG_PARAM_NUM] = {0}; - - static int cmd_socip_dump_help(struct major_cmd_ctrl *self, const char *argv) - { -+ HIKP_SET_USED(argv); -+ - printf("\n Usage: %s %s\n", self->cmd_ptr->name, - "-c -d -m -i "); - printf("\n %s\n", self->cmd_ptr->help_info); -diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c -index 6f28ecd..c1c7d02 100644 ---- a/tool_lib/op_logs.c -+++ b/tool_lib/op_logs.c -@@ -246,7 +246,7 @@ int op_log_initialise(const char *log_dir) - memset(log_path, '\0', OP_LOG_FILE_PATH_MAXLEN); - memset(g_op_log, '\0', OP_LOG_FILE_PATH_MAXLEN); - ret = snprintf(log_path, sizeof(log_path), "%s", log_dir); -- if (ret < 0 || ret >= sizeof(log_path)) -+ if (ret < 0 || (size_t)ret >= sizeof(log_path)) - return -EINVAL; - - if (!is_dir_exist(log_path)) { -@@ -275,22 +275,17 @@ int op_log_initialise(const char *log_dir) - void op_log_record_input(const int argc, const char **argv) - { - char input_str[OP_LOG_FILE_W_MAXSIZE + 1] = {0}; -- struct op_log_print_t log_info[] = { -- {"%s", g_cmd_exec_time}, -- {"[%s]", input_str}, -- }; -- size_t i, arr_size; - int offset = 0; - char *arg; - int ret; - - memset(g_input_buf, 0, sizeof(g_input_buf)); - -- if (argv == NULL || argc == 0) -+ if (argv == NULL || argc <= 0) - return; - - arg = input_str; -- for (i = 0; i < argc; i++) { -+ for (int i = 0; i < argc; i++) { - ret = snprintf(arg, (sizeof(input_str) - (arg - input_str)), "%s ", argv[i]); - if (ret < 0 || ret >= (int)(sizeof(input_str) - (arg - input_str))) - return; -@@ -299,15 +294,18 @@ void op_log_record_input(const int argc, const char **argv) - } - input_str[strlen(input_str) - 1] = 0; - -- arr_size = HIKP_ARRAY_SIZE(log_info); -- for (i = 0; i < arr_size; i++) { -- ret = snprintf(g_input_buf + offset, (OP_LOG_FILE_W_MAXSIZE + 1 - offset), -- log_info[i].format, log_info[i].str); -- if (ret < 0 || ret >= (OP_LOG_FILE_W_MAXSIZE + 1 - offset)) -- return; -- -- offset += ret; -+ ret = snprintf(g_input_buf + offset, (OP_LOG_FILE_W_MAXSIZE + 1 - offset), -+ "%s", g_cmd_exec_time); -+ if (ret < 0 || ret >= (OP_LOG_FILE_W_MAXSIZE + 1 - offset)) { -+ printf("snprintf exec time failed, ret 0x%x\n", ret); -+ return; - } -+ -+ offset += ret; -+ ret = snprintf(g_input_buf + offset, (OP_LOG_FILE_W_MAXSIZE + 1 - offset), -+ "[%s]", input_str); -+ if (ret < 0 || ret >= (OP_LOG_FILE_W_MAXSIZE + 1 - offset)) -+ printf("snprintf exec cmd failed, ret 0x%x\n", ret); - } - - void op_log_record_result(int ret, const char *tool_name, const char *log_dir) -@@ -393,7 +391,7 @@ static int signal_fcntl(const char *name, uint32_t operation, int *fd) - return uda_fcntl(lock_file, operation, fd); - } - --void signal_op_log_write(int signal_code) -+static void signal_op_log_write(int signal_code) - { - char log_str[] = "[00:00:00] [KILLED<00>].\r\n"; - int op_log_fd; -diff --git a/tool_lib/tool_lib.c b/tool_lib/tool_lib.c -index 62f5fbb..3dc5dad 100644 ---- a/tool_lib/tool_lib.c -+++ b/tool_lib/tool_lib.c -@@ -245,7 +245,7 @@ int tool_flock(const char *name, uint32_t operation, int *fd, const char *log_di - } - - ret = snprintf(lock_file, sizeof(lock_file), "%s", log_dir); -- if (ret < 0 || ret >= sizeof(lock_file)) { -+ if (ret < 0 || (size_t)ret >= sizeof(lock_file)) { - HIKP_ERROR_PRINT("generate flock [%s] folder name failed, errno is %d\n", - log_dir, errno); - return -errno; -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index 3bf7bf8..24b1fbb 100644 ---- a/tool_lib/tool_lib.h -+++ b/tool_lib/tool_lib.h -@@ -90,6 +90,10 @@ struct type_trans { - #define HIKP_WARN_PRINT(x, args...) HIKP_LOG_PRINT("[ WARN ] " x, ##args) - #define HIKP_INFO_PRINT(x, args...) HIKP_LOG_PRINT("[ INFO ] " x, ##args) - #define HIKP_DBG_PRINT(x, args...) HIKP_LOG_PRINT("[ DBG ] " x, ##args) -+ -+/* definition to mark a variable or function parameter as used so -+ * as to avoid a compiler warning -+ */ - #define HIKP_SET_USED(x) (void)(x) - - #define MIDR_EL1_PATH "/sys/devices/system/cpu/cpu0/regs/identification/midr_el1" --- -2.45.0.windows.1 - diff --git a/0092-hikptool-pcie-The-query-result-of-pcie_dumpreg-does-.patch b/0092-hikptool-pcie-The-query-result-of-pcie_dumpreg-does-.patch deleted file mode 100644 index 8d6f29bc075e75222f7b98cab8327be8c96d72cc..0000000000000000000000000000000000000000 --- a/0092-hikptool-pcie-The-query-result-of-pcie_dumpreg-does-.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 4fa7bfb97799f85940d2c8cec1a2078a3a637d4d Mon Sep 17 00:00:00 2001 -From: moubingquan -Date: Fri, 20 Dec 2024 15:03:30 +0800 -Subject: [PATCH 69/81] [hikptool/ pcie]:The query result of pcie_dumpreg does - not match the register list. - -Rectify the problem that the pcie_regdump -command dump registers do not match the register table. - -Signed-off-by: moubingquan ---- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 8 ++------ - 1 file changed, 2 insertions(+), 6 deletions(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index 4172637..ad7cc7f 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -64,10 +64,8 @@ struct pcie_dumpreg_info g_reg_table_tl[] = { - {0, "TL_RX_NONPOST_CNT"}, - {0, "TL_RX_CPL_CNT"}, - {0, "TL_RX_LOC_TLP_CNT"}, -- {0, "TL_RX_ERR_STATUS"}, - {0, "TL_CFGSPACE_BDF"}, - {0, "TL_TX_UR_CNT"}, -- {0, "TL_RX_ERR_STATUS"}, - }; - - struct pcie_dumpreg_info g_reg_table_dl[] = { -@@ -126,7 +124,6 @@ struct pcie_dumpreg_info g_reg_table_mac[] = { - {0, "MAC_REG_DEBUG_PIPE9"}, - {0, "MAC_REG_DEBUG_PIPE10"}, - {0, "MAC_REG_DEBUG_PIPE11"}, -- {0, "MAC_LEAVE_L0_INFO"}, - {0, "DFX_APB_LANE_ERROR_STATUS_0"}, - {0, "DFX_APB_LANE_ERROR_STATUS_1"}, - {0, "MAC_REG_PHY_RXDATA_TS_REG"}, -@@ -255,7 +252,6 @@ struct pcie_dumpreg_info g_reg_table_iob_rx[] = { - {0, "DFX_IOB_RX_CNT_RESP_RX"}, - {0, "DFX_IOB_RX_CNT_RESP_LOC"}, - {0, "DFX_IOB_RX_CNT_RESP_RECV"}, -- {0, "IOB_RX_INT_STATUS"}, - {0, "DFX_IOB_RX_AMB_WR_CNT_0"}, - {0, "DFX_IOB_RX_AMB_WR_CNT_1"}, - {0, "DFX_IOB_RX_AMB_RD_CNT_0"}, -@@ -369,8 +365,8 @@ struct pcie_dumpreg_info g_reg_table_core_glb[] = { - {0, "CORE_INT_FE_RO_2"}, - {0, "PORT07_LINK_MODE"}, - {0, "PORT815_LINK_MODE"}, -- {0, "PCIE_LINK_DOWN_CLR_PORT_EN_REG"}, -- {0, "CORE_CLK_FLG_REG"}, -+ {0, "PCIE_LINK_DOWN_CLR_PORT_EN"}, -+ {0, "CORE_CLK_FLG"}, - }; - - struct pcie_dumpreg_info g_reg_table_core_tl[] = { --- -2.45.0.windows.1 - diff --git a/0093-hikptool-hccs-support-dump-hccs-info.patch b/0093-hikptool-hccs-support-dump-hccs-info.patch deleted file mode 100644 index 5daade362e9daee8f7f5f4bd35a21bbc4a25aa16..0000000000000000000000000000000000000000 --- a/0093-hikptool-hccs-support-dump-hccs-info.patch +++ /dev/null @@ -1,1032 +0,0 @@ -From 71cc63275102a8956afaf60f9183899cd7c4cc82 Mon Sep 17 00:00:00 2001 -From: Jie Hai -Date: Tue, 17 Dec 2024 15:29:28 +0800 -Subject: [PATCH] hikptool/hccs: support dump hccs info - -1. support dump HCCS topology. - e.g. hikptool hccs -g topo -2. support dump HCCS port fixed attributes. - e.g. hikptool hccs -g fixed_attr -c \ - -d -p -3. support dump HCCS port dfx information. - e.g. hikptool hccs -g dfx_info -c \ - -d -p - -Signed-off-by: Huisong Li -Signed-off-by: Jie Hai ---- - CMakeLists.txt | 1 + - hccs/hikp_hccs.c | 807 ++++++++++++++++++++++++++++ - hccs/hikp_hccs.h | 161 ++++++ - libhikptdev/include/hikptdev_plug.h | 1 + - 4 files changed, 970 insertions(+) - create mode 100644 hccs/hikp_hccs.c - create mode 100644 hccs/hikp_hccs.h - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 56cc932..72f2dab 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -45,6 +45,7 @@ file(GLOB_RECURSE HIKPTOOL_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/sata/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/serdes/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/socip/*.c -+ ${CMAKE_CURRENT_SOURCE_DIR}/hccs/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/tool_lib/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/info_collect/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/hikp_init_main.c -diff --git a/hccs/hikp_hccs.c b/hccs/hikp_hccs.c -new file mode 100644 -index 0000000..5ef4222 ---- /dev/null -+++ b/hccs/hikp_hccs.c -@@ -0,0 +1,807 @@ -+/* -+ * Copyright (c) 2024-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 -+#include -+#include -+#include -+#include -+#include -+#include "tool_cmd.h" -+#include "hikpt_rciep.h" -+#include "hikp_hccs.h" -+ -+enum hccs_link_fsm { -+ HCCS_PORT_RESET = 1, -+ HCCS_PORT_SETUP, -+ HCCS_PORT_CONFIG, -+ HCCS_PORT_READY -+}; -+ -+const struct { -+ enum hccs_link_fsm link_fsm; -+ const char *str; -+} link_fsm_map[] = { -+ {HCCS_PORT_RESET, "reset"}, -+ {HCCS_PORT_SETUP, "setup"}, -+ {HCCS_PORT_CONFIG, "config"}, -+ {HCCS_PORT_READY, "link-up"}, -+}; -+ -+static struct hccs_param g_hccs_param = { 0 }; -+static struct hikp_plat_hccs_info g_hccs_info = { 0 }; -+ -+static int hikp_hccs_get_plat_topo(struct hccs_param *param, -+ union hccs_feature_info *info); -+static void hikp_hccs_show_topo(union hccs_feature_info *data); -+static int hikp_hccs_get_port_attr(struct hccs_param *param, -+ union hccs_feature_info *info); -+static void hikp_hccs_show_port_attr(union hccs_feature_info *feature_info); -+static int hikp_hccs_get_port_dfx_info(struct hccs_param *param, -+ union hccs_feature_info *info); -+static void hikp_hccs_show_port_dfx_info(union hccs_feature_info *feature_info); -+static int hikp_plat_hccs_hw_info(struct hikp_plat_hccs_info *hccs_info); -+static int hikp_hccs_get_die_num(uint8_t chip_id, struct hikp_plat_hccs_info *hccs_info); -+ -+static const struct hikp_hccs_feature_cmd g_hccs_feature_cmd[] = { -+ {"topo", HCCS_GET_PORT_IDS_ON_DIE, hikp_hccs_get_plat_topo, -+ hikp_hccs_show_topo, 0}, -+ {"fixed_attr", HCCS_GET_PORT_FIXED_ATTR, hikp_hccs_get_port_attr, -+ hikp_hccs_show_port_attr, HCCS_PORT_INFO_MASK}, -+ {"dfx_info", HCCS_GET_PORT_DFX_INFO, hikp_hccs_get_port_dfx_info, -+ hikp_hccs_show_port_dfx_info, HCCS_PORT_INFO_MASK}, -+}; -+ -+static int hikp_hccs_cmd_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(argv); -+ -+ printf("\n Usage: %s\n", self->cmd_ptr->name); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); -+ printf(" %s, %-25s %s\n", "-c", "--chip_id=", "target chip"); -+ printf(" %s, %-25s %s\n", "-d", "--die_id=", "target die"); -+ printf(" %s, %-25s %s\n", "-p", "--port_id=", "target port"); -+ printf(" %s\n", -+ "[-g/--get ]\n" -+ " topo : get hccs_typo info, no target specified.\n" -+ " fixed_attr : get fixed attributes for port specified by -c X -d X -p X.\n" -+ " dfx_info : get dfx info for port specified by -c X -d X -p X.\n"); -+ return 0; -+} -+ -+static int hikp_hccs_cmd_send(struct hikp_cmd_header *req_header, -+ struct hikp_hccs_req *req_data, -+ void *buff, size_t buff_len, -+ struct hikp_hccs_rsp_head *rsp_head) -+{ -+ struct hikp_cmd_ret *cmd_ret; -+ struct hikp_hccs_rsp *rsp; -+ uint64_t cur_blk_size; -+ int ret; -+ -+ cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(struct hikp_hccs_req)); -+ ret = hikp_rsp_normal_check(cmd_ret); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Failed to query from firmware! ret = %d.\n", ret); -+ goto out; -+ } -+ -+ rsp = (struct hikp_hccs_rsp *)cmd_ret->rsp_data; -+ cur_blk_size = rsp->rsp_head.cur_blk_size; -+ if (cur_blk_size == 0) { -+ HIKP_ERROR_PRINT("Firmware reported zero data size!\n"); -+ ret = -EINVAL; -+ goto out; -+ } -+ if (cur_blk_size > buff_len || -+ cur_blk_size > sizeof(struct hikp_hccs_rsp)) { -+ HIKP_ERROR_PRINT("The firmware data size (%" PRIu64 ") greater than " -+ "sw buffer(%zu) or hikp_hccs_rsp size(%zu).\n", -+ cur_blk_size, buff_len, sizeof(struct hikp_hccs_rsp)); -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ memcpy(buff, rsp->rsp_data, rsp->rsp_head.cur_blk_size); -+ rsp_head->total_blk_num = rsp->rsp_head.total_blk_num; -+ rsp_head->cur_blk_size = rsp->rsp_head.cur_blk_size; -+ -+out: -+ hikp_cmd_free(&cmd_ret); -+ return ret; -+} -+ -+static int hikp_hccs_query(struct hikp_cmd_header *req_header, -+ struct hikp_hccs_req *req_data, -+ void *buff, size_t buff_len) -+{ -+ struct hikp_hccs_rsp_head rsp_head = {0}; -+ uint16_t total_blk_size = 0; -+ uint16_t total_blk_num; -+ uint16_t blk_id = 0; -+ int ret; -+ -+ ret = hikp_hccs_cmd_send(req_header, req_data, buff, buff_len, &rsp_head); -+ if (ret != 0) -+ return ret; -+ total_blk_num = rsp_head.total_blk_num; -+ total_blk_size += rsp_head.cur_blk_size; -+ for (blk_id = 1; blk_id < total_blk_num; blk_id++) { -+ if (buff_len <= total_blk_size) { -+ HIKP_ERROR_PRINT("No enough buffer to get block-(%u) context.\n", -+ blk_id); -+ return -EINVAL; -+ } -+ -+ req_data->head.blk_id = blk_id; -+ ret = hikp_hccs_cmd_send(req_header, req_data, -+ (uint8_t *)buff + total_blk_size, -+ buff_len - total_blk_size, &rsp_head); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Failed to get context for block-(%u)!\n", -+ blk_id); -+ return -EINVAL; -+ } -+ total_blk_size += rsp_head.cur_blk_size; -+ } -+ -+ return 0; -+} -+ -+static int hikp_hccs_get_chip_num(struct hikp_plat_hccs_info *hccs_info) -+{ -+ struct hccs_chip_num_rsp_data rsp_data = {0}; -+ struct hikp_cmd_header req_header = {0}; -+ struct hikp_hccs_req req = {0}; -+ int ret; -+ -+ hikp_cmd_init(&req_header, HCCS_MOD, HCCS_GET_CHIP_NUM, 0); -+ ret = hikp_hccs_query(&req_header, &req, -+ &rsp_data, sizeof(struct hccs_chip_num_rsp_data)); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Failed to get chip number from firmware, ret = %d!\n", ret); -+ return ret; -+ } -+ -+ if (rsp_data.chip_num == 0) { -+ HIKP_ERROR_PRINT("The chip number obtained from firmware is zero!\n"); -+ return -EINVAL; -+ } -+ hccs_info->chip_num = rsp_data.chip_num; -+ -+ return 0; -+} -+ -+static int hikp_hccs_get_die_num(uint8_t chip_id, struct hikp_plat_hccs_info *hccs_info) -+{ -+ struct hccs_die_num_rsp_data rsp_data = {0}; -+ struct hikp_cmd_header req_header = {0}; -+ struct hccs_die_num_req_para *req_param; -+ struct hikp_hccs_req req = {0}; -+ int ret; -+ -+ hikp_cmd_init(&req_header, HCCS_MOD, HCCS_GET_DIE_NUM, 0); -+ req_param = (struct hccs_die_num_req_para *)&req.req_data; -+ req_param->chip_id = chip_id; -+ ret = hikp_hccs_query(&req_header, &req, -+ &rsp_data, sizeof(struct hccs_die_num_rsp_data)); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Failed to get die number from firmware, ret = %d!\n", ret); -+ return ret; -+ } -+ -+ hccs_info->chip_info[chip_id].die_num = rsp_data.die_num; -+ return 0; -+} -+ -+static int hikp_hccs_get_die_info(struct hccs_die_info *die_info, -+ uint8_t chip_id, uint8_t die_idx) -+{ -+ struct hccs_die_info_rsp_data rsp_data = {0}; -+ struct hccs_die_info_req_para *req_param; -+ struct hikp_cmd_header req_header = {0}; -+ struct hikp_hccs_req req = {0}; -+ int ret; -+ -+ hikp_cmd_init(&req_header, HCCS_MOD, HCCS_GET_DIE_INFO, 0); -+ req_param = (struct hccs_die_info_req_para *)&req.req_data; -+ req_param->chip_id = chip_id; -+ req_param->die_idx = die_idx; -+ ret = hikp_hccs_query(&req_header, &req, -+ &rsp_data, sizeof(struct hccs_die_info_rsp_data)); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Fail to get die information from firmware, ret = %d!\n", ret); -+ return ret; -+ } -+ -+ die_info->die_id = rsp_data.die_id; -+ die_info->port_num = rsp_data.port_num; -+ return 0; -+} -+ -+static int hikp_hccs_get_all_die_info(struct hikp_plat_hccs_info *hccs_info) -+{ -+ uint8_t chip_id, die_idx, die_num; -+ struct hccs_chip_info *chip_info; -+ struct hccs_die_info *die_info; -+ bool has_die = false; -+ int ret; -+ -+ for (chip_id = 0; chip_id < hccs_info->chip_num; chip_id++) { -+ chip_info = &hccs_info->chip_info[chip_id]; -+ die_num = chip_info->die_num; -+ if (die_num == 0) -+ continue; -+ -+ has_die = true; -+ die_info = (struct hccs_die_info *)calloc(die_num, sizeof(struct hccs_die_info)); -+ if (die_info == NULL) { -+ HIKP_ERROR_PRINT("Failed to allocate memory for die information!\n"); -+ return -ENOMEM; -+ } -+ chip_info->die_info = die_info; -+ for (die_idx = 0; die_idx < die_num; die_idx++, die_info++) { -+ ret = hikp_hccs_get_die_info(die_info, chip_id, die_idx); -+ if (ret < 0) { -+ HIKP_ERROR_PRINT("Failed to get die information for die idx %u!\n", -+ die_idx); -+ return ret; -+ } -+ } -+ } -+ -+ return has_die ? 0 : -EINVAL; -+} -+ -+static int hikp_hccs_get_ports_on_die(uint8_t *port_ids, uint16_t port_num, -+ uint8_t chip_id, uint8_t die_id) -+{ -+ struct hccs_die_ports_req_para *req_param; -+ struct hikp_cmd_header req_header = {0}; -+ struct hikp_hccs_req req = {0}; -+ int ret; -+ -+ hikp_cmd_init(&req_header, HCCS_MOD, HCCS_GET_PORT_IDS_ON_DIE, 0); -+ req_param = (struct hccs_die_ports_req_para *)&req.req_data; -+ req_param->chip_id = chip_id; -+ req_param->die_id = die_id; -+ ret = hikp_hccs_query(&req_header, &req, -+ port_ids, sizeof(uint8_t) * port_num); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Fail to get port ids from firmware, ret = %d!\n", ret); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int hikp_hccs_get_all_port_info(struct hikp_plat_hccs_info *hccs_info) -+{ -+ struct hccs_chip_info *chip_info; -+ struct hccs_die_info *die_info; -+ struct hccs_die_info *dies; -+ uint8_t chip_id, die_idx; -+ bool has_port = false; -+ int ret; -+ -+ for (chip_id = 0; chip_id < hccs_info->chip_num; chip_id++) { -+ chip_info = &hccs_info->chip_info[chip_id]; -+ dies = chip_info->die_info; -+ has_port = false; -+ for (die_idx = 0; die_idx < chip_info->die_num; die_idx++) { -+ die_info = &dies[die_idx]; -+ if (die_info->port_num == 0) -+ continue; -+ -+ has_port = true; -+ die_info->port_ids = (uint8_t *)calloc(die_info->port_num, -+ sizeof(uint8_t)); -+ if (die_info->port_ids == NULL) -+ return -ENOMEM; -+ -+ ret = hikp_hccs_get_ports_on_die(die_info->port_ids, die_info->port_num, -+ chip_id, die_info->die_id); -+ if (ret < 0) { -+ HIKP_ERROR_PRINT("Failed to get port ids for " -+ "chip (%u) die idx (%u)!\n", -+ chip_id, die_idx); -+ return ret; -+ } -+ } -+ } -+ -+ return has_port ? 0 : -EINVAL; -+} -+ -+static int hikp_hccs_get_chip_info(struct hikp_plat_hccs_info *hccs_info) -+{ -+ uint8_t chip_id; -+ int ret; -+ -+ ret = hikp_hccs_get_chip_num(hccs_info); -+ if (ret < 0) { -+ HIKP_ERROR_PRINT("Failed to get chip num!\n"); -+ return ret; -+ } -+ -+ hccs_info->chip_info = (struct hccs_chip_info *)calloc(hccs_info->chip_num, -+ sizeof(struct hccs_chip_info)); -+ if (hccs_info->chip_info == NULL) { -+ HIKP_ERROR_PRINT("Failed to allocate memory for chip info!\n"); -+ return -ENOMEM; -+ } -+ -+ for (chip_id = 0; chip_id < hccs_info->chip_num; chip_id++) { -+ ret = hikp_hccs_get_die_num(chip_id, hccs_info); -+ if (ret < 0) { -+ HIKP_ERROR_PRINT("Failed to get die num!\n"); -+ return ret; -+ } -+ } -+ -+ return 0; -+} -+ -+static int hikp_plat_hccs_hw_info(struct hikp_plat_hccs_info *hccs_info) -+{ -+ int ret; -+ -+ ret = hikp_hccs_get_chip_info(hccs_info); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Failed to get chip info, ret = %d!\n", ret); -+ return ret; -+ } -+ -+ ret = hikp_hccs_get_all_die_info(hccs_info); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Failed to get all die info, ret = %d!\n", ret); -+ return ret; -+ } -+ -+ ret = hikp_hccs_get_all_port_info(hccs_info); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Failed to get all port info, ret = %d!\n", ret); -+ return ret; -+ } -+ return 0; -+} -+ -+static int hikp_hccs_get_plat_topo(struct hccs_param *param, -+ union hccs_feature_info *info) -+{ -+ int ret; -+ -+ HIKP_SET_USED(param); -+ HIKP_SET_USED(info); -+ -+ ret = hikp_plat_hccs_hw_info(&g_hccs_info); -+ if (ret < 0) { -+ HIKP_ERROR_PRINT("Failed to get HCCS hardware info, ret = %d!\n", ret); -+ return ret; -+ } -+ return 0; -+} -+ -+static void hikp_plat_hccs_free(struct hikp_plat_hccs_info *hccs_info) -+{ -+ struct hccs_chip_info *chip_info; -+ struct hccs_die_info *die_info; -+ uint8_t chip_id, die_idx; -+ -+ if (hccs_info->chip_info == NULL) -+ return; -+ -+ for (chip_id = 0; chip_id < hccs_info->chip_num; chip_id++) { -+ chip_info = &hccs_info->chip_info[chip_id]; -+ die_info = chip_info->die_info; -+ if (die_info == NULL) -+ continue; -+ -+ for (die_idx = 0; die_idx < chip_info->die_num; die_idx++) { -+ if (die_info[die_idx].port_ids == NULL) -+ continue; -+ free(die_info[die_idx].port_ids); -+ die_info[die_idx].port_ids = NULL; -+ } -+ free(die_info); -+ chip_info->die_info = NULL; -+ } -+ free(hccs_info->chip_info); -+ hccs_info->chip_info = NULL; -+} -+ -+static bool hikp_hccs_die_id_valid(struct hikp_plat_hccs_info *hccs_info, -+ struct hccs_param *param, uint8_t *die_idx) -+{ -+ struct hccs_chip_info *chip_info; -+ struct hccs_die_info *die_info; -+ uint8_t idx; -+ -+ chip_info = &hccs_info->chip_info[param->chip_id]; -+ die_info = chip_info->die_info; -+ for (idx = 0; idx < chip_info->die_num; idx++) { -+ if (param->die_id != die_info[idx].die_id) -+ continue; -+ *die_idx = idx; -+ return true; -+ } -+ return false; -+} -+ -+static bool hikp_hccs_port_id_valid(struct hikp_plat_hccs_info *hccs_info, -+ struct hccs_param *param, uint8_t die_idx) -+{ -+ struct hccs_chip_info *chip_info; -+ struct hccs_die_info *die_info; -+ uint8_t port_id, *port_ids; -+ -+ chip_info = &hccs_info->chip_info[param->chip_id]; -+ die_info = &chip_info->die_info[die_idx]; -+ port_ids = die_info->port_ids; -+ -+ for (port_id = 0; port_id < die_info->port_num; port_id++) { -+ if (param->port_id == port_ids[port_id]) -+ return true; -+ } -+ -+ return false; -+} -+ -+static bool hikp_hccs_req_param_check(struct hikp_plat_hccs_info *hccs_info, -+ struct hccs_param *param) -+{ -+ uint8_t die_idx; -+ -+ if (param->chip_id >= hccs_info->chip_num) { -+ HIKP_ERROR_PRINT("param error: chip id %u exceed chip number %u!\n", -+ param->chip_id, hccs_info->chip_num); -+ return false; -+ } -+ -+ if (!hikp_hccs_die_id_valid(hccs_info, param, &die_idx)) { -+ HIKP_ERROR_PRINT("Param error: die%u not found on chip%u!\n", -+ param->die_id, param->chip_id); -+ return false; -+ } -+ -+ if (!hikp_hccs_port_id_valid(hccs_info, param, die_idx)) { -+ HIKP_ERROR_PRINT("Param error: port id %u not found on chip%u die%u!\n", -+ param->port_id, param->chip_id, param->die_id); -+ return false; -+ } -+ -+ return true; -+} -+ -+static int hikp_hccs_get_port_attr(struct hccs_param *param, -+ union hccs_feature_info *info) -+{ -+ struct hccs_port_attr_req_para *req_para; -+ struct hikp_cmd_header req_header = {0}; -+ struct hikp_hccs_req req = {0}; -+ int ret; -+ -+ ret = hikp_plat_hccs_hw_info(&g_hccs_info); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Failed to get HCCS hardware info for " -+ "port attributes, ret = %d.\n", ret); -+ return ret; -+ } -+ -+ if (!hikp_hccs_req_param_check(&g_hccs_info, param)) -+ return -EINVAL; -+ -+ hikp_cmd_init(&req_header, HCCS_MOD, HCCS_GET_PORT_FIXED_ATTR, 0); -+ req_para = (struct hccs_port_attr_req_para *)&req.req_data; -+ req_para->chip_id = param->chip_id; -+ req_para->die_id = param->die_id; -+ req_para->port_id = param->port_id; -+ ret = hikp_hccs_query(&req_header, &req, -+ info, sizeof(union hccs_feature_info)); -+ if (ret != 0) -+ return ret; -+ return 0; -+} -+ -+static int hikp_hccs_get_port_dfx_info(struct hccs_param *param, -+ union hccs_feature_info *info) -+{ -+ struct hikp_hccs_rsp_head rsp_head = {0}; -+ struct hikp_cmd_header req_header = {0}; -+ struct hccs_port_dfx_info_vld *dfx_info; -+ struct hccs_port_dfx_req_para *dfx_req; -+ struct hikp_hccs_req req = {0}; -+ int ret; -+ -+ ret = hikp_plat_hccs_hw_info(&g_hccs_info); -+ if (ret != 0) { -+ HIKP_ERROR_PRINT("Failed to get HCCS hardware info for dfx info, ret = %d\n", -+ ret); -+ return ret; -+ } -+ -+ if (!hikp_hccs_req_param_check(&g_hccs_info, param)) -+ return -EINVAL; -+ -+ dfx_info = &info->dfx_info; -+ dfx_req = (struct hccs_port_dfx_req_para *)&req.req_data; -+ dfx_req->chip_id = param->chip_id; -+ dfx_req->port_id = param->port_id; -+ dfx_req->die_id = param->die_id; -+ hikp_cmd_init(&req_header, HCCS_MOD, HCCS_GET_PORT_DFX_INFO, 0); -+ ret = hikp_hccs_cmd_send(&req_header, &req, -+ &dfx_info->info, -+ sizeof(struct hccs_port_dfx_info), -+ &rsp_head); -+ if (ret != 0) -+ return ret; -+ -+ dfx_info->vld_size = rsp_head.cur_blk_size; -+ -+ return 0; -+} -+ -+static void hikp_hccs_show_topo(union hccs_feature_info *data) -+{ -+ uint8_t chip_id, die_idx, die_num, port_idx, *port_ids; -+ struct hccs_die_info *die_info; -+ struct hccs_die_info *dies; -+ -+ HIKP_SET_USED(data); -+ -+ for (chip_id = 0; chip_id < g_hccs_info.chip_num; chip_id++) { -+ die_num = g_hccs_info.chip_info[chip_id].die_num; -+ dies = g_hccs_info.chip_info[chip_id].die_info; -+ printf("--chip%u\n", chip_id); -+ if (die_num == 0) -+ continue; -+ for (die_idx = 0; die_idx < die_num; die_idx++) { -+ die_info = &dies[die_idx]; -+ printf("\t--die%u\n", die_info->die_id); -+ port_ids = die_info->port_ids; -+ if (die_info->port_num == 0) -+ continue; -+ -+ for (port_idx = 0; port_idx < die_info->port_num; port_idx++) -+ printf("\t\t--hccs%u\n", port_ids[port_idx]); -+ } -+ } -+} -+ -+static void hikp_hccs_show_port_attr(union hccs_feature_info *feature_info) -+{ -+ struct hccs_port_fixed_attr *info = &feature_info->attr; -+ -+ printf("%-16s\tHCCS-V%u\n" -+ "%-16s\tx%u\n" -+ "%-16s\t%uMbps\n" -+ "%-16s\t%u\n", -+ "hccs_type", info->hccs_type, -+ "lane_mode", info->lane_mode, -+ "speed", info->speed, -+ "enabled", info->enabled); -+} -+ -+static const char *hikp_hccs_link_fsm_to_str(uint8_t link_fsm) -+{ -+ size_t i; -+ -+ for (i = 0; i < sizeof(link_fsm_map) / sizeof(link_fsm_map[0]); i++) { -+ if (link_fsm_map[i].link_fsm == link_fsm) -+ return link_fsm_map[i].str; -+ } -+ -+ return "unknown"; -+} -+ -+static void hikp_hccs_show_port_dfx_info(union hccs_feature_info *feature_info) -+{ -+ struct hccs_port_dfx_info_vld *info_vld = &feature_info->dfx_info; -+ struct hccs_port_dfx_info *info = &info_vld->info; -+ size_t vld_size; -+ -+ vld_size = (size_t)info_vld->vld_size; -+ if (vld_size >= sizeof(info->link_fsm)) { -+ printf("%-16s\t%s\n", "link_fsm", hikp_hccs_link_fsm_to_str(info->link_fsm)); -+ vld_size -= sizeof(info->link_fsm); -+ } -+ -+ if (vld_size >= sizeof(info->cur_lane_num)) { -+ printf("%-16s\t%u\n", "cur_lane_num", info->cur_lane_num); -+ vld_size -= sizeof(info->cur_lane_num); -+ } -+ -+ if (vld_size >= sizeof(info->lane_mask)) { -+ printf("%-16s\t0x%x\n", "lane_mask", info->lane_mask); -+ vld_size -= sizeof(info->lane_mask); -+ } -+ -+ if (vld_size >= sizeof(info->crc_err_cnt)) { -+ printf("%-16s\t%u\n", "crc_err_cnt", info->crc_err_cnt); -+ vld_size -= sizeof(info->crc_err_cnt); -+ } -+ -+ if (vld_size >= sizeof(info->retry_cnt)) { -+ printf("%-16s\t%u\n", "retry_cnt", info->retry_cnt); -+ vld_size -= sizeof(info->retry_cnt); -+ } -+ -+ if (vld_size >= sizeof(info->phy_reinit_cnt)) { -+ printf("%-16s\t%u\n", "phy_reinit_cnt", info->phy_reinit_cnt); -+ vld_size -= sizeof(info->phy_reinit_cnt); -+ } -+ -+ if (vld_size >= sizeof(info->tx_credit)) { -+ printf("%-16s\t%u\n", "tx_credit", info->tx_credit); -+ vld_size -= sizeof(info->tx_credit); -+ } -+} -+ -+static void hikp_hccs_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ const struct hikp_hccs_feature_cmd *hccs_cmd; -+ union hccs_feature_info info = {0}; -+ int ret; -+ -+ if (g_hccs_param.feature_idx == -1) { -+ hikp_hccs_cmd_help(self, NULL); -+ snprintf(self->err_str, sizeof(self->err_str), "-g/--get param error!"); -+ self->err_no = -EINVAL; -+ return; -+ } -+ -+ hccs_cmd = &g_hccs_feature_cmd[g_hccs_param.feature_idx]; -+ if (g_hccs_param.param_mask != hccs_cmd->param_needed) { -+ hikp_hccs_cmd_help(self, NULL); -+ snprintf(self->err_str, sizeof(self->err_str), "Parameter mismatched!"); -+ self->err_no = -EINVAL; -+ return; -+ } -+ -+ ret = hikp_hccs_get_chip_num(&g_hccs_info); -+ if (ret < 0) { -+ self->err_no = ret; -+ return; -+ } -+ -+ if (g_hccs_info.chip_num == 1) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "The command is just supported on multi-sockets!\n"); -+ self->err_no = -EINVAL; -+ return; -+ } -+ -+ ret = hccs_cmd->query(&g_hccs_param, &info); -+ if (ret != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "Failed to query %s, ret = %d.", -+ hccs_cmd->feature_name, ret); -+ self->err_no = ret; -+ hikp_plat_hccs_free(&g_hccs_info); -+ return; -+ } -+ -+ printf("############## HCCS: %s info ############\n", hccs_cmd->feature_name); -+ hccs_cmd->show(&info); -+ printf("#################### END #######################\n"); -+ -+ hikp_plat_hccs_free(&g_hccs_info); -+} -+ -+static int hikp_hccs_cmd_feature_select(struct major_cmd_ctrl *self, const char *argv) -+{ -+ size_t feat_size = HIKP_ARRAY_SIZE(g_hccs_feature_cmd); -+ size_t i; -+ -+ for (i = 0; i < feat_size; i++) { -+ if (strcmp(argv, g_hccs_feature_cmd[i].feature_name) == 0) { -+ g_hccs_param.feature_idx = i; -+ return 0; -+ } -+ } -+ -+ hikp_hccs_cmd_help(self, NULL); -+ snprintf(self->err_str, sizeof(self->err_str), "-g/--get param error!!!"); -+ self->err_no = -EINVAL; -+ -+ return self->err_no; -+} -+ -+static int hikp_hccs_cmd_parse_chip(struct major_cmd_ctrl *self, const char *argv) -+{ -+ uint32_t chip_id; -+ -+ self->err_no = string_toui(argv, &chip_id); -+ if (self->err_no) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "Failed to parse -c/--chip_id parameter."); -+ return self->err_no; -+ } -+ if (chip_id > UINT8_MAX) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "chip id should not be greater than %u.", UINT8_MAX); -+ self->err_no = -EINVAL; -+ return self->err_no; -+ } -+ -+ g_hccs_param.param_mask |= HCCS_ENABLE_CHIP_ID; -+ g_hccs_param.chip_id = (uint8_t)chip_id; -+ -+ return 0; -+} -+ -+static int hikp_hccs_cmd_parse_die(struct major_cmd_ctrl *self, const char *argv) -+{ -+ uint32_t die_id; -+ -+ self->err_no = string_toui(argv, &die_id); -+ if (self->err_no) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "Failed to parse -d/--die_id parameter."); -+ return self->err_no; -+ } -+ -+ if (die_id > UINT8_MAX) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "die id should not be greater than %u.", UINT8_MAX); -+ self->err_no = -EINVAL; -+ return self->err_no; -+ } -+ -+ g_hccs_param.param_mask |= HCCS_ENABLE_DIE_ID; -+ g_hccs_param.die_id = (uint8_t)die_id; -+ -+ return 0; -+} -+ -+static int hikp_hccs_cmd_parse_port(struct major_cmd_ctrl *self, const char *argv) -+{ -+ uint32_t port_id; -+ -+ self->err_no = string_toui(argv, &port_id); -+ if (self->err_no) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "Failed to parse -p/--port_id parameter."); -+ return self->err_no; -+ } -+ -+ if (port_id > UINT8_MAX) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "port id should not be greater %u.", UINT8_MAX); -+ self->err_no = -EINVAL; -+ return self->err_no; -+ } -+ -+ g_hccs_param.param_mask |= HCCS_ENABLE_PORT_ID; -+ g_hccs_param.port_id = (uint8_t)port_id; -+ return 0; -+} -+ -+static void hikp_hccs_cmd_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ g_hccs_param.feature_idx = -1; -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = hikp_hccs_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, hikp_hccs_cmd_help); -+ cmd_option_register("-g", "--get", true, hikp_hccs_cmd_feature_select); -+ cmd_option_register("-c", "--chip_id", true, hikp_hccs_cmd_parse_chip); -+ cmd_option_register("-d", "--die_id", true, hikp_hccs_cmd_parse_die); -+ cmd_option_register("-p", "--port_id", true, hikp_hccs_cmd_parse_port); -+} -+ -+HIKP_CMD_DECLARE("hccs", "dump HCCS information.", hikp_hccs_cmd_init); -diff --git a/hccs/hikp_hccs.h b/hccs/hikp_hccs.h -new file mode 100644 -index 0000000..8ccc01a ---- /dev/null -+++ b/hccs/hikp_hccs.h -@@ -0,0 +1,161 @@ -+/* -+ * Copyright (c) 2024-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_HCCS_H -+#define HIKP_HCCS_H -+ -+#include -+ -+enum hikp_hccs_cmd_type { -+ HCCS_GET_CHIP_NUM = 0, -+ HCCS_GET_DIE_NUM, -+ HCCS_GET_DIE_INFO, -+ HCCS_GET_PORT_IDS_ON_DIE, -+ HCCS_GET_PORT_FIXED_ATTR, -+ HCCS_GET_PORT_DFX_INFO, -+}; -+ -+struct hccs_die_info { -+ uint8_t die_id; -+ uint16_t port_num; -+ uint8_t *port_ids; -+}; -+ -+struct hccs_chip_info { -+ uint8_t chip_id; -+ uint8_t die_num; -+ struct hccs_die_info *die_info; -+}; -+ -+struct hccs_port_fixed_attr { -+ uint8_t hccs_type; /* HCCS_V1, HCCS_V2 and etc. */ -+ uint8_t lane_mode; -+ uint16_t speed; /* Unit Mbps. */ -+ uint8_t enabled; /* Indicate if port is enabled. */ -+ uint8_t rsv[3]; -+}; -+ -+struct hccs_port_dfx_info { -+ uint8_t link_fsm; -+ uint8_t cur_lane_num; -+ uint16_t lane_mask; -+ uint32_t crc_err_cnt; -+ uint32_t retry_cnt; -+ uint32_t phy_reinit_cnt; -+ uint32_t tx_credit; -+ uint32_t rsv1[54]; -+}; -+ -+struct hccs_port_dfx_info_vld { -+ struct hccs_port_dfx_info info; -+ uint8_t vld_size; /* Indicate the valid bytes firmware reported. */ -+}; -+ -+union hccs_feature_info { -+ struct hccs_port_fixed_attr attr; -+ struct hccs_port_dfx_info_vld dfx_info; -+}; -+ -+struct hccs_chip_num_rsp_data { -+ uint8_t chip_num; -+}; -+ -+struct hccs_die_num_req_para { -+ uint8_t chip_id; -+}; -+ -+struct hccs_die_num_rsp_data { -+ uint8_t die_num; -+}; -+ -+struct hccs_die_info_req_para { -+ uint8_t chip_id; -+ uint8_t die_idx; -+}; -+ -+struct hccs_die_info_rsp_data { -+ uint8_t die_id; -+ uint8_t rsv; -+ uint16_t port_num; -+}; -+ -+struct hccs_die_ports_req_para { -+ uint8_t chip_id; -+ uint8_t die_id; -+}; -+ -+struct hccs_port_attr_req_para { -+ uint8_t chip_id; -+ uint8_t die_id; -+ uint8_t port_id; -+}; -+ -+struct hccs_port_dfx_req_para { -+ uint8_t chip_id; -+ uint8_t die_id; -+ uint8_t port_id; -+}; -+ -+struct hikp_hccs_rsp_head { -+ uint16_t total_blk_num; -+ uint8_t cur_blk_size; /* real data size, not contain header size. */ -+ uint8_t rsv; -+}; -+ -+#define HCCS_MAX_RSP_DATA 59 -+struct hikp_hccs_rsp { -+ struct hikp_hccs_rsp_head rsp_head; /* 4 Byte */ -+ uint32_t rsp_data[HCCS_MAX_RSP_DATA]; -+}; -+ -+struct hikp_hccs_req_head { -+ uint16_t blk_id; -+ uint16_t rsv; -+}; -+ -+#define HCCS_MAX_REQ_DATA 31 -+struct hikp_hccs_req { -+ struct hikp_hccs_req_head head; /* 4 Byte */ -+ uint32_t req_data[HCCS_MAX_REQ_DATA]; -+}; -+ -+#define HCCS_ENABLE_CHIP_ID HI_BIT(0) -+#define HCCS_ENABLE_DIE_ID HI_BIT(1) -+#define HCCS_ENABLE_PORT_ID HI_BIT(2) -+#define HCCS_PORT_INFO_MASK (HCCS_ENABLE_CHIP_ID | HCCS_ENABLE_DIE_ID | \ -+ HCCS_ENABLE_PORT_ID) -+ -+struct hccs_param { -+ int feature_idx; -+ uint8_t chip_id; -+ uint8_t die_id; -+ uint32_t port_id; -+ /* mask for param passed by user, see HCCS_ENABLE_XXX. */ -+ uint16_t param_mask; -+}; -+ -+struct hikp_plat_hccs_info { -+ uint8_t chip_num; -+ struct hccs_chip_info *chip_info; -+}; -+ -+#define HIKP_HCCS_FEATURE_NAME_LEN 20 -+struct hikp_hccs_feature_cmd { -+ const char feature_name[HIKP_HCCS_FEATURE_NAME_LEN]; -+ uint32_t cmd_code; -+ int (*query)(struct hccs_param *param, union hccs_feature_info *info); -+ void (*show)(union hccs_feature_info *data); -+ uint16_t param_needed; -+}; -+ -+#endif /* HIKP_HCCS_H */ -diff --git a/libhikptdev/include/hikptdev_plug.h b/libhikptdev/include/hikptdev_plug.h -index 2123935..d45a654 100644 ---- a/libhikptdev/include/hikptdev_plug.h -+++ b/libhikptdev/include/hikptdev_plug.h -@@ -44,6 +44,7 @@ enum cmd_module_type { - DPDK_MOD = 9, - CXL_MOD = 10, - UB_MOD = 11, -+ HCCS_MOD = 16 - }; - - void hikp_unlock(void); --- -2.45.0.windows.1 - diff --git a/0094-hikptool-pcie-The-PCS-layer-register-print-command-i.patch b/0094-hikptool-pcie-The-PCS-layer-register-print-command-i.patch deleted file mode 100644 index 83f91b493694e747f546b627a03ae9b5bd52c10e..0000000000000000000000000000000000000000 --- a/0094-hikptool-pcie-The-PCS-layer-register-print-command-i.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 315bab874c894053be65b47be3ac783dcd1259da Mon Sep 17 00:00:00 2001 -From: moubingquan -Date: Wed, 8 Jan 2025 10:49:19 +0800 -Subject: [PATCH 71/81] [hikptool/ pcie]:The PCS-layer register print command - is deleted. - -The register print of the PCS layer is deleted. -Currently, the register of this module does -not need to be dumped. - -Signed-off-by: moubingquan ---- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 15 --------------- - pcie/func_lib/pcie_func/pcie_reg_dump.h | 10 ---------- - 2 files changed, 25 deletions(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index ad7cc7f..cb59d2c 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -131,20 +131,6 @@ struct pcie_dumpreg_info g_reg_table_mac[] = { - {0, "MAC_POWERDOWN_VALUE_REG"}, - }; - --struct pcie_dumpreg_info g_reg_table_pcs[] = { -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(SERDES_STATUS_RPT), -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(EBUF_STATUS), -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(GEN3_DEC_ENC_STATUS), -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(WAKE_STATUS), -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(RECV_DET_OR_PWR_CHAGE), -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(EQEVAL_STATUS), -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(LANE_INTR_STATUS), -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(M_PCS_RPT_REG), -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(MSG_BUS_DFX), -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(DETECT_CLK_FLG_REG), -- HIKP_PCIE_PCS_LANE_TBL_ENTRY(SDS_CFG_REG_REG), --}; -- - struct pcie_dumpreg_info g_reg_table_iob_tx[] = { - {0, "IOB_TX_ECAM_CONTROL0"}, - {0, "IOB_TX_ECAM_CONTROL1"}, -@@ -456,7 +442,6 @@ struct pcie_dumpreg_table g_dump_info_glb[] = { - {HIKP_ARRAY_SIZE(g_reg_table_iob_rx), g_reg_table_iob_rx}, - {HIKP_ARRAY_SIZE(g_reg_table_ap_glb), g_reg_table_ap_glb}, - {HIKP_ARRAY_SIZE(g_reg_table_core_glb), g_reg_table_core_glb}, -- {HIKP_ARRAY_SIZE(g_reg_table_pcs), g_reg_table_pcs}, - {HIKP_ARRAY_SIZE(g_reg_table_core_tl), g_reg_table_core_tl}, - {HIKP_ARRAY_SIZE(g_reg_table_dfx_core_tl), g_reg_table_dfx_core_tl}, - }; -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.h b/pcie/func_lib/pcie_func/pcie_reg_dump.h -index 3c52a6e..c74ce56 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.h -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.h -@@ -22,16 +22,6 @@ - #define PCIE_DUMPREG_LOGFILE_NAME "pcie_dumpreg" - #define LOG_FILE_PATH_MAX_LEN 512 - --#define HIKP_PCIE_PCS_LANE_TBL_ENTRY(name) \ -- {0, STR(CONTACT(name, _00))}, {0, STR(CONTACT(name, _01))}, \ -- {0, STR(CONTACT(name, _02))}, {0, STR(CONTACT(name, _03))}, \ -- {0, STR(CONTACT(name, _04))}, {0, STR(CONTACT(name, _05))}, \ -- {0, STR(CONTACT(name, _06))}, {0, STR(CONTACT(name, _07))}, \ -- {0, STR(CONTACT(name, _08))}, {0, STR(CONTACT(name, _09))}, \ -- {0, STR(CONTACT(name, _10))}, {0, STR(CONTACT(name, _11))}, \ -- {0, STR(CONTACT(name, _12))}, {0, STR(CONTACT(name, _13))}, \ -- {0, STR(CONTACT(name, _14))}, {0, STR(CONTACT(name, _15))} -- - enum pcie_dump_level { - DUMP_GLOBAL_LEVEL = 1, - DUMP_PORT_LEVEL = 2, --- -2.45.0.windows.1 - diff --git a/0095-hikptool-pcie-Resolved-the-problem-that-it-takes-a-l.patch b/0095-hikptool-pcie-Resolved-the-problem-that-it-takes-a-l.patch deleted file mode 100644 index 3e3ee5164349195fc04e78848e05e4a9bb81056d..0000000000000000000000000000000000000000 --- a/0095-hikptool-pcie-Resolved-the-problem-that-it-takes-a-l.patch +++ /dev/null @@ -1,119 +0,0 @@ -From 2f868efe20df8a6c0d28969912bee91d82482c21 Mon Sep 17 00:00:00 2001 -From: moubingquan -Date: Wed, 15 Jan 2025 10:24:28 +0800 -Subject: [PATCH] hikptool/pcie: Resolved the problem that it takes a long time - to write files - -The write function takes a long time to write -files when the FIO pressure is heavy. -Therefore, the function needs to be changed to -fwrite with cache. - -Signed-off-by: moubingquan ---- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 34 +++++++++++-------------- - 1 file changed, 15 insertions(+), 19 deletions(-) - -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index cb59d2c..ba6641e 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -22,7 +22,7 @@ - #include "pcie_common.h" - #include "pcie_reg_dump.h" - --int g_pcie_dumpreg_fd; -+FILE *g_pcie_dumpreg_fd = NULL; - char dumpreg_log_file[MAX_LOG_NAME_LEN + 1] = {0}; - - struct pcie_dumpreg_info g_reg_table_tl[] = { -@@ -381,7 +381,7 @@ static int pcie_create_dumpreg_log_file(uint32_t port_id, uint32_t dump_level) - { - char file_name[MAX_LOG_NAME_LEN + 1] = { 0 }; - char info_str[MAX_LOG_NAME_LEN + 1] = { 0 }; -- int fd_file; -+ FILE *fd_file = NULL; - int ret; - - ret = snprintf(info_str, sizeof(info_str), "%s_port%u_level%u", -@@ -399,8 +399,8 @@ static int pcie_create_dumpreg_log_file(uint32_t port_id, uint32_t dump_level) - - (void)remove((const char *)file_name); - /* Add write permission to the file */ -- fd_file = open(file_name, O_RDWR | O_SYNC | O_CREAT, 0600); -- if (fd_file < 0) { -+ fd_file = fopen(file_name, "w+"); -+ if (fd_file == NULL) { - Err("open %s failed.\n", file_name); - return -EPERM; - } -@@ -409,30 +409,26 @@ static int pcie_create_dumpreg_log_file(uint32_t port_id, uint32_t dump_level) - return 0; - } - --static int pcie_close_dumpreg_log_file(void) -+static void pcie_close_dumpreg_log_file(void) - { -- int ret; -- -- ret = fchmod(g_pcie_dumpreg_fd, 0400); -- close(g_pcie_dumpreg_fd); -+ fclose(g_pcie_dumpreg_fd); - /* Revoke write permission of file */ -- g_pcie_dumpreg_fd = -1; -- -- return ret; -+ chmod(dumpreg_log_file, 0400); -+ g_pcie_dumpreg_fd = NULL; - } - - static void pcie_dumpreg_write_value_to_file(const char *reg_name, uint32_t val) - { - char str[MAX_STR_LEN] = { 0 }; -- ssize_t wr_ret; -+ size_t wr_ret; - int ret; - - ret = snprintf(str, sizeof(str), " %-40s : 0x%x\n", reg_name, val); - if (ret < 0 || ret >= MAX_STR_LEN) { - Err("pcie dumpreg write info to logfile failed.\n"); - } else { -- wr_ret = write(g_pcie_dumpreg_fd, str, strlen(str)); -- if (wr_ret == -1) -+ wr_ret = fwrite(str, 1, strlen(str), g_pcie_dumpreg_fd); -+ if (wr_ret != strlen(str)) - Err("write info to logfile failed.\n"); - } - } -@@ -470,7 +466,7 @@ static int pcie_dumpreg_write_header_to_file(uint32_t version, - const struct pcie_dump_req_para *req_data) - { - char str[MAX_STR_LEN] = {0}; -- ssize_t wr_ret; -+ size_t wr_ret; - int ret; - - ret = snprintf(str, sizeof(str), "Command Version[%u], dump_level[%u], port_id[%u]\n\n", -@@ -480,8 +476,8 @@ static int pcie_dumpreg_write_header_to_file(uint32_t version, - return -EIO; - } - -- wr_ret = write(g_pcie_dumpreg_fd, str, strlen(str)); -- if (wr_ret == -1) { -+ wr_ret = fwrite(str, 1, strlen(str), g_pcie_dumpreg_fd); -+ if (wr_ret != strlen(str)) { - Err("write header to logfile failed.\n"); - return -EIO; - } -@@ -566,7 +562,7 @@ int pcie_dumpreg_do_dump(uint32_t port_id, uint32_t dump_level) - - Info("pcie reg dump finish.\n"); - close_file_ret: -- (void)pcie_close_dumpreg_log_file(); -+ pcie_close_dumpreg_log_file(); - free_cmd_ret: - hikp_cmd_free(&cmd_ret); - --- -2.45.0.windows.1 - diff --git a/0096-Hikptool-add-support-dump-SDMA-register-information-.patch b/0096-Hikptool-add-support-dump-SDMA-register-information-.patch deleted file mode 100644 index 30000065787ecf4a4be78e601e6e986c6c076c5f..0000000000000000000000000000000000000000 --- a/0096-Hikptool-add-support-dump-SDMA-register-information-.patch +++ /dev/null @@ -1,472 +0,0 @@ -From fde1f62e767c37f6a6c717df3d03154d081da47e Mon Sep 17 00:00:00 2001 -From: wangzijian -Date: Tue, 25 Feb 2025 07:11:27 +0800 -Subject: [PATCH 1/2] Hikptool add support dump SDMA register information - according to the usage environment. - -1. support dump SDMA channel status reg e.g. hikptool sdma_dump -s -c -d -2. support dump SDMA pc reg e.g. hikptool sdma_dump -p -c -d -n -3. support dump SDMA vc reg e.g. hikptool sdma_dump -v -c -d -n - -Signed-off-by: wangzijian ---- - CMakeLists.txt | 1 + - libhikptdev/include/hikptdev_plug.h | 3 +- - sdma/sdma_func/sdma_common.h | 31 +++++ - sdma/sdma_func/sdma_dump_reg.c | 133 ++++++++++++++++++++++ - sdma/sdma_func/sdma_dump_reg.h | 28 +++++ - sdma/user_cmd/sdma_cmd_dump.c | 171 ++++++++++++++++++++++++++++ - sdma/user_cmd/sdma_tools_include.h | 24 ++++ - 7 files changed, 390 insertions(+), 1 deletion(-) - create mode 100644 sdma/sdma_func/sdma_common.h - create mode 100644 sdma/sdma_func/sdma_dump_reg.c - create mode 100644 sdma/sdma_func/sdma_dump_reg.h - create mode 100644 sdma/user_cmd/sdma_cmd_dump.c - create mode 100644 sdma/user_cmd/sdma_tools_include.h - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 72f2dab..4f4eb03 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -46,6 +46,7 @@ file(GLOB_RECURSE HIKPTOOL_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/serdes/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/socip/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/hccs/*.c -+ ${CMAKE_CURRENT_SOURCE_DIR}/sdma/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/tool_lib/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/info_collect/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/hikp_init_main.c -diff --git a/libhikptdev/include/hikptdev_plug.h b/libhikptdev/include/hikptdev_plug.h -index d45a654..375fb89 100644 ---- a/libhikptdev/include/hikptdev_plug.h -+++ b/libhikptdev/include/hikptdev_plug.h -@@ -44,7 +44,8 @@ enum cmd_module_type { - DPDK_MOD = 9, - CXL_MOD = 10, - UB_MOD = 11, -- HCCS_MOD = 16 -+ HCCS_MOD = 16, -+ SDMA_MOD = 17 - }; - - void hikp_unlock(void); -diff --git a/sdma/sdma_func/sdma_common.h b/sdma/sdma_func/sdma_common.h -new file mode 100644 -index 0000000..40969b8 ---- /dev/null -+++ b/sdma/sdma_func/sdma_common.h -@@ -0,0 +1,31 @@ -+/* -+ * 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 SDMA_COMMON_H -+#define SDMA_COMMON_H -+ -+#define RESP_MAX_NUM 160 -+ -+/* SDMA command code */ -+enum sdma_cmd_type { -+ SDMA_DUMP = 0, -+}; -+ -+enum sdma_dump_cmd_type { -+ DUMP_UNKNOWN = 0, -+ DUMP_CHN_STATUS, -+ DUMP_CHN_PC, -+ DUMP_CHN_VC, -+}; -+ -+#endif /* SDMA_COMMON_H */ -diff --git a/sdma/sdma_func/sdma_dump_reg.c b/sdma/sdma_func/sdma_dump_reg.c -new file mode 100644 -index 0000000..7440fb6 ---- /dev/null -+++ b/sdma/sdma_func/sdma_dump_reg.c -@@ -0,0 +1,133 @@ -+/* -+ * 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 -+#include -+#include -+#include -+#include -+#include -+#include -+#include "hikptdev_plug.h" -+#include "sdma_common.h" -+#include "sdma_dump_reg.h" -+ -+#define TARGET_DIR "/sys/devices/platform/" -+#define PREFIX "HISI0431" -+#define PREFIX_LEN 8 -+ -+int sdma_dev_check(void) -+{ -+ struct dirent *entry; -+ DIR *dir; -+ -+ dir = opendir(TARGET_DIR); -+ if (dir == NULL) { -+ perror("opendir"); -+ return -errno; -+ } -+ -+ while ((entry = readdir(dir)) != NULL) { -+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) -+ continue; -+ -+ if (strlen(entry->d_name) >= PREFIX_LEN) { -+ if (strncmp(entry->d_name, PREFIX, PREFIX_LEN) == 0) { -+ closedir(dir); -+ return 0; -+ } -+ } -+ } -+ -+ closedir(dir); -+ return -ENODEV; -+} -+ -+static int sdma_rsp_normal_check(const struct hikp_cmd_ret *cmd_ret) -+{ -+ if (cmd_ret == NULL) -+ return -ENOSPC; -+ -+ if (cmd_ret->status != 0) -+ return -EINVAL; -+ -+ if (cmd_ret->rsp_data_num > RESP_MAX_NUM) -+ return -E2BIG; -+ -+ return 0; -+} -+ -+static int sdma_get_reg(const struct tool_sdma_cmd *cmd, uint32_t *reg_save, uint32_t *reg_num) -+{ -+ struct sdma_dump_req_para req_data = { 0 }; -+ struct hikp_cmd_header req_header = { 0 }; -+ struct hikp_cmd_ret *cmd_ret; -+ uint32_t i; -+ int ret; -+ -+ req_data.chip_id = cmd->chip_id; -+ req_data.die_id = cmd->die_id; -+ req_data.chn_id = cmd->chn_id; -+ -+ hikp_cmd_init(&req_header, SDMA_MOD, SDMA_DUMP, cmd->sdma_cmd_type); -+ cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -+ ret = sdma_rsp_normal_check(cmd_ret); -+ if (ret) { -+ printf("check cmd ret failed, ret: %d.\n", ret); -+ hikp_cmd_free(&cmd_ret); -+ return ret; -+ } -+ *reg_num = cmd_ret->rsp_data_num; -+ for (i = 0; i < *reg_num; i++) -+ reg_save[i] = cmd_ret->rsp_data[i]; -+ -+ hikp_cmd_free(&cmd_ret); -+ -+ return 0; -+} -+ -+static void sdma_print_reg(const uint32_t *reg_save, uint32_t reg_num) -+{ -+ uint32_t i; -+ -+ if (reg_num == 0) { -+ printf("SDMA dump is failed\n"); -+ return; -+ } -+ printf(" sdma reg dump list:\n"); -+ for (i = 0; i < reg_num; i++) -+ printf(" 0x%08x\n", reg_save[i]); -+} -+ -+int sdma_reg_dump(struct tool_sdma_cmd *cmd) -+{ -+ uint32_t sdma_reg_save[RESP_MAX_NUM] = { 0 }; -+ uint32_t sdma_reg_num = 0; -+ int ret; -+ -+ if (cmd == NULL) -+ return -EINVAL; -+ -+ ret = sdma_dev_check(); -+ if (ret) { -+ printf("The current environment not support this feature!\n"); -+ return ret; -+ } -+ -+ ret = sdma_get_reg(cmd, sdma_reg_save, &sdma_reg_num); -+ if (ret) -+ return ret; -+ -+ sdma_print_reg(sdma_reg_save, sdma_reg_num); -+ -+ return 0; -+} -diff --git a/sdma/sdma_func/sdma_dump_reg.h b/sdma/sdma_func/sdma_dump_reg.h -new file mode 100644 -index 0000000..51c4e66 ---- /dev/null -+++ b/sdma/sdma_func/sdma_dump_reg.h -@@ -0,0 +1,28 @@ -+/* -+ * 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 SDMA_DUMP_REG_H -+#define SDMA_DUMP_REG_H -+ -+#include "sdma_tools_include.h" -+ -+struct sdma_dump_req_para { -+ uint32_t chip_id; -+ uint32_t die_id; -+ uint32_t chn_id; -+}; -+ -+int sdma_dev_check(void); -+int sdma_reg_dump(struct tool_sdma_cmd *cmd); -+ -+#endif /* SDMA_DUMP_REG_H */ -diff --git a/sdma/user_cmd/sdma_cmd_dump.c b/sdma/user_cmd/sdma_cmd_dump.c -new file mode 100644 -index 0000000..47b095d ---- /dev/null -+++ b/sdma/user_cmd/sdma_cmd_dump.c -@@ -0,0 +1,171 @@ -+/* -+ * 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 -+#include "hikptdev_plug.h" -+#include "tool_lib.h" -+#include "tool_cmd.h" -+#include "sdma_tools_include.h" -+#include "sdma_common.h" -+#include "sdma_dump_reg.h" -+ -+struct tool_sdma_cmd g_sdma_dump_cmd = { -+ .sdma_cmd_type = DUMP_UNKNOWN, -+ .chip_id = (uint32_t)(-1), -+ .die_id = (uint32_t)(-1), -+ .chn_id = (uint32_t)(-1), -+}; -+ -+static int sdma_dump_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ int ret; -+ -+ ret = sdma_dev_check(); -+ if (ret) { -+ printf("The current environment not support this feature!\n"); -+ return ret; -+ } -+ HIKP_SET_USED(argv); -+ -+ printf("\n Usage: %s\n", self->cmd_ptr->name); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf(" %s, %-25s %s\n", "-c", "--chipid", "please input chip id[x] first\n"); -+ printf(" %s, %-25s %s\n", "-d", "--dieid", "please input die id[x] first\n"); -+ printf(" %s, %-25s %s\n", "-n", "--chnid", "please input chn id[x] first\n"); -+ printf("\n Options:\n\n"); -+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); -+ printf(" %s, %-25s %s\n", "-s", "--chnstatus", "dump sdma channel status dfx reg\n"); -+ printf("\tParameter Limitation: -c --chipid and -d --dieid is necessary,"); -+ printf(" -n --chnid is invalid\n"); -+ printf("\tUsage: -s -c [chipid] -d [dieid], e.g. -s -c 0 -d 0\n\n"); -+ printf(" %s, %-25s %s\n", "-p", "--pc", "dump sdma pc channel dfx reg\n"); -+ printf("\tParameter Limitation: All three parameters are necessary,"); -+ printf(" the -n --chnid range is limited to 0-31\n"); -+ printf("\tUsage: -p -c [chipid] -d [dieid] -n [chnid], e.g. -p -c 0 -d 0 -n 31\n\n"); -+ printf(" %s, %-25s %s\n", "-v", "--vc", "dump sdma vc channel dfx reg\n"); -+ printf("\tParameter Limitation: All three parameters are necessary,"); -+ printf(" the -n --chnid range is limited to 0-159\n"); -+ printf("\tUsage: -v -c [chipid] -d [dieid] -n [chnid], e.g. -v -c 0 -d 0 -n 159\n\n"); -+ printf("\n"); -+ -+ return 0; -+} -+ -+static int sdma_set_id(struct major_cmd_ctrl *self, const char *argv, uint32_t *id) -+{ -+ uint32_t val = 0; -+ int ret; -+ -+ ret = string_toui(argv, &val); -+ if (ret) { -+ snprintf(self->err_str, sizeof(self->err_str), "Invalid id."); -+ self->err_no = ret; -+ return ret; -+ } -+ *id = val; -+ return ret; -+} -+ -+static int sdma_set_chip_id(struct major_cmd_ctrl *self, const char *argv) -+{ -+ return sdma_set_id(self, argv, &g_sdma_dump_cmd.chip_id); -+} -+ -+static int sdma_set_die_id(struct major_cmd_ctrl *self, const char *argv) -+{ -+ return sdma_set_id(self, argv, &g_sdma_dump_cmd.die_id); -+} -+ -+static int sdma_set_chn_id(struct major_cmd_ctrl *self, const char *argv) -+{ -+ return sdma_set_id(self, argv, &g_sdma_dump_cmd.chn_id); -+} -+ -+static int sdma_dump_chn_status(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ g_sdma_dump_cmd.sdma_cmd_type = DUMP_CHN_STATUS; -+ return 0; -+} -+ -+static int sdma_dump_chn_pc(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ g_sdma_dump_cmd.sdma_cmd_type = DUMP_CHN_PC; -+ return 0; -+} -+ -+static int sdma_dump_chn_vc(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ g_sdma_dump_cmd.sdma_cmd_type = DUMP_CHN_VC; -+ return 0; -+} -+ -+static int sdma_dump_excute_function_call(uint32_t cmd_type) -+{ -+ if (cmd_type != DUMP_UNKNOWN) -+ return sdma_reg_dump(&g_sdma_dump_cmd); -+ -+ return -EINVAL; -+} -+ -+static void sdma_dump_execute(struct major_cmd_ctrl *self) -+{ -+ int ret; -+ const char *suc_msg[] = { -+ "", -+ "sdma_dump_chn_status success.", -+ "sdma_dump_dfx_pc success.", -+ "sdma_dump_dfx_vc success." -+ }; -+ const char *err_msg[] = { -+ "sdma_dump failed, unknown cmd type", -+ "sdma_dump_chn_status error.", -+ "sdma_dump_dfx_pc error.", -+ "sdma_dump_dfx_vc error." -+ }; -+ -+ ret = sdma_dump_excute_function_call(g_sdma_dump_cmd.sdma_cmd_type); -+ if (ret == 0) -+ printf("%s\n", suc_msg[g_sdma_dump_cmd.sdma_cmd_type]); -+ else { -+ snprintf(self->err_str, sizeof(self->err_str), "%s\n", -+ err_msg[g_sdma_dump_cmd.sdma_cmd_type]); -+ self->err_no = ret; -+ } -+} -+ -+static void cmd_sdma_dump_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = sdma_dump_execute; -+ -+ cmd_option_register("-c", "--chipid", true, sdma_set_chip_id); -+ cmd_option_register("-d", "--dieid", true, sdma_set_die_id); -+ cmd_option_register("-n", "--chnid", true, sdma_set_chn_id); -+ cmd_option_register("-h", "--help", false, sdma_dump_help); -+ cmd_option_register("-s", "--chnstatus", false, sdma_dump_chn_status); -+ cmd_option_register("-p", "--pc", false, sdma_dump_chn_pc); -+ cmd_option_register("-v", "--vc", false, sdma_dump_chn_vc); -+} -+ -+HIKP_CMD_DECLARE("sdma_dump", "sdma reg dump", cmd_sdma_dump_init); -diff --git a/sdma/user_cmd/sdma_tools_include.h b/sdma/user_cmd/sdma_tools_include.h -new file mode 100644 -index 0000000..01b24b5 ---- /dev/null -+++ b/sdma/user_cmd/sdma_tools_include.h -@@ -0,0 +1,24 @@ -+/* -+ * 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 SDMA_TOOLS_INCLUDE_H -+#define SDMA_TOOLS_INCLUDE_H -+ -+struct tool_sdma_cmd { -+ uint32_t sdma_cmd_type; -+ uint32_t chip_id; -+ uint32_t die_id; -+ uint32_t chn_id; -+}; -+ -+#endif /* SDMA_TOOLS_INCLUDE_H */ --- -2.45.0.windows.1 - diff --git a/0097-Add-support-collect-sdma-hikptool-dump-reg-info.patch b/0097-Add-support-collect-sdma-hikptool-dump-reg-info.patch deleted file mode 100644 index fe689aa324af3d4cb642ae142d00dfab4a73e40d..0000000000000000000000000000000000000000 --- a/0097-Add-support-collect-sdma-hikptool-dump-reg-info.patch +++ /dev/null @@ -1,389 +0,0 @@ -From 3a8f39f91fd54a656a0b3d9278f4d77eddc94771 Mon Sep 17 00:00:00 2001 -From: zhangyuyang -Date: Fri, 28 Feb 2025 14:20:26 +0800 -Subject: [PATCH 2/2] Add support collect sdma hikptool dump reg info. - -1. support collect sdma info e.g. hiktool info_collect -sdma - -Signed-off-by: zhangyuyang ---- - info_collect/hikp_collect.h | 3 + - info_collect/hikp_collect_main.c | 19 ++- - info_collect/hikp_collect_sdma.c | 261 +++++++++++++++++++++++++++++++ - 3 files changed, 282 insertions(+), 1 deletion(-) - create mode 100644 info_collect/hikp_collect_sdma.c - -diff --git a/info_collect/hikp_collect.h b/info_collect/hikp_collect.h -index 28aa5a4..26108ac 100644 ---- a/info_collect/hikp_collect.h -+++ b/info_collect/hikp_collect.h -@@ -24,6 +24,7 @@ - #define GROUP_IMP "imp" - #define GROUP_COMMON "common" - #define GROUP_SERDES "serdes" -+#define GROUP_SDMA "sdma" - - enum info_collect_type { - COLLECT_ACC, -@@ -35,6 +36,7 @@ enum info_collect_type { - COLLECT_SATA, - COLLECT_SERDES, - COLLECT_SOCIP, -+ COLLECT_SDMA, - COLLECT_ALL, - COLLECT_UNKNOWN_TYPE, - }; -@@ -49,5 +51,6 @@ void collect_roce_log(void); - void collect_pcie_info(void); - void collect_imp_log(void); - void collect_serdes_log(void); -+void collect_sdma_log(void); - - #endif /* HIKP_COLLECT_H */ -diff --git a/info_collect/hikp_collect_main.c b/info_collect/hikp_collect_main.c -index c413346..46120a5 100644 ---- a/info_collect/hikp_collect_main.c -+++ b/info_collect/hikp_collect_main.c -@@ -108,6 +108,15 @@ static int info_collect_socip(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - -+static int info_collect_sdma(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ set_info_collect_type(COLLECT_SDMA); -+ return 0; -+} -+ - static int info_collect_all(struct major_cmd_ctrl *self, const char *argv) - { - HIKP_SET_USED(self); -@@ -128,12 +137,13 @@ static void collect_all_log(void) - collect_sata_log(); - collect_serdes_log(); - collect_socip_log(); -+ collect_sdma_log(); - } - - static int info_collect_excute_funs_call(uint32_t collect_type) - { - const char *type_name[] = {"acc", "imp", "nic", "pcie", "roce", "sas", -- "sata", "serdes", "socip", "all"}; -+ "sata", "serdes", "socip", "sdma", "all"}; - int ret; - - if (collect_type == COLLECT_UNKNOWN_TYPE) -@@ -173,6 +183,9 @@ static int info_collect_excute_funs_call(uint32_t collect_type) - case COLLECT_SOCIP: - collect_socip_log(); - break; -+ case COLLECT_SDMA: -+ collect_sdma_log(); -+ break; - case COLLECT_ALL: - collect_all_log(); - break; -@@ -199,6 +212,7 @@ static void info_collect_execute(struct major_cmd_ctrl *self) - "collect sata info success.", - "collect serdes info success.", - "collect socip info success.", -+ "collect sdma info success.", - "collect all info success.", - }; - const char *err_msg[] = { -@@ -211,6 +225,7 @@ static void info_collect_execute(struct major_cmd_ctrl *self) - "collect sata info error.", - "collect serdes info error.", - "collect socip info error.", -+ "collect sdma info error.", - "collect all info error.", - "collect info failed, unknown type.", - }; -@@ -245,6 +260,7 @@ static int info_collect_help(struct major_cmd_ctrl *self, const char *argv) - printf(" %s, %-25s %s\n", "-sata", "--sata", "collect sata info\n"); - printf(" %s, %-25s %s\n", "-serdes", "--serdes", "collect serdes info\n"); - printf(" %s, %-25s %s\n", "-socip", "--socip", "collect socip info\n"); -+ printf(" %s, %-25s %s\n", "-sdma", "--sdma", "collect sdma info\n"); - printf(" %s, %-25s %s\n", "-all", "--all", "collect all info\n"); - printf("\n"); - -@@ -268,6 +284,7 @@ static void cmd_info_collect_init(void) - cmd_option_register("-sata", "--sata", false, info_collect_sata); - cmd_option_register("-serdes", "--serdes", false, info_collect_serdes); - cmd_option_register("-socip", "--socip", false, info_collect_socip); -+ cmd_option_register("-sdma", "--sdma", false, info_collect_sdma); - cmd_option_register("-all", "--all", false, info_collect_all); - } - -diff --git a/info_collect/hikp_collect_sdma.c b/info_collect/hikp_collect_sdma.c -new file mode 100644 -index 0000000..8dc315c ---- /dev/null -+++ b/info_collect/hikp_collect_sdma.c -@@ -0,0 +1,261 @@ -+/* -+ * Copyright (c) 2024 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 -+#include -+#include "hikp_collect_lib.h" -+#include "hikp_collect.h" -+#include "tool_lib.h" -+#include "sdma_dump_reg.h" -+#include "sdma_tools_include.h" -+ -+#define PC_MAX_NUM 32 -+#define VC_MAX_NUM 160 -+#define SDMA_DIE_MAX 4 -+#define SDMA_DIE_CHANGE 2 -+#define SDMA_DUMP_DELAY 50000 -+#define BUFFER_LENTH 1024 -+ -+typedef int (*reg_info_func_t)(uint32_t, uint32_t); -+ -+enum sdma_dump_type { -+ SDMA_DUMP_UNKNOWN = 0, -+ SDMA_DUMP_CHN_STATUS, -+ SDMA_DUMP_CHN_PC, -+ SDMA_DUMP_CHN_VC, -+}; -+ -+struct reg_op { -+ char *func_name; -+ reg_info_func_t func; -+ uint32_t sdma_die; -+}; -+ -+static int sdma_dmesg_exec(void *data) -+{ -+ struct info_collect_cmd *cmd = (struct info_collect_cmd *)data; -+ char dmesg_cmd[MAX_LOG_NAME_LEN] = {0}; -+ char buffer[BUFFER_LENTH] = {0}; -+ int i = 0; -+ FILE *fp; -+ -+ while (cmd->args[i] != 0) { -+ strcat(dmesg_cmd, cmd->args[i]); -+ strcat(dmesg_cmd, " "); -+ i++; -+ } -+ -+ fp = popen(dmesg_cmd, "r"); -+ if (fp == NULL) { -+ perror("popen"); -+ return -errno; -+ } -+ -+ while (fgets(buffer, sizeof(buffer), fp) != NULL) { -+ printf("%s", buffer); -+ } -+ -+ pclose(fp); -+ -+ return 0; -+} -+ -+static void collect_sdma_kernel_log(void) -+{ -+ struct info_collect_cmd sdma_kernel_cmds[] = { -+ { -+ .log_name = "dmesg", -+ .args = {"dmesg", "|", "grep", "sdma", NULL}, -+ }, -+ }; -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(sdma_kernel_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_collect_log(GROUP_SDMA, sdma_kernel_cmds[i].log_name, -+ sdma_dmesg_exec, (void *)&sdma_kernel_cmds[i]); -+ if (ret) { -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", -+ sdma_kernel_cmds[i].log_name, ret); -+ } -+ } -+} -+ -+static void collect_sdma_debugfs_log(void) -+{ -+ struct info_collect_cmd sdma_debugfs_cmds[] = { -+ { -+ .log_name = "sdma_channels", -+ .args = {"cat", "/sys/kernel/debug/sdma/sdma_channels", NULL}, -+ }, -+ { -+ .log_name = "sdma_error", -+ .args = {"cat", "/sys/kernel/debug/sdma/sdma_error", NULL}, -+ }, -+ { -+ .log_name = "sdma_stats", -+ .args = {"cat", "/sys/kernel/debug/sdma/sdma_stats", NULL}, -+ }, -+ }; -+ size_t i, size; -+ int ret; -+ -+ size = HIKP_ARRAY_SIZE(sdma_debugfs_cmds); -+ for (i = 0; i < size; i++) { -+ ret = hikp_collect_log(GROUP_SDMA, sdma_debugfs_cmds[i].log_name, -+ hikp_collect_cat_glob_exec, (void *)&sdma_debugfs_cmds[i]); -+ if (ret) { -+ HIKP_ERROR_PRINT("collect %s log failed: %d\n", -+ sdma_debugfs_cmds[i].log_name, ret); -+ } -+ } -+} -+ -+static int sdma_reg_log(void *data) -+{ -+ struct reg_op *op = (struct reg_op *)data; -+ uint32_t chip, die; -+ int ret; -+ -+ chip = op->sdma_die / SDMA_DIE_CHANGE; -+ die = op->sdma_die % SDMA_DIE_CHANGE; -+ ret = op->func(chip, die); -+ if (ret) -+ HIKP_ERROR_PRINT("%s chip%u die%u failed: %d\n", op->func_name, chip, die, ret); -+ -+ return ret; -+} -+ -+static int sdma_chn_status_dump_info(uint32_t chip_id, uint32_t die_id) -+{ -+ struct tool_sdma_cmd cmd = { -+ .chip_id = chip_id, -+ .die_id = die_id, -+ }; -+ int ret; -+ -+ printf("hikptool sdma_dump -s -c %u -d %u\n", cmd.chip_id, cmd.die_id); -+ printf(" sdma%u channel status\n", SDMA_DIE_CHANGE * cmd.chip_id + cmd.die_id); -+ cmd.sdma_cmd_type = SDMA_DUMP_CHN_STATUS; -+ ret = sdma_reg_dump(&cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("dump channel status failed: %d\n", ret); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int sdma_pc_dump_info(uint32_t chip_id, uint32_t die_id) -+{ -+ struct tool_sdma_cmd cmd = { -+ .chip_id = chip_id, -+ .die_id = die_id, -+ }; -+ uint32_t i; -+ int ret; -+ -+ cmd.sdma_cmd_type = SDMA_DUMP_CHN_PC; -+ for (i = 0; i < PC_MAX_NUM; i++) { -+ printf("hikptool sdma_dump -p -c %u -d %u -n %u\n", cmd.chip_id, cmd.die_id, i); -+ printf(" sdma%u pc chn%u\n", SDMA_DIE_CHANGE * cmd.chip_id + cmd.die_id, i); -+ cmd.chn_id = i; -+ ret = sdma_reg_dump(&cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("dump pc chn%u reg failed: %d\n", i, ret); -+ return ret; -+ } -+ } -+ -+ return 0; -+} -+ -+static int sdma_vc_dump_info(uint32_t chip_id, uint32_t die_id) -+{ -+ struct tool_sdma_cmd cmd = { -+ .chip_id = chip_id, -+ .die_id = die_id, -+ }; -+ uint32_t i; -+ int ret; -+ -+ cmd.sdma_cmd_type = SDMA_DUMP_CHN_VC; -+ for (i = 0; i < VC_MAX_NUM; i++) { -+ printf("hikptool sdma_dump -v -c %u -d %u -n %u\n", cmd.chip_id, cmd.die_id, i); -+ printf(" sdma%u vc chn%u\n", SDMA_DIE_CHANGE * cmd.chip_id + cmd.die_id, i); -+ cmd.chn_id = i; -+ ret = sdma_reg_dump(&cmd); -+ if (ret) { -+ HIKP_ERROR_PRINT("dump vc chn%u reg failed: %d\n", i, ret); -+ return ret; -+ } -+ } -+ -+ return 0; -+} -+ -+static void collect_sdma_reg_log(void) -+{ -+ struct reg_op ch_op = { -+ .func = sdma_chn_status_dump_info, -+ .func_name = "sdma_chn_status_dump_info", -+ }; -+ struct reg_op pc_op = { -+ .func = sdma_pc_dump_info, -+ .func_name = "sdma_pc_dump_info", -+ }; -+ struct reg_op vc_op = { -+ .func = sdma_vc_dump_info, -+ .func_name = "sdma_vc_dump_info", -+ }; -+ char log_name[MAX_LOG_NAME_LEN] = {0}; -+ uint32_t i; -+ int ret; -+ -+ for (i = 0; i < SDMA_DIE_MAX; i++) { -+ ch_op.sdma_die = i; -+ memset(log_name, 0, MAX_LOG_NAME_LEN); -+ (void)snprintf(log_name, MAX_LOG_NAME_LEN, "sdma%u_channel_status_dump", i); -+ -+ ret = hikp_collect_log(GROUP_SDMA, log_name, sdma_reg_log, (void *)&ch_op); -+ if (ret) -+ HIKP_ERROR_PRINT("%s failed: %d\n", ch_op.func_name, ret); -+ usleep(SDMA_DUMP_DELAY); -+ -+ pc_op.sdma_die = i; -+ memset(log_name, 0, MAX_LOG_NAME_LEN); -+ (void)snprintf(log_name, MAX_LOG_NAME_LEN, "sdma%u_pc_dump", i); -+ -+ ret = hikp_collect_log(GROUP_SDMA, log_name, sdma_reg_log, (void *)&pc_op); -+ if (ret) -+ HIKP_ERROR_PRINT("%s failed: %d\n", pc_op.func_name, ret); -+ usleep(SDMA_DUMP_DELAY); -+ -+ vc_op.sdma_die = i; -+ memset(log_name, 0, MAX_LOG_NAME_LEN); -+ (void)snprintf(log_name, MAX_LOG_NAME_LEN, "sdma%u_vc_dump", i); -+ -+ ret = hikp_collect_log(GROUP_SDMA, log_name, sdma_reg_log, (void *)&vc_op); -+ if (ret) -+ HIKP_ERROR_PRINT("%s failed: %d\n", vc_op.func_name, ret); -+ usleep(SDMA_DUMP_DELAY); -+ } -+} -+ -+void collect_sdma_log(void) -+{ -+ collect_sdma_kernel_log(); -+ collect_sdma_debugfs_log(); -+ collect_sdma_reg_log(); -+} --- -2.45.0.windows.1 - diff --git a/0098-hikptool-Update-the-tool-version-number-to-1.1.4.patch b/0098-hikptool-Update-the-tool-version-number-to-1.1.4.patch deleted file mode 100644 index 0520b30eb6e24aad919926315b0fbcb41b6f71a2..0000000000000000000000000000000000000000 --- a/0098-hikptool-Update-the-tool-version-number-to-1.1.4.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 3feff89b32b14e562e79d7c07053dd764321accc Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Fri, 14 Mar 2025 20:41:11 +0800 -Subject: [PATCH] hikptool: Update the tool version number to 1.1.4 - -Update the tool version number to 1.1.4 - -Signed-off-by: veega2022 ---- - tool_lib/tool_lib.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index 24b1fbb..d4493d7 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.3" -+#define TOOL_VER "1.1.4" - - #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/0099-hikptool-ras-Add-support-for-exporting-black-box-dat.patch b/0099-hikptool-ras-Add-support-for-exporting-black-box-dat.patch deleted file mode 100644 index fe1d50488e98546cfd453d2b3d262ff84d772ed3..0000000000000000000000000000000000000000 --- a/0099-hikptool-ras-Add-support-for-exporting-black-box-dat.patch +++ /dev/null @@ -1,713 +0,0 @@ -From 2cfa1ab8d699bc0336063409942ff5afb86394a8 Mon Sep 17 00:00:00 2001 -From: Bing Xia -Date: Wed, 12 Mar 2025 10:24:21 +0800 -Subject: [PATCH] hikptool: ras: Add support for exporting black box data to - file. - -1. support export black box data - e.g. hikptool bbox_export -2. support clear black box data - e.g. hikptool bbox_export -c - -Signed-off-by: Bing Xia xiabing14@h-partners.com ---- - CMakeLists.txt | 1 + - libhikptdev/include/hikptdev_plug.h | 3 +- - ras/ras_func/ras_common.h | 26 ++ - ras/ras_func/ras_dump_data.c | 389 ++++++++++++++++++++++++++++ - ras/ras_func/ras_dump_data.h | 88 +++++++ - ras/user_cmd/ras_cmd_dump.c | 99 +++++++ - ras/user_cmd/ras_tools_include.h | 25 ++ - 7 files changed, 630 insertions(+), 1 deletion(-) - create mode 100644 ras/ras_func/ras_common.h - create mode 100644 ras/ras_func/ras_dump_data.c - create mode 100644 ras/ras_func/ras_dump_data.h - create mode 100644 ras/user_cmd/ras_cmd_dump.c - create mode 100644 ras/user_cmd/ras_tools_include.h - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 4f4eb03..d50e2ac 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -47,6 +47,7 @@ file(GLOB_RECURSE HIKPTOOL_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/socip/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/hccs/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/sdma/*.c -+ ${CMAKE_CURRENT_SOURCE_DIR}/ras/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/tool_lib/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/info_collect/*.c - ${CMAKE_CURRENT_SOURCE_DIR}/hikp_init_main.c -diff --git a/libhikptdev/include/hikptdev_plug.h b/libhikptdev/include/hikptdev_plug.h -index 375fb89..bb58496 100644 ---- a/libhikptdev/include/hikptdev_plug.h -+++ b/libhikptdev/include/hikptdev_plug.h -@@ -45,7 +45,8 @@ enum cmd_module_type { - CXL_MOD = 10, - UB_MOD = 11, - HCCS_MOD = 16, -- SDMA_MOD = 17 -+ SDMA_MOD = 17, -+ RAS_MOD = 19 - }; - - void hikp_unlock(void); -diff --git a/ras/ras_func/ras_common.h b/ras/ras_func/ras_common.h -new file mode 100644 -index 0000000..9b9a486 ---- /dev/null -+++ b/ras/ras_func/ras_common.h -@@ -0,0 +1,26 @@ -+/* -+ * 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 RAS_COMMON_H -+#define RAS_COMMON_H -+ -+enum { -+ RAS_DUMP, -+}; -+ -+enum ras_dump_cmd_type { -+ DUMP_DFX = 0, -+ DUMP_CLEAR, -+}; -+ -+#endif /* RAS_COMMON_H */ -diff --git a/ras/ras_func/ras_dump_data.c b/ras/ras_func/ras_dump_data.c -new file mode 100644 -index 0000000..6230a48 ---- /dev/null -+++ b/ras/ras_func/ras_dump_data.c -@@ -0,0 +1,389 @@ -+/* -+ * 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 -+#include -+#include -+#include -+#include -+#include -+#include -+#include "hikptdev_plug.h" -+#include "op_logs.h" -+#include "ras_common.h" -+#include "ras_dump_data.h" -+ -+static struct dfx_reg_dump_header header; -+ -+static int ras_get_data(uint32_t ras_cmd_type, struct ras_dump_req_para *req_data, -+ struct ras_rsp *ras_rsp_data) -+{ -+ uint32_t i; -+ struct hikp_cmd_ret *cmd_ret; -+ struct hikp_cmd_header req_header; -+ -+ hikp_cmd_init(&req_header, RAS_MOD, RAS_DUMP, ras_cmd_type); -+ cmd_ret = hikp_cmd_alloc(&req_header, req_data, RAS_REQ_DATA_LEN); -+ if (cmd_ret == NULL || cmd_ret->status != 0 || -+ cmd_ret->rsp_data_num > HIKP_RSP_ALL_DATA_MAX) { -+ printf("hikp_data_proc err\n"); -+ hikp_cmd_free(&cmd_ret); -+ return -1; -+ } -+ -+ ras_rsp_data->rsp_data_num = cmd_ret->rsp_data_num; -+ for (i = 0; i < ras_rsp_data->rsp_data_num; i++) { -+ ras_rsp_data->rsp_data[i] = cmd_ret->rsp_data[i]; -+ } -+ -+ hikp_cmd_free(&cmd_ret); -+ return 0; -+} -+ -+static void ras_print_time(struct file_seq *s) -+{ -+ time_t time_seconds = time(0); -+ struct tm timeinfo; -+ -+ (void)localtime_r(&time_seconds, &timeinfo); -+ s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "Time: %d-%d-%d %d:%d:%d\n", -+ timeinfo.tm_year + START_YEAR, timeinfo.tm_mon + 1, timeinfo.tm_mday, -+ timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); -+} -+ -+static int ras_parse_data(uint32_t *reg_save, uint32_t reg_num, uint32_t reg_off, struct file_seq *s) -+{ -+ uint32_t i, j; -+ uint32_t cycle; -+ uint32_t reg_count, pkt_reg_num; -+ uint32_t off = reg_off; -+ -+ pkt_reg_num = header.pkt_length / sizeof(uint32_t); -+ cycle = reg_num / pkt_reg_num; -+ if (!cycle) -+ return -1; -+ -+ for (i = 0; i < cycle; i++) { -+ if ((off + pkt_reg_num) > HIKP_RSP_ALL_DATA_MAX) { -+ HIKP_ERROR_PRINT("off is %u, pkt_reg_num is %u,\ -+ reg_save index will exceed max reg_save length\n", -+ off, pkt_reg_num); -+ return -1; -+ } -+ -+ ras_print_time(s); -+ s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "Socket: 0X%hhX\t", -+ (reg_save[off + DFX_HEAD_INFO_DW0] >> DFX_HEAD_SKT_ID_OFF) & 0xff); -+ s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "DIE: 0X%hhX\t", -+ (reg_save[off + DFX_HEAD_INFO_DW0] >> DFX_HEAD_DIE_ID_OFF) & 0xff); -+ s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "Module: 0X%hhX\t", -+ (reg_save[off + DFX_HEAD_INFO_DW1] >> DFX_HEAD_MODULE_ID_OFF) & 0xff); -+ s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "Sub Module: 0X%hhX\t", -+ (reg_save[off + DFX_HEAD_INFO_DW1] >> DFX_HEAD_SUBMODULE_ID_OFF) & 0xff); -+ s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "SequenceNum: 0X%hhX\t", -+ (reg_save[off + DFX_HEAD_INFO_DW1] >> DFX_HEAD_SEQUENCE_NUM_OFF) & 0xff); -+ s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "Version: 0X%hhX\n", -+ (reg_save[off + DFX_HEAD_INFO_DW0] >> DFX_HEAD_VERSION_OFF) & 0xff); -+ s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, -+ "----------------------- DFX REGISTER DUMP -----------------------\n"); -+ -+ reg_count = (reg_save[off + DFX_HEAD_INFO_DW1] >> DFX_HEAD_REG_COUNT_OFF) & 0xff; -+ if (!reg_count || reg_count > pkt_reg_num - DFX_REG_PACKET_HEAD_LEN) { -+ HIKP_ERROR_PRINT("reg_count is %u, value is not within the reasonable range(1-%u).\n", -+ reg_count, pkt_reg_num - DFX_REG_PACKET_HEAD_LEN); -+ return -1; -+ } -+ -+ for (j = 0; j < reg_count; j++) -+ s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "0X%X\n", -+ reg_save[off + DFX_COMMON_MAIN_TEXT_BEGIN + j]); -+ -+ s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "\n"); -+ off += pkt_reg_num; -+ } -+ -+ return 0; -+} -+ -+static int ras_generate_file_name(struct file_seq *s) -+{ -+ time_t time_seconds = time(0); -+ struct tm timeinfo; -+ int ret; -+ -+ (void)localtime_r(&time_seconds, &timeinfo); -+ ret = snprintf(s->file_name, MAX_LOG_NAME_LEN, "rasdfx_%d_%d_%d_%d_%d_%d.log", -+ timeinfo.tm_year + START_YEAR, timeinfo.tm_mon + 1, timeinfo.tm_mday, -+ timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); -+ if (ret < 0 || (uint32_t)ret >= MAX_LOG_NAME_LEN) { -+ HIKP_ERROR_PRINT("generate file name failed, errno is %d\n", errno); -+ return -errno; -+ } -+ -+ return 0; -+} -+ -+static int ras_store_data(struct file_seq *s) -+{ -+ char file_path[OP_LOG_FILE_PATH_MAXLEN]; -+ size_t write_cnt; -+ FILE *fp; -+ int rc; -+ -+ rc = snprintf(file_path, sizeof(file_path), HIKP_LOG_DIR_PATH"%s", s->file_name); -+ if (rc < 0) { -+ HIKP_ERROR_PRINT("creat log file path fail.\n"); -+ return -EIO; -+ } -+ -+ fp = fopen(file_path, "a"); -+ if (fp == NULL) { -+ HIKP_ERROR_PRINT("open %s failed, errno is %d\n", file_path, errno); -+ return -errno; -+ } -+ -+ write_cnt = fwrite(s->buffer, 1, s->len, fp); -+ if (write_cnt != (uint32_t)s->len) { -+ fclose(fp); -+ HIKP_ERROR_PRINT("write %s failed, write cnt %zu.\n", file_path, write_cnt); -+ return -EAGAIN; -+ } -+ -+ printf("dump imp log completed, log file: %s.\n", file_path); -+ /* Set the file permission to 0440 */ -+ if (chmod(file_path, 0440)) -+ HIKP_ERROR_PRINT("chmod %s failed, errno is %d\n", file_path, errno); -+ -+ if (fclose(fp)) { -+ HIKP_ERROR_PRINT("close %s failed, errno is %d\n", file_path, errno); -+ return -errno; -+ } -+ -+ s->len = 0; -+ -+ return 0; -+} -+ -+static int file_seq_init(struct file_seq *s, uint32_t size) -+{ -+ if (!size) -+ return -1; -+ -+ s->buffer_size = size; -+ s->len = 0; -+ s->buffer = (char*)malloc(s->buffer_size); -+ if (!s->buffer) -+ return -1; -+ -+ return 0; -+} -+ -+static void file_seq_destroy(struct file_seq *s) -+{ -+ free(s->buffer); -+ s->buffer = NULL; -+} -+ -+static void ras_rsp_init(struct ras_rsp *ras_rsp_data) -+{ -+ ras_rsp_data->first_pkt_begin = 0; -+ ras_rsp_data->last_pkt_end = 0; -+ ras_rsp_data->rsp_data_num = 0; -+ ras_rsp_data->packet_buffer_len = 0; -+ -+ memset(ras_rsp_data->rsp_data, 0, sizeof(ras_rsp_data->rsp_data)); -+ memset(ras_rsp_data->packet_buffer, 0, sizeof(ras_rsp_data->packet_buffer)); -+} -+ -+static int parse_packet_buffer_data(struct ras_rsp *ras_rsp_data, -+ uint32_t pkt_reg_num, struct file_seq *s) -+{ -+ int ret; -+ -+ if (pkt_reg_num > MAX_DFX_PACKET_LEN) { -+ HIKP_ERROR_PRINT("pkt_reg_num is %u, has exceeded max packet length\n", pkt_reg_num); -+ return -1; -+ } -+ -+ if (ras_rsp_data->packet_buffer_len) { -+ uint32_t rest_pkt_length; -+ -+ rest_pkt_length = pkt_reg_num - ras_rsp_data->packet_buffer_len; -+ memcpy(ras_rsp_data->packet_buffer + ras_rsp_data->packet_buffer_len, -+ ras_rsp_data->rsp_data, rest_pkt_length); -+ -+ ras_rsp_data->first_pkt_begin = rest_pkt_length; -+ ret = ras_parse_data(ras_rsp_data->packet_buffer, pkt_reg_num, 0, s); -+ if (ret) { -+ HIKP_ERROR_PRINT("ras parse packet_buffer_data is failed\n"); -+ return ret; -+ } -+ } else { -+ ras_rsp_data->first_pkt_begin = 0; -+ } -+ -+ if (ras_rsp_data->first_pkt_begin == ras_rsp_data->rsp_data_num) -+ return 0; -+ -+ ras_rsp_data->packet_buffer_len = -+ (ras_rsp_data->rsp_data_num - ras_rsp_data->first_pkt_begin) % pkt_reg_num; -+ ras_rsp_data->last_pkt_end = ras_rsp_data->rsp_data_num - ras_rsp_data->packet_buffer_len - 1; -+ ras_rsp_data->rsp_data_num = ras_rsp_data->last_pkt_end - ras_rsp_data->first_pkt_begin + 1; -+ -+ memcpy(ras_rsp_data->packet_buffer, ras_rsp_data->rsp_data + ras_rsp_data->last_pkt_end + 1, -+ ras_rsp_data->packet_buffer_len); -+ -+ return 0; -+} -+ -+static int ras_dump_pkt_pre(struct ras_rsp *ras_rsp_data, struct file_seq *s) -+{ -+ int ret; -+ uint32_t reg_num, max_pkt_num, s_buffer_size; -+ -+ max_pkt_num = (HIKP_RSP_DATA_SIZE_MAX / header.pkt_length) + 1; -+ reg_num = header.pkt_length / sizeof(uint32_t) - DFX_REG_PACKET_HEAD_LEN; -+ s_buffer_size = max_pkt_num * -+ (reg_num * DFX_FILE_SINGLE_REG_SIZE + DFX_FILE_SINGLE_PACKET_HEAD_SIZE); -+ ras_rsp_data->rsp_data_num = 0; -+ -+ ret = file_seq_init(s, s_buffer_size); -+ if (ret) { -+ HIKP_ERROR_PRINT("malloc file_seq buffer is failed\n"); -+ return ret; -+ } -+ -+ ret = ras_generate_file_name(s); -+ if (ret) { -+ HIKP_ERROR_PRINT("ras generate file name is failed\n"); -+ file_seq_destroy(s); -+ return ret; -+ } -+ -+ return ret; -+} -+ -+static int ras_dump_packet(struct tool_ras_cmd *cmd, struct ras_rsp *ras_rsp_data, -+ struct ras_dump_req_para *req_data) -+{ -+ int ret; -+ uint32_t i, cmd_num; -+ bool has_printed_socid = false; -+ struct file_seq s; -+ -+ ret = ras_dump_pkt_pre(ras_rsp_data, &s); -+ if (ret) -+ return ret; -+ -+ cmd_num = (header.pkt_num * header.pkt_length + -+ HIKP_RSP_DATA_SIZE_MAX - 1) / HIKP_RSP_DATA_SIZE_MAX; -+ /* 0: get header info; 1-n: get packet data */ -+ for (i = 0; i < cmd_num; i++) { -+ req_data->cmd_id = i + 1; -+ ret = ras_get_data(cmd->ras_cmd_type, req_data, ras_rsp_data); -+ if (ret) { -+ HIKP_ERROR_PRINT("ras dump cmd %u is failed\n", req_data->cmd_id); -+ goto err_out_free; -+ } -+ -+ if (!has_printed_socid) { -+ s.len += snprintf(s.buffer + s.len, s.buffer_size - s.len, "SocID: %hhX\n", -+ (ras_rsp_data->rsp_data[DFX_HEAD_INFO_DW0] >> DFX_HEAD_SOC_ID_OFF) & 0xff); -+ s.len += snprintf(s.buffer + s.len, s.buffer_size - s.len, "\n"); -+ -+ has_printed_socid = true; -+ } -+ -+ ret = parse_packet_buffer_data(ras_rsp_data, header.pkt_length / sizeof(uint32_t), &s); -+ if (ret) { -+ HIKP_ERROR_PRINT("ras parse packet buffer data is failed\n"); -+ goto err_out_free; -+ } -+ -+ if (ras_rsp_data->first_pkt_begin != ras_rsp_data->rsp_data_num) { -+ ret = ras_parse_data(ras_rsp_data->rsp_data, ras_rsp_data->rsp_data_num, -+ ras_rsp_data->first_pkt_begin, &s); -+ if (ret) { -+ HIKP_ERROR_PRINT("ras parse rsp_data is failed\n"); -+ goto err_out_free; -+ } -+ } -+ -+ ret = ras_store_data(&s); -+ if (ret) { -+ HIKP_ERROR_PRINT("ras store rsp_data is failed\n"); -+ goto err_out_free; -+ } -+ } -+ -+err_out_free: -+ file_seq_destroy(&s); -+ return ret; -+} -+ -+int ras_data_dump(struct tool_ras_cmd *cmd) -+{ -+ int ret; -+ struct ras_rsp ras_rsp_data; -+ struct ras_dump_req_para req_data = {0}; -+ -+ if (cmd == NULL) -+ return -ENOSPC; -+ -+ ras_rsp_init(&ras_rsp_data); -+ ret = ras_get_data(cmd->ras_cmd_type, &req_data, &ras_rsp_data); -+ if (ret || (ras_rsp_data.rsp_data_num != DFX_REG_DUMP_HEADER_LEN)) { -+ HIKP_ERROR_PRINT("ras dump header is failed, rsp_data_num is %u\n", -+ ras_rsp_data.rsp_data_num); -+ return -1; -+ } -+ -+ if (!ras_rsp_data.rsp_data[HEAD_MAGIC]) { -+ HIKP_ERROR_PRINT("ras dfx dump is failed, data does not exist or has been cleared.\n"); -+ return -1; -+ } -+ -+ header.pkt_num = ras_rsp_data.rsp_data[PKT_NUM]; -+ header.pkt_length = ras_rsp_data.rsp_data[PKT_LENGTH]; -+ if (header.pkt_num == 0 || header.pkt_length < DFX_REG_PACKET_HEAD_LEN) { -+ HIKP_ERROR_PRINT("ras dfx dump is failed, pkt_num is %u, pkt_length is %u\n", -+ header.pkt_num, header.pkt_length); -+ return -1; -+ } -+ -+ ret = ras_dump_packet(cmd, &ras_rsp_data, &req_data); -+ if (ret) -+ HIKP_ERROR_PRINT("ras dump packet is failed\n"); -+ -+ return ret; -+} -+ -+int ras_data_clear(struct tool_ras_cmd *cmd) -+{ -+ int ret; -+ struct ras_rsp ras_rsp_data; -+ struct ras_dump_req_para req_data = { 0 }; -+ -+ if (cmd == NULL) -+ return -ENOSPC; -+ -+ ras_rsp_init(&ras_rsp_data); -+ ret = ras_get_data(cmd->ras_cmd_type, &req_data, &ras_rsp_data); -+ if (ret || ras_rsp_data.rsp_data_num != DFX_REG_DUMP_HEADER_LEN || -+ ras_rsp_data.rsp_data[HEAD_MAGIC] != DFX_DATA_IS_CLEARED) { -+ HIKP_ERROR_PRINT("ras dfx data clear is failed\n"); -+ return -1; -+ } -+ -+ return 0; -+} -+ -diff --git a/ras/ras_func/ras_dump_data.h b/ras/ras_func/ras_dump_data.h -new file mode 100644 -index 0000000..9b326b3 ---- /dev/null -+++ b/ras/ras_func/ras_dump_data.h -@@ -0,0 +1,88 @@ -+/* -+ * 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 RAS_DUMP_REG_H -+#define RAS_DUMP_REG_H -+ -+#include "ras_tools_include.h" -+#include "hikpt_rciep.h" -+#include "tool_lib.h" -+ -+#define RAS_FILE_HEAD_BUF_LEN 256 -+#define MAX_DFX_PACKET_LEN 256 -+#define RAS_REQ_DATA_LEN 4 -+#define DFX_REG_DUMP_HEADER_LEN 6 -+#define DFX_REG_PACKET_HEAD_LEN 3 -+ -+struct dfx_reg_dump_header { -+ uint32_t head_magic; // 文件头的magic数字,特定值表示有效记录。 -+ uint32_t version; // 存储格å¼ç‰ˆæœ¬ -+ uint32_t cap_bits; // bit0表示是å¦å¼€å¯crc,其余bitä¿ç•™ã€‚ -+ uint32_t pkt_num; // packetæ•°é‡ -+ uint32_t pkt_length; // å•个packetå ç”¨å†…存空间,å•ä½bytes -+ uint32_t reserved; -+}; -+ -+struct file_seq { -+ char *buffer; -+ uint32_t buffer_size; -+ int len; -+ char file_name[MAX_LOG_NAME_LEN]; -+}; -+ -+struct ras_rsp { -+ uint32_t rsp_data[HIKP_RSP_ALL_DATA_MAX]; -+ uint32_t first_pkt_begin; -+ uint32_t last_pkt_end; -+ uint32_t rsp_data_num; -+ uint32_t packet_buffer[MAX_DFX_PACKET_LEN]; -+ uint32_t packet_buffer_len; -+}; -+ -+struct ras_dump_req_para { -+ uint32_t cmd_id; -+}; -+ -+enum reg_dump_header_index { -+ HEAD_MAGIC, -+ VERSION, -+ CAP_BITS, -+ PKT_NUM, -+ PKT_LENGTH -+}; -+ -+enum dfx_packet_index { -+ DFX_HEAD_INFO_DW0, -+ DFX_HEAD_INFO_DW1, -+ DFX_COMMON_MAIN_TEXT_BEGIN = 3 -+}; -+ -+#define DFX_HEAD_VERSION_OFF 0 -+#define DFX_HEAD_SOC_ID_OFF 8 -+#define DFX_HEAD_SKT_ID_OFF 16 -+#define DFX_HEAD_DIE_ID_OFF 24 -+#define DFX_HEAD_MODULE_ID_OFF 0 -+#define DFX_HEAD_SUBMODULE_ID_OFF 8 -+#define DFX_HEAD_SEQUENCE_NUM_OFF 16 -+#define DFX_HEAD_REG_COUNT_OFF 24 -+ -+#define DFX_DATA_IS_CLEARED 0 -+ -+#define DFX_FILE_SINGLE_PACKET_HEAD_SIZE 256 -+#define DFX_FILE_SINGLE_REG_SIZE 10 -+ -+ -+int ras_data_dump(struct tool_ras_cmd *cmd); -+int ras_data_clear(struct tool_ras_cmd *cmd); -+ -+#endif /* RAS_DUMP_REG_H */ -diff --git a/ras/user_cmd/ras_cmd_dump.c b/ras/user_cmd/ras_cmd_dump.c -new file mode 100644 -index 0000000..f8ae828 ---- /dev/null -+++ b/ras/user_cmd/ras_cmd_dump.c -@@ -0,0 +1,99 @@ -+/* -+ * 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 -+#include "tool_cmd.h" -+#include "ras_tools_include.h" -+#include "ras_dump_data.h" -+ -+struct tool_ras_cmd g_ras_dump_cmd = { -+ .ras_cmd_type = DUMP_DFX, -+}; -+ -+static int ras_dump_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(argv); -+ -+ printf("\n Usage: %s\n", self->cmd_ptr->name); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); -+ printf(" %s, %-25s %s\n", "-c", "--clear", "clearing memory dfx data\n"); -+ printf("\n"); -+ -+ return 0; -+} -+ -+static enum ras_dump_cmd_type ras_get_cmd_type(void) -+{ -+ return g_ras_dump_cmd.ras_cmd_type; -+} -+ -+static void ras_set_cmd_type(enum ras_dump_cmd_type type) -+{ -+ g_ras_dump_cmd.ras_cmd_type = type; -+} -+ -+static int ras_set_clear(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ HIKP_SET_USED(argv); -+ -+ ras_set_cmd_type(DUMP_CLEAR); -+ return 0; -+} -+ -+static int ras_dump_execute_process(void) -+{ -+ if (ras_get_cmd_type() == DUMP_DFX) -+ return ras_data_dump(&g_ras_dump_cmd); -+ else if (ras_get_cmd_type() == DUMP_CLEAR) -+ return ras_data_clear(&g_ras_dump_cmd); -+ else -+ return -EINVAL; -+} -+ -+static void ras_dump_execute(struct major_cmd_ctrl *self) -+{ -+ int ret; -+ const char *suc_msg[] = { -+ "ras dfx data dump success.", -+ "ras dfx data clear success." -+ }; -+ const char *err_msg[] = { -+ "ras dfx data dump error.", -+ "ras dfx data clear error." -+ }; -+ -+ ret = ras_dump_execute_process(); -+ if (ret == 0) { -+ printf("%s\n", suc_msg[ras_get_cmd_type()]); -+ } else { -+ snprintf(self->err_str, sizeof(self->err_str), "%s\n", -+ err_msg[ras_get_cmd_type()]); -+ self->err_no = ret; -+ } -+} -+ -+static void cmd_ras_dump_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = ras_dump_execute; -+ -+ cmd_option_register("-c", "--clear", false, ras_set_clear); -+ cmd_option_register("-h", "--help", false, ras_dump_help); -+} -+ -+HIKP_CMD_DECLARE("bbox_export", "export black box data to file", cmd_ras_dump_init); -diff --git a/ras/user_cmd/ras_tools_include.h b/ras/user_cmd/ras_tools_include.h -new file mode 100644 -index 0000000..a999b8a ---- /dev/null -+++ b/ras/user_cmd/ras_tools_include.h -@@ -0,0 +1,25 @@ -+/* -+ * 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 RAS_TOOLS_INCLUDE_H -+#define RAS_TOOLS_INCLUDE_H -+ -+#include "hikptdev_plug.h" -+#include "tool_lib.h" -+#include "ras_common.h" -+ -+struct tool_ras_cmd { -+ enum ras_dump_cmd_type ras_cmd_type; -+}; -+ -+#endif /* RAS_TOOLS_INCLUDE_H */ --- -2.33.0 - diff --git a/0100-hikptool-The-cpu_ring-command-is-added.patch b/0100-hikptool-The-cpu_ring-command-is-added.patch deleted file mode 100644 index e82989f8dc5698cf037772ca4938dabc192fbaf4..0000000000000000000000000000000000000000 --- a/0100-hikptool-The-cpu_ring-command-is-added.patch +++ /dev/null @@ -1,225 +0,0 @@ -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/0101-hikptool-Code-quality-reinforcement.patch b/0101-hikptool-Code-quality-reinforcement.patch deleted file mode 100644 index 92794791fcd986ef34a4d3af6672e72b39d7e76d..0000000000000000000000000000000000000000 --- a/0101-hikptool-Code-quality-reinforcement.patch +++ /dev/null @@ -1,465 +0,0 @@ -From a24253e1a53ae199c8838f07ce3daa0ac6039894 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Tue, 10 Jun 2025 22:14:32 +0800 -Subject: [PATCH] hikptool: Code quality reinforcement - -Fixed some Code Security Review Comments -Including: Out-of-bounds access risk, -null pointer check - -Signed-off-by: veega2022 ---- - hccs/hikp_hccs.c | 2 +- - info_collect/hikp_collect_lib.c | 23 +++++++++++--- - net/nic/nic_dfx/hikp_nic_dfx.c | 16 ++++++---- - net/nic/nic_fd/hikp_nic_fd.c | 9 ++++++ - net/nic/nic_fd/hikp_nic_fd.h | 1 + - net/nic/nic_log/hikp_nic_log.c | 31 ++++++++++++++----- - .../roce_ext_common/hikp_roce_ext_common.c | 10 ++++++ - net/roce/roce_scc/hikp_roce_scc.c | 12 ++++--- - net/roce/roce_trp/hikp_roce_trp.c | 12 ++++--- - net/ub/ub_dfx/hikp_ub_dfx.c | 30 +++++++++++------- - net/ub/ub_ppp/hikp_unic_ppp.c | 13 +++++--- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 7 ++++- - tool_lib/tool_cmd.c | 10 +++++- - 13 files changed, 128 insertions(+), 48 deletions(-) - -diff --git a/hccs/hikp_hccs.c b/hccs/hikp_hccs.c -index 5ef4222..d979aad 100644 ---- a/hccs/hikp_hccs.c -+++ b/hccs/hikp_hccs.c -@@ -106,7 +106,7 @@ static int hikp_hccs_cmd_send(struct hikp_cmd_header *req_header, - goto out; - } - if (cur_blk_size > buff_len || -- cur_blk_size > sizeof(struct hikp_hccs_rsp)) { -+ cur_blk_size > sizeof(rsp->rsp_data)) { - HIKP_ERROR_PRINT("The firmware data size (%" PRIu64 ") greater than " - "sw buffer(%zu) or hikp_hccs_rsp size(%zu).\n", - cur_blk_size, buff_len, sizeof(struct hikp_hccs_rsp)); -diff --git a/info_collect/hikp_collect_lib.c b/info_collect/hikp_collect_lib.c -index bada846..c4db315 100644 ---- a/info_collect/hikp_collect_lib.c -+++ b/info_collect/hikp_collect_lib.c -@@ -102,10 +102,15 @@ int hikp_create_save_path(const char *name) - { - char collect_name[MAX_LOG_NAME_LEN] = {0}; - time_t time_seconds = time(0); -- struct tm timeinfo; -+ struct tm timeinfo, *ptm; - int ret; - -- localtime_r(&time_seconds, &timeinfo); -+ ptm = localtime_r(&time_seconds, &timeinfo); -+ if (!ptm) { -+ HIKP_ERROR_PRINT("failed to get time info.\n"); -+ return -EINVAL; -+ } -+ - if (name != NULL) - (void)snprintf((char *)collect_name, MAX_LOG_NAME_LEN, - "collect_%s_%04d%02d%02d%02d%02d%02d", -@@ -201,12 +206,22 @@ static int hikp_collect_cmd_exec(const struct info_collect_cmd *cmd) - * process just like when it succeeds. - * */ - if (execvp(cmd->args[ARGS_IDX0], cmd->args) < 0) { -- HIKP_ERROR_PRINT("execvp failed: %d\n", errno); -+ HIKP_ERROR_PRINT("%s: execvp failed %d\n", cmd->args[ARGS_IDX0], errno); - exit(EXIT_FAILURE); - } - } else if (pid > 0) { - /* Parent process */ -- waitpid(pid, &status, 0); -+ if (waitpid(pid, &status, 0) < 0) { -+ HIKP_ERROR_PRINT("%s: waitpid() failure %d\n", -+ cmd->args[ARGS_IDX0], errno); -+ } else if (WIFEXITED((unsigned int)status) && -+ (WEXITSTATUS((unsigned int)status) != 0)) { -+ HIKP_ERROR_PRINT("%s: child exit %u\n", -+ cmd->args[ARGS_IDX0], -+ WEXITSTATUS((unsigned int)status)); -+ if (strcmp(cmd->args[ARGS_IDX0], "tar") == 0) -+ return -ECHILD; -+ } - } else { - HIKP_ERROR_PRINT("fork failed!\n"); - return -ECHILD; -diff --git a/net/nic/nic_dfx/hikp_nic_dfx.c b/net/nic/nic_dfx/hikp_nic_dfx.c -index d6114de..c7737a8 100644 ---- a/net/nic/nic_dfx/hikp_nic_dfx.c -+++ b/net/nic/nic_dfx/hikp_nic_dfx.c -@@ -406,9 +406,11 @@ static const struct dfx_type_name_parse g_dfx_ssu_name_parse[] = { - - void hikp_nic_dfx_set_cmd_para(int idx) - { -- g_dfx_param.sub_cmd_code = g_dfx_module_parse[idx].sub_cmd_code; -- g_dfx_param.module_idx = idx; -- g_dfx_param.flag |= MODULE_SET_FLAG; -+ if (idx < (int)HIKP_ARRAY_SIZE(g_dfx_module_parse)) { -+ g_dfx_param.sub_cmd_code = g_dfx_module_parse[idx].sub_cmd_code; -+ g_dfx_param.module_idx = idx; -+ g_dfx_param.flag |= MODULE_SET_FLAG; -+ } - } - - static void dfx_help_info(const struct major_cmd_ctrl *self) -@@ -458,6 +460,7 @@ static int hikp_nic_dfx_get_blk(struct hikp_cmd_ret **cmd_ret, - static int hikp_nic_get_first_blk_dfx(struct nic_dfx_rsp_head_t *rsp_head, uint32_t **reg_data, - uint32_t *max_dfx_size, uint32_t *version) - { -+ uint32_t reg_data_size = MAX_DFX_DATA_NUM * sizeof(uint32_t); - struct nic_dfx_rsp_t *dfx_rsp = NULL; - struct hikp_cmd_ret *cmd_ret = NULL; - int ret; -@@ -482,11 +485,12 @@ static int hikp_nic_get_first_blk_dfx(struct nic_dfx_rsp_head_t *rsp_head, uint3 - goto err_out; - } - -- if (rsp_head->cur_blk_size > *max_dfx_size) { -+ if (rsp_head->cur_blk_size > *max_dfx_size || rsp_head->cur_blk_size > reg_data_size) { - free(*reg_data); - *reg_data = NULL; -- HIKP_ERROR_PRINT("blk0 reg_data copy size error, data size: 0x%x, max size: 0x%x\n", -- rsp_head->cur_blk_size, *max_dfx_size); -+ HIKP_ERROR_PRINT("blk0 reg_data copy size error" -+ "data size: 0x%x, max size: 0x%x, reg_data_size: 0x%x\n", -+ rsp_head->cur_blk_size, *max_dfx_size, reg_data_size); - ret = -EINVAL; - goto err_out; - } -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index 10fee42..eace094 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -841,6 +841,7 @@ static void hikp_nic_fd_data_free(union nic_fd_feature_info *fd_data) - static int hikp_nic_check_fd_hw_info(const struct nic_fd_hw_info *hw_info, - const struct fd_feature_cmd *fd_cmd) - { -+ uint16_t max_key_bytes, active_key_bits; - uint16_t i; - - if (strcmp(fd_cmd->feature_name, NIC_FD_RULES_NAME) == 0) { -@@ -863,6 +864,14 @@ static int hikp_nic_check_fd_hw_info(const struct nic_fd_hw_info *hw_info, - return -EOPNOTSUPP; - } - } -+ -+ max_key_bytes = hikp_nic_get_tcam_data_size(hw_info->key_max_bit); -+ active_key_bits = hikp_nic_get_max_key_len(hw_info->mode); -+ if (active_key_bits > max_key_bytes * HIKP_BITS_PER_BYTE) { -+ HIKP_ERROR_PRINT("The active tcam bits(%u) is more than the max key bits(%d).\n", -+ active_key_bits, max_key_bytes * HIKP_BITS_PER_BYTE); -+ return -EINVAL; -+ } - } else if (strcmp(fd_cmd->feature_name, NIC_FD_COUNTER_NAME) == 0) { - if (hw_info->alloc.stage_counter_num[NIC_FD_STAGE_1] == 0) { - HIKP_ERROR_PRINT("The stage1's counter number is zero.\n"); -diff --git a/net/nic/nic_fd/hikp_nic_fd.h b/net/nic/nic_fd/hikp_nic_fd.h -index ce363c9..98577ff 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.h -+++ b/net/nic/nic_fd/hikp_nic_fd.h -@@ -113,6 +113,7 @@ struct nic_fd_key_cfg { - struct nic_fd_hw_info { - uint8_t mode; - uint8_t enable; -+ /* Max key bit width hwardware supported and unrelated to mode. */ - uint16_t key_max_bit; - struct nic_fd_alloc alloc; - struct nic_fd_key_cfg key_cfg[NIC_FD_STAGE_NUM]; -diff --git a/net/nic/nic_log/hikp_nic_log.c b/net/nic/nic_log/hikp_nic_log.c -index 0e2d556..4dd2721 100644 ---- a/net/nic/nic_log/hikp_nic_log.c -+++ b/net/nic/nic_log/hikp_nic_log.c -@@ -56,30 +56,45 @@ static int hikp_nic_write_data_to_file(uint8_t *data, uint32_t len) - size_t write_cnt; - FILE *fp = NULL; - int ret; -+ int rc; - - ret = generate_file_name(file_name, MAX_LOG_NAME_LEN, (const unsigned char *)"m7"); - if (ret < 0) - return ret; - -- ret = snprintf(g_log_path, sizeof(g_log_path), HIKP_LOG_DIR_PATH"%s", file_name); -- if (ret < 0) { -+ rc = snprintf(g_log_path, sizeof(g_log_path), HIKP_LOG_DIR_PATH"%s", file_name); -+ if (rc < 0) { - HIKP_ERROR_PRINT("creat log file path fail.\n"); - return -EIO; - } -- (void)remove((const char *)g_log_path); -+ -+ if (access((const char *)g_log_path, F_OK) == 0) { -+ if (remove((const char *)g_log_path)) { -+ HIKP_ERROR_PRINT("remove %s failed, errno is %d\n", g_log_path, errno); -+ return -errno; -+ } -+ } -+ - fp = fopen(g_log_path, "w+"); - if (fp == NULL) { - HIKP_ERROR_PRINT("open %s failed, errno is %d\n", g_log_path, errno); - return -errno; - } - write_cnt = fwrite(data, 1, len, fp); -- if (write_cnt != len) -- HIKP_ERROR_PRINT("write %s failed, write cnt %lu.\n", g_log_path, write_cnt); -+ if (write_cnt != len) { -+ HIKP_ERROR_PRINT("write %s failed, write cnt %zu.\n", g_log_path, write_cnt); -+ ret = -EAGAIN; -+ } - - printf("dump m7 log completed, log file: %s.\n", g_log_path); -- (void)chmod(g_log_path, 0440); -- (void)fclose(fp); -- return 0; -+ /* Set the file permission to 0440 */ -+ if (chmod(g_log_path, 0440)) -+ HIKP_ERROR_PRINT("chmod %s failed, errno is %d\n", g_log_path, errno); -+ -+ if (fclose(fp)) -+ HIKP_ERROR_PRINT("close %s failed, errno is %d\n", g_log_path, errno); -+ -+ return ret; - } - - static int hikp_nic_get_blk_log(struct hikp_cmd_ret **cmd_ret, uint32_t blk_id) -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..d7aaaa8 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) { -- hikp_cmd_free(&cmd_ret); -+ if (cur_size > data_size || roce_scc_res->head.cur_block_num > ROCE_HIKP_SCC_REG_NUM) { - 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); -+ hikp_cmd_free(&cmd_ret); - 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); -diff --git a/net/ub/ub_dfx/hikp_ub_dfx.c b/net/ub/ub_dfx/hikp_ub_dfx.c -index 8a3e293..4929003 100644 ---- a/net/ub/ub_dfx/hikp_ub_dfx.c -+++ b/net/ub/ub_dfx/hikp_ub_dfx.c -@@ -104,6 +104,7 @@ static int hikp_ub_get_first_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t - struct ub_dfx_rsp *dfx_rsp = NULL; - struct hikp_cmd_ret *cmd_ret; - uint32_t rsp_data_size; -+ uint8_t cur_blk_size; - int ret; - - ret = hikp_ub_dfx_get_blk_data(&cmd_ret, 0, g_ub_dfx_param.sub_cmd_code); -@@ -127,18 +128,20 @@ static int hikp_ub_get_first_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t - } - - rsp_data_size = cmd_ret->rsp_data_num * REP_DATA_BLK_SIZE; -- if (rsp_data_size - sizeof(dfx_rsp->rsp_head) < rsp_head->cur_blk_size || -- *max_dfx_size < rsp_head->cur_blk_size) { -- HIKP_ERROR_PRINT("blk0 reg_data copy size error, rsp data size: %u, data size: %hhu, max size: %u\n", -- rsp_data_size, rsp_head->cur_blk_size, *max_dfx_size); -+ cur_blk_size = rsp_head->cur_blk_size; -+ if (rsp_data_size - sizeof(dfx_rsp->rsp_head) < cur_blk_size || -+ *max_dfx_size < cur_blk_size || cur_blk_size > sizeof(dfx_rsp->reg_data)) { -+ HIKP_ERROR_PRINT("blk0 reg_data copy size error, rsp data size: %u, " -+ "data size: %hhu, max size: %u\n", -+ rsp_data_size, cur_blk_size, *max_dfx_size); - free(*reg_data); - *reg_data = NULL; - ret = -EINVAL; - goto err_out; - } -- memcpy(*reg_data, dfx_rsp->reg_data, rsp_head->cur_blk_size); -+ memcpy(*reg_data, dfx_rsp->reg_data, cur_blk_size); - -- *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; -+ *max_dfx_size -= (uint32_t)cur_blk_size; - err_out: - hikp_cmd_free(&cmd_ret); - -@@ -151,6 +154,7 @@ static int hikp_ub_get_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t blk_id - struct ub_dfx_rsp *dfx_rsp = NULL; - struct hikp_cmd_ret *cmd_ret; - uint32_t rsp_data_size; -+ uint8_t cur_blk_size; - int ret; - - ret = hikp_ub_dfx_get_blk_data(&cmd_ret, blk_id, g_ub_dfx_param.sub_cmd_code); -@@ -160,15 +164,17 @@ static int hikp_ub_get_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t blk_id - dfx_rsp = (struct ub_dfx_rsp *)(cmd_ret->rsp_data); - *rsp_head = dfx_rsp->rsp_head; - rsp_data_size = cmd_ret->rsp_data_num * REP_DATA_BLK_SIZE; -- if (rsp_data_size - sizeof(dfx_rsp->rsp_head) < rsp_head->cur_blk_size || -- rsp_head->cur_blk_size > *max_dfx_size) { -- HIKP_ERROR_PRINT("blk%u reg_data copy size error, rsp data size: %u, data size: %hhu, max size: %u\n", -- blk_id, rsp_data_size, rsp_head->cur_blk_size, *max_dfx_size); -+ cur_blk_size = rsp_head->cur_blk_size; -+ if (rsp_data_size - sizeof(dfx_rsp->rsp_head) < cur_blk_size || -+ *max_dfx_size < cur_blk_size || cur_blk_size > sizeof(dfx_rsp->reg_data)) { -+ HIKP_ERROR_PRINT("blk%u reg_data copy size error, rsp data size: %u, " -+ "data size: %hhu, max size: %u\n", -+ blk_id, rsp_data_size, cur_blk_size, *max_dfx_size); - ret = -EINVAL; - goto err_out; - } -- memcpy(reg_data, dfx_rsp->reg_data, rsp_head->cur_blk_size); -- *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; -+ memcpy(reg_data, dfx_rsp->reg_data, cur_blk_size); -+ *max_dfx_size -= (uint32_t)cur_blk_size; - - err_out: - hikp_cmd_free(&cmd_ret); -diff --git a/net/ub/ub_ppp/hikp_unic_ppp.c b/net/ub/ub_ppp/hikp_unic_ppp.c -index 4c48e70..5f48ee6 100644 ---- a/net/ub/ub_ppp/hikp_unic_ppp.c -+++ b/net/ub/ub_ppp/hikp_unic_ppp.c -@@ -90,6 +90,7 @@ static int hikp_unic_ppp_get_blk(struct hikp_cmd_header *req_header, - struct hikp_cmd_ret *cmd_ret; - struct unic_ppp_rsp *rsp; - uint32_t rsp_data_size; -+ uint8_t cur_blk_size; - int ret = 0; - - cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data)); -@@ -100,14 +101,16 @@ static int hikp_unic_ppp_get_blk(struct hikp_cmd_header *req_header, - - rsp = (struct unic_ppp_rsp *)cmd_ret->rsp_data; - rsp_data_size = cmd_ret->rsp_data_num * REP_DATA_BLK_SIZE; -- if (rsp_data_size - sizeof(rsp->rsp_head) < rsp->rsp_head.cur_blk_size || -- buf_len < rsp->rsp_head.cur_blk_size) { -- HIKP_ERROR_PRINT("block context copy size error, data size: %u, buffer size: %zu, blk size: %hhu.\n", -- rsp_data_size, buf_len, rsp->rsp_head.cur_blk_size); -+ cur_blk_size = rsp->rsp_head.cur_blk_size; -+ if (rsp_data_size - sizeof(rsp->rsp_head) < cur_blk_size || -+ buf_len < cur_blk_size || cur_blk_size > sizeof(rsp->rsp_data)) { -+ HIKP_ERROR_PRINT("block context copy size error, data size: %u, " -+ "buffer size: %zu, blk size: %hhu.\n", -+ rsp_data_size, buf_len, cur_blk_size); - ret = -EINVAL; - goto out; - } -- memcpy(buf, rsp->rsp_data, rsp->rsp_head.cur_blk_size); -+ memcpy(buf, rsp->rsp_data, cur_blk_size); - memcpy(rsp_head, &rsp->rsp_head, sizeof(struct unic_ppp_rsp_head)); - - out: -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index ba6641e..f7ec2b3 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -397,7 +397,12 @@ static int pcie_create_dumpreg_log_file(uint32_t port_id, uint32_t dump_level) - memset(dumpreg_log_file, 0, sizeof(dumpreg_log_file)); - (void)strncpy((char *)dumpreg_log_file, file_name, MAX_LOG_NAME_LEN + 1); - -- (void)remove((const char *)file_name); -+ if (access((const char *)file_name, F_OK) == 0) { -+ if (remove((const char *)file_name)) { -+ Err("remove %s failed, errno is %d\n", file_name, errno); -+ return -errno; -+ } -+ } - /* Add write permission to the file */ - fd_file = fopen(file_name, "w+"); - if (fd_file == NULL) { -diff --git a/tool_lib/tool_cmd.c b/tool_lib/tool_cmd.c -index db54f0f..409bb5d 100644 ---- a/tool_lib/tool_cmd.c -+++ b/tool_lib/tool_cmd.c -@@ -206,7 +206,15 @@ void command_parse_and_excute(const int argc, const char **argv) - snprintf(major_cmd->err_str, sizeof(major_cmd->err_str), "locking failed."); - goto PARSE_OUT; - } -- major_cmd->execute(major_cmd); -+ -+ if (major_cmd->execute) { -+ major_cmd->execute(major_cmd); -+ } else { -+ major_cmd->err_no = -EPERM; -+ snprintf(major_cmd->err_str, sizeof(major_cmd->err_str), -+ "Command execute is null."); -+ } -+ - tool_unlock(&lock_fd, UDA_FLOCK_BLOCK); - PARSE_OUT: - if (major_cmd->err_no) --- -2.45.0.windows.1 - diff --git a/0102-hikptool-Add-more-RoCE-registers-for-diagnosis.patch b/0102-hikptool-Add-more-RoCE-registers-for-diagnosis.patch deleted file mode 100644 index 3c426de3113e492e8445a145ecbd03848518e889..0000000000000000000000000000000000000000 --- a/0102-hikptool-Add-more-RoCE-registers-for-diagnosis.patch +++ /dev/null @@ -1,78 +0,0 @@ -From fc70fc5b4e5c5d3dda0e1c7926af46b815309d99 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Thu, 12 Jun 2025 21:37:47 +0800 -Subject: [PATCH] hikptool: Add more RoCE registers for diagnosis - -Add more RoCE registers for diagnosis. - -Signed-off-by: Junxian Huang ---- - net/roce/roce_pkt/hikp_roce_pkt.c | 3 +++ - net/roce/roce_scc/hikp_roce_scc.c | 1 + - net/roce/roce_timer/hikp_roce_timer.c | 8 ++++++++ - net/roce/roce_tsp/hikp_roce_tsp.c | 4 ++++ - 4 files changed, 16 insertions(+) - -diff --git a/net/roce/roce_pkt/hikp_roce_pkt.c b/net/roce/roce_pkt/hikp_roce_pkt.c -index 1538788..4d1a377 100644 ---- a/net/roce/roce_pkt/hikp_roce_pkt.c -+++ b/net/roce/roce_pkt/hikp_roce_pkt.c -@@ -90,6 +90,9 @@ static const char *g_pkt_reg_name[] = { - "ROCEE_CNP_PKT_TX_CNT", - "TRP_GET_MPT_ERR_PKT_CNT", - "TRP_GET_IRRL_ERR_PKT_CNT", -+ "GEN_AC_CQ_CQE_CNT", -+ "GEN_AC_CQ_POE_CNT", -+ "GEN_AC_CQ_NOTIFY_CNT", - }; - - static void hikp_roce_pkt_print(uint32_t total_block_num, -diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c -index d7aaaa8..428beda 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.c -+++ b/net/roce/roce_scc/hikp_roce_scc.c -@@ -265,6 +265,7 @@ static const char *g_scc_common_reg_name[] = { - "SCC_INPUT_REQ_CNT", - "SCC_OUTPUT_RSP_CNT", - "SCC_INOUT_CNT_CFG", -+ "SCC_CUR_PROCESS_TIME", - }; - - static const char *g_scc_dcqcn_reg_name[] = { -diff --git a/net/roce/roce_timer/hikp_roce_timer.c b/net/roce/roce_timer/hikp_roce_timer.c -index 927d8a6..38b63ac 100644 ---- a/net/roce/roce_timer/hikp_roce_timer.c -+++ b/net/roce/roce_timer/hikp_roce_timer.c -@@ -69,6 +69,14 @@ static const char *g_timer_qpc_reg_name[] = { - "ROCEE_TIMER_QPC_ECC_ERR", - "ROCEE_TIMER_QPC_ECC_ERR_INFO", - "START_TYPE_ERR_CNT", -+ "FIFO_CNT_TH0", -+ "FIFO_CNT_TH1", -+ "FIFO_CNT_TH2", -+ "FIFO_CNT_TH3", -+ "FIFO_CNT_TH4", -+ "FIFO_CNT_TH5", -+ "FIFO_CNT_TH6", -+ "FIFO_CNT_TH7", - }; - - static const char *g_timer_cqc_reg_name[] = { -diff --git a/net/roce/roce_tsp/hikp_roce_tsp.c b/net/roce/roce_tsp/hikp_roce_tsp.c -index 5fe2104..671288d 100644 ---- a/net/roce/roce_tsp/hikp_roce_tsp.c -+++ b/net/roce/roce_tsp/hikp_roce_tsp.c -@@ -167,6 +167,10 @@ static const char *g_tsp_common_reg_name[] = { - "TSP_INDRECT_RD_CTRL", - "TSP_INDRECT_RD_DATA", - "ROCEE_TSP_OVF", -+ "ROCE_TPP_DATA_FIFO_ST", -+ "ROCE_TPP_DATA_ALM", -+ "ROCE_TPP_DATA_STA0", -+ "ROCE_TPP_DATA_STA1", - }; - - static const char *g_tsp_tdp_reg_name[] = { --- -2.45.0.windows.1 - diff --git a/0103-hikptool-roce-Support-to-print-u64-reg_data.patch b/0103-hikptool-roce-Support-to-print-u64-reg_data.patch deleted file mode 100644 index 0c0ba73d729de80675b52be96912192b2144cc2d..0000000000000000000000000000000000000000 --- a/0103-hikptool-roce-Support-to-print-u64-reg_data.patch +++ /dev/null @@ -1,198 +0,0 @@ -From 2c29a135c0d23978e1c98d69b42924564aee1635 Mon Sep 17 00:00:00 2001 -From: wenglianfa -Date: Thu, 3 Jul 2025 17:25:08 +0800 -Subject: [PATCH 103/104] hikptool/roce: Support to print u64 reg_data - -Support to print u64 reg_data. - -Signed-off-by: wenglianfa ---- - .../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 - - 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/0104-hikptool-roce-Add-roce_dfx_sta-cmd-for-RoCE-DFX-stat.patch b/0104-hikptool-roce-Add-roce_dfx_sta-cmd-for-RoCE-DFX-stat.patch deleted file mode 100644 index ead99fe4a107b7d10244268b25a3e520f05439d5..0000000000000000000000000000000000000000 --- a/0104-hikptool-roce-Add-roce_dfx_sta-cmd-for-RoCE-DFX-stat.patch +++ /dev/null @@ -1,248 +0,0 @@ -From 3a0b96217951248fe8a0a85e99220b33bd93ee31 Mon Sep 17 00:00:00 2001 -From: wenglianfa -Date: Wed, 2 Jul 2025 11:46:15 +0800 -Subject: [PATCH 104/104] 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 ---- - 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 \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=", "device target, e.g. eth0"); -+ printf(" %s, %-25s %s\n", "-c", "--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/0105-hikptool-Fix-ASAN-compilation-warnings.patch b/0105-hikptool-Fix-ASAN-compilation-warnings.patch deleted file mode 100644 index b4a1b116106a1fd840806f26f37593bbcf389cdf..0000000000000000000000000000000000000000 --- a/0105-hikptool-Fix-ASAN-compilation-warnings.patch +++ /dev/null @@ -1,72 +0,0 @@ -From b5c30aa2248f8919d3da7fa5288cd6bd5b2bd606 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Mon, 28 Jul 2025 11:40:11 +0800 -Subject: [PATCH 1/3] hikptool: Fix ASAN compilation warnings - -Add a 64-bit alignment flag to ensure -the alignment of the data field segment. - -Signed-off-by: veega2022 ---- - libhikptdev/include/hikptdev_plug.h | 2 +- - net/nic/nic_fd/hikp_nic_fd.c | 10 +++++++++----- - 2 files changed, 8 insertions(+), 4 deletions(-) - -diff --git a/libhikptdev/include/hikptdev_plug.h b/libhikptdev/include/hikptdev_plug.h -index ba9931f..7dad632 100644 ---- a/libhikptdev/include/hikptdev_plug.h -+++ b/libhikptdev/include/hikptdev_plug.h -@@ -27,7 +27,7 @@ struct hikp_cmd_ret { - uint32_t status; - uint32_t version; - uint32_t rsp_data_num; -- uint32_t rsp_data[0]; -+ uint32_t rsp_data[0] __attribute__((aligned(__SIZEOF_LONG__))); - }; - - /* Module code */ -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index f581553..dd0a73a 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -247,6 +247,7 @@ static void hikp_nic_print_tuple(const struct key_info *tuple_key, - #define HIKP_NIC_FD_TUPLE_KEY_LEN_6_BYTES 6 - #define HIKP_NIC_FD_TUPLE_KEY_LEN_4_BYTES 4 - #define HIKP_NIC_FD_TUN_VNI_LEN 3 -+ uint32_t temp_value = 0; - uint32_t tun_vni = 0; - uint64_t mask = 0; - uint8_t i; -@@ -271,7 +272,8 @@ static void hikp_nic_print_tuple(const struct key_info *tuple_key, - case OUTER_ETH_TYPE: - case INNER_ETH_TYPE: - printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask); -- printf("0x%x\n", *(uint16_t *)tcam_y); -+ memcpy(&temp_value, tcam_y, sizeof(uint16_t)); -+ printf("0x%x\n", temp_value); - break; - case OUTER_VLAN_TAG_FST: - case OUTER_VLAN_TAG_SEC: -@@ -286,7 +288,8 @@ static void hikp_nic_print_tuple(const struct key_info *tuple_key, - case INNER_SRC_PORT: - case INNER_DST_PORT: - printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask); -- printf("%u\n", *(uint16_t *)tcam_y); -+ memcpy(&temp_value, tcam_y, sizeof(uint16_t)); -+ printf("%u\n", temp_value); - break; - case OUTER_IP_TOS: - case INNER_IP_TOS: -@@ -306,7 +309,8 @@ static void hikp_nic_print_tuple(const struct key_info *tuple_key, - case OUTER_L4_RSV: - case INNER_L4_RSV: - printf("\t %s[mask=0x%" PRIx64 "]: ", tuple_key->key_name, mask); -- printf("%u\n", *(uint32_t *)tcam_y); -+ memcpy(&temp_value, tcam_y, sizeof(uint32_t)); -+ printf("%u\n", temp_value); - break; - case OUTER_TUN_VNI: - for (i = 0; i < HIKP_NIC_FD_TUN_VNI_LEN; i++) --- -2.45.0.windows.1 - diff --git a/0106-hikptool-Add-serdes-module-submodule-dump-types.patch b/0106-hikptool-Add-serdes-module-submodule-dump-types.patch deleted file mode 100644 index 6e9a70572ac9dcd01a9a649f4e113ef612bc11d0..0000000000000000000000000000000000000000 --- a/0106-hikptool-Add-serdes-module-submodule-dump-types.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 0d82e543f2fcf08c5a6b90a27af8d00f44e830db Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Mon, 28 Jul 2025 11:45:28 +0800 -Subject: [PATCH 2/3] hikptool: Add serdes module submodule dump types - -Add serdes module submodule dump types, -including CS and DS types. - -Signed-off-by: wujinzi ---- - serdes/hikp_serdes.c | 3 ++- - serdes/hikp_serdes.h | 5 +++++ - 2 files changed, 7 insertions(+), 1 deletion(-) - -diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c -index 01776df..f07f1b6 100644 ---- a/serdes/hikp_serdes.c -+++ b/serdes/hikp_serdes.c -@@ -401,7 +401,8 @@ static int cmd_serdes_dump_help(struct major_cmd_ctrl *self, const char *argv) - - static int cmd_serdes_dump_subcmds(struct major_cmd_ctrl *self, const char *argv) - { -- const char *set_cmds[HILINK_DUMP_TYPE_END] = { "cs", "ds", "csds", "ram", "subctrl"}; -+ const char *set_cmds[HILINK_DUMP_TYPE_END] = { "cs", "ds", "csds", "ram", "subctrl", -+ "cs1", "cs2", "ds1", "ds2", "ds3"}; - uint8_t i; - - for (i = 0; i < HILINK_DUMP_TYPE_END; i++) { -diff --git a/serdes/hikp_serdes.h b/serdes/hikp_serdes.h -index 4ea969d..59aea69 100644 ---- a/serdes/hikp_serdes.h -+++ b/serdes/hikp_serdes.h -@@ -76,6 +76,11 @@ enum hilink_dump_type_e { - HILINK_SERDES_REG_CSDS, - HILINK_SERDES_REG_RAM, - HILINK_SUBCTRL_REG, -+ HILINK_SERDES_REG_CS_PART1 = 5, -+ HILINK_SERDES_REG_CS_PART2, -+ HILINK_SERDES_REG_DS_PART1, -+ HILINK_SERDES_REG_DS_PART2, -+ HILINK_SERDES_REG_DS_PART3, - HILINK_DUMP_TYPE_END - }; - --- -2.45.0.windows.1 - diff --git a/0107-hikptool-Optimize-the-ROCE-SCC-module-register-dump-.patch b/0107-hikptool-Optimize-the-ROCE-SCC-module-register-dump-.patch deleted file mode 100644 index 37c68212c39a29c800fe82b9c2ffbcba29af8da1..0000000000000000000000000000000000000000 --- a/0107-hikptool-Optimize-the-ROCE-SCC-module-register-dump-.patch +++ /dev/null @@ -1,194 +0,0 @@ -From a638d6fd56936237374349ad4050a0d9b6ea0226 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Mon, 28 Jul 2025 12:02:55 +0800 -Subject: [PATCH 3/3] hikptool: Optimize the ROCE SCC module register dump - display - -Add ROCE_SCC CFG option command parsing display. -ROCE_SCC common option adds 2 register dumps. - -Signed-off-by: veega2022 ---- - info_collect/hikp_collect_roce.c | 3 +- - net/roce/roce_scc/hikp_roce_scc.c | 60 +++++++++++++++++++++++++++++++ - net/roce/roce_scc/hikp_roce_scc.h | 15 ++++++++ - 3 files changed, 77 insertions(+), 1 deletion(-) - -diff --git a/info_collect/hikp_collect_roce.c b/info_collect/hikp_collect_roce.c -index 01d773b..8b2215a 100644 ---- a/info_collect/hikp_collect_roce.c -+++ b/info_collect/hikp_collect_roce.c -@@ -180,8 +180,9 @@ static int collect_hikp_roce_scc_log(void *nic_name) - hikp_roce_set_scc_submodule(LDCP); - hikp_roce_scc_execute(&self); - -- printf("hikptool roce_scc -i %s -m CFG\n", (char *)nic_name); -+ printf("hikptool roce_scc -i %s -m CFG -v\n", (char *)nic_name); - hikp_roce_set_scc_submodule(CFG); -+ hikp_roce_set_scc_verbose_en(0x1); - hikp_roce_scc_execute(&self); - - return 0; -diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c -index 428beda..b03ba07 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.c -+++ b/net/roce/roce_scc/hikp_roce_scc.c -@@ -34,6 +34,11 @@ void hikp_roce_set_scc_submodule(uint32_t module) - g_roce_scc_param_t.sub_cmd = module; - } - -+void hikp_roce_set_scc_verbose_en(uint8_t verbose_en) -+{ -+ g_roce_scc_param_t.verbose_flag = verbose_en; -+} -+ - static int hikp_roce_scc_help(struct major_cmd_ctrl *self, const char *argv) - { - HIKP_SET_USED(argv); -@@ -47,6 +52,8 @@ static int hikp_roce_scc_help(struct major_cmd_ctrl *self, const char *argv) - "COMMON/DCQCN/DIP/HC3/LDCP/CFG"); - printf(" %s, %-25s %s\n", "-c", "--clear=", - "[Only Work for COMMON]clear param count registers"); -+ printf(" %s, %-25s %s\n", "-v", "--verbose=", -+ "[Only Work for CFG]see more information"); - printf("\n"); - - return 0; -@@ -92,6 +99,23 @@ static int hikp_roce_scc_clear_set(struct major_cmd_ctrl *self, const char *argv - return 0; - } - -+static int hikp_roce_scc_verbose_set(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(argv); -+ -+ /* Currently, only the cfg subcommand is supported for parsing. */ -+ self->err_no = (g_roce_scc_param_t.sub_cmd == CFG) ? 0 : -EINVAL; -+ if (self->err_no) { -+ snprintf(self->err_str, sizeof(self->err_str), -+ "only the cfg subcommand is supported for parsing."); -+ return -EINVAL; -+ } -+ -+ hikp_roce_set_scc_verbose_en(0x1); -+ -+ return 0; -+} -+ - static int hikp_roce_scc_clear_module_check(void) - { - if (g_roce_scc_param_t.sub_cmd == SCC_COMMON) -@@ -266,6 +290,8 @@ static const char *g_scc_common_reg_name[] = { - "SCC_OUTPUT_RSP_CNT", - "SCC_INOUT_CNT_CFG", - "SCC_CUR_PROCESS_TIME", -+ "SCC_AVE_PROCESS_TOTAL_TIME", -+ "SCC_AVE_PROCESS_TOTAL_CNT", - }; - - static const char *g_scc_dcqcn_reg_name[] = { -@@ -319,9 +345,35 @@ static const struct reg_name_info { - {CFG, g_scc_cfg_reg_name, HIKP_ARRAY_SIZE(g_scc_cfg_reg_name)}, - }; - -+struct roce_scc_parse_info { -+ char *field_offset; -+ uint32_t mask_offset; -+ uint32_t shift_offset; -+} g_scc_parse_info[] = { -+ {"ROCEE_SCC_SCH_EN", ROCEE_SCC_SCH_EN_MASK, ROCEE_SCC_SCH_EN_SHIFT}, -+ {"ROCEE_TM_SCH_EN", ROCEE_TM_SCH_EN_MASK, ROCEE_TM_SCH_EN_SHIFT}, -+ {"ROCEE_SCH_UNIT_VALUE", ROCEE_SCH_UNIT_VALUE_MASK, ROCEE_SCH_UNIT_VALUE_SHIFT}, -+ {"ROCEE_SCC_WL_CFG", ROCEE_SCC_WL_CFG_MASK, ROCEE_SCC_WL_CFG_SHIFT}, -+ {"ROCEE_SCC_TOKEN_VALUE", ROCEE_SCC_TOKEN_VALUE_MASK, ROCEE_SCC_TOKEN_VALUE_SHIFT}, -+}; -+ -+static void hikp_roce_scc_parse(const uint32_t *reg_arr, uint8_t reg_len, uint32_t *parse_data, -+ uint8_t parse_data_len) -+{ -+ uint32_t parse_id = 0; -+ uint8_t reg_id; -+ -+ for (reg_id = 0; reg_id < reg_len; reg_id++) -+ for (; parse_id < parse_data_len; parse_id++) -+ parse_data[parse_id] = -+ (reg_arr[reg_id] & g_scc_parse_info[parse_id].mask_offset) >> -+ g_scc_parse_info[parse_id].shift_offset; -+} -+ - static void hikp_roce_scc_print(uint8_t total_block_num, - const uint32_t *offset, const uint32_t *data) - { -+ uint32_t parse_data[MAX_PARSE_NUM] = {0}; - const char **reg_name; - uint8_t arr_len; - uint32_t i; -@@ -346,6 +398,13 @@ static void hikp_roce_scc_print(uint8_t total_block_num, - printf("%-40s[0x%08X] : 0x%08X\n", - i < arr_len ? reg_name[i] : "", - offset[i], data[i]); -+ -+ if (g_roce_scc_param_t.verbose_flag) { -+ hikp_roce_scc_parse(data, total_block_num, parse_data, MAX_PARSE_NUM); -+ for (i = 0; i < MAX_PARSE_NUM; i++) -+ printf("%-40s : 0x%08X\n", -+ g_scc_parse_info[i].field_offset, parse_data[i]); -+ } - printf("***********************************\n"); - } - -@@ -413,6 +472,7 @@ static void cmd_roce_scc_init(void) - cmd_option_register("-i", "--interface", true, hikp_roce_scc_target); - cmd_option_register("-m", "--module", true, hikp_roce_scc_module_select); - cmd_option_register("-c", "--clear", false, hikp_roce_scc_clear_set); -+ cmd_option_register("-v", "--verbose", false, hikp_roce_scc_verbose_set); - } - - HIKP_CMD_DECLARE("roce_scc", "get or clear roce_scc registers information", cmd_roce_scc_init); -diff --git a/net/roce/roce_scc/hikp_roce_scc.h b/net/roce/roce_scc/hikp_roce_scc.h -index b86b59a..8e56146 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.h -+++ b/net/roce/roce_scc/hikp_roce_scc.h -@@ -23,6 +23,18 @@ - #x, x \ - } - -+#define MAX_PARSE_NUM 5 -+#define ROCEE_SCC_SCH_EN_MASK GENMASK(24, 24) -+#define ROCEE_TM_SCH_EN_MASK GENMASK(23, 23) -+#define ROCEE_SCH_UNIT_VALUE_MASK GENMASK(22, 16) -+#define ROCEE_SCC_WL_CFG_MASK GENMASK(15, 12) -+#define ROCEE_SCC_TOKEN_VALUE_MASK GENMASK(11, 8) -+#define ROCEE_SCC_SCH_EN_SHIFT 24 -+#define ROCEE_TM_SCH_EN_SHIFT 23 -+#define ROCEE_SCH_UNIT_VALUE_SHIFT 16 -+#define ROCEE_SCC_WL_CFG_SHIFT 12 -+#define ROCEE_SCC_TOKEN_VALUE_SHIFT 8 -+ - struct roce_scc_req_param { - struct bdf_t bdf; - uint8_t reset_flag; -@@ -33,6 +45,7 @@ struct cmd_roce_scc_param_t { - struct tool_target target; - uint8_t reset_flag; - uint32_t sub_cmd; -+ uint8_t verbose_flag; - }; - - struct roce_scc_head { -@@ -64,10 +77,12 @@ enum roce_scc_type { - HC3, - LDCP, - CFG, -+ VERBOSE, - }; - - int hikp_roce_set_scc_bdf(char *nic_name); - void hikp_roce_set_scc_submodule(uint32_t module); - void hikp_roce_scc_execute(struct major_cmd_ctrl *self); -+void hikp_roce_set_scc_verbose_en(uint8_t verbose_en); - - #endif /* HIKP_ROCE_SCC_H */ --- -2.45.0.windows.1 - diff --git a/0108-hikptool-solve-some-code-review-comments.patch b/0108-hikptool-solve-some-code-review-comments.patch deleted file mode 100644 index 70c0a82ce1b0b4d192387f51be96125a6fab8b13..0000000000000000000000000000000000000000 --- a/0108-hikptool-solve-some-code-review-comments.patch +++ /dev/null @@ -1,881 +0,0 @@ -From 8f79cb062d73d3926c202ef0405aba10a0238609 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Tue, 26 Aug 2025 19:15:14 +0800 -Subject: [PATCH] hikptool: solve some code review comments - -Code review comments include: -1. Spelling errors in words -2. Unreasonable buffer validation -3. Insufficiently clear print information for exception branches -4. No validation of function return values -5. Optimization of large functions - -Signed-off-by: veega2022 ---- - CMakeLists.txt | 4 +- - hccs/hikp_hccs.c | 26 ++- - info_collect/hikp_collect_serdes.c | 2 +- - libhikptdev/src/rciep/hikpt_rciep.c | 5 +- - net/hikp_net_lib.c | 2 +- - net/nic/nic_fd/hikp_nic_fd.c | 18 +- - net/nic/nic_fd/hikp_nic_fd.h | 2 +- - net/nic/nic_info/hikp_nic_info.c | 2 +- - net/nic/nic_log/hikp_nic_log.c | 2 +- - net/nic/nic_ppp/hikp_nic_ppp.c | 10 +- - net/nic/nic_ppp/hikp_nic_ppp.h | 4 +- - net/nic/nic_torus/hikp_nic_torus.c | 2 +- - .../roce_ext_common/hikp_roce_ext_common.c | 162 +++++++++++------- - net/roce/roce_scc/hikp_roce_scc.c | 2 +- - net/roce/roce_scc/hikp_roce_scc.h | 1 - - net/roce/roce_trp/hikp_roce_trp.c | 2 +- - net/roh/hikp_roh_mac.c | 6 +- - pcie/func_lib/pcie_func/pcie_reg_dump.c | 5 +- - pcie/func_lib/pcie_func/pcie_reg_read.c | 2 +- - pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c | 2 +- - sas/user_cmd/cmd_code/sas_cmd_anacq.c | 4 +- - sas/user_cmd/cmd_code/sas_cmd_anadq.c | 4 +- - sas/user_cmd/cmd_code/sas_cmd_dev.c | 2 +- - sas/user_cmd/cmd_code/sas_cmd_dqe.c | 2 +- - serdes/hikp_serdes.c | 28 ++- - socip/hikp_socip_dumpreg.c | 6 +- - tool_lib/tool_lib.c | 8 +- - 27 files changed, 178 insertions(+), 137 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 386cc28..86053a1 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -9,6 +9,8 @@ - # - # See the Mulan PSL v2 for more details. - -+cmake_minimum_required(VERSION 3.0.0) -+ - project(hikptool C) - - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \ -@@ -61,7 +63,7 @@ target_include_directories(hikptool PRIVATE ${HIKPTOOL_HEADER_DIR}) - target_link_directories(hikptool PRIVATE ${CMAKE_INSTALL_PREFIX}/lib) - target_link_libraries(hikptool PRIVATE KPTDEV_SO) - if (ENABLE_STATIC) -- # I don¡¯t know why, but once you add double quotes to these -+ # I don't know why, but once you add double quotes to these - # link parameters, an error will be reported. - set(EXT_LINK_FLAGS -static-libgcc -static-libstdc++ -static) - set_target_properties(hikptool PROPERTIES LINK_SEARCH_START_STATIC ON) -diff --git a/hccs/hikp_hccs.c b/hccs/hikp_hccs.c -index d979aad..f6ef003 100644 ---- a/hccs/hikp_hccs.c -+++ b/hccs/hikp_hccs.c -@@ -11,6 +11,7 @@ - * See the Mulan PSL v2 for more details. - */ - -+#include - #include - #include - #include -@@ -613,39 +614,32 @@ static void hikp_hccs_show_port_dfx_info(union hccs_feature_info *feature_info) - size_t vld_size; - - vld_size = (size_t)info_vld->vld_size; -- if (vld_size >= sizeof(info->link_fsm)) { -+ if (vld_size > offsetof(struct hccs_port_dfx_info, link_fsm)) { - printf("%-16s\t%s\n", "link_fsm", hikp_hccs_link_fsm_to_str(info->link_fsm)); -- vld_size -= sizeof(info->link_fsm); - } - -- if (vld_size >= sizeof(info->cur_lane_num)) { -+ if (vld_size > offsetof(struct hccs_port_dfx_info, cur_lane_num)) { - printf("%-16s\t%u\n", "cur_lane_num", info->cur_lane_num); -- vld_size -= sizeof(info->cur_lane_num); - } - -- if (vld_size >= sizeof(info->lane_mask)) { -+ if (vld_size > offsetof(struct hccs_port_dfx_info, lane_mask)) { - printf("%-16s\t0x%x\n", "lane_mask", info->lane_mask); -- vld_size -= sizeof(info->lane_mask); - } - -- if (vld_size >= sizeof(info->crc_err_cnt)) { -+ if (vld_size > offsetof(struct hccs_port_dfx_info, crc_err_cnt)) { - printf("%-16s\t%u\n", "crc_err_cnt", info->crc_err_cnt); -- vld_size -= sizeof(info->crc_err_cnt); - } - -- if (vld_size >= sizeof(info->retry_cnt)) { -+ if (vld_size > offsetof(struct hccs_port_dfx_info, retry_cnt)) { - printf("%-16s\t%u\n", "retry_cnt", info->retry_cnt); -- vld_size -= sizeof(info->retry_cnt); - } - -- if (vld_size >= sizeof(info->phy_reinit_cnt)) { -+ if (vld_size > offsetof(struct hccs_port_dfx_info, phy_reinit_cnt)) { - printf("%-16s\t%u\n", "phy_reinit_cnt", info->phy_reinit_cnt); -- vld_size -= sizeof(info->phy_reinit_cnt); - } - -- if (vld_size >= sizeof(info->tx_credit)) { -+ if (vld_size > offsetof(struct hccs_port_dfx_info, tx_credit)) { - printf("%-16s\t%u\n", "tx_credit", info->tx_credit); -- vld_size -= sizeof(info->tx_credit); - } - } - -@@ -748,7 +742,7 @@ static int hikp_hccs_cmd_parse_die(struct major_cmd_ctrl *self, const char *argv - self->err_no = string_toui(argv, &die_id); - if (self->err_no) { - snprintf(self->err_str, sizeof(self->err_str), -- "Failed to parse -d/--die_id parameter."); -+ "Failed to parse -d/--die_id parameter."); - return self->err_no; - } - -@@ -778,7 +772,7 @@ static int hikp_hccs_cmd_parse_port(struct major_cmd_ctrl *self, const char *arg - - if (port_id > UINT8_MAX) { - snprintf(self->err_str, sizeof(self->err_str), -- "port id should not be greater %u.", UINT8_MAX); -+ "port id should not be greater than %u.", UINT8_MAX); - self->err_no = -EINVAL; - return self->err_no; - } -diff --git a/info_collect/hikp_collect_serdes.c b/info_collect/hikp_collect_serdes.c -index 31f29b3..ff58629 100644 ---- a/info_collect/hikp_collect_serdes.c -+++ b/info_collect/hikp_collect_serdes.c -@@ -210,7 +210,7 @@ static void collect_serdes_dump_log(void) - log_cmd.die_id = j; - ret = snprintf(log_name, MAX_LOG_NAME_LEN, "serdes_dump_c%ud%u", i, j); - if (ret < 0 || (uint32_t)(ret) >= MAX_LOG_NAME_LEN) { -- HIKP_ERROR_PRINT("create serdes_info log name failed\n"); -+ HIKP_ERROR_PRINT("create serdes_dump log name failed\n"); - break; - } - ret = hikp_collect_log(GROUP_SERDES, log_name, -diff --git a/libhikptdev/src/rciep/hikpt_rciep.c b/libhikptdev/src/rciep/hikpt_rciep.c -index 88ac16e..5cdf258 100644 ---- a/libhikptdev/src/rciep/hikpt_rciep.c -+++ b/libhikptdev/src/rciep/hikpt_rciep.c -@@ -73,7 +73,8 @@ static int hikp_try_lock(void) - count--; - usleep(LOCK_CHECK_GAP_US); - } while (count); -- printf("dev lock by other process:%u.\n", g_hikp_req->field.pid_record); -+ printf("try to lock failed, lock may be occupied by another process: %u, error: %s\n", -+ g_hikp_req->field.pid_record, strerror(errno)); - - return -EBUSY; - } -@@ -187,7 +188,7 @@ static int hikp_req_first_round(uint32_t *req_data, uint32_t rep_num, uint32_t * - req_issue(); /* On the first round, an interrupt is triggered. */ - *cpl_status = hikp_wait_for_cpl_status(); - if (*cpl_status != HIKP_CPL_BY_TF && *cpl_status != HIKP_CPL_BY_IMU) { -- printf("First round failed. Error code:%u.\n", *cpl_status); -+ printf("First round failed. Error code:0x%X.\n", *cpl_status); - return RCIEP_FAIL; - } - -diff --git a/net/hikp_net_lib.c b/net/hikp_net_lib.c -index 7646aad..91c00d9 100644 ---- a/net/hikp_net_lib.c -+++ b/net/hikp_net_lib.c -@@ -97,7 +97,7 @@ static bool check_and_parse_domain_bdf_id(const char *bus_info, struct bdf_t *bd - if (strlen(bus_info) >= IFNAMSIZ) - return false; - -- /* pci_id: 0000:bd:00.0 ==> doman:bus:device.function add -+ /* pci_id: 0000:bd:00.0 ==> domain:bus:device.function add - * remains here to solve such input: 0000:bd:00.0abcdef - */ - retval = sscanf(bus_info, "%x:%x:%x.%u%s", &domain, &bus, &dev, &fun, remains); -diff --git a/net/nic/nic_fd/hikp_nic_fd.c b/net/nic/nic_fd/hikp_nic_fd.c -index 891368a..8a2bfb3 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.c -+++ b/net/nic/nic_fd/hikp_nic_fd.c -@@ -26,7 +26,7 @@ struct key_info { - - static const struct key_info g_meta_data_key_info[] = { - {"packet_type_id", PACKET_TYPE_ID, 6}, -- {"fragement", IP_FRAGEMENT, 1}, -+ {"fragment", IP_FRAGMENT, 1}, - {"roce_type", ROCE_TYPE, 1}, - {"next_key", NEXT_KEY, 5}, - {"vlan_num", VLAN_NUMBER, 2}, -@@ -169,7 +169,7 @@ static void hikp_nic_show_fd_key_info(struct nic_fd_hw_info *hw_info) - printf(" outer_dest_ipv6_word_en: 0x%x\n", key_cfg->outer_dest_ipv6_word_en); - - if (key_cfg->key_select == HNS3_FD_KEY_BASE_ON_PTYPE) { -- HIKP_WARN_PRINT("Unsupport for parsing packet type key.\n"); -+ HIKP_WARN_PRINT("Unsupported for parsing packet type key.\n"); - continue; - } - -@@ -333,7 +333,7 @@ static void hikp_nic_print_meta_data(uint16_t type, uint32_t val) - case NEXT_KEY: - printf("%u", val); - break; -- case IP_FRAGEMENT: -+ case IP_FRAGMENT: - printf("%s", val == 0 ? "NON-IP frag packet" : "IP frag packet"); - break; - case ROCE_TYPE: -@@ -676,14 +676,14 @@ static int hikp_nic_query_fd_rules(struct hikp_cmd_header *req_header, const str - } - if (rsp_head.cur_blk_entry_cnt + entry_cnt > g_fd_hw_info.alloc.stage_entry_num[stage]) { - HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " -- "is over the maximum entry nubmer (%u) of this stage.", -+ "is over the maximum entry number (%u) of this stage.", - rsp_head.cur_blk_entry_cnt + entry_cnt, idx, - g_fd_hw_info.alloc.stage_entry_num[stage]); - return -EINVAL; - } - entry_cnt += rsp_head.cur_blk_entry_cnt; - if (rsp_head.next_entry_idx <= idx) { -- HIKP_ERROR_PRINT("The next entry index (%u) is less than or equal with the curent(%u).\n", -+ HIKP_ERROR_PRINT("The next entry index (%u) is less than or equal with the current(%u).\n", - rsp_head.next_entry_idx, idx); - return -EINVAL; - } -@@ -735,14 +735,14 @@ static int hikp_nic_query_fd_counter(struct hikp_cmd_header *req_header, const s - } - if (rsp_head.cur_blk_entry_cnt + entry_size > g_fd_hw_info.alloc.stage_counter_num[stage]) { - HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " -- "is over the maximum counter nubmer (%u) of this stage.", -+ "is over the maximum counter number (%u) of this stage.", - rsp_head.cur_blk_entry_cnt + entry_size, idx, - g_fd_hw_info.alloc.stage_counter_num[stage]); - return -EINVAL; - } - entry_size += rsp_head.cur_blk_entry_cnt; - if (rsp_head.next_entry_idx <= idx) { -- HIKP_ERROR_PRINT("The next entry index (%u) is less than or equal with the curent(%u).\n", -+ HIKP_ERROR_PRINT("The next entry index (%u) is less than or equal with the current(%u).\n", - rsp_head.next_entry_idx, idx); - return -EINVAL; - } -@@ -856,7 +856,7 @@ static int hikp_nic_check_fd_hw_info(const struct nic_fd_hw_info *hw_info, - } - if (hw_info->mode > FD_MODE_DEPTH_2K_WIDTH_200B_STAGE_2) - HIKP_WARN_PRINT("Unknown fd mode(%u), " -- "unsupport for displaying meta data info.\n", -+ "unsupported for displaying meta data info.\n", - hw_info->mode); - - for (i = 0; i < NIC_FD_STAGE_NUM; i++) { -@@ -1080,7 +1080,7 @@ static int hikp_nic_cmd_fd_parse_stage(struct major_cmd_ctrl *self, const char * - - if (stage_no - 1 == NIC_FD_STAGE_2) { - snprintf(self->err_str, sizeof(self->err_str), -- "unsupport for querying stage%u entry!", stage_no); -+ "unsupported for querying stage%u entry!", stage_no); - self->err_no = -EOPNOTSUPP; - return self->err_no; - } -diff --git a/net/nic/nic_fd/hikp_nic_fd.h b/net/nic/nic_fd/hikp_nic_fd.h -index 98577ff..7b1331d 100644 ---- a/net/nic/nic_fd/hikp_nic_fd.h -+++ b/net/nic/nic_fd/hikp_nic_fd.h -@@ -56,7 +56,7 @@ enum nic_fd_tuple { - - enum nic_fd_meta_data { - PACKET_TYPE_ID = 0, -- IP_FRAGEMENT, -+ IP_FRAGMENT, - ROCE_TYPE, - NEXT_KEY, - VLAN_NUMBER, -diff --git a/net/nic/nic_info/hikp_nic_info.c b/net/nic/nic_info/hikp_nic_info.c -index b05d6ef..a1985a9 100644 ---- a/net/nic/nic_info/hikp_nic_info.c -+++ b/net/nic/nic_info/hikp_nic_info.c -@@ -249,7 +249,7 @@ static int hikp_nic_traverse_all_hns3_dev_and_get_info(void) - - sockfd = hikp_net_creat_sock(); - if (sockfd < MIN_SOCKFD) { -- HIKP_ERROR_PRINT("creat sockfd failed, sockfd is %d.\n", sockfd); -+ HIKP_ERROR_PRINT("create sockfd failed, sockfd is %d.\n", sockfd); - return -EIO; - } - ret = getifaddrs(&ifa_lst); -diff --git a/net/nic/nic_log/hikp_nic_log.c b/net/nic/nic_log/hikp_nic_log.c -index 4dd2721..d2af181 100644 ---- a/net/nic/nic_log/hikp_nic_log.c -+++ b/net/nic/nic_log/hikp_nic_log.c -@@ -64,7 +64,7 @@ static int hikp_nic_write_data_to_file(uint8_t *data, uint32_t len) - - rc = snprintf(g_log_path, sizeof(g_log_path), HIKP_LOG_DIR_PATH"%s", file_name); - if (rc < 0) { -- HIKP_ERROR_PRINT("creat log file path fail.\n"); -+ HIKP_ERROR_PRINT("create log file path fail.\n"); - return -EIO; - } - -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.c b/net/nic/nic_ppp/hikp_nic_ppp.c -index 43a9000..d5cf61f 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.c -+++ b/net/nic/nic_ppp/hikp_nic_ppp.c -@@ -555,7 +555,7 @@ static int hikp_nic_ppp_query_uc_mac_addr(struct hikp_cmd_header *req_header, - } - if (entry_size + rsp_head.cur_blk_entry_cnt > max_hw_entry_size) { - HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " -- "is over the maximum entry nubmer (%u) of unicast MAC table.\n", -+ "is over the maximum entry number (%u) of unicast MAC table.\n", - entry_size + rsp_head.cur_blk_entry_cnt, idx, max_hw_entry_size); - return -EINVAL; - } -@@ -597,7 +597,7 @@ static int hikp_nic_ppp_query_mc_mac_addr(struct hikp_cmd_header *req_header, - } - if (entry_size + rsp_head.cur_blk_entry_cnt > max_hw_entry_size) { - HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " -- "is over the maximum entry nubmer (%u) of multicast MAC table.\n", -+ "is over the maximum entry number (%u) of multicast MAC table.\n", - entry_size + rsp_head.cur_blk_entry_cnt, idx, max_hw_entry_size); - return -EINVAL; - } -@@ -668,7 +668,7 @@ static int hikp_nic_ppp_query_vf_vlan_tbl(struct hikp_cmd_header *req_header, - } - if (entry_size + rsp_head.cur_blk_entry_cnt > hw_entry_size) { - HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " -- "is over the maximum entry nubmer (%u) of VF VLAN table.\n", -+ "is over the maximum entry number (%u) of VF VLAN table.\n", - entry_size + rsp_head.cur_blk_entry_cnt, idx, hw_entry_size); - return -EINVAL; - } -@@ -709,7 +709,7 @@ static int hikp_nic_ppp_query_port_vlan_tbl(struct hikp_cmd_header *req_header, - } - if (entry_size + rsp_head.cur_blk_entry_cnt > hw_entry_size) { - HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " -- "is over the maximum entry nubmer (%u) of port VLAN table.\n", -+ "is over the maximum entry number (%u) of port VLAN table.\n", - entry_size + rsp_head.cur_blk_entry_cnt, idx, hw_entry_size); - return -EINVAL; - } -@@ -771,7 +771,7 @@ static int hikp_nic_query_mng_tbl(struct hikp_cmd_header *req_header, - } - if (entry_size + rsp_head.cur_blk_entry_cnt > g_ppp_hw_res.mng_tbl_size) { - HIKP_ERROR_PRINT("The sum of entry number (%u) after block-%u " -- "is over the maximum entry nubmer (%u) of manager table.\n", -+ "is over the maximum entry number (%u) of manager table.\n", - entry_size + rsp_head.cur_blk_entry_cnt, idx, g_ppp_hw_res.mng_tbl_size); - return -EINVAL; - } -diff --git a/net/nic/nic_ppp/hikp_nic_ppp.h b/net/nic/nic_ppp/hikp_nic_ppp.h -index 229e019..e2ee79b 100644 ---- a/net/nic/nic_ppp/hikp_nic_ppp.h -+++ b/net/nic/nic_ppp/hikp_nic_ppp.h -@@ -40,7 +40,7 @@ struct hikp_nic_ppp_hw_resources { - uint32_t rsv1[10]; - }; - --/* struct mac_vlan_uc_entry::e_vport field defination: -+/* struct mac_vlan_uc_entry::e_vport field definition: - * bit[0-2]: pf_id - * bit[3-10]: vf_id - */ -@@ -148,7 +148,7 @@ struct nic_mng_tbl { - struct func_vlan_offload_cfg { - uint16_t vlan_fe; - uint16_t pvid; -- uint8_t port_vlan_bypass; /* 0: off, 1: on, 2: unsupport port vlan */ -+ uint8_t port_vlan_bypass; /* 0: off, 1: on, 2: unsupported port vlan */ - uint8_t accept_tag1; - uint8_t accept_tag2; - uint8_t accept_untag1; -diff --git a/net/nic/nic_torus/hikp_nic_torus.c b/net/nic/nic_torus/hikp_nic_torus.c -index 7ad5211..ef8454f 100644 ---- a/net/nic/nic_torus/hikp_nic_torus.c -+++ b/net/nic/nic_torus/hikp_nic_torus.c -@@ -123,7 +123,7 @@ static void hikp_nic_torus_show(const struct nic_torus_info *info) - printf("ssu_pause_time_out_en: %u\n", info->pause_time_out_en); - printf("vlan_fe: 0x%x (for port vlan)\n", info->vlan_fe); - printf("ets_tcg0_mapping: 0x%x\n", info->ets_tcg0_mapping); -- printf("ets_tcg0_mapping is showed as 0xff if ncl_config forward bit is setted to 1\n"); -+ printf("ets_tcg0_mapping is showed as 0xff if ncl_config forward bit is set to 1\n"); - - hikp_nic_torus_switch_param_show(info); - -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 ac6c8fb..102a0dc 100644 ---- a/net/roce/roce_ext_common/hikp_roce_ext_common.c -+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c -@@ -83,6 +83,100 @@ static int get_cmd_reg_array_length(enum roce_cmd_type cmd_type) - return idx; - } - -+static int fill_output(struct hikp_cmd_ret *cmd_ret, -+ const char *cmd_name, -+ uint32_t block_id, -+ struct roce_ext_res_output *output) -+{ -+ struct roce_ext_res_param *roce_ext_res = (struct roce_ext_res_param *)cmd_ret->rsp_data; -+ struct roce_ext_head *res_head = &output->res_head; -+ struct reg_data *reg = &output->reg; -+ -+ res_head->cur_block_num = roce_ext_res->head.cur_block_num; -+ -+ if (block_id != 0) -+ return 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); -+ return -EINVAL; -+ } -+ -+ size_t per_val_size = res_head->flags & ROCE_HIKP_DATA_U64_FLAG ? -+ sizeof(uint64_t) : sizeof(uint32_t); -+ reg->offset = (uint32_t *)calloc(res_head->total_block_num, sizeof(uint32_t)); -+ output->per_val_size = per_val_size; -+ reg->data = calloc(res_head->total_block_num, per_val_size); -+ if (!reg->offset || !reg->data) { -+ printf("hikptool roce_%s alloc log memory failed!\n", cmd_name); -+ hikp_roce_ext_reg_data_free(reg); -+ return -ENOMEM; -+ } -+ -+ return 0; -+} -+ -+static int validate_block_numbers(const struct roce_ext_head *res_head, -+ const char *cmd_name, -+ uint32_t block_id) -+{ -+ uint32_t remain_block = res_head->total_block_num - block_id; -+ -+ if (!res_head->cur_block_num || res_head->cur_block_num > remain_block) { -+ printf("hikptool roce_%s block size error, cur: %u, total: %u, remain: %u.\n", -+ cmd_name, res_head->cur_block_num, -+ res_head->total_block_num, remain_block); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+static int copy_data_from_response(struct hikp_cmd_ret *cmd_ret, -+ struct roce_ext_res_output *output, -+ int reg_array_length, -+ const char *cmd_name, -+ uint32_t block_id) -+{ -+ struct roce_ext_res_param *roce_ext_res = (struct roce_ext_res_param *)cmd_ret->rsp_data; -+ struct roce_ext_head *res_head = &output->res_head; -+ struct reg_data *reg = &output->reg; -+ size_t reg_data_offset; -+ size_t offset_size; -+ size_t data_size; -+ void *dst_data; -+ -+ /* -+ * 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); -+ if ((reg_data_offset + data_size) / sizeof(uint32_t) + (size_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); -+ return -EINVAL; -+ } -+ -+ memcpy(reg->offset + block_id, -+ (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); -+ -+ return 0; -+} -+ - static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - uint32_t block_id, - struct roce_ext_res_output *output, -@@ -94,14 +188,8 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - struct roce_ext_reg_name *reg_name = &output->reg_name; - struct roce_ext_head *res_head = &output->res_head; - const char *cmd_name = get_cmd_name(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 offset_size; -- size_t data_size; -- void *dst_data; - int ret; - - /* reg_array_length greater than or equal to 0 ensures that cmd_name -@@ -116,67 +204,19 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type, - goto get_data_error; - } - -- roce_ext_res = (struct roce_ext_res_param *)cmd_ret->rsp_data; -- res_head->cur_block_num = roce_ext_res->head.cur_block_num; -- -- 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); -- ret = -EINVAL; -- goto get_data_error; -- } -- reg->offset = (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 failed!\n", -- cmd_name); -- ret = -ENOMEM; -- hikp_roce_ext_reg_data_free(reg); -- goto get_data_error; -- } -- } -+ ret = fill_output(cmd_ret, cmd_name, block_id, output); -+ if (ret) -+ goto get_data_error; - -- remain_block = res_head->total_block_num - block_id; -- if (!res_head->cur_block_num || res_head->cur_block_num > remain_block) { -- printf("hikptool roce_%s block size error, cur: %u, total: %u, remain: %u.\n", -- cmd_name, res_head->cur_block_num, -- res_head->total_block_num, remain_block); -- ret = -EINVAL; -+ ret = validate_block_numbers(res_head, cmd_name, block_id); -+ if (ret) { - hikp_roce_ext_reg_data_free(reg); - goto get_data_error; - } - -- /* -- * 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; -+ ret = copy_data_from_response(cmd_ret, output, reg_array_length, cmd_name, block_id); -+ if (ret) - hikp_roce_ext_reg_data_free(reg); -- goto get_data_error; -- } -- memcpy(reg->offset + block_id, -- (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); -diff --git a/net/roce/roce_scc/hikp_roce_scc.c b/net/roce/roce_scc/hikp_roce_scc.c -index b03ba07..9440180 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.c -+++ b/net/roce/roce_scc/hikp_roce_scc.c -@@ -187,7 +187,7 @@ static int hikp_roce_scc_get_total_data_num(struct roce_scc_head *res_head, - *offset = (uint32_t *)calloc(1, max_size); - *data = (uint32_t *)calloc(1, max_size); - if ((*offset == NULL) || (*data == NULL)) { -- printf("hikptool roce_scc alloc log memmory 0x%zx failed\n", max_size); -+ printf("hikptool roce_scc alloc log memory 0x%zx failed\n", max_size); - ret = -ENOMEM; - goto get_data_error; - } -diff --git a/net/roce/roce_scc/hikp_roce_scc.h b/net/roce/roce_scc/hikp_roce_scc.h -index 8e56146..f6f3ec4 100644 ---- a/net/roce/roce_scc/hikp_roce_scc.h -+++ b/net/roce/roce_scc/hikp_roce_scc.h -@@ -77,7 +77,6 @@ enum roce_scc_type { - HC3, - LDCP, - CFG, -- VERBOSE, - }; - - int hikp_roce_set_scc_bdf(char *nic_name); -diff --git a/net/roce/roce_trp/hikp_roce_trp.c b/net/roce/roce_trp/hikp_roce_trp.c -index 8b34409..2c52822 100644 ---- a/net/roce/roce_trp/hikp_roce_trp.c -+++ b/net/roce/roce_trp/hikp_roce_trp.c -@@ -185,7 +185,7 @@ static int hikp_roce_trp_get_total_data_num(struct roce_trp_head *res_head, - *offset = (uint32_t *)calloc(1, max_size); - *data = (uint32_t *)calloc(1, max_size); - if ((*offset == NULL) || (*data == NULL)) { -- printf("hikptool roce_trp alloc log memmory 0x%zx failed\n", max_size); -+ printf("hikptool roce_trp alloc log memory 0x%zx failed\n", max_size); - hikp_roce_trp_reg_data_free(offset, data); - ret = -ENOMEM; - goto get_data_error; -diff --git a/net/roh/hikp_roh_mac.c b/net/roh/hikp_roh_mac.c -index e16a3db..81334da 100644 ---- a/net/roh/hikp_roh_mac.c -+++ b/net/roh/hikp_roh_mac.c -@@ -162,16 +162,16 @@ static int hikp_roh_build_cam(struct major_cmd_ctrl *self, struct cam_table_entr - struct hikp_cmd_header req_header = { 0 }; - struct hikp_cmd_ret *cmd_ret = NULL; - int block_num; -+ int addition; - int reg_num; -- int addtion; - int index; - - reg_num = hikp_roh_get_cam_reg_num(self); - if (reg_num < 0) - return -EIO; - -- addtion = reg_num % RESPONSE_DATA_NUMBER_MAX ? 1 : 0; -- block_num = reg_num / RESPONSE_DATA_NUMBER_MAX + addtion; -+ addition = reg_num % RESPONSE_DATA_NUMBER_MAX ? 1 : 0; -+ block_num = reg_num / RESPONSE_DATA_NUMBER_MAX + addition; - - for (int i = 0; i < block_num; i++) { - req_data.bdf = g_roh_mac_param.target.bdf; -diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c -index f7ec2b3..c38d0e5 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_dump.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c -@@ -417,8 +417,9 @@ static int pcie_create_dumpreg_log_file(uint32_t port_id, uint32_t dump_level) - static void pcie_close_dumpreg_log_file(void) - { - fclose(g_pcie_dumpreg_fd); -- /* Revoke write permission of file */ -- chmod(dumpreg_log_file, 0400); -+ /* Set the file permission to 0400 */ -+ if (chmod(dumpreg_log_file, 0400)) -+ Err("chmod %s failed, errno is %d\n", dumpreg_log_file, errno); - g_pcie_dumpreg_fd = NULL; - } - -diff --git a/pcie/func_lib/pcie_func/pcie_reg_read.c b/pcie/func_lib/pcie_func/pcie_reg_read.c -index c04c3d9..619f8e8 100644 ---- a/pcie/func_lib/pcie_func/pcie_reg_read.c -+++ b/pcie/func_lib/pcie_func/pcie_reg_read.c -@@ -70,7 +70,7 @@ static int pcie_reg_read_result_show(const struct hikp_cmd_ret *cmd_ret) - cmd_ret->rsp_data_num); - return -EINVAL; - } -- Info("RIGISTER VALUE[0x%08x].\n", cmd_ret->rsp_data[0]); -+ Info("REGISTER VALUE[0x%08x].\n", cmd_ret->rsp_data[0]); - - return 0; - } -diff --git a/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c b/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c -index 7b0efde..d89f223 100644 ---- a/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c -+++ b/pcie/usr_cmd/cmd_analysis/pcie_cmd_trace.c -@@ -86,7 +86,7 @@ static int pcie_trace_mode_set(struct major_cmd_ctrl *self, const char *argv) - g_trace_cmd.cmd_type = TRACE_MODE; - ret = string_toui(argv, &val); - if (ret || val > 1) { -- printf("tarce mode set err %d\n", ret); -+ printf("trace mode set err %d\n", ret); - return -EINVAL; - } - g_trace_cmd.trace_mode_val = val; -diff --git a/sas/user_cmd/cmd_code/sas_cmd_anacq.c b/sas/user_cmd/cmd_code/sas_cmd_anacq.c -index bdaaa42..4d9a750 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_anacq.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_anacq.c -@@ -27,8 +27,8 @@ static int sas_anacq_help(struct major_cmd_ctrl *self, const char *argv) - printf(" %s, %-25s %s\n", "-d", "--dieid", "please input die id[x] first\n"); - printf("\n Options:\n\n"); - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); -- printf(" %s, %-25s %s\n", "-p", "--pointer", "dispaly cq queue read/write pointer\n"); -- printf(" %s, %-25s %s\n", "-s", "--number", "dispaly cq number\n"); -+ printf(" %s, %-25s %s\n", "-p", "--pointer", "display cq queue read/write pointer\n"); -+ printf(" %s, %-25s %s\n", "-s", "--number", "display cq number\n"); - printf("\n"); - - return 0; -diff --git a/sas/user_cmd/cmd_code/sas_cmd_anadq.c b/sas/user_cmd/cmd_code/sas_cmd_anadq.c -index bff2c71..176cfa3 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_anadq.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_anadq.c -@@ -27,8 +27,8 @@ static int sas_anadq_help(struct major_cmd_ctrl *self, const char *argv) - printf(" %s, %-25s %s\n", "-d", "--dieid", "please input die id[x] first\n"); - printf("\n Options:\n\n"); - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); -- printf(" %s, %-25s %s\n", "-p", "--pointer", "dispaly dq queue read/write pointer\n"); -- printf(" %s, %-25s %s\n", "-s", "--number", "dispaly dq number\n"); -+ printf(" %s, %-25s %s\n", "-p", "--pointer", "display dq queue read/write pointer\n"); -+ printf(" %s, %-25s %s\n", "-s", "--number", "display dq number\n"); - printf("\n"); - - return 0; -diff --git a/sas/user_cmd/cmd_code/sas_cmd_dev.c b/sas/user_cmd/cmd_code/sas_cmd_dev.c -index 879e764..06832ce 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_dev.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_dev.c -@@ -27,7 +27,7 @@ static int sas_dev_help(struct major_cmd_ctrl *self, const char *argv) - printf(" %s, %-25s %s\n", "-d", "--dieid", "please input die id[x] first\n"); - printf("\n Options:\n\n"); - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); -- printf(" %s, %-25s %s\n", "-l", "--link", "dispaly device type and speed\n"); -+ printf(" %s, %-25s %s\n", "-l", "--link", "display device type and speed\n"); - printf("\n"); - - return 0; -diff --git a/sas/user_cmd/cmd_code/sas_cmd_dqe.c b/sas/user_cmd/cmd_code/sas_cmd_dqe.c -index 5a85468..b914f54 100644 ---- a/sas/user_cmd/cmd_code/sas_cmd_dqe.c -+++ b/sas/user_cmd/cmd_code/sas_cmd_dqe.c -@@ -28,7 +28,7 @@ static int sas_dqe_help(struct major_cmd_ctrl *self, const char *argv) - printf(" %s, %-25s %s\n", "-q", "--queue", "please input queue id[x] first\n"); - printf("\n Options:\n\n"); - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); -- printf(" %s, %-25s %s\n", "-i", "--info", "dispaly the dqe detail information\n"); -+ printf(" %s, %-25s %s\n", "-i", "--info", "display the dqe detail information\n"); - printf("\n"); - - return 0; -diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c -index f07f1b6..39d46af 100644 ---- a/serdes/hikp_serdes.c -+++ b/serdes/hikp_serdes.c -@@ -130,7 +130,7 @@ static int cmd_serdes_key_info_pro(struct major_cmd_ctrl *self, const char *argv - - #define USEMODE_SSC_STR_MAXLEN 20 - static void hikp_serdes_brief_info_print(struct cmd_serdes_param *cmd, -- const struct hilink_brief_info *data, uint32_t data_size) -+ const struct hilink_brief_info *data) - { - uint8_t ds_id; - uint8_t start_sds_id = cmd->start_sds_id; -@@ -144,11 +144,6 @@ static void hikp_serdes_brief_info_print(struct cmd_serdes_param *cmd, - "nossc", "ssc", "mssc_in", "mssc_s", "mssc_n", "mssc_w", "mssc_e" - }; - -- if (data_size != sds_num) { -- printf("serdes brief info data size is wrong.\n"); -- return; -- } -- - for (ds_id = 0; ds_id < sds_num; ds_id++) { - if (data[ds_id].usemode >= HILINK_USE_MODE_END) { - printf("usemode[%u] is out of range.\n", data[ds_id].usemode); -@@ -204,17 +199,13 @@ static void hikp_serdes_brief_info_print(struct cmd_serdes_param *cmd, - "--------------------------------\n") - - static void hikp_serdes_detail_info_print(struct cmd_serdes_param *cmd, -- const struct hilink_detail_info *data, uint32_t data_size) -+ const struct hilink_detail_info *data) - { - uint32_t i; - uint8_t ds_id; - uint8_t start_sds_id = cmd->start_sds_id; - uint8_t sds_num = cmd->sds_num; - -- if (data_size != sds_num) { -- printf("serdes detail info data size is wrong.\n"); -- return; -- } - printf(KEY_INFO_TITLE); - for (ds_id = 0; ds_id < sds_num; ds_id++) { - printf("chip%u (M%u,ds%d) [%3d,%3d,%3u,%3d,%3d]", -@@ -341,13 +332,20 @@ static void hikp_serdes_info_print(struct cmd_serdes_param *cmd) - struct hilink_detail_info *detail_info_data = NULL; - - if (cmd->sub_cmd > 0) { -+ if (g_out_put.result_offset != cmd->sds_num * sizeof(struct hilink_detail_info)) { -+ printf("serdes detail info data size is wrong.\n"); -+ return; -+ } - detail_info_data = (struct hilink_detail_info *)g_out_put.out_str; -- hikp_serdes_detail_info_print(cmd, detail_info_data, -- g_out_put.result_offset / sizeof(struct hilink_detail_info)); -+ hikp_serdes_detail_info_print(cmd, detail_info_data); - } else { -+ if (g_out_put.result_offset != cmd->sds_num * sizeof(struct hilink_brief_info)) { -+ printf("serdes brief info data size is wrong.\n"); -+ return; -+ } -+ - brief_info_data = (struct hilink_brief_info *)g_out_put.out_str; -- hikp_serdes_brief_info_print(cmd, brief_info_data, -- g_out_put.result_offset / sizeof(struct hilink_brief_info)); -+ hikp_serdes_brief_info_print(cmd, brief_info_data); - } - } - -diff --git a/socip/hikp_socip_dumpreg.c b/socip/hikp_socip_dumpreg.c -index b3b3ed7..6d94f4a 100644 ---- a/socip/hikp_socip_dumpreg.c -+++ b/socip/hikp_socip_dumpreg.c -@@ -25,7 +25,7 @@ enum { - - struct dump_reg_param_t { - uint8_t val; -- bool is_vaild; -+ bool is_valid; - }; - - static const char *g_param_desc[SOCIP_DUMP_REG_PARAM_NUM] = { -@@ -65,7 +65,7 @@ static int get_param(struct major_cmd_ctrl *self, const char *argv, uint32_t ind - self->err_no = -EINVAL; - return -EINVAL; - } -- param->is_vaild = true; -+ param->is_valid = true; - - return 0; - } -@@ -97,7 +97,7 @@ static bool check_socip_dumpreg_param(void) - uint32_t i; - - for (i = 0; i < HIKP_ARRAY_SIZE(g_dump_reg_param); i++) { -- if (!param->is_vaild) { -+ if (!param->is_valid) { - ret = false; - HIKP_ERROR_PRINT("%s is not set\n", g_param_desc[i]); - } -diff --git a/tool_lib/tool_lib.c b/tool_lib/tool_lib.c -index 3dc5dad..559c558 100644 ---- a/tool_lib/tool_lib.c -+++ b/tool_lib/tool_lib.c -@@ -23,6 +23,7 @@ uint32_t get_chip_type(void) - uint32_t chip_type = CHIP_UNKNOW; - uint64_t midr_el1; - uint32_t part_num; -+ char *end = NULL; - FILE *file; - - file = fopen(MIDR_EL1_PATH, "r"); -@@ -38,7 +39,12 @@ uint32_t get_chip_type(void) - } - - fclose(file); -- midr_el1 = strtoul(midr_buffer, NULL, MIDR_HEX_TYPE); -+ midr_el1 = strtoul(midr_buffer, &end, MIDR_HEX_TYPE); -+ if ((end <= midr_buffer) || (midr_el1 == ULONG_MAX)) { -+ HIKP_ERROR_PRINT("Get chip type failed: %d\n", errno); -+ return chip_type; -+ } -+ - part_num = (midr_el1 & 0xffff) >> PART_NUM_OFFSET; - (void)snprintf(part_num_str, MIDR_BUFFER_SIZE, "%x", part_num); - --- -2.25.1 - diff --git a/0109-hikptool-optimization-tool-help-information.patch b/0109-hikptool-optimization-tool-help-information.patch deleted file mode 100644 index 9be43fd5b0d91957a4c6b07d9541d5c7af15cfec..0000000000000000000000000000000000000000 --- a/0109-hikptool-optimization-tool-help-information.patch +++ /dev/null @@ -1,238 +0,0 @@ -From c72ca6bfc60bca9543beb4f39328099cac094c15 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Tue, 26 Aug 2025 19:29:41 +0800 -Subject: [PATCH 2/2] hikptool: optimization tool help information - -Based on the actual hardware platform, -display the supported commands; -if the current hardware does not support a command, -it will not be displayed, and the user will -be prompted with an error message if they input that command. - -Signed-off-by: veega2022 ---- - hikp_init_main.c | 148 +++++++++++++++++++++++++++++++++++++++++++- - tool_lib/tool_cmd.h | 5 ++ - tool_lib/tool_lib.c | 2 + - tool_lib/tool_lib.h | 1 + - 4 files changed, 154 insertions(+), 2 deletions(-) - -diff --git a/hikp_init_main.c b/hikp_init_main.c -index e159ad9..7b63e9b 100644 ---- a/hikp_init_main.c -+++ b/hikp_init_main.c -@@ -19,9 +19,149 @@ - /* hikptool command adapter */ - struct cmd_adapter g_tool = { 0 }; - -+static const char *g_cxl_cmd_list[] = { -+ "cxl_cpa", "cxl_dl", "cxl_membar", "cxl_rcrb", -+}; -+ -+static const char *g_hccs_cmd_list[] = { -+ "hccs", -+}; -+ -+static const char *g_log_collect_cmd_list[] = { -+ "info_collect", -+}; -+ -+static const char *g_nic_cmd_list[] = { -+ "nic_dfx", "nic_fd", "nic_fec", "nic_gro", "nic_info", -+ "nic_log", "nic_mac", "nic_ncsi", "nic_notify_pkt", "nic_port", -+ "nic_port_fault", "nic_ppp", "nic_qos", "nic_queue", "nic_rss", -+ "nic_torus", "nic_xsfp", -+}; -+ -+static const char *g_pcie_cmd_list[] = { -+ "pcie_dumpreg", "pcie_info", "pcie_regrd", "pcie_trace", -+}; -+ -+static const char *g_roce_cmd_list[] = { -+ "roce_bond", "roce_caep", "roce_dfx_sta", "roce_global_cfg", "roce_gmv", -+ "roce_mdb", "roce_pkt", "roce_qmm", "roce_rst", "roce_scc", -+ "roce_timer", "roce_trp", "roce_tsp", -+}; -+ -+static const char *g_roh_cmd_list[] = { -+ "roh_mac", "roh_show_bp", "roh_show_mib", -+}; -+ -+static const char *g_sas_cmd_list[] = { -+ "sas_anacq", "sas_anadq", "sas_dev", "sas_dqe", "sas_dump", "sas_errcode", -+}; -+ -+static const char *g_sata_cmd_list[] = { -+ "sata_dump", -+}; -+ -+static const char *g_serdes_cmd_list[] = { -+ "serdes_dump", "serdes_info", -+}; -+ -+static const char *g_socip_cmd_list[] = { -+ "socip_dumpreg", -+}; -+ -+static const char *g_core_ring_cmd_list[] = { -+ "cpu_ring", -+}; -+ -+static const char *g_sdma_cmd_list[] = { -+ "sdma_dump", -+}; -+ -+static const char *g_ub_cmd_list[] = { -+ "ub_bp", "ub_crd", "ub_dfx", "ub_info", "ub_link", "unic_ppp", -+}; -+ -+static const char *g_ras_cmd_list[] = { -+ "bbox_export", -+}; -+ -+const struct cmd_list_info g_chip_hip09_hip10_cmd_list[] = { -+ {g_cxl_cmd_list, HIKP_ARRAY_SIZE(g_cxl_cmd_list)}, -+ {g_hccs_cmd_list, HIKP_ARRAY_SIZE(g_hccs_cmd_list)}, -+ {g_log_collect_cmd_list, HIKP_ARRAY_SIZE(g_log_collect_cmd_list)}, -+ {g_nic_cmd_list, HIKP_ARRAY_SIZE(g_nic_cmd_list)}, -+ {g_pcie_cmd_list, HIKP_ARRAY_SIZE(g_pcie_cmd_list)}, -+ {g_roce_cmd_list, HIKP_ARRAY_SIZE(g_roce_cmd_list)}, -+ {g_roh_cmd_list, HIKP_ARRAY_SIZE(g_roh_cmd_list)}, -+ {g_sas_cmd_list, HIKP_ARRAY_SIZE(g_sas_cmd_list)}, -+ {g_sata_cmd_list, HIKP_ARRAY_SIZE(g_sata_cmd_list)}, -+ {g_serdes_cmd_list, HIKP_ARRAY_SIZE(g_serdes_cmd_list)}, -+ {g_socip_cmd_list, HIKP_ARRAY_SIZE(g_socip_cmd_list)}, -+}; -+ -+const struct cmd_list_info g_chip_hip11_cmd_list[] = { -+ {g_core_ring_cmd_list, HIKP_ARRAY_SIZE(g_core_ring_cmd_list)}, -+ {g_log_collect_cmd_list, HIKP_ARRAY_SIZE(g_log_collect_cmd_list)}, -+ {g_nic_cmd_list, HIKP_ARRAY_SIZE(g_nic_cmd_list)}, -+ {g_pcie_cmd_list, HIKP_ARRAY_SIZE(g_pcie_cmd_list)}, -+ {g_roce_cmd_list, HIKP_ARRAY_SIZE(g_roce_cmd_list)}, -+ {g_roh_cmd_list, HIKP_ARRAY_SIZE(g_roh_cmd_list)}, -+ {g_sata_cmd_list, HIKP_ARRAY_SIZE(g_sata_cmd_list)}, -+ {g_sdma_cmd_list, HIKP_ARRAY_SIZE(g_sdma_cmd_list)}, -+ {g_serdes_cmd_list, HIKP_ARRAY_SIZE(g_serdes_cmd_list)}, -+ {g_socip_cmd_list, HIKP_ARRAY_SIZE(g_socip_cmd_list)}, -+ {g_ub_cmd_list, HIKP_ARRAY_SIZE(g_ub_cmd_list)}, -+}; -+ -+const struct cmd_list_info g_chip_hip12_cmd_list[] = { -+ {g_ras_cmd_list, HIKP_ARRAY_SIZE(g_ras_cmd_list)}, -+ {g_hccs_cmd_list, HIKP_ARRAY_SIZE(g_hccs_cmd_list)}, -+ {g_log_collect_cmd_list, HIKP_ARRAY_SIZE(g_log_collect_cmd_list)}, -+ {g_pcie_cmd_list, HIKP_ARRAY_SIZE(g_pcie_cmd_list)}, -+ {g_serdes_cmd_list, HIKP_ARRAY_SIZE(g_serdes_cmd_list)}, -+ {g_socip_cmd_list, HIKP_ARRAY_SIZE(g_socip_cmd_list)}, -+}; -+ -+static bool cmd_is_support(const char *cmd_name, struct cmd_list_info *cmd_info, size_t len) -+{ -+ for (size_t i = 0; i < len; i++) -+ for (size_t j = 0; j < cmd_info[i].list_len; j++) -+ if (strcmp(cmd_info[i].cmd_list[j], cmd_name) == 0) -+ return true; -+ -+ return false; -+} -+ -+static bool check_cmd_is_support(const char *cmd_name) -+{ -+ uint32_t chip_type = get_chip_type(); -+ bool is_support = true; -+ -+ switch (chip_type) { -+ case CHIP_HIP09: -+ case CHIP_HIP10: -+ case CHIP_HIP10C: -+ is_support = cmd_is_support(cmd_name, g_chip_hip09_hip10_cmd_list, -+ HIKP_ARRAY_SIZE(g_chip_hip09_hip10_cmd_list)); -+ break; -+ case CHIP_HIP11: -+ is_support = cmd_is_support(cmd_name, g_chip_hip11_cmd_list, -+ HIKP_ARRAY_SIZE(g_chip_hip11_cmd_list)); -+ break; -+ case CHIP_HIP12: -+ is_support = cmd_is_support(cmd_name, g_chip_hip12_cmd_list, -+ HIKP_ARRAY_SIZE(g_chip_hip12_cmd_list)); -+ break; -+ default: -+ break; -+ } -+ -+ /* Unrecognized hardware type, default display supported */ -+ return is_support; -+} -+ - static void show_tool_version(const struct cmd_adapter *adapter) - { -- printf("%s version %s Huawei\n", adapter->name, adapter->version); -+ printf("%s version %s Huawei HW(%u)\n", adapter->name, adapter->version, get_chip_type()); - } - - static int cmp(const void *a, const void *b) -@@ -52,7 +192,8 @@ static void show_tool_help(const struct cmd_adapter *adapter) - qsort(start_cmd_ptr, end_cmd_ptr - start_cmd_ptr, - sizeof(struct hikp_cmd_type), (const void *)cmp); - for (cmd_ptr = start_cmd_ptr; cmd_ptr < end_cmd_ptr; cmd_ptr++) -- printf(" %-23s %s\n", cmd_ptr->name, cmd_ptr->help_info); -+ if (check_cmd_is_support(cmd_ptr->name)) -+ printf(" %-23s %s\n", cmd_ptr->name, cmd_ptr->help_info); - - printf("\n"); - } -@@ -92,6 +233,9 @@ static int parse_and_init_cmd(const char *arg) - if (strnlen(cmd_ptr->name, MAX_CMD_LEN) != strnlen(arg, MAX_CMD_LEN)) - continue; - -+ if (!check_cmd_is_support(cmd_ptr->name)) -+ continue; -+ - if ((strncmp(arg, cmd_ptr->name, - strnlen(cmd_ptr->name, MAX_CMD_LEN - 1) + 1) == 0) && cmd_ptr->cmd_init) { - g_tool.p_major_cmd.cmd_ptr = cmd_ptr; -diff --git a/tool_lib/tool_cmd.h b/tool_lib/tool_cmd.h -index 1aaaf22..87df2d7 100644 ---- a/tool_lib/tool_cmd.h -+++ b/tool_lib/tool_cmd.h -@@ -67,6 +67,11 @@ struct cmd_adapter { - struct major_cmd_ctrl p_major_cmd; - }; - -+struct cmd_list_info { -+ const char **cmd_list; -+ size_t list_len; -+}; -+ - extern int _s_cmd_data; - extern int _e_cmd_data; - extern struct cmd_adapter g_tool; -diff --git a/tool_lib/tool_lib.c b/tool_lib/tool_lib.c -index 559c558..f5facd5 100644 ---- a/tool_lib/tool_lib.c -+++ b/tool_lib/tool_lib.c -@@ -56,6 +56,8 @@ uint32_t get_chip_type(void) - chip_type = CHIP_HIP10C; - else if (strcmp(part_num_str, "d22") == 0) - chip_type = CHIP_HIP11; -+ else if (strcmp(part_num_str, "d06") == 0) -+ chip_type = CHIP_HIP12; - else - chip_type = CHIP_UNKNOW; - -diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h -index d4accf1..b7b756c 100644 ---- a/tool_lib/tool_lib.h -+++ b/tool_lib/tool_lib.h -@@ -106,6 +106,7 @@ enum chip_type { - CHIP_HIP10, - CHIP_HIP10C, - CHIP_HIP11, -+ CHIP_HIP12, - CHIP_UNKNOW, - }; - --- -2.45.0.windows.1 - diff --git a/0110-hikptool-ras-do-some-cleanup-and-refactoring-of-rasd.patch b/0110-hikptool-ras-do-some-cleanup-and-refactoring-of-rasd.patch deleted file mode 100644 index 28066b8c038b0cab3745ba874299bd1ca8264c57..0000000000000000000000000000000000000000 --- a/0110-hikptool-ras-do-some-cleanup-and-refactoring-of-rasd.patch +++ /dev/null @@ -1,875 +0,0 @@ -From bfd5326b0abb9d6f54333f8f9090fd8cabc17061 Mon Sep 17 00:00:00 2001 -From: Junhao He -Date: Tue, 16 Sep 2025 16:59:56 +0800 -Subject: [PATCH] hikptool: ras: do some cleanup and refactoring of rasdfx dump - -cleanup: -1) Add a macro to simplify obtaining the packet size -2) Remove redundant checks for cmd and size, as they are always true -3) Use memcpy instead of for loop statements -4) Remove the redundant initialization of ras_rsp_data to 0 -5) Other minor cleanup - -refactor: -During the dump file process, do not repeatedly open and close the file -No need to subtract the packet header length, then simplify the code for -obtaining the file buffer size. - -Add helper of ras_get_rasdfx_header -Add a check to verify if cmd_ret->rsp_data_num is 0 -Add a check to verify whether f_header.pkt_num exceeds the maximum value - -The header.pkt_length indicates the size in bytes, which needs to be -converted to DWORD size, and then compared with DFX_REG_PACKET_HEAD_LEN -to address potential division by zero issues. - -Refactoring of parseing payload. - -Signed-off-by: Junhao He ---- - ras/ras_func/ras_common.h | 26 -- - ras/ras_func/ras_dump_data.c | 468 +++++++++++++------------------ - ras/ras_func/ras_dump_data.h | 90 +++--- - ras/user_cmd/ras_cmd_dump.c | 35 +-- - ras/user_cmd/ras_tools_include.h | 25 -- - 5 files changed, 243 insertions(+), 401 deletions(-) - delete mode 100644 ras/ras_func/ras_common.h - delete mode 100644 ras/user_cmd/ras_tools_include.h - -diff --git a/ras/ras_func/ras_common.h b/ras/ras_func/ras_common.h -deleted file mode 100644 -index 0931ed9..0000000 ---- a/ras/ras_func/ras_common.h -+++ /dev/null -@@ -1,26 +0,0 @@ --/* -- * 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 RAS_COMMON_H --#define RAS_COMMON_H -- --enum { -- RAS_DUMP, --}; -- --enum ras_dump_cmd_type { -- DUMP_DFX = 0, -- DUMP_CLEAR, --}; -- --#endif /* RAS_COMMON_H */ -diff --git a/ras/ras_func/ras_dump_data.c b/ras/ras_func/ras_dump_data.c -index 7ab7d6b..2d0f274 100644 ---- a/ras/ras_func/ras_dump_data.c -+++ b/ras/ras_func/ras_dump_data.c -@@ -13,377 +13,299 @@ - #include - #include - #include -+#include - #include - #include - #include - #include - #include "hikptdev_plug.h" - #include "op_logs.h" --#include "ras_common.h" -+#include "hikpt_rciep.h" -+#include "tool_lib.h" - #include "ras_dump_data.h" - --static struct dfx_reg_dump_header header; -+static void __attribute__((format(printf, 2, 3))) __THROWNL -+rasdfx_wr2buf(struct file_seq *s, const char *fmt, ...); - --static int ras_get_data(uint32_t ras_cmd_type, struct ras_dump_req_para *req_data, -- struct ras_rsp *ras_rsp_data) --{ -- uint32_t i; -- struct hikp_cmd_ret *cmd_ret; -- struct hikp_cmd_header req_header; -+#define RAS_DUMP 0 - -- hikp_cmd_init(&req_header, RAS_MOD, RAS_DUMP, ras_cmd_type); -- cmd_ret = hikp_cmd_alloc(&req_header, req_data, RAS_REQ_DATA_LEN); -- if (cmd_ret == NULL || cmd_ret->status != 0 || -- cmd_ret->rsp_data_num > HIKP_RSP_ALL_DATA_MAX) { -- printf("hikp_data_proc err\n"); -- hikp_cmd_free(&cmd_ret); -- return -1; -- } -+#define RASDFX_FILE_HEADER_LEN 6 -+#define MAX_DFX_PACKET_LEN 256 -+#define DFX_REG_PACKET_HEAD_LEN 3U - -- ras_rsp_data->rsp_data_num = cmd_ret->rsp_data_num; -- for (i = 0; i < ras_rsp_data->rsp_data_num; i++) { -- ras_rsp_data->rsp_data[i] = cmd_ret->rsp_data[i]; -- } -+#define DFX_DATA_CLEARED_MAGIC 0 -+#define DFX_DATA_DUMPED_MAGIC 0x5aa5a55a - -- hikp_cmd_free(&cmd_ret); -- return 0; --} -+#define RASDFX_PACKET_HEAD_SIZE 256 -+#define RASDFX_PACKET_SIZE(reg_num) (RASDFX_PACKET_HEAD_SIZE + (reg_num) * 10) -+#define RASDFX_PACKET_NUM_MAX 1000000 - --static void ras_print_time(struct file_seq *s) -+static void __THROWNL rasdfx_wr2buf(struct file_seq *s, const char *fmt, ...) - { -- time_t time_seconds = time(0); -- struct tm timeinfo; -- -- (void)localtime_r(&time_seconds, &timeinfo); -- s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "Time: %d-%d-%d %d:%d:%d\n", -- timeinfo.tm_year + START_YEAR, timeinfo.tm_mon + 1, timeinfo.tm_mday, -- timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); -+ size_t size = s->buf_size - s->buf_offs; -+ va_list argp; -+ int len; -+ -+ va_start(argp, fmt); -+ len = vsnprintf(s->buf + s->buf_offs, size, fmt, argp); -+ va_end(argp); -+ -+ if (len < 0 || (size_t)len >= size) -+ HIKP_WARN_PRINT("rasdfx_wr2buf failed, the dfx data is incomplete\n"); -+ else -+ s->buf_offs += (size_t)len; - } - --static int ras_parse_data(uint32_t *reg_save, uint32_t reg_num, uint32_t reg_off, struct file_seq *s) -+static struct hikp_cmd_ret *ras_get_rsp_data(struct ras_dump_cmd *cmd) - { -- uint32_t i, j; -- uint32_t cycle; -- uint32_t reg_count, pkt_reg_num; -- uint32_t off = reg_off; -- -- pkt_reg_num = header.pkt_length / sizeof(uint32_t); -- cycle = reg_num / pkt_reg_num; -- if (!cycle) -- return -1; -- -- for (i = 0; i < cycle; i++) { -- if ((off + pkt_reg_num) > HIKP_RSP_ALL_DATA_MAX) { -- HIKP_ERROR_PRINT("off is %u, pkt_reg_num is %u,\ -- reg_save index will exceed max reg_save length\n", -- off, pkt_reg_num); -- return -1; -- } -- -- ras_print_time(s); -- s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "Socket: 0X%hhX\t", -- (reg_save[off + DFX_HEAD_INFO_DW0] >> DFX_HEAD_SKT_ID_OFF) & 0xff); -- s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "DIE: 0X%hhX\t", -- (reg_save[off + DFX_HEAD_INFO_DW0] >> DFX_HEAD_DIE_ID_OFF) & 0xff); -- s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "Module: 0X%hhX\t", -- (reg_save[off + DFX_HEAD_INFO_DW1] >> DFX_HEAD_MODULE_ID_OFF) & 0xff); -- s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "Sub Module: 0X%hhX\t", -- (reg_save[off + DFX_HEAD_INFO_DW1] >> DFX_HEAD_SUBMODULE_ID_OFF) & 0xff); -- s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "SequenceNum: 0X%hhX\t", -- (reg_save[off + DFX_HEAD_INFO_DW1] >> DFX_HEAD_SEQUENCE_NUM_OFF) & 0xff); -- s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "Version: 0X%hhX\n", -- (reg_save[off + DFX_HEAD_INFO_DW0] >> DFX_HEAD_VERSION_OFF) & 0xff); -- s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, -- "----------------------- DFX REGISTER DUMP -----------------------\n"); -- -- reg_count = (reg_save[off + DFX_HEAD_INFO_DW1] >> DFX_HEAD_REG_COUNT_OFF) & 0xff; -- if (!reg_count || reg_count > pkt_reg_num - DFX_REG_PACKET_HEAD_LEN) { -- HIKP_ERROR_PRINT("reg_count is %u, value is not within the reasonable range(1-%u).\n", -- reg_count, pkt_reg_num - DFX_REG_PACKET_HEAD_LEN); -- return -1; -- } -+ struct hikp_cmd_header req_header; -+ struct hikp_cmd_ret *cmd_ret; - -- for (j = 0; j < reg_count; j++) -- s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "0X%X\n", -- reg_save[off + DFX_COMMON_MAIN_TEXT_BEGIN + j]); -+ hikp_cmd_init(&req_header, RAS_MOD, RAS_DUMP, cmd->cmd_type); -+ cmd_ret = hikp_cmd_alloc(&req_header, &cmd->cmd_id, sizeof(cmd->cmd_id)); -+ if (!cmd_ret) { -+ HIKP_ERROR_PRINT("alloc cmd failed, cmd: %u\n", cmd->cmd_id); -+ return NULL; -+ } - -- s->len += snprintf(s->buffer + s->len, s->buffer_size - s->len, "\n"); -- off += pkt_reg_num; -+ if (cmd_ret->status) { -+ HIKP_ERROR_PRINT("hikp_data_proc err, status: %u\n", cmd_ret->status); -+ hikp_cmd_free(&cmd_ret); -+ return NULL; - } - -- return 0; -+ return cmd_ret; - } - --static int ras_generate_file_name(struct file_seq *s) -+static int ras_get_rasdfx_header(struct ras_dump_cmd *cmd, struct rasdfx_file_header *f_header) - { -- time_t time_seconds = time(0); -- struct tm timeinfo; -- int ret; -+ struct hikp_cmd_ret *cmd_ret; - -- (void)localtime_r(&time_seconds, &timeinfo); -- ret = snprintf(s->file_name, MAX_LOG_NAME_LEN, "rasdfx_%d_%d_%d_%d_%d_%d.log", -- timeinfo.tm_year + START_YEAR, timeinfo.tm_mon + 1, timeinfo.tm_mday, -- timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); -- if (ret < 0 || (uint32_t)ret >= MAX_LOG_NAME_LEN) { -- HIKP_ERROR_PRINT("generate file name failed, errno is %d\n", errno); -- return -errno; -+ cmd->cmd_id = 0; -+ cmd_ret = ras_get_rsp_data(cmd); -+ if (!cmd_ret) -+ return -ENOMEM; -+ -+ if (cmd_ret->rsp_data_num != RASDFX_FILE_HEADER_LEN) { -+ HIKP_ERROR_PRINT("invalid number of response data: %u\n", cmd_ret->rsp_data_num); -+ hikp_cmd_free(&cmd_ret); -+ return -1; - } - -+ memcpy(f_header, cmd_ret->rsp_data, sizeof(struct rasdfx_file_header)); -+ hikp_cmd_free(&cmd_ret); -+ - return 0; - } - --static int ras_store_data(struct file_seq *s) -+static bool ras_check_header(struct rasdfx_file_header *f_header) - { -- char file_path[OP_LOG_FILE_PATH_MAXLEN]; -- size_t write_cnt; -- FILE *fp; -- int rc; -- -- rc = snprintf(file_path, sizeof(file_path), HIKP_LOG_DIR_PATH"%s", s->file_name); -- if (rc < 0) { -- HIKP_ERROR_PRINT("creat log file path fail.\n"); -- return -EIO; -+ if (f_header->pkt_size_dwords % REP_DATA_BLK_SIZE) { -+ HIKP_ERROR_PRINT("packet size is not aligned: %u\n", f_header->pkt_size_dwords); -+ return false; - } - -- fp = fopen(file_path, "a"); -- if (fp == NULL) { -- HIKP_ERROR_PRINT("open %s failed, errno is %d\n", file_path, errno); -- return -errno; -+ /* Converted to DWORD units to simplify subsequent calculations */ -+ f_header->pkt_size_dwords = f_header->pkt_size_dwords / REP_DATA_BLK_SIZE; -+ if (f_header->pkt_size_dwords < DFX_REG_PACKET_HEAD_LEN || -+ f_header->pkt_size_dwords > MAX_DFX_PACKET_LEN) { -+ HIKP_ERROR_PRINT("packet size is out of bounds: %u\n", f_header->pkt_size_dwords); -+ return false; - } - -- write_cnt = fwrite(s->buffer, 1, s->len, fp); -- if (write_cnt != (uint32_t)s->len) { -- fclose(fp); -- HIKP_ERROR_PRINT("write %s failed, write cnt %zu.\n", file_path, write_cnt); -- return -EAGAIN; -- } -- -- printf("dump imp log completed, log file: %s.\n", file_path); -- /* Set the file permission to 0440 */ -- if (chmod(file_path, 0440)) -- HIKP_ERROR_PRINT("chmod %s failed, errno is %d\n", file_path, errno); -- -- if (fclose(fp)) { -- HIKP_ERROR_PRINT("close %s failed, errno is %d\n", file_path, errno); -- return -errno; -+ if (f_header->pkt_num == 0 || f_header->pkt_num > RASDFX_PACKET_NUM_MAX) { -+ HIKP_ERROR_PRINT("packet number is out of bounds: %u\n", f_header->pkt_num); -+ return false; - } - -- s->len = 0; -- -- return 0; -+ return true; - } - --static int file_seq_init(struct file_seq *s, uint32_t size) -+static int ras_open_rasdfx_file_seq(struct file_seq *s, struct rasdfx_file_header *f_header) - { -- if (!size) -- return -1; -+ char file_path[OP_LOG_FILE_PATH_MAXLEN]; -+ time_t time_seconds = time(0); -+ struct tm timeinfo; - -- s->buffer_size = size; -- s->len = 0; -- s->buffer = (char*)malloc(s->buffer_size); -- if (!s->buffer) -- return -1; -+ s->buf_offs = 0; -+ s->buf_size = RASDFX_PACKET_SIZE(f_header->pkt_size_dwords); -+ s->buf = (char *)malloc(s->buf_size); -+ if (!s->buf) { -+ HIKP_ERROR_PRINT("malloc file_seq buffer is failed\n"); -+ return -ENOMEM; -+ } -+ -+ (void)localtime_r(&time_seconds, &timeinfo); -+ snprintf(file_path, sizeof(file_path), "%srasdfx_%04d_%02d_%02d_%02d_%02d_%02d.log", -+ HIKP_LOG_DIR_PATH, timeinfo.tm_year + START_YEAR, timeinfo.tm_mon + 1, -+ timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); -+ -+ // creat and open file, set file permissiion 0440 -+ s->fd = open(file_path, O_WRONLY | O_CREAT, S_IRUSR | S_IRGRP); -+ if (s->fd < 0) { -+ HIKP_ERROR_PRINT("open %s failed: %s\n", file_path, strerror(errno)); -+ free(s->buf); -+ return -errno; -+ } - -+ printf("dump dfx log start, log file: %s\n", file_path); - return 0; - } - --static void file_seq_destroy(struct file_seq *s) -+static void ras_close_rasdfx_file_seq(struct file_seq *s) - { -- free(s->buffer); -- s->buffer = NULL; -+ (void)close(s->fd); -+ free(s->buf); - } - --static void ras_rsp_init(struct ras_rsp *ras_rsp_data) -+static void ras_parse_rasdfx_pkt_header(struct file_seq *s, struct rasdfx_pkt *pkt) - { -- ras_rsp_data->first_pkt_begin = 0; -- ras_rsp_data->last_pkt_end = 0; -- ras_rsp_data->rsp_data_num = 0; -- ras_rsp_data->packet_buffer_len = 0; -+ time_t time_seconds = time(0); -+ struct tm timeinfo; - -- memset(ras_rsp_data->rsp_data, 0, sizeof(ras_rsp_data->rsp_data)); -- memset(ras_rsp_data->packet_buffer, 0, sizeof(ras_rsp_data->packet_buffer)); -+ (void)localtime_r(&time_seconds, &timeinfo); -+ rasdfx_wr2buf(s, "Time: %d-%d-%d %d:%d:%d\n", -+ timeinfo.tm_year + START_YEAR, timeinfo.tm_mon + 1, timeinfo.tm_mday, -+ timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); -+ rasdfx_wr2buf(s, "Socket: 0X%hhX ", pkt->dw0.skt_id); -+ rasdfx_wr2buf(s, "DIE: 0X%hhX ", pkt->dw0.die_id); -+ rasdfx_wr2buf(s, "Module: 0X%hhX ", pkt->dw1.module_id); -+ rasdfx_wr2buf(s, "Sub Module: 0X%hhX ", pkt->dw1.submodule_id); -+ rasdfx_wr2buf(s, "SequenceNum: 0X%hhX ", pkt->dw1.sequence_num); -+ rasdfx_wr2buf(s, "Version: 0X%hhX\n", pkt->dw0.version); -+ rasdfx_wr2buf(s, "----------------------- DFX REGISTER DUMP -----------------------\n"); - } - --static int parse_packet_buffer_data(struct ras_rsp *ras_rsp_data, -- uint32_t pkt_reg_num, struct file_seq *s) -+static int ras_parse_rasdfx_payload(struct file_seq *s, uint32_t *buf, -+ struct rasdfx_file_header *f_header) - { -- int ret; -- -- if (pkt_reg_num > MAX_DFX_PACKET_LEN) { -- HIKP_ERROR_PRINT("pkt_reg_num is %u, has exceeded max packet length\n", pkt_reg_num); -- return -1; -- } -+ struct rasdfx_pkt *pkt = (struct rasdfx_pkt *)buf; -+ uint32_t reg_offs, i; -+ ssize_t write_cnt; - -- if (ras_rsp_data->packet_buffer_len) { -- uint32_t rest_pkt_length; -+ rasdfx_wr2buf(s, "SocID: %u\n\n", pkt->dw0.soc_id); - -- rest_pkt_length = pkt_reg_num - ras_rsp_data->packet_buffer_len; -- memcpy(ras_rsp_data->packet_buffer + ras_rsp_data->packet_buffer_len, -- ras_rsp_data->rsp_data, rest_pkt_length); -- -- ras_rsp_data->first_pkt_begin = rest_pkt_length; -- ret = ras_parse_data(ras_rsp_data->packet_buffer, pkt_reg_num, 0, s); -- if (ret) { -- HIKP_ERROR_PRINT("ras parse packet_buffer_data is failed\n"); -- return ret; -+ for (i = 0; i < f_header->pkt_num; i++) { -+ ras_parse_rasdfx_pkt_header(s, pkt); -+ if (pkt->dw1.reg_count > f_header->pkt_size_dwords - DFX_REG_PACKET_HEAD_LEN) { -+ HIKP_ERROR_PRINT("ras dfx register number is incorrect\n"); -+ return -1; - } -- } else { -- ras_rsp_data->first_pkt_begin = 0; -- } - -- if (ras_rsp_data->first_pkt_begin == ras_rsp_data->rsp_data_num) -- return 0; -+ for (reg_offs = 0; reg_offs < pkt->dw1.reg_count; reg_offs++) -+ rasdfx_wr2buf(s, "0X%08X\n", pkt->reg_base[reg_offs]); -+ rasdfx_wr2buf(s, "\n"); - -- ras_rsp_data->packet_buffer_len = -- (ras_rsp_data->rsp_data_num - ras_rsp_data->first_pkt_begin) % pkt_reg_num; -- ras_rsp_data->last_pkt_end = ras_rsp_data->rsp_data_num - ras_rsp_data->packet_buffer_len - 1; -- ras_rsp_data->rsp_data_num = ras_rsp_data->last_pkt_end - ras_rsp_data->first_pkt_begin + 1; -+ write_cnt = write(s->fd, s->buf, s->buf_offs); -+ if (write_cnt != (ssize_t)s->buf_offs) { -+ HIKP_ERROR_PRINT("write rasdfx file failed: %s\n", strerror(errno)); -+ return -1; -+ } - -- memcpy(ras_rsp_data->packet_buffer, ras_rsp_data->rsp_data + ras_rsp_data->last_pkt_end + 1, -- ras_rsp_data->packet_buffer_len); -+ s->buf_offs = 0; -+ pkt = (struct rasdfx_pkt *)((uint32_t *)pkt + f_header->pkt_size_dwords); -+ } - - return 0; - } - --static int ras_dump_pkt_pre(struct ras_rsp *ras_rsp_data, struct file_seq *s) -+static int ras_dump_data_into_buf(struct ras_dump_cmd *cmd, uint32_t *buf, uint32_t buf_max) - { -- int ret; -- uint32_t reg_num, max_pkt_num, s_buffer_size; -- -- max_pkt_num = (HIKP_RSP_DATA_SIZE_MAX / header.pkt_length) + 1; -- reg_num = header.pkt_length / sizeof(uint32_t) - DFX_REG_PACKET_HEAD_LEN; -- s_buffer_size = max_pkt_num * -- (reg_num * DFX_FILE_SINGLE_REG_SIZE + DFX_FILE_SINGLE_PACKET_HEAD_SIZE); -- ras_rsp_data->rsp_data_num = 0; -+ struct hikp_cmd_ret *cmd_ret; -+ uint32_t copy_len = 0; -+ uint32_t data_num; -+ -+ while (copy_len < buf_max) { -+ cmd->cmd_id++; -+ cmd_ret = ras_get_rsp_data(cmd); -+ if (!cmd_ret) -+ return -ENOMEM; -+ -+ data_num = cmd_ret->rsp_data_num; -+ if (data_num == 0 || data_num > HIKP_RSP_ALL_DATA_MAX) { -+ HIKP_ERROR_PRINT("invalid response data number: %u\n", data_num); -+ hikp_cmd_free(&cmd_ret); -+ return -1; -+ } - -- ret = file_seq_init(s, s_buffer_size); -- if (ret) { -- HIKP_ERROR_PRINT("malloc file_seq buffer is failed\n"); -- return ret; -- } -+ if (copy_len + data_num > buf_max) { -+ HIKP_ERROR_PRINT("response data is more than expected\n"); -+ hikp_cmd_free(&cmd_ret); -+ return -1; -+ } - -- ret = ras_generate_file_name(s); -- if (ret) { -- HIKP_ERROR_PRINT("ras generate file name is failed\n"); -- file_seq_destroy(s); -- return ret; -+ memcpy(buf + copy_len, cmd_ret->rsp_data, data_num * REP_DATA_BLK_SIZE); -+ copy_len += data_num; -+ hikp_cmd_free(&cmd_ret); - } - -- return ret; -+ return 0; - } - --static int ras_dump_packet(struct tool_ras_cmd *cmd, struct ras_rsp *ras_rsp_data, -- struct ras_dump_req_para *req_data) -+static int ras_get_rasdfx_payload(struct ras_dump_cmd *cmd, struct rasdfx_file_header *f_header) - { -- int ret; -- uint32_t i, cmd_num; -- bool has_printed_socid = false; -+ uint32_t buf_max = f_header->pkt_size_dwords * f_header->pkt_num; -+ uint32_t *total_buf; - struct file_seq s; -+ int ret; - -- ret = ras_dump_pkt_pre(ras_rsp_data, &s); -- if (ret) -- return ret; -- -- cmd_num = (header.pkt_num * header.pkt_length + -- HIKP_RSP_DATA_SIZE_MAX - 1) / HIKP_RSP_DATA_SIZE_MAX; -- /* 0: get header info; 1-n: get packet data */ -- for (i = 0; i < cmd_num; i++) { -- req_data->cmd_id = i + 1; -- ret = ras_get_data(cmd->ras_cmd_type, req_data, ras_rsp_data); -- if (ret) { -- HIKP_ERROR_PRINT("ras dump cmd %u is failed\n", req_data->cmd_id); -- goto err_out_free; -- } -- -- if (!has_printed_socid) { -- s.len += snprintf(s.buffer + s.len, s.buffer_size - s.len, "SocID: %hhX\n", -- (ras_rsp_data->rsp_data[DFX_HEAD_INFO_DW0] >> DFX_HEAD_SOC_ID_OFF) & 0xff); -- s.len += snprintf(s.buffer + s.len, s.buffer_size - s.len, "\n"); -+ total_buf = (uint32_t *)malloc(buf_max * REP_DATA_BLK_SIZE); -+ if (!total_buf) { -+ HIKP_ERROR_PRINT("malloc total_buf failed\n"); -+ return -ENOMEM; -+ } - -- has_printed_socid = true; -- } -+ ret = ras_dump_data_into_buf(cmd, total_buf, buf_max); -+ if (ret) -+ goto release_total_buf; - -- ret = parse_packet_buffer_data(ras_rsp_data, header.pkt_length / sizeof(uint32_t), &s); -- if (ret) { -- HIKP_ERROR_PRINT("ras parse packet buffer data is failed\n"); -- goto err_out_free; -- } -+ ret = ras_open_rasdfx_file_seq(&s, f_header); -+ if (ret) -+ goto release_total_buf; - -- if (ras_rsp_data->first_pkt_begin != ras_rsp_data->rsp_data_num) { -- ret = ras_parse_data(ras_rsp_data->rsp_data, ras_rsp_data->rsp_data_num, -- ras_rsp_data->first_pkt_begin, &s); -- if (ret) { -- HIKP_ERROR_PRINT("ras parse rsp_data is failed\n"); -- goto err_out_free; -- } -- } -+ ret = ras_parse_rasdfx_payload(&s, total_buf, f_header); - -- ret = ras_store_data(&s); -- if (ret) { -- HIKP_ERROR_PRINT("ras store rsp_data is failed\n"); -- goto err_out_free; -- } -- } -- --err_out_free: -- file_seq_destroy(&s); -+ ras_close_rasdfx_file_seq(&s); -+release_total_buf: -+ free(total_buf); - return ret; - } - --int ras_data_dump(struct tool_ras_cmd *cmd) -+int ras_data_dump(void) - { -+ struct ras_dump_cmd cmd = { .cmd_type = DUMP_DFX }; -+ struct rasdfx_file_header f_header; - int ret; -- struct ras_rsp ras_rsp_data; -- struct ras_dump_req_para req_data = {0}; -- -- if (cmd == NULL) -- return -ENOSPC; - -- ras_rsp_init(&ras_rsp_data); -- ret = ras_get_data(cmd->ras_cmd_type, &req_data, &ras_rsp_data); -- if (ret || (ras_rsp_data.rsp_data_num != DFX_REG_DUMP_HEADER_LEN)) { -- HIKP_ERROR_PRINT("ras dump header is failed, rsp_data_num is %u\n", -- ras_rsp_data.rsp_data_num); -- return -1; -- } -+ ret = ras_get_rasdfx_header(&cmd, &f_header); -+ if (ret) -+ return ret; - -- if (!ras_rsp_data.rsp_data[HEAD_MAGIC]) { -- HIKP_ERROR_PRINT("ras dfx dump is failed, data does not exist or has been cleared.\n"); -+ if (f_header.head_magic != DFX_DATA_DUMPED_MAGIC) { -+ HIKP_ERROR_PRINT("data does not exist or has been cleared.\n"); - return -1; - } - -- header.pkt_num = ras_rsp_data.rsp_data[PKT_NUM]; -- header.pkt_length = ras_rsp_data.rsp_data[PKT_LENGTH]; -- if (header.pkt_num == 0 || header.pkt_length < DFX_REG_PACKET_HEAD_LEN) { -- HIKP_ERROR_PRINT("ras dfx dump is failed, pkt_num is %u, pkt_length is %u\n", -- header.pkt_num, header.pkt_length); -+ if (!ras_check_header(&f_header)) - return -1; -- } - -- ret = ras_dump_packet(cmd, &ras_rsp_data, &req_data); -- if (ret) -- HIKP_ERROR_PRINT("ras dump packet is failed\n"); -- -- return ret; -+ return ras_get_rasdfx_payload(&cmd, &f_header); - } - --int ras_data_clear(struct tool_ras_cmd *cmd) -+int ras_data_clear(void) - { -+ struct ras_dump_cmd cmd = { .cmd_type = DUMP_CLEAR }; -+ struct rasdfx_file_header f_header; - int ret; -- struct ras_rsp ras_rsp_data; -- struct ras_dump_req_para req_data = { 0 }; - -- if (cmd == NULL) -- return -ENOSPC; -+ ret = ras_get_rasdfx_header(&cmd, &f_header); -+ if (ret) -+ return ret; - -- ras_rsp_init(&ras_rsp_data); -- ret = ras_get_data(cmd->ras_cmd_type, &req_data, &ras_rsp_data); -- if (ret || ras_rsp_data.rsp_data_num != DFX_REG_DUMP_HEADER_LEN || -- ras_rsp_data.rsp_data[HEAD_MAGIC] != DFX_DATA_IS_CLEARED) { -+ if (f_header.head_magic != DFX_DATA_CLEARED_MAGIC) { - HIKP_ERROR_PRINT("ras dfx data clear is failed\n"); - return -1; - } - - return 0; - } -- -diff --git a/ras/ras_func/ras_dump_data.h b/ras/ras_func/ras_dump_data.h -index 4c54ffe..ef4a00f 100644 ---- a/ras/ras_func/ras_dump_data.h -+++ b/ras/ras_func/ras_dump_data.h -@@ -11,78 +11,60 @@ - * See the Mulan PSL v2 for more details. - */ - --#ifndef RAS_DUMP_REG_H --#define RAS_DUMP_REG_H -+#ifndef RAS_DUMP_DATA_H -+#define RAS_DUMP_DATA_H - --#include "ras_tools_include.h" --#include "hikpt_rciep.h" --#include "tool_lib.h" -+#include - --#define RAS_FILE_HEAD_BUF_LEN 256 --#define MAX_DFX_PACKET_LEN 256 --#define RAS_REQ_DATA_LEN 4 --#define DFX_REG_DUMP_HEADER_LEN 6 --#define DFX_REG_PACKET_HEAD_LEN 3 -- --struct dfx_reg_dump_header { -+struct rasdfx_file_header { - uint32_t head_magic; // 文件头的magic数字,特定值表示有效记录。 - uint32_t version; // 存储格å¼ç‰ˆæœ¬ - uint32_t cap_bits; // bit0表示是å¦å¼€å¯crc,其余bitä¿ç•™ã€‚ - uint32_t pkt_num; // packetæ•°é‡ -- uint32_t pkt_length; // å•个packetå ç”¨å†…存空间,å•ä½bytes -+ uint32_t pkt_size_dwords; // å•个packet内DWord个数,å•ä½4bytes - uint32_t reserved; - }; - --struct file_seq { -- char *buffer; -- uint32_t buffer_size; -- int len; -- char file_name[MAX_LOG_NAME_LEN]; --}; -- --struct ras_rsp { -- uint32_t rsp_data[HIKP_RSP_ALL_DATA_MAX]; -- uint32_t first_pkt_begin; -- uint32_t last_pkt_end; -- uint32_t rsp_data_num; -- uint32_t packet_buffer[MAX_DFX_PACKET_LEN]; -- uint32_t packet_buffer_len; -+struct rasdfx_pkt_header_dw0 { -+ uint32_t version : 8; -+ uint32_t soc_id : 8; -+ uint32_t skt_id : 8; -+ uint32_t die_id : 8; - }; - --struct ras_dump_req_para { -- uint32_t cmd_id; -+struct rasdfx_pkt_header_dw1 { -+ uint32_t module_id : 8; -+ uint32_t submodule_id : 8; -+ uint32_t sequence_num : 8; -+ uint32_t reg_count : 8; - }; - --enum reg_dump_header_index { -- HEAD_MAGIC, -- VERSION, -- CAP_BITS, -- PKT_NUM, -- PKT_LENGTH -+struct rasdfx_pkt { -+ struct rasdfx_pkt_header_dw0 dw0; -+ struct rasdfx_pkt_header_dw1 dw1; -+ uint32_t reserved; -+ uint32_t reg_base[0]; - }; - --enum dfx_packet_index { -- DFX_HEAD_INFO_DW0, -- DFX_HEAD_INFO_DW1, -- DFX_COMMON_MAIN_TEXT_BEGIN = 3 -+struct file_seq { -+ int fd; -+ char *buf; -+ size_t buf_size; -+ size_t buf_offs; - }; - --#define DFX_HEAD_VERSION_OFF 0 --#define DFX_HEAD_SOC_ID_OFF 8 --#define DFX_HEAD_SKT_ID_OFF 16 --#define DFX_HEAD_DIE_ID_OFF 24 --#define DFX_HEAD_MODULE_ID_OFF 0 --#define DFX_HEAD_SUBMODULE_ID_OFF 8 --#define DFX_HEAD_SEQUENCE_NUM_OFF 16 --#define DFX_HEAD_REG_COUNT_OFF 24 -+enum ras_dump_cmd_type { -+ DUMP_DFX, -+ DUMP_CLEAR -+ }; - --#define DFX_DATA_IS_CLEARED 0 -- --#define DFX_FILE_SINGLE_PACKET_HEAD_SIZE 256 --#define DFX_FILE_SINGLE_REG_SIZE 10 -+struct ras_dump_cmd { -+ enum ras_dump_cmd_type cmd_type; -+ uint32_t cmd_id; /* 0: get header info, 1-n: get packet data */ -+}; - -+int ras_data_dump(void); -+int ras_data_clear(void); - --int ras_data_dump(struct tool_ras_cmd *cmd); --int ras_data_clear(struct tool_ras_cmd *cmd); -+#endif /* RAS_DUMP_DATA_H */ - --#endif /* RAS_DUMP_REG_H */ -diff --git a/ras/user_cmd/ras_cmd_dump.c b/ras/user_cmd/ras_cmd_dump.c -index 14fa0cf..a9f1d85 100644 ---- a/ras/user_cmd/ras_cmd_dump.c -+++ b/ras/user_cmd/ras_cmd_dump.c -@@ -13,11 +13,12 @@ - - #include - #include "tool_cmd.h" --#include "ras_tools_include.h" -+#include "hikptdev_plug.h" -+#include "tool_lib.h" - #include "ras_dump_data.h" - --struct tool_ras_cmd g_ras_dump_cmd = { -- .ras_cmd_type = DUMP_DFX, -+struct ras_dump_cmd g_cmd = { -+ .cmd_type = DUMP_DFX - }; - - static int ras_dump_help(struct major_cmd_ctrl *self, const char *argv) -@@ -34,33 +35,21 @@ static int ras_dump_help(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - --static enum ras_dump_cmd_type ras_get_cmd_type(void) --{ -- return g_ras_dump_cmd.ras_cmd_type; --} -- --static void ras_set_cmd_type(enum ras_dump_cmd_type type) --{ -- g_ras_dump_cmd.ras_cmd_type = type; --} -- - static int ras_set_clear(struct major_cmd_ctrl *self, const char *argv) - { - HIKP_SET_USED(self); - HIKP_SET_USED(argv); - -- ras_set_cmd_type(DUMP_CLEAR); -+ g_cmd.cmd_type = DUMP_CLEAR; - return 0; - } - --static int ras_dump_execute_process(void) -+static int ras_dump_execute_process(enum ras_dump_cmd_type cmd_type) - { -- if (ras_get_cmd_type() == DUMP_DFX) -- return ras_data_dump(&g_ras_dump_cmd); -- else if (ras_get_cmd_type() == DUMP_CLEAR) -- return ras_data_clear(&g_ras_dump_cmd); -+ if (cmd_type == DUMP_CLEAR) -+ return ras_data_clear(); - else -- return -EINVAL; -+ return ras_data_dump(); - } - - static void ras_dump_execute(struct major_cmd_ctrl *self) -@@ -75,12 +64,12 @@ static void ras_dump_execute(struct major_cmd_ctrl *self) - "ras dfx data clear error." - }; - -- ret = ras_dump_execute_process(); -+ ret = ras_dump_execute_process(g_cmd.cmd_type); - if (ret == 0) { -- printf("%s\n", suc_msg[ras_get_cmd_type()]); -+ printf("%s\n", suc_msg[g_cmd.cmd_type]); - } else { - snprintf(self->err_str, sizeof(self->err_str), "%s\n", -- err_msg[ras_get_cmd_type()]); -+ err_msg[g_cmd.cmd_type]); - self->err_no = ret; - } - } -diff --git a/ras/user_cmd/ras_tools_include.h b/ras/user_cmd/ras_tools_include.h -deleted file mode 100644 -index 19d9db2..0000000 ---- a/ras/user_cmd/ras_tools_include.h -+++ /dev/null -@@ -1,25 +0,0 @@ --/* -- * 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 RAS_TOOLS_INCLUDE_H --#define RAS_TOOLS_INCLUDE_H -- --#include "hikptdev_plug.h" --#include "tool_lib.h" --#include "ras_common.h" -- --struct tool_ras_cmd { -- enum ras_dump_cmd_type ras_cmd_type; --}; -- --#endif /* RAS_TOOLS_INCLUDE_H */ --- -2.25.1 - diff --git a/0111-hikptool-hccs-Fix-the-usage-description.patch b/0111-hikptool-hccs-Fix-the-usage-description.patch deleted file mode 100644 index 2e9a006861f9a4132d21477a88e578c8ddb08d46..0000000000000000000000000000000000000000 --- a/0111-hikptool-hccs-Fix-the-usage-description.patch +++ /dev/null @@ -1,42 +0,0 @@ -From c5330c4445ef85eaf98376e52e8b6d95f0281369 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 27 Aug 2025 15:21:14 +0800 -Subject: [PATCH 1/2] hikptool:hccs: Fix the usage description - -Fix the usage description to make it more readable. - -Signed-off-by: Huisong Li ---- - hccs/hikp_hccs.c | 14 ++++++++------ - 1 file changed, 8 insertions(+), 6 deletions(-) - -diff --git a/hccs/hikp_hccs.c b/hccs/hikp_hccs.c -index f6ef003..347f76b 100644 ---- a/hccs/hikp_hccs.c -+++ b/hccs/hikp_hccs.c -@@ -71,14 +71,16 @@ static int hikp_hccs_cmd_help(struct major_cmd_ctrl *self, const char *argv) - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); -- printf(" %s, %-25s %s\n", "-c", "--chip_id=", "target chip"); -- printf(" %s, %-25s %s\n", "-d", "--die_id=", "target die"); -- printf(" %s, %-25s %s\n", "-p", "--port_id=", "target port"); -+ printf(" %s, %-25s %s\n", "-c", "--chip_id=", "target chip ID which is from 'X' in chipX"); -+ printf(" %s, %-25s %s\n", "-d", "--die_id=", "target die ID which is from 'Y' in dieY"); -+ printf(" %s, %-25s %s\n", "-p", "--port_id=", "target port ID which from 'Z' in hccsZ"); - printf(" %s\n", - "[-g/--get ]\n" -- " topo : get hccs_typo info, no target specified.\n" -- " fixed_attr : get fixed attributes for port specified by -c X -d X -p X.\n" -- " dfx_info : get dfx info for port specified by -c X -d X -p X.\n"); -+ " topo : get HCCS topology information, no target specified.\n" -+ " fixed_attr : get fixed attributes of one port specified by -c X -d Y -p Z.\n" -+ " dfx_info : get dfx info of one port specified by -c X -d Y -p Z.\n" -+ "\n" -+ " eg: hikptool hccs -g dfx_info -c 0 -d 2 -p 1\n"); - return 0; - } - --- -2.34.1 - diff --git a/0112-hikptool-hccs-enable-HCCS-dfx-for-HIP11.patch b/0112-hikptool-hccs-enable-HCCS-dfx-for-HIP11.patch deleted file mode 100644 index 152e1cecd3b12afb6c4abcb9fd93b519466bc3de..0000000000000000000000000000000000000000 --- a/0112-hikptool-hccs-enable-HCCS-dfx-for-HIP11.patch +++ /dev/null @@ -1,25 +0,0 @@ -From e62fbbf6a8a969f6c9d700b1471d9ab53167584c Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Aug 2025 11:56:49 +0800 -Subject: [PATCH 2/2] hikptool:hccs: enable HCCS dfx for HIP11 - -Signed-off-by: Huisong Li ---- - hikp_init_main.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/hikp_init_main.c b/hikp_init_main.c -index 7b63e9b..acbed8c 100644 ---- a/hikp_init_main.c -+++ b/hikp_init_main.c -@@ -100,6 +100,7 @@ const struct cmd_list_info g_chip_hip09_hip10_cmd_list[] = { - - const struct cmd_list_info g_chip_hip11_cmd_list[] = { - {g_core_ring_cmd_list, HIKP_ARRAY_SIZE(g_core_ring_cmd_list)}, -+ {g_hccs_cmd_list, HIKP_ARRAY_SIZE(g_hccs_cmd_list)}, - {g_log_collect_cmd_list, HIKP_ARRAY_SIZE(g_log_collect_cmd_list)}, - {g_nic_cmd_list, HIKP_ARRAY_SIZE(g_nic_cmd_list)}, - {g_pcie_cmd_list, HIKP_ARRAY_SIZE(g_pcie_cmd_list)}, --- -2.34.1 - diff --git a/0113-hikptool-Add-the-nic_led-command-implementation.patch b/0113-hikptool-Add-the-nic_led-command-implementation.patch deleted file mode 100644 index af2a759839b222dd12458b2c81b27b9ef9d2fe67..0000000000000000000000000000000000000000 --- a/0113-hikptool-Add-the-nic_led-command-implementation.patch +++ /dev/null @@ -1,253 +0,0 @@ -From c046a19e9e7a8faa258ceb2c9aaa9af3a67ba49a Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 8 Oct 2025 11:11:01 +0800 -Subject: [PATCH 1/6] hikptool: Add the nic_led command implementation - -A new command nic_leg has been added, -which supports querying the light configuration -and status of specified ports. - -Usage: hikptool nic_led -i ethxx - -Signed-off-by: veega2022 ---- - hikp_init_main.c | 2 +- - net/hikp_net_lib.h | 1 + - net/nic/nic_led/hikp_nic_led.c | 128 +++++++++++++++++++++++++++++++++ - net/nic/nic_led/hikp_nic_led.h | 64 +++++++++++++++++ - 4 files changed, 194 insertions(+), 1 deletion(-) - create mode 100644 net/nic/nic_led/hikp_nic_led.c - create mode 100644 net/nic/nic_led/hikp_nic_led.h - -diff --git a/hikp_init_main.c b/hikp_init_main.c -index acbed8c..d52d603 100644 ---- a/hikp_init_main.c -+++ b/hikp_init_main.c -@@ -35,7 +35,7 @@ static const char *g_nic_cmd_list[] = { - "nic_dfx", "nic_fd", "nic_fec", "nic_gro", "nic_info", - "nic_log", "nic_mac", "nic_ncsi", "nic_notify_pkt", "nic_port", - "nic_port_fault", "nic_ppp", "nic_qos", "nic_queue", "nic_rss", -- "nic_torus", "nic_xsfp", -+ "nic_torus", "nic_xsfp", "nic_led", - }; - - static const char *g_pcie_cmd_list[] = { -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index aa700ab..f1c40f6 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -82,6 +82,7 @@ enum nic_cmd_type { - GET_NOTIFY_PKT_CMD, - GET_TORUS_INFO_CMD = 0xD, - GET_PORT_FAULT_STATUS = 0xE, -+ GET_PORT_LED_CFG = 0xF, - }; - - enum roh_cmd_type { -diff --git a/net/nic/nic_led/hikp_nic_led.c b/net/nic/nic_led/hikp_nic_led.c -new file mode 100644 -index 0000000..725a451 ---- /dev/null -+++ b/net/nic/nic_led/hikp_nic_led.c -@@ -0,0 +1,128 @@ -+/* -+ * 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 -+#include -+#include -+#include -+#include "hikp_nic_led.h" -+ -+static struct nic_led_cmd_info g_led_cmd_info = {0}; -+ -+static const char *nic_led_cmd_get_speed_status(uint8_t speed_led) -+{ -+ struct speed_status led_speed[] = { -+ {SPEED_1G_BLINK, "1G"}, -+ {SPEED_10G_BLINK, "10G"}, -+ {SPEED_25G_BLINK, "25G"}, -+ {SPEED_40G_BLINK, "40G"}, -+ {SPEED_50G_BLINK, "50G"}, -+ {SPEED_100G_BLINK, "100G"}, -+ {SPEED_200G_BLINK, "200G"}, -+ {SPEED_NO_LINK_BLINK, "NO_LINK"}, -+ {SPEED_TEST_BLINK, "TEST_MODE"}, -+ {SPEED_ERROR_BLINK, "ERROR_MODE"}, -+ }; -+ size_t size = HIKP_ARRAY_SIZE(led_speed); -+ -+ for (size_t i = 0; i < size; i++) { -+ if (speed_led == led_speed[i].status) -+ return led_speed[i].speed; -+ } -+ -+ return "unknown"; -+} -+ -+static bool nic_led_cmd_param_check(struct major_cmd_ctrl *self) -+{ -+ if ((g_led_cmd_info.cmd_flag & LED_PORT_TARGET_BIT) == 0) { -+ self->err_no = -EINVAL; -+ snprintf(self->err_str, sizeof(self->err_str), "Need port id."); -+ return false; -+ } -+ -+ return true; -+} -+ -+static void nic_led_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ struct hikp_cmd_header header = { 0 }; -+ struct nic_led_resp *led_rsp = NULL; -+ struct nic_led_req_para req = { 0 }; -+ struct hikp_cmd_ret *cmd_ret; -+ -+ if (!nic_led_cmd_param_check(self)) -+ return; -+ -+ req.bdf = g_led_cmd_info.port_dev.bdf; -+ hikp_cmd_init(&header, NIC_MOD, GET_PORT_LED_CFG, NIC_LED_CFG_DUMP); -+ cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); -+ self->err_no = hikp_rsp_normal_check(cmd_ret); -+ if (self->err_no) { -+ snprintf(self->err_str, sizeof(self->err_str), "Get led dfx info failed."); -+ goto ERR_OUT; -+ } -+ -+ led_rsp = (struct nic_led_resp *)cmd_ret->rsp_data; -+ printf("%-40s: %u\n", "led_en", led_rsp->led_en); -+ printf("%-40s: %s\n", "speed_led", nic_led_cmd_get_speed_status(led_rsp->speed_led_status)); -+ printf("%-40s: 0x%x(0x%x)\n", "led_err_status(sw_status)", -+ led_rsp->hw_err_mode, led_rsp->sw_err_mode); -+ printf("%-40s: 0x%x(0x%x)\n", "led_locate_status(sw_status)", -+ led_rsp->hw_locate_mode, led_rsp->sw_locate_mode); -+ printf("%-40s: 0x%x(0x%x)\n", "led_active_status(sw_status)", -+ led_rsp->hw_active_mode, led_rsp->sw_active_mode); -+ -+ERR_OUT: -+ hikp_cmd_free(&cmd_ret); -+} -+ -+static int nic_led_cmd_help(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(argv); -+ -+ printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); -+ printf(" %s, %-25s %s\n", "-i", "--interface=", -+ "device target or bdf id, e.g. eth0~3 or 0000:35:00.0"); -+ -+ return 0; -+} -+ -+static int nic_led_get_target(struct major_cmd_ctrl *self, const char *argv) -+{ -+ self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_led_cmd_info.port_dev); -+ if (self->err_no != 0) { -+ snprintf(self->err_str, sizeof(self->err_str), "unknown device!"); -+ return self->err_no; -+ } -+ -+ g_led_cmd_info.cmd_flag |= LED_PORT_TARGET_BIT; -+ -+ return 0; -+} -+ -+static void cmd_nic_led_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = nic_led_cmd_execute; -+ -+ cmd_option_register("-h", "--help", false, nic_led_cmd_help); -+ cmd_option_register("-i", "--interface", true, nic_led_get_target); -+} -+ -+HIKP_CMD_DECLARE("nic_led", "dump led configuration of port!", cmd_nic_led_init); -diff --git a/net/nic/nic_led/hikp_nic_led.h b/net/nic/nic_led/hikp_nic_led.h -new file mode 100644 -index 0000000..4f05ae5 ---- /dev/null -+++ b/net/nic/nic_led/hikp_nic_led.h -@@ -0,0 +1,64 @@ -+/* -+ * 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_NIC_LED_H -+#define HIKP_NIC_LED_H -+ -+#include "hikp_net_lib.h" -+ -+enum nic_led_sub_cmd_type { -+ NIC_LED_CFG_DUMP = 1, -+}; -+ -+#define LED_PORT_TARGET_BIT HI_BIT(0) -+ -+struct speed_status { -+ uint8_t status; -+ const char *speed; -+}; -+ -+#define SPEED_1G_BLINK 0x0 -+#define SPEED_10G_BLINK 0x1 -+#define SPEED_25G_BLINK 0x8 -+#define SPEED_40G_BLINK 0x2 -+#define SPEED_50G_BLINK 0x6 -+#define SPEED_100G_BLINK 0xa -+#define SPEED_200G_BLINK 0x16 -+#define SPEED_NO_LINK_BLINK 0x10 -+#define SPEED_TEST_BLINK 0xe -+#define SPEED_ERROR_BLINK 0x9 -+ -+struct nic_led_req_para { -+ struct bdf_t bdf; -+ uint32_t rsvd[2]; -+}; -+ -+struct nic_led_resp { -+ uint8_t led_en; -+ uint8_t hw_err_mode; -+ uint8_t hw_locate_mode; -+ uint8_t hw_active_mode; -+ uint8_t sw_err_mode; -+ uint8_t sw_locate_mode; -+ uint8_t sw_active_mode; -+ uint8_t speed_led_status; -+ -+ uint32_t rsvd[58]; -+}; -+ -+struct nic_led_cmd_info { -+ struct tool_target port_dev; -+ uint32_t cmd_flag; -+}; -+ -+#endif /* HIKP_NIC_LED_H */ --- -2.45.0.windows.1 - diff --git a/0114-hikptool-Add-dfx-to-roce_dfx_sta.patch b/0114-hikptool-Add-dfx-to-roce_dfx_sta.patch deleted file mode 100644 index 2b4a708c7ea7eacc7882f06cf4b2862d44eeba68..0000000000000000000000000000000000000000 --- a/0114-hikptool-Add-dfx-to-roce_dfx_sta.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 506656a17485d36cfcb530891ce440dbb86008c6 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 8 Oct 2025 11:14:00 +0800 -Subject: [PATCH 2/6] hikptool: Add dfx to roce_dfx_sta - -Add two dfx to roce_dfx_sta commands: - -LENGTH_ERR - this is for scenarios where the incoming packet size -exceeds PMTU. -RQ_RNR - this is for RNR scenarios on server side. -These two dfx are mostly added for UD since in this case packets will -be silently dropped, but they also apply to RC. - -Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com ---- - net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c b/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c -index b74507c..98337a3 100644 ---- a/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c -+++ b/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c -@@ -59,6 +59,8 @@ static const char *g_dfx_sta_reg_name[] = { - "PKT_RNR_STA", - "PKT_RTY_STA", - "MSN_RTY_STA", -+ "LENGTH_ERR", -+ "RQ_RNR", - }; - - static int hikp_roce_dfx_sta_get_data(struct hikp_cmd_ret **cmd_ret, --- -2.45.0.windows.1 - diff --git a/0115-hikptool-Add-new-dump-ncsi-table-entry-configuration.patch b/0115-hikptool-Add-new-dump-ncsi-table-entry-configuration.patch deleted file mode 100644 index e819796438df11fa2f6c9164ab19cac4971e9f0b..0000000000000000000000000000000000000000 --- a/0115-hikptool-Add-new-dump-ncsi-table-entry-configuration.patch +++ /dev/null @@ -1,472 +0,0 @@ -From e74538f5d6e92872a811e76cb6dd48461f396d67 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 8 Oct 2025 11:19:20 +0800 -Subject: [PATCH 3/6] hikptool: Add new dump ncsi table entry configuration - -The nic_ncsi command has been updated with -a new -d option, which supports dumping the -configuration of specified module entries. - -The usage is as follows: - -hikptool nic_ncsi -i ethxx -d [module name] - -Supported module names include: tx_mac, smac, dmac, etc. - -Signed-off-by: veega2022 ---- - net/hikp_net_lib.h | 9 ++ - net/nic/nic_ncsi/hikp_nic_ncsi.c | 245 +++++++++++++++++++++++++++++-- - net/nic/nic_ncsi/hikp_nic_ncsi.h | 108 +++++++++++++- - 3 files changed, 352 insertions(+), 10 deletions(-) - -diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h -index f1c40f6..e855d4e 100644 ---- a/net/hikp_net_lib.h -+++ b/net/hikp_net_lib.h -@@ -83,6 +83,7 @@ enum nic_cmd_type { - GET_TORUS_INFO_CMD = 0xD, - GET_PORT_FAULT_STATUS = 0xE, - GET_PORT_LED_CFG = 0xF, -+ GET_NCSI_TABLE_ENTRY_INFO_CMD = 0x10, - }; - - enum roh_cmd_type { -@@ -120,6 +121,14 @@ enum nic_get_ncsi_sub_cmd { - NIC_NCSI_GET_DFX_INFO, - }; - -+enum nic_get_ncsi_entry_sub_cmd { -+ NIC_NCSI_GET_BUF_STATUS = 1, -+ NIC_NCSI_GET_VLAN_FILTER_TBL, -+ NIC_NCSI_GET_ETHER_FILTER_TBL, -+ NIC_NCSI_GET_DMAC_FILTER_TBL, -+ NIC_NCSI_GET_SMAC_FILTER_TBL, -+}; -+ - #define HIKP_MAX_PF_NUM 8 - #define HIKP_NIC_MAX_FUNC_NUM 256 - -diff --git a/net/nic/nic_ncsi/hikp_nic_ncsi.c b/net/nic/nic_ncsi/hikp_nic_ncsi.c -index 955e456..44d8e53 100644 ---- a/net/nic/nic_ncsi/hikp_nic_ncsi.c -+++ b/net/nic/nic_ncsi/hikp_nic_ncsi.c -@@ -48,18 +48,12 @@ static void nic_ncsi_cmd_print_dfx_info(struct nic_ncsi_cmd_resp *ncsi_info) - printf("\tncsi_ub_to_eth_lldp: %u\n", ncsi_info->ncsi_dfx.ncsi_ub_to_eth_lldp); - } - --static void nic_ncsi_cmd_execute(struct major_cmd_ctrl *self) -+static void nic_ncsi_cmd_get_cnt_dfx(struct major_cmd_ctrl *self) - { - struct hikp_cmd_ret *cmd_resp = NULL; - struct hikp_cmd_header req_header = {0}; - struct nic_ncsi_cmd_req ncsi_req = {0}; - -- if (!g_ncsi_cmd_info.port_flag) { -- self->err_no = -EINVAL; -- snprintf(self->err_str, sizeof(self->err_str), "Need port id."); -- return; -- } -- - memcpy(&ncsi_req.bdf, &g_ncsi_cmd_info.target.bdf, sizeof(ncsi_req.bdf)); - hikp_cmd_init(&req_header, NIC_MOD, GET_NCSI_INFO_CMD, NIC_NCSI_GET_DFX_INFO); - cmd_resp = hikp_cmd_alloc(&req_header, &ncsi_req, sizeof(ncsi_req)); -@@ -75,6 +69,226 @@ ERR_OUT: - hikp_cmd_free(&cmd_resp); - } - -+static int nic_ncsi_cmd_get_entry_response_data(struct major_cmd_ctrl *self, uint32_t sub_cmd, -+ struct hikp_cmd_ret **cmd_resp) -+{ -+ struct hikp_cmd_header req_header = {0}; -+ struct nic_ncsi_cmd_req ncsi_req = {0}; -+ -+ memcpy(&ncsi_req.bdf, &g_ncsi_cmd_info.target.bdf, sizeof(ncsi_req.bdf)); -+ hikp_cmd_init(&req_header, NIC_MOD, GET_NCSI_TABLE_ENTRY_INFO_CMD, sub_cmd); -+ *cmd_resp = hikp_cmd_alloc(&req_header, &ncsi_req, sizeof(ncsi_req)); -+ self->err_no = hikp_rsp_normal_check(*cmd_resp); -+ if (self->err_no) -+ snprintf(self->err_str, sizeof(self->err_str), -+ "Get ncsi filter(0x%x) info failed.", sub_cmd); -+ -+ return self->err_no; -+} -+ -+static void nic_ncsi_cmd_show_tx_buf_status(struct major_cmd_ctrl *self) -+{ -+ struct nic_ncsi_tx_buf_resp *tx_buf_rsp; -+ struct hikp_cmd_ret *cmd_resp = NULL; -+ int ret; -+ -+ ret = nic_ncsi_cmd_get_entry_response_data(self, NIC_NCSI_GET_BUF_STATUS, &cmd_resp); -+ if (ret) -+ goto ERR_OUT; -+ -+ tx_buf_rsp = (struct nic_ncsi_tx_buf_resp *)cmd_resp->rsp_data; -+ printf("ncsi tx buffer status:\n"); -+ printf("%-30s: %u\n", "tx_buf_empty", tx_buf_rsp->tx_buf_empty); -+ printf("%-30s: %u\n", "ctrl_sof", tx_buf_rsp->ctrl_sof); -+ printf("%-30s: %u\n", "ctrl_eof", tx_buf_rsp->ctrl_eof); -+ printf("%-30s: %u\n", "ctrl_err", tx_buf_rsp->ctrl_err); -+ printf("%-30s: %u\n", "ctrl_byte_sel", tx_buf_rsp->ctrl_byte_sel); -+ -+ERR_OUT: -+ hikp_cmd_free(&cmd_resp); -+} -+ -+static void nic_ncsi_cmd_show_vlan_filter_cfg(struct major_cmd_ctrl *self) -+{ -+ struct nic_ncsi_vlan_filter_resp *vlan_rsp = NULL; -+ struct hikp_cmd_ret *cmd_resp = NULL; -+ int ret; -+ -+ ret = nic_ncsi_cmd_get_entry_response_data(self, NIC_NCSI_GET_VLAN_FILTER_TBL, &cmd_resp); -+ if (ret) -+ goto ERR_OUT; -+ -+ vlan_rsp = (struct nic_ncsi_vlan_filter_resp *)cmd_resp->rsp_data; -+ printf("vlan filter config:\n"); -+ printf("%-30s: 0x%x\n", "filter_enable",vlan_rsp->filter_en_map); -+ printf("%-30s: 0x%x\n", "filter_type", vlan_rsp->filer_type); -+ printf("%-30s: 0x%x\n", "entry_to_bmc", vlan_rsp->entry_to_bmc_map); -+ printf("%-30s: 0x%x\n", "entry_to_bmc_only", vlan_rsp->entry_to_bmc_only_map); -+ -+ printf("enabled entries:\n"); -+ printf("%5s |%10s\n", "id", "vlan_id"); -+ for (uint32_t i = 0; i < NIC_NCSI_VLAN_ENTRY_NUM; i++) { -+ if (!vlan_rsp->entry[i].entry_en) -+ continue; -+ printf("%5u |%10u\n", i, vlan_rsp->entry[i].vlan_id); -+ } -+ -+ERR_OUT: -+ hikp_cmd_free(&cmd_resp); -+} -+ -+static void nic_ncsi_cmd_show_ether_filter_cfg(struct major_cmd_ctrl *self) -+{ -+ struct nic_ncsi_ether_filter_resp *ether_rsp = NULL; -+ struct hikp_cmd_ret *cmd_resp = NULL; -+ int ret; -+ -+ ret = nic_ncsi_cmd_get_entry_response_data(self, NIC_NCSI_GET_ETHER_FILTER_TBL, &cmd_resp); -+ if (ret) -+ goto ERR_OUT; -+ -+ ether_rsp = (struct nic_ncsi_ether_filter_resp *)cmd_resp->rsp_data; -+ printf("ether filter config:\n"); -+ printf("%-30s: 0x%x\n", "filter_enable", ether_rsp->ether_en_map); -+ printf("%-30s: 0x%x\n", "entry_to_bmc", ether_rsp->entry_to_bmc_map); -+ printf("%-30s: 0x%x\n", "entry_to_bmc_only", ether_rsp->entry_to_bmc_only_map); -+ -+ printf("enabled entries:\n"); -+ printf("%5s |%13s\n", "id", "ether_type"); -+ for (uint32_t i = 0; i < NIC_NCSI_ETHER_ENTRY_NUM; i++) { -+ if (!ether_rsp->entry[i].entry_en) -+ continue; -+ -+ printf("%5u |%13u\n", i, ether_rsp->entry[i].entry_type); -+ } -+ -+ERR_OUT: -+ hikp_cmd_free(&cmd_resp); -+} -+ -+static void nic_ncsi_cmd_show_dmac_filter_cfg(struct major_cmd_ctrl *self) -+{ -+ struct nic_ncsi_dmac_filter_resp *dmac_rsp = NULL; -+ struct hikp_cmd_ret *cmd_resp = NULL; -+ int ret; -+ -+ ret = nic_ncsi_cmd_get_entry_response_data(self, NIC_NCSI_GET_DMAC_FILTER_TBL, &cmd_resp); -+ if (ret) -+ goto ERR_OUT; -+ -+ dmac_rsp = (struct nic_ncsi_dmac_filter_resp *)cmd_resp->rsp_data; -+ printf("dmac filter config:\n"); -+ printf("%-30s: 0x%x\n", "filter_enable", dmac_rsp->dmac_en_map); -+ printf("%-30s: 0x%x\n", "entry_to_bmc", dmac_rsp->dmac_to_bmc); -+ printf("%-30s: 0x%x\n", "entry_to_bmc_only", dmac_rsp->dmac_to_bmc_only); -+ -+ printf("enabled entries:\n"); -+ printf("%5s |%10s |%10s |%13s\n", "id", "type", "entry_h", "entry_l"); -+ for (uint32_t i = 0; i < NIC_NCSI_DMAC_ENTRY_NUM; i++) { -+ if (!dmac_rsp->entry[i].entry_en) -+ continue; -+ printf("%5u |%10u |%#10x |%#13x\n", -+ i, dmac_rsp->entry[i].entry_type, -+ dmac_rsp->entry[i].entry_cfg_h, dmac_rsp->entry[i].entry_cfg_l); -+ } -+ -+ printf("multicast_filter: %16s(%u)%15s(%u)%16s(%u)%11s(%u)%15s(%u)\n", -+ "ipv6_neighbor", dmac_rsp->mc_ipv6_neighbor_en, -+ "ipv6_route", dmac_rsp->mc_ipv6_route_en, -+ "dhcpv6_relay", dmac_rsp->mc_dhcpv6_relay_en, -+ "to_bmc", dmac_rsp->mc_to_bmc, "to_bmc_only", dmac_rsp->mc_to_bmc_only); -+ -+ printf("broadcast_filter: %16s(%u)%15s(%u)%16s(%u)%11s(%u)%15s(%u)%15s(%u)\n", -+ "arp", dmac_rsp->bc_arp_en, "dhcp_client", dmac_rsp->bc_dhcp_client, -+ "dhcp_server", dmac_rsp->bc_dhcp_server, "netbios", dmac_rsp->bc_netbios_en, -+ "to_bmc", dmac_rsp->bc_to_bmc, "to_bmc_only", dmac_rsp->bc_to_bmc_only); -+ -+ERR_OUT: -+ hikp_cmd_free(&cmd_resp); -+} -+ -+static void nic_ncsi_cmd_show_smac_filter_cfg(struct major_cmd_ctrl *self) -+{ -+ struct nic_ncsi_smac_filter_resp *smac_rsp = NULL; -+ struct hikp_cmd_ret *cmd_resp = NULL; -+ int ret; -+ -+ ret = nic_ncsi_cmd_get_entry_response_data(self, NIC_NCSI_GET_SMAC_FILTER_TBL, &cmd_resp); -+ if (ret) -+ goto ERR_OUT; -+ -+ smac_rsp = (struct nic_ncsi_smac_filter_resp *)cmd_resp->rsp_data; -+ printf("smac filter config:\n"); -+ printf("%-30s: 0x%x\n", "filter_enable", smac_rsp->smac_en_map); -+ printf("%-30s: 0x%x\n", "pt_pkt_enable", smac_rsp->pt_pkt_en); -+ -+ printf("enabled entries:\n"); -+ printf("%5s |%10s |%15s |%10s |%13s\n", -+ "id", "dport", "entry_to_mac", "entry_h", "entry_l"); -+ for (uint32_t i = 0; i < NIC_NCSI_SMAC_ENTRY_NUM; i++) { -+ if (!smac_rsp->entry[i].entry_en) -+ continue; -+ printf("%5u |%10u |%15u |%#10x |%#13x\n", -+ i, smac_rsp->entry[i].entry_dport, -+ smac_rsp->entry[i].entry_to_mac, smac_rsp->entry[i].entry_cfg_h, -+ smac_rsp->entry[i].entry_cfg_l); -+ } -+ -+ERR_OUT: -+ hikp_cmd_free(&cmd_resp); -+} -+ -+static void nic_ncsi_cmd_get_filter_cfg(struct major_cmd_ctrl *self) -+{ -+ struct ncsi_dump_mod_proc mod_info[] = { -+ {"tx_buf", nic_ncsi_cmd_show_tx_buf_status}, -+ {"vlan", nic_ncsi_cmd_show_vlan_filter_cfg}, -+ {"ether", nic_ncsi_cmd_show_ether_filter_cfg}, -+ {"dmac", nic_ncsi_cmd_show_dmac_filter_cfg}, -+ {"smac", nic_ncsi_cmd_show_smac_filter_cfg}, -+ }; -+ uint32_t size = HIKP_ARRAY_SIZE(mod_info); -+ -+ if (!g_ncsi_cmd_info.module_name) { -+ self->err_no = -EPERM; -+ snprintf(self->err_str, sizeof(self->err_str), "dump module is null."); -+ return; -+ } -+ -+ if (strcmp(g_ncsi_cmd_info.module_name, "all") == 0) { -+ for (uint32_t i = 0; i < size; i++) { -+ mod_info[i].show(self); -+ printf("----------------------------------" -+ "------------------------------------------\n"); -+ } -+ } else { -+ for (uint32_t i = 0; i < size; i++) { -+ if (strcmp(g_ncsi_cmd_info.module_name, mod_info[i].name) != 0) -+ continue; -+ -+ return mod_info[i].show(self); -+ } -+ -+ self->err_no = -EINVAL; -+ snprintf(self->err_str, sizeof(self->err_str), -+ "Invalid filter conifg module: %s.", g_ncsi_cmd_info.module_name); -+ } -+} -+ -+static void nic_ncsi_cmd_execute(struct major_cmd_ctrl *self) -+{ -+ if ((g_ncsi_cmd_info.cmd_flag & NCSI_PORT_TARGET_BIT) == 0) { -+ self->err_no = -EINVAL; -+ snprintf(self->err_str, sizeof(self->err_str), "Need port id."); -+ return; -+ } -+ -+ if (g_ncsi_cmd_info.cmd_flag & NCSI_DUMP_MODULE_BIT) -+ nic_ncsi_cmd_get_filter_cfg(self); -+ else -+ nic_ncsi_cmd_get_cnt_dfx(self); -+} -+ - static int nic_ncsi_cmd_get_port_info(struct major_cmd_ctrl *self, const char *argv) - { - self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_ncsi_cmd_info.target); -@@ -82,7 +296,17 @@ static int nic_ncsi_cmd_get_port_info(struct major_cmd_ctrl *self, const char *a - snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); - return self->err_no; - } -- g_ncsi_cmd_info.port_flag = true; -+ g_ncsi_cmd_info.cmd_flag |= NCSI_PORT_TARGET_BIT; -+ -+ return 0; -+} -+ -+static int nic_ncsi_cmd_get_dump_mode(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(self); -+ -+ g_ncsi_cmd_info.cmd_flag |= NCSI_DUMP_MODULE_BIT; -+ g_ncsi_cmd_info.module_name = argv; - - return 0; - } -@@ -97,6 +321,8 @@ static int nic_ncsi_cmd_show_help(struct major_cmd_ctrl *self, const char *argv) - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); - printf(" %s, %-25s %s\n", "-i", "--interface=", - "device target or bdf id, e.g. eth0~3 or 0000:35:00.0"); -+ printf(" %s, %-25s %s\n", "-d", "--dump", "specify the module name for the dump " -+ "e.g. tx_buf, vlan, ether, dmac, smac, all"); - printf("\n"); - - return 0; -@@ -124,12 +350,13 @@ static void cmd_nic_get_ncsi_init(void) - { - struct major_cmd_ctrl *major_cmd = get_major_cmd(); - -- g_ncsi_cmd_info.port_flag = false; -+ g_ncsi_cmd_info.cmd_flag = 0; - major_cmd->option_count = 0; - major_cmd->execute = nic_ncsi_cmd_execute; - - cmd_option_register("-h", "--help", false, nic_ncsi_cmd_show_help); - cmd_option_register("-i", "--interface", true, nic_ncsi_cmd_get_port_info); -+ cmd_option_register("-d", "--dump", true, nic_ncsi_cmd_get_dump_mode); - } - - HIKP_CMD_DECLARE("nic_ncsi", "query nic port ncsi information", cmd_nic_get_ncsi_init); -diff --git a/net/nic/nic_ncsi/hikp_nic_ncsi.h b/net/nic/nic_ncsi/hikp_nic_ncsi.h -index 56ab653..dfcf974 100644 ---- a/net/nic/nic_ncsi/hikp_nic_ncsi.h -+++ b/net/nic/nic_ncsi/hikp_nic_ncsi.h -@@ -44,14 +44,120 @@ struct nic_ncsi_cmd_resp { - uint32_t rsv1[50]; /* max resp data: 240 Bytes */ - }; - -+struct nic_ncsi_tx_buf_resp { -+ uint8_t tx_buf_empty : 1; -+ uint8_t ctrl_sof : 1; -+ uint8_t ctrl_eof : 1; -+ uint8_t ctrl_err : 1; -+ uint8_t ctrl_byte_sel : 2; -+ uint8_t rsv0 : 2; -+ uint8_t rsv1[7]; -+ uint32_t rsv2[58]; /* max resp data: 240 Bytes */ -+}; -+ -+#define NIC_NCSI_VLAN_ENTRY_NUM 16 -+struct ncsi_vlan_entry { -+ uint32_t vlan_id : 16; -+ uint32_t entry_en : 1; -+ uint32_t rsv : 15; -+}; -+ -+struct nic_ncsi_vlan_filter_resp { -+ uint32_t filter_en_map : 16; -+ uint32_t filer_type : 8; -+ uint32_t rsv0 : 8; -+ uint32_t entry_to_bmc_only_map : 16; -+ uint32_t entry_to_bmc_map : 16; -+ -+ struct ncsi_vlan_entry entry[NIC_NCSI_VLAN_ENTRY_NUM]; -+ uint32_t rsv1[42]; /* max resp data: 240 Bytes */ -+}; -+ -+#define NIC_NCSI_ETHER_ENTRY_NUM 4 -+struct ncsi_ether_entry { -+ uint32_t entry_type : 16; -+ uint32_t entry_en : 1; -+ uint32_t rsv : 15; -+}; -+ -+struct nic_ncsi_ether_filter_resp { -+ uint32_t ether_en_map : 4; -+ uint32_t entry_to_bmc_only_map : 4; -+ uint32_t entry_to_bmc_map : 4; -+ uint32_t rsv0 : 20; -+ uint32_t rsv1; -+ struct ncsi_ether_entry entry[NIC_NCSI_ETHER_ENTRY_NUM]; -+ uint32_t rsv2[54]; /* max resp data: 240 Bytes */ -+}; -+ -+#define NIC_NCSI_DMAC_ENTRY_NUM 8 -+struct ncsi_dmac_entry { -+ uint32_t entry_cfg_l; -+ uint32_t entry_cfg_h : 16; -+ uint32_t entry_type : 2; -+ uint32_t entry_en : 1; -+ uint32_t rsv : 13; -+}; -+ -+struct nic_ncsi_dmac_filter_resp { -+ uint32_t dmac_en_map : 8; -+ uint32_t dmac_to_bmc_only : 8; -+ uint32_t dmac_to_bmc : 8; -+ uint32_t rsv0 : 8; -+ uint32_t mc_ipv6_neighbor_en : 1; -+ uint32_t mc_ipv6_route_en : 1; -+ uint32_t mc_dhcpv6_relay_en : 1; -+ uint32_t mc_to_bmc : 1; -+ uint32_t mc_to_bmc_only : 1; -+ uint32_t rsv1 : 27; -+ uint32_t bc_arp_en : 1; -+ uint32_t bc_dhcp_client : 1; -+ uint32_t bc_dhcp_server : 1; -+ uint32_t bc_netbios_en : 1; -+ uint32_t bc_to_bmc : 1; -+ uint32_t bc_to_bmc_only : 1; -+ uint32_t rsv2 : 26; -+ uint32_t rsv3; -+ struct ncsi_dmac_entry entry[NIC_NCSI_DMAC_ENTRY_NUM]; -+ uint32_t rsv4[40]; /* max resp data: 240 Bytes */ -+}; -+ -+#define NIC_NCSI_SMAC_ENTRY_NUM 8 -+struct ncsi_smac_entry { -+ uint32_t entry_cfg_l; -+ uint32_t entry_cfg_h : 16; -+ uint32_t entry_en : 1; -+ uint32_t entry_dport : 3; -+ uint32_t entry_to_mac : 1; -+ uint32_t rsv : 11; -+}; -+ -+struct nic_ncsi_smac_filter_resp { -+ uint32_t smac_en_map : 8; -+ uint32_t pt_pkt_en : 1; -+ uint32_t rsv0 : 23; -+ uint32_t rsv1; -+ struct ncsi_smac_entry entry[NIC_NCSI_SMAC_ENTRY_NUM]; -+ uint32_t rsv2[42]; /* max resp data: 240 Bytes */ -+}; -+ - struct nic_ncsi_cmd_req { - struct bdf_t bdf; - uint32_t rsv0[30]; /* max req data: 128 Bytes */ - }; - -+struct ncsi_dump_mod_proc { -+ const char *name; -+ void (*show)(struct major_cmd_ctrl *self); -+}; -+ -+#define NCSI_PORT_TARGET_BIT HI_BIT(0) -+#define NCSI_DUMP_MODULE_BIT HI_BIT(1) -+ - struct nic_ncsi_cmd_info { - struct tool_target target; -- bool port_flag; -+ uint32_t cmd_flag; -+ const char *module_name; - }; - - struct nic_ncsi_collect_param { --- -2.45.0.windows.1 - diff --git a/0116-hikptool-Optimize-one-click-log-collection-supported.patch b/0116-hikptool-Optimize-one-click-log-collection-supported.patch deleted file mode 100644 index 6516bd5ff8ecb06d970a187557940228b76cf670..0000000000000000000000000000000000000000 --- a/0116-hikptool-Optimize-one-click-log-collection-supported.patch +++ /dev/null @@ -1,241 +0,0 @@ -From ac7b14bfbff739c826e70b7f2087d0dfee5a27a1 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 8 Oct 2025 11:23:29 +0800 -Subject: [PATCH 4/6] hikptool: Optimize one-click log collection supported - commands - -Depending on the hardware platform, -the corresponding supported collection -commands are displayed, while unsupported -commands are no longer shown and input is -also not supported. - -Signed-off-by: veega2022 ---- - info_collect/hikp_collect_main.c | 165 ++++++++++++++++++++++++++----- - 1 file changed, 143 insertions(+), 22 deletions(-) - -diff --git a/info_collect/hikp_collect_main.c b/info_collect/hikp_collect_main.c -index 46120a5..3571850 100644 ---- a/info_collect/hikp_collect_main.c -+++ b/info_collect/hikp_collect_main.c -@@ -126,7 +126,7 @@ static int info_collect_all(struct major_cmd_ctrl *self, const char *argv) - return 0; - } - --static void collect_all_log(void) -+static void collect_all_log_hip09_10(void) - { - collect_pcie_info(); - collect_acc_log(); -@@ -137,9 +137,49 @@ static void collect_all_log(void) - collect_sata_log(); - collect_serdes_log(); - collect_socip_log(); -+} -+ -+static void collect_all_log_hip11(void) -+{ -+ collect_pcie_info(); -+ collect_imp_log(); -+ collect_nic_log(); -+ collect_roce_log(); -+ collect_sata_log(); -+ collect_serdes_log(); -+ collect_socip_log(); - collect_sdma_log(); - } - -+static void collect_all_log_hip12(void) -+{ -+ collect_pcie_info(); -+ collect_acc_log(); -+ collect_serdes_log(); -+ collect_socip_log(); -+} -+ -+static void collect_all_log(void) -+{ -+ uint32_t chip_type = get_chip_type(); -+ -+ switch (chip_type) { -+ case CHIP_HIP09: -+ case CHIP_HIP10: -+ case CHIP_HIP10C: -+ collect_all_log_hip09_10(); -+ break; -+ case CHIP_HIP11: -+ collect_all_log_hip11(); -+ break; -+ case CHIP_HIP12: -+ collect_all_log_hip12(); -+ break; -+ default: -+ break; -+ } -+} -+ - static int info_collect_excute_funs_call(uint32_t collect_type) - { - const char *type_name[] = {"acc", "imp", "nic", "pcie", "roce", "sas", -@@ -199,7 +239,6 @@ static int info_collect_excute_funs_call(uint32_t collect_type) - return ret; - } - -- - static void info_collect_execute(struct major_cmd_ctrl *self) - { - const char *suc_msg[] = { -@@ -243,38 +282,32 @@ static void info_collect_execute(struct major_cmd_ctrl *self) - } - } - --static int info_collect_help(struct major_cmd_ctrl *self, const char *argv) -+static int info_collect_help_hip09_10(struct major_cmd_ctrl *self, const char *argv) - { - HIKP_SET_USED(argv); - - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf("\n Options:\n\n"); -- printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); -- printf(" %s, %-25s %s\n", "-acc", "--acc", "collect acc info\n"); -- printf(" %s, %-25s %s\n", "-imp", "--imp", "collect imp info\n"); -- printf(" %s, %-25s %s\n", "-nic", "--nic", "collect nic info\n"); -- printf(" %s, %-25s %s\n", "-pcie", "--pcie", "collect pcie info\n"); -- printf(" %s, %-25s %s\n", "-roce", "--roce", "collect roce info\n"); -- printf(" %s, %-25s %s\n", "-sas", "--sas", "collect sas info\n"); -- printf(" %s, %-25s %s\n", "-sata", "--sata", "collect sata info\n"); -- printf(" %s, %-25s %s\n", "-serdes", "--serdes", "collect serdes info\n"); -- printf(" %s, %-25s %s\n", "-socip", "--socip", "collect socip info\n"); -- printf(" %s, %-25s %s\n", "-sdma", "--sdma", "collect sdma info\n"); -- printf(" %s, %-25s %s\n", "-all", "--all", "collect all info\n"); -+ printf(" %-10s, %-25s %s\n", "-h", "--help", "display this help and exit"); -+ printf(" %-10s, %-25s %s\n", "-acc", "--acc", "collect acc info"); -+ printf(" %-10s, %-25s %s\n", "-imp", "--imp", "collect imp info"); -+ printf(" %-10s, %-25s %s\n", "-nic", "--nic", "collect nic info"); -+ printf(" %-10s, %-25s %s\n", "-pcie", "--pcie", "collect pcie info"); -+ printf(" %-10s, %-25s %s\n", "-roce", "--roce", "collect roce info"); -+ printf(" %-10s, %-25s %s\n", "-sas", "--sas", "collect sas info"); -+ printf(" %-10s, %-25s %s\n", "-sata", "--sata", "collect sata info"); -+ printf(" %-10s, %-25s %s\n", "-serdes", "--serdes", "collect serdes info"); -+ printf(" %-10s, %-25s %s\n", "-socip", "--socip", "collect socip info"); -+ printf(" %-10s, %-25s %s\n", "-all", "--all", "collect all info"); - printf("\n"); - - return 0; - } - --static void cmd_info_collect_init(void) -+static void info_collect_cmd_register_hip09_10(void) - { -- struct major_cmd_ctrl *major_cmd = get_major_cmd(); -- -- major_cmd->option_count = 0; -- major_cmd->execute = info_collect_execute; -- -- cmd_option_register("-h", "--help", false, info_collect_help); -+ cmd_option_register("-h", "--help", false, info_collect_help_hip09_10); - cmd_option_register("-acc", "--acc", false, info_collect_acc); - cmd_option_register("-imp", "--imp", false, info_collect_imp); - cmd_option_register("-nic", "--nic", false, info_collect_nic); -@@ -284,8 +317,96 @@ static void cmd_info_collect_init(void) - cmd_option_register("-sata", "--sata", false, info_collect_sata); - cmd_option_register("-serdes", "--serdes", false, info_collect_serdes); - cmd_option_register("-socip", "--socip", false, info_collect_socip); -+ cmd_option_register("-all", "--all", false, info_collect_all); -+} -+ -+static int info_collect_help_hip11(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(argv); -+ -+ printf("\n Usage: %s\n", self->cmd_ptr->name); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %-10s, %-25s %s\n", "-h", "--help", "display this help and exit"); -+ printf(" %-10s, %-25s %s\n", "-imp", "--imp", "collect imp info"); -+ printf(" %-10s, %-25s %s\n", "-nic", "--nic", "collect nic info"); -+ printf(" %-10s, %-25s %s\n", "-pcie", "--pcie", "collect pcie info"); -+ printf(" %-10s, %-25s %s\n", "-roce", "--roce", "collect roce info"); -+ printf(" %-10s, %-25s %s\n", "-sata", "--sata", "collect sata info"); -+ printf(" %-10s, %-25s %s\n", "-serdes", "--serdes", "collect serdes info"); -+ printf(" %-10s, %-25s %s\n", "-socip", "--socip", "collect socip info"); -+ printf(" %-10s, %-25s %s\n", "-sdma", "--sdma", "collect sdma info"); -+ printf(" %-10s, %-25s %s\n", "-all", "--all", "collect all info"); -+ printf("\n"); -+ -+ return 0; -+} -+ -+static void info_collect_cmd_register_hip11(void) -+{ -+ cmd_option_register("-h", "--help", false, info_collect_help_hip11); -+ cmd_option_register("-imp", "--imp", false, info_collect_imp); -+ cmd_option_register("-nic", "--nic", false, info_collect_nic); -+ cmd_option_register("-pcie", "--pcie", false, info_collect_pcie); -+ cmd_option_register("-roce", "--roce", false, info_collect_roce); -+ cmd_option_register("-sata", "--sata", false, info_collect_sata); -+ cmd_option_register("-serdes", "--serdes", false, info_collect_serdes); -+ cmd_option_register("-socip", "--socip", false, info_collect_socip); - cmd_option_register("-sdma", "--sdma", false, info_collect_sdma); - cmd_option_register("-all", "--all", false, info_collect_all); - } - -+static int info_collect_help_hip12(struct major_cmd_ctrl *self, const char *argv) -+{ -+ HIKP_SET_USED(argv); -+ -+ printf("\n Usage: %s\n", self->cmd_ptr->name); -+ printf("\n %s\n", self->cmd_ptr->help_info); -+ printf("\n Options:\n\n"); -+ printf(" %-10s, %-25s %s\n", "-h", "--help", "display this help and exit"); -+ printf(" %-10s, %-25s %s\n", "-acc", "--acc", "collect acc info"); -+ printf(" %-10s, %-25s %s\n", "-pcie", "--pcie", "collect pcie info"); -+ printf(" %-10s, %-25s %s\n", "-serdes", "--serdes", "collect serdes info"); -+ printf(" %-10s, %-25s %s\n", "-socip", "--socip", "collect socip info"); -+ printf(" %-10s, %-25s %s\n", "-all", "--all", "collect all info"); -+ printf("\n"); -+ -+ return 0; -+} -+ -+static void info_collect_cmd_register_hip12(void) -+{ -+ cmd_option_register("-h", "--help", false, info_collect_help_hip12); -+ cmd_option_register("-acc", "--acc", false, info_collect_acc); -+ cmd_option_register("-pcie", "--pcie", false, info_collect_pcie); -+ cmd_option_register("-serdes", "--serdes", false, info_collect_serdes); -+ cmd_option_register("-socip", "--socip", false, info_collect_socip); -+ cmd_option_register("-all", "--all", false, info_collect_all); -+} -+ -+static void cmd_info_collect_init(void) -+{ -+ struct major_cmd_ctrl *major_cmd = get_major_cmd(); -+ uint32_t chip_type = get_chip_type(); -+ -+ major_cmd->option_count = 0; -+ major_cmd->execute = info_collect_execute; -+ -+ switch (chip_type) { -+ case CHIP_HIP09: -+ case CHIP_HIP10: -+ case CHIP_HIP10C: -+ info_collect_cmd_register_hip09_10(); -+ break; -+ case CHIP_HIP11: -+ info_collect_cmd_register_hip11(); -+ break; -+ case CHIP_HIP12: -+ info_collect_cmd_register_hip12(); -+ break; -+ default: -+ break; -+ } -+} -+ - HIKP_CMD_DECLARE("info_collect", "information collect", cmd_info_collect_init); --- -2.45.0.windows.1 - diff --git a/0117-hikptool-Remove-sas_dqe-command.patch b/0117-hikptool-Remove-sas_dqe-command.patch deleted file mode 100644 index 90cd59b35e7d9760b7c42b69f5ffadc32600b31b..0000000000000000000000000000000000000000 --- a/0117-hikptool-Remove-sas_dqe-command.patch +++ /dev/null @@ -1,389 +0,0 @@ -From 92d25f5fa6182ea0c6af53a90c94c34264965b70 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 8 Oct 2025 11:31:28 +0800 -Subject: [PATCH 5/6] hikptool: Remove sas_dqe command - -Revmove the sas_dqe command as it is not used in -problem analysis and may cause malfunctions when -executed. The debugfs related functions can be -used instead. - -Signed-off-by: Xingui Yang yangxingui@huawei.com ---- - hikp_init_main.c | 2 +- - sas/sas_func/sas_common.h | 5 -- - sas/sas_func/sas_read_dev.c | 2 +- - sas/sas_func/sas_read_dqe.c | 114 ---------------------------- - sas/sas_func/sas_read_dqe.h | 85 --------------------- - sas/user_cmd/cmd_code/sas_cmd_dqe.c | 106 -------------------------- - 6 files changed, 2 insertions(+), 312 deletions(-) - delete mode 100644 sas/sas_func/sas_read_dqe.c - delete mode 100644 sas/sas_func/sas_read_dqe.h - delete mode 100644 sas/user_cmd/cmd_code/sas_cmd_dqe.c - -diff --git a/hikp_init_main.c b/hikp_init_main.c -index d52d603..72d206f 100644 ---- a/hikp_init_main.c -+++ b/hikp_init_main.c -@@ -53,7 +53,7 @@ static const char *g_roh_cmd_list[] = { - }; - - static const char *g_sas_cmd_list[] = { -- "sas_anacq", "sas_anadq", "sas_dev", "sas_dqe", "sas_dump", "sas_errcode", -+ "sas_anacq", "sas_anadq", "sas_dev", "sas_dump", "sas_errcode", - }; - - static const char *g_sata_cmd_list[] = { -diff --git a/sas/sas_func/sas_common.h b/sas/sas_func/sas_common.h -index 78edf2e..c11b7d4 100644 ---- a/sas/sas_func/sas_common.h -+++ b/sas/sas_func/sas_common.h -@@ -79,9 +79,4 @@ enum sas_dev_cmd_type { - DEV_UNKNOWN_TYPE, - }; - --enum sas_dqe_cmd_type { -- DQE_INFO, -- DQE_UNKNOWN_TYPE, --}; -- - #endif /* SAS_COMMON_H */ -diff --git a/sas/sas_func/sas_read_dev.c b/sas/sas_func/sas_read_dev.c -index dec2935..c541c1c 100644 ---- a/sas/sas_func/sas_read_dev.c -+++ b/sas/sas_func/sas_read_dev.c -@@ -34,7 +34,7 @@ static int sas_get_dev(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 - hikp_cmd_init(&req_header, SAS_MOD, SAS_DEV, cmd->sas_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { -- printf("sas_dqe excutes hikp_cmd_alloc err\n"); -+ printf("sas_dev excutes hikp_cmd_alloc err\n"); - hikp_cmd_free(&cmd_ret); - return -EINVAL; - } -diff --git a/sas/sas_func/sas_read_dqe.c b/sas/sas_func/sas_read_dqe.c -deleted file mode 100644 -index ae4ef68..0000000 ---- a/sas/sas_func/sas_read_dqe.c -+++ /dev/null -@@ -1,114 +0,0 @@ --/* -- * Copyright (c) 2022 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 --#include --#include --#include --#include --#include --#include "hikptdev_plug.h" --#include "sas_common.h" --#include "sas_read_dqe.h" -- --static int sas_get_dqe(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint32_t *reg_num) --{ -- struct hikp_cmd_header req_header; -- struct hikp_cmd_ret *cmd_ret; -- struct sas_dqe_req_para req_data = { 0 }; -- -- req_data.chip_id = cmd->chip_id; -- req_data.die_id = cmd->die_id; -- req_data.que_id = cmd->que_id; -- req_data.dqe_id = cmd->dqe_id; -- -- hikp_cmd_init(&req_header, SAS_MOD, SAS_DQE, cmd->sas_cmd_type); -- cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); -- if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { -- printf("sas_dqe excutes hikp_cmd_alloc err\n"); -- hikp_cmd_free(&cmd_ret); -- return -EINVAL; -- } -- *reg_num = cmd_ret->rsp_data_num; -- for (uint32_t i = 0; i < *reg_num; i++) -- reg_save[i] = cmd_ret->rsp_data[i]; -- -- hikp_cmd_free(&cmd_ret); -- return 0; --} -- --static void print_dqe_info(const void *reg_save) --{ -- volatile struct hisi_sas_dq_info *dqe = (volatile struct hisi_sas_dq_info *)(reg_save); -- -- printf("The dqe dw0 information as below:\n"); -- printf("abort_flag: %u\n", dqe->dw0.abort_flag); -- printf("abort_devtype: %u\n", dqe->dw0.abort_devtype); -- printf("Rsponse_report: %u\n", dqe->dw0.Rsponse_report); -- printf("TLR_Ctrl: %u\n", dqe->dw0.TLR_Ctrl); -- printf("Phy_ID: %u\n", dqe->dw0.Phy_ID); -- printf("Force_Phy: %u\n", dqe->dw0.Force_Phy); -- printf("PORT: 0x%x\n", dqe->dw0.PORT); -- printf("PRI: %u\n", dqe->dw0.PRI); -- printf("CMD: %u\n", dqe->dw0.CMD); -- -- printf("The dqe dw1 information as below:\n"); -- printf("Non_Busy_Constraint: %u\n", dqe->dw1.Non_Busy_Constraint); -- printf("SSP_Pass_Through: %u\n", dqe->dw1.SSP_Pass_Through); -- printf("DIR: %u\n", dqe->dw1.DIR); -- printf("Reset: %u\n", dqe->dw1.Reset); -- printf("PIR_Present: %u\n", dqe->dw1.PIR_Present); -- printf("Enable_Transport_Layer_Retry: %u\n", dqe->dw1.Enable_Transport_Layer_Retry); -- printf("Verify_Data_Transfer_Length: 0x%x\n", dqe->dw1.Verify_Data_Transfer_Length); -- printf("Frame_Type: %u\n", dqe->dw1.Frame_Type); -- printf("Device_ID: %u\n", dqe->dw1.Device_ID); -- -- printf("The dqe dw2 information as below:\n"); -- printf("Command_Frame_Length: %u\n", dqe->dw2.Command_Frame_Length); -- printf("Leave_Affiliation_Open: %u\n", dqe->dw2.Leave_Affiliation_Open); -- printf("Ncq_Tag: %u\n", dqe->dw2.Ncq_Tag); -- printf("Max_Response_Frame_Length: %u\n", dqe->dw2.Max_Response_Frame_Length); -- printf("Sg_Mode: %u\n", dqe->dw2.Sg_Mode); -- printf("First_Burst: %u\n", dqe->dw2.First_Burst); -- -- printf("Initiator_Port_Transfer_Tag: %u\n", dqe->Initiator_Port_Transfer_Tag); -- printf("Target_Port_Transfer_Tag: %u\n", dqe->Target_Port_Transfer_Tag); -- printf("Data_Transfer_Length: %u\n", dqe->Data_Transfer_Length); -- printf("First_Burst_Num: %u\n", dqe->First_Burst_Num); -- printf("DIF_PRD_Table_Length: %u\n", dqe->DIF_PRD_Table_Length); -- printf("PRD_Table_Length: %u\n", dqe->PRD_Table_Length); -- -- printf("The dqe dw7 information as below:\n"); -- printf("Double_Mode: %u\n", dqe->dw7.Double_Mode); -- printf("Abort_IPTT: %u\n", dqe->dw7.Abort_IPTT); --} -- --int sas_dqe(const struct tool_sas_cmd *cmd) --{ -- int ret; -- uint32_t reg_num = 0; -- uint32_t reg_save[RESP_MAX_NUM] = { 0 }; -- -- if (cmd == NULL) -- return -ENOSPC; -- -- ret = sas_get_dqe(cmd, reg_save, ®_num); -- if (ret) -- return ret; -- -- if (reg_num < REG_NUM_DQE_MAX) { -- printf("SAS dqe is failed\n"); -- return -EINVAL; -- } -- print_dqe_info(reg_save); -- return 0; --} -diff --git a/sas/sas_func/sas_read_dqe.h b/sas/sas_func/sas_read_dqe.h -deleted file mode 100644 -index 95e1ff3..0000000 ---- a/sas/sas_func/sas_read_dqe.h -+++ /dev/null -@@ -1,85 +0,0 @@ --/* -- * Copyright (c) 2022 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 SAS_DQE_H --#define SAS_DQE_H -- --#include "sas_tools_include.h" -- --struct sas_dqe_req_para { -- uint32_t chip_id; -- uint32_t die_id; -- uint32_t que_id; -- uint32_t dqe_id; --}; -- --struct hikp_sas_dqe_dw0 { -- uint32_t abort_flag : 2; -- uint32_t abort_devtype : 1; -- uint32_t Rsvd0 : 2; -- uint32_t Rsponse_report : 1; -- uint32_t TLR_Ctrl : 2; -- uint32_t Phy_ID : 9; -- uint32_t Force_Phy : 1; -- uint32_t PORT : 4; -- uint32_t Rsvd1 : 5; -- uint32_t PRI : 1; -- uint32_t Rsvd5 : 1; -- uint32_t CMD : 3; --}; -- --struct hikp_sas_dqe_dw1 { -- uint32_t Rsvd2 : 3; -- uint32_t Non_Busy_Constraint : 1; -- uint32_t SSP_Pass_Through : 1; -- uint32_t DIR : 2; -- uint32_t Reset : 1; -- uint32_t PIR_Present : 1; -- uint32_t Enable_Transport_Layer_Retry : 1; -- uint32_t Verify_Data_Transfer_Length : 1; -- uint32_t Frame_Type : 5; -- uint32_t Device_ID : 16; --}; -- --struct hikp_sas_dqe_dw2 { -- uint32_t Command_Frame_Length : 9; -- uint32_t Leave_Affiliation_Open : 1; -- uint32_t Ncq_Tag : 5; -- uint32_t Max_Response_Frame_Length : 9; -- uint32_t Sg_Mode : 2; -- uint32_t First_Burst : 1; -- uint32_t Rsvd3 : 5; --}; -- --struct hikp_sas_dqe_dw7 { -- uint32_t Rsvd4 : 15; -- uint32_t Double_Mode : 1; -- uint32_t Abort_IPTT : 16; --}; -- --struct hisi_sas_dq_info { -- struct hikp_sas_dqe_dw0 dw0; -- struct hikp_sas_dqe_dw1 dw1; -- struct hikp_sas_dqe_dw2 dw2; -- uint32_t Initiator_Port_Transfer_Tag : 16; -- uint32_t Target_Port_Transfer_Tag : 16; -- uint32_t Data_Transfer_Length; -- uint32_t First_Burst_Num; -- uint32_t DIF_PRD_Table_Length : 16; -- uint32_t PRD_Table_Length : 16; -- struct hikp_sas_dqe_dw7 dw7; --}; -- --int sas_dqe(const struct tool_sas_cmd *cmd); -- --#endif /* SAS_DQE_H */ -diff --git a/sas/user_cmd/cmd_code/sas_cmd_dqe.c b/sas/user_cmd/cmd_code/sas_cmd_dqe.c -deleted file mode 100644 -index b914f54..0000000 ---- a/sas/user_cmd/cmd_code/sas_cmd_dqe.c -+++ /dev/null -@@ -1,106 +0,0 @@ --/* -- * Copyright (c) 2022 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 --#include "tool_cmd.h" --#include "sas_common.h" --#include "sas_tools_include.h" --#include "sas_read_dqe.h" -- --static int sas_dqe_help(struct major_cmd_ctrl *self, const char *argv) --{ -- HIKP_SET_USED(argv); -- -- printf("\n Usage: %s\n", self->cmd_ptr->name); -- printf("\n %s\n", self->cmd_ptr->help_info); -- printf(" %s, %-25s %s\n", "-c", "--chipid", "please input chip id[x] first\n"); -- printf(" %s, %-25s %s\n", "-d", "--dieid", "please input die id[x] first\n"); -- printf(" %s, %-25s %s\n", "-q", "--queue", "please input queue id[x] first\n"); -- printf("\n Options:\n\n"); -- printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); -- printf(" %s, %-25s %s\n", "-i", "--info", "display the dqe detail information\n"); -- printf("\n"); -- -- return 0; --} -- --static int sas_dqe_info(struct major_cmd_ctrl *self, const char *argv) --{ -- int ret; -- -- (void)sas_set_cmd_type(DQE_INFO); -- ret = sas_set_dqe_id(self, argv); -- return ret; --} -- --static int sas_set_queue_id(struct major_cmd_ctrl *self, const char *argv) --{ -- int ret; -- -- ret = sas_set_que_id(self, argv); -- if (ret || sas_get_que_id() >= SAS_QUEUE_NUM) { -- snprintf(self->err_str, sizeof(self->err_str), "Invalid queue id."); -- self->err_no = ret; -- return -EINVAL; -- } -- -- return 0; --} -- --static int sas_dqe_excute_funs_call(uint32_t cmd_type) --{ -- if ((cmd_type != SAS_UNKNOW_CMD) && (sas_get_que_id() != (-1))) -- return sas_dqe(sas_get_cmd_p()); -- -- return -EINVAL; --} -- --static void sas_dqe_execute(struct major_cmd_ctrl *self) --{ -- int ret, cmd; -- const char *suc_msg[] = { -- "sas_dqe_info success.", -- }; -- const char *err_msg[] = { -- "sas_dqe_info error.", -- "sas_dqe failed, unknown type", -- }; -- -- cmd = sas_get_cmd_type(); -- ret = sas_dqe_excute_funs_call(cmd); -- (void)sas_set_cmd_type(SAS_UNKNOW_CMD); -- if (ret == 0) { -- printf("%s\n", suc_msg[cmd]); -- } else { -- if (cmd == SAS_UNKNOW_CMD) -- cmd = DQE_UNKNOWN_TYPE; -- snprintf(self->err_str, sizeof(self->err_str), "%s\n", err_msg[cmd]); -- self->err_no = ret; -- } --} -- --static void cmd_sas_dqe_init(void) --{ -- struct major_cmd_ctrl *major_cmd = get_major_cmd(); -- -- major_cmd->option_count = 0; -- major_cmd->execute = sas_dqe_execute; -- -- cmd_option_register("-c", "--chipid", true, sas_set_chip_id); -- cmd_option_register("-d", "--dieid", true, sas_set_die_id); -- cmd_option_register("-h", "--help", false, sas_dqe_help); -- cmd_option_register("-q", "--queue", true, sas_set_queue_id); -- cmd_option_register("-i", "--info", true, sas_dqe_info); --} -- --HIKP_CMD_DECLARE("sas_dqe", "sas dqe information ", cmd_sas_dqe_init); --- -2.45.0.windows.1 - diff --git a/0118-hikptool-Modify-the-version-number-of-the-SO-dynamic.patch b/0118-hikptool-Modify-the-version-number-of-the-SO-dynamic.patch deleted file mode 100644 index 5907ab694448b09670b75e3bd3f9cdecb303b8e7..0000000000000000000000000000000000000000 --- a/0118-hikptool-Modify-the-version-number-of-the-SO-dynamic.patch +++ /dev/null @@ -1,30 +0,0 @@ -From bcba3ee468a1e0932734c8e617fe69ecf21fea74 Mon Sep 17 00:00:00 2001 -From: veega2022 -Date: Wed, 8 Oct 2025 11:38:38 +0800 -Subject: [PATCH 6/6] hikptool: Modify the version number of the SO dynamic - library. - -Ensure that the version number of the tool -matches the version number of the.so file. - -libhikptdev.so.1.0.0 --> libhikptdev.so.1.1.5 - -Signed-off-by: veega2022 ---- - libhikptdev/src/rciep/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libhikptdev/src/rciep/CMakeLists.txt b/libhikptdev/src/rciep/CMakeLists.txt -index e3f96c0..057b8f5 100644 ---- a/libhikptdev/src/rciep/CMakeLists.txt -+++ b/libhikptdev/src/rciep/CMakeLists.txt -@@ -23,5 +23,5 @@ target_include_directories(KPTDEV_SO PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../in - - target_link_options(KPTDEV_SO PRIVATE -Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIE -pie -s) - --set_target_properties(KPTDEV_SO PROPERTIES OUTPUT_NAME ${KPTDEV_SO_NAME} SOVERSION 1 VERSION 1.0.0) -+set_target_properties(KPTDEV_SO PROPERTIES OUTPUT_NAME ${KPTDEV_SO_NAME} SOVERSION 1 VERSION 1.1.5) - install(TARGETS KPTDEV_SO LIBRARY DESTINATION lib OPTIONAL) --- -2.45.0.windows.1 - diff --git a/hikptool-1.1.5.tar.gz b/hikptool-1.1.5.tar.gz deleted file mode 100644 index ebab670a840ed75d87d6918267b90cfc82b98b25..0000000000000000000000000000000000000000 Binary files a/hikptool-1.1.5.tar.gz and /dev/null differ diff --git a/hikptool-1.1.6.tar.gz b/hikptool-1.1.6.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..3202e6f96a239c715df58fd11da4ef737215153d Binary files /dev/null and b/hikptool-1.1.6.tar.gz differ diff --git a/hikptool.spec b/hikptool.spec index b58fb69b3d76dc79f98d8f75365ef20ae3400d76..4c7b2bccaed94288625a572b2e940963f8388a85 100644 --- a/hikptool.spec +++ b/hikptool.spec @@ -2,8 +2,8 @@ Name: hikptool Summary: A userspace tool for Linux providing problem location on Kunpeng chips -Version: 1.1.5 -Release: 26 +Version: 1.1.6 +Release: 1 License: MulanPSL2 Source: %{name}-%{version}.tar.gz ExclusiveOS: linux @@ -16,125 +16,6 @@ BuildRequires: gcc make cmake Requires: glibc ExclusiveArch: aarch64 -Patch0001: 0001-socip-Return-EINVAL-when-the-parameter-check-fails.patch -Patch0002: 0002-fix-compiler-security-option-problem.patch -Patch0003: 0003-fix-the-security-compilation-PIE-issue.patch -Patch0004: 0004-hikptool-fix-print-sas_dev-info-error-problem.patch -Patch0005: 0005-fix-hikptool-rciep-rsp-filed-error-problem.patch -Patch0006: 0006-fix-pcie_info-cmd-print-display-problem.patch -Patch0007: 0007-fix-signal-proc-func-api-modified-to-be-open-to-the-.patch -Patch0008: 0008-delete-pcie-AP_INT-module-for-dump-reg.patch -Patch0009: 0009-fix-serdes-module-dump-reg-num-is-not-enough-problem.patch -Patch0010: 0010-fix-the-number-of-PCS-lane-registers-in-the-PCIe-dum.patch -Patch0011: 0011-optimize-the-nic_mac-dump-register.patch -Patch0012: 0012-Fix-a-resource-release-bug-in-hikp_roh_get_cam_reg_n.patch -Patch0013: 0013-fix-missing-white-space-issue.patch -Patch0014: 0014-hikptool-fix-maininfo-detail-info-print-error.patch -Patch0015: 0015-hikptool-fix-print-sas_dqe-info-error-problem.patch -Patch0016: 0016-hikptool-fix-compiling-specifications-check-problem.patch -Patch0017: 0017-Complete-the-developing-of-hikptool-ub_dfx-function.patch -Patch0018: 0018-Complete-the-developing-of-hikptool-ub_link-function.patch -Patch0019: 0019-Complete-the-developing-of-hikptool-ub_bp-function.patch -Patch0020: 0020-Complete-the-developing-of-hikptool-ub_crd-function.patch -Patch0021: 0021-Complete-the-developing-of-hikptool-ub_info-function.patch -Patch0022: 0022-add-support-query-ip-guid-entries.patch -Patch0023: 0023-hikptool-delete-redundant-copyright-notices.patch -Patch0024: 0024-hikptool-add-pm-trace.patch -Patch0025: 0025-hikptool-add-The-security-compilation-options.patch -Patch0026: 0026-hikptool-nic_port-cmd-add-print-arb-info-and-phy-inf.patch -Patch0027: 0027-hikptool-add-pcie-new-dump.patch -Patch0028: 0028-hikptool-add-show-CDR-DFX-info-in-nic_port-cmd.patch -Patch0029: 0029-hikptool-add-new-cmd-support-query-ncsi-dfx-info.patch -Patch0030: 0030-hikptool-Don-t-show-gen5.patch -Patch0031: 0031-hikptool-RDMA-Fix-the-missing-bank-ID-in-roce_trp-GE.patch -Patch0032: 0032-hikptool-fix-the-memory-leak-risk-problem.patch -Patch0033: 0033-hikptool-add-new-cmd-support-query-fault-notify-pkt-.patch -Patch0034: 0034-hikptool-add-new-cmd-to-support-query-port-fault-inf.patch -Patch0035: 0035-hikptool-support-to-query-pfc-storm-parameters.patch -Patch0036: 0036-hikptool-add-sub-cmd-nic_torus-support.patch -Patch0037: 0037-hikptool-optimized-display-the-hot-plug-card-info-in.patch -Patch0038: 0038-hikptool-Update-the-tool-version-number-to-1.1.0.patch -Patch0039: 0039-hikptool-roce-Add-a-common-frame-for-hikptool-roce-r.patch -Patch0040: 0040-hikptool-roce-Add-roce_rst-cmd-for-reset-signal-regi.patch -Patch0041: 0041-hikptool-roce-Add-roce_global_cfg-cmd-for-global-con.patch -Patch0042: 0042-hikptool-roce-Add-roce_bond-cmd-for-bond-registers-q.patch -Patch0043: 0043-hikptool-roce-Add-ext-query-for-roce_caep-cmd.patch -Patch0044: 0044-hikptool-roce-Add-ext-query-for-roce_mdb-cmd.patch -Patch0045: 0045-hikptool-roce-Add-ext-query-for-roce_qmm-cmd.patch -Patch0046: 0046-hikptool-Querying-the-SerDes-Relationship-of-the-PCI.patch -Patch0047: 0047-hikptool-Remove-the-function-of-querying-SAS-device-.patch -Patch0048: 0048-hikptool-roce-Use-calloc-to-alloc-memory-for-array-i.patch -Patch0049: 0049-hikptool-roce-Fix-missing-check-of-reg-num-responsed.patch -Patch0050: 0050-hikptool-Change-the-unic_ppp-directory-to-ub_ppp.patch -Patch0051: 0051-hikptool-roce-Fix-the-wrong-maximum-of-gmv-index.patch -Patch0052: 0052-hikptool-Resolved-some-centralized-code-review-comme.patch -Patch0053: 0053-hikptool-roce-Fix-the-infinite-loop-due-to-compatibi.patch -Patch0054: 0054-hikptool-roh-fix-the-display-information-for-roh-mac.patch -Patch0055: 0055-hikptool-augument-serdes-relationship-of-the-PCIe.patch -Patch0056: 0056-hikptool-Supported-parsing-the-optical-module-that-u.patch -Patch0057: 0057-hikptool-Fixed-an-issue-where-the-MAC-type-is-incorr.patch -Patch0058: 0058-hikptool-The-nic_port-command-is-adapted-to-display-.patch -Patch0059: 0059-hikptool-fix-cleancode-codecheck-alarm.patch -Patch0060: 0060-hikptool-Delete-meaningless-printing.patch -Patch0061: 0061-hikptool-Update-the-tool-version-number-to-1.1.1.patch -Patch0062: 0062-hikptool-The-ecam-register-is-added-to-the-PCIe-dump.patch -Patch0063: 0063-hikptool-roce-Print-names-of-registers-for-gmv-mdb-p.patch -Patch0064: 0064-hikptool-roce-Support-exposing-names-of-extend-regis.patch -Patch0065: 0065-hikptool-roce-Fix-the-validation-check-of-cur_block_.patch -Patch0066: 0066-hikptool-roce-Fix-redundant-update-of-total_block_nu.patch -Patch0067: 0067-hikptool-roce-Add-check-for-total_block_num-from-FW.patch -Patch0068: 0068-hikptool-Resolve-the-review-problems-found-in-the-R-.patch -Patch0069: 0069-hikptool-Support-static-compilation-for-hikptool.patch -Patch0070: 0070-hikptool-nic-Fix-the-Code-review-comments.patch -Patch0071: 0071-hikptool-nic-add-check-for-the-value-from-FW.patch -Patch0072: 0072-hikptool-nic-Fix-the-Code-review-comments-in-NIC-mod.patch -Patch0073: 0073-hikptool-nic-return-real-errno-if-realpath-failed-in.patch -Patch0074: 0074-hikptool-nic-return-real-cmd-status-if-alloc-failed-.patch -Patch0075: 0075-hikptool-nic-check-path-before-used-it-in-function-h.patch -Patch0076: 0076-hikptool-nic-check-strtol-if-it-failed-in-get_numvfs.patch -Patch0077: 0077-hikptool-nic-adding-NUL-at-the-end-of-the-buffer-len.patch -Patch0078: 0078-hikptool-nic-avoid-array-boundary-exceeded-in-hikp_n.patch -Patch0079: 0079-hikptool-nic-Fix-bad-usage-of-format-string.patch -Patch0080: 0080-hikptool-nic-Fix-potential-dead-loop.patch -Patch0081: 0081-hikptool-Rectify-the-cleancode-issue.patch -Patch0082: 0082-hikptool-Modify-the-macro-definition-of-the-header-f.patch -Patch0083: 0083-hikptool-The-memory-release-interface-is-added.patch -Patch0084: 0084-hikptool-nic-Dump-register-names-for-SSU-and-PPP-mod.patch -Patch0085: 0085-hikptool-Added-the-dfx-register-for-PCIe-dump.patch -Patch0086: 0086-hikptool-The-macro_num-error-is-rectified-and-the-of.patch -Patch0087: 0087-Fix-the-logic-of-obtaining-statistics-on-flow-contro.patch -Patch0088: 0088-hikptool-Rectify-the-compilation-alarm.patch -Patch0089: 0089-hikptool-Update-the-tool-version-number-to-1.1.3.patch -Patch0090: 0090-hikptool-Support-for-info-collect.patch -Patch0091: 0091-hikptool-Added-compilation-options.patch -Patch0092: 0092-hikptool-pcie-The-query-result-of-pcie_dumpreg-does-.patch -Patch0093: 0093-hikptool-hccs-support-dump-hccs-info.patch -Patch0094: 0094-hikptool-pcie-The-PCS-layer-register-print-command-i.patch -Patch0095: 0095-hikptool-pcie-Resolved-the-problem-that-it-takes-a-l.patch -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 -Patch0101: 0101-hikptool-Code-quality-reinforcement.patch -Patch0102: 0102-hikptool-Add-more-RoCE-registers-for-diagnosis.patch -Patch0103: 0103-hikptool-roce-Support-to-print-u64-reg_data.patch -Patch0104: 0104-hikptool-roce-Add-roce_dfx_sta-cmd-for-RoCE-DFX-stat.patch -Patch0105: 0105-hikptool-Fix-ASAN-compilation-warnings.patch -Patch0106: 0106-hikptool-Add-serdes-module-submodule-dump-types.patch -Patch0107: 0107-hikptool-Optimize-the-ROCE-SCC-module-register-dump-.patch -Patch0108: 0108-hikptool-solve-some-code-review-comments.patch -Patch0109: 0109-hikptool-optimization-tool-help-information.patch -Patch0110: 0110-hikptool-ras-do-some-cleanup-and-refactoring-of-rasd.patch -Patch0111: 0111-hikptool-hccs-Fix-the-usage-description.patch -Patch0112: 0112-hikptool-hccs-enable-HCCS-dfx-for-HIP11.patch -Patch0113: 0113-hikptool-Add-the-nic_led-command-implementation.patch -Patch0114: 0114-hikptool-Add-dfx-to-roce_dfx_sta.patch -Patch0115: 0115-hikptool-Add-new-dump-ncsi-table-entry-configuration.patch -Patch0116: 0116-hikptool-Optimize-one-click-log-collection-supported.patch -Patch0117: 0117-hikptool-Remove-sas_dqe-command.patch -Patch0118: 0118-hikptool-Modify-the-version-number-of-the-SO-dynamic.patch - %description This package contains the hikptool @@ -153,7 +34,7 @@ mkdir -p ${RPM_BUILD_ROOT}/usr/lib64 install -b -m755 ./build/hikptool ${RPM_BUILD_ROOT}/usr/bin install -b -m755 ./build/libhikptdev/src/rciep/libhikptdev.so.1 ${RPM_BUILD_ROOT}/usr/lib64 install -b -m755 ./build/libhikptdev/src/rciep/libhikptdev.so ${RPM_BUILD_ROOT}/usr/lib64 -install -b -m755 ./build/libhikptdev/src/rciep/libhikptdev.so.1.1.5 ${RPM_BUILD_ROOT}/usr/lib64 +install -b -m755 ./build/libhikptdev/src/rciep/libhikptdev.so.1.1.6 ${RPM_BUILD_ROOT}/usr/lib64 %clean rm -rf ${RPM_BUILD_ROOT} @@ -161,7 +42,7 @@ rm -rf ${RPM_BUILD_ROOT} %files /usr/lib64/libhikptdev.so.1 /usr/lib64/libhikptdev.so -%attr(0500,root,root) /usr/lib64/libhikptdev.so.1.1.5 +%attr(0500,root,root) /usr/lib64/libhikptdev.so.1.1.6 %attr(0500,root,root) /usr/bin/hikptool %pre @@ -186,80 +67,5 @@ fi /sbin/ldconfig %changelog -* Thu Oct 9 2025 Huisong Li 1.1.5-26 -- Add some new DFX commands and update the dynamic library version number. - -* Wed Sep 24 2025 Huisong Li 1.0.0-25 -- hccs: support HCCS dfx for HIP11 - -* Tue Sep 16 2025 Junhao He 1.0.0-24 -- ras: do some cleanup and refactoring of rasdfx dump - -* Thu Aug 28 2025 veega2022 1.0.0-23 -- Optimize help information and modify code review comments - -* Mon Jul 28 2025 veega2022 1.0.0-22 -- Optimize the ROCE SCC module register dump display - -* Fri Jul 25 2025 Junxian Huang 1.0.0-21 -- Support roce_dfx_sta query - -* Tue Jun 17 2025 veega2022 1.0.0-20 -- Fix code review comments, and add roce dfx registers. - -* 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. - -* Tue Mar 18 2025 veega2022 1.0.0-17 -- The HCCS and SDMA modules and the log collection function are added - -* Thu Nov 21 2024 veega2022 1.0.0-16 -- Synchronize code, Modify the review comments to increase the reliability of the code - -* Thu May 23 2024 veega2022 1.0.0-15 -- Synchronize code, the DFX register of the ECAM is added when the PCIe dumps registers - -* Wed Apr 24 2024 veega2022 1.0.0-14 -- Synchronize code, fix some issues with ROH, PCIE and NIC modules - -* Thu Nov 16 2023 veega2022 1.0.0-13 -- Synchronize the code and add the DFX of the roce module to resolve some review comments - -* Fri Oct 20 2023 veega2022 1.0.0-12 -- Added DFX for UB, NIC, MAC modules, fixed some bugs - -* Sat Jun 03 2023 veega2022 1.0.0-11 -- fix compiling specifications check problem - -* Tue May 30 2023 veega2022 1.0.0-10 -- sync code: fix PCIe and serdes, roh module problem - -* Thu Apr 06 2023 veega2022 1.0.0-9 -- fix sas device info print error bug - -* Wed Mar 15 2023 veega2022 1.0.0-8 -- fix security compilation PIE issue - -* Tue Dec 13 2022 veega2022 1.0.0-7 -- fix compiler security option problem - -* Mon Dec 12 2022 veega2022 1.0.0-6 -- Add socip patch for fix return -EINVAL when the parameter check fails - -* Thu Nov 24 2022 veega2022 1.0.0-5 -- Add nic_ppp dump mac and vlan function and change the hikptool permission to 0500 - -* Wed Nov 16 2022 veega2022 1.0.0-4 -- change the hikptool permission to 4550 - -* Fri Oct 28 2022 veega2022 1.0.0-3 -- Add sas/sata features source code - -* Wed Oct 26 2022 veega2022 1.0.0-2 -- Add roce/roh/cxl/serdes/socip/pcie features source code - -* Wed Oct 12 2022 veega2022 1.0.0-1 -- First Spec Version Include hikptool Code +* Thu Oct 30 2025 veega2022 1.1.6-1 +- Supports querying UB DFX information (UBUS, UMMU modules, etc.) and updates the version number to 1.1.6