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"); }
@@ -408,13 +409,13 @@ static void mac_cmd_show_hot_plug_card(struct major_cmd_ctrl *self) static void mac_cmd_print_cdr_dfx(struct mac_cmd_cdr_dfx *cdr_dfx, struct mac_port_cdr_dfx *info) { struct mac_item type_table[] = { - {PORT_CDR_SD5902, "sd5902"}, {PORT_CDR_SD5901, "sd5901"}, + {PORT_CDR_TYPE_A, "cdr_a"}, {PORT_CDR_TYPE_B, "cdr_b"}, }; - struct mac_item sd5902_mode[] = { - {SD5902_MODE_2PLL, "2pll"}, {SD5902_MODE_FASTPI, "fastpi"}, + struct mac_item cdr_a_mode[] = { + {CDR_A_MODE_2PLL, "2pll"}, {CDR_A_MODE_FASTPI, "fastpi"}, }; - struct mac_item sd5901_mode[] = { - {SD5901_MODE_PCS, "pcs"}, {SD5901_MODE_CDR, "cdr"}, + struct mac_item cdr_b_mode[] = { + {CDR_B_MODE_PCS, "pcs"}, {CDR_B_MODE_CDR, "cdr"}, }; struct mac_item status_table[] = { {CDR_STATUS_NORMAL, "normal"}, {CDR_STATUS_ERROR, "error"}, @@ -424,12 +425,12 @@ static void mac_cmd_print_cdr_dfx(struct mac_cmd_cdr_dfx *cdr_dfx, struct mac_po const char *mode_str = "NA";
for (uint32_t i = 0; i < cdr_dfx->cdr_num; i++) { - if (cdr_dfx->cdr_type == PORT_CDR_SD5902) { - mode_str = mac_get_str(info->dfx[i].cdr_mode, sd5902_mode, - HIKP_ARRAY_SIZE(sd5902_mode), "unknown"); - } else if (cdr_dfx->cdr_type == PORT_CDR_SD5901) { - mode_str = mac_get_str(info->dfx[i].cdr_mode, sd5901_mode, - HIKP_ARRAY_SIZE(sd5901_mode), "unknown"); + if (cdr_dfx->cdr_type == PORT_CDR_TYPE_A) { + mode_str = mac_get_str(info->dfx[i].cdr_mode, cdr_a_mode, + HIKP_ARRAY_SIZE(cdr_a_mode), "unknown"); + } else if (cdr_dfx->cdr_type == PORT_CDR_TYPE_B) { + mode_str = mac_get_str(info->dfx[i].cdr_mode, cdr_b_mode, + HIKP_ARRAY_SIZE(cdr_b_mode), "unknown"); } printf("\t|0x%-8x%-9u%-10s%-10s%-10s\n", info->dfx[i].cdr_addr, info->dfx[i].cdr_start_lane, type_str, mode_str, @@ -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 @@ -188,18 +188,18 @@ struct mac_cmd_phy_info { };
enum { - PORT_CDR_SD5902 = 0, - PORT_CDR_SD5901, + PORT_CDR_TYPE_A = 0, + PORT_CDR_TYPE_B, };
enum { - SD5902_MODE_2PLL = 0, - SD5902_MODE_FASTPI, + CDR_A_MODE_2PLL = 0, + CDR_A_MODE_FASTPI, };
enum { - SD5901_MODE_PCS = 0, - SD5901_MODE_CDR, + CDR_B_MODE_PCS = 0, + CDR_B_MODE_CDR, };
enum { @@ -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);