hikptool/0037-hikptool-optimized-display-the-hot-plug-card-info-in.patch

141 lines
4.4 KiB
Diff
Raw Permalink Normal View History

From 16154c431d5c694707b12cdb3ab3b52207d9c44d Mon Sep 17 00:00:00 2001
From: veega <zhuweijia@huawei.com>
Date: Fri, 15 Sep 2023 09:32:33 +0800
Subject: [PATCH] hikptool: optimized display the hot-plug card info in
nic_port cmd
A command word was added to query the port information display capability.
If a port does not support a flexible card, the card information is not displayed.
Signed-off-by: veega <zhuweijia@huawei.com>
---
net/nic/nic_mac/hikp_mac_cmd.h | 1 +
net/nic/nic_mac/hikp_nic_port.c | 81 +++++++++++++++++++++------------
net/nic/nic_mac/hikp_nic_port.h | 17 ++++---
3 files changed, 65 insertions(+), 34 deletions(-)
diff --git a/net/nic/nic_mac/hikp_mac_cmd.h b/net/nic/nic_mac/hikp_mac_cmd.h
index adaadf4..f74fd2a 100644
--- a/net/nic/nic_mac/hikp_mac_cmd.h
+++ b/net/nic/nic_mac/hikp_mac_cmd.h
@@ -31,6 +31,7 @@ enum mac_port_sub_cmd {
QUERY_PORT_PHY_DFX,
QUERY_HOT_PLUG_CARD_DFX,
QUERY_PORT_CDR_DFX,
+ QUERY_PORT_INFO_DFX_CAP,
};
enum mac_dump_reg_sub_cmd {
diff --git a/net/nic/nic_mac/hikp_nic_port.c b/net/nic/nic_mac/hikp_nic_port.c
index c9f46fc..5ba6927 100644
--- a/net/nic/nic_mac/hikp_nic_port.c
+++ b/net/nic/nic_mac/hikp_nic_port.c
@@ -361,11 +361,12 @@ static void mac_cmd_disp_arb_info(const struct mac_cmd_arb_dfx *arb_dfx)
static void mac_cmd_disp_hot_plug_card_info(const struct cmd_hot_plug_card_info *hpc_dfx)
{
- printf("\n======================== HOT PLUG CARD INFO =======================\n");
+ printf("\n===================== HOT PLUG CARD INFO =====================\n");
printf("hot plug card in position: 0x%x\n", hpc_dfx->in_pos);
printf("support type: 0x%x\n", hpc_dfx->support_type);
- printf("current type: 0x%x\n", hpc_dfx->cur_type);
+ if (hpc_dfx->in_pos)
+ printf("current type: 0x%x\n", hpc_dfx->cur_type);
printf("----------------------------------------------------------------------------\n");
}
@@ -491,35 +492,59 @@ static void mac_cmd_show_port_dfx(struct major_cmd_ctrl *self, uint32_t mask)
}
}
-static void mac_cmd_port_execute(struct major_cmd_ctrl *self)
+static int mac_cmd_get_port_dfx_cap(uint32_t *cap)
{
struct mac_cmd_port_hardware *port_hw = NULL;
+ struct mac_cmd_port_dfx_cap *dfx_cap = NULL;
+ struct hikp_cmd_ret *dfx_cap_resp = NULL;
struct hikp_cmd_ret *hw_cmd_ret = NULL;
- uint32_t mask;
int ret;
- if (!g_port_info.port_flag) {
- self->err_no = -EINVAL;
- snprintf(self->err_str, sizeof(self->err_str), "Need port id.");
- return;
+ ret = mac_cmd_get_dfx_cfg(QUERY_PORT_INFO_DFX_CAP, &dfx_cap_resp);
+ if (ret == 0) {
+ dfx_cap = (struct mac_cmd_port_dfx_cap *)dfx_cap_resp->rsp_data;
+ *cap = dfx_cap->cap_bit_map;
+ free(dfx_cap_resp);
+ dfx_cap_resp = NULL;
+ return ret;
}
+ /* not support get capability, so use old process */
ret = mac_cmd_get_dfx_cfg(QUERY_PORT_HARDWARE, &hw_cmd_ret);
- if (ret != 0) {
- printf("hikp_data_proc get port hw failed.\n");
- self->err_no = -ENOSPC;
- return;
- }
+ if (ret)
+ return ret;
- mask = MAC_LSPORT_LINK | MAC_LSPORT_MAC |
- MAC_LSPORT_ARB | MAC_HOT_PLUG_CARD | MAC_LSPORT_CDR;
+ *cap = MAC_LSPORT_LINK | MAC_LSPORT_MAC | MAC_LSPORT_ARB |
+ MAC_HOT_PLUG_CARD | MAC_LSPORT_CDR;
port_hw = (struct mac_cmd_port_hardware *)(hw_cmd_ret->rsp_data);
if (port_hw->port_type == HIKP_PORT_TYPE_PHY ||
port_hw->port_type == HIKP_PORT_TYPE_PHY_SDS)
- mask |= MAC_LSPORT_PHY;
+ *cap |= MAC_LSPORT_PHY;
- mac_cmd_show_port_dfx(self, mask);
free(hw_cmd_ret);
+ hw_cmd_ret = NULL;
+ return ret;
+}
+
+static void mac_cmd_port_execute(struct major_cmd_ctrl *self)
+{
+ uint32_t dfx_cap;
+ int ret;
+
+ if (!g_port_info.port_flag) {
+ self->err_no = -EINVAL;
+ snprintf(self->err_str, sizeof(self->err_str), "Need port id.");
+ return;
+ }
+
+ ret = mac_cmd_get_port_dfx_cap(&dfx_cap);
+ if (ret) {
+ self->err_no = ret;
+ snprintf(self->err_str, sizeof(self->err_str), "Get DFX capability failed.");
+ return;
+ }
+
+ mac_cmd_show_port_dfx(self, dfx_cap);
}
static int mac_cmd_get_port_target(struct major_cmd_ctrl *self, const char *argv)
diff --git a/net/nic/nic_mac/hikp_nic_port.h b/net/nic/nic_mac/hikp_nic_port.h
index 42ab3f9..78928b3 100644
--- a/net/nic/nic_mac/hikp_nic_port.h
+++ b/net/nic/nic_mac/hikp_nic_port.h
@@ -225,6 +225,11 @@ struct mac_cmd_cdr_dfx {
struct mac_port_cdr_dfx host_cdr;
};
+struct mac_cmd_port_dfx_cap {
+ uint32_t cap_bit_map;
+ uint32_t rsvd[3];
+};
+
struct mac_cmd_dfx_callback {
uint32_t mask;
void (*show_dfx)(struct major_cmd_ctrl *self);
--
2.36.1.windows.1