diff options
author | Michal Kubecek <mkubecek@suse.cz> | 2021-10-11 12:37:03 +0200 |
---|---|---|
committer | Michal Kubecek <mkubecek@suse.cz> | 2021-10-11 12:37:03 +0200 |
commit | 88892ece6357ddb74fe52a3209c11b9867d4f7b1 (patch) | |
tree | 7616a3733dceeb4aa0b7609928a951dd7bd7d44c | |
parent | d007b49930d8243183160794001256ddd9037fee (diff) | |
parent | 79cb4ab4787b078fc647291eac6d681f98512a7c (diff) | |
download | ethtool-88892ece6357ddb74fe52a3209c11b9867d4f7b1.tar.gz |
Merge branch 'review/module-fixes-2-v2'
Ido Schimmel:
This patchset contains small patches for various issues I noticed while
working on the module EEPROM parsing code.
v2:
* Patch #1: Do not assume the CLEI code is NULL terminated
-rw-r--r-- | cmis.c | 12 | ||||
-rw-r--r-- | cmis.h | 6 | ||||
-rw-r--r-- | qsfp.c | 18 |
3 files changed, 19 insertions, 17 deletions
@@ -1,7 +1,7 @@ /** * Description: * - * This module adds QSFP-DD support to ethtool. The changes are similar to + * This module adds CMIS support to ethtool. The changes are similar to * the ones already existing in qsfp.c, but customized to use the memory * addresses and logic as defined in the specification's document. * @@ -271,7 +271,7 @@ static void cmis_show_mod_lvl_monitors(const __u8 *id) PRINT_TEMP("Module temperature", OFFSET_TO_TEMP(CMIS_CURR_TEMP_OFFSET)); PRINT_VCC("Module voltage", - OFFSET_TO_U16(CMIS_CURR_CURR_OFFSET)); + OFFSET_TO_U16(CMIS_CURR_VCC_OFFSET)); } static void cmis_show_link_len_from_page(const __u8 *page_one_data) @@ -307,6 +307,8 @@ static void cmis_show_link_len(const __u8 *id) */ static void cmis_show_vendor_info(const __u8 *id) { + const char *clei = (const char *)(id + CMIS_CLEI_START_OFFSET); + sff_show_ascii(id, CMIS_VENDOR_NAME_START_OFFSET, CMIS_VENDOR_NAME_END_OFFSET, "Vendor name"); cmis_show_oui(id); @@ -319,9 +321,9 @@ static void cmis_show_vendor_info(const __u8 *id) sff_show_ascii(id, CMIS_DATE_YEAR_OFFSET, CMIS_DATE_VENDOR_LOT_OFFSET + 1, "Date code"); - if (id[CMIS_CLEI_PRESENT_BYTE] & CMIS_CLEI_PRESENT_MASK) - sff_show_ascii(id, CMIS_CLEI_START_OFFSET, - CMIS_CLEI_END_OFFSET, "CLEI code"); + if (*clei && strncmp(clei, CMIS_CLEI_BLANK, CMIS_CLEI_LEN)) + sff_show_ascii(id, CMIS_CLEI_START_OFFSET, CMIS_CLEI_END_OFFSET, + "CLEI code"); } void qsfp_dd_show_all(const __u8 *id) @@ -11,7 +11,7 @@ /* Module-Level Monitors (Page 0) */ #define CMIS_CURR_TEMP_OFFSET 0x0E -#define CMIS_CURR_CURR_OFFSET 0x10 +#define CMIS_CURR_VCC_OFFSET 0x10 #define CMIS_CTOR_OFFSET 0xCB @@ -34,10 +34,10 @@ #define CMIS_DATE_VENDOR_LOT_OFFSET 0xBC /* CLEI Code (Page 0) */ -#define CMIS_CLEI_PRESENT_BYTE 0x02 -#define CMIS_CLEI_PRESENT_MASK 0x20 #define CMIS_CLEI_START_OFFSET 0xBE #define CMIS_CLEI_END_OFFSET 0xC7 +#define CMIS_CLEI_BLANK " " +#define CMIS_CLEI_LEN 0x0A /* Cable assembly length */ #define CMIS_CBL_ASM_LEN_OFFSET 0xCA @@ -64,7 +64,7 @@ static struct sff8636_aw_flags { const char *str; /* Human-readable string, null at the end */ - int offset; /* A2-relative address offset */ + int offset; __u8 value; /* Alarm is on if (offset & value) != 0. */ } sff8636_aw_flags[] = { { "Laser bias current high alarm (Chan 1)", @@ -738,7 +738,6 @@ static void sff8636_dom_parse(const __u8 *id, const __u8 *page_three, struct sff sd->scd[i].rx_power = OFFSET_TO_U16(rx_power_offset); sd->scd[i].tx_power = OFFSET_TO_U16(tx_power_offset); } - } static void sff8636_show_dom(const __u8 *id, const __u8 *page_three, __u32 eeprom_len) @@ -819,8 +818,7 @@ static void sff8636_show_dom(const __u8 *id, const __u8 *page_three, __u32 eepro } } - -static void sff6836_show_page_zero(const __u8 *id) +static void sff8636_show_page_zero(const __u8 *id) { sff8636_show_ext_identifier(id); sff8636_show_connector(id); @@ -863,11 +861,13 @@ void sff8636_show_all(const __u8 *id, __u32 eeprom_len) } sff8636_show_identifier(id); - if ((id[SFF8636_ID_OFFSET] == SFF8024_ID_QSFP) || - (id[SFF8636_ID_OFFSET] == SFF8024_ID_QSFP_PLUS) || - (id[SFF8636_ID_OFFSET] == SFF8024_ID_QSFP28)) { - sff6836_show_page_zero(id); + switch (id[SFF8636_ID_OFFSET]) { + case SFF8024_ID_QSFP: + case SFF8024_ID_QSFP_PLUS: + case SFF8024_ID_QSFP28: + sff8636_show_page_zero(id); sff8636_show_dom(id, id + 3 * 0x80, eeprom_len); + break; } } @@ -875,7 +875,7 @@ void sff8636_show_all_paged(const struct ethtool_module_eeprom *page_zero, const struct ethtool_module_eeprom *page_three) { sff8636_show_identifier(page_zero->data); - sff6836_show_page_zero(page_zero->data); + sff8636_show_page_zero(page_zero->data); if (page_three) sff8636_show_dom(page_zero->data, page_three->data - 0x80, ETH_MODULE_SFF_8636_MAX_LEN); |