diff --git a/libhikptdev/include/hikptdev_plug.h b/libhikptdev/include/hikptdev_plug.h index 56cea78f19c594733a83e0054b795bbe57cc85cc..5ea02cab364e6af53ca40be17cb2badb3f9664c5 100644 --- a/libhikptdev/include/hikptdev_plug.h +++ b/libhikptdev/include/hikptdev_plug.h @@ -11,8 +11,8 @@ * See the Mulan PSL v2 for more details. */ -#ifndef __HIKPTDEV_PLUG_H -#define __HIKPTDEV_PLUG_H +#ifndef HIKPTDEV_PLUG_H +#define HIKPTDEV_PLUG_H #include @@ -56,4 +56,4 @@ void hikp_dev_uninit(void); int hikp_rsp_normal_check(const struct hikp_cmd_ret *cmd_ret); int hikp_rsp_normal_check_with_version(const struct hikp_cmd_ret *cmd_ret, uint32_t version); -#endif +#endif /* HIKPTDEV_PLUG_H */ diff --git a/libhikptdev/src/rciep/hikpt_rciep.c b/libhikptdev/src/rciep/hikpt_rciep.c index f673dd05043a4d4a44ab76c1304596d4fe1faf6b..75ec2245df3880a73ebd700f12239d0650686853 100644 --- a/libhikptdev/src/rciep/hikpt_rciep.c +++ b/libhikptdev/src/rciep/hikpt_rciep.c @@ -366,8 +366,8 @@ static int hikp_iep_check(const char *tmp_vendor_dir, return ret; ret = hikp_iep_check_item(revision_dir, MAX_PCI_REVISION_LEN, HIKP_IEP_REVISION); - if (ret != 0) - printf("Revision id not match %s.\n", HIKP_IEP_REVISION); + if (ret != 0 && ret != -ENXIO) + return ret; return 0; } diff --git a/net/nic/nic_info/hikp_nic_info.c b/net/nic/nic_info/hikp_nic_info.c index cd78bc76c24245611a70263faa2a0df4c511c03b..992bbf00cd78b6d84eb0d8aed755542a0e8dc91a 100644 --- a/net/nic/nic_info/hikp_nic_info.c +++ b/net/nic/nic_info/hikp_nic_info.c @@ -98,6 +98,13 @@ static int hikp_nic_get_curr_die_info(void) return 0; } +static const char *hikp_nic_info_get_mac_type(uint8_t type_val) +{ + const char *mac_type[MAC_TYPE_MAX] = {"ETH", "ROH", "UB"}; + + return (type_val >= MAC_TYPE_MAX) ? "UNKNOWN" : mac_type[type_val]; +} + static void hikp_nic_info_print_cur_pf(const struct bdf_t *bdf) { struct tool_target *pf_target = &g_info_param.target; @@ -113,7 +120,7 @@ static void hikp_nic_info_print_cur_pf(const struct bdf_t *bdf) bdf->domain, bdf->bus_id, bdf->dev_id, bdf->fun_id); printf("\t%-16s %u\n", "mac id:", g_info_param.info.pf_info[pf_id].mac_id); printf("\t%-16s %s\n", "mac type:", - g_info_param.info.pf_info[pf_id].mac_type ? "ROH" : "ETH"); + hikp_nic_info_get_mac_type(g_info_param.info.pf_info[pf_id].mac_type)); printf("\t%-16s %u\n", "func_num:", g_info_param.info.pf_info[pf_id].func_num); printf("\t%-16s %u\n", "tqp_num:", g_info_param.info.pf_info[pf_id].tqp_num); printf("\t%-16s 0x%x\n", "pf_cap_flag:", g_info_param.info.pf_info[pf_id].pf_cap_flag); @@ -162,7 +169,7 @@ static void hikp_nic_info_print_cur_die(void) printf("\n%-16s", "mac type:"); for (i = 0; i < g_info_param.info.pf_num; i++) - printf("%s\t", g_info_param.info.pf_info[i].mac_type ? "ROH" : "ETH"); + printf("%s\t", hikp_nic_info_get_mac_type(g_info_param.info.pf_info[i].mac_type)); printf("\n%-16s", "func num:"); for (i = 0; i < g_info_param.info.pf_num; i++) diff --git a/net/nic/nic_info/hikp_nic_info.h b/net/nic/nic_info/hikp_nic_info.h index 7419209a224b8f08ef6dab7dead841a73ad9ee11..194146e60d6ea13804d9d6b8c2a2b82fd45bfc03 100644 --- a/net/nic/nic_info/hikp_nic_info.h +++ b/net/nic/nic_info/hikp_nic_info.h @@ -70,4 +70,11 @@ struct nic_info_param { bool have_interface; }; +enum nic_info_mac_type { + MAC_TYPE_ETH = 0, + MAC_TYPE_ROH, + MAC_TYPE_UB, + MAC_TYPE_MAX, +}; + #endif diff --git a/net/nic/nic_mac/hikp_mac_cmd.h b/net/nic/nic_mac/hikp_mac_cmd.h index f74fd2a9edf5685778565c6c00383cef1412975b..9a3f0d93bc89e34a2a7cc0a0dde0e40b9449af81 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 5ba69273fc2cb76f4243eb002cd62759e5b3dcb8..725ef9589cfb1f4fe8b906404aa5e74e5f2bd3e5 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 78928b377bd6bb9e56f4aadab3596bf8012b8c90..cb72ebc22fb30c1ade13710db4f8a8b305d90d26 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); diff --git a/net/nic/nic_mac/hikp_nic_xsfp.c b/net/nic/nic_mac/hikp_nic_xsfp.c index d97a5069f2e55e122c529d97bbf86d1a4030bcec..70ed589993535d2262632cbb203eae914b2cd73b 100644 --- a/net/nic/nic_mac/hikp_nic_xsfp.c +++ b/net/nic/nic_mac/hikp_nic_xsfp.c @@ -55,6 +55,108 @@ static struct sff_ext_comp g_sff_ext_spec_comp[] = { {0x4A, "50GBASE-ER"}, }; +static struct sff_host_media_id g_sff_host_ids[] = { + {0x0, "Undefined", 0x0, "Undefined"}, + {0x1, "1000BASE-CX", 0x1, "NRZ"}, + {0xC, "100GAUI-4 C2M", 0x4, "NRZ"}, + {0xD, "100GAUI-2 C2M", 0x2, "PAM4"}, + {0x4B, "100GAUI-1-S C2M", 0x1, "PAM4"}, + {0x4C, "100GAUI-1-L C2M", 0x1, "PAM4"}, + {0xE, "200GAUI-8 C2M", 0x8, "NRZ"}, + {0xF, "200GAUI-4 C2M", 0x4, "PAM4"}, + {0x4D, "200GAUI-2-S C2M", 0x2, "PAM4"}, + {0x4E, "200GAUI-2-L C2M", 0x2, "PAM4"}, + {0x11, "400GAUI-8 C2M", 0x8, "PAM4"}, + {0x4F, "400GAUI-4-S C2M", 0x4, "PAM4"}, + {0x50, "400GAUI-4-L C2M", 0x4, "PAM4"}, + {0x13, "10GBASE-CX4", 0x4, "NRZ"}, + {0x14, "25GBASE-CR CA-25G-L", 0x1, "NRZ"}, + {0x15, "25GBASE-CR or 25GBASE-CR-SCA-25G-S", 0x1, "NRZ"}, + {0x16, "25GBASE-CR or 25GBASE-CR-SCA-25G-N", 0x1, "NRZ"}, + {0x17, "40GBASE-CR4", 0x4, "NRZ"}, + {0x43, "50GBASE-CR2 with RS(528,514)FEC", 0x2, "NRZ"}, + {0x44, "50GBASE-CR2 with BASE-R, Fire code FEC", 0x2, "NRZ"}, + {0x45, "50GBASE-CR2 with no FEC", 0x2, "NRZ"}, + {0x18, "50GBASE-CR", 0x1, "PAM4"}, + {0x1A, "100GBASE-CR4", 0x4, "NRZ"}, + {0x1B, "100GBASE-CR2", 0x2, "PAM4"}, + {0x46, "100GBASE-CR1", 0x1, "PAM4"}, + {0x1C, "200GBASE-CR4", 0x4, "PAM4"}, + {0x47, "200GBASE-CR2", 0x2, "PAM4"}, + {0x1D, "400G CR8", 0x8, "PAM4"}, + {0x48, "400GBASE-CR4", 0x4, "PAM4"}, +}; + +static struct sff_host_media_id g_mmf_media_ids[] = { + {0x0, "Undefined", 0x0, "Undefined"}, + {0x2, "10GBASE-SR", 0x1, "NRZ"}, + {0x3, "25GBASE-SR", 0x1, "NRZ"}, + {0x4, "40GBASE-SR4", 0x4, "NRZ"}, + {0x5, "40GE SWDM4 MSA", 0x4, "NRZ"}, + {0x7, "50GBASE-SR", 0x1, "PAM4"}, + {0x9, "100GBASE-SR4", 0x4, "NRZ"}, + {0xA, "100GE SWDM4 MSA", 0x4, "NRZ"}, + {0xC, "100GBASE-SR2", 0x2, "PAM4"}, + {0xD, "100GBASE-SR1", 0x1, "PAM4"}, + {0x1D, "100GBASE-VR1", 0x1, "PAM4"}, + {0xE, "200GBASE-SR4", 0x4, "PAM4"}, + {0x1B, "200GBASE-SR2", 0x2, "PAM4"}, + {0x1E, "200GBASE-VR2", 0x2, "PAM4"}, + {0x10, "400GBASE-SR8", 0x8, "PAM4"}, + {0x11, "400GBASE-SR4", 0x4, "PAM4"}, + {0x1F, "400GBASE-VR4", 0x4, "PAM4"}, +}; + +static struct sff_host_media_id g_smf_media_ids[] = { + {0x0, "Undefined", 0x0, "Undefined"}, + {0x4, "10GBASE-LR", 0x1, "NRZ"}, + {0x5, "10GBASE-ER", 0x1, "NRZ"}, + {0x4E, "10GBASE-BR", 0x1, "NRZ"}, + {0x6, "10G-ZR", 0x1, "NRZ"}, + {0x7, "25GBASE-LR", 0x1, "NRZ"}, + {0x8, "25GBASE-ER", 0x1, "NRZ"}, + {0x4F, "25GBASE-BR", 0x1, "NRZ"}, + {0x9, "40GBASE-LR4", 0x4, "NRZ"}, + {0xB, "50GBASE-FR", 0x1, "PAM4"}, + {0xC, "50GBASE-LR", 0x1, "PAM4"}, + {0x40, "50GBASE-ER", 0x1, "PAM4"}, + {0x50, "50GBASE-BR", 0x1, "PAM4"}, + {0xD, "100GBASE-LR4", 0x4, "NRZ"}, + {0xE, "100GBASE-ER4", 0x4, "NRZ"}, + {0xF, "100G PSM4 MSA", 0x4, "NRZ"}, + {0x34, "100G CWDM4-OCP", 0x4, "NRZ"}, + {0x10, "100G CWDM4 MSA", 0x4, "NRZ"}, + {0x11, "100G 4WDM-10 MSA", 0x4, "NRZ"}, + {0x12, "100G 4WDM-20 MSA", 0x4, "NRZ"}, + {0x13, "100G 4WDM-40 MSA", 0x4, "NRZ"}, + {0x14, "100GBASE-DR", 0x1, "PAM4"}, + {0x17, "200GBASE-DR4", 0x4, "PAM4"}, + {0x18, "200GBASE-FR4", 0x4, "PAM4"}, + {0x19, "200GBASE-LR4", 0x4, "PAM4"}, + {0x41, "200GBASE-ER4", 0x4, "PAM4"}, + {0x1A, "400GBASE-FR8", 0x8, "PAM4"}, + {0x1B, "400GBASE-LR8", 0x8, "PAM4"}, + {0x42, "400GBASE-ER8", 0x8, "PAM4"}, + {0x1C, "400GBASE-DR4", 0x4, "PAM4"}, + {0x55, "400GBASE-DR4-2", 0x4, "PAM4"}, + {0x43, "400GBASE-LR4-6", 0x4, "PAM4"}, +}; + +static struct sff_media_cable_id g_passive_cable_ids[] = { + {0x0, "Undefined"}, + {0x1, "Copper cable"}, + {0xBF, "Passive Loopback module"}, +}; + +static struct sff_media_cable_id g_active_cable_ids[] = { + {0x0, "Undefined"}, + {0x1, "Active Cable assembly"}, + {0x2, "Active Cable assembly"}, + {0x3, "Active Cable assembly"}, + {0x4, "Active Cable assembly"}, + {0xBF, "Active Loopback module"}, +}; + static int hikp_xsfp_get_cmd_data(struct hikp_cmd_ret **cmd_resp, uint32_t sub_cmd, uint32_t blk_id) { struct hikp_xsfp_req req = {0}; @@ -320,6 +422,148 @@ static void hikp_show_qsfp_info(const uint8_t *data, uint32_t size) printf("--------------------------------------------------------------\n"); } +static void cmis_print_media_optical(const struct cmis_app_desc *desc, + struct sff_host_media_id *ids, size_t len) +{ + for (uint8_t i = 0; i < len; i++) { + if (desc->media_id == ids[i].id) { + printf("%s(%s)\n", ids[i].int_spec, ids[i].modulation); + return; + } + } + printf("0x%x\n", desc->media_id); +} + +static void cmis_print_media_cable(const struct cmis_app_desc *desc, + struct sff_media_cable_id *ids, size_t len) +{ + for (uint8_t i = 0; i < len; i++) { + if (desc->media_id == ids[i].id) { + printf("%s\n", ids[i].app_name); + return; + } + } + printf("0x%x\n", desc->media_id); +} + +static void cmis_print_host_int_spec(const struct cmis_app_desc *desc) +{ + size_t size = HIKP_ARRAY_SIZE(g_sff_host_ids); + + for (uint8_t i = 0; i < size; i++) { + if (desc->host_id == g_sff_host_ids[i].id) { + printf("%s(%s) | ", + g_sff_host_ids[i].int_spec, g_sff_host_ids[i].modulation); + return; + } + } + + printf("0x%x | ", desc->host_id); +} + +static void cmis_print_host_and_media_int(const struct cmis_page_info *info, uint8_t app_id) +{ + const struct cmis_app_desc *desc = &info->page0_lower.apps[app_id]; + uint8_t media_type = info->page0_lower.media_type; + + printf("%s %-9u: %s", "app_descriptor", app_id, "host and media int: "); + cmis_print_host_int_spec(desc); + + switch (media_type) { + case OPT_MMF: + cmis_print_media_optical(desc, g_mmf_media_ids, HIKP_ARRAY_SIZE(g_mmf_media_ids)); + break; + case OPT_SMF: + cmis_print_media_optical(desc, g_smf_media_ids, HIKP_ARRAY_SIZE(g_smf_media_ids)); + break; + case PASSIVE_COPPER: + cmis_print_media_cable(desc, g_passive_cable_ids, + HIKP_ARRAY_SIZE(g_passive_cable_ids)); + break; + case ACTIVE_CABLE: + cmis_print_media_cable(desc, g_active_cable_ids, + HIKP_ARRAY_SIZE(g_active_cable_ids)); + break; + default: + printf("0x%x\n", desc->media_id); + break; + } +} + +static void cmis_print_application_desc(const struct cmis_page_info *info) +{ + for (uint8_t i = 0; i < CMIS_LOW_MEM_APP_DESC_NUM; i++) { + /* Undefined or unused, not print */ + if ((info->page0_lower.apps[i].host_id == 0xFF) || + (!info->page0_lower.apps[i].host_id && !info->page0_lower.apps[i].media_id)) + continue; + + cmis_print_host_and_media_int(info, i); + } +} + +static void cmis_print_base_id_info(const struct cmis_page_info *info) +{ + /* page00h reg 202: bit6-7 */ + float cab_len_mul[] = {0.1f, 1.0f, 10.0f, 100.0f}; + /* page01h reg 132: bit6-7 */ + float smf_len_mul[] = {0.1f, 1.0f, 10.0f, 1.0f}; + const char *type[MEDIA_TYPE_RSVD] = { + "Undefined", "MMF Optical Interfaces", "SMF Optical Interfaces", + "Passive Copper Cables", "Active Cables", "BASE-T" + }; + + printf("%-24s: 0x%02x\n", "identifier", info->page0_lower.identifier); + printf("%-24s: 0x%02x\n", "connector", info->page0_upper.connector_type); + + if (info->page0_lower.media_type >= MEDIA_TYPE_RSVD) + printf("%-24s: 0x%02x\n", "media_type", info->page0_lower.media_type); + else + printf("%-24s: %s\n", "media_type", type[info->page0_lower.media_type]); + + printf("%-24s: %0.2f (m)\n", "cable_len", (float)info->page0_upper.cab_base_len * + cab_len_mul[info->page0_upper.len_multiplier]); + printf("%-24s: %0.2f (km)\n", "smf_len_km", + (float)info->page1.smf_len * smf_len_mul[info->page1.smf_len_multip]); + printf("%-24s: %u (m)\n", "om5_len", info->page1.om5_len * 0x2); + printf("%-24s: %u (m)\n", "om4_len", info->page1.om4_len * 0x2); + printf("%-24s: %u (m)\n", "om3_len", info->page1.om3_len * 0x2); + printf("%-24s: %u (m)\n", "om2_len", info->page1.om2_len); + printf("%-24s: %u (nm)\n", "wavelength", + (((uint16_t)info->page1.nominal_wave_len[0] << 8U) | + (uint16_t)info->page1.nominal_wave_len[1]) / CMIS_WAVE_LEN_DIV); + printf("%-24s: %u (nm)\n", "wavelength_tolerance", + (((uint16_t)info->page1.wave_len_tolerance[0] << 8U) | + (uint16_t)info->page1.wave_len_tolerance[1]) / CMIS_TOL_WAVE_LEN_DIV); + printf("%-24s: 0x%02x\n", "media_technology", info->page0_upper.media_int_tech); + xsfp_print_data("vendor_name", VEND_NAME_LEN, info->page0_upper.vend_name, PRINT_ASCII); + xsfp_print_data("vendor_oui", VEND_OUI_LEN, info->page0_upper.vend_oui, PRINT_HEX); + xsfp_print_data("vendor_pn", VEND_PN_LEN, info->page0_upper.vend_pn, PRINT_ASCII); + xsfp_print_data("vendor_rev", CMIS_VEND_REV_LEN, info->page0_upper.vend_rev, PRINT_ASCII); + xsfp_print_data("vendor_sn", VEND_SN_LEN, info->page0_upper.vend_sn, PRINT_ASCII); + xsfp_print_data("vendor_date_code", VEND_DATE_CODE_LEN, + info->page0_upper.date_code, PRINT_ASCII); + + cmis_print_application_desc(info); +} + +static void cmis_print_dom_info(const struct cmis_page_info *info) +{ + if (!info->page0_lower.mem_model && info->page1.temp_mon_supp) + printf("%-24s: %d.%02u\n", "temperature", (int8_t)info->page0_lower.module_temp[0], + info->page0_lower.module_temp[1]); +} + +static void hikp_show_cmis_info(const uint8_t *data, uint32_t size) +{ + struct cmis_page_info *cmis_data = (struct cmis_page_info *)data; + + printf("------------------------show cmis info------------------------\n"); + cmis_print_base_id_info(cmis_data); + cmis_print_dom_info(cmis_data); + printf("--------------------------------------------------------------\n"); +} + static void hikp_xsfp_parse_info(const uint8_t *data, uint32_t size) { if (data[SFF_ID_OFFSET] == ID_SFP) { @@ -328,6 +572,12 @@ static void hikp_xsfp_parse_info(const uint8_t *data, uint32_t size) data[SFF_ID_OFFSET] == ID_QSFP_PLUS || data[SFF_ID_OFFSET] == ID_QSFP28) { hikp_show_qsfp_info(data, size); + } else if (data[SFF_ID_OFFSET] == ID_QSFP_DD || + data[SFF_ID_OFFSET] == ID_SFP_DD || + data[SFF_ID_OFFSET] == ID_QSFP_P_CMIS || + data[SFF_ID_OFFSET] == ID_SFP_DD_CMIS || + data[SFF_ID_OFFSET] == ID_SFP_P_CMIS) { + hikp_show_cmis_info(data, size); } else { /* unknown type just dump hex data */ hikp_xsfp_dump_hex(data, size); diff --git a/net/nic/nic_mac/hikp_nic_xsfp.h b/net/nic/nic_mac/hikp_nic_xsfp.h index a3781972ab283ad4feb48f2acd0629c8c07d4eb6..6f5e38fc31b7a3f978afe51eadecc9b2577d362e 100644 --- a/net/nic/nic_mac/hikp_nic_xsfp.h +++ b/net/nic/nic_mac/hikp_nic_xsfp.h @@ -75,6 +75,11 @@ #define QSFP_10GBASE_LR_MASK HI_BIT(5) #define QSFP_10GBASE_LRM_MASK HI_BIT(6) +#define CMIS_WAVE_LEN_DIV 20 +#define CMIS_TOL_WAVE_LEN_DIV 200 + +#define CMIS_VEND_REV_LEN 2 + enum print_type { PRINT_ASCII = 0, PRINT_HEX, @@ -87,6 +92,11 @@ enum sff_id_val { ID_QSFP = 0x0C, ID_QSFP_PLUS = 0x0D, ID_QSFP28 = 0x11, + ID_QSFP_DD = 0x18, + ID_SFP_DD = 0x1A, + ID_QSFP_P_CMIS = 0x1E, + ID_SFP_DD_CMIS = 0x1F, + ID_SFP_P_CMIS = 0x20, }; struct sff_comp_info { @@ -99,6 +109,18 @@ struct sff_ext_comp { const char *module_cap; }; +struct sff_host_media_id { + uint8_t id; + const char *int_spec; + uint8_t lane_cnt; + const char *modulation; +}; + +struct sff_media_cable_id { + uint8_t id; + const char *app_name; +}; + struct sfp_a0_page { uint8_t identifier; /* reg 0: Identifier */ uint8_t ext_identifier; /* reg 1: Ext. Identifier */ @@ -358,6 +380,143 @@ struct qsfp_page0_info { struct qsfp_page0_upper page_upper; }; +enum cmis_media_type { + UNDEFINED = 0, + OPT_MMF, + OPT_SMF, + PASSIVE_COPPER, + ACTIVE_CABLE, + BASE_T, + MEDIA_TYPE_RSVD, +}; + +#define CMIS_LOW_MEM_APP_DESC_NUM 8 +struct cmis_app_desc { + uint8_t host_id; /* host electrical interface id */ + uint8_t media_id; /* module media electrical interface id */ + uint8_t media_lane_cnt : 4, + host_lane_cnt : 4; /* host and media lane counts */ + uint8_t host_assign; /* Host Lane Assignment Options */ +}; + +struct cmis_page0_lower { + uint8_t identifier; /* reg 0: Identifier */ + uint8_t rev_compliance; /* reg 1: CMIS revision */ + /* reg 2: Module Management Characteristics */ + uint8_t rsv0 : 2, + mci_max_speed : 2, + rsv1 : 2, + step_cfg_only : 1, + mem_model : 1; + /* reg 3: Global Status Information */ + uint8_t intr_deasserted : 1, + module_state : 3, + rsv2 : 4; + uint8_t flags_sum[4]; /* reg 4-7: Lane-Level Flags Summary */ + uint8_t module_flags[6]; /* reg 8-13: Module-Level Flags */ + uint8_t module_temp[2]; /* reg 14-15: TempMonValue */ + uint8_t module_vcc[2]; /* reg 16-17: VccMonVoltage */ + uint8_t module_mon_val[8]; /* reg 18-25: Module-Level Mon Value */ + /* reg 26: Module Global Controls */ + uint8_t rsv3 : 3, + sw_reset : 1, + lowpwr_req_sw : 1, + squ_method_sel : 1, + lowpwr_allow_req_hw : 1, + bank_bc_enable : 1; + uint8_t rsv4[14]; /* reg 27-40: */ + uint8_t module_fault; /* reg 41: Module Fault Information */ + uint8_t rsv5[22]; /* reg 42-63: Reserved */ + uint8_t custom[21]; /* reg 64-84: Custom */ + uint8_t media_type; /* reg 85: Media Type Encodings */ + /* reg 86-117: Application Descriptor */ + struct cmis_app_desc apps[CMIS_LOW_MEM_APP_DESC_NUM]; + uint8_t pwd_area[8]; /* reg 118-125: Password Facilities */ + uint8_t bank_sel; /* reg 126: Bank Index of Page mapped to Upper Memory */ + uint8_t page_sel; /* reg 127: Page Index of Page mapped to Upper Memory */ +}; + +struct cmis_page0_upper { + uint8_t identifier_cp; /* reg 128: The Same Byte 00h:0 */ + uint8_t vend_name[16]; /* reg 129-144: Vendor name (ASCII) */ + uint8_t vend_oui[3]; /* reg 145-147: Vendor IEEE company ID */ + uint8_t vend_pn[16]; /* reg 148-163: Part number provided by vendor (ASCII) */ + /* reg 164-165: Revision level for part number provided by vendor (ASCII) */ + uint8_t vend_rev[2]; + uint8_t vend_sn[16]; /* reg 166-181: Vendor Serial Number (ASCII) */ + uint8_t date_code[8]; /* reg 182-189: Manufacturing Date Code (ASCII) */ + /* reg 190-199: Common Language Equipment Identification Code (ASCII) */ + uint8_t clei_code[10]; + uint8_t module_pwr_class; /* reg 200: Module Power Class */ + /* reg 201: Maximum power consumption in multiples of 0.25 W + * rounded up to the next whole multiple of 0.25 W + */ + uint8_t max_power; + /* reg 202: Cable Assembly Link Length */ + uint8_t cab_base_len : 6, + len_multiplier : 2; + uint8_t connector_type; /* reg 203: Media Connector Type */ + uint8_t copp_attenuation[6]; /* reg 204-209: Copper Cable Attenuation */ + uint8_t media_lanes; /* reg 210: Media Lane Information */ + uint8_t cable_assembly_lane; /* reg 211: Cable Assembly Lane Information */ + uint8_t media_int_tech; /* reg 212: Media Interface Technology */ + uint8_t rsv0[8]; /* reg 213-220: Reserved */ + uint8_t rsv1; /* reg 221: Custom1 */ + uint8_t page_check_sum; /* reg 222: Page Checksum over bytes 128-221 */ + uint8_t rsv[33]; /* reg 223-255: Custom Info (non-volatile) */ +}; + +struct cmis_page1_info { + uint8_t inac_fw_hw_ver[4]; /* reg 128-131: Inactive FW revision and HW revision */ + uint8_t smf_len : 6, /* reg 132: Base link length for SMF fiber in km */ + smf_len_multip : 2; /* Link length multiplier for SMF fiber */ + uint8_t om5_len; /* reg 133: Link length supported for OM5 fiber */ + uint8_t om4_len; /* reg 134: Link length supported for OM4 fiber */ + uint8_t om3_len; /* reg 135: Link length supported for EBW 50/125 µm fiber (OM3) */ + uint8_t om2_len; /* reg 136: Link length supported for 50/125 µm fiber (OM2) */ + uint8_t rsv0; /* reg 137: Reserved */ + uint8_t nominal_wave_len[2]; /* reg 138-139: NominalWavelength */ + uint8_t wave_len_tolerance[2]; /* reg 140-141: WavelengthTolerance */ + uint8_t pages_support; /* reg 142: Supported Pages Advertising */ + uint8_t duration_adv[2]; /* reg 143-144: Durations Advertising */ + uint8_t module_char[10]; /* reg 145-154: Module Characteristics Advertising */ + uint8_t contrl_support[2]; /* reg 155-156: Supported Controls Advertisement */ + uint8_t flags_support[2]; /* reg 157-158: Supported Flags Advertisement */ + /* reg 159: Supported Mon Advertisement */ + uint8_t temp_mon_supp : 1, + vcc_mon_supp : 1, + aux1_mon_supp : 1, + aux2_mon_supp : 1, + aux3_mon_supp : 1, + custom_mon_supp : 1, + rsv1 : 2; + /* reg 160: Supported Power Mon Advertisement */ + uint8_t txbias_mon_supp : 1, + tx_pwr_mon_supp : 1, + rx_pwr_mon_supp : 1, + txbias_curr_scal : 2, + rsv2 : 3; + /* reg 161-162: Supported Configuration and Signal Integrity Controls Advertisement */ + uint8_t sig_intr_support[2]; + uint8_t cdb_func_support[4]; /* reg 163-166: CDB Messaging Support Advertisement */ + uint8_t add_dura_adv[3]; /* reg 167-169: Additional Durations Advertising */ + uint8_t rsv3[7]; /* reg 170-175: Reserved */ + uint8_t media_lane_adv[15]; /* reg 176-190: Media Lane Assignment Advertising */ + uint8_t custom[32]; /* reg 191-222: Custom */ + uint8_t add_app_desc[28]; /* reg 223-250: Additional Application Descriptor Registers */ + uint8_t rsv4[4]; /* reg 251-254: Reserved */ + uint8_t page_check_sum; /* reg 255: Page Checksum */ +}; + +/* Current support max 640 bytes data */ +struct cmis_page_info { + struct cmis_page0_lower page0_lower; + struct cmis_page0_upper page0_upper; + struct cmis_page1_info page1; + uint8_t page2_data[128]; + uint8_t page3_data[128]; +}; + #define XSFP_TARGET_BIT HI_BIT(0) #define XSFP_RAW_DATA_BIT HI_BIT(1) diff --git a/net/roh/hikp_roh_show_mib.c b/net/roh/hikp_roh_show_mib.c index 425a0e63c5f4c439715451925be4d660d952ee50..7267fe517cbb6dc8b154f68860944c6591841d4c 100644 --- a/net/roh/hikp_roh_show_mib.c +++ b/net/roh/hikp_roh_show_mib.c @@ -232,6 +232,7 @@ static void hikp_roh_show_mib_in_multi_rounds(struct major_cmd_ctrl *self) return; } + printf("**************ROH MAC MIB INFO*************\n"); for (int i = 0; i < total_round; i++) { ret = hikp_roh_fill_pmu_cnt(i); if (ret != 0) { @@ -239,6 +240,7 @@ static void hikp_roh_show_mib_in_multi_rounds(struct major_cmd_ctrl *self) return; } } + printf("*****************************************\n"); } static void hikp_roh_show_mib_execute(struct major_cmd_ctrl *self) diff --git a/pcie/func_lib/pcie_func/pcie_statistics.c b/pcie/func_lib/pcie_func/pcie_statistics.c index ed42cec36a2debb77233b940d3bb8e531c5fb199..badf3d1608f647696962a4377138252d0bd0ed0d 100644 --- a/pcie/func_lib/pcie_func/pcie_statistics.c +++ b/pcie/func_lib/pcie_func/pcie_statistics.c @@ -26,7 +26,7 @@ static const char *g_global_width_name[GLOBAL_WIDTH_TABLE_SIZE] = { }; static const char *g_global_ndie_name[] = { - "Ndie_A", "Ndie_B" + "Ndie_A", "Ndie_B", "Ndie_C", "Ndie_D" }; static int port_distribution_rsp_data_check(const struct hikp_cmd_ret *cmd_ret, uint32_t *port_num) diff --git a/tool_lib/op_logs.c b/tool_lib/op_logs.c index f57f5fd62dfd79fb2ba82c025eb4f2dfc87c0a26..9fb91d892519f94928d9a0c46f9bc67106f75326 100644 --- a/tool_lib/op_logs.c +++ b/tool_lib/op_logs.c @@ -283,7 +283,7 @@ void op_log_record_input(const int argc, const char **argv) arg = input_str; for (i = 0; i < argc; i++) { ret = snprintf(arg, (sizeof(input_str) - (arg - input_str)), "%s ", argv[i]); - if (ret < 0 || ret >= (sizeof(input_str) - (arg - input_str))) + if (ret < 0 || ret >= (int)(sizeof(input_str) - (arg - input_str))) return; arg = arg + strlen(argv[i]) + 1; diff --git a/tool_lib/tool_lib.c b/tool_lib/tool_lib.c index 180418f160ebe0e9391a486eff052798d0b91a69..5c1a02dd6abb1c5397c39d1be317f575f1e3e38b 100644 --- a/tool_lib/tool_lib.c +++ b/tool_lib/tool_lib.c @@ -281,9 +281,9 @@ static int get_rand_str(char *str, int length) [TYPE_LOWERCASE] = {'a', 26}, }; uint32_t r[RANDOM_NUM]; + uint32_t type; int fd, size; int i, j; - int type; fd = open("/dev/urandom", O_RDONLY); if (fd < 0) { @@ -325,7 +325,7 @@ int generate_file_name(unsigned char *file_name, ret = snprintf((char *)file_name, file_name_len, "%s_%d_%d_%d_%d_%d_%d_%s.log", prefix, timeinfo.tm_year + START_YEAR, timeinfo.tm_mon + 1, timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec, str_r); - if (ret < 0 || ret >= file_name_len) { + if (ret < 0 || (uint32_t)ret >= file_name_len) { HIKP_ERROR_PRINT("generate file name failed, errno is %d\n", errno); return -errno; } diff --git a/tool_lib/tool_lib.h b/tool_lib/tool_lib.h index 14b3db5267e4610babacab847edf293bb8cfa829..72a99c68083e37c6e1ad893c97591f5c89562c8e 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.1.0" +#define TOOL_VER "1.1.1" #define HI_GET_BITFIELD(value, start, mask) (((value) >> (start)) & (mask)) #define HI_SET_FIELD(origin, shift, val) ((origin) |= (val) << (shift))