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 new file mode 100644 index 0000000000000000000000000000000000000000..15a960d711bb773dac85c39040687636cc2784e0 --- /dev/null +++ b/0063-hikptool-roce-Print-names-of-registers-for-gmv-mdb-p.patch @@ -0,0 +1,739 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..081b1422be27b3602c58d6707b0e16de9f5e0a2d --- /dev/null +++ b/0064-hikptool-roce-Support-exposing-names-of-extend-regis.patch @@ -0,0 +1,354 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..50861bda15cf5167be7bb9d46cff9b81e93cc586 --- /dev/null +++ b/0065-hikptool-roce-Fix-the-validation-check-of-cur_block_.patch @@ -0,0 +1,70 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..23137e9745ddd8cf84aea0f531ae08f9749a44cd --- /dev/null +++ b/0066-hikptool-roce-Fix-redundant-update-of-total_block_nu.patch @@ -0,0 +1,36 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..b46a7cc592890a79bd953931eeb144d86ecb5897 --- /dev/null +++ b/0067-hikptool-roce-Add-check-for-total_block_num-from-FW.patch @@ -0,0 +1,70 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..9e663f769850e38a26e4c65fc1e591efcbbdcccf --- /dev/null +++ b/0068-hikptool-Resolve-the-review-problems-found-in-the-R-.patch @@ -0,0 +1,1376 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..d8ea37025b6d12e55950f6aa3ca2c785a9b0e979 --- /dev/null +++ b/0069-hikptool-Support-static-compilation-for-hikptool.patch @@ -0,0 +1,76 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..ffc2ef00dab29854d2ccacb629f8aea4cd44d752 --- /dev/null +++ b/0070-hikptool-nic-Fix-the-Code-review-comments.patch @@ -0,0 +1,265 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..8a0dbe12a1fcb8f8803e2661d9ff2d6ea03d6c01 --- /dev/null +++ b/0071-hikptool-nic-add-check-for-the-value-from-FW.patch @@ -0,0 +1,172 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..22712a79ab28bdf2b23598aaf0b14c412f65c879 --- /dev/null +++ b/0072-hikptool-nic-Fix-the-Code-review-comments-in-NIC-mod.patch @@ -0,0 +1,85 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..0c3df09ab62a0ecb9718d69e44d120acc8d93f7f --- /dev/null +++ b/0073-hikptool-nic-return-real-errno-if-realpath-failed-in.patch @@ -0,0 +1,43 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..98e93c216bdca214aa76b739d4fe28c9f3fe5b3a --- /dev/null +++ b/0074-hikptool-nic-return-real-cmd-status-if-alloc-failed-.patch @@ -0,0 +1,165 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..0c9fd5c473340101a83510237458c099ea48c29b --- /dev/null +++ b/0075-hikptool-nic-check-path-before-used-it-in-function-h.patch @@ -0,0 +1,40 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..4e43195f886555bc899990d4e0eb3dd57d6c5873 --- /dev/null +++ b/0076-hikptool-nic-check-strtol-if-it-failed-in-get_numvfs.patch @@ -0,0 +1,35 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..ed4a543e60365ea1b0918dc1a5525f45696073f4 --- /dev/null +++ b/0077-hikptool-nic-adding-NUL-at-the-end-of-the-buffer-len.patch @@ -0,0 +1,43 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..6187f6e8103573f3bfa7d58446e12eda6f43a228 --- /dev/null +++ b/0078-hikptool-nic-avoid-array-boundary-exceeded-in-hikp_n.patch @@ -0,0 +1,59 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..f532a66cc680b56934a9f57304f594b12c171a67 --- /dev/null +++ b/0079-hikptool-nic-Fix-bad-usage-of-format-string.patch @@ -0,0 +1,31 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..aa791231d94676c9d288ba7aacfc12594dbc6cc5 --- /dev/null +++ b/0080-hikptool-nic-Fix-potential-dead-loop.patch @@ -0,0 +1,43 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..2bfb188d21db1e3c662a48e51f91f3fd31814ec0 --- /dev/null +++ b/0081-hikptool-Rectify-the-cleancode-issue.patch @@ -0,0 +1,482 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..da3df978252c391c948aa0df5f32cfec361aa004 --- /dev/null +++ b/0082-hikptool-Modify-the-macro-definition-of-the-header-f.patch @@ -0,0 +1,1097 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..14448761504accee5944c47c31d9a9f4f93c534d --- /dev/null +++ b/0083-hikptool-The-memory-release-interface-is-added.patch @@ -0,0 +1,1557 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..1d66d5a11b9e7e9a78ae137e0f5bf41bcf59b381 --- /dev/null +++ b/0084-hikptool-nic-Dump-register-names-for-SSU-and-PPP-mod.patch @@ -0,0 +1,519 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..283080dd68501422743414e679e366bef8188b17 --- /dev/null +++ b/0085-hikptool-Added-the-dfx-register-for-PCIe-dump.patch @@ -0,0 +1,54 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..4e4de78bb1e348d2506ea252e041914ff691e16b --- /dev/null +++ b/0086-hikptool-The-macro_num-error-is-rectified-and-the-of.patch @@ -0,0 +1,62 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..251b0e3fe2733c186ee8af881ba39e27c04b3491 --- /dev/null +++ b/0087-Fix-the-logic-of-obtaining-statistics-on-flow-contro.patch @@ -0,0 +1,185 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..af82b0f017eb6ac611124ce3f272daf09afd4bf0 --- /dev/null +++ b/0088-hikptool-Rectify-the-compilation-alarm.patch @@ -0,0 +1,102 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..da0387aaa83d8c9685aafcf7b08b1bf432df43d4 --- /dev/null +++ b/0089-hikptool-Update-the-tool-version-number-to-1.1.3.patch @@ -0,0 +1,28 @@ +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/hikptool.spec b/hikptool.spec index 72c968dd8d6f237e4ccf48b00706b654d340fcf3..f9e93189c5a1405e028543f75d7c74318e351f3b 100644 --- a/hikptool.spec +++ b/hikptool.spec @@ -3,7 +3,7 @@ Name: hikptool Summary: A userspace tool for Linux providing problem location on Kunpeng chips Version: 1.0.0 -Release: 15 +Release: 16 License: MulanPSL2 Source: %{name}-%{version}.tar.gz ExclusiveOS: linux @@ -78,6 +78,33 @@ 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 %description This package contains the hikptool @@ -130,6 +157,9 @@ fi /sbin/ldconfig %changelog +* 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