diff --git a/hikp_init_main.c b/hikp_init_main.c index acbed8cd294575d7a9203225f20624d32a0fa439..72d206ff5e78ca2b38e88a8fca7b717e874720f0 100644 --- a/hikp_init_main.c +++ b/hikp_init_main.c @@ -35,7 +35,7 @@ static const char *g_nic_cmd_list[] = { "nic_dfx", "nic_fd", "nic_fec", "nic_gro", "nic_info", "nic_log", "nic_mac", "nic_ncsi", "nic_notify_pkt", "nic_port", "nic_port_fault", "nic_ppp", "nic_qos", "nic_queue", "nic_rss", - "nic_torus", "nic_xsfp", + "nic_torus", "nic_xsfp", "nic_led", }; static const char *g_pcie_cmd_list[] = { @@ -53,7 +53,7 @@ static const char *g_roh_cmd_list[] = { }; static const char *g_sas_cmd_list[] = { - "sas_anacq", "sas_anadq", "sas_dev", "sas_dqe", "sas_dump", "sas_errcode", + "sas_anacq", "sas_anadq", "sas_dev", "sas_dump", "sas_errcode", }; static const char *g_sata_cmd_list[] = { diff --git a/info_collect/hikp_collect_main.c b/info_collect/hikp_collect_main.c index 46120a55c2f94843cadacb7ee69d4ab8838d57d3..35718504550a94f83ac901260c9d88eb6934085a 100644 --- a/info_collect/hikp_collect_main.c +++ b/info_collect/hikp_collect_main.c @@ -126,7 +126,7 @@ static int info_collect_all(struct major_cmd_ctrl *self, const char *argv) return 0; } -static void collect_all_log(void) +static void collect_all_log_hip09_10(void) { collect_pcie_info(); collect_acc_log(); @@ -137,9 +137,49 @@ static void collect_all_log(void) collect_sata_log(); collect_serdes_log(); collect_socip_log(); +} + +static void collect_all_log_hip11(void) +{ + collect_pcie_info(); + collect_imp_log(); + collect_nic_log(); + collect_roce_log(); + collect_sata_log(); + collect_serdes_log(); + collect_socip_log(); collect_sdma_log(); } +static void collect_all_log_hip12(void) +{ + collect_pcie_info(); + collect_acc_log(); + collect_serdes_log(); + collect_socip_log(); +} + +static void collect_all_log(void) +{ + uint32_t chip_type = get_chip_type(); + + switch (chip_type) { + case CHIP_HIP09: + case CHIP_HIP10: + case CHIP_HIP10C: + collect_all_log_hip09_10(); + break; + case CHIP_HIP11: + collect_all_log_hip11(); + break; + case CHIP_HIP12: + collect_all_log_hip12(); + break; + default: + break; + } +} + static int info_collect_excute_funs_call(uint32_t collect_type) { const char *type_name[] = {"acc", "imp", "nic", "pcie", "roce", "sas", @@ -199,7 +239,6 @@ static int info_collect_excute_funs_call(uint32_t collect_type) return ret; } - static void info_collect_execute(struct major_cmd_ctrl *self) { const char *suc_msg[] = { @@ -243,38 +282,32 @@ static void info_collect_execute(struct major_cmd_ctrl *self) } } -static int info_collect_help(struct major_cmd_ctrl *self, const char *argv) +static int info_collect_help_hip09_10(struct major_cmd_ctrl *self, const char *argv) { HIKP_SET_USED(argv); printf("\n Usage: %s\n", self->cmd_ptr->name); printf("\n %s\n", self->cmd_ptr->help_info); printf("\n Options:\n\n"); - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); - printf(" %s, %-25s %s\n", "-acc", "--acc", "collect acc info\n"); - printf(" %s, %-25s %s\n", "-imp", "--imp", "collect imp info\n"); - printf(" %s, %-25s %s\n", "-nic", "--nic", "collect nic info\n"); - printf(" %s, %-25s %s\n", "-pcie", "--pcie", "collect pcie info\n"); - printf(" %s, %-25s %s\n", "-roce", "--roce", "collect roce info\n"); - printf(" %s, %-25s %s\n", "-sas", "--sas", "collect sas info\n"); - printf(" %s, %-25s %s\n", "-sata", "--sata", "collect sata info\n"); - printf(" %s, %-25s %s\n", "-serdes", "--serdes", "collect serdes info\n"); - printf(" %s, %-25s %s\n", "-socip", "--socip", "collect socip info\n"); - printf(" %s, %-25s %s\n", "-sdma", "--sdma", "collect sdma info\n"); - printf(" %s, %-25s %s\n", "-all", "--all", "collect all info\n"); + printf(" %-10s, %-25s %s\n", "-h", "--help", "display this help and exit"); + printf(" %-10s, %-25s %s\n", "-acc", "--acc", "collect acc info"); + printf(" %-10s, %-25s %s\n", "-imp", "--imp", "collect imp info"); + printf(" %-10s, %-25s %s\n", "-nic", "--nic", "collect nic info"); + printf(" %-10s, %-25s %s\n", "-pcie", "--pcie", "collect pcie info"); + printf(" %-10s, %-25s %s\n", "-roce", "--roce", "collect roce info"); + printf(" %-10s, %-25s %s\n", "-sas", "--sas", "collect sas info"); + printf(" %-10s, %-25s %s\n", "-sata", "--sata", "collect sata info"); + printf(" %-10s, %-25s %s\n", "-serdes", "--serdes", "collect serdes info"); + printf(" %-10s, %-25s %s\n", "-socip", "--socip", "collect socip info"); + printf(" %-10s, %-25s %s\n", "-all", "--all", "collect all info"); printf("\n"); return 0; } -static void cmd_info_collect_init(void) +static void info_collect_cmd_register_hip09_10(void) { - struct major_cmd_ctrl *major_cmd = get_major_cmd(); - - major_cmd->option_count = 0; - major_cmd->execute = info_collect_execute; - - cmd_option_register("-h", "--help", false, info_collect_help); + cmd_option_register("-h", "--help", false, info_collect_help_hip09_10); cmd_option_register("-acc", "--acc", false, info_collect_acc); cmd_option_register("-imp", "--imp", false, info_collect_imp); cmd_option_register("-nic", "--nic", false, info_collect_nic); @@ -284,8 +317,96 @@ static void cmd_info_collect_init(void) cmd_option_register("-sata", "--sata", false, info_collect_sata); cmd_option_register("-serdes", "--serdes", false, info_collect_serdes); cmd_option_register("-socip", "--socip", false, info_collect_socip); + cmd_option_register("-all", "--all", false, info_collect_all); +} + +static int info_collect_help_hip11(struct major_cmd_ctrl *self, const char *argv) +{ + HIKP_SET_USED(argv); + + printf("\n Usage: %s\n", self->cmd_ptr->name); + printf("\n %s\n", self->cmd_ptr->help_info); + printf("\n Options:\n\n"); + printf(" %-10s, %-25s %s\n", "-h", "--help", "display this help and exit"); + printf(" %-10s, %-25s %s\n", "-imp", "--imp", "collect imp info"); + printf(" %-10s, %-25s %s\n", "-nic", "--nic", "collect nic info"); + printf(" %-10s, %-25s %s\n", "-pcie", "--pcie", "collect pcie info"); + printf(" %-10s, %-25s %s\n", "-roce", "--roce", "collect roce info"); + printf(" %-10s, %-25s %s\n", "-sata", "--sata", "collect sata info"); + printf(" %-10s, %-25s %s\n", "-serdes", "--serdes", "collect serdes info"); + printf(" %-10s, %-25s %s\n", "-socip", "--socip", "collect socip info"); + printf(" %-10s, %-25s %s\n", "-sdma", "--sdma", "collect sdma info"); + printf(" %-10s, %-25s %s\n", "-all", "--all", "collect all info"); + printf("\n"); + + return 0; +} + +static void info_collect_cmd_register_hip11(void) +{ + cmd_option_register("-h", "--help", false, info_collect_help_hip11); + cmd_option_register("-imp", "--imp", false, info_collect_imp); + cmd_option_register("-nic", "--nic", false, info_collect_nic); + cmd_option_register("-pcie", "--pcie", false, info_collect_pcie); + cmd_option_register("-roce", "--roce", false, info_collect_roce); + cmd_option_register("-sata", "--sata", false, info_collect_sata); + cmd_option_register("-serdes", "--serdes", false, info_collect_serdes); + cmd_option_register("-socip", "--socip", false, info_collect_socip); cmd_option_register("-sdma", "--sdma", false, info_collect_sdma); cmd_option_register("-all", "--all", false, info_collect_all); } +static int info_collect_help_hip12(struct major_cmd_ctrl *self, const char *argv) +{ + HIKP_SET_USED(argv); + + printf("\n Usage: %s\n", self->cmd_ptr->name); + printf("\n %s\n", self->cmd_ptr->help_info); + printf("\n Options:\n\n"); + printf(" %-10s, %-25s %s\n", "-h", "--help", "display this help and exit"); + printf(" %-10s, %-25s %s\n", "-acc", "--acc", "collect acc info"); + printf(" %-10s, %-25s %s\n", "-pcie", "--pcie", "collect pcie info"); + printf(" %-10s, %-25s %s\n", "-serdes", "--serdes", "collect serdes info"); + printf(" %-10s, %-25s %s\n", "-socip", "--socip", "collect socip info"); + printf(" %-10s, %-25s %s\n", "-all", "--all", "collect all info"); + printf("\n"); + + return 0; +} + +static void info_collect_cmd_register_hip12(void) +{ + cmd_option_register("-h", "--help", false, info_collect_help_hip12); + cmd_option_register("-acc", "--acc", false, info_collect_acc); + cmd_option_register("-pcie", "--pcie", false, info_collect_pcie); + cmd_option_register("-serdes", "--serdes", false, info_collect_serdes); + cmd_option_register("-socip", "--socip", false, info_collect_socip); + cmd_option_register("-all", "--all", false, info_collect_all); +} + +static void cmd_info_collect_init(void) +{ + struct major_cmd_ctrl *major_cmd = get_major_cmd(); + uint32_t chip_type = get_chip_type(); + + major_cmd->option_count = 0; + major_cmd->execute = info_collect_execute; + + switch (chip_type) { + case CHIP_HIP09: + case CHIP_HIP10: + case CHIP_HIP10C: + info_collect_cmd_register_hip09_10(); + break; + case CHIP_HIP11: + info_collect_cmd_register_hip11(); + break; + case CHIP_HIP12: + info_collect_cmd_register_hip12(); + break; + default: + break; + } +} + HIKP_CMD_DECLARE("info_collect", "information collect", cmd_info_collect_init); diff --git a/libhikptdev/src/rciep/CMakeLists.txt b/libhikptdev/src/rciep/CMakeLists.txt index e3f96c05e9b1023fc55d795dc52918e292bb9afd..057b8f528c04c11fbaba1be3110a1299070f54bb 100644 --- a/libhikptdev/src/rciep/CMakeLists.txt +++ b/libhikptdev/src/rciep/CMakeLists.txt @@ -23,5 +23,5 @@ target_include_directories(KPTDEV_SO PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../in target_link_options(KPTDEV_SO PRIVATE -Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIE -pie -s) -set_target_properties(KPTDEV_SO PROPERTIES OUTPUT_NAME ${KPTDEV_SO_NAME} SOVERSION 1 VERSION 1.0.0) +set_target_properties(KPTDEV_SO PROPERTIES OUTPUT_NAME ${KPTDEV_SO_NAME} SOVERSION 1 VERSION 1.1.5) install(TARGETS KPTDEV_SO LIBRARY DESTINATION lib OPTIONAL) diff --git a/net/hikp_net_lib.h b/net/hikp_net_lib.h index aa700ab28a5c38f8eaec4dca7d4037910f4e353c..e855d4ece3e64f9222ca2681233883fcaed5a21d 100644 --- a/net/hikp_net_lib.h +++ b/net/hikp_net_lib.h @@ -82,6 +82,8 @@ enum nic_cmd_type { GET_NOTIFY_PKT_CMD, GET_TORUS_INFO_CMD = 0xD, GET_PORT_FAULT_STATUS = 0xE, + GET_PORT_LED_CFG = 0xF, + GET_NCSI_TABLE_ENTRY_INFO_CMD = 0x10, }; enum roh_cmd_type { @@ -119,6 +121,14 @@ enum nic_get_ncsi_sub_cmd { NIC_NCSI_GET_DFX_INFO, }; +enum nic_get_ncsi_entry_sub_cmd { + NIC_NCSI_GET_BUF_STATUS = 1, + NIC_NCSI_GET_VLAN_FILTER_TBL, + NIC_NCSI_GET_ETHER_FILTER_TBL, + NIC_NCSI_GET_DMAC_FILTER_TBL, + NIC_NCSI_GET_SMAC_FILTER_TBL, +}; + #define HIKP_MAX_PF_NUM 8 #define HIKP_NIC_MAX_FUNC_NUM 256 diff --git a/net/nic/nic_led/hikp_nic_led.c b/net/nic/nic_led/hikp_nic_led.c new file mode 100644 index 0000000000000000000000000000000000000000..725a451a6eaf969e10fa57e30f1c9a45461fdd9f --- /dev/null +++ b/net/nic/nic_led/hikp_nic_led.c @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2025 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include +#include "hikp_nic_led.h" + +static struct nic_led_cmd_info g_led_cmd_info = {0}; + +static const char *nic_led_cmd_get_speed_status(uint8_t speed_led) +{ + struct speed_status led_speed[] = { + {SPEED_1G_BLINK, "1G"}, + {SPEED_10G_BLINK, "10G"}, + {SPEED_25G_BLINK, "25G"}, + {SPEED_40G_BLINK, "40G"}, + {SPEED_50G_BLINK, "50G"}, + {SPEED_100G_BLINK, "100G"}, + {SPEED_200G_BLINK, "200G"}, + {SPEED_NO_LINK_BLINK, "NO_LINK"}, + {SPEED_TEST_BLINK, "TEST_MODE"}, + {SPEED_ERROR_BLINK, "ERROR_MODE"}, + }; + size_t size = HIKP_ARRAY_SIZE(led_speed); + + for (size_t i = 0; i < size; i++) { + if (speed_led == led_speed[i].status) + return led_speed[i].speed; + } + + return "unknown"; +} + +static bool nic_led_cmd_param_check(struct major_cmd_ctrl *self) +{ + if ((g_led_cmd_info.cmd_flag & LED_PORT_TARGET_BIT) == 0) { + self->err_no = -EINVAL; + snprintf(self->err_str, sizeof(self->err_str), "Need port id."); + return false; + } + + return true; +} + +static void nic_led_cmd_execute(struct major_cmd_ctrl *self) +{ + struct hikp_cmd_header header = { 0 }; + struct nic_led_resp *led_rsp = NULL; + struct nic_led_req_para req = { 0 }; + struct hikp_cmd_ret *cmd_ret; + + if (!nic_led_cmd_param_check(self)) + return; + + req.bdf = g_led_cmd_info.port_dev.bdf; + hikp_cmd_init(&header, NIC_MOD, GET_PORT_LED_CFG, NIC_LED_CFG_DUMP); + cmd_ret = hikp_cmd_alloc(&header, &req, sizeof(req)); + self->err_no = hikp_rsp_normal_check(cmd_ret); + if (self->err_no) { + snprintf(self->err_str, sizeof(self->err_str), "Get led dfx info failed."); + goto ERR_OUT; + } + + led_rsp = (struct nic_led_resp *)cmd_ret->rsp_data; + printf("%-40s: %u\n", "led_en", led_rsp->led_en); + printf("%-40s: %s\n", "speed_led", nic_led_cmd_get_speed_status(led_rsp->speed_led_status)); + printf("%-40s: 0x%x(0x%x)\n", "led_err_status(sw_status)", + led_rsp->hw_err_mode, led_rsp->sw_err_mode); + printf("%-40s: 0x%x(0x%x)\n", "led_locate_status(sw_status)", + led_rsp->hw_locate_mode, led_rsp->sw_locate_mode); + printf("%-40s: 0x%x(0x%x)\n", "led_active_status(sw_status)", + led_rsp->hw_active_mode, led_rsp->sw_active_mode); + +ERR_OUT: + hikp_cmd_free(&cmd_ret); +} + +static int nic_led_cmd_help(struct major_cmd_ctrl *self, const char *argv) +{ + HIKP_SET_USED(argv); + + printf("\n Usage: %s %s\n", self->cmd_ptr->name, "-i "); + printf("\n %s\n", self->cmd_ptr->help_info); + printf("\n Options:\n\n"); + printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); + printf(" %s, %-25s %s\n", "-i", "--interface=", + "device target or bdf id, e.g. eth0~3 or 0000:35:00.0"); + + return 0; +} + +static int nic_led_get_target(struct major_cmd_ctrl *self, const char *argv) +{ + self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_led_cmd_info.port_dev); + if (self->err_no != 0) { + snprintf(self->err_str, sizeof(self->err_str), "unknown device!"); + return self->err_no; + } + + g_led_cmd_info.cmd_flag |= LED_PORT_TARGET_BIT; + + return 0; +} + +static void cmd_nic_led_init(void) +{ + struct major_cmd_ctrl *major_cmd = get_major_cmd(); + + major_cmd->option_count = 0; + major_cmd->execute = nic_led_cmd_execute; + + cmd_option_register("-h", "--help", false, nic_led_cmd_help); + cmd_option_register("-i", "--interface", true, nic_led_get_target); +} + +HIKP_CMD_DECLARE("nic_led", "dump led configuration of port!", cmd_nic_led_init); diff --git a/net/nic/nic_led/hikp_nic_led.h b/net/nic/nic_led/hikp_nic_led.h new file mode 100644 index 0000000000000000000000000000000000000000..4f05ae54b3ccc0e4090c17bf2d6f1d9285d885fd --- /dev/null +++ b/net/nic/nic_led/hikp_nic_led.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 Hisilicon Technologies Co., Ltd. + * Hikptool is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * + * See the Mulan PSL v2 for more details. + */ + +#ifndef HIKP_NIC_LED_H +#define HIKP_NIC_LED_H + +#include "hikp_net_lib.h" + +enum nic_led_sub_cmd_type { + NIC_LED_CFG_DUMP = 1, +}; + +#define LED_PORT_TARGET_BIT HI_BIT(0) + +struct speed_status { + uint8_t status; + const char *speed; +}; + +#define SPEED_1G_BLINK 0x0 +#define SPEED_10G_BLINK 0x1 +#define SPEED_25G_BLINK 0x8 +#define SPEED_40G_BLINK 0x2 +#define SPEED_50G_BLINK 0x6 +#define SPEED_100G_BLINK 0xa +#define SPEED_200G_BLINK 0x16 +#define SPEED_NO_LINK_BLINK 0x10 +#define SPEED_TEST_BLINK 0xe +#define SPEED_ERROR_BLINK 0x9 + +struct nic_led_req_para { + struct bdf_t bdf; + uint32_t rsvd[2]; +}; + +struct nic_led_resp { + uint8_t led_en; + uint8_t hw_err_mode; + uint8_t hw_locate_mode; + uint8_t hw_active_mode; + uint8_t sw_err_mode; + uint8_t sw_locate_mode; + uint8_t sw_active_mode; + uint8_t speed_led_status; + + uint32_t rsvd[58]; +}; + +struct nic_led_cmd_info { + struct tool_target port_dev; + uint32_t cmd_flag; +}; + +#endif /* HIKP_NIC_LED_H */ diff --git a/net/nic/nic_ncsi/hikp_nic_ncsi.c b/net/nic/nic_ncsi/hikp_nic_ncsi.c index 955e456a1b73d37a8c43bc858e81c25fda1aad58..44d8e5341b6ce74a7fe4e15d02b06a91b372bb48 100644 --- a/net/nic/nic_ncsi/hikp_nic_ncsi.c +++ b/net/nic/nic_ncsi/hikp_nic_ncsi.c @@ -48,18 +48,12 @@ static void nic_ncsi_cmd_print_dfx_info(struct nic_ncsi_cmd_resp *ncsi_info) printf("\tncsi_ub_to_eth_lldp: %u\n", ncsi_info->ncsi_dfx.ncsi_ub_to_eth_lldp); } -static void nic_ncsi_cmd_execute(struct major_cmd_ctrl *self) +static void nic_ncsi_cmd_get_cnt_dfx(struct major_cmd_ctrl *self) { struct hikp_cmd_ret *cmd_resp = NULL; struct hikp_cmd_header req_header = {0}; struct nic_ncsi_cmd_req ncsi_req = {0}; - if (!g_ncsi_cmd_info.port_flag) { - self->err_no = -EINVAL; - snprintf(self->err_str, sizeof(self->err_str), "Need port id."); - return; - } - memcpy(&ncsi_req.bdf, &g_ncsi_cmd_info.target.bdf, sizeof(ncsi_req.bdf)); hikp_cmd_init(&req_header, NIC_MOD, GET_NCSI_INFO_CMD, NIC_NCSI_GET_DFX_INFO); cmd_resp = hikp_cmd_alloc(&req_header, &ncsi_req, sizeof(ncsi_req)); @@ -75,6 +69,226 @@ ERR_OUT: hikp_cmd_free(&cmd_resp); } +static int nic_ncsi_cmd_get_entry_response_data(struct major_cmd_ctrl *self, uint32_t sub_cmd, + struct hikp_cmd_ret **cmd_resp) +{ + struct hikp_cmd_header req_header = {0}; + struct nic_ncsi_cmd_req ncsi_req = {0}; + + memcpy(&ncsi_req.bdf, &g_ncsi_cmd_info.target.bdf, sizeof(ncsi_req.bdf)); + hikp_cmd_init(&req_header, NIC_MOD, GET_NCSI_TABLE_ENTRY_INFO_CMD, sub_cmd); + *cmd_resp = hikp_cmd_alloc(&req_header, &ncsi_req, sizeof(ncsi_req)); + self->err_no = hikp_rsp_normal_check(*cmd_resp); + if (self->err_no) + snprintf(self->err_str, sizeof(self->err_str), + "Get ncsi filter(0x%x) info failed.", sub_cmd); + + return self->err_no; +} + +static void nic_ncsi_cmd_show_tx_buf_status(struct major_cmd_ctrl *self) +{ + struct nic_ncsi_tx_buf_resp *tx_buf_rsp; + struct hikp_cmd_ret *cmd_resp = NULL; + int ret; + + ret = nic_ncsi_cmd_get_entry_response_data(self, NIC_NCSI_GET_BUF_STATUS, &cmd_resp); + if (ret) + goto ERR_OUT; + + tx_buf_rsp = (struct nic_ncsi_tx_buf_resp *)cmd_resp->rsp_data; + printf("ncsi tx buffer status:\n"); + printf("%-30s: %u\n", "tx_buf_empty", tx_buf_rsp->tx_buf_empty); + printf("%-30s: %u\n", "ctrl_sof", tx_buf_rsp->ctrl_sof); + printf("%-30s: %u\n", "ctrl_eof", tx_buf_rsp->ctrl_eof); + printf("%-30s: %u\n", "ctrl_err", tx_buf_rsp->ctrl_err); + printf("%-30s: %u\n", "ctrl_byte_sel", tx_buf_rsp->ctrl_byte_sel); + +ERR_OUT: + hikp_cmd_free(&cmd_resp); +} + +static void nic_ncsi_cmd_show_vlan_filter_cfg(struct major_cmd_ctrl *self) +{ + struct nic_ncsi_vlan_filter_resp *vlan_rsp = NULL; + struct hikp_cmd_ret *cmd_resp = NULL; + int ret; + + ret = nic_ncsi_cmd_get_entry_response_data(self, NIC_NCSI_GET_VLAN_FILTER_TBL, &cmd_resp); + if (ret) + goto ERR_OUT; + + vlan_rsp = (struct nic_ncsi_vlan_filter_resp *)cmd_resp->rsp_data; + printf("vlan filter config:\n"); + printf("%-30s: 0x%x\n", "filter_enable",vlan_rsp->filter_en_map); + printf("%-30s: 0x%x\n", "filter_type", vlan_rsp->filer_type); + printf("%-30s: 0x%x\n", "entry_to_bmc", vlan_rsp->entry_to_bmc_map); + printf("%-30s: 0x%x\n", "entry_to_bmc_only", vlan_rsp->entry_to_bmc_only_map); + + printf("enabled entries:\n"); + printf("%5s |%10s\n", "id", "vlan_id"); + for (uint32_t i = 0; i < NIC_NCSI_VLAN_ENTRY_NUM; i++) { + if (!vlan_rsp->entry[i].entry_en) + continue; + printf("%5u |%10u\n", i, vlan_rsp->entry[i].vlan_id); + } + +ERR_OUT: + hikp_cmd_free(&cmd_resp); +} + +static void nic_ncsi_cmd_show_ether_filter_cfg(struct major_cmd_ctrl *self) +{ + struct nic_ncsi_ether_filter_resp *ether_rsp = NULL; + struct hikp_cmd_ret *cmd_resp = NULL; + int ret; + + ret = nic_ncsi_cmd_get_entry_response_data(self, NIC_NCSI_GET_ETHER_FILTER_TBL, &cmd_resp); + if (ret) + goto ERR_OUT; + + ether_rsp = (struct nic_ncsi_ether_filter_resp *)cmd_resp->rsp_data; + printf("ether filter config:\n"); + printf("%-30s: 0x%x\n", "filter_enable", ether_rsp->ether_en_map); + printf("%-30s: 0x%x\n", "entry_to_bmc", ether_rsp->entry_to_bmc_map); + printf("%-30s: 0x%x\n", "entry_to_bmc_only", ether_rsp->entry_to_bmc_only_map); + + printf("enabled entries:\n"); + printf("%5s |%13s\n", "id", "ether_type"); + for (uint32_t i = 0; i < NIC_NCSI_ETHER_ENTRY_NUM; i++) { + if (!ether_rsp->entry[i].entry_en) + continue; + + printf("%5u |%13u\n", i, ether_rsp->entry[i].entry_type); + } + +ERR_OUT: + hikp_cmd_free(&cmd_resp); +} + +static void nic_ncsi_cmd_show_dmac_filter_cfg(struct major_cmd_ctrl *self) +{ + struct nic_ncsi_dmac_filter_resp *dmac_rsp = NULL; + struct hikp_cmd_ret *cmd_resp = NULL; + int ret; + + ret = nic_ncsi_cmd_get_entry_response_data(self, NIC_NCSI_GET_DMAC_FILTER_TBL, &cmd_resp); + if (ret) + goto ERR_OUT; + + dmac_rsp = (struct nic_ncsi_dmac_filter_resp *)cmd_resp->rsp_data; + printf("dmac filter config:\n"); + printf("%-30s: 0x%x\n", "filter_enable", dmac_rsp->dmac_en_map); + printf("%-30s: 0x%x\n", "entry_to_bmc", dmac_rsp->dmac_to_bmc); + printf("%-30s: 0x%x\n", "entry_to_bmc_only", dmac_rsp->dmac_to_bmc_only); + + printf("enabled entries:\n"); + printf("%5s |%10s |%10s |%13s\n", "id", "type", "entry_h", "entry_l"); + for (uint32_t i = 0; i < NIC_NCSI_DMAC_ENTRY_NUM; i++) { + if (!dmac_rsp->entry[i].entry_en) + continue; + printf("%5u |%10u |%#10x |%#13x\n", + i, dmac_rsp->entry[i].entry_type, + dmac_rsp->entry[i].entry_cfg_h, dmac_rsp->entry[i].entry_cfg_l); + } + + printf("multicast_filter: %16s(%u)%15s(%u)%16s(%u)%11s(%u)%15s(%u)\n", + "ipv6_neighbor", dmac_rsp->mc_ipv6_neighbor_en, + "ipv6_route", dmac_rsp->mc_ipv6_route_en, + "dhcpv6_relay", dmac_rsp->mc_dhcpv6_relay_en, + "to_bmc", dmac_rsp->mc_to_bmc, "to_bmc_only", dmac_rsp->mc_to_bmc_only); + + printf("broadcast_filter: %16s(%u)%15s(%u)%16s(%u)%11s(%u)%15s(%u)%15s(%u)\n", + "arp", dmac_rsp->bc_arp_en, "dhcp_client", dmac_rsp->bc_dhcp_client, + "dhcp_server", dmac_rsp->bc_dhcp_server, "netbios", dmac_rsp->bc_netbios_en, + "to_bmc", dmac_rsp->bc_to_bmc, "to_bmc_only", dmac_rsp->bc_to_bmc_only); + +ERR_OUT: + hikp_cmd_free(&cmd_resp); +} + +static void nic_ncsi_cmd_show_smac_filter_cfg(struct major_cmd_ctrl *self) +{ + struct nic_ncsi_smac_filter_resp *smac_rsp = NULL; + struct hikp_cmd_ret *cmd_resp = NULL; + int ret; + + ret = nic_ncsi_cmd_get_entry_response_data(self, NIC_NCSI_GET_SMAC_FILTER_TBL, &cmd_resp); + if (ret) + goto ERR_OUT; + + smac_rsp = (struct nic_ncsi_smac_filter_resp *)cmd_resp->rsp_data; + printf("smac filter config:\n"); + printf("%-30s: 0x%x\n", "filter_enable", smac_rsp->smac_en_map); + printf("%-30s: 0x%x\n", "pt_pkt_enable", smac_rsp->pt_pkt_en); + + printf("enabled entries:\n"); + printf("%5s |%10s |%15s |%10s |%13s\n", + "id", "dport", "entry_to_mac", "entry_h", "entry_l"); + for (uint32_t i = 0; i < NIC_NCSI_SMAC_ENTRY_NUM; i++) { + if (!smac_rsp->entry[i].entry_en) + continue; + printf("%5u |%10u |%15u |%#10x |%#13x\n", + i, smac_rsp->entry[i].entry_dport, + smac_rsp->entry[i].entry_to_mac, smac_rsp->entry[i].entry_cfg_h, + smac_rsp->entry[i].entry_cfg_l); + } + +ERR_OUT: + hikp_cmd_free(&cmd_resp); +} + +static void nic_ncsi_cmd_get_filter_cfg(struct major_cmd_ctrl *self) +{ + struct ncsi_dump_mod_proc mod_info[] = { + {"tx_buf", nic_ncsi_cmd_show_tx_buf_status}, + {"vlan", nic_ncsi_cmd_show_vlan_filter_cfg}, + {"ether", nic_ncsi_cmd_show_ether_filter_cfg}, + {"dmac", nic_ncsi_cmd_show_dmac_filter_cfg}, + {"smac", nic_ncsi_cmd_show_smac_filter_cfg}, + }; + uint32_t size = HIKP_ARRAY_SIZE(mod_info); + + if (!g_ncsi_cmd_info.module_name) { + self->err_no = -EPERM; + snprintf(self->err_str, sizeof(self->err_str), "dump module is null."); + return; + } + + if (strcmp(g_ncsi_cmd_info.module_name, "all") == 0) { + for (uint32_t i = 0; i < size; i++) { + mod_info[i].show(self); + printf("----------------------------------" + "------------------------------------------\n"); + } + } else { + for (uint32_t i = 0; i < size; i++) { + if (strcmp(g_ncsi_cmd_info.module_name, mod_info[i].name) != 0) + continue; + + return mod_info[i].show(self); + } + + self->err_no = -EINVAL; + snprintf(self->err_str, sizeof(self->err_str), + "Invalid filter conifg module: %s.", g_ncsi_cmd_info.module_name); + } +} + +static void nic_ncsi_cmd_execute(struct major_cmd_ctrl *self) +{ + if ((g_ncsi_cmd_info.cmd_flag & NCSI_PORT_TARGET_BIT) == 0) { + self->err_no = -EINVAL; + snprintf(self->err_str, sizeof(self->err_str), "Need port id."); + return; + } + + if (g_ncsi_cmd_info.cmd_flag & NCSI_DUMP_MODULE_BIT) + nic_ncsi_cmd_get_filter_cfg(self); + else + nic_ncsi_cmd_get_cnt_dfx(self); +} + static int nic_ncsi_cmd_get_port_info(struct major_cmd_ctrl *self, const char *argv) { self->err_no = tool_check_and_get_valid_bdf_id(argv, &g_ncsi_cmd_info.target); @@ -82,7 +296,17 @@ static int nic_ncsi_cmd_get_port_info(struct major_cmd_ctrl *self, const char *a snprintf(self->err_str, sizeof(self->err_str), "Unknown device %s.", argv); return self->err_no; } - g_ncsi_cmd_info.port_flag = true; + g_ncsi_cmd_info.cmd_flag |= NCSI_PORT_TARGET_BIT; + + return 0; +} + +static int nic_ncsi_cmd_get_dump_mode(struct major_cmd_ctrl *self, const char *argv) +{ + HIKP_SET_USED(self); + + g_ncsi_cmd_info.cmd_flag |= NCSI_DUMP_MODULE_BIT; + g_ncsi_cmd_info.module_name = argv; return 0; } @@ -97,6 +321,8 @@ static int nic_ncsi_cmd_show_help(struct major_cmd_ctrl *self, const char *argv) printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit"); printf(" %s, %-25s %s\n", "-i", "--interface=", "device target or bdf id, e.g. eth0~3 or 0000:35:00.0"); + printf(" %s, %-25s %s\n", "-d", "--dump", "specify the module name for the dump " + "e.g. tx_buf, vlan, ether, dmac, smac, all"); printf("\n"); return 0; @@ -124,12 +350,13 @@ static void cmd_nic_get_ncsi_init(void) { struct major_cmd_ctrl *major_cmd = get_major_cmd(); - g_ncsi_cmd_info.port_flag = false; + g_ncsi_cmd_info.cmd_flag = 0; major_cmd->option_count = 0; major_cmd->execute = nic_ncsi_cmd_execute; cmd_option_register("-h", "--help", false, nic_ncsi_cmd_show_help); cmd_option_register("-i", "--interface", true, nic_ncsi_cmd_get_port_info); + cmd_option_register("-d", "--dump", true, nic_ncsi_cmd_get_dump_mode); } HIKP_CMD_DECLARE("nic_ncsi", "query nic port ncsi information", cmd_nic_get_ncsi_init); diff --git a/net/nic/nic_ncsi/hikp_nic_ncsi.h b/net/nic/nic_ncsi/hikp_nic_ncsi.h index 56ab6533d9108ec4edd8a0a1ad617afd313a9d78..dfcf974300a4712873c90cd170f9c64974239077 100644 --- a/net/nic/nic_ncsi/hikp_nic_ncsi.h +++ b/net/nic/nic_ncsi/hikp_nic_ncsi.h @@ -44,14 +44,120 @@ struct nic_ncsi_cmd_resp { uint32_t rsv1[50]; /* max resp data: 240 Bytes */ }; +struct nic_ncsi_tx_buf_resp { + uint8_t tx_buf_empty : 1; + uint8_t ctrl_sof : 1; + uint8_t ctrl_eof : 1; + uint8_t ctrl_err : 1; + uint8_t ctrl_byte_sel : 2; + uint8_t rsv0 : 2; + uint8_t rsv1[7]; + uint32_t rsv2[58]; /* max resp data: 240 Bytes */ +}; + +#define NIC_NCSI_VLAN_ENTRY_NUM 16 +struct ncsi_vlan_entry { + uint32_t vlan_id : 16; + uint32_t entry_en : 1; + uint32_t rsv : 15; +}; + +struct nic_ncsi_vlan_filter_resp { + uint32_t filter_en_map : 16; + uint32_t filer_type : 8; + uint32_t rsv0 : 8; + uint32_t entry_to_bmc_only_map : 16; + uint32_t entry_to_bmc_map : 16; + + struct ncsi_vlan_entry entry[NIC_NCSI_VLAN_ENTRY_NUM]; + uint32_t rsv1[42]; /* max resp data: 240 Bytes */ +}; + +#define NIC_NCSI_ETHER_ENTRY_NUM 4 +struct ncsi_ether_entry { + uint32_t entry_type : 16; + uint32_t entry_en : 1; + uint32_t rsv : 15; +}; + +struct nic_ncsi_ether_filter_resp { + uint32_t ether_en_map : 4; + uint32_t entry_to_bmc_only_map : 4; + uint32_t entry_to_bmc_map : 4; + uint32_t rsv0 : 20; + uint32_t rsv1; + struct ncsi_ether_entry entry[NIC_NCSI_ETHER_ENTRY_NUM]; + uint32_t rsv2[54]; /* max resp data: 240 Bytes */ +}; + +#define NIC_NCSI_DMAC_ENTRY_NUM 8 +struct ncsi_dmac_entry { + uint32_t entry_cfg_l; + uint32_t entry_cfg_h : 16; + uint32_t entry_type : 2; + uint32_t entry_en : 1; + uint32_t rsv : 13; +}; + +struct nic_ncsi_dmac_filter_resp { + uint32_t dmac_en_map : 8; + uint32_t dmac_to_bmc_only : 8; + uint32_t dmac_to_bmc : 8; + uint32_t rsv0 : 8; + uint32_t mc_ipv6_neighbor_en : 1; + uint32_t mc_ipv6_route_en : 1; + uint32_t mc_dhcpv6_relay_en : 1; + uint32_t mc_to_bmc : 1; + uint32_t mc_to_bmc_only : 1; + uint32_t rsv1 : 27; + uint32_t bc_arp_en : 1; + uint32_t bc_dhcp_client : 1; + uint32_t bc_dhcp_server : 1; + uint32_t bc_netbios_en : 1; + uint32_t bc_to_bmc : 1; + uint32_t bc_to_bmc_only : 1; + uint32_t rsv2 : 26; + uint32_t rsv3; + struct ncsi_dmac_entry entry[NIC_NCSI_DMAC_ENTRY_NUM]; + uint32_t rsv4[40]; /* max resp data: 240 Bytes */ +}; + +#define NIC_NCSI_SMAC_ENTRY_NUM 8 +struct ncsi_smac_entry { + uint32_t entry_cfg_l; + uint32_t entry_cfg_h : 16; + uint32_t entry_en : 1; + uint32_t entry_dport : 3; + uint32_t entry_to_mac : 1; + uint32_t rsv : 11; +}; + +struct nic_ncsi_smac_filter_resp { + uint32_t smac_en_map : 8; + uint32_t pt_pkt_en : 1; + uint32_t rsv0 : 23; + uint32_t rsv1; + struct ncsi_smac_entry entry[NIC_NCSI_SMAC_ENTRY_NUM]; + uint32_t rsv2[42]; /* max resp data: 240 Bytes */ +}; + struct nic_ncsi_cmd_req { struct bdf_t bdf; uint32_t rsv0[30]; /* max req data: 128 Bytes */ }; +struct ncsi_dump_mod_proc { + const char *name; + void (*show)(struct major_cmd_ctrl *self); +}; + +#define NCSI_PORT_TARGET_BIT HI_BIT(0) +#define NCSI_DUMP_MODULE_BIT HI_BIT(1) + struct nic_ncsi_cmd_info { struct tool_target target; - bool port_flag; + uint32_t cmd_flag; + const char *module_name; }; struct nic_ncsi_collect_param { diff --git a/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c b/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c index b74507c6e0d5fa06d8d679ddf03f30090ec7d857..98337a3f2c29a97fa2d0cbbc54a9cbf5c06e9367 100644 --- a/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c +++ b/net/roce/roce_dfx_sta/hikp_roce_dfx_sta.c @@ -59,6 +59,8 @@ static const char *g_dfx_sta_reg_name[] = { "PKT_RNR_STA", "PKT_RTY_STA", "MSN_RTY_STA", + "LENGTH_ERR", + "RQ_RNR", }; static int hikp_roce_dfx_sta_get_data(struct hikp_cmd_ret **cmd_ret, diff --git a/sas/sas_func/sas_common.h b/sas/sas_func/sas_common.h index 78edf2ef7e63f2b9f50ad873e7266c55b00f2319..c11b7d4865fc83f3b7d13dc78f36dd85727e45c4 100644 --- a/sas/sas_func/sas_common.h +++ b/sas/sas_func/sas_common.h @@ -79,9 +79,4 @@ enum sas_dev_cmd_type { DEV_UNKNOWN_TYPE, }; -enum sas_dqe_cmd_type { - DQE_INFO, - DQE_UNKNOWN_TYPE, -}; - #endif /* SAS_COMMON_H */ diff --git a/sas/sas_func/sas_read_dev.c b/sas/sas_func/sas_read_dev.c index dec29354ebd0a6da70c721534fe4b89b239b92f7..c541c1c6e41ed0085aaaf998c13a09e2b765126e 100644 --- a/sas/sas_func/sas_read_dev.c +++ b/sas/sas_func/sas_read_dev.c @@ -34,7 +34,7 @@ static int sas_get_dev(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint3 hikp_cmd_init(&req_header, SAS_MOD, SAS_DEV, cmd->sas_cmd_type); cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_dqe excutes hikp_cmd_alloc err\n"); + printf("sas_dev excutes hikp_cmd_alloc err\n"); hikp_cmd_free(&cmd_ret); return -EINVAL; } diff --git a/sas/sas_func/sas_read_dqe.c b/sas/sas_func/sas_read_dqe.c deleted file mode 100644 index ae4ef68c6b9d7aa61b384c3808db7c7dabe2dcb5..0000000000000000000000000000000000000000 --- a/sas/sas_func/sas_read_dqe.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2022 Hisilicon Technologies Co., Ltd. - * Hikptool is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * - * See the Mulan PSL v2 for more details. - */ -#include -#include -#include -#include -#include -#include -#include "hikptdev_plug.h" -#include "sas_common.h" -#include "sas_read_dqe.h" - -static int sas_get_dqe(const struct tool_sas_cmd *cmd, uint32_t *reg_save, uint32_t *reg_num) -{ - struct hikp_cmd_header req_header; - struct hikp_cmd_ret *cmd_ret; - struct sas_dqe_req_para req_data = { 0 }; - - req_data.chip_id = cmd->chip_id; - req_data.die_id = cmd->die_id; - req_data.que_id = cmd->que_id; - req_data.dqe_id = cmd->dqe_id; - - hikp_cmd_init(&req_header, SAS_MOD, SAS_DQE, cmd->sas_cmd_type); - cmd_ret = hikp_cmd_alloc(&req_header, &req_data, sizeof(req_data)); - if (cmd_ret == NULL || cmd_ret->status != 0 || cmd_ret->rsp_data_num > RESP_MAX_NUM) { - printf("sas_dqe excutes hikp_cmd_alloc err\n"); - hikp_cmd_free(&cmd_ret); - return -EINVAL; - } - *reg_num = cmd_ret->rsp_data_num; - for (uint32_t i = 0; i < *reg_num; i++) - reg_save[i] = cmd_ret->rsp_data[i]; - - hikp_cmd_free(&cmd_ret); - return 0; -} - -static void print_dqe_info(const void *reg_save) -{ - volatile struct hisi_sas_dq_info *dqe = (volatile struct hisi_sas_dq_info *)(reg_save); - - printf("The dqe dw0 information as below:\n"); - printf("abort_flag: %u\n", dqe->dw0.abort_flag); - printf("abort_devtype: %u\n", dqe->dw0.abort_devtype); - printf("Rsponse_report: %u\n", dqe->dw0.Rsponse_report); - printf("TLR_Ctrl: %u\n", dqe->dw0.TLR_Ctrl); - printf("Phy_ID: %u\n", dqe->dw0.Phy_ID); - printf("Force_Phy: %u\n", dqe->dw0.Force_Phy); - printf("PORT: 0x%x\n", dqe->dw0.PORT); - printf("PRI: %u\n", dqe->dw0.PRI); - printf("CMD: %u\n", dqe->dw0.CMD); - - printf("The dqe dw1 information as below:\n"); - printf("Non_Busy_Constraint: %u\n", dqe->dw1.Non_Busy_Constraint); - printf("SSP_Pass_Through: %u\n", dqe->dw1.SSP_Pass_Through); - printf("DIR: %u\n", dqe->dw1.DIR); - printf("Reset: %u\n", dqe->dw1.Reset); - printf("PIR_Present: %u\n", dqe->dw1.PIR_Present); - printf("Enable_Transport_Layer_Retry: %u\n", dqe->dw1.Enable_Transport_Layer_Retry); - printf("Verify_Data_Transfer_Length: 0x%x\n", dqe->dw1.Verify_Data_Transfer_Length); - printf("Frame_Type: %u\n", dqe->dw1.Frame_Type); - printf("Device_ID: %u\n", dqe->dw1.Device_ID); - - printf("The dqe dw2 information as below:\n"); - printf("Command_Frame_Length: %u\n", dqe->dw2.Command_Frame_Length); - printf("Leave_Affiliation_Open: %u\n", dqe->dw2.Leave_Affiliation_Open); - printf("Ncq_Tag: %u\n", dqe->dw2.Ncq_Tag); - printf("Max_Response_Frame_Length: %u\n", dqe->dw2.Max_Response_Frame_Length); - printf("Sg_Mode: %u\n", dqe->dw2.Sg_Mode); - printf("First_Burst: %u\n", dqe->dw2.First_Burst); - - printf("Initiator_Port_Transfer_Tag: %u\n", dqe->Initiator_Port_Transfer_Tag); - printf("Target_Port_Transfer_Tag: %u\n", dqe->Target_Port_Transfer_Tag); - printf("Data_Transfer_Length: %u\n", dqe->Data_Transfer_Length); - printf("First_Burst_Num: %u\n", dqe->First_Burst_Num); - printf("DIF_PRD_Table_Length: %u\n", dqe->DIF_PRD_Table_Length); - printf("PRD_Table_Length: %u\n", dqe->PRD_Table_Length); - - printf("The dqe dw7 information as below:\n"); - printf("Double_Mode: %u\n", dqe->dw7.Double_Mode); - printf("Abort_IPTT: %u\n", dqe->dw7.Abort_IPTT); -} - -int sas_dqe(const struct tool_sas_cmd *cmd) -{ - int ret; - uint32_t reg_num = 0; - uint32_t reg_save[RESP_MAX_NUM] = { 0 }; - - if (cmd == NULL) - return -ENOSPC; - - ret = sas_get_dqe(cmd, reg_save, ®_num); - if (ret) - return ret; - - if (reg_num < REG_NUM_DQE_MAX) { - printf("SAS dqe is failed\n"); - return -EINVAL; - } - print_dqe_info(reg_save); - return 0; -} diff --git a/sas/sas_func/sas_read_dqe.h b/sas/sas_func/sas_read_dqe.h deleted file mode 100644 index 95e1ff3b22a4c6461c0cf6a8226a0ebf748b4f11..0000000000000000000000000000000000000000 --- a/sas/sas_func/sas_read_dqe.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2022 Hisilicon Technologies Co., Ltd. - * Hikptool is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * - * See the Mulan PSL v2 for more details. - */ - -#ifndef SAS_DQE_H -#define SAS_DQE_H - -#include "sas_tools_include.h" - -struct sas_dqe_req_para { - uint32_t chip_id; - uint32_t die_id; - uint32_t que_id; - uint32_t dqe_id; -}; - -struct hikp_sas_dqe_dw0 { - uint32_t abort_flag : 2; - uint32_t abort_devtype : 1; - uint32_t Rsvd0 : 2; - uint32_t Rsponse_report : 1; - uint32_t TLR_Ctrl : 2; - uint32_t Phy_ID : 9; - uint32_t Force_Phy : 1; - uint32_t PORT : 4; - uint32_t Rsvd1 : 5; - uint32_t PRI : 1; - uint32_t Rsvd5 : 1; - uint32_t CMD : 3; -}; - -struct hikp_sas_dqe_dw1 { - uint32_t Rsvd2 : 3; - uint32_t Non_Busy_Constraint : 1; - uint32_t SSP_Pass_Through : 1; - uint32_t DIR : 2; - uint32_t Reset : 1; - uint32_t PIR_Present : 1; - uint32_t Enable_Transport_Layer_Retry : 1; - uint32_t Verify_Data_Transfer_Length : 1; - uint32_t Frame_Type : 5; - uint32_t Device_ID : 16; -}; - -struct hikp_sas_dqe_dw2 { - uint32_t Command_Frame_Length : 9; - uint32_t Leave_Affiliation_Open : 1; - uint32_t Ncq_Tag : 5; - uint32_t Max_Response_Frame_Length : 9; - uint32_t Sg_Mode : 2; - uint32_t First_Burst : 1; - uint32_t Rsvd3 : 5; -}; - -struct hikp_sas_dqe_dw7 { - uint32_t Rsvd4 : 15; - uint32_t Double_Mode : 1; - uint32_t Abort_IPTT : 16; -}; - -struct hisi_sas_dq_info { - struct hikp_sas_dqe_dw0 dw0; - struct hikp_sas_dqe_dw1 dw1; - struct hikp_sas_dqe_dw2 dw2; - uint32_t Initiator_Port_Transfer_Tag : 16; - uint32_t Target_Port_Transfer_Tag : 16; - uint32_t Data_Transfer_Length; - uint32_t First_Burst_Num; - uint32_t DIF_PRD_Table_Length : 16; - uint32_t PRD_Table_Length : 16; - struct hikp_sas_dqe_dw7 dw7; -}; - -int sas_dqe(const struct tool_sas_cmd *cmd); - -#endif /* SAS_DQE_H */ diff --git a/sas/user_cmd/cmd_code/sas_cmd_dqe.c b/sas/user_cmd/cmd_code/sas_cmd_dqe.c deleted file mode 100644 index b914f54da94038d7da60bb8f107181be0b9ed81f..0000000000000000000000000000000000000000 --- a/sas/user_cmd/cmd_code/sas_cmd_dqe.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2022 Hisilicon Technologies Co., Ltd. - * Hikptool is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * - * See the Mulan PSL v2 for more details. - */ - -#include -#include "tool_cmd.h" -#include "sas_common.h" -#include "sas_tools_include.h" -#include "sas_read_dqe.h" - -static int sas_dqe_help(struct major_cmd_ctrl *self, const char *argv) -{ - HIKP_SET_USED(argv); - - printf("\n Usage: %s\n", self->cmd_ptr->name); - printf("\n %s\n", self->cmd_ptr->help_info); - printf(" %s, %-25s %s\n", "-c", "--chipid", "please input chip id[x] first\n"); - printf(" %s, %-25s %s\n", "-d", "--dieid", "please input die id[x] first\n"); - printf(" %s, %-25s %s\n", "-q", "--queue", "please input queue id[x] first\n"); - printf("\n Options:\n\n"); - printf(" %s, %-25s %s\n", "-h", "--help", "display this help and exit\n"); - printf(" %s, %-25s %s\n", "-i", "--info", "display the dqe detail information\n"); - printf("\n"); - - return 0; -} - -static int sas_dqe_info(struct major_cmd_ctrl *self, const char *argv) -{ - int ret; - - (void)sas_set_cmd_type(DQE_INFO); - ret = sas_set_dqe_id(self, argv); - return ret; -} - -static int sas_set_queue_id(struct major_cmd_ctrl *self, const char *argv) -{ - int ret; - - ret = sas_set_que_id(self, argv); - if (ret || sas_get_que_id() >= SAS_QUEUE_NUM) { - snprintf(self->err_str, sizeof(self->err_str), "Invalid queue id."); - self->err_no = ret; - return -EINVAL; - } - - return 0; -} - -static int sas_dqe_excute_funs_call(uint32_t cmd_type) -{ - if ((cmd_type != SAS_UNKNOW_CMD) && (sas_get_que_id() != (-1))) - return sas_dqe(sas_get_cmd_p()); - - return -EINVAL; -} - -static void sas_dqe_execute(struct major_cmd_ctrl *self) -{ - int ret, cmd; - const char *suc_msg[] = { - "sas_dqe_info success.", - }; - const char *err_msg[] = { - "sas_dqe_info error.", - "sas_dqe failed, unknown type", - }; - - cmd = sas_get_cmd_type(); - ret = sas_dqe_excute_funs_call(cmd); - (void)sas_set_cmd_type(SAS_UNKNOW_CMD); - if (ret == 0) { - printf("%s\n", suc_msg[cmd]); - } else { - if (cmd == SAS_UNKNOW_CMD) - cmd = DQE_UNKNOWN_TYPE; - snprintf(self->err_str, sizeof(self->err_str), "%s\n", err_msg[cmd]); - self->err_no = ret; - } -} - -static void cmd_sas_dqe_init(void) -{ - struct major_cmd_ctrl *major_cmd = get_major_cmd(); - - major_cmd->option_count = 0; - major_cmd->execute = sas_dqe_execute; - - cmd_option_register("-c", "--chipid", true, sas_set_chip_id); - cmd_option_register("-d", "--dieid", true, sas_set_die_id); - cmd_option_register("-h", "--help", false, sas_dqe_help); - cmd_option_register("-q", "--queue", true, sas_set_queue_id); - cmd_option_register("-i", "--info", true, sas_dqe_info); -} - -HIKP_CMD_DECLARE("sas_dqe", "sas dqe information ", cmd_sas_dqe_init);