From: veega2022 zhuweijia@huawei.com
union hikp_space_rsp 0xF8h is reserved and 0xFCh is cpl_status
Signed-off-by: hesiyuan hesiyuan4@huawei.com --- libhikptdev/src/rciep/hikpt_rciep.c | 2 +- libhikptdev/src/rciep/hikpt_rciep.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libhikptdev/src/rciep/hikpt_rciep.c b/libhikptdev/src/rciep/hikpt_rciep.c index 9b7a82a..5c7e82f 100644 --- a/libhikptdev/src/rciep/hikpt_rciep.c +++ b/libhikptdev/src/rciep/hikpt_rciep.c @@ -97,7 +97,7 @@ static uint32_t hikp_wait_for_cpl_status(void) uint32_t status;
do { - status = g_hikp_req->field.cpl_status; + status = g_hikp_rsp->field.cpl_status; if (status != HIKP_INIT_STAT) return status; count--; diff --git a/libhikptdev/src/rciep/hikpt_rciep.h b/libhikptdev/src/rciep/hikpt_rciep.h index 093724a..8fbb3c0 100644 --- a/libhikptdev/src/rciep/hikpt_rciep.h +++ b/libhikptdev/src/rciep/hikpt_rciep.h @@ -75,8 +75,8 @@ union hikp_space_rsp { uint32_t version; /* 000h */ uint32_t rsp_para_num; /* 004h */ uint32_t data[HIKP_RSP_DATA_MAX]; /* 008h */ - uint32_t cpl_status; /* 0F8h */ - uint32_t pid_record; /* 0FCh */ + uint32_t rsv; /* 0F8h */ + uint32_t cpl_status; /* 0FCh */ struct iep_doorbell sw_db; /* 100h. Fixed and unmodifiable */ } field;
From: veega2022 zhuweijia@huawei.com
The spelling of WITDH is incorrect. Change it to WIDTH.
Signed-off-by: hesiyuan hesiyuan4@huawei.com --- pcie/func_lib/pcie_func/pcie_statistics.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c index f12660d..308a142 100644 --- a/pcie/func_lib/pcie_func/pcie_statistics.c +++ b/pcie/func_lib/pcie_func/pcie_statistics.c @@ -22,7 +22,7 @@ #include "pcie_statistics.h"
static const char *g_global_width_name[GLOBAL_WIDTH_TABLE_SIZE] = { - "PCIE_WITDH_X1", "PCIE_WITDH_X2", "PCIE_WITDH_X4", "PCIE_WITDH_X8", "PCIE_WITDH_X16" + "PCIE_WIDTH_X1", "PCIE_WIDTH_X2", "PCIE_WIDTH_X4", "PCIE_WIDTH_X8", "PCIE_WIDTH_X16" };
static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, uint32_t *port_num) @@ -81,7 +81,7 @@ int pcie_port_distribution_get(uint32_t chip_id) for (i = 0; i < pair_num; i++) { if (port_info->info_pair[i].port_width >= HIKP_ARRAY_SIZE(g_global_width_name)) { Info("PCIe Base", "port_id[%u] %s\n", port_info->info_pair[i].port_id, - "UNKNOWN_WITDH"); + "UNKNOWN_WIDTH"); continue; } Info("PCIe Base", "port_id[%u] %s\n", port_info->info_pair[i].port_id,
From: veega2022 zhuweijia@huawei.com
move sig_init api to op_logs public header file
Signed-off-by: wangkang wangkang124@hisilicon.com --- hikp_init_main.c | 20 -------------------- libhikptdev/src/rciep/hikpt_rciep.h | 2 +- tool_lib/op_logs.c | 23 ++++++++++++++++++++++- tool_lib/op_logs.h | 3 ++- 4 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/hikp_init_main.c b/hikp_init_main.c index 4102c69..4629b40 100644 --- a/hikp_init_main.c +++ b/hikp_init_main.c @@ -19,26 +19,6 @@ /* hikptool command adapter */ struct cmd_adapter g_tool = { 0 };
-static void _sig_ign_handle(int arg) -{ - signal_op_log_write(arg); - hikp_unlock(); - _exit(1); -} - -static void sig_init(void) -{ - (void)signal(SIGINT, _sig_ign_handle); /* Quit process */ - (void)signal(SIGTERM, _sig_ign_handle); - (void)signal(SIGQUIT, _sig_ign_handle); - (void)signal(SIGHUP, _sig_ign_handle); - (void)signal(SIGSEGV, _sig_ign_handle); - (void)signal(SIGBUS, _sig_ign_handle); - (void)signal(SIGFPE, _sig_ign_handle); - (void)signal(SIGABRT, _sig_ign_handle); - (void)signal(SIGTSTP, _sig_ign_handle); /* Stop process */ -} - static void show_tool_version(const struct cmd_adapter *adapter) { printf("%s version %s Huawei\n", adapter->name, adapter->version); diff --git a/libhikptdev/src/rciep/hikpt_rciep.h b/libhikptdev/src/rciep/hikpt_rciep.h index 8fbb3c0..dd08759 100644 --- a/libhikptdev/src/rciep/hikpt_rciep.h +++ b/libhikptdev/src/rciep/hikpt_rciep.h @@ -40,7 +40,7 @@ #define MAX_LOCK_COUNT 5 #define LOCK_CHECK_GAP_US 1000 #define CPL_CHECK_GAP_US 1000 -#define WAIT_CPL_MAX_MS 5000 +#define WAIT_CPL_MAX_MS 8000
enum { HIKP_RESOURCE_DIR, diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c index d6082a3..069428d 100644 --- a/tool_lib/op_logs.c +++ b/tool_lib/op_logs.c @@ -14,7 +14,9 @@ #include <syslog.h> #include <unistd.h> #include <sys/stat.h> +#include <signal.h> #include "tool_lib.h" +#include "hikptdev_plug.h" #include "op_logs.h"
static char g_op_log[OP_LOG_FILE_PATH_MAXLEN] = {0}; @@ -23,7 +25,6 @@ static bool g_record = true; static bool g_log_info; static char g_input_buf[OP_LOG_FILE_W_MAXSIZE + 1] = {0};
- static void op_log_write(const char *log_data) { size_t w_size; @@ -414,3 +415,23 @@ SIGNAL_LOG_OUT: (void)close(fd); (void)uda_unfcntl(&op_log_fd, UDA_FLOCK_BLOCK); } + +static void signal_handle(int arg) +{ + signal_op_log_write(arg); + hikp_unlock(); + _exit(1); +} + +void sig_init(void) +{ + (void)signal(SIGINT, signal_handle); /* Quit process */ + (void)signal(SIGTERM, signal_handle); + (void)signal(SIGQUIT, signal_handle); + (void)signal(SIGHUP, signal_handle); + (void)signal(SIGSEGV, signal_handle); + (void)signal(SIGBUS, signal_handle); + (void)signal(SIGFPE, signal_handle); + (void)signal(SIGABRT, signal_handle); + (void)signal(SIGTSTP, signal_handle); /* Stop process */ +} diff --git a/tool_lib/op_logs.h b/tool_lib/op_logs.h index 597f063..6b6e421 100644 --- a/tool_lib/op_logs.h +++ b/tool_lib/op_logs.h @@ -45,7 +45,8 @@ struct op_log_print_t { char *str; };
-void signal_op_log_write(int signal_code); +void sig_init(void); + void op_log_on(void); void op_log_off(void); int op_log_initialise(const char *log_dir);
From: veega2022 zhuweijia@huawei.com
the AP_INT module is abandoned, so deleted this module and do not dump this module reg
Signed-off-by: hesiyuan hesiyuan4@huawei.com --- pcie/func_lib/pcie_func/pcie_reg_read.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/pcie/func_lib/pcie_func/pcie_reg_read.c b/pcie/func_lib/pcie_func/pcie_reg_read.c index 6ba4f07..b3d4643 100644 --- a/pcie/func_lib/pcie_func/pcie_reg_read.c +++ b/pcie/func_lib/pcie_func/pcie_reg_read.c @@ -30,7 +30,6 @@ static struct pcie_module_table g_module_table[] = { {"PCIPC_REG", PCIPC_REG_ID}, {"AP_MCTP_REG", AP_MCTP_REG_ID}, {"AP_ENGINE_REG", AP_ENGINE_REG_ID}, - {"AP_INT_REG", AP_INT_REG_ID}, {"AP_DMA_REG", AP_DMA_REG_ID}, {"TOP_REG", TOP_REG_ID}, {"CORE_GLOBAL_REG", CORE_GLOBAL_REG_ID},
From: veega2022 zhuweijia@huawei.com
The number of new chip registers may increase. Therefore, increase the number of dump registers.
Signed-off-by: wangkang wangkang124@hisilicon.com --- serdes/hikp_serdes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c index 89e66e1..dd9eee3 100644 --- a/serdes/hikp_serdes.c +++ b/serdes/hikp_serdes.c @@ -23,7 +23,7 @@
static struct cmd_serdes_param g_serdes_param = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-#define SERDES_OUTPUT_MAX_SIZE 2048 +#define SERDES_OUTPUT_MAX_SIZE 2560 static char g_serdes_data_out_buf[SERDES_OUTPUT_MAX_SIZE] = {0};
static int cmd_serdes_maininfo_help(struct major_cmd_ctrl *self, const char *argv)
From: veega2022 zhuweijia@huawei.com
Traverse the PCS registers of all lanes under the current core.
Signed-off-by: hesiyuan hesiyuan4@huawei.com --- pcie/func_lib/pcie_func/pcie_reg_dump.c | 36 +++++++++++------------- pcie/func_lib/pcie_func/pcie_reg_dump.h | 10 +++++++ pcie/usr_cmd/interface/pcie_common_api.h | 4 +++ 3 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.c b/pcie/func_lib/pcie_func/pcie_reg_dump.c index 7d91969..e10ff7e 100644 --- a/pcie/func_lib/pcie_func/pcie_reg_dump.c +++ b/pcie/func_lib/pcie_func/pcie_reg_dump.c @@ -108,13 +108,13 @@ struct pcie_dumpreg_info g_reg_table_mac[] = { };
struct pcie_dumpreg_info g_reg_table_pcs[] = { - {0, "SERDES_STATUS_RPT"}, - {0, "EBUF_STATUS"}, - {0, "GEN3_DEC_ENC_STATUS"}, - {0, "WAKE_STATUS"}, - {0, "RECV_DET_OR_PWR_CHAGE"}, - {0, "EQEVAL_STATUS"}, - {0, "LANE_INTR_STATUS"}, + HIKP_PCIE_PCS_LANE_TBL_ENTRY(SERDES_STATUS_RPT), + HIKP_PCIE_PCS_LANE_TBL_ENTRY(EBUF_STATUS), + HIKP_PCIE_PCS_LANE_TBL_ENTRY(GEN3_DEC_ENC_STATUS), + HIKP_PCIE_PCS_LANE_TBL_ENTRY(WAKE_STATUS), + HIKP_PCIE_PCS_LANE_TBL_ENTRY(RECV_DET_OR_PWR_CHAGE), + HIKP_PCIE_PCS_LANE_TBL_ENTRY(EQEVAL_STATUS), + HIKP_PCIE_PCS_LANE_TBL_ENTRY(LANE_INTR_STATUS), };
struct pcie_dumpreg_info g_reg_table_iob_tx[] = { @@ -348,6 +348,13 @@ static void pcie_dumpreg_save_glb_analysis_log(const uint32_t *data, uint32_t da pcie_dumpreg_write_value_to_file(g_reg_table_core_glb[item_i].name, g_reg_table_core_glb[item_i].val); } + /* PCS REG */ + for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_pcs) && + data_i < data_num; item_i++, data_i++) { + g_reg_table_pcs[item_i].val = data[data_i]; + pcie_dumpreg_write_value_to_file(g_reg_table_pcs[item_i].name, + g_reg_table_pcs[item_i].val); + } }
static void pcie_dumpreg_save_port_analysis_log(uint32_t *data, uint32_t data_num) @@ -376,13 +383,6 @@ static void pcie_dumpreg_save_port_analysis_log(uint32_t *data, uint32_t data_nu pcie_dumpreg_write_value_to_file(g_reg_table_mac[item_i].name, g_reg_table_mac[item_i].val); } - /* PCS REG */ - for (item_i = 0; item_i < HIKP_ARRAY_SIZE(g_reg_table_pcs) && - data_i < data_num; item_i++, data_i++) { - g_reg_table_pcs[item_i].val = data[data_i]; - pcie_dumpreg_write_value_to_file(g_reg_table_pcs[item_i].name, - g_reg_table_pcs[item_i].val); - } }
static int pcie_dumpreg_write_header_to_file(uint32_t version, @@ -421,14 +421,12 @@ static int pcie_dumpreg_save_log(uint32_t *data, uint32_t data_num, switch (req_data->level) { case DUMP_GLOBAL_LEVEL: expect_data_num = HIKP_ARRAY_SIZE(g_reg_table_iob_tx) + - HIKP_ARRAY_SIZE(g_reg_table_iob_rx) + HIKP_ARRAY_SIZE(g_reg_table_ap_glb) + - HIKP_ARRAY_SIZE(g_reg_table_core_glb); + HIKP_ARRAY_SIZE(g_reg_table_iob_rx) + HIKP_ARRAY_SIZE(g_reg_table_ap_glb) + + HIKP_ARRAY_SIZE(g_reg_table_core_glb) + HIKP_ARRAY_SIZE(g_reg_table_pcs); break; case DUMP_PORT_LEVEL: expect_data_num = HIKP_ARRAY_SIZE(g_reg_table_tl) + - HIKP_ARRAY_SIZE(g_reg_table_dl) + - HIKP_ARRAY_SIZE(g_reg_table_mac) + - HIKP_ARRAY_SIZE(g_reg_table_pcs); + HIKP_ARRAY_SIZE(g_reg_table_dl) + HIKP_ARRAY_SIZE(g_reg_table_mac); break; default: Err("PCIe DUMPREG", "check dump level failed.\n"); diff --git a/pcie/func_lib/pcie_func/pcie_reg_dump.h b/pcie/func_lib/pcie_func/pcie_reg_dump.h index 1993c1f..4ec1909 100644 --- a/pcie/func_lib/pcie_func/pcie_reg_dump.h +++ b/pcie/func_lib/pcie_func/pcie_reg_dump.h @@ -20,6 +20,16 @@ #define MAX_STR_LEN 80 #define PCIE_DUMPREG_LOGFILE_NAME "pcie_dumpreg"
+#define HIKP_PCIE_PCS_LANE_TBL_ENTRY(name) \ + {0, STR(CONTACT(name, _00))}, {0, STR(CONTACT(name, _01))}, \ + {0, STR(CONTACT(name, _02))}, {0, STR(CONTACT(name, _03))}, \ + {0, STR(CONTACT(name, _04))}, {0, STR(CONTACT(name, _05))}, \ + {0, STR(CONTACT(name, _06))}, {0, STR(CONTACT(name, _07))}, \ + {0, STR(CONTACT(name, _08))}, {0, STR(CONTACT(name, _09))}, \ + {0, STR(CONTACT(name, _10))}, {0, STR(CONTACT(name, _11))}, \ + {0, STR(CONTACT(name, _12))}, {0, STR(CONTACT(name, _13))}, \ + {0, STR(CONTACT(name, _14))}, {0, STR(CONTACT(name, _15))} + enum pcie_dump_level { DUMP_GLOBAL_LEVEL = 1, DUMP_PORT_LEVEL = 2, diff --git a/pcie/usr_cmd/interface/pcie_common_api.h b/pcie/usr_cmd/interface/pcie_common_api.h index f6541bd..9809575 100644 --- a/pcie/usr_cmd/interface/pcie_common_api.h +++ b/pcie/usr_cmd/interface/pcie_common_api.h @@ -17,6 +17,10 @@ #include <stdint.h> #include <stdio.h>
+#define CONTACT(x, y) x##y +#define STR_INTER(x) #x +#define STR(x) STR_INTER(x) + struct print_info { char *buff; size_t buff_size;
From: veega2022 zhuweijia@huawei.com
The hikptool ub_dfx command is submitted for the first time. This command can be used to dump register information of the LRB, PFA, and PM modules.
Signed-off-by: Jianqiang Li lijianqiang16@huawei.com --- libhikptdev/include/hikptdev_plug.h | 1 + net/hikp_net_lib.h | 9 + net/ub/ub_dfx/hikp_ub_dfx.c | 319 ++++++++++++++++++++++++++++ net/ub/ub_dfx/hikp_ub_dfx.h | 100 +++++++++ tool_lib/tool_lib.h | 2 +- 5 files changed, 430 insertions(+), 1 deletion(-) create mode 100644 net/ub/ub_dfx/hikp_ub_dfx.c create mode 100644 net/ub/ub_dfx/hikp_ub_dfx.h
diff --git a/libhikptdev/include/hikptdev_plug.h b/libhikptdev/include/hikptdev_plug.h index 42bea6b..56cea78 100644 --- a/libhikptdev/include/hikptdev_plug.h +++ b/libhikptdev/include/hikptdev_plug.h @@ -43,6 +43,7 @@ enum cmd_module_type { MAC_MOD = 8, DPDK_MOD = 9, CXL_MOD = 10, + UB_MOD = 11, };
void hikp_unlock(void); diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h index cc99d0c..af0a51d 100644 --- a/net/hikp_net_lib.h +++ b/net/hikp_net_lib.h @@ -98,6 +98,15 @@ enum roce_cmd_type { GET_ROCEE_TSP_CMD, };
+enum ub_cmd_type { + GET_UNIC_PPP_CMD = 0x1, + GET_UB_DFX_INFO_CMD, + GET_UB_LINK_INFO_CMD, + GET_UB_BP_INFO_CMD, + GET_UB_CRD_INFO_CMD, + GET_UB_BASIC_INFO_CMD, +}; + #define HIKP_MAX_PF_NUM 8 #define HIKP_NIC_MAX_FUNC_NUM 256
diff --git a/net/ub/ub_dfx/hikp_ub_dfx.c b/net/ub/ub_dfx/hikp_ub_dfx.c new file mode 100644 index 0000000..c50f555 --- /dev/null +++ b/net/ub/ub_dfx/hikp_ub_dfx.c @@ -0,0 +1,319 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#include "tool_cmd.h" +#include "hikp_net_lib.h" +#include "hikp_ub_dfx.h" + +struct ub_dfx_param g_ub_dfx_param = { 0 }; + +static const struct dfx_module_cmd g_ub_dfx_module_parse[] = { + {"LRB", LRB_DFX_REG_DUMP}, + {"PFA", PFA_DFX_REG_DUMP}, + {"PM", PM_DFX_REG_DUMP} +}; + +static const struct dfx_type_parse g_dfx_type_parse[] = { + {INCORRECT_REG_TYPE, WIDTH_32_BIT, "INCORRECT TYPE"}, + {TYPE_32_STATS, WIDTH_32_BIT, "32 bit statistics"}, + {TYPE_32_RUNNING_STATUS, WIDTH_32_BIT, "32 bit running status"}, + {TYPE_64_STATS, WIDTH_64_BIT, "64 bit statistics"}, +}; + +static void dfx_help_info(const struct major_cmd_ctrl *self) +{ + printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i <interface>\n"); + printf("\n %s\n", self->cmd_ptr->help_info); + printf(" Options:\n\n"); + printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); + printf(" %s, %-25s %s\n", "-i", "--interface=<interface>", + "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); + printf(" %s\n", " [-m/--module LRB/PFA/PM] : this is necessary param\n"); +} + +static int hikp_ub_dfx_help(struct major_cmd_ctrl *self, const char *argv) +{ + dfx_help_info(self); + return 0; +} + +static int hikp_ub_dfx_target(struct major_cmd_ctrl *self, const char *argv) +{ + self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ub_dfx_param.target)); + if (self->err_no != 0) { + snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); + return self->err_no; + } + + return 0; +} + +static int hikp_ub_dfx_module_select(struct major_cmd_ctrl *self, const char *argv) +{ + size_t arr_size = HIKP_ARRAY_SIZE(g_ub_dfx_module_parse); + bool is_found; + size_t i; + + for (i = 0; i < arr_size; i++) { + is_found = strncmp(argv, (const char *)g_ub_dfx_module_parse[i].module_name, + sizeof(g_ub_dfx_module_parse[i].module_name)) == 0; + if (is_found) { + g_ub_dfx_param.sub_cmd_code = g_ub_dfx_module_parse[i].sub_cmd_code; + g_ub_dfx_param.module_idx = i; + g_ub_dfx_param.flag |= MODULE_SET_FLAG; + return 0; + } + } + dfx_help_info(self); + snprintf(self->err_str, sizeof(self->err_str), "-m/--module param error!!!"); + self->err_no = -EINVAL; + + return -EINVAL; +} + +static int hikp_ub_dfx_get_blk_data(struct hikp_cmd_ret **cmd_ret, + uint32_t blk_id, uint32_t sub_cmd_code) +{ + struct hikp_cmd_header req_header = { 0 }; + struct ub_dfx_req_para req_data = { 0 }; + + req_data.bdf = g_ub_dfx_param.target.bdf; + req_data.block_id = blk_id; + hikp_cmd_init(&req_header, UB_MOD, GET_UB_DFX_INFO_CMD, sub_cmd_code); + *cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); + + return hikp_rsp_normal_check(*cmd_ret); +} + +static int hikp_ub_get_first_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t **reg_data, + uint32_t *max_dfx_size, uint32_t *version) +{ + struct ub_dfx_rsp *dfx_rsp = NULL; + struct hikp_cmd_ret *cmd_ret; + int ret; + + ret = hikp_ub_dfx_get_blk_data(&cmd_ret, 0, g_ub_dfx_param.sub_cmd_code); + if (ret < 0) + goto err_out; + + dfx_rsp = (struct ub_dfx_rsp *)(cmd_ret->rsp_data); + *version = cmd_ret->version; + *rsp_head = dfx_rsp->rsp_head; + if (rsp_head->total_blk_num == 0) { + /* if total block number is zero, set total type number to zero anyway */ + rsp_head->total_type_num = 0; + goto err_out; + } + *max_dfx_size = (uint32_t)(rsp_head->total_blk_num * MAX_DFX_DATA_NUM * sizeof(uint32_t)); + *reg_data = (uint32_t *)calloc(1, *max_dfx_size); + if (*reg_data == NULL) { + HIKP_ERROR_PRINT("malloc log memory 0x%x failed.\n", *max_dfx_size); + ret = -ENOMEM; + goto err_out; + } + + if (rsp_head->cur_blk_size > *max_dfx_size) { + free(*reg_data); + *reg_data = NULL; + HIKP_ERROR_PRINT("blk0 reg_data copy size error, data size: 0x%x, max size: 0x%x\n", + rsp_head->cur_blk_size, *max_dfx_size); + ret = -EINVAL; + goto err_out; + } + memcpy(*reg_data, dfx_rsp->reg_data, rsp_head->cur_blk_size); + + *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; +err_out: + free(cmd_ret); + cmd_ret = NULL; + + return ret; +} + +static int hikp_ub_get_blk_dfx(struct ub_dfx_rsp_head *rsp_head, uint32_t blk_id, + uint32_t *reg_data, uint32_t *max_dfx_size) +{ + struct ub_dfx_rsp *dfx_rsp = NULL; + struct hikp_cmd_ret *cmd_ret; + int ret; + + ret = hikp_ub_dfx_get_blk_data(&cmd_ret, blk_id, g_ub_dfx_param.sub_cmd_code); + if (ret < 0) + goto err_out; + + dfx_rsp = (struct ub_dfx_rsp *)(cmd_ret->rsp_data); + *rsp_head = dfx_rsp->rsp_head; + if (rsp_head->cur_blk_size > *max_dfx_size) { + HIKP_ERROR_PRINT("blk%u reg_data copy size error, " + "data size: 0x%x, max size: 0x%x\n", + blk_id, rsp_head->cur_blk_size, *max_dfx_size); + ret = -EINVAL; + goto err_out; + } + memcpy(reg_data, dfx_rsp->reg_data, rsp_head->cur_blk_size); + *max_dfx_size -= (uint32_t)rsp_head->cur_blk_size; + +err_out: + free(cmd_ret); + cmd_ret = NULL; + + return ret; +} + +static bool is_type_found(uint16_t type_id, uint32_t *index) +{ + size_t arr_size = HIKP_ARRAY_SIZE(g_dfx_type_parse); + size_t i; + + for (i = 0; i < arr_size; i++) { + if (g_dfx_type_parse[i].type_id == type_id) { + *index = i; + return true; + } + } + + return false; +} + +static void hikp_ub_dfx_print_type_head(uint8_t type_id, uint8_t *last_type_id) +{ + uint32_t index = 0; + + if (type_id != *last_type_id) { + printf("-----------------------------------------------------\n"); + if (is_type_found(type_id, &index)) + printf("type name: %s\n\n", g_dfx_type_parse[index].type_name); + else + HIKP_WARN_PRINT("type name: unknown type, type id is %u\n\n", type_id); + + *last_type_id = type_id; + } +} + +static void hikp_ub_dfx_print_b32(uint32_t num, uint32_t *reg_data) +{ + uint32_t word_num = num * WORD_NUM_PER_REG; + uint16_t offset; + uint32_t value; + uint32_t index; + uint32_t i; + + for (i = 0, index = 1; i < word_num; i = i + WORD_NUM_PER_REG, index++) { + offset = (uint16_t)HI_GET_BITFIELD(reg_data[i], 0, DFX_REG_ADDR_MASK); + value = reg_data[i + 1]; + printf("%03u: 0x%04x\t0x%08x\n", index, offset, value); + } +} + +static void hikp_ub_dfx_print_b64(uint32_t num, uint32_t *reg_data) +{ + uint32_t word_num = num * WORD_NUM_PER_REG; + uint16_t offset; + uint64_t value; + uint32_t index; + uint32_t i; + + for (i = 0, index = 1; i < word_num; i = i + WORD_NUM_PER_REG, index++) { + offset = (uint16_t)HI_GET_BITFIELD(reg_data[i], 0, DFX_REG_ADDR_MASK); + value = (uint64_t)reg_data[i + 1] | + (HI_GET_BITFIELD((uint64_t)reg_data[i], DFX_REG_VALUE_OFF, + DFX_REG_VALUE_MASK) << BIT_NUM_OF_WORD); + printf("%03u: 0x%04x\t0x%016lx\n", index, offset, value); + } +} + +static void hikp_ub_dfx_print(const struct ub_dfx_rsp_head *rsp_head, uint32_t *reg_data) +{ + struct ub_dfx_type_head *type_head; + uint8_t last_type_id = 0; + uint32_t *ptr = reg_data; + uint8_t i; + + printf("****************** module %s reg dump start ********************\n", + g_ub_dfx_module_parse[g_ub_dfx_param.module_idx].module_name); + for (i = 0; i < rsp_head->total_type_num; i++) { + type_head = (struct ub_dfx_type_head *)ptr; + if (type_head->type_id == INCORRECT_REG_TYPE) { + HIKP_ERROR_PRINT("No.%u type is incorrect reg type\n", i + 1u); + break; + } + hikp_ub_dfx_print_type_head(type_head->type_id, &last_type_id); + ptr++; + if (type_head->bit_width == WIDTH_32_BIT) { + hikp_ub_dfx_print_b32((uint32_t)type_head->reg_num, ptr); + } else if (type_head->bit_width == WIDTH_64_BIT) { + hikp_ub_dfx_print_b64((uint32_t)type_head->reg_num, ptr); + } else { + HIKP_ERROR_PRINT("type%u's bit width error.\n", type_head->type_id); + break; + } + ptr += (uint32_t)type_head->reg_num * WORD_NUM_PER_REG; + } + printf("################### ====== dump end ====== ######################\n"); +} + +static void hikp_ub_dfx_execute(struct major_cmd_ctrl *self) +{ + struct ub_dfx_rsp_head rsp_head = { 0 }; + struct ub_dfx_rsp_head tmp_head = { 0 }; + uint32_t *reg_data = NULL; + uint32_t max_dfx_size = 0; + uint32_t real_reg_size; + uint32_t version; + uint32_t i; + + if (!(g_ub_dfx_param.flag & MODULE_SET_FLAG)) { + self->err_no = -EINVAL; + snprintf(self->err_str, sizeof(self->err_str), "Please specify a module."); + dfx_help_info(self); + return; + } + + self->err_no = hikp_ub_get_first_blk_dfx(&rsp_head, ®_data, &max_dfx_size, &version); + if (self->err_no != 0) { + snprintf(self->err_str, sizeof(self->err_str), "get the first block dfx fail."); + return; + } + real_reg_size = (uint32_t)rsp_head.cur_blk_size; + for (i = 1; i < rsp_head.total_blk_num; i++) { + self->err_no = hikp_ub_get_blk_dfx(&tmp_head, i, + reg_data + (real_reg_size / sizeof(uint32_t)), + &max_dfx_size); + if (self->err_no != 0) { + snprintf(self->err_str, sizeof(self->err_str), + "getting block%u reg fail.", i); + free(reg_data); + return; + } + real_reg_size += (uint32_t)tmp_head.cur_blk_size; + memset(&tmp_head, 0, sizeof(struct ub_dfx_rsp_head)); + } + + printf("DFX cmd version: 0x%x\n\n", version); + hikp_ub_dfx_print((const struct ub_dfx_rsp_head *)&rsp_head, reg_data); + free(reg_data); +} + +static void cmd_ub_dfx_init(void) +{ + struct major_cmd_ctrl *major_cmd = get_major_cmd(); + + major_cmd->option_count = 0; + major_cmd->execute = hikp_ub_dfx_execute; + + cmd_option_register("-h", "--help", false, hikp_ub_dfx_help); + cmd_option_register("-i", "--interface", true, hikp_ub_dfx_target); + cmd_option_register("-m", "--module", true, hikp_ub_dfx_module_select); +} + +HIKP_CMD_DECLARE("ub_dfx", "dump ub dfx info of hardware", cmd_ub_dfx_init); diff --git a/net/ub/ub_dfx/hikp_ub_dfx.h b/net/ub/ub_dfx/hikp_ub_dfx.h new file mode 100644 index 0000000..4ba37a1 --- /dev/null +++ b/net/ub/ub_dfx/hikp_ub_dfx.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#ifndef HIKP_UB_DFX_H +#define HIKP_UB_DFX_H + +#include "hikp_net_lib.h" + +#define MAX_DFX_DATA_NUM 59 +#define MODULE_SET_FLAG 0x1 + +enum ub_dfx_cmd_type { + LRB_DFX_REG_DUMP = 0, + PFA_DFX_REG_DUMP = 1, + PM_DFX_REG_DUMP = 2, + INVALID_MODULE = 0xFFFFFFFF, +}; + +enum ub_dfx_reg_type { + INCORRECT_REG_TYPE = 0, + TYPE_32_STATS = 1, + TYPE_32_RUNNING_STATUS = 2, + TYPE_64_STATS = 3, + TYPE_INVALID = 255, +}; + +#define MAX_TYPE_NAME_LEN 40 + +enum ub_dfx_reg_width { + WIDTH_32_BIT = 32, + WIDTH_64_BIT = 64, +}; + +struct dfx_type_parse { + uint8_t type_id; + uint8_t bit_width; + uint8_t type_name[MAX_TYPE_NAME_LEN]; +}; + +struct ub_dfx_param { + struct tool_target target; + uint32_t sub_cmd_code; + uint8_t module_idx; + uint8_t flag; +}; + +#define MAX_MODULE_NAME_LEN 20 +struct dfx_module_cmd { + uint8_t module_name[MAX_MODULE_NAME_LEN]; + uint32_t sub_cmd_code; +}; + +struct ub_dfx_req_para { + struct bdf_t bdf; + uint8_t block_id; +}; + +struct ub_dfx_type_head { + uint8_t type_id; + uint8_t bit_width; + uint8_t reg_num; + uint8_t flag; +}; + +struct ub_dfx_rsp_head { + uint8_t total_blk_num; + uint8_t total_type_num; + uint8_t cur_blk_size; + uint8_t rsvd; +}; + +/********************************************************* + * All registers are returned as key-value pairs, and divided + * into three groups of data. + * 1. 32bit regs: R0 bit0~bit15: offset, R1 bit0~bit31: value + * 2. 64bit regs: R0 bit0~bit15: offset, R0 bit16~bit31 high16 value, R1 bit0~bit31: low32 value + *********************************************************/ +#define DFX_REG_VALUE_OFF 16 +#define DFX_REG_VALUE_MASK 0xFFFF +#define DFX_REG_ADDR_MASK 0xFFFF + +#define WORD_NUM_PER_REG 2 +#define BIT_NUM_OF_WORD 32 + +struct ub_dfx_rsp { + struct ub_dfx_rsp_head rsp_head; + uint32_t reg_data[MAX_DFX_DATA_NUM]; +}; + +#endif /* HIKP_UB_DFX_H */ diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h index b211175..bf37465 100644 --- a/tool_lib/tool_lib.h +++ b/tool_lib/tool_lib.h @@ -18,7 +18,7 @@
#define TOOL_NAME "hikptool"
-#define TOOL_VER "1.0.13" +#define TOOL_VER "1.0.14"
#define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask)) #define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift))
From: veega2022 zhuweijia@huawei.com
if reg dump block data num is 0, print not support dump and return. hikptool version: 1.0.15
Signed-off-by: veega2022 zhuweijia@huawei.com --- net/nic/nic_mac/hikp_nic_mac_dump.c | 5 +++++ tool_lib/tool_lib.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/nic/nic_mac/hikp_nic_mac_dump.c b/net/nic/nic_mac/hikp_nic_mac_dump.c index 6e856a8..3e818cd 100644 --- a/net/nic/nic_mac/hikp_nic_mac_dump.c +++ b/net/nic/nic_mac/hikp_nic_mac_dump.c @@ -64,6 +64,11 @@ static int mac_cmd_dump_mod(struct major_cmd_ctrl *self, const char *name, uint32_t i; int ret;
+ if (blk_num == 0) { + printf("%s module is not support dump.\n", name); + return 0; + } + printf("============ %10s REG INFO ==============\n", name); printf("\t %s :\t%10s\n", "offset", "value");
diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h index bf37465..9766a7e 100644 --- a/tool_lib/tool_lib.h +++ b/tool_lib/tool_lib.h @@ -18,7 +18,7 @@
#define TOOL_NAME "hikptool"
-#define TOOL_VER "1.0.14" +#define TOOL_VER "1.0.15"
#define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask)) #define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift))
From: veega2022 zhuweijia@huawei.com
The hikptool ub_link command is submitted for the first time. This command can be used to query the link state machine and status statistics during link establishment.
Signed-off-by: Jianqiang Li lijianqiang16@huawei.com --- net/ub/ub_link/hikp_ub_link.c | 98 +++++++++++++++++++++++++++++++++++ net/ub/ub_link/hikp_ub_link.h | 53 +++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 net/ub/ub_link/hikp_ub_link.c create mode 100644 net/ub/ub_link/hikp_ub_link.h
diff --git a/net/ub/ub_link/hikp_ub_link.c b/net/ub/ub_link/hikp_ub_link.c new file mode 100644 index 0000000..b6353f7 --- /dev/null +++ b/net/ub/ub_link/hikp_ub_link.c @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#include "hikp_ub_link.h" + +static struct ub_link_param g_ub_link_param = { 0 }; + +static int hikp_ub_link_help(struct major_cmd_ctrl *self, const char *argv) +{ + printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i <interface>\n"); + printf("\n %s\n", self->cmd_ptr->help_info); + printf(" Options:\n\n"); + printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); + printf(" %s, %-25s %s\n", "-i", "--interface=<interface>", + "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); + printf("\n"); + return 0; +} + +static int hikp_ub_link_target(struct major_cmd_ctrl *self, const char *argv) +{ + self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ub_link_param.target)); + if (self->err_no != 0) { + snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); + return self->err_no; + } + + return 0; +} + +static void hikp_ub_link_info_show(const struct ub_link_rsp *info) +{ + printf("%-32s %u\n", "mac id:", info->mac_id); + printf("%-32s %s\n", "hdlc link status:", info->hdlc_link ? "true" : "false"); + printf("%-32s %s\n", "hpcs link status:", info->hpcs_link ? "true" : "false"); + printf("%-32s 0x%08x\n", "hdlc_link_fsm register value:", info->hdlc_link_fsm); + printf("%-32s 0x%08x\n", "hpcs_link_fsm register value:", info->hpcs_link_fsm); +} + +static int hikp_ub_query_link_info(const struct bdf_t *bdf) +{ + struct hikp_cmd_header header = { 0 }; + struct ub_link_req_paras req = { 0 }; + struct hikp_cmd_ret *cmd_ret; + struct ub_link_rsp *rsp; + + req.bdf = *bdf; + hikp_cmd_init(&header, UB_MOD, GET_UB_LINK_INFO_CMD, UB_LINK_INFO_DUMP); + cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); + if (cmd_ret == NULL || cmd_ret->status != 0) { + free(cmd_ret); + cmd_ret = NULL; + return -EIO; + } + + rsp = (struct ub_link_rsp *)cmd_ret->rsp_data; + hikp_ub_link_info_show(rsp); + + free(cmd_ret); + cmd_ret = NULL; + return 0; +} + +static void hikp_ub_link_cmd_execute(struct major_cmd_ctrl *self) +{ + struct bdf_t *bdf = &g_ub_link_param.target.bdf; + int ret; + + ret = hikp_ub_query_link_info(bdf); + if (ret != 0) { + snprintf(self->err_str, sizeof(self->err_str), "fail to get link info."); + self->err_no = ret; + return; + } +} + +static void cmd_ub_link_init(void) +{ + struct major_cmd_ctrl *major_cmd = get_major_cmd(); + + major_cmd->option_count = 0; + major_cmd->execute = hikp_ub_link_cmd_execute; + + cmd_option_register("-h", "--help", false, hikp_ub_link_help); + cmd_option_register("-i", "--interface", true, hikp_ub_link_target); +} + +HIKP_CMD_DECLARE("ub_link", "get ub link information", cmd_ub_link_init); diff --git a/net/ub/ub_link/hikp_ub_link.h b/net/ub/ub_link/hikp_ub_link.h new file mode 100644 index 0000000..dec5129 --- /dev/null +++ b/net/ub/ub_link/hikp_ub_link.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#ifndef HIKP_UB_LINK_H +#define HIKP_UB_LINK_H + +#include "hikp_net_lib.h" + +enum ub_link_sub_cmd_type { + UB_LINK_INFO_DUMP = 0, +}; + +struct ub_link_param { + struct tool_target target; +}; + +struct ub_link_req_paras { + struct bdf_t bdf; +}; + +struct ub_link_rsp { + uint8_t mac_id; + uint8_t hdlc_link; + uint8_t hpcs_link; + uint8_t rsvd; + uint32_t hdlc_link_fsm; + uint32_t hpcs_link_fsm; +}; + +#endif /* HIKP_UB_LINK_H */
From: veega2022 zhuweijia@huawei.com
The hikptool ub_bp command is submitted for the first time. This command can be used to query the back pressure status of the VL in the UB-N.
Signed-off-by: Jianqiang Li lijianqiang16@huawei.com --- net/ub/ub_bp/hikp_ub_bp.c | 102 ++++++++++++++++++++++++++++++++++++++ net/ub/ub_bp/hikp_ub_bp.h | 39 +++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 net/ub/ub_bp/hikp_ub_bp.c create mode 100644 net/ub/ub_bp/hikp_ub_bp.h
diff --git a/net/ub/ub_bp/hikp_ub_bp.c b/net/ub/ub_bp/hikp_ub_bp.c new file mode 100644 index 0000000..70a9a4b --- /dev/null +++ b/net/ub/ub_bp/hikp_ub_bp.c @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#include "hikp_ub_bp.h" + +static struct ub_bp_param g_ub_bp_param = { 0 }; + +static int hikp_ub_bp_help(struct major_cmd_ctrl *self, const char *argv) +{ + printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i <interface>\n"); + printf("\n %s\n", self->cmd_ptr->help_info); + printf(" Options:\n\n"); + printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); + printf(" %s, %-25s %s\n", "-i", "--interface=<interface>", + "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); + printf("\n"); + return 0; +} + +static int hikp_ub_bp_target(struct major_cmd_ctrl *self, const char *argv) +{ + self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ub_bp_param.target)); + if (self->err_no) { + snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); + return self->err_no; + } + return 0; +} + +static void hikp_ub_bp_info_show(const struct ub_bp_rsp *info) +{ + int bp_val_offset; + + printf("%-28s : %u\n", "mac id", info->mac_id); + printf("%-28s : ", "back pressure status"); + + for (bp_val_offset = MAX_VL_NUM; bp_val_offset >= 0; bp_val_offset--) { + printf("%d", HI_GETBIT(info->bp_val, bp_val_offset) ? 1 : 0); + } + printf("\n"); +} + + +static int hikp_ub_query_bp(const struct bdf_t *bdf) +{ + struct hikp_cmd_header header = { 0 }; + struct ub_bp_req_para req = { 0 }; + struct hikp_cmd_ret *cmd_ret; + struct ub_bp_rsp *rsp; + + req.bdf = *bdf; + hikp_cmd_init(&header, UB_MOD, GET_UB_BP_INFO_CMD, UB_BP_INFO_DUMP); + cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); + if (cmd_ret == NULL || cmd_ret->status != 0) { + free(cmd_ret); + cmd_ret = NULL; + return -EIO; + } + + rsp = (struct ub_bp_rsp *)cmd_ret->rsp_data; + hikp_ub_bp_info_show(rsp); + + free(cmd_ret); + cmd_ret = NULL; + return 0; +} + +static void hikp_ub_bp_cmd_execute(struct major_cmd_ctrl *self) +{ + struct bdf_t *bdf = &g_ub_bp_param.target.bdf; + int ret; + + ret = hikp_ub_query_bp(bdf); + if (ret != 0) { + snprintf(self->err_str, sizeof(self->err_str), "fail to get ub bp info."); + self->err_no = ret; + return; + } +} + +static void cmd_ub_bp_init(void) +{ + struct major_cmd_ctrl *major_cmd = get_major_cmd(); + + major_cmd->option_count = 0; + major_cmd->execute = hikp_ub_bp_cmd_execute; + + cmd_option_register("-h", "--help", false, hikp_ub_bp_help); + cmd_option_register("-i", "--interface", true, hikp_ub_bp_target); +} + +HIKP_CMD_DECLARE("ub_bp", "get ub bp information", cmd_ub_bp_init); diff --git a/net/ub/ub_bp/hikp_ub_bp.h b/net/ub/ub_bp/hikp_ub_bp.h new file mode 100644 index 0000000..0bd4740 --- /dev/null +++ b/net/ub/ub_bp/hikp_ub_bp.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#ifndef HIKP_UB_BP_H +#define HIKP_UB_BP_H + +#include "hikp_net_lib.h" + +#define MAX_VL_NUM 17 + +enum ub_bp_sub_cmd_type { + UB_BP_INFO_DUMP = 0, +}; + +struct ub_bp_param { + struct tool_target target; +}; + +struct ub_bp_req_para { + struct bdf_t bdf; +}; + +struct ub_bp_rsp { + uint8_t mac_id; + uint8_t rsvd[3]; + uint32_t bp_val; +}; + +#endif /* HIKP_UB_BP_H */
From: veega2022 zhuweijia@huawei.com
The hikptool ub_crd command is submitted for the first time. This command is used to query the letter of credit status by reading the register value.
Signed-off-by: Jianqiang Li lijianqiang16@huawei.com --- net/ub/ub_crd/hikp_ub_crd.c | 133 ++++++++++++++++++++++++++++++++++++ net/ub/ub_crd/hikp_ub_crd.h | 44 ++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 net/ub/ub_crd/hikp_ub_crd.c create mode 100644 net/ub/ub_crd/hikp_ub_crd.h
diff --git a/net/ub/ub_crd/hikp_ub_crd.c b/net/ub/ub_crd/hikp_ub_crd.c new file mode 100644 index 0000000..d5d0015 --- /dev/null +++ b/net/ub/ub_crd/hikp_ub_crd.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#include "hikp_ub_crd.h" + +static struct ub_crd_param g_ub_crd_param = { 0 }; + +static int hikp_ub_crd_help(struct major_cmd_ctrl *self, const char *argv) +{ + printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i <interface>\n"); + printf("\n %s\n", self->cmd_ptr->help_info); + printf(" Options:\n\n"); + printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); + printf(" %s, %-25s %s\n", "-i", "--interface=<interface>", + "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); + printf("\n"); + return 0; +} + +static int hikp_ub_crd_target(struct major_cmd_ctrl *self, const char *argv) +{ + self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ub_crd_param.target)); + if (self->err_no) { + snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); + return self->err_no; + } + return 0; +} + +static int hikp_ub_show_crd(uint32_t off, struct ub_crd_rsp *crd_rsp, uint32_t num_rows, + char const *crds[][2]) +{ + int reg_index; + int i; + + for (i = 0; i < num_rows; i++) { + union cut_reg reg; + + reg_index = off + i; + reg.value = crd_rsp->cut_reg_value[reg_index]; + if (strcmp(crds[i][0], "NULL") != 0) + printf("%-28s : %#x\n", crds[i][0], reg.cut[0]); + + if (strcmp(crds[i][1], "NULL") != 0) + printf("%-28s : %#x\n", crds[i][1], reg.cut[1]); + } + return off + num_rows; +} + +static int hikp_ub_query_crd(void) +{ + struct hikp_cmd_header req_header = { 0 }; + struct ub_crd_req_para req_data = { 0 }; + struct hikp_cmd_ret *cmd_ret = NULL; + struct ub_crd_rsp *crd_rsp = NULL; + int offset; + int ret; + + char const *init_crds[][2] = { + {"CFG_REMOTE_ICRD", "CFG_REMOTE_LCRD"}, + {"CFG_REMOTE_CRD_VL6", "CFG_REMOTE_CRD_VL7"}, + {"CFG_REMOTE_CRD_VL4", "CFG_REMOTE_CRD_VL5"}, + {"CFG_REMOTE_CRD_VL2", "CFG_REMOTE_CRD_VL3"}, + {"CFG_REMOTE_CRD_VL0", "CFG_REMOTE_CRD_VL1"}, + {"CFG_REMOTE_CRD_VL8", "NULL"} }; + + char const *temp_crds[][2] = { + {"TX_LCRD_VNA_EXIST_NUM", "NULL"}, {"TX_ICRD_VNA_EXIST_NUM", "NULL"}, + {"TX_CRD_VN0_EXIST_NUM", "NULL"}, {"TX_CRD_VN1_EXIST_NUM", "NULL"}, + {"TX_CRD_VN2_EXIST_NUM", "NULL"}, {"TX_CRD_VN3_EXIST_NUM", "NULL"}, + {"TX_CRD_VN4_EXIST_NUM", "NULL"}, {"TX_CRD_VN5_EXIST_NUM", "NULL"}, + {"TX_CRD_VN6_EXIST_NUM", "NULL"}, {"TX_CRD_VN7_EXIST_NUM", "NULL"}, + {"TX_ACK_EXIST_NUM", "NULL"}, {"TX_ROH_LCRD_LOCAL_NUM", "NULL"} }; + + hikp_cmd_init(&req_header, UB_MOD, GET_UB_CRD_INFO_CMD, UB_CRD_INFO_DUMP); + req_data.bdf = g_ub_crd_param.target.bdf; + cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); + if (cmd_ret == NULL || cmd_ret->status != 0) { + free(cmd_ret); + cmd_ret = NULL; + return -EIO; + } + + crd_rsp = (struct ub_crd_rsp *)(cmd_ret->rsp_data); + + printf("******************** CREDIT CNT START ********************\n"); + printf("------------------- INIT CREDIT START -----------------\n"); + offset = hikp_ub_show_crd(0, crd_rsp, NUM_ROWS_INIT_CRDS, init_crds); + printf("------------------- INIT CREDIT END --------------------\n"); + printf("------------------- TEMP CREDIT START ------------------\n"); + offset = hikp_ub_show_crd(offset, crd_rsp, NUM_ROWS_TEMP_CRDS, temp_crds); + printf("------------------- TEMP CREDIT END --------------------\n"); + printf("********************* CREDIT CNT END *********************\n"); + + free(cmd_ret); + cmd_ret = NULL; + return 0; +} + +static void hikp_ub_crd_cmd_execute(struct major_cmd_ctrl *self) +{ + int ret; + + ret = hikp_ub_query_crd(); + if (ret != 0) { + snprintf(self->err_str, sizeof(self->err_str), "fail to get ub crd info."); + self->err_no = ret; + return; + } +} + +static void cmd_ub_crd_init(void) +{ + struct major_cmd_ctrl *major_cmd = get_major_cmd(); + + major_cmd->option_count = 0; + major_cmd->execute = hikp_ub_crd_cmd_execute; + + cmd_option_register("-h", "--help", false, hikp_ub_crd_help); + cmd_option_register("-i", "--interface", true, hikp_ub_crd_target); +} + +HIKP_CMD_DECLARE("ub_crd", "get ub crd information", cmd_ub_crd_init); diff --git a/net/ub/ub_crd/hikp_ub_crd.h b/net/ub/ub_crd/hikp_ub_crd.h new file mode 100644 index 0000000..5dfa38a --- /dev/null +++ b/net/ub/ub_crd/hikp_ub_crd.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#ifndef HIKP_UB_CRD_H +#define HIKP_UB_CRD_H + +#include "hikp_net_lib.h" + +#define MAX_CRD_SIZE 20 +#define NUM_ROWS_INIT_CRDS 6 +#define NUM_ROWS_TEMP_CRDS 12 + +enum ub_crd_sub_cmd_type { + UB_CRD_INFO_DUMP = 0, +}; + +union cut_reg { + uint32_t value; + uint16_t cut[2]; +}; + +struct ub_crd_param { + struct tool_target target; +}; + +struct ub_crd_req_para { + struct bdf_t bdf; +}; + +struct ub_crd_rsp { + uint32_t cut_reg_value[MAX_CRD_SIZE]; +}; + +#endif /* HIKP_UB_CRD_H */
From: veega2022 zhuweijia@huawei.com
The hikptool ub_info command is submitted for the first time. This command is used to query whether the cloud attack defense function is enabled and query the single-port multi-stack working mode.
Signed-off-by: Jianqiang Li lijianqiang16@huawei.com --- net/ub/ub_info/hikp_ub_info.c | 96 +++++++++++++++++++++++++++++++++++ net/ub/ub_info/hikp_ub_info.h | 37 ++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 net/ub/ub_info/hikp_ub_info.c create mode 100644 net/ub/ub_info/hikp_ub_info.h
diff --git a/net/ub/ub_info/hikp_ub_info.c b/net/ub/ub_info/hikp_ub_info.c new file mode 100644 index 0000000..3b354dd --- /dev/null +++ b/net/ub/ub_info/hikp_ub_info.c @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#include "hikp_ub_info.h" + +static struct ub_info_param g_ub_info_param = { 0 }; + +static int hikp_ub_info_help(struct major_cmd_ctrl *self, const char *argv) +{ + printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i <interface>\n"); + printf("\n %s\n", self->cmd_ptr->help_info); + printf(" Options:\n\n"); + printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); + printf(" %s, %-25s %s\n", "-i", "--interface=<interface>", + "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); + printf("\n"); + return 0; +} + +static int hikp_ub_info_target(struct major_cmd_ctrl *self, const char *argv) +{ + self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_ub_info_param.target)); + if (self->err_no != 0) { + snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); + return self->err_no; + } + + return 0; +} + +static void hikp_ub_basic_info_show(const struct ub_info_rsp *info) +{ + printf("%-32s : %s\n", "cloud-based attack defense", info->cloud_mode ? "YES" : "NO"); + printf("%-32s : %s\n", "pf working mode", info->pf_drv_type ? "UB" : "RDMA"); + printf("%-32s : %s\n", "vf working mode", info->vf_drv_type ? "UB" : "RDMA"); +} + +static int hikp_ub_query_basic_info(const struct bdf_t *bdf) +{ + struct hikp_cmd_header header = { 0 }; + struct ub_info_req_para req = { 0 }; + struct hikp_cmd_ret *cmd_ret; + struct ub_info_rsp *rsp; + + req.bdf = *bdf; + hikp_cmd_init(&header, UB_MOD, GET_UB_BASIC_INFO_CMD, UB_BASIC_INFO_DUMP); + cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); + if (cmd_ret == NULL || cmd_ret->status != 0) { + free(cmd_ret); + cmd_ret = NULL; + return -EIO; + } + + rsp = (struct ub_info_rsp *)cmd_ret->rsp_data; + hikp_ub_basic_info_show(rsp); + + free(cmd_ret); + cmd_ret = NULL; + return 0; +} + +static void hikp_ub_info_cmd_execute(struct major_cmd_ctrl *self) +{ + struct bdf_t *bdf = &g_ub_info_param.target.bdf; + int ret; + + ret = hikp_ub_query_basic_info(bdf); + if (ret != 0) { + snprintf(self->err_str, sizeof(self->err_str), "fail to get basic info."); + self->err_no = ret; + return; + } +} + +static void cmd_ub_info_init(void) +{ + struct major_cmd_ctrl *major_cmd = get_major_cmd(); + + major_cmd->option_count = 0; + major_cmd->execute = hikp_ub_info_cmd_execute; + + cmd_option_register("-h", "--help", false, hikp_ub_info_help); + cmd_option_register("-i", "--interface", true, hikp_ub_info_target); +} + +HIKP_CMD_DECLARE("ub_info", "get ub basic information", cmd_ub_info_init); diff --git a/net/ub/ub_info/hikp_ub_info.h b/net/ub/ub_info/hikp_ub_info.h new file mode 100644 index 0000000..a9cb858 --- /dev/null +++ b/net/ub/ub_info/hikp_ub_info.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#ifndef HIKP_UB_INFO_H +#define HIKP_UB_INFO_H + +#include "hikp_net_lib.h" + +enum ub_info_sub_cmd_type { + UB_BASIC_INFO_DUMP = 0, +}; + +struct ub_info_param { + struct tool_target target; +}; + +struct ub_info_req_para { + struct bdf_t bdf; +}; + +struct ub_info_rsp { + uint32_t cloud_mode; + uint32_t pf_drv_type; + uint32_t vf_drv_type; +}; + +#endif /* HIKP_UB_INFO_H */
From: veega2022 zhuweijia@huawei.com
The function of reading IP and guid entries through the imp command is added.
Signed-off-by: Jianqiang Li lijianqiang16@huawei.com --- net/ub/ub_unic/hikp_unic_ppp.c | 468 +++++++++++++++++++++++++++++++++ net/ub/ub_unic/hikp_unic_ppp.h | 139 ++++++++++ 2 files changed, 607 insertions(+) create mode 100644 net/ub/ub_unic/hikp_unic_ppp.c create mode 100644 net/ub/ub_unic/hikp_unic_ppp.h
diff --git a/net/ub/ub_unic/hikp_unic_ppp.c b/net/ub/ub_unic/hikp_unic_ppp.c new file mode 100644 index 0000000..5325b03 --- /dev/null +++ b/net/ub/ub_unic/hikp_unic_ppp.c @@ -0,0 +1,468 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#include <string.h> +#include <stdio.h> +#include <sys/types.h> +#include <arpa/inet.h> +#include <unistd.h> +#include "hikp_unic_ppp.h" + +static struct hikp_unic_ppp_hw_resources g_unic_ppp_hw_res = { 0 }; +static struct unic_ppp_param g_unic_ppp_param = { 0 }; + +static void hikp_unic_ppp_show_ip_tbl(const void *data); +static void hikp_unic_ppp_show_guid_tbl(const void *data); + +static int hikp_unic_query_ppp_ip_tbl(struct hikp_cmd_header *req_header, + const struct bdf_t *bdf, void *data); +static int hikp_unic_query_ppp_guid_tbl(struct hikp_cmd_header *req_header, + const struct bdf_t *bdf, void *data); + +static const struct unic_ppp_feature_cmd g_unic_ppp_feature_cmd[] = { + { UNIC_PPP_IP_TBL_NAME, UNIC_IP_TBL_DUMP, true, + hikp_unic_query_ppp_ip_tbl, hikp_unic_ppp_show_ip_tbl }, + { UNIC_PPP_GUID_TBL_NAME, UNIC_GUID_TBL_DUMP, true, + hikp_unic_query_ppp_guid_tbl, hikp_unic_ppp_show_guid_tbl }, +}; + +static int hikp_unic_ppp_cmd_help(struct major_cmd_ctrl *self, const char *argv) +{ + printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i <interface>"); + printf("\n %s\n", self->cmd_ptr->help_info); + printf("\n Options:\n\n"); + printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); + printf(" %s, %-25s %s\n", "-i", "--interface=<interface>", + "device target or bdf id, e.g. ubn0 or 0000:35:00.0"); + printf(" %s, %-24s %s\n", "-du", "--dump", "dump ip or guid table info."); + + return 0; +} + +static int hikp_unic_cmd_get_ppp_target(struct major_cmd_ctrl *self, const char *argv) +{ + self->err_no = tool_check_and_get_valid_bdf_id(argv, &(g_unic_ppp_param.target)); + if (self->err_no != 0) { + snprintf(self->err_str, sizeof(self->err_str), "unknown device!"); + return self->err_no; + } + + return 0; +} + +static int hikp_unic_cmd_ppp_feature_select(struct major_cmd_ctrl *self, const char *argv) +{ + size_t feat_size = HIKP_ARRAY_SIZE(g_unic_ppp_feature_cmd); + size_t i; + + for (i = 0; i < feat_size; i++) { + if (strncmp(argv, g_unic_ppp_feature_cmd[i].feature_name, + HIKP_UNIC_PPP_MAX_FEATURE_NAME_LEN) == 0) { + g_unic_ppp_param.feature_idx = i; + return 0; + } + } + + hikp_unic_ppp_cmd_help(self, NULL); + snprintf(self->err_str, sizeof(self->err_str), "please input valid dump type."); + self->err_no = -EINVAL; + + return self->err_no; +} + +static int hikp_unic_ppp_get_blk(struct hikp_cmd_header *req_header, + const struct unic_ppp_req_para *req_data, void *buf, + size_t buf_len, struct unic_ppp_rsp_head *rsp_head) +{ + struct hikp_cmd_ret *cmd_ret; + struct unic_ppp_rsp *rsp; + int ret = 0; + + cmd_ret = hikp_cmd_alloc(req_header, req_data, sizeof(*req_data)); + if (cmd_ret == NULL || cmd_ret->status != 0) { + ret = -EIO; + goto out; + } + + rsp = (struct unic_ppp_rsp *)cmd_ret->rsp_data; + if (rsp->rsp_head.cur_blk_size > buf_len) { + HIKP_ERROR_PRINT("unic_ppp block context copy size error, " + "buffer size=%llu, data size=%u.\n", + buf_len, rsp->rsp_head.cur_blk_size); + ret = -EINVAL; + goto out; + } + memcpy(buf, rsp->rsp_data, rsp->rsp_head.cur_blk_size); + memcpy(rsp_head, &rsp->rsp_head, sizeof(struct unic_ppp_rsp_head)); + +out: + free(cmd_ret); + return ret; +} + +static int hikp_unic_query_ppp_by_blkid(struct hikp_cmd_header *req_header, const struct bdf_t *bdf, + void *data, size_t len) +{ + struct unic_ppp_rsp_head rsp_head = { 0 }; + struct unic_ppp_req_para req_data = { 0 }; + uint32_t total_blk_size; + uint8_t blk_id = 0; + int ret = 0; + + req_data.bdf = *bdf; + req_data.block_id = blk_id; + ret = hikp_unic_ppp_get_blk(req_header, &req_data, data, len, &rsp_head); + if (ret != 0) { + HIKP_ERROR_PRINT("Fail to get block-%u context.\n", blk_id); + return ret; + } + total_blk_size = rsp_head.cur_blk_size; + + for (blk_id = 1; blk_id < rsp_head.total_blk_num; blk_id++) { + req_data.block_id = blk_id; + ret = hikp_unic_ppp_get_blk(req_header, &req_data, (uint8_t *)data + total_blk_size, + len - total_blk_size, &rsp_head); + if (ret != 0) { + HIKP_ERROR_PRINT("Fail to get block-%u context.\n", blk_id); + return ret; + } + total_blk_size += rsp_head.cur_blk_size; + } + + return ret; +} + +static int hikp_unic_get_ppp_entry_hw_res(const struct bdf_t *bdf, + struct hikp_unic_ppp_hw_resources *hw_res) +{ + struct hikp_cmd_header req_header = { 0 }; + + hikp_cmd_init(&req_header, UB_MOD, GET_UNIC_PPP_CMD, UNIC_PPP_ENTRY_HW_SPEC_GET); + return hikp_unic_query_ppp_by_blkid(&req_header, bdf, hw_res, + sizeof(struct hikp_unic_ppp_hw_resources)); +} + +static int hikp_unic_ppp_alloc_ip_tbl_entry(const struct hikp_unic_ppp_hw_resources *hw_res, + struct unic_ip_tbl *ip_tbl) +{ + uint32_t max_ip_entry_size; + + max_ip_entry_size = hw_res->ip_max_mem_size + hw_res->ip_overflow_size; + if (max_ip_entry_size == 0) { + HIKP_ERROR_PRINT("ip tbl query is not supported\n"); + return -EIO; + } + ip_tbl->entry = (struct unic_ip_entry *)calloc(max_ip_entry_size, + sizeof(struct unic_ip_entry)); + if (ip_tbl->entry == NULL) { + HIKP_ERROR_PRINT("fail to alloc ip_table_entry memory.\n"); + return -ENOMEM; + } + + return 0; +} + +static int hikp_unic_ppp_alloc_guid_tbl_entry(const struct hikp_unic_ppp_hw_resources *hw_res, + struct unic_guid_tbl *guid_tbl) +{ + if (hw_res->uc_guid_tbl_size == 0 && hw_res->mc_guid_tbl_size == 0) { + HIKP_ERROR_PRINT("guid tbl query is not supported\n"); + return -EIO; + } + guid_tbl->uc_tbl.entry = (struct unic_guid_uc_entry *)calloc(hw_res->uc_guid_tbl_size, + sizeof(struct unic_guid_uc_entry)); + if (guid_tbl->uc_tbl.entry == NULL) { + HIKP_ERROR_PRINT("fail to alloc uc_guid_entry_table memory.\n"); + return -ENOMEM; + } + + guid_tbl->mc_tbl.entry = (struct unic_guid_mc_entry *)calloc(hw_res->mc_guid_tbl_size, + sizeof(struct unic_guid_mc_entry)); + if (guid_tbl->mc_tbl.entry == NULL) { + HIKP_ERROR_PRINT("fail to alloc mc_guid_entry_table memory.\n"); + free(guid_tbl->uc_tbl.entry); + return -ENOMEM; + } + + return 0; +} + +static union unic_ppp_feature_info* +hikp_unic_ppp_data_alloc(const struct unic_ppp_feature_cmd *unic_ppp_cmd, + const struct hikp_unic_ppp_hw_resources *hw_res) +{ + union unic_ppp_feature_info *unic_ppp_data; + int ret = -1; + + unic_ppp_data = (union unic_ppp_feature_info *)calloc(1, + sizeof(union unic_ppp_feature_info)); + if (unic_ppp_data == NULL) { + HIKP_ERROR_PRINT("Fail to allocate unic_ppp_feature_info memory.\n"); + return NULL; + } + + if (g_unic_ppp_param.feature_idx == UNIC_PPP_IP_FEATURE_IDX) { + ret = hikp_unic_ppp_alloc_ip_tbl_entry(hw_res, &unic_ppp_data->ip_tbl); + } else if (g_unic_ppp_param.feature_idx == UNIC_PPP_GUID_FEATURE_IDX) { + ret = hikp_unic_ppp_alloc_guid_tbl_entry(hw_res, &unic_ppp_data->guid_tbl); + } + + if (ret != 0) { + goto out; + } + + return unic_ppp_data; +out: + free(unic_ppp_data); + return NULL; +} + +static int hikp_unic_query_ppp_ip_tbl(struct hikp_cmd_header *req_header, const struct bdf_t *bdf, + void *data) +{ + struct unic_ip_tbl *ip_tbl = (struct unic_ip_tbl *)data; + struct unic_ppp_rsp_head unic_rsp_head = { 0 }; + struct unic_ppp_req_para req_data = { 0 }; + uint32_t max_ip_entry_size; + uint32_t entry_size = 0; + size_t left_buf_len = 0; + uint32_t index = 0; + int ret = -1; + + max_ip_entry_size = g_unic_ppp_hw_res.ip_max_mem_size + g_unic_ppp_hw_res.ip_overflow_size; + req_data.bdf = *bdf; + while (index < max_ip_entry_size) { + req_data.cur_entry_idx = index; + left_buf_len = sizeof(struct unic_ip_entry) * (max_ip_entry_size - entry_size); + ret = hikp_unic_ppp_get_blk(req_header, &req_data, ip_tbl->entry + entry_size, + left_buf_len, &unic_rsp_head); + if (ret != 0) { + HIKP_ERROR_PRINT("Fail to get the ip entry after index=%u, ret=%d.\n", + index, ret); + return ret; + } + entry_size += unic_rsp_head.cur_blk_entry_cnt; + index = unic_rsp_head.next_entry_idx; + } + ip_tbl->entry_size = entry_size; + + return ret; +} + +static int hikp_unic_query_ppp_guid_tbl(struct hikp_cmd_header *req_header, + const struct bdf_t *bdf, void *data) +{ + struct unic_guid_tbl *guid_tbl = (struct unic_guid_tbl*)data; + struct unic_ppp_rsp_head unic_rsp_head = { 0 }; + struct unic_ppp_req_para req_data = { 0 }; + uint32_t entry_size = 0; + size_t left_buf_len = 0; + uint32_t index = 0; + int ret = -1; + + req_data.bdf = *bdf; + req_data.is_unicast = 1; + while (index < g_unic_ppp_hw_res.uc_guid_tbl_size) { + req_data.cur_entry_idx = index; + left_buf_len = sizeof(struct unic_guid_uc_entry) * + (g_unic_ppp_hw_res.uc_guid_tbl_size - entry_size); + ret = hikp_unic_ppp_get_blk(req_header, &req_data, + guid_tbl->uc_tbl.entry + entry_size, + left_buf_len, &unic_rsp_head); + if (ret != 0) { + HIKP_ERROR_PRINT("Fail to get the uc_guid entry after index=%u, ret=%d.\n", + index, ret); + return ret; + } + entry_size += unic_rsp_head.cur_blk_entry_cnt; + index = unic_rsp_head.next_entry_idx; + } + guid_tbl->uc_tbl.entry_size = entry_size; + + left_buf_len = 0; + entry_size = 0; + index = 0; + req_data.is_unicast = 0; + + while (index < g_unic_ppp_hw_res.mc_guid_tbl_size) { + req_data.cur_entry_idx = index; + left_buf_len = sizeof(struct unic_guid_mc_entry) * + (g_unic_ppp_hw_res.mc_guid_tbl_size - entry_size); + ret = hikp_unic_ppp_get_blk(req_header, &req_data, + guid_tbl->mc_tbl.entry + entry_size, + left_buf_len, &unic_rsp_head); + if (ret != 0) { + HIKP_ERROR_PRINT("Fail to get the mc_guid entry after index=%u, ret=%d.\n", + index, ret); + return ret; + } + entry_size += unic_rsp_head.cur_blk_entry_cnt; + index = unic_rsp_head.next_entry_idx; + } + guid_tbl->mc_tbl.entry_size = entry_size; + + return ret; +} + +static void hikp_unic_ppp_show_ip_tbl(const void *data) +{ + struct unic_ip_tbl *ip_tbl = (struct unic_ip_tbl *)data; + struct unic_ip_entry *entry; + uint16_t *ip_addr_tbl_str; + int i, j; + + printf("ip_table_size = %u\n", ip_tbl->entry_size); + printf("index\t| func_id\t| ip_addr\n"); + for (i = 0; i < ip_tbl->entry_size; i++) { + entry = &ip_tbl->entry[i]; + ip_addr_tbl_str = (uint16_t *)entry->ip_addr; + printf("%-4u\t| %-3u\t\t| ", entry->index, entry->function_id); + for (j = 0; j < IP_ADDR_TBL_LEN - 1; j++) + printf("%04x:" , ntohs(ip_addr_tbl_str[j])); + printf("%04x\n", ntohs(ip_addr_tbl_str[IP_ADDR_TBL_LEN - 1])); + } +} + +static void hikp_unic_ppp_show_guid_tbl(const void *data) +{ + struct unic_guid_tbl *guid_tbl = (struct unic_guid_tbl *)data; + uint32_t cnt; + int i; + + printf("unicast guid num : %u\n", guid_tbl->uc_tbl.entry_size); + if (guid_tbl->uc_tbl.entry_size > 0) { + printf("| num\t| func id | GUID \n"); + for (cnt = 0; cnt < guid_tbl->uc_tbl.entry_size; cnt++) { + printf("| %3u\t| %7u | ", cnt, guid_tbl->uc_tbl.entry[cnt].function_id); + for (i = 0; i < HIKP_UNIC_GUID_ADDR_LEN - 1; i++) { + printf("%02x:", guid_tbl->uc_tbl.entry[cnt].guid_addr[i]); + } + printf("%02x\n", + guid_tbl->uc_tbl.entry[cnt].guid_addr[HIKP_UNIC_GUID_ADDR_LEN - 1]); + } + } + + printf("multicast guid num : %u\n", guid_tbl->mc_tbl.entry_size); + if (guid_tbl->mc_tbl.entry_size > 0) { + printf("| num\t| idx\t| %-48s\t| bitmap\n", "GUID"); + for (cnt = 0; cnt < guid_tbl->mc_tbl.entry_size; cnt++) { + printf("| %3u\t| %4u\t| ", cnt, guid_tbl->mc_tbl.entry[cnt].idx); + for (i = 0; i < HIKP_UNIC_GUID_ADDR_LEN - 1; i++) { + printf("%02x:", guid_tbl->mc_tbl.entry[cnt].guid_addr[i]); + } + printf("%02x\t| ", + guid_tbl->mc_tbl.entry[cnt].guid_addr[HIKP_UNIC_GUID_ADDR_LEN - 1]); + for (i = HIKP_UNIC_GUID_BITMAP_LEN - 1; i > 0; i--) { + printf("%08x:", guid_tbl->mc_tbl.entry[cnt].function_bitmap[i]); + } + printf("%08x\n", guid_tbl->mc_tbl.entry[cnt].function_bitmap[0]); + } + } +} + +static int hikp_unic_ppp_check_input_param(struct major_cmd_ctrl *self, + const struct unic_ppp_param *ppp_param) +{ + const struct bdf_t *bdf = &ppp_param->target.bdf; + + if (bdf->dev_id != 0) { + snprintf(self->err_str, sizeof(self->err_str), "VF does not support query!"); + self->err_no = -EINVAL; + return self->err_no; + } + + if (ppp_param->feature_idx == UNIC_PPP_INIT_FEATURE_IDX) { + hikp_unic_ppp_cmd_help(self, NULL); + snprintf(self->err_str, sizeof(self->err_str), "-du/--dump parameter error!"); + self->err_no = -EINVAL; + return self->err_no; + } + + return 0; +} + +static void hikp_unic_ppp_data_free(union unic_ppp_feature_info *unic_ppp_data) +{ + struct unic_guid_tbl *guid_tbl; + struct unic_ip_tbl *ip_tbl; + + if (g_unic_ppp_param.feature_idx == UNIC_PPP_IP_FEATURE_IDX) { + ip_tbl = &unic_ppp_data->ip_tbl; + free(ip_tbl->entry); + } else if (g_unic_ppp_param.feature_idx == UNIC_PPP_GUID_FEATURE_IDX) { + guid_tbl = &unic_ppp_data->guid_tbl; + free(guid_tbl->uc_tbl.entry); + free(guid_tbl->mc_tbl.entry); + } + + free(unic_ppp_data); +} + +static void hikp_unic_ppp_cmd_execute(struct major_cmd_ctrl *self) +{ + const struct unic_ppp_feature_cmd *unic_ppp_cmd; + union unic_ppp_feature_info *unic_ppp_data; + struct hikp_cmd_header req_header = {0}; + int ret; + + ret = hikp_unic_ppp_check_input_param(self, &g_unic_ppp_param); + if (ret != 0) + return; + + ret = hikp_unic_get_ppp_entry_hw_res(&g_unic_ppp_param.target.bdf, &g_unic_ppp_hw_res); + if (ret != 0) { + snprintf(self->err_str, sizeof(self->err_str), + "fail to obtain unic_ppp hardware resources."); + self->err_no = ret; + return; + } + + unic_ppp_cmd = &g_unic_ppp_feature_cmd[g_unic_ppp_param.feature_idx]; + unic_ppp_data = hikp_unic_ppp_data_alloc(unic_ppp_cmd, &g_unic_ppp_hw_res); + if (unic_ppp_data == NULL) { + snprintf(self->err_str, sizeof(self->err_str), + "failed to allocate unic_ppp_data memory!"); + self->err_no = -ENOMEM; + return; + } + + hikp_cmd_init(&req_header, UB_MOD, GET_UNIC_PPP_CMD, unic_ppp_cmd->sub_cmd_code); + ret = unic_ppp_cmd->query(&req_header, &g_unic_ppp_param.target.bdf, unic_ppp_data); + if (ret != 0) { + snprintf(self->err_str, sizeof(self->err_str), + "failed to query %s info, ret = %d.", unic_ppp_cmd->feature_name, ret); + self->err_no = ret; + goto out; + } + + printf("############## UNIC_PPP: %s info ############\n", unic_ppp_cmd->feature_name); + unic_ppp_cmd->show(unic_ppp_data); + printf("#################### END #######################\n"); + +out: + hikp_unic_ppp_data_free(unic_ppp_data); +} + +static void cmd_unic_get_ppp_init(void) +{ + struct major_cmd_ctrl *major_cmd = get_major_cmd(); + + g_unic_ppp_param.feature_idx = UNIC_PPP_INIT_FEATURE_IDX; + major_cmd->execute = hikp_unic_ppp_cmd_execute; + + cmd_option_register("-h", "--help", false, hikp_unic_ppp_cmd_help); + cmd_option_register("-i", "--interface", true, hikp_unic_cmd_get_ppp_target); + cmd_option_register("-du", "--dump", true, hikp_unic_cmd_ppp_feature_select); +} + +HIKP_CMD_DECLARE("unic_ppp", "dump ppp info of unic!", cmd_unic_get_ppp_init); \ No newline at end of file diff --git a/net/ub/ub_unic/hikp_unic_ppp.h b/net/ub/ub_unic/hikp_unic_ppp.h new file mode 100644 index 0000000..c25fabd --- /dev/null +++ b/net/ub/ub_unic/hikp_unic_ppp.h @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#ifndef HIKP_UNIC_PPP_H +#define HIKP_UNIC_PPP_H + +#include "hikp_net_lib.h" + +#define HIKP_UNIC_IP_ADDR_FMT_SIZE 50 +#define MAX_IP_ADDR_STR_LEN 50 +#define IP_ADDR_LEN 16 +#define IP_ADDR_TBL_LEN 8 + +#define HIKP_UNIC_IP_ADDR_LEN 4 +#define HIKP_UNIC_GUID_BITMAP_LEN 8 +#define HIKP_UNIC_GUID_ADDR_LEN 16 + +#define UNIC_PPP_MAX_RSP_DATA 57 +#define HIKP_UNIC_PPP_MAX_FEATURE_NAME_LEN 20 + +#define UNIC_PPP_IP_TBL_NAME "ip" +#define UNIC_PPP_GUID_TBL_NAME "guid" + +enum unic_ppp_sub_cmd_type { + UNIC_PPP_ENTRY_HW_SPEC_GET = 0, + UNIC_IP_TBL_DUMP, + UNIC_GUID_TBL_DUMP, +}; + +enum unic_ppp_feature_idx { + UNIC_PPP_IP_FEATURE_IDX = 0, + UNIC_PPP_GUID_FEATURE_IDX, + UNIC_PPP_INIT_FEATURE_IDX = -1, +}; + +struct hikp_unic_ppp_hw_resources { + uint16_t uc_guid_tbl_size; + uint16_t mc_guid_tbl_size; + uint32_t ip_max_mem_size; + uint32_t ip_overflow_size; + uint32_t rsv; + /* port information */ + uint16_t total_func_num; /* contain PF and VF. */ + uint16_t abs_func_id_base; /* The absolute func_id of the first VF in this port. */ + uint32_t rsv1[11]; +}; + +struct unic_ip_entry { + uint32_t index; + uint32_t function_id; + uint32_t ip_addr[HIKP_UNIC_IP_ADDR_LEN]; +}; + +struct unic_ip_tbl { + uint32_t entry_size; + struct unic_ip_entry *entry; +}; + +struct unic_guid_uc_entry { + uint32_t function_id; + uint8_t guid_addr[HIKP_UNIC_GUID_ADDR_LEN]; +}; + +struct unic_guid_uc_tbl { + uint32_t entry_size; + struct unic_guid_uc_entry *entry; +}; + +struct unic_guid_mc_entry { + uint32_t idx; + uint8_t guid_addr[HIKP_UNIC_GUID_ADDR_LEN]; + uint32_t function_bitmap[8]; +}; + +struct unic_guid_mc_tbl { + uint32_t entry_size; + struct unic_guid_mc_entry *entry; +}; + +struct unic_guid_tbl { + struct unic_guid_uc_tbl uc_tbl; + struct unic_guid_mc_tbl mc_tbl; +}; + +union unic_ppp_feature_info { + struct unic_guid_tbl guid_tbl; + struct unic_ip_tbl ip_tbl; +}; + +struct unic_ppp_feature_cmd { + const char feature_name[HIKP_UNIC_PPP_MAX_FEATURE_NAME_LEN]; + uint32_t sub_cmd_code; + bool need_query_hw_res; + int (*query)(struct hikp_cmd_header *req_header, + const struct bdf_t *bdf, void *data); + void (*show)(const void *data); +}; + +struct unic_ppp_param { + struct tool_target target; + int feature_idx; +}; + +struct unic_ppp_req_para { + struct bdf_t bdf; + uint8_t block_id; + union { + uint8_t is_unicast; /* 1: uc GUID, 0: mc GUID. */ + uint8_t rsv; /* firmware ignores it if isn't used to query GUID table. */ + }; + uint8_t rsv1[2]; + uint32_t cur_entry_idx; /* firmware queries GUID/IP table from the value. */ +}; + +struct unic_ppp_rsp_head { + uint8_t total_blk_num; + uint8_t cur_blk_size; /* real data size, not contain head size. */ + uint16_t rsv; + /* firmware must set following fields when query GUID/IP table. */ + uint32_t next_entry_idx; + uint32_t cur_blk_entry_cnt; +}; + +typedef struct unic_ppp_rsp { + struct unic_ppp_rsp_head rsp_head; /* 12 Byte */ + uint32_t rsp_data[UNIC_PPP_MAX_RSP_DATA]; +} unic_ppp_rsp_t; + +#endif /* HIKP_UNIC_PPP_H */
From: veega2022 zhuweijia@huawei.com
Fix a resource release bug in hikp_roh_get_cam_reg_num
Signed-off-by: chenke chenke54@huawei.com --- net/roh/hikp_roh_mac.c | 6 +++++- net/roh/hikp_roh_show_bp.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/roh/hikp_roh_mac.c b/net/roh/hikp_roh_mac.c index 90708b1..43f954c 100644 --- a/net/roh/hikp_roh_mac.c +++ b/net/roh/hikp_roh_mac.c @@ -141,6 +141,7 @@ static int hikp_roh_get_cam_reg_num(struct major_cmd_ctrl *self) struct roh_mac_req_para req_data = { 0 }; struct hikp_cmd_header req_header = { 0 }; struct hikp_cmd_ret *cmd_ret = NULL; + uint32_t cam_reg_num;
req_data.bdf = g_roh_mac_param.target.bdf; hikp_cmd_init(&req_header, ROH_MOD, HIKP_ROH_MAC, CMD_GET_CAM_REG_NUM); @@ -153,7 +154,10 @@ static int hikp_roh_get_cam_reg_num(struct major_cmd_ctrl *self) return -EIO; } mac_rsp = (struct roh_mac_cam_reg_num *)(cmd_ret->rsp_data); - return mac_rsp->cam_reg_num; + cam_reg_num = mac_rsp->cam_reg_num; + free(cmd_ret); + cmd_ret = NULL; + return cam_reg_num; }
static int hikp_roh_build_cam(struct major_cmd_ctrl *self, struct cam_table_entry_t *cam_table) diff --git a/net/roh/hikp_roh_show_bp.c b/net/roh/hikp_roh_show_bp.c index c89e98b..73a53d8 100644 --- a/net/roh/hikp_roh_show_bp.c +++ b/net/roh/hikp_roh_show_bp.c @@ -44,7 +44,7 @@ static int hikp_roh_show_bp(struct major_cmd_ctrl *self) union bp_val res; uint8_t flit_bp; int mac_id; - int ret; + int ret = 0;
struct hikp_cmd_ret *cmd_ret = NULL; struct hikp_cmd_header req_header = { 0 };
From: veega2022 zhuweijia@huawei.com
Add a space on the left and right of the "="
Signed-off-by: veega2022 zhuweijia@huawei.com --- socip/hikp_socip_dumpreg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/socip/hikp_socip_dumpreg.c b/socip/hikp_socip_dumpreg.c index b74dac8..32325bb 100644 --- a/socip/hikp_socip_dumpreg.c +++ b/socip/hikp_socip_dumpreg.c @@ -142,7 +142,7 @@ static void hikp_socip_dumpreg_execute(struct major_cmd_ctrl *self) hikp_cmd_init(&req_header, SOCIP_MOD, HIKP_SOCIP_CMD_DUMPREG, param[MODULE_ID_INDEX].val); cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); if (!cmd_ret) { - self->err_no=-EINVAL; + self->err_no = -EINVAL; HIKP_ERROR_PRINT("hikp_cmd_alloc\n"); return; }
Delete redundant copyright notices in hikp_ub_link.h
Signed-off-by: veega zhuweijia@huawei.com --- net/ub/ub_link/hikp_ub_link.h | 13 ------------- tool_lib/tool_lib.h | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-)
diff --git a/net/ub/ub_link/hikp_ub_link.h b/net/ub/ub_link/hikp_ub_link.h index 14ee912..7c71cb2 100644 --- a/net/ub/ub_link/hikp_ub_link.h +++ b/net/ub/ub_link/hikp_ub_link.h @@ -11,19 +11,6 @@ * See the Mulan PSL v2 for more details. */
-/* - * Copyright (c) 2023 Hisilicon Technologies Co., Ltd. - * Hikptool is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * - * See the Mulan PSL v2 for more details. - */ - #ifndef HIKP_UB_LINK_H #define HIKP_UB_LINK_H
diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h index 9766a7e..6548b57 100644 --- a/tool_lib/tool_lib.h +++ b/tool_lib/tool_lib.h @@ -18,7 +18,7 @@
#define TOOL_NAME "hikptool"
-#define TOOL_VER "1.0.15" +#define TOOL_VER "1.0.16"
#define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask)) #define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift))
From: huangguanhua huangguanhua3@huawei.com
Signed-off-by: huangguanhua huangguanhua3@huawei.com --- serdes/hikp_serdes.c | 12 ++++++++---- serdes/hikp_serdes.h | 3 ++- tool_lib/op_logs.c | 6 +++--- 3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/serdes/hikp_serdes.c b/serdes/hikp_serdes.c index dd9eee3..527fd53 100644 --- a/serdes/hikp_serdes.c +++ b/serdes/hikp_serdes.c @@ -184,21 +184,22 @@ static void hikp_serdes_brief_info_print(struct major_cmd_ctrl *self, "Tap16,Tap17,Tap18,Tap19,Tap20]\n" \ "FWFourEye: It only takes effect when the firmware is running and " \ "continuous adaptation is turned on\n" \ + "Snr: [SNR_METRIC,SNR_METRIC_HIS_MIN,SNR_CYCLES,HEH,SNR_METRIC_SW]\n" \ "-----------------------------------------------------" \ "------------------------------------------------" \ "-----------------------------------------------------" \ "------------------------------------------------" \ - "-------------------\n" \ + "--------------------------------\n" \ " [ FFE ]" \ "[ CTLE ]" \ "[ " \ "DFE ]" \ - "[ FWFourEye ][ snr ]\n" \ + "[ FWFourEye ][ Snr ]\n" \ "-----------------------------------------------------" \ "-------------------------------------------------" \ "-----------------------------------------------------" \ "-------------------------------------------------" \ - "------------------\n") + "--------------------------------\n")
static void hikp_serdes_detail_info_print(struct major_cmd_ctrl *self, const struct hilink_detail_info *data, @@ -233,7 +234,10 @@ static void hikp_serdes_detail_info_print(struct major_cmd_ctrl *self, printf("][%4d,%4d,%4d,%4d]", data[ds_id].eye_diagram.top, data[ds_id].eye_diagram.bottom, data[ds_id].eye_diagram.left, data[ds_id].eye_diagram.right); - printf("[%7d]\n", data[ds_id].snr); + /* 0: SNR_METRIC, 1:SNR_METRIC_HIS_MIN */ + printf("[%3d,%3d,%3d,%3d,%3d]\n", data[ds_id].snr_para[0], data[ds_id].snr_para[1], + /* 2:SNR_CYCLES, 3:HEH, 4:SNR_METRIC_SW */ + data[ds_id].snr_para[2], data[ds_id].snr_para[3], data[ds_id].snr_para[4]); } }
diff --git a/serdes/hikp_serdes.h b/serdes/hikp_serdes.h index 99b9b15..83c28b8 100644 --- a/serdes/hikp_serdes.h +++ b/serdes/hikp_serdes.h @@ -192,7 +192,8 @@ struct hilink_detail_info { struct hilink_rx_param rx_ctle_cfg; struct hilink_serdes_rx_tap rx_tap_cfg; struct hilink_4p_eye_result eye_diagram; - uint32_t snr; + /* 5: (0: SNR_METRIC, 1:SNR_METRIC_HIS_MIN, 2:SNR_CYCLES, 3:HEH, 4:SNR_METRIC_SW) */ + int32_t snr_para[5]; };
struct hilink_brief_info { diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c index 069428d..d91ddb0 100644 --- a/tool_lib/op_logs.c +++ b/tool_lib/op_logs.c @@ -431,7 +431,7 @@ void sig_init(void) (void)signal(SIGHUP, signal_handle); (void)signal(SIGSEGV, signal_handle); (void)signal(SIGBUS, signal_handle); - (void)signal(SIGFPE, signal_handle); - (void)signal(SIGABRT, signal_handle); - (void)signal(SIGTSTP, signal_handle); /* Stop process */ + (void)signal(SIGFPE, signal_handle); + (void)signal(SIGABRT, signal_handle); + (void)signal(SIGTSTP, signal_handle); /* Stop process */ }
From: FuJia Ni nifujia1@hisilicon.com
the volatile modifier is added because the O2 compilation optimization is enbaled. As a result, the pointer data is not updated.
Signed-off-by: FuJia Ni nifujia1@hisilicon.com --- sas/sas_func/sas_read_dqe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sas/sas_func/sas_read_dqe.c b/sas/sas_func/sas_read_dqe.c index fc04682..2f653df 100644 --- a/sas/sas_func/sas_read_dqe.c +++ b/sas/sas_func/sas_read_dqe.c @@ -47,7 +47,7 @@ static int sas_get_dqe(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3
static void print_dqe_info(const void *reg_save, uint32_t reg_num) { - struct hisi_sas_dq_info *dqe = (struct hisi_sas_dq_info *)(reg_save); + volatile struct hisi_sas_dq_info *dqe = (volatile struct hisi_sas_dq_info *)(reg_save);
printf("The dqe dw0 information as below:\n"); printf("abort_flag: %u\n", dqe->dw0.abort_flag);