5 Star 0 Fork 7

src-openEuler/hikptool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0058-hikptool-The-nic_port-command-is-adapted-to-display-.patch 5.08 KB
一键复制 编辑 原始数据 按行查看 历史
From 9bdcedb5d634b438139daf6de851a0f40e8708fe Mon Sep 17 00:00:00 2001
From: veega2022 <zhuweijia@huawei.com>
Date: Thu, 22 Feb 2024 10:34:09 +0800
Subject: [PATCH] hikptool: The nic_port command is adapted to display the DFX
of the ROH MAC
ROH MAC is different from ETH MAC. For ROH MAC,
the following DFX parameters are added:
tx link lanes, rx link lanes, pcs link, mac link, tx retry count, etc.
For the firmware of earlier versions,
the MAC DFX of the ETH type is displayed by default.
Signed-off-by: veega2022 <zhuweijia@huawei.com>
---
net/nic/nic_mac/hikp_mac_cmd.h | 1 +
net/nic/nic_mac/hikp_nic_port.c | 63 +++++++++++++++++++++++++++++++--
net/nic/nic_mac/hikp_nic_port.h | 25 +++++++++++++
3 files changed, 86 insertions(+), 3 deletions(-)
diff --git a/net/nic/nic_mac/hikp_mac_cmd.h b/net/nic/nic_mac/hikp_mac_cmd.h
index f74fd2a..9a3f0d9 100644
--- a/net/nic/nic_mac/hikp_mac_cmd.h
+++ b/net/nic/nic_mac/hikp_mac_cmd.h
@@ -32,6 +32,7 @@ enum mac_port_sub_cmd {
QUERY_HOT_PLUG_CARD_DFX,
QUERY_PORT_CDR_DFX,
QUERY_PORT_INFO_DFX_CAP,
+ QUERY_PORT_ROH_MAC_DFX,
};
enum mac_dump_reg_sub_cmd {
diff --git a/net/nic/nic_mac/hikp_nic_port.c b/net/nic/nic_mac/hikp_nic_port.c
index 5ba6927..725ef95 100644
--- a/net/nic/nic_mac/hikp_nic_port.c
+++ b/net/nic/nic_mac/hikp_nic_port.c
@@ -174,7 +174,7 @@ static void mac_show_speed(uint32_t speed, uint32_t lanes)
printf("speed: %s_%s\n", speed_str, lanes_str);
}
-static void mac_cmd_disp_mac_info(const struct mac_cmd_mac_dfx *mac_dfx)
+static void mac_cmd_disp_eth_mac_info(const struct mac_cmd_mac_dfx *mac_dfx)
{
printf("\n========================== MAC INFO ==========================\n");
mac_show_speed(mac_dfx->speed, mac_dfx->lanes);
@@ -192,7 +192,7 @@ static void mac_cmd_disp_mac_info(const struct mac_cmd_mac_dfx *mac_dfx)
printf("pcs_err = 0x%x\n", mac_dfx->pcs_err_cnt);
}
-static void mac_cmd_show_mac(struct major_cmd_ctrl *self)
+static void mac_cmd_show_eth_mac(struct major_cmd_ctrl *self)
{
struct mac_cmd_mac_dfx *mac_dfx = NULL;
struct hikp_cmd_ret *cmd_ret = NULL;
@@ -206,8 +206,65 @@ static void mac_cmd_show_mac(struct major_cmd_ctrl *self)
}
mac_dfx = (struct mac_cmd_mac_dfx *)(cmd_ret->rsp_data);
- mac_cmd_disp_mac_info(mac_dfx);
+ mac_cmd_disp_eth_mac_info(mac_dfx);
+ free(cmd_ret);
+ cmd_ret = NULL;
+}
+
+static void mac_cmd_disp_roh_mac_info(const struct mac_cmd_roh_mac_dfx *mac_dfx)
+{
+ printf("\n========================== MAC INFO ==========================\n");
+ mac_show_speed(mac_dfx->speed, mac_dfx->lanes);
+ mac_print_enum("fec", mac_dfx->fec, g_fec_table, HIKP_ARRAY_SIZE(g_fec_table), "unknown");
+ mac_print_enum("sds_rate", mac_dfx->sds_rate, g_sds_rate_table,
+ HIKP_ARRAY_SIZE(g_sds_rate_table), "unknown");
+ printf("tx_link_lanes: %u\n", mac_dfx->tx_link_lanes);
+ printf("rx_link_lanes: %u\n", mac_dfx->rx_link_lanes);
+ mac_print_link("pcs_link", mac_dfx->pcs_link);
+ mac_print_link("mac_link", mac_dfx->mac_link);
+ printf("tx_retry_cnt: %u\n", mac_dfx->tx_retry_cnt);
+}
+
+static void mac_cmd_show_roh_mac(struct major_cmd_ctrl *self)
+{
+ struct mac_cmd_roh_mac_dfx *mac_dfx = NULL;
+ struct hikp_cmd_ret *cmd_ret = NULL;
+ int ret;
+
+ ret = mac_cmd_get_dfx_cfg(QUERY_PORT_ROH_MAC_DFX, &cmd_ret);
+ if (ret) {
+ snprintf(self->err_str, sizeof(self->err_str), "mac get roh mac dfx failed.");
+ self->err_no = -ENOSPC;
+ return;
+ }
+
+ mac_dfx = (struct mac_cmd_roh_mac_dfx *)(cmd_ret->rsp_data);
+ mac_cmd_disp_roh_mac_info(mac_dfx);
free(cmd_ret);
+ cmd_ret = NULL;
+}
+
+static void mac_cmd_show_mac(struct major_cmd_ctrl *self)
+{
+ struct mac_cmd_port_hardware *hw = NULL;
+ struct hikp_cmd_ret *hw_cmd_ret = NULL;
+ int ret;
+
+ ret = mac_cmd_get_dfx_cfg(QUERY_PORT_HARDWARE, &hw_cmd_ret);
+ if (ret) {
+ snprintf(self->err_str, sizeof(self->err_str), "mac get hardware dfx failed.");
+ self->err_no = -ENOSPC;
+ return;
+ }
+
+ hw = (struct mac_cmd_port_hardware *)(hw_cmd_ret->rsp_data);
+ if (hw->cmd_mac_type == CMD_MAC_TYPE_ROH || hw->cmd_mac_type == CMD_MAC_TYPE_UB)
+ mac_cmd_show_roh_mac(self);
+ else
+ mac_cmd_show_eth_mac(self);
+
+ free(hw_cmd_ret);
+ hw_cmd_ret = NULL;
}
static void mac_cmd_disp_link_info(struct mac_cmd_link_dfx *link_dfx)
diff --git a/net/nic/nic_mac/hikp_nic_port.h b/net/nic/nic_mac/hikp_nic_port.h
index 78928b3..cb72ebc 100644
--- a/net/nic/nic_mac/hikp_nic_port.h
+++ b/net/nic/nic_mac/hikp_nic_port.h
@@ -107,6 +107,9 @@ struct mac_item {
struct mac_cmd_port_hardware {
uint8_t port_type;
uint8_t media_type;
+ uint8_t cmd_mac_type : 4,
+ rsv0 : 4;
+ uint8_t rsv1;
};
struct mac_cmd_mac_dfx {
@@ -230,6 +233,28 @@ struct mac_cmd_port_dfx_cap {
uint32_t rsvd[3];
};
+enum cmd_mac_type {
+ CMD_MAC_TYPE_ETH = 0,
+ CMD_MAC_TYPE_ROH,
+ CMD_MAC_TYPE_UB,
+ CMD_MAC_TYPE_MAX,
+};
+
+struct mac_cmd_roh_mac_dfx {
+ uint8_t speed;
+ uint8_t fec;
+ uint8_t lanes;
+ uint8_t sds_rate;
+ uint8_t tx_link_lanes : 4,
+ rx_link_lanes : 4;
+ uint8_t pcs_link : 1,
+ mac_link : 1,
+ rsv0 : 6;
+ uint8_t rsv1[2];
+ uint32_t tx_retry_cnt;
+ uint32_t rsv2[4];
+};
+
struct mac_cmd_dfx_callback {
uint32_t mask;
void (*show_dfx)(struct major_cmd_ctrl *self);
--
2.30.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/hikptool.git
git@gitee.com:src-openeuler/hikptool.git
src-openeuler
hikptool
hikptool
master

搜索帮助