Add JSON output to --module-info
Subsystems (3)
v4 cover Add JSON output to --module-info
Add JSON output for 'ethtool -m' / --module-info, following the guideline below:
1. Fields with description, will have a separate description field.
2. Units will be documented in a separate module-info.json file.
3. ASCII fields will be presented as strings.
4. On/Off is rendered as true/false.
5. Yes/no is rendered as true/false.
6. Per-channel fields will be presented as array, when each element represents a channel.
7. Fields that hold version, will be split to major and minor sub fields.
This patchset suppose to extend [1] to cover all types of modules.
Patchset overview:
Patches #1-#7: Preparations.
Patches #8-#9: Add JSON output support for CMIS compliant modules. Patches #10-#11: Add JSON output support for SFF8636 modules. Patches #12-#14: Add JSON output support for SFF8079 and SFF8472 modules. Patch #15: Add a new schema JSON file for units documentation. Patches #16: Add '-j' support to ethtool
[1] https://lore.kernel.org/all/[email protected]/
v4:
Patch #10:
* In extended_identifier field, use an array for all descriptions instead of 3 different descriptions.
* Remove duplicated definition of YESNO() and ONOFF()
* defines.
v3:
* Remove unit fields from JSON output.
* Reword commit messages.
* Add patch #2 and #15.
* Enable properly JSON output support for SFF8079.
* Remove printings from fields that might be empty strings.
* Fix JSON output in sff8636_show_dom_mod_lvl_flags().
v2:
* In rx_power JSON field, add a type field to let the user know what type is printed in "value".
* Use uint instead of hexa fields in JSON context.
* Simplify sff8636_show_dom().
* Use "false" in module_show_lane_status() instead of "None" in JSON context.
module_common: Add a new file to all the common code for all module
types
ethtool: Standardize Link Length field names across module types
sff_common: Move sff_show_revision_compliance() to qsfp.c
cmis: Change loop order in cmis_show_dom_chan_lvl_flags()
qsfp: Reorder the channel-level flags list for SFF8636 module type
qsfp: Refactor sff8636_show_dom() by moving code into separate
functions
module_common: Add helpers to support JSON printing for common value
types
cmis: Add JSON output handling to --module-info in CMIS modules
cmis: Enable JSON output support in CMIS modules
qsfp: Add JSON output handling to --module-info in SFF8636 modules
qsfp: Enable JSON output support for SFF8636 modules
sfpid: Add JSON output handling to --module-info in SFF8079 modules
sfpdiag: Add JSON output handling to --module-info in SFF8472 modules
ethtool: Enable JSON output support for SFF8079 and SFF8472 modules
module_info: Add a new JSON file for units documentation
ethtool: Add '-j' support to ethtool
Makefile.am | 7 +- cmis.c | 493 +++++++++++----------- cmis.h | 65 --- ethtool.c | 10 +- module-common.c | 662 +++++++++++++++++++++++++++++ module-common.h | 287 +++++++++++++ module_info.json | 191 +++++++++ netlink/module-eeprom.c | 26 +- qsfp.c | 894 +++++++++++++++++++++------------------- qsfp.h | 108 ----- sff-common.c | 348 ++++------------ sff-common.h | 119 ++---- sfpdiag.c | 52 ++- sfpid.c | 446 +++++++++++--------- 14 files changed, 2250 insertions(+), 1458 deletions(-) create mode 100644 module-common.c create mode 100644 module-common.h create mode 100644 module_info.json
Signature · 1 line
2.47.0
PATCH v4 1/16 module_common: Add a new file to all the common code for all module types
Currently, a significant amount of repetitive code exists across different module type files.
Consolidate shared functions and definitions into a single, dedicated file to improve organization and maintainability.
--- Makefile.am | 7 +- cmis.c | 212 ++++------------- cmis.h | 65 ------ module-common.c | 506 ++++++++++++++++++++++++++++++++++++++++ module-common.h | 281 ++++++++++++++++++++++ netlink/module-eeprom.c | 26 +-- qsfp.c | 301 +++++------------------- qsfp.h | 108 --------- sff-common.c | 227 ------------------ sff-common.h | 77 ------ sfpdiag.c | 5 +- sfpid.c | 62 ++--- 12 files changed, 923 insertions(+), 954 deletions(-) create mode 100644 module-common.c create mode 100644 module-common.h
Makefile.am +4 -3
@@ -21,9 +21,10 @@ ethtool_SOURCES += \ fec.c fec_8xx.c fsl_enetc.c ibm_emac.c ixgb.c ixgbe.c \ natsemi.c pcnet32.c realtek.c tg3.c marvell.c vioc.c \ smsc911x.c at76c50x-usb.c sfc.c stmmac.c \ - sff-common.c sff-common.h sfpid.c sfpdiag.c \ - ixgbevf.c tse.c vmxnet3.c qsfp.c qsfp.h fjes.c lan78xx.c \ - igc.c cmis.c cmis.h bnxt.c cpsw.c lan743x.c hns3.c + sff-common.c sff-common.h module-common.c module-common.h \ + sfpid.c sfpdiag.c ixgbevf.c tse.c vmxnet3.c qsfp.c qsfp.h \ + fjes.c lan78xx.c igc.c cmis.c cmis.h bnxt.c cpsw.c lan743x.c \ + hns3.c endif if ENABLE_BASH_COMPLETION
cmis.c +39 -173
293 lines not on this page · raw message
cmis.h +0 -65
89 lines not on this page · raw message
module-common.c new file +506 -0
506 lines not on this page · raw message
module-common.h new file +281 -0
281 lines not on this page · raw message
netlink/module-eeprom.c +13 -13
@@ -9,7 +9,7 @@#include <stdio.h> #include <stddef.h> -#include "../sff-common.h" +#include "../module-common.h" #include "../qsfp.h" #include "../cmis.h" #include "../internal.h"
@@ -225,20 +225,20 @@ static int eeprom_parse(struct cmd_context *ctx)switch (request.data[0 ]) {#ifdef ETHTOOL_ENABLE_PRETTY_DUMP -case SFF8024_ID_GBIC : -case SFF8024_ID_SOLDERED_MODULE : -case SFF8024_ID_SFP : +case MODULE_ID_GBIC : +case MODULE_ID_SOLDERED_MODULE : +case MODULE_ID_SFP :return sff8079_show_all_nl (ctx); -case SFF8024_ID_QSFP : -case SFF8024_ID_QSFP28 : -case SFF8024_ID_QSFP_PLUS : +case MODULE_ID_QSFP : +case MODULE_ID_QSFP28 : +case MODULE_ID_QSFP_PLUS :return sff8636_show_all_nl (ctx); -case SFF8024_ID_QSFP_DD : -case SFF8024_ID_OSFP : -case SFF8024_ID_DSFP : -case SFF8024_ID_QSFP_PLUS_CMIS : -case SFF8024_ID_SFP_DD_CMIS : -case SFF8024_ID_SFP_PLUS_CMIS : +case MODULE_ID_QSFP_DD : +case MODULE_ID_OSFP : +case MODULE_ID_DSFP : +case MODULE_ID_QSFP_PLUS_CMIS : +case MODULE_ID_SFP_DD_CMIS : +case MODULE_ID_SFP_PLUS_CMIS :return cmis_show_all_nl (ctx);#endif default :
qsfp.c +63 -238
380 lines not on this page · raw message
qsfp.h +0 -108
120 lines not on this page · raw message
sff-common.c +0 -227
233 lines not on this page · raw message
sff-common.h +0 -77
91 lines not on this page · raw message
sfpdiag.c +2 -3
@@ -12,7 +12,7 @@#include <math.h> #include <arpa/inet.h> #include "internal.h" -#include "sff-common.h" +#include "module-common.h" /* Offsets in decimal, for direct comparison with the SFF specs */
@@ -263,8 +263,7 @@ void sff8472_show_all(const __u8 *id)PRINT_xX_PWR (rx_power_string, sd.rx_power[MCURR ]); -PRINT_TEMP ("Module temperature" , sd.sfp_temp[MCURR ]); -PRINT_VCC ("Module voltage" , sd.sfp_voltage[MCURR ]); +module_show_dom_mod_lvl_monitors (&sd);printf ("\t%-41s : %s\n" ,"Alarm/warning flags implemented" , (sd.supports_alarms ?"Yes" :"No" ));
sfpid.c +15 -47
102 lines not on this page · raw message
Signature · 1 line
2.47.0
PATCH v4 2/16 ethtool: Standardize Link Length field names across module types
In reply to Danielle RatsonThe 'Link Length' fields have inconsistent naming across different module types.
To ensure consistency, especially with the upcoming JSON support for the EEPROM dump, these field names should be aligned.
Standardize the Link Length fields across all module types.
---
Notes:
v3:
* New patch.
cmis.c | 4 ++-- qsfp.c | 8 ++++---- sfpid.c | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-)
cmis.c +2 -2
@@ -282,9 +282,9 @@ static void cmis_show_link_len(const struct cmis_memory_map *map)module_show_value_with_unit (map->page_01h,CMIS_OM4_LEN_OFFSET ,"Length (OM4)" ,2 ,"m" );module_show_value_with_unit (map->page_01h,CMIS_OM3_LEN_OFFSET , -"Length (OM3 50/125um)" ,2 ,"m" ); +"Length (OM3)" ,2 ,"m" );module_show_value_with_unit (map->page_01h,CMIS_OM2_LEN_OFFSET , -"Length (OM2 50/125um)" ,1 ,"m" ); +"Length (OM2)" ,1 ,"m" ); }/**
qsfp.c +4 -4
@@ -736,13 +736,13 @@ static void sff8636_show_page_zero(const struct sff8636_memory_map *map) "BR, Nominal", 100, "Mbps");sff8636_show_rate_identifier (map);module_show_value_with_unit (map->page_00h,SFF8636_SM_LEN_OFFSET , -"Length (SMF,km)" ,1 ,"km" ); +"Length (SMF)" ,1 ,"km" );module_show_value_with_unit (map->page_00h,SFF8636_OM3_LEN_OFFSET , -"Length (OM3 50um)" ,2 ,"m" ); +"Length (OM3)" ,2 ,"m" );module_show_value_with_unit (map->page_00h,SFF8636_OM2_LEN_OFFSET , -"Length (OM2 50um)" ,1 ,"m" ); +"Length (OM2)" ,1 ,"m" );module_show_value_with_unit (map->page_00h,SFF8636_OM1_LEN_OFFSET , -"Length (OM1 62.5um)" ,1 ,"m" ); +"Length (OM1)" ,1 ,"m" );module_show_value_with_unit (map->page_00h,SFF8636_CBL_LEN_OFFSET ,"Length (Copper or Active cable)" ,1 ,"m" );sff8636_show_wavelength_or_copper_compliance (map);
sfpid.c +6 -5
@@ -395,11 +395,12 @@ static void sff8079_show_all_common(const __u8 *id)sff8079_show_encoding (id);printf ("\t%-41s : %u%s\n" ,"BR, Nominal" , br_nom,"MBd" );sff8079_show_rate_identifier (id); -module_show_value_with_unit (id,14 ,"Length (SMF,km)" ,1 ,"km" ); -module_show_value_with_unit (id,15 ,"Length (SMF)" ,100 ,"m" ); -module_show_value_with_unit (id,16 ,"Length (50um)" ,10 ,"m" ); -module_show_value_with_unit (id,17 ,"Length (62.5um)" ,10 ,"m" ); -module_show_value_with_unit (id,18 ,"Length (Copper)" ,1 ,"m" ); +module_show_value_with_unit (id,14 ,"Length (SMF)" ,1 ,"km" ); +module_show_value_with_unit (id,16 ,"Length (OM2)" ,10 ,"m" ); +module_show_value_with_unit (id,17 ,"Length (OM1)" ,10 ,"m" ); +module_show_value_with_unit (id,18 , +"Length (Copper or Active cable)" , +1 ,"m" );module_show_value_with_unit (id,19 ,"Length (OM3)" ,10 ,"m" );sff8079_show_wavelength_or_copper_compliance (id);module_show_ascii (id,20 ,35 ,"Vendor name" );
Signature · 1 line
2.47.0
PATCH v4 3/16 sff_common: Move sff_show_revision_compliance() to qsfp.c
In reply to Danielle RatsonThe only use of the function sff_show_revision_compliance() is in qsfp.c file.
Therefore, it doesn't belong to sff_common.c file but it can simply be a static function in qsfp.c.
Move sff_show_revision_compliance() function to qsfp.c.
--- qsfp.c | 40 ++++++++++++++++++++++++++++++++++++++-- sff-common.c | 36 ------------------------------------ sff-common.h | 1 - 3 files changed, 38 insertions(+), 39 deletions(-)
qsfp.c +38 -2
@@ -514,6 +514,42 @@ sff8636_show_wavelength_or_copper_compliance(const struct sff8636_memory_map *ma } } +static void sff8636_show_revision_compliance (const __u8 *id,int rev_offset) +{ +static const char *pfx = +"\tRevision Compliance :" ; + +switch (id[rev_offset]) { +case SFF8636_REV_UNSPECIFIED : +printf ("%s Revision not specified\n" , pfx); +break ; +case SFF8636_REV_8436_48 : +printf ("%s SFF-8436 Rev 4.8 or earlier\n" , pfx); +break ; +case SFF8636_REV_8436_8636 : +printf ("%s SFF-8436 Rev 4.8 or earlier\n" , pfx); +break ; +case SFF8636_REV_8636_13 : +printf ("%s SFF-8636 Rev 1.3 or earlier\n" , pfx); +break ; +case SFF8636_REV_8636_14 : +printf ("%s SFF-8636 Rev 1.4\n" , pfx); +break ; +case SFF8636_REV_8636_15 : +printf ("%s SFF-8636 Rev 1.5\n" , pfx); +break ; +case SFF8636_REV_8636_20 : +printf ("%s SFF-8636 Rev 2.0\n" , pfx); +break ; +case SFF8636_REV_8636_27 : +printf ("%s SFF-8636 Rev 2.5/2.6/2.7\n" , pfx); +break ; +default : +printf ("%s Unallocated\n" , pfx); +break ; + } +} +/* * 2-byte internal temperature conversions: * First byte is a signed 8-bit integer, which is the temp decimal part
@@ -757,8 +793,8 @@ static void sff8636_show_page_zero(const struct sff8636_memory_map *map) SFF8636_VENDOR_SN_END_OFFSET, "Vendor SN");module_show_ascii (map->page_00h,SFF8636_DATE_YEAR_OFFSET ,SFF8636_DATE_VENDOR_LOT_OFFSET +1 ,"Date code" ); -sff_show_revision_compliance (map->lower_memory, -SFF8636_REV_COMPLIANCE_OFFSET ); +sff8636_show_revision_compliance (map->lower_memory, +SFF8636_REV_COMPLIANCE_OFFSET );sff8636_show_signals (map); }
sff-common.c +0 -36
@@ -122,39 +122,3 @@ void sff_show_thresholds(struct sff_diags sd)PRINT_xX_PWR ("Laser rx power low warning threshold" , sd.rx_power[LWARN ]); } - -void sff_show_revision_compliance (const __u8 *id,int rev_offset) -{ -static const char *pfx = -"\tRevision Compliance :" ; - -switch (id[rev_offset]) { -case SFF8636_REV_UNSPECIFIED : -printf ("%s Revision not specified\n" , pfx); -break ; -case SFF8636_REV_8436_48 : -printf ("%s SFF-8436 Rev 4.8 or earlier\n" , pfx); -break ; -case SFF8636_REV_8436_8636 : -printf ("%s SFF-8436 Rev 4.8 or earlier\n" , pfx); -break ; -case SFF8636_REV_8636_13 : -printf ("%s SFF-8636 Rev 1.3 or earlier\n" , pfx); -break ; -case SFF8636_REV_8636_14 : -printf ("%s SFF-8636 Rev 1.4\n" , pfx); -break ; -case SFF8636_REV_8636_15 : -printf ("%s SFF-8636 Rev 1.5\n" , pfx); -break ; -case SFF8636_REV_8636_20 : -printf ("%s SFF-8636 Rev 2.0\n" , pfx); -break ; -case SFF8636_REV_8636_27 : -printf ("%s SFF-8636 Rev 2.5/2.6/2.7\n" , pfx); -break ; -default : -printf ("%s Unallocated\n" , pfx); -break ; - } -}
sff-common.h +0 -1
@@ -132,6 +132,5 @@ double convert_mw_to_dbm(double mw);void sff_show_thresholds (struct sff_diags sd);void sff8024_show_encoding (const __u8 *id,int encoding_offset,int sff_type); -void sff_show_revision_compliance (const __u8 *id,int rev_offset);#endif /* SFF_COMMON_H__ */
Signature · 1 line
2.47.0
PATCH v4 4/16 cmis: Change loop order in cmis_show_dom_chan_lvl_flags()
In reply to Danielle RatsonCurrently, when printing channel-level flags in ethtool dump, we are going over the banks, and for each bank, we are printing all the flags.
When JSON support will be added, in per-channel fields we would like to have an array that each of its elements represents a channel.
Therefore, change the loop order so first we loop over the flags, and for each one, we print all its channels.
--- cmis.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
cmis.c +12 -13
@@ -683,22 +683,19 @@ static void cmis_show_dom_mod_lvl_flags(const struct cmis_memory_map *map)* [1] CMIS Rev. 5, page 162, section 8.9.3, Table 8-77 * [1] CMIS Rev. 5, page 164, section 8.9.3, Table 8-78 */ -static void cmis_show_dom_chan_lvl_flags_chan (const struct cmis_memory_map *map, -int bank,int chan) +static void cmis_show_dom_chan_lvl_flag (const struct cmis_memory_map *map, +int bank,int flag) {const __u8 *page_11h = map->upper_memory[bank][0x11 ];int i; -for (i =0 ; module_aw_chan_flags[i].fmt_str; i++) { +for (i =0 ; i <CMIS_CHANNELS_PER_BANK ; i++) { +int chan = bank *CMIS_CHANNELS_PER_BANK + i;char str[80 ]; -if (!(map->page_01h[module_aw_chan_flags[i].adver_offset] & - module_aw_chan_flags[i].adver_value)) -continue ; - -snprintf (str,80 , module_aw_chan_flags[i].fmt_str, chan +1 ); +snprintf (str,80 , module_aw_chan_flags[flag].fmt_str, chan +1 );printf ("\t%-41s : %s\n" , str, - page_11h[module_aw_chan_flags[i].offset] & chan ? + page_11h[module_aw_chan_flags[flag].offset] & chan ?"On" :"Off" ); } }
@@ -708,15 +705,17 @@ cmis_show_dom_chan_lvl_flags_bank(const struct cmis_memory_map *map, int bank) {const __u8 *page_11h = map->upper_memory[bank][0x11 ]; -int i; +int flag;if (!page_11h)return ; -for (i =0 ; i <CMIS_CHANNELS_PER_BANK ; i++) { -int chan = bank *CMIS_CHANNELS_PER_BANK + i; +for (flag =0 ; module_aw_chan_flags[flag].fmt_str; flag++) { +if (!(map->page_01h[module_aw_chan_flags[flag].adver_offset] & + module_aw_chan_flags[flag].adver_value)) +continue ; -cmis_show_dom_chan_lvl_flags_chan (map, bank, chan); +cmis_show_dom_chan_lvl_flag (map, bank, flag); } }
Signature · 1 line
2.47.0
PATCH v4 5/16 qsfp: Reorder the channel-level flags list for SFF8636 module type
In reply to Danielle RatsonCurrently, when printing channel-level flags in the ethtool dump, we iterate over a list where each element represents a flag and a channel.
The list is structured such that, for each channel, all elements with the same flag are grouped together.
To accommodate future JSON support, where per-channel fields will be represented as an array (with each element corresponding to a specific channel), the presentation order needs to change. Additionally, the hard-coded channel numbers in the flag names should be removed.
---
Notes:
v2:
* Simplify sff8636_show_dom().
module-common.c | 168 ++++++++++++++++++++++++------------------------ qsfp.c | 17 +++-- 2 files changed, 95 insertions(+), 90 deletions(-)
module-common.c +84 -84
@@ -87,112 +87,112 @@ const struct module_aw_chan module_aw_chan_flags[] = {CMIS_RX_PWR_AW_LWARN_OFFSET ,CMIS_DIAG_CHAN_ADVER_OFFSET , CMIS_RX_PWR_MON_MASK }, - { MODULE_TYPE_SFF8636, "Laser bias current high alarm (Chan 1)", + { MODULE_TYPE_SFF8636, "Laser bias current high alarm", SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_1_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser bias current low alarm (Chan 1)", - SFF8636_TX_BIAS_12_AW_OFFSET, 0,(SFF8636_TX_BIAS_1_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser bias current high warning (Chan 1)", - SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_1_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser bias current low warning (Chan 1)", - SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_1_LWARN) }, - - { MODULE_TYPE_SFF8636, "Laser bias current high alarm (Chan 2)", + { MODULE_TYPE_SFF8636, "Laser bias current high alarm", SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_2_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser bias current low alarm (Chan 2)", - SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_2_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser bias current high warning (Chan 2)", - SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_2_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser bias current low warning (Chan 2)", - SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_2_LWARN) }, - - { MODULE_TYPE_SFF8636, "Laser bias current high alarm (Chan 3)", + { MODULE_TYPE_SFF8636, "Laser bias current high alarm", SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_3_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser bias current low alarm (Chan 3)", - SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_3_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser bias current high warning (Chan 3)", - SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_3_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser bias current low warning (Chan 3)", - SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_3_LWARN) }, - - { MODULE_TYPE_SFF8636, "Laser bias current high alarm (Chan 4)", + { MODULE_TYPE_SFF8636, "Laser bias current high alarm", SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_4_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser bias current low alarm (Chan 4)", + + { MODULE_TYPE_SFF8636, "Laser bias current low alarm", + SFF8636_TX_BIAS_12_AW_OFFSET, 0,(SFF8636_TX_BIAS_1_LALARM) }, + { MODULE_TYPE_SFF8636, "Laser bias current low alarm", + SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_2_LALARM) }, + { MODULE_TYPE_SFF8636, "Laser bias current low alarm", + SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_3_LALARM) }, + { MODULE_TYPE_SFF8636, "Laser bias current low alarm", SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_4_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser bias current high warning (Chan 4)", + + { MODULE_TYPE_SFF8636, "Laser bias current high warning", + SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_1_HWARN) }, + { MODULE_TYPE_SFF8636, "Laser bias current high warning", + SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_2_HWARN) }, + { MODULE_TYPE_SFF8636, "Laser bias current high warning", + SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_3_HWARN) }, + { MODULE_TYPE_SFF8636, "Laser bias current high warning", SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_4_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser bias current low warning (Chan 4)", + + { MODULE_TYPE_SFF8636, "Laser bias current low warning", + SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_1_LWARN) }, + { MODULE_TYPE_SFF8636, "Laser bias current low warning", + SFF8636_TX_BIAS_12_AW_OFFSET, 0, (SFF8636_TX_BIAS_2_LWARN) }, + { MODULE_TYPE_SFF8636, "Laser bias current low warning", + SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_3_LWARN) }, + { MODULE_TYPE_SFF8636, "Laser bias current low warning", SFF8636_TX_BIAS_34_AW_OFFSET, 0, (SFF8636_TX_BIAS_4_LWARN) }, - { MODULE_TYPE_SFF8636, "Laser tx power high alarm (Channel 1)", + { MODULE_TYPE_SFF8636, "Laser tx power high alarm", SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_1_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser tx power low alarm (Channel 1)", - SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_1_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser tx power high warning (Channel 1)", - SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_1_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser tx power low warning (Channel 1)", - SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_1_LWARN) }, - - { MODULE_TYPE_SFF8636, "Laser tx power high alarm (Channel 2)", + { MODULE_TYPE_SFF8636, "Laser tx power high alarm", SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_2_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser tx power low alarm (Channel 2)", - SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_2_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser tx power high warning (Channel 2)", - SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_2_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser tx power low warning (Channel 2)", - SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_2_LWARN) }, - - { MODULE_TYPE_SFF8636, "Laser tx power high alarm (Channel 3)", + { MODULE_TYPE_SFF8636, "Laser tx power high alarm", SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_3_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser tx power low alarm (Channel 3)", - SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_3_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser tx power high warning (Channel 3)", - SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_3_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser tx power low warning (Channel 3)", - SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_3_LWARN) }, - - { MODULE_TYPE_SFF8636, "Laser tx power high alarm (Channel 4)", + { MODULE_TYPE_SFF8636, "Laser tx power high alarm", SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_4_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser tx power low alarm (Channel 4)", + + { MODULE_TYPE_SFF8636, "Laser tx power low alarm", + SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_1_LALARM) }, + { MODULE_TYPE_SFF8636, "Laser tx power low alarm", + SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_2_LALARM) }, + { MODULE_TYPE_SFF8636, "Laser tx power low alarm", + SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_3_LALARM) }, + { MODULE_TYPE_SFF8636, "Laser tx power low alarm", SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_4_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser tx power high warning (Channel 4)", + + { MODULE_TYPE_SFF8636, "Laser tx power high warning", + SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_1_HWARN) }, + { MODULE_TYPE_SFF8636, "Laser tx power high warning", + SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_2_HWARN) }, + { MODULE_TYPE_SFF8636, "Laser tx power high warning", + SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_3_HWARN) }, + { MODULE_TYPE_SFF8636, "Laser tx power high warning", SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_4_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser tx power low warning (Channel 4)", + + { MODULE_TYPE_SFF8636, "Laser tx power low warning", + SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_1_LWARN) }, + { MODULE_TYPE_SFF8636, "Laser tx power low warning", + SFF8636_TX_PWR_12_AW_OFFSET, 0, (SFF8636_TX_PWR_2_LWARN) }, + { MODULE_TYPE_SFF8636, "Laser tx power low warning", + SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_3_LWARN) }, + { MODULE_TYPE_SFF8636, "Laser tx power low warning", SFF8636_TX_PWR_34_AW_OFFSET, 0, (SFF8636_TX_PWR_4_LWARN) }, - { MODULE_TYPE_SFF8636, "Laser rx power high alarm (Channel 1)", + { MODULE_TYPE_SFF8636, "Laser rx power high alarm", SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_1_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser rx power low alarm (Channel 1)", - SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_1_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser rx power high warning (Channel 1)", - SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_1_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser rx power low warning (Channel 1)", - SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_1_LWARN) }, - - { MODULE_TYPE_SFF8636, "Laser rx power high alarm (Channel 2)", + { MODULE_TYPE_SFF8636, "Laser rx power high alarm", SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_2_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser rx power low alarm (Channel 2)", - SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_2_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser rx power high warning (Channel 2)", - SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_2_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser rx power low warning (Channel 2)", - SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_2_LWARN) }, - - { MODULE_TYPE_SFF8636, "Laser rx power high alarm (Channel 3)", + { MODULE_TYPE_SFF8636, "Laser rx power high alarm", SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_3_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser rx power low alarm (Channel 3)", - SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_3_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser rx power high warning (Channel 3)", - SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_3_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser rx power low warning (Channel 3)", - SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_3_LWARN) }, - - { MODULE_TYPE_SFF8636, "Laser rx power high alarm (Channel 4)", + { MODULE_TYPE_SFF8636, "Laser rx power high alarm", SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_4_HALARM) }, - { MODULE_TYPE_SFF8636, "Laser rx power low alarm (Channel 4)", + + { MODULE_TYPE_SFF8636, "Laser rx power low alarm", + SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_1_LALARM) }, + { MODULE_TYPE_SFF8636, "Laser rx power low alarm", + SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_2_LALARM) }, + { MODULE_TYPE_SFF8636, "Laser rx power low alarm", + SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_3_LALARM) }, + { MODULE_TYPE_SFF8636, "Laser rx power low alarm", SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_4_LALARM) }, - { MODULE_TYPE_SFF8636, "Laser rx power high warning (Channel 4)", + + { MODULE_TYPE_SFF8636, "Laser rx power high warning", + SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_1_HWARN) }, + { MODULE_TYPE_SFF8636, "Laser rx power high warning", + SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_2_HWARN) }, + { MODULE_TYPE_SFF8636, "Laser rx power high warning", + SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_3_HWARN) }, + { MODULE_TYPE_SFF8636, "Laser rx power high warning", SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_4_HWARN) }, - { MODULE_TYPE_SFF8636, "Laser rx power low warning (Channel 4)", + + { MODULE_TYPE_SFF8636, "Laser rx power low warning", + SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_1_LWARN) }, + { MODULE_TYPE_SFF8636, "Laser rx power low warning", + SFF8636_RX_PWR_12_AW_OFFSET, 0, (SFF8636_RX_PWR_2_LWARN) }, + { MODULE_TYPE_SFF8636, "Laser rx power low warning", + SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_3_LWARN) }, + { MODULE_TYPE_SFF8636, "Laser rx power low warning", SFF8636_RX_PWR_34_AW_OFFSET, 0, (SFF8636_RX_PWR_4_LWARN) }, { 0, NULL, 0, 0, 0 },
qsfp.c +11 -6
@@ -711,13 +711,18 @@ static void sff8636_show_dom(const struct sff8636_memory_map *map) }if (sd.supports_alarms) { +bool value; +for (i =0 ; module_aw_chan_flags[i].fmt_str; ++i) { -if (module_aw_chan_flags[i].type ==MODULE_TYPE_SFF8636 ) -printf ("\t%-41s : %s\n" , - module_aw_chan_flags[i].fmt_str, - (map->lower_memory[module_aw_chan_flags[i].offset] - & module_aw_chan_flags[i].adver_value) ? -"On" :"Off" ); +if (module_aw_chan_flags[i].type !=MODULE_TYPE_SFF8636 ) +continue ; + + value = map->lower_memory[module_aw_chan_flags[i].offset] & + module_aw_chan_flags[i].adver_value; +printf ("\t%-41s (Chan %d) : %s\n" , + module_aw_chan_flags[i].fmt_str, + (i %SFF8636_MAX_CHANNEL_NUM ) +1 , + value ?"On" :"Off" ); }for (i =0 ; module_aw_mod_flags[i].str; ++i) {if (module_aw_mod_flags[i].type ==MODULE_TYPE_SFF8636 )
Signature · 1 line
2.47.0
PATCH v4 6/16 qsfp: Refactor sff8636_show_dom() by moving code into separate functions
In reply to Danielle RatsonThe sff8636_show_dom() function is quite lengthy, and with the planned addition of JSON support, it will become even longer and more complex.
To improve readability and maintainability, refactor the function by moving portions of the code into separate functions, following the approach used in the cmis.c module.
--- qsfp.c | 126 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 46 deletions(-)
qsfp.c +80 -46
@@ -649,13 +649,85 @@ out: } } -static void sff8636_show_dom (const struct sff8636_memory_map *map) +static void sff8636_show_dom_chan_lvl_tx_bias (const struct sff_diags *sd) { -struct sff_diags sd = {0 }; -char *rx_power_string =NULL ;char power_string[MAX_DESC_SIZE ];int i; +for (i =0 ; i <SFF8636_MAX_CHANNEL_NUM ; i++) { +snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , +"Laser tx bias current" , i+1 ); +PRINT_BIAS (power_string, sd->scd[i].bias_cur); + } +} + +static void sff8636_show_dom_chan_lvl_tx_power (const struct sff_diags *sd) +{ +char power_string[MAX_DESC_SIZE ]; +int i; + +for (i =0 ; i <SFF8636_MAX_CHANNEL_NUM ; i++) { +snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , +"Transmit avg optical power" , i+1 ); +PRINT_xX_PWR (power_string, sd->scd[i].tx_power); + } +} + +static void sff8636_show_dom_chan_lvl_rx_power (const struct sff_diags *sd) +{ +char power_string[MAX_DESC_SIZE ]; +char *rx_power_string =NULL ; +int i; + +if (!sd->rx_power_type) + rx_power_string ="Receiver signal OMA" ; +else + rx_power_string ="Rcvr signal avg optical power" ; + +for (i =0 ; i <SFF8636_MAX_CHANNEL_NUM ; i++) { +snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , + rx_power_string, i+1 ); +PRINT_xX_PWR (power_string, sd->scd[i].rx_power); + } +} + +static void +sff8636_show_dom_chan_lvl_flags (const struct sff8636_memory_map *map) +{ +bool value; +int i; + +for (i =0 ; module_aw_chan_flags[i].fmt_str; ++i) { +if (module_aw_chan_flags[i].type !=MODULE_TYPE_SFF8636 ) +continue ; + + value = map->lower_memory[module_aw_chan_flags[i].offset] & + module_aw_chan_flags[i].adver_value; +printf ("\t%-41s (Chan %d) : %s\n" , + module_aw_chan_flags[i].fmt_str, + (i %SFF8636_MAX_CHANNEL_NUM ) +1 , + value ?"On" :"Off" ); + } +} + +static void +sff8636_show_dom_mod_lvl_flags (const struct sff8636_memory_map *map) +{ +int i; + +for (i =0 ; module_aw_mod_flags[i].str; ++i) { +if (module_aw_mod_flags[i].type ==MODULE_TYPE_SFF8636 ) +printf ("\t%-41s : %s\n" , + module_aw_mod_flags[i].str, +ONOFF (map->lower_memory[module_aw_mod_flags[i].offset] + & module_aw_mod_flags[i].value)); + } +} + +static void sff8636_show_dom (const struct sff8636_memory_map *map) +{ +struct sff_diags sd = {0 }; +/* * There is no clear identifier to signify the existence of * optical diagnostics similar to SFF-8472. So checking existence
@@ -687,51 +759,13 @@ static void sff8636_show_dom(const struct sff8636_memory_map *map)printf ("\t%-41s : %s\n" ,"Alarm/warning flags implemented" , (sd.supports_alarms ?"Yes" :"No" )); -for (i =0 ; i <SFF8636_MAX_CHANNEL_NUM ; i++) { -snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , -"Laser tx bias current" , i+1 ); -PRINT_BIAS (power_string, sd.scd[i].bias_cur); - } - -for (i =0 ; i <SFF8636_MAX_CHANNEL_NUM ; i++) { -snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , -"Transmit avg optical power" , i+1 ); -PRINT_xX_PWR (power_string, sd.scd[i].tx_power); - } - -if (!sd.rx_power_type) - rx_power_string ="Receiver signal OMA" ; -else - rx_power_string ="Rcvr signal avg optical power" ; - -for (i =0 ; i <SFF8636_MAX_CHANNEL_NUM ; i++) { -snprintf (power_string,MAX_DESC_SIZE ,"%s(Channel %d)" , - rx_power_string, i+1 ); -PRINT_xX_PWR (power_string, sd.scd[i].rx_power); - } +sff8636_show_dom_chan_lvl_tx_bias (&sd); +sff8636_show_dom_chan_lvl_tx_power (&sd); +sff8636_show_dom_chan_lvl_rx_power (&sd);if (sd.supports_alarms) { -bool value; - -for (i =0 ; module_aw_chan_flags[i].fmt_str; ++i) { -if (module_aw_chan_flags[i].type !=MODULE_TYPE_SFF8636 ) -continue ; - - value = map->lower_memory[module_aw_chan_flags[i].offset] & - module_aw_chan_flags[i].adver_value; -printf ("\t%-41s (Chan %d) : %s\n" , - module_aw_chan_flags[i].fmt_str, - (i %SFF8636_MAX_CHANNEL_NUM ) +1 , - value ?"On" :"Off" ); - } -for (i =0 ; module_aw_mod_flags[i].str; ++i) { -if (module_aw_mod_flags[i].type ==MODULE_TYPE_SFF8636 ) -printf ("\t%-41s : %s\n" , - module_aw_mod_flags[i].str, - (map->lower_memory[module_aw_mod_flags[i].offset] - & module_aw_mod_flags[i].value) ? -"On" :"Off" ); - } +sff8636_show_dom_chan_lvl_flags (map); +sff8636_show_dom_mod_lvl_flags (map);sff_show_thresholds (sd); }
Signature · 1 line
2.47.0
PATCH v4 7/16 module_common: Add helpers to support JSON printing for common value types
In reply to Danielle RatsonUpcoming patches will introduce JSON support to the ethtool dump. The ethtool dump currently handles various field types, including strings, unsigned integers, floats, etc.
To facilitate this transition, implement helper functions for commonly used types. These helpers will enable consistent printing for both JSON and regular dump formats.
In addition, add JSON support for common functions and defines to use in the upcoming patches.
---
Notes:
v3:
* Remove unit fields.
* Remove unit printings from helpers.
v2:
* Use "false" in module_show_lane_status() instead of "None" in JSON context.
* Use uint instead of hexa fields in JSON context.
module-common.c | 340 +++++++++++++++++++++++++++++++++++------------- module-common.h | 6 + sff-common.c | 93 +++++++++++-- sff-common.h | 41 ++++++ 4 files changed, 374 insertions(+), 106 deletions(-)
module-common.c +248 -92
@@ -5,6 +5,7 @@#include <stdio.h> #include <math.h> +#include <ctype.h> #include "module-common.h" const struct module_aw_mod module_aw_mod_flags[] = {
@@ -198,309 +199,464 @@ const struct module_aw_chan module_aw_chan_flags[] = { { 0, NULL, 0, 0, 0 }, }; +void convert_json_field_name (const char *str,char *json_str) +{ +for (size_t i =0 ; i <strlen (str); i++) + json_str[i] = (str[i] ==' ' ) ? +'_' :tolower ((unsigned char )str[i]); +} + +void module_print_any_uint (const char *fn,int value,const char *unit) +{ +char json_fn[100 ] ="" ; + +if (is_json_context ()) { +convert_json_field_name (fn, json_fn); +print_uint (PRINT_JSON , json_fn,"%u" , value); + }else { +printf ("\t%-41s : %u%s\n" , fn, value, unit ? unit :"" ); + } +} + +void module_print_any_string (const char *fn,const char *value) +{ +char json_fn[100 ] ="" ; + +if (is_json_context ()) { +convert_json_field_name (fn, json_fn); +print_string (PRINT_JSON , json_fn,"%s" , value); + }else { +printf ("\t%-41s : %s\n" , fn, value); + } +} + +void module_print_any_float (const char *fn,float value,const char *unit) +{ +char json_fn[100 ] ="" ; + +if (is_json_context ()) { +convert_json_field_name (fn, json_fn); +print_float (PRINT_JSON , json_fn,"%.04f" , value); + }else { +printf ("\t%-41s : %.04f%s\n" , fn, value, unit ? unit :"" ); + } +} + +void module_print_any_bool (const char *fn,char *given_json_fn,bool value, +const char *str_value) +{ +char json_fn[100 ] ="" ; + +if (!given_json_fn) +convert_json_field_name (fn, json_fn); +else +strcpy (json_fn, given_json_fn); + +if (is_json_context ()) +print_bool (PRINT_JSON , json_fn,NULL , value); +else +printf ("\t%-41s : %s\n" , fn, str_value); +} +void module_show_value_with_unit (const __u8 *id,unsigned int reg,const char *name,unsigned int mult,const char *unit) {unsigned int val = id[reg]; -printf ("\t%-41s : %u%s\n" , name, val * mult, unit); +module_print_any_uint (name, val * mult, unit); }void module_show_ascii (const __u8 *id,unsigned int first_reg,unsigned int last_reg,const char *name) { +char json_fn[100 ] ="" ; +char val_str[32 ] ="" ;unsigned int reg, val; -printf ("\t%-41s : " , name); +if (is_json_context ()) +convert_json_field_name (name, json_fn); +else +printf ("\t%-41s : " , name); +while (first_reg <= last_reg && id[last_reg] ==' ' ) last_reg--;for (reg = first_reg; reg <= last_reg; reg++) { +char val_char; + val = id[reg]; -putchar (((val >=32 ) && (val <=126 )) ? val :'_' ); + val_char = (char )val; + +if (is_json_context ()) + val_str[reg - first_reg] = (((val >=32 ) && (val <=126 )) ? + val_char :'_' ); +else +putchar (((val >=32 ) && (val <=126 )) ? val :'_' ); } -printf ("\n" ); + +if (is_json_context ()) +print_string (PRINT_JSON , json_fn,"%s" , val_str); +else +printf ("\n" ); }void module_show_lane_status (const char *name,unsigned int lane_cnt,const char *yes,const char *no,unsigned int value) { -printf ("\t%-41s : " , name); +char json_fn[100 ] ="" ; + +convert_json_field_name (name, json_fn); +if (!value) { -printf ("None\n" ); +if (is_json_context ()) +print_bool (PRINT_JSON , json_fn,NULL , false); +else +printf ("\t%-41s : None\n" , name);return ; } -printf ("[" ); -while (lane_cnt--) { -printf (" %s%c" , value &1 ? yes : no, lane_cnt ?',' :' ' ); - value >>=1 ; +if (is_json_context ()) { +open_json_array (json_fn,"" ); + +while (lane_cnt--) { +print_string (PRINT_JSON ,NULL ,"%s" , + value &1 ? yes : no); + value >>=1 ; + } +close_json_array ("" ); + }else { +printf ("\t%-41s : [" , name); +while (lane_cnt--) { +printf (" %s%c" , value &1 ? yes : no, lane_cnt ?',' :' ' ); + value >>=1 ; + } +printf ("]\n" ); } -printf ("]\n" ); }void module_show_oui (const __u8 *id,int id_offset) { -printf ("\t%-41s : %02x:%02x:%02x\n" ,"Vendor OUI" , - id[id_offset], id[(id_offset) +1 ], - id[(id_offset) +2 ]); +char oui_value[16 ]; + +if (is_json_context ()) { +open_json_array ("vendor_oui" ,"" ); +print_int (PRINT_JSON ,NULL ,NULL , id[id_offset]); +print_int (PRINT_JSON ,NULL ,NULL , id[(id_offset) +1 ]); +print_int (PRINT_JSON ,NULL ,NULL , id[(id_offset) +2 ]); +close_json_array ("" ); + }else { +snprintf (oui_value,16 ,"%02x:%02x:%02x" , id[id_offset], + id[(id_offset) +1 ], id[(id_offset) +2 ]); +printf ("\t%-41s : %s\n" ,"Vendor OUI" , oui_value); + } }void module_show_identifier (const __u8 *id,int id_offset) { -printf ("\t%-41s : 0x%02x" ,"Identifier" , id[id_offset]); +char id_description[SFF_MAX_DESC_LEN ]; +switch (id[id_offset]) {case MODULE_ID_UNKNOWN : -printf (" (no module present, unknown, or unspecified)\n" ); +strncpy (id_description, +"no module present, unknown, or unspecified" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_GBIC : -printf (" (GBIC)\n" ); +strncpy (id_description,"GBIC" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_SOLDERED_MODULE : -printf (" (module soldered to motherboard)\n" ); +strncpy (id_description, +"module soldered to motherboard" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_SFP : -printf (" (SFP)\n" ); +strncpy (id_description,"SFP" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_300_PIN_XBI : -printf (" (300 pin XBI)\n" ); +strncpy (id_description,"300 pin XBI" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_XENPAK : -printf (" (XENPAK)\n" ); +strncpy (id_description,"XENPAK" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_XFP : -printf (" (XFP)\n" ); +strncpy (id_description,"XFP" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_XFF : -printf (" (XFF)\n" ); +strncpy (id_description,"XFF" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_XFP_E : -printf (" (XFP-E)\n" ); +strncpy (id_description,"XFP-E" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_XPAK : -printf (" (XPAK)\n" ); +strncpy (id_description,"XPAK" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_X2 : -printf (" (X2)\n" ); +strncpy (id_description,"X2" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_DWDM_SFP : -printf (" (DWDM-SFP)\n" ); +strncpy (id_description,"DWDM-SFP" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_QSFP : -printf (" (QSFP)\n" ); +strncpy (id_description,"QSFP" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_QSFP_PLUS : -printf (" (QSFP+)\n" ); +strncpy (id_description,"QSFP+" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_CXP : -printf (" (CXP)\n" ); +strncpy (id_description,"CXP" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_HD4X : -printf (" (Shielded Mini Multilane HD 4X)\n" ); +strncpy (id_description,"Shielded Mini Multilane HD 4X" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_HD8X : -printf (" (Shielded Mini Multilane HD 8X)\n" ); +strncpy (id_description,"Shielded Mini Multilane HD 8X" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_QSFP28 : -printf (" (QSFP28)\n" ); +strncpy (id_description,"QSFP28" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_CXP2 : -printf (" (CXP2/CXP28)\n" ); +strncpy (id_description,"CXP2/CXP28" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_CDFP : -printf (" (CDFP Style 1/Style 2)\n" ); +strncpy (id_description,"CDFP Style 1/Style 2" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_HD4X_FANOUT : -printf (" (Shielded Mini Multilane HD 4X Fanout Cable)\n" ); +strncpy (id_description, +"Shielded Mini Multilane HD 4X Fanout Cable" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_HD8X_FANOUT : -printf (" (Shielded Mini Multilane HD 8X Fanout Cable)\n" ); +strncpy (id_description, +"Shielded Mini Multilane HD 8X Fanout Cable" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_CDFP_S3 : -printf (" (CDFP Style 3)\n" ); +strncpy (id_description,"CDFP Style 3" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_MICRO_QSFP : -printf (" (microQSFP)\n" ); +strncpy (id_description,"microQSFP" ,SFF_MAX_DESC_LEN );break ;case MODULE_ID_QSFP_DD : -printf (" (QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628))\n" ); +strncpy (id_description, +"QSFP-DD Double Density 8X Pluggable Transceiver (INF-8628)" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_OSFP : -printf (" (OSFP 8X Pluggable Transceiver)\n" ); +strncpy (id_description,"OSFP 8X Pluggable Transceiver" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_DSFP : -printf (" (DSFP Dual Small Form Factor Pluggable Transceiver)\n" ); +strncpy (id_description, +"DSFP Dual Small Form Factor Pluggable Transceiver" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_QSFP_PLUS_CMIS : -printf (" (QSFP+ or later with Common Management Interface Specification (CMIS))\n" ); +strncpy (id_description, +"QSFP+ or later with Common Management Interface Specification (CMIS)" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_SFP_DD_CMIS : -printf (" (SFP-DD Double Density 2X Pluggable Transceiver with Common Management Interface Specification (CMIS))\n" ); +strncpy (id_description, +"SFP-DD Double Density 2X Pluggable Transceiver with Common Management Interface Specification (CMIS)" , +SFF_MAX_DESC_LEN );break ;case MODULE_ID_SFP_PLUS_CMIS : -printf (" (SFP+ and later with Common Management Interface Specification (CMIS))\n" ); +strncpy (id_description, +"SFP+ and later with Common Management Interface Specification (CMIS)" , +SFF_MAX_DESC_LEN );break ;default : -printf (" (reserved or unknown)\n" ); +strncpy (id_description,"reserved or unknown" , +SFF_MAX_DESC_LEN );break ; } + +sff_print_any_hex_field ("Identifier" ,"identifier" , id[id_offset], + id_description); }void module_show_connector (const __u8 *id,int ctor_offset) { -printf ("\t%-41s : 0x%02x" ,"Connector" , id[ctor_offset]); +char ctor_description[SFF_MAX_DESC_LEN ]; +switch (id[ctor_offset]) {case MODULE_CTOR_UNKNOWN : -printf (" (unknown or unspecified)\n" ); +strncpy (ctor_description,"unknown or unspecified" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_SC : -printf (" (SC)\n" ); +strncpy (ctor_description,"SC" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_FC_STYLE_1 : -printf (" (Fibre Channel Style 1 copper)\n" ); +strncpy (ctor_description,"Fibre Channel Style 1 copper" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_FC_STYLE_2 : -printf (" (Fibre Channel Style 2 copper)\n" ); +strncpy (ctor_description,"Fibre Channel Style 2 copper" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_BNC_TNC : -printf (" (BNC/TNC)\n" ); +strncpy (ctor_description,"BNC/TNC" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_FC_COAX : -printf (" (Fibre Channel coaxial headers)\n" ); +strncpy (ctor_description,"Fibre Channel coaxial headers" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_FIBER_JACK : -printf (" (FibreJack)\n" ); +strncpy (ctor_description,"FibreJack" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_LC : -printf (" (LC)\n" ); +strncpy (ctor_description,"LC" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_MT_RJ : -printf (" (MT-RJ)\n" ); +strncpy (ctor_description,"MT-RJ" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_MU : -printf (" (MU)\n" ); +strncpy (ctor_description,"MU" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_SG : -printf (" (SG)\n" ); +strncpy (ctor_description,"SG" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_OPT_PT : -printf (" (Optical pigtail)\n" ); +strncpy (ctor_description,"Optical pigtail" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_MPO : -printf (" (MPO Parallel Optic)\n" ); +strncpy (ctor_description,"MPO Parallel Optic" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_MPO_2 : -printf (" (MPO Parallel Optic - 2x16)\n" ); +strncpy (ctor_description,"MPO Parallel Optic - 2x16" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_HSDC_II : -printf (" (HSSDC II)\n" ); +strncpy (ctor_description,"HSSDC II" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_COPPER_PT : -printf (" (Copper pigtail)\n" ); +strncpy (ctor_description,"Copper pigtail" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_RJ45 : -printf (" (RJ45)\n" ); +strncpy (ctor_description,"RJ45" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_NO_SEPARABLE : -printf (" (No separable connector)\n" ); +strncpy (ctor_description,"No separable connector" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_MXC_2x16: -printf (" (MXC 2x16)\n" ); +strncpy (ctor_description,"MXC 2x16" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_CS_OPTICAL : -printf (" (CS optical connector)\n" ); +strncpy (ctor_description,"CS optical connector" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_CS_OPTICAL_MINI : -printf (" (Mini CS optical connector)\n" ); +strncpy (ctor_description,"Mini CS optical connector" , +SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_MPO_2X12 : -printf (" (MPO 2x12)\n" ); +strncpy (ctor_description,"MPO 2x12" ,SFF_MAX_DESC_LEN );break ;case MODULE_CTOR_MPO_1X16 : -printf (" (MPO 1x16)\n" ); +strncpy (ctor_description,"MPO 1x16" ,SFF_MAX_DESC_LEN );break ;default : -printf (" (reserved or unknown)\n" ); +strncpy (ctor_description,"reserved or unknown" , +SFF_MAX_DESC_LEN );break ; } + +sff_print_any_hex_field ("Connector" ,"connector" , id[ctor_offset], + ctor_description); }void module_show_mit_compliance (u16 value) { -static const char *cc =" (Copper cable," ; - -printf ("\t%-41s : 0x%02x" ,"Transmitter technology" , value); +static const char *cc ="Copper cable," ; +char description[SFF_MAX_DESC_LEN ];switch (value) {case MODULE_850_VCSEL : -printf (" (850 nm VCSEL)\n" ); +strncpy (description,"850 nm VCSEL" ,SFF_MAX_DESC_LEN );break ;case CMIS_1310_VCSEL :case SFF8636_TRANS_1310_VCSEL : -printf (" (1310 nm VCSEL)\n" ); +strncpy (description,"1310 nm VCSEL" ,SFF_MAX_DESC_LEN );break ;case CMIS_1550_VCSEL :case SFF8636_TRANS_1550_VCSEL : -printf (" (1550 nm VCSEL)\n" ); +strncpy (description,"1550 nm VCSEL" ,SFF_MAX_DESC_LEN );break ;case CMIS_1310_FP :case SFF8636_TRANS_1310_FP : -printf (" (1310 nm FP)\n" ); +strncpy (description,"1310 nm FP" ,SFF_MAX_DESC_LEN );break ;case CMIS_1310_DFB :case SFF8636_TRANS_1310_DFB : -printf (" (1310 nm DFB)\n" ); +strncpy (description,"1310 nm DFB" ,SFF_MAX_DESC_LEN );break ;case CMIS_1550_DFB :case SFF8636_TRANS_1550_DFB : -printf (" (1550 nm DFB)\n" ); +strncpy (description,"1550 nm DFB" ,SFF_MAX_DESC_LEN );break ;case CMIS_1310_EML :case SFF8636_TRANS_1310_EML : -printf (" (1310 nm EML)\n" ); +strncpy (description,"1310 nm EML" ,SFF_MAX_DESC_LEN );break ;case CMIS_1550_EML :case SFF8636_TRANS_1550_EML : -printf (" (1550 nm EML)\n" ); +strncpy (description,"1550 nm EML" ,SFF_MAX_DESC_LEN );break ;case CMIS_OTHERS :case SFF8636_TRANS_OTHERS : -printf (" (Others/Undefined)\n" ); +strncpy (description,"Others/Undefined" ,SFF_MAX_DESC_LEN );break ;case CMIS_1490_DFB :case SFF8636_TRANS_1490_DFB : -printf (" (1490 nm DFB)\n" ); +strncpy (description,"1490 nm DFB" ,SFF_MAX_DESC_LEN );break ;case CMIS_COPPER_UNEQUAL :case SFF8636_TRANS_COPPER_PAS_UNEQUAL : -printf ("%s unequalized)\n" , cc); +snprintf (description,SFF_MAX_DESC_LEN ,"%s unequalized" , cc);break ;case CMIS_COPPER_PASS_EQUAL :case SFF8636_TRANS_COPPER_PAS_EQUAL : -printf ("%s passive equalized)\n" , cc); +snprintf (description,SFF_MAX_DESC_LEN ,"%s passive equalized" , + cc);break ;case CMIS_COPPER_NF_EQUAL :case SFF8636_TRANS_COPPER_LNR_FAR_EQUAL : -printf ("%s near and far end limiting active equalizers)\n" , cc); +snprintf (description,SFF_MAX_DESC_LEN , +"%s near and far end limiting active equalizers" , cc);break ;case CMIS_COPPER_F_EQUAL :case SFF8636_TRANS_COPPER_FAR_EQUAL : -printf ("%s far end limiting active equalizers)\n" , cc); +snprintf (description,SFF_MAX_DESC_LEN , +"%s far end limiting active equalizers" , cc);break ;case CMIS_COPPER_N_EQUAL :case SFF8636_TRANS_COPPER_NEAR_EQUAL : -printf ("%s near end limiting active equalizers)\n" , cc); +snprintf (description,SFF_MAX_DESC_LEN , +"%s near end limiting active equalizers" , cc);break ;case CMIS_COPPER_LINEAR_EQUAL :case SFF8636_TRANS_COPPER_LNR_EQUAL : -printf ("%s linear active equalizers)\n" , cc); +snprintf (description,SFF_MAX_DESC_LEN ,"%s linear active equalizers" , + cc);break ; } + +sff_print_any_hex_field ("Transmitter technology" , +"transmitter_technology" , value, description); }void module_show_dom_mod_lvl_monitors (const struct sff_diags *sd) { -PRINT_TEMP ("Module temperature" , sd->sfp_temp[MCURR ]); -PRINT_VCC ("Module voltage" , sd->sfp_voltage[MCURR ]); +PRINT_TEMP_ALL ("Module temperature" ,"module_temperature" , + sd->sfp_temp[MCURR ]); +PRINT_VCC_ALL ("Module voltage" ,"module_voltage" , + sd->sfp_voltage[MCURR ]); }
module-common.h +6 -0
@@ -264,6 +264,12 @@ struct module_aw_chan {extern const struct module_aw_mod module_aw_mod_flags[];extern const struct module_aw_chan module_aw_chan_flags[]; +void convert_json_field_name (const char *str,char *json_str); +void module_print_any_uint (const char *fn,int value,const char *unit); +void module_print_any_string (const char *fn,const char *value); +void module_print_any_float (const char *fn,float value,const char *unit); +void module_print_any_bool (const char *fn,char *given_json_fn,bool value, +const char *str_value);void module_show_value_with_unit (const __u8 *id,unsigned int reg,const char *name,unsigned int mult,const char *unit);
sff-common.c +79 -14
129 lines not on this page · raw message
sff-common.h +41 -0
73 lines not on this page · raw message
Signature · 1 line
2.47.0
PATCH v4 8/16 cmis: Add JSON output handling to --module-info in CMIS modules
In reply to Danielle RatsonAdd JSON output handling for 'ethtool -m' / --module-info, following the guideline below:
1. Fields with description, will have a separate description field.
2. Units will be documented in a separate module-info.json file.
3. ASCII fields will be presented as strings.
4. On/Off is rendered as true/false.
5. Yes/no is rendered as true/false.
6. Per-channel fields will be presented as array, when each element represents a channel.
7. Fields that hold version, will be split to major and minor sub fields.
---
Notes:
v3:
* Remove unit fields.
* Reword commit message.
v2:
* Use uint instead of hexa fields in JSON context.
* In rx_power JSON field, add a type field to let the user know what type is printed in "value".
cmis.c | 278 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 189 insertions(+), 89 deletions(-)
cmis.c +189 -89
@@ -62,7 +62,15 @@ static void cmis_show_rev_compliance(const struct cmis_memory_map *map)int major = (rev >>4 ) &0x0F ;int minor = rev &0x0F ; -printf ("\t%-41s : Rev. %d.%d\n" ,"Revision compliance" , major, minor); +if (is_json_context ()) { +open_json_object ("revision_compliance" ); +print_uint (PRINT_JSON ,"major" ,"%u" , major); +print_uint (PRINT_JSON ,"minor" ,"%u" , minor); +close_json_object (); + }else { +printf ("\t%-41s : Rev. %d.%d\n" ,"Revision compliance" , major, + minor); + } } static void
@@ -123,8 +131,8 @@ static void cmis_show_power_info(const struct cmis_memory_map *map) base_power = map->page_00h[CMIS_PWR_MAX_POWER_OFFSET ]; max_power = base_power *0.25f ; -printf ("\t%-41s : %d\n" ,"Power class" , power_class +1 ); -printf ("\t%-41s : %.02fW\n" ,"Max power" , max_power); +module_print_any_uint ("Power class" , power_class +1 ,NULL ); +module_print_any_float ("Max power" , max_power,"W" ); }/**
@@ -143,7 +151,7 @@ static void cmis_show_cbl_asm_len(const struct cmis_memory_map *map)/* Check if max length */ if (map->page_00h[CMIS_CBL_ASM_LEN_OFFSET ] ==CMIS_6300M_MAX_LEN ) { -printf ("\t%-41s : > 6.3km\n" , fn); +module_print_any_string (fn,"> 6.3km" );return ; }
@@ -168,7 +176,7 @@ static void cmis_show_cbl_asm_len(const struct cmis_memory_map *map)/* Get base value from first 6 bits and multiply by mul */ val = (map->page_00h[CMIS_CBL_ASM_LEN_OFFSET ] &CMIS_LEN_VAL_MASK ); val = (float )val * mul; -printf ("\t%-41s : %0.2fm\n" , fn, val); +module_print_any_float (fn, val,"m" ); }/**
@@ -202,7 +210,7 @@ static void cmis_print_smf_cbl_len(const struct cmis_memory_map *map)/* Get base value from first 6 bits and multiply by mul */ val = (map->page_01h[CMIS_SMF_LEN_OFFSET ] &CMIS_LEN_VAL_MASK ); val = (float )val * mul; -printf ("\t%-41s : %0.2fkm\n" , fn, val); +module_print_any_float (fn, val,"km" ); }/**
@@ -212,22 +220,26 @@ static void cmis_print_smf_cbl_len(const struct cmis_memory_map *map)*/ static void cmis_show_sig_integrity (const struct cmis_memory_map *map) { +bool value; +if (!map->page_01h)return ;/* CDR Bypass control: 2nd bit from each byte */ -printf ("\t%-41s : " ,"Tx CDR bypass control" ); -printf ("%s\n" ,YESNO (map->page_01h[CMIS_SIG_INTEG_TX_OFFSET ] &0x02 )); + value = map->page_01h[CMIS_SIG_INTEG_TX_OFFSET ] &0x02 ; +module_print_any_bool ("Tx CDR bypass control" ,NULL , value, +YESNO (value)); -printf ("\t%-41s : " ,"Rx CDR bypass control" ); -printf ("%s\n" ,YESNO (map->page_01h[CMIS_SIG_INTEG_RX_OFFSET ] &0x02 )); + value = map->page_01h[CMIS_SIG_INTEG_RX_OFFSET ] &0x02 ; +module_print_any_bool ("Rx CDR bypass control" ,NULL , value, +YESNO (value));/* CDR Implementation: 1st bit from each byte */ -printf ("\t%-41s : " ,"Tx CDR" ); -printf ("%s\n" ,YESNO (map->page_01h[CMIS_SIG_INTEG_TX_OFFSET ] &0x01 )); + value = map->page_01h[CMIS_SIG_INTEG_TX_OFFSET ] &0x01 ; +module_print_any_bool ("Tx CDR" ,NULL , value,YESNO (value)); -printf ("\t%-41s : " ,"Rx CDR" ); -printf ("%s\n" ,YESNO (map->page_01h[CMIS_SIG_INTEG_RX_OFFSET ] &0x01 )); + value = map->page_01h[CMIS_SIG_INTEG_RX_OFFSET ] &0x01 ; +module_print_any_bool ("Rx CDR" ,NULL , value,YESNO (value)); }/**
@@ -247,21 +259,25 @@ static void cmis_show_mit_compliance(const struct cmis_memory_map *map)module_show_mit_compliance (value);if (value >=CMIS_COPPER_UNEQUAL ) { -printf ("\t%-41s : %udb\n" ,"Attenuation at 5GHz" , - map->page_00h[CMIS_COPPER_ATT_5GHZ ]); -printf ("\t%-41s : %udb\n" ,"Attenuation at 7GHz" , - map->page_00h[CMIS_COPPER_ATT_7GHZ ]); -printf ("\t%-41s : %udb\n" ,"Attenuation at 12.9GHz" , - map->page_00h[CMIS_COPPER_ATT_12P9GHZ ]); -printf ("\t%-41s : %udb\n" ,"Attenuation at 25.8GHz" , - map->page_00h[CMIS_COPPER_ATT_25P8GHZ ]); +module_print_any_uint ("Attenuation at 5GHz" , + map->page_00h[CMIS_COPPER_ATT_5GHZ ],"db" ); +module_print_any_uint ("Attenuation at 7GHz" , + map->page_00h[CMIS_COPPER_ATT_7GHZ ],"db" ); +module_print_any_uint ("Attenuation at 12.9GHz" , + map->page_00h[CMIS_COPPER_ATT_12P9GHZ ], +"db" ); +module_print_any_uint ("Attenuation at 25.8GHz" , + map->page_00h[CMIS_COPPER_ATT_25P8GHZ ], +"db" ); }else if (map->page_01h) { -printf ("\t%-41s : %.3lfnm\n" ,"Laser wavelength" , - (((map->page_01h[CMIS_NOM_WAVELENGTH_MSB ] <<8 ) | - map->page_01h[CMIS_NOM_WAVELENGTH_LSB ]) *0.05 )); -printf ("\t%-41s : %.3lfnm\n" ,"Laser wavelength tolerance" , - (((map->page_01h[CMIS_WAVELENGTH_TOL_MSB ] <<8 ) | - map->page_01h[CMIS_WAVELENGTH_TOL_LSB ]) *0.005 )); +module_print_any_float ("Laser wavelength" , + (((map->page_01h[CMIS_NOM_WAVELENGTH_MSB ] <<8 ) | + map->page_01h[CMIS_NOM_WAVELENGTH_LSB ]) *0.05 ), +"nm" ); +module_print_any_float ("Laser wavelength tolerance" , + (((map->page_01h[CMIS_WAVELENGTH_TOL_MSB ] <<8 ) | + map->page_01h[CMIS_NOM_WAVELENGTH_LSB ]) *0.05 ), +"nm" ); } }
@@ -314,6 +330,8 @@ static void cmis_show_vendor_info(const struct cmis_memory_map *map) CMIS_CLEI_END_OFFSET, "CLEI code"); } +#define CMIS_MAX_DESC_LEN 64 +/* Print the current Module State. Relevant documents: * [1] CMIS Rev. 5, pag. 57, section 6.3.2.2, Figure 6-3 * [2] CMIS Rev. 5, pag. 60, section 6.3.2.3, Figure 6-4
@@ -321,31 +339,40 @@ static void cmis_show_vendor_info(const struct cmis_memory_map *map)*/ static void cmis_show_mod_state (const struct cmis_memory_map *map) { +char mod_state_description[CMIS_MAX_DESC_LEN ];__u8 mod_state; mod_state = (map->lower_memory[CMIS_MODULE_STATE_OFFSET ] &CMIS_MODULE_STATE_MASK ) >>1 ; -printf ("\t%-41s : 0x%02x" ,"Module State" , mod_state);switch (mod_state) {case CMIS_MODULE_STATE_MODULE_LOW_PWR : -printf (" (ModuleLowPwr)\n" ); +strncpy (mod_state_description,"ModuleLowPwr" , +CMIS_MAX_DESC_LEN );break ;case CMIS_MODULE_STATE_MODULE_PWR_UP : -printf (" (ModulePwrUp)\n" ); +strncpy (mod_state_description,"ModulePwrUp" , +CMIS_MAX_DESC_LEN );break ;case CMIS_MODULE_STATE_MODULE_READY : -printf (" (ModuleReady)\n" ); +strncpy (mod_state_description,"ModuleReady" , +CMIS_MAX_DESC_LEN );break ;case CMIS_MODULE_STATE_MODULE_PWR_DN : -printf (" (ModulePwrDn)\n" ); +strncpy (mod_state_description,"ModulePwrDn" , +CMIS_MAX_DESC_LEN );break ;case CMIS_MODULE_STATE_MODULE_FAULT : -printf (" (ModuleFault)\n" ); +strncpy (mod_state_description,"ModuleFault" , +CMIS_MAX_DESC_LEN );break ;default : -printf (" (reserved or unknown)\n" ); +strncpy (mod_state_description,"reserved or unknown" , +CMIS_MAX_DESC_LEN );break ; } + +sff_print_any_hex_field ("Module state" ,"module_state" , + mod_state, mod_state_description); }/* Print the Module Fault Information. Relevant documents:
@@ -354,6 +381,7 @@ static void cmis_show_mod_state(const struct cmis_memory_map *map)*/ static void cmis_show_mod_fault_cause (const struct cmis_memory_map *map) { +char fault_cause_description[CMIS_MAX_DESC_LEN ];__u8 mod_state, fault_cause; mod_state = (map->lower_memory[CMIS_MODULE_STATE_OFFSET] &
@@ -362,24 +390,31 @@ static void cmis_show_mod_fault_cause(const struct cmis_memory_map *map)return ; fault_cause = map->lower_memory[CMIS_MODULE_FAULT_OFFSET ]; -printf ("\t%-41s : 0x%02x" ,"Module Fault Cause" , fault_cause);switch (fault_cause) {case CMIS_MODULE_FAULT_NO_FAULT : -printf (" (No fault detected / not supported)\n" ); +strncpy (fault_cause_description, +"No fault detected / not supported" ,CMIS_MAX_DESC_LEN );break ;case CMIS_MODULE_FAULT_TEC_RUNAWAY : -printf (" (TEC runaway)\n" ); +strncpy (fault_cause_description,"TEC runaway" , +CMIS_MAX_DESC_LEN );break ;case CMIS_MODULE_FAULT_DATA_MEM_CORRUPTED : -printf (" (Data memory corrupted)\n" ); +strncpy (fault_cause_description,"Data memory corrupted" , +CMIS_MAX_DESC_LEN );break ;case CMIS_MODULE_FAULT_PROG_MEM_CORRUPTED : -printf (" (Program memory corrupted)\n" ); +strncpy (fault_cause_description,"Program memory corrupted" , +CMIS_MAX_DESC_LEN );break ;default : -printf (" (reserved or unknown)\n" ); +strncpy (fault_cause_description,"reserved or unknown" , +CMIS_MAX_DESC_LEN );break ; } + +sff_print_any_hex_field ("Module Fault Cause" ,"module_fault_cause" , + fault_cause, fault_cause_description); }/* Print the current Module-Level Controls. Relevant documents:
@@ -388,12 +423,17 @@ static void cmis_show_mod_fault_cause(const struct cmis_memory_map *map)*/ static void cmis_show_mod_lvl_controls (const struct cmis_memory_map *map) { -printf ("\t%-41s : " ,"LowPwrAllowRequestHW" ); -printf ("%s\n" ,ONOFF (map->lower_memory[CMIS_MODULE_CONTROL_OFFSET ] & -CMIS_LOW_PWR_ALLOW_REQUEST_HW_MASK )); -printf ("\t%-41s : " ,"LowPwrRequestSW" ); -printf ("%s\n" ,ONOFF (map->lower_memory[CMIS_MODULE_CONTROL_OFFSET ] & -CMIS_LOW_PWR_REQUEST_SW_MASK )); +bool value; + + value = map->lower_memory[CMIS_MODULE_CONTROL_OFFSET ] & +CMIS_LOW_PWR_ALLOW_REQUEST_HW_MASK ; +module_print_any_bool ("LowPwrAllowRequestHW" ,"low_pwr_allow_request_hw" , + value,ONOFF (value)); + + value = map->lower_memory[CMIS_MODULE_CONTROL_OFFSET ] & +CMIS_LOW_PWR_REQUEST_SW_MASK ; +module_print_any_bool ("LowPwrRequestSW" ,"low_pwr_request_sw" , value, +ONOFF (value)); } static void cmis_parse_dom_power_type(const struct cmis_memory_map *map,
@@ -557,14 +597,22 @@ cmis_show_dom_chan_lvl_tx_bias_bank(const struct cmis_memory_map *map,if (!page_11h)return ; +open_json_array ("laser_tx_bias_current" ,"" ); +for (i =0 ; i <CMIS_CHANNELS_PER_BANK ; i++) {int chan = bank *CMIS_CHANNELS_PER_BANK + i;char fmt_str[80 ]; -snprintf (fmt_str,80 ,"%s (Channel %d)" , -"Laser tx bias current" , chan +1 ); -PRINT_BIAS (fmt_str, sd->scd[chan].bias_cur); +if (is_json_context ()) { +print_float (PRINT_JSON ,NULL ,"%.3f" , + (double )sd->scd[chan].bias_cur /500. ); + }else { +snprintf (fmt_str,80 ,"%s (Channel %d)" , +"Laser tx bias current" , chan +1 ); +PRINT_BIAS (fmt_str, sd->scd[chan].bias_cur); + } } +close_json_array ("" ); } static void cmis_show_dom_chan_lvl_tx_bias(const struct cmis_memory_map *map,
@@ -593,14 +641,22 @@ cmis_show_dom_chan_lvl_tx_power_bank(const struct cmis_memory_map *map,if (!page_11h)return ; +open_json_array ("transmit_avg_optical_power" ,"" ); +for (i =0 ; i <CMIS_CHANNELS_PER_BANK ; i++) {int chan = bank *CMIS_CHANNELS_PER_BANK + i;char fmt_str[80 ]; -snprintf (fmt_str,80 ,"%s (Channel %d)" , -"Transmit avg optical power" , chan +1 ); -PRINT_xX_PWR (fmt_str, sd->scd[chan].tx_power); +if (is_json_context ()) { +print_float (PRINT_JSON ,NULL ,"%.4f" , + (double )sd->scd[chan].tx_power /10000. ); + }else { +snprintf (fmt_str,80 ,"%s (Channel %d)" , +"Transmit avg optical power" , chan +1 ); +PRINT_xX_PWR (fmt_str, sd->scd[chan].tx_power); + } } +close_json_array ("" ); } static void cmis_show_dom_chan_lvl_tx_power(const struct cmis_memory_map *map,
@@ -623,25 +679,38 @@ cmis_show_dom_chan_lvl_rx_power_bank(const struct cmis_memory_map *map, const struct sff_diags *sd, int bank) {const __u8 *page_11h = map->upper_memory[bank][0x11 ]; +char *rx_power_type_str;int i;if (!page_11h)return ; +if (!sd->rx_power_type) + rx_power_type_str ="Receiver signal OMA" ; +else + rx_power_type_str ="Rcvr signal avg optical power" ; + +open_json_object ("rx_power" ); + +open_json_array ("values" ,"" );for (i =0 ; i <CMIS_CHANNELS_PER_BANK ; i++) {int chan = bank *CMIS_CHANNELS_PER_BANK + i; -char *rx_power_str;char fmt_str[80 ]; -if (!sd->rx_power_type) - rx_power_str ="Receiver signal OMA" ; -else - rx_power_str ="Rcvr signal avg optical power" ; - -snprintf (fmt_str,80 ,"%s (Channel %d)" , rx_power_str, - chan +1 ); -PRINT_xX_PWR (fmt_str, sd->scd[chan].rx_power); +if (is_json_context ()) { +print_float (PRINT_JSON ,NULL ,"%.4f" , + (double )sd->scd[chan].rx_power /10000. ); + }else { +snprintf (fmt_str,80 ,"%s (Channel %d)" , + rx_power_type_str, chan +1 ); +PRINT_xX_PWR (fmt_str, sd->scd[chan].rx_power); + } } +close_json_array ("" ); + +if (is_json_context ()) +module_print_any_string ("type" , rx_power_type_str); +close_json_object (); } static void cmis_show_dom_chan_lvl_rx_power(const struct cmis_memory_map *map,
@@ -672,10 +741,13 @@ static void cmis_show_dom_mod_lvl_flags(const struct cmis_memory_map *map)int i;for (i =0 ; module_aw_mod_flags[i].str; i++) { -if (module_aw_mod_flags[i].type ==MODULE_TYPE_CMIS ) -printf ("\t%-41s : %s\n" , module_aw_mod_flags[i].str, - map->lower_memory[module_aw_mod_flags[i].offset] & - module_aw_mod_flags[i].value ?"On" :"Off" ); +if (module_aw_mod_flags[i].type ==MODULE_TYPE_CMIS ) { +bool value = map->lower_memory[module_aw_mod_flags[i].offset] & + module_aw_mod_flags[i].value; + +module_print_any_bool (module_aw_mod_flags[i].str,NULL , + value,ONOFF (value)); + } } }
@@ -692,11 +764,16 @@ static void cmis_show_dom_chan_lvl_flag(const struct cmis_memory_map *map,for (i =0 ; i <CMIS_CHANNELS_PER_BANK ; i++) {int chan = bank *CMIS_CHANNELS_PER_BANK + i;char str[80 ]; - -snprintf (str,80 , module_aw_chan_flags[flag].fmt_str, chan +1 ); -printf ("\t%-41s : %s\n" , str, - page_11h[module_aw_chan_flags[flag].offset] & chan ? -"On" :"Off" ); +bool value; + + value = page_11h[module_aw_chan_flags[flag].offset] & chan; +if (is_json_context ()) { +print_bool (PRINT_JSON ,NULL ,NULL , value); + }else { +snprintf (str,80 ,"%s (Chan %d)" , + module_aw_chan_flags[flag].fmt_str, chan +1 ); +printf ("\t%-41s : %s\n" , str,ONOFF (value)); + } } }
@@ -711,11 +788,19 @@ cmis_show_dom_chan_lvl_flags_bank(const struct cmis_memory_map *map,return ;for (flag =0 ; module_aw_chan_flags[flag].fmt_str; flag++) { -if (!(map->page_01h[module_aw_chan_flags[flag].adver_offset] & - module_aw_chan_flags[flag].adver_value)) -continue ; - -cmis_show_dom_chan_lvl_flag (map, bank, flag); +char json_str[80 ] = {}; + +if (module_aw_chan_flags[flag].type ==MODULE_TYPE_CMIS ) { +if (!(map->page_01h[module_aw_chan_flags[flag].adver_offset] & + module_aw_chan_flags[flag].adver_value)) +continue ; + +convert_json_field_name (module_aw_chan_flags[flag].fmt_str, + json_str); +open_json_array (json_str,"" ); +cmis_show_dom_chan_lvl_flag (map, bank, flag); +close_json_array ("" ); + } } }
@@ -745,8 +830,12 @@ static void cmis_show_dom(const struct cmis_memory_map *map)cmis_show_dom_chan_lvl_monitors (map, &sd);cmis_show_dom_mod_lvl_flags (map);cmis_show_dom_chan_lvl_flags (map); -if (sd.supports_alarms) -sff_show_thresholds (sd); +if (sd.supports_alarms) { +if (is_json_context ()) +sff_show_thresholds_json (sd); +else +sff_show_thresholds (sd); + } }/* Print active and inactive firmware versions. Relevant documents:
@@ -756,14 +845,24 @@ static void cmis_show_dom(const struct cmis_memory_map *map)static void cmis_show_fw_version_common (const char *name,__u8 major,__u8 minor) { +char json_fn[32 ] ="" ; +if (major ==0 && minor ==0 ) {return ; }else if (major ==0xFF && minor ==0xFF ) { -printf ("\t%-41s : Invalid\n" , name); +module_print_any_string (name,"Invalid" );return ; } -printf ("\t%-41s : %d.%d\n" , name, major, minor); +if (is_json_context ()) { +convert_json_field_name (name, json_fn); +open_json_object (json_fn); +print_uint (PRINT_JSON ,"major" ,"%u" , major); +print_uint (PRINT_JSON ,"minor" ,"%u" , minor); +close_json_object (); + }else { +printf ("\t%-41s : %d.%d\n" , name, major, minor); + } }static void cmis_show_fw_active_version (const struct cmis_memory_map *map)
@@ -811,7 +910,7 @@ static void cmis_show_cdb_instances(const struct cmis_memory_map *map) {__u8 cdb_instances =cmis_cdb_instances_get (map); -printf ("\t%-41s : %u\n" ,"CDB instances" , cdb_instances); +module_print_any_uint ("CDB instances" , cdb_instances,NULL ); }static void cmis_show_cdb_mode (const struct cmis_memory_map *map)
@@ -819,8 +918,8 @@ static void cmis_show_cdb_mode(const struct cmis_memory_map *map)__u8 mode = map->page_01h[CMIS_CDB_ADVER_OFFSET ] &CMIS_CDB_ADVER_MODE_MASK ; -printf ("\t%-41s : %s\n" ,"CDB background mode" , - mode ?"Supported" :"Not supported" ); +module_print_any_string ("CDB background mode" , + mode ?"Supported" :"Not supported" ); }static void cmis_show_cdb_epl_pages (const struct cmis_memory_map *map)
@@ -828,7 +927,7 @@ static void cmis_show_cdb_epl_pages(const struct cmis_memory_map *map)__u8 epl_pages = map->page_01h[CMIS_CDB_ADVER_OFFSET ] &CMIS_CDB_ADVER_EPL_MASK ; -printf ("\t%-41s : %u\n" ,"CDB EPL pages" , epl_pages); +module_print_any_uint ("CDB EPL pages" , epl_pages,NULL ); }static void cmis_show_cdb_rw_len (const struct cmis_memory_map *map)
@@ -839,9 +938,10 @@ static void cmis_show_cdb_rw_len(const struct cmis_memory_map *map)* units of 8 bytes, in addition to the minimum 8 bytes. */ rw_len = (rw_len +1 ) *8 ; -printf ("\t%-41s : %u\n" ,"CDB Maximum EPL RW length" , rw_len); -printf ("\t%-41s : %u\n" ,"CDB Maximum LPL RW length" , - rw_len >CMIS_PAGE_SIZE ?CMIS_PAGE_SIZE : rw_len); +module_print_any_uint ("CDB Maximum EPL RW length" , rw_len,NULL ); +module_print_any_uint ("CDB Maximum LPL RW length" , + rw_len >CMIS_PAGE_SIZE ?CMIS_PAGE_SIZE : rw_len, +NULL ); }static void cmis_show_cdb_trigger (const struct cmis_memory_map *map)
@@ -853,8 +953,8 @@ static void cmis_show_cdb_trigger(const struct cmis_memory_map *map)* page, or by multiple writes ending with the writing of the CDB * Command Code (CMDID). */ -printf ("\t%-41s : %s\n" ,"CDB trigger method" , - trigger ?"Single write" :"Multiple writes" ); +module_print_any_string ("CDB trigger method" , + trigger ?"Single write" :"Multiple writes" ); }/* Print CDB messaging support advertisement. Relevant documents:
Signature · 1 line
2.47.0
PATCH v4 9/16 cmis: Enable JSON output support in CMIS modules
In reply to Danielle RatsonA sample output:
$ ethtool --json -m swp23
[ {
"identifier": 24,
"identifier_description": "QSFP-DD Double Density 8X Pluggable
Transceiver (INF-8628)",
"power_class": 5,
"max_power": 10,
"connector": 40,
"connector_description": "MPO 1x16",
"cable_assembly_length": 0,
"tx_cdr_bypass_control": false,
"rx_cdr_bypass_control": false,
"tx_cdr": true,
"rx_cdr": true,
"transmitter_technology": 0,
"transmitter_technology_description": "850 nm VCSEL",
"laser_wavelength": 850,
"laser_wavelength_tolerance": 94.8,
"length_(smf)": 0,
"length_(om5)": 0,
"length_(om4)": 100,
"length_(om3)": 70,
"length_(om2)": 0,
"vendor_name": "FINISAR CORP.",
"vendor_oui": [ 0,144,101 ],
"vendor_pn": "FTCD8613E1PCM",
"vendor_rev": "A0",
"vendor_sn": "X6LBE6H",
"date_code": "211229__",
"revision_compliance": {
"major": 4,
"minor": 0
},
"rx_loss_of_signal": [
"Yes","Yes","Yes","Yes","Yes","Yes","Yes","Yes" ],
"tx_loss_of_signal": false,
"rx_loss_of_lock": false,
"tx_loss_of_lock": false,
"tx_fault": false,
"module_state": 3,
"module_state_description": "ModuleReady",
"low_pwr_allow_request_hw": false,
"low_pwr_request_sw": false,
"module_temperature": 37.5273,
"module_voltage": 3.3358,
"laser_tx_bias_current": [ 0,0,0,0,0,0,0,0 ],
"transmit_avg_optical_power": [
0.0001,0.0001,0.0001,0.0001,0.0001,0.0001,0.0001,0.0001 ],
"rx_power": {
"values": [
0.0001,0.0001,0.0001,0.0001,0.0001,0.0001,0.0001,0.0001 ],
"type": "Rcvr signal avg optical power"
},
"module_temperature_high_alarm": false,
"module_temperature_low_alarm": false,
"module_temperature_high_warning": false,
"module_temperature_low_warning": false,
"module_voltage_high_alarm": false,
"module_voltage_low_alarm": false,
"module_voltage_high_warning": false,
"module_voltage_low_warning": false,
"laser_bias_current_high_alarm": [
false,false,false,false,false,false,false,false ],
"laser_bias_current_low_alarm": [
false,false,false,false,false,false,false,false ],
"laser_bias_current_high_warning": [
false,false,false,false,false,false,false,false ],
"laser_bias_current_low_warning": [
false,false,false,false,false,false,false,false ],
"laser_tx_power_high_alarm": [
false,false,false,false,false,false,false,false ],
"laser_tx_power_low_alarm": [
false,false,false,false,false,false,false,false ],
"laser_tx_power_high_warning": [
false,false,false,false,false,false,false,false ],
"laser_tx_power_low_warning": [
false,false,false,false,false,false,false,false ],
"laser_rx_power_high_alarm": [
false,false,false,false,false,false,false,false ],
"laser_rx_power_low_alarm": [
false,false,false,false,false,false,false,false ],
"laser_rx_power_high_warning": [
false,false,false,false,false,false,false,false ],
"laser_rx_power_low_warning": [
false,false,false,false,false,false,false,false ],
"laser_bias_current": {
"high_alarm_threshold": 13,
"low_alarm_threshold": 3,
"high_warning_threshold": 11,
"low_warning_threshold": 5
},
"laser_output_power": {
"high_alarm_threshold": 3.1623,
"low_alarm_threshold": 0.1,
"high_warning_threshold": 1.9953,
"low_warning_threshold": 0.1585
},
"module_temperature": {
"high_alarm_threshold": 75,
"low_alarm_threshold": -5,
"high_warning_threshold": 70,
"low_warning_threshold": 0
},
"module_voltage": {
"high_alarm_threshold": 3.465,
"low_alarm_threshold": 3.135,
"high_warning_threshold": 3.45,
"low_warning_threshold": 3.15
},
"laser_rx_power": {
"high_alarm_threshold": 3.1623,
"low_alarm_threshold": 0.0398,
"high_warning_threshold": 2.5119,
"low_warning_threshold": 0.0794
},
"active_firmware_version": {
"major": 2,
"minor": 7
},
"inactive_firmware_version": {
"major": 2,
"minor": 7
},
"cdb_instances": 1,
"cdb_background_mode": "Supported",
"cdb_epl_pages": 0,
"cdb_maximum_epl_rw_length": 128,
"cdb_maximum_lpl_rw_length": 128,
"cdb_trigger_method": "Single write"
} ]---
Notes:
v3:
* Reword commit message.
cmis.c | 6 ++++++ ethtool.c | 1 + 2 files changed, 7 insertions(+)
cmis.c +6 -0
@@ -1122,10 +1122,16 @@ int cmis_show_all_nl(struct cmd_context *ctx)struct cmis_memory_map map = {};int ret; +new_json_obj (ctx->json); +open_json_object (NULL ); + ret =cmis_memory_map_init_pages (ctx, &map);if (ret <0 )return ret;cmis_show_all_common (&map); +close_json_object (); +delete_json_obj (); +return 0 ; }
ethtool.c +1 -0
@@ -6050,6 +6050,7 @@ static const struct option args[] = { }, { .opts = "-m|--dump-module-eeprom|--module-info", + .json = true, .func = do_getmodule, .nlfunc = nl_getmodule, .help = "Query/Decode Module EEPROM information and optical diagnostics if available",
Signature · 1 line
2.47.0
PATCH v4 10/16 qsfp: Add JSON output handling to --module-info in SFF8636 modules
In reply to Danielle RatsonAdd JSON output handling for 'ethtool -m' / --module-info, following the guideline below:
1. Fields with description, will have a separate description field.
2. Units will be documented in a separate module-info.json file.
3. ASCII fields will be presented as strings.
4. On/Off is rendered as true/false.
5. Yes/no is rendered as true/false.
6. Per-channel fields will be presented as array, when each element represents a channel.
7. Fields that hold version, will be split to major and minor sub fields.
---
Notes:
v4:
* In extended_identifier field, use an array for all descriptions instead of 3 different descriptions.
* Remove duplicated definition of YESNO() and ONOFF() defines.
v3:
* Remove unit fields.
* Reword commit message.
* Fix JSON output in sff8636_show_dom_mod_lvl_flags().
qsfp.c | 536 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 331 insertions(+), 205 deletions(-)
qsfp.c +331 -205
@@ -82,64 +82,94 @@ static void sff8636_show_identifier(const struct sff8636_memory_map *map)static void sff8636_show_ext_identifier (const struct sff8636_memory_map *map) { -printf ("\t%-41s : 0x%02x\n" ,"Extended identifier" , - map->page_00h[SFF8636_EXT_ID_OFFSET ]); -static const char *pfx ="\tExtended identifier description :" ; +char description[64 ]; + +if (is_json_context ()) { +open_json_object ("extended_identifier" ); +print_uint (PRINT_JSON ,"value" ,"%u" , + map->page_00h[SFF8636_EXT_ID_OFFSET ]); + }else { +printf ("\t%-41s : 0x%02x\n" ,"Extended identifier" , + map->page_00h[SFF8636_EXT_ID_OFFSET ]); + } +open_json_array ("description" ,"" );switch (map->page_00h[SFF8636_EXT_ID_OFFSET ] &SFF8636_EXT_ID_PWR_CLASS_MASK ) {case SFF8636_EXT_ID_PWR_CLASS_1 : -printf ("%s 1.5W max. Power consumption\n" , pfx); +strncpy (description,"1.5W max. Power consumption" ,64 );break ;case SFF8636_EXT_ID_PWR_CLASS_2 : -printf ("%s 2.0W max. Power consumption\n" , pfx); +strncpy (description,"1.5W max. Power consumption" ,64 );break ;case SFF8636_EXT_ID_PWR_CLASS_3 : -printf ("%s 2.5W max. Power consumption\n" , pfx); +strncpy (description,"2.5W max. Power consumption" ,64 );break ;case SFF8636_EXT_ID_PWR_CLASS_4 : -printf ("%s 3.5W max. Power consumption\n" , pfx); +strncpy (description,"3.5W max. Power consumption" ,64 );break ; } +if (is_json_context ()) +print_string (PRINT_JSON ,NULL ,"%s" , description); +else +printf ("%s %s\n" , pfx, description); +if (map->page_00h[SFF8636_EXT_ID_OFFSET ] &SFF8636_EXT_ID_CDR_TX_MASK ) -printf ("%s CDR present in TX," , pfx); +strncpy (description,"CDR present in TX," ,64 );else -printf ("%s No CDR in TX," , pfx); +strncpy (description,"No CDR in TX," ,64 );if (map->page_00h[SFF8636_EXT_ID_OFFSET ] &SFF8636_EXT_ID_CDR_RX_MASK ) -printf (" CDR present in RX\n" ); +strcat (description," CDR present in RX" ); +else +strcat (description," No CDR in RX" ); + +if (is_json_context ()) +print_string (PRINT_JSON ,NULL ,"%s" , description);else -printf (" No CDR in RX\n" ); +printf ("%s %s\n" , pfx, description);switch (map->page_00h[SFF8636_EXT_ID_OFFSET ] &SFF8636_EXT_ID_EPWR_CLASS_MASK ) {case SFF8636_EXT_ID_PWR_CLASS_LEGACY : -printf ("%s" , pfx); +strncpy (description,"" ,64 );break ;case SFF8636_EXT_ID_PWR_CLASS_5 : -printf ("%s 4.0W max. Power consumption," , pfx); +strncpy (description,"4.0W max. Power consumption," ,64 );break ;case SFF8636_EXT_ID_PWR_CLASS_6 : -printf ("%s 4.5W max. Power consumption, " , pfx); +strncpy (description,"4.5W max. Power consumption," ,64 );break ;case SFF8636_EXT_ID_PWR_CLASS_7 : -printf ("%s 5.0W max. Power consumption, " , pfx); +strncpy (description,"5.0W max. Power consumption," ,64 );break ; } +if (map->lower_memory[SFF8636_PWR_MODE_OFFSET ] &SFF8636_HIGH_PWR_ENABLE ) -printf (" High Power Class (> 3.5 W) enabled\n" ); +strcat (description," High Power Class (> 3.5 W) enabled" ); +else +strcat (description, +" High Power Class (> 3.5 W) not enabled" ); + +if (is_json_context ()) +print_string (PRINT_JSON ,NULL ,"%s" , description);else -printf (" High Power Class (> 3.5 W) not enabled\n" ); -printf ("\t%-41s : " ,"Power set" ); -printf ("%s\n" ,ONOFF (map->lower_memory[SFF8636_PWR_MODE_OFFSET ] & -SFF8636_LOW_PWR_SET )); -printf ("\t%-41s : " ,"Power override" ); -printf ("%s\n" ,ONOFF (map->lower_memory[SFF8636_PWR_MODE_OFFSET ] & -SFF8636_PWR_OVERRIDE )); +printf ("%s %s\n" , pfx, description); + +close_json_array ("" ); +close_json_object (); + +bool value = map->lower_memory[SFF8636_PWR_MODE_OFFSET ] & +SFF8636_LOW_PWR_SET ; +module_print_any_bool ("Power set" ,"power_set" , value,ONOFF (value)); + value = map->lower_memory[SFF8636_PWR_MODE_OFFSET ] & +SFF8636_PWR_OVERRIDE ; +module_print_any_bool ("Power override" ,"power_override" , value, +ONOFF (value)); }static void sff8636_show_connector (const struct sff8636_memory_map *map)
@@ -149,232 +179,262 @@ static void sff8636_show_connector(const struct sff8636_memory_map *map)static void sff8636_show_transceiver (const struct sff8636_memory_map *map) { -static const char *pfx = -"\tTransceiver type :" ; - -printf ("\t%-41s : 0x%02x 0x%02x 0x%02x " \ -"0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n" , -"Transceiver codes" , - map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ], - map->page_00h[SFF8636_SONET_COMP_OFFSET ], - map->page_00h[SFF8636_SAS_COMP_OFFSET ], - map->page_00h[SFF8636_GIGE_COMP_OFFSET ], - map->page_00h[SFF8636_FC_LEN_OFFSET ], - map->page_00h[SFF8636_FC_TECH_OFFSET ], - map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ], - map->page_00h[SFF8636_FC_SPEED_OFFSET ]); +static const char *pfx ="Transceiver type" ; +char value[140 ] ="" ; + +if (is_json_context ()) { +open_json_array ("transceiver_codes" ,"" ); +print_uint (PRINT_JSON ,NULL ,"%u" , + map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ]); +print_uint (PRINT_JSON ,NULL ,"%u" , + map->page_00h[SFF8636_SONET_COMP_OFFSET ]); +print_uint (PRINT_JSON ,NULL ,"%u" , + map->page_00h[SFF8636_SAS_COMP_OFFSET ]); +print_uint (PRINT_JSON ,NULL ,"%u" , + map->page_00h[SFF8636_GIGE_COMP_OFFSET ]); +print_uint (PRINT_JSON ,NULL ,"%u" , + map->page_00h[SFF8636_FC_LEN_OFFSET ]); +print_uint (PRINT_JSON ,NULL ,"%u" , + map->page_00h[SFF8636_FC_TECH_OFFSET ]); +print_uint (PRINT_JSON ,NULL ,"%u" , + map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ]); +print_uint (PRINT_JSON ,NULL ,"%u" , + map->page_00h[SFF8636_FC_SPEED_OFFSET ]); +close_json_array ("" ); + }else { +printf ("\t%-41s : 0x%02x 0x%02x 0x%02x " \ +"0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n" , +"Transceiver codes" , + map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ], + map->page_00h[SFF8636_SONET_COMP_OFFSET ], + map->page_00h[SFF8636_SAS_COMP_OFFSET ], + map->page_00h[SFF8636_GIGE_COMP_OFFSET ], + map->page_00h[SFF8636_FC_LEN_OFFSET ], + map->page_00h[SFF8636_FC_TECH_OFFSET ], + map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ], + map->page_00h[SFF8636_FC_SPEED_OFFSET ]); + }/* 10G/40G Ethernet Compliance Codes */ if (map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ] &SFF8636_ETHERNET_10G_LRM ) -printf ("%s 10G Ethernet: 10G Base-LRM\n" , pfx); +sprintf (value,"%s" ,"10G Ethernet: 10G Base-LRM" );if (map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ] &SFF8636_ETHERNET_10G_LR ) -printf ("%s 10G Ethernet: 10G Base-LR\n" , pfx); +sprintf (value,"%s" ,"10G Ethernet: 10G Base-LR" );if (map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ] &SFF8636_ETHERNET_10G_SR ) -printf ("%s 10G Ethernet: 10G Base-SR\n" , pfx); +sprintf (value,"%s" ,"10G Ethernet: 10G Base-SR" );if (map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ] &SFF8636_ETHERNET_40G_CR4 ) -printf ("%s 40G Ethernet: 40G Base-CR4\n" , pfx); +sprintf (value,"%s" ,"40G Ethernet: 40G Base-CR4" );if (map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ] &SFF8636_ETHERNET_40G_SR4 ) -printf ("%s 40G Ethernet: 40G Base-SR4\n" , pfx); +sprintf (value,"%s" ,"40G Ethernet: 40G Base-SR4" );if (map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ] &SFF8636_ETHERNET_40G_LR4 ) -printf ("%s 40G Ethernet: 40G Base-LR4\n" , pfx); +sprintf (value,"%s" ,"40G Ethernet: 40G Base-LR4" );if (map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ] &SFF8636_ETHERNET_40G_ACTIVE ) -printf ("%s 40G Ethernet: 40G Active Cable (XLPPI)\n" , pfx); +sprintf (value,"%s" ,"40G Ethernet: 40G Active Cable (XLPPI)" );/* Extended Specification Compliance Codes from SFF-8024 */ if (map->page_00h[SFF8636_ETHERNET_COMP_OFFSET ] &SFF8636_ETHERNET_RSRVD ) {switch (map->page_00h[SFF8636_OPTION_1_OFFSET ]) {case SFF8636_ETHERNET_UNSPECIFIED : -printf ("%s (reserved or unknown)\n" , pfx); +sprintf (value,"%s" ,"(reserved or unknown)" );break ;case SFF8636_ETHERNET_100G_AOC : -printf ("%s 100G Ethernet: 100G AOC or 25GAUI C2M AOC with worst BER of 5x10^(-5)\n" , - pfx); +sprintf (value,"%s" , +"100G Ethernet: 100G AOC or 25GAUI C2M AOC with worst BER of 5x10^(-5)" );break ;case SFF8636_ETHERNET_100G_SR4 : -printf ("%s 100G Ethernet: 100G Base-SR4 or 25GBase-SR\n" , - pfx); +sprintf (value,"%s" , +"100G Ethernet: 100G Base-SR4 or 25GBase-SR" );break ;case SFF8636_ETHERNET_100G_LR4 : -printf ("%s 100G Ethernet: 100G Base-LR4\n" , pfx); +sprintf (value,"%s" ,"100G Ethernet: 100G Base-LR4" );break ;case SFF8636_ETHERNET_100G_ER4 : -printf ("%s 100G Ethernet: 100G Base-ER4\n" , pfx); +sprintf (value,"%s" ,"100G Ethernet: 100G Base-ER4" );break ;case SFF8636_ETHERNET_100G_SR10 : -printf ("%s 100G Ethernet: 100G Base-SR10\n" , pfx); +sprintf (value,"%s" ,"100G Ethernet: 100G Base-SR10" );break ;case SFF8636_ETHERNET_100G_CWDM4_FEC : -printf ("%s 100G Ethernet: 100G CWDM4 MSA with FEC\n" , pfx); +sprintf (value,"%s" , +"100G Ethernet: 100G CWDM4 MSA with FEC" );break ;case SFF8636_ETHERNET_100G_PSM4 : -printf ("%s 100G Ethernet: 100G PSM4 Parallel SMF\n" , pfx); +sprintf (value,"%s" , +"100G Ethernet: 100G PSM4 Parallel SMF" );break ;case SFF8636_ETHERNET_100G_ACC : -printf ("%s 100G Ethernet: 100G ACC or 25GAUI C2M ACC with worst BER of 5x10^(-5)\n" , - pfx); +sprintf (value,"%s" , +"100G Ethernet: 100G ACC or 25GAUI C2M ACC with worst BER of 5x10^(-5)" );break ;case SFF8636_ETHERNET_100G_CWDM4_NO_FEC : -printf ("%s 100G Ethernet: 100G CWDM4 MSA without FEC\n" , pfx); +sprintf (value,"%s" , +"100G Ethernet: 100G CWDM4 MSA without FEC" );break ;case SFF8636_ETHERNET_100G_RSVD1 : -printf ("%s (reserved or unknown)\n" , pfx); +sprintf (value,"%s" ,"(reserved or unknown)" );break ;case SFF8636_ETHERNET_100G_CR4 : -printf ("%s 100G Ethernet: 100G Base-CR4 or 25G Base-CR CA-L\n" , - pfx); +sprintf (value,"%s" , +"100G Ethernet: 100G Base-CR4 or 25G Base-CR CA-L" );break ;case SFF8636_ETHERNET_25G_CR_CA_S : -printf ("%s 25G Ethernet: 25G Base-CR CA-S\n" , pfx); +sprintf (value,"%s" ,"25G Ethernet: 25G Base-CR CA-S" );break ;case SFF8636_ETHERNET_25G_CR_CA_N : -printf ("%s 25G Ethernet: 25G Base-CR CA-N\n" , pfx); +sprintf (value,"%s" ,"25G Ethernet: 25G Base-CR CA-N" );break ;case SFF8636_ETHERNET_40G_ER4 : -printf ("%s 40G Ethernet: 40G Base-ER4\n" , pfx); +sprintf (value,"%s" ,"40G Ethernet: 40G Base-ER4" );break ;case SFF8636_ETHERNET_4X10_SR : -printf ("%s 4x10G Ethernet: 10G Base-SR\n" , pfx); +sprintf (value,"%s" ,"4x10G Ethernet: 10G Base-SR" );break ;case SFF8636_ETHERNET_40G_PSM4 : -printf ("%s 40G Ethernet: 40G PSM4 Parallel SMF\n" , pfx); +sprintf (value,"%s" , +"40G Ethernet: 40G PSM4 Parallel SMF" );break ;case SFF8636_ETHERNET_G959_P1I1_2D1 : -printf ("%s Ethernet: G959.1 profile P1I1-2D1 (10709 MBd, 2km, 1310nm SM)\n" , - pfx); +sprintf (value,"%s" , +"Ethernet: G959.1 profile P1I1-2D1 (10709 MBd, 2km, 1310nm SM)" );break ;case SFF8636_ETHERNET_G959_P1S1_2D2 : -printf ("%s Ethernet: G959.1 profile P1S1-2D2 (10709 MBd, 40km, 1550nm SM)\n" , - pfx); +sprintf (value,"%s" , +"Ethernet: G959.1 profile P1S1-2D2 (10709 MBd, 40km, 1550nm SM)" );break ;case SFF8636_ETHERNET_G959_P1L1_2D2 : -printf ("%s Ethernet: G959.1 profile P1L1-2D2 (10709 MBd, 80km, 1550nm SM)\n" , - pfx); +sprintf (value,"%s" , +"Ethernet: G959.1 profile P1L1-2D2 (10709 MBd, 80km, 1550nm SM)" );break ;case SFF8636_ETHERNET_10GT_SFI : -printf ("%s 10G Ethernet: 10G Base-T with SFI electrical interface\n" , - pfx); +sprintf (value,"%s" , +"10G Ethernet: 10G Base-T with SFI electrical interface" );break ;case SFF8636_ETHERNET_100G_CLR4 : -printf ("%s 100G Ethernet: 100G CLR4\n" , pfx); +sprintf (value,"%s" ,"100G Ethernet: 100G CLR4" );break ;case SFF8636_ETHERNET_100G_AOC2 : -printf ("%s 100G Ethernet: 100G AOC or 25GAUI C2M AOC with worst BER of 10^(-12)\n" , - pfx); +sprintf (value,"%s" , +"100G Ethernet: 100G AOC or 25GAUI C2M AOC with worst BER of 10^(-12)" );break ;case SFF8636_ETHERNET_100G_ACC2 : -printf ("%s 100G Ethernet: 100G ACC or 25GAUI C2M ACC with worst BER of 10^(-12)\n" , - pfx); +sprintf (value,"%s" , +"100G Ethernet: 100G ACC or 25GAUI C2M ACC with worst BER of 10^(-12)" );break ;case SFF8636_ETHERNET_100GE_DWDM2 : -printf ("%s 100GE-DWDM2 (DWDM transceiver using 2 wavelengths on a 1550 nm DWDM grid with a reach up to 80 km)\n" , - pfx); +sprintf (value,"%s" , +"100GE-DWDM2 (DWDM transceiver using 2 wavelengths on a 1550 nm DWDM grid with a reach up to 80 km)" );break ;case SFF8636_ETHERNET_100G_1550NM_WDM : -printf ("%s 100G 1550nm WDM (4 wavelengths)\n" , pfx); +sprintf (value,"%s" ,"100G 1550nm WDM (4 wavelengths)" );break ;case SFF8636_ETHERNET_10G_BASET_SR : -printf ("%s 10GBASE-T Short Reach (30 meters)\n" , pfx); +sprintf (value,"%s" , +"10GBASE-T Short Reach (30 meters)" );break ;case SFF8636_ETHERNET_5G_BASET : -printf ("%s 5GBASE-T\n" , pfx); +sprintf (value,"%s" ,"5GBASE-T" );break ;case SFF8636_ETHERNET_2HALFG_BASET : -printf ("%s 2.5GBASE-T\n" , pfx); +sprintf (value,"%s" ,"2.5GBASE-T" );break ;case SFF8636_ETHERNET_40G_SWDM4 : -printf ("%s 40G SWDM4\n" , pfx); +sprintf (value,"%s" ,"40G SWDM4" );break ;case SFF8636_ETHERNET_100G_SWDM4 : -printf ("%s 100G SWDM4\n" , pfx); +sprintf (value,"%s" ,"100G SWDM4" );break ;case SFF8636_ETHERNET_100G_PAM4_BIDI : -printf ("%s 100G PAM4 BiDi\n" , pfx); +sprintf (value,"%s" ,"100G PAM4 BiDi" );break ;case SFF8636_ETHERNET_4WDM10_MSA : -printf ("%s 4WDM-10 MSA (10km version of 100G CWDM4 with same RS(528,514) FEC in host system)\n" , - pfx); +sprintf (value,"%s" , +"4WDM-10 MSA (10km version of 100G CWDM4 with same RS(528,514) FEC in host system)" );break ;case SFF8636_ETHERNET_4WDM20_MSA : -printf ("%s 4WDM-20 MSA (20km version of 100GBASE-LR4 with RS(528,514) FEC in host system)\n" , - pfx); +sprintf (value,"%s" ,"4WDM-20 MSA (20km version of 100GBASE-LR4 with RS(528,514) FEC in host system)" );break ;case SFF8636_ETHERNET_4WDM40_MSA : -printf ("%s 4WDM-40 MSA (40km reach with APD receiver and RS(528,514) FEC in host system)\n" , - pfx); +sprintf (value,"%s" , +"4WDM-40 MSA (40km reach with APD receiver and RS(528,514) FEC in host system)" );break ;case SFF8636_ETHERNET_100G_DR : -printf ("%s 100GBASE-DR (clause 140), CAUI-4 (no FEC)\n" , pfx); +sprintf (value,"%s" , +"100GBASE-DR (clause 140), CAUI-4 (no FEC)" );break ;case SFF8636_ETHERNET_100G_FR_NOFEC : -printf ("%s 100G-FR or 100GBASE-FR1 (clause 140), CAUI-4 (no FEC)\n" , pfx); +sprintf (value,"%s" , +"100G-FR or 100GBASE-FR1 (clause 140), CAUI-4 (no FEC)" );break ;case SFF8636_ETHERNET_100G_LR_NOFEC : -printf ("%s 100G-LR or 100GBASE-LR1 (clause 140), CAUI-4 (no FEC)\n" , pfx); +sprintf (value,"%s" , +"100G-LR or 100GBASE-LR1 (clause 140), CAUI-4 (no FEC)" );break ;case SFF8636_ETHERNET_200G_ACC1 : -printf ("%s Active Copper Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 10-6 or below\n" , - pfx); +sprintf (value,"%s" , +"Active Copper Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 10-6 or below" );break ;case SFF8636_ETHERNET_200G_AOC1 : -printf ("%s Active Optical Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 10-6 or below\n" , - pfx); +sprintf (value,"%s" , +"Active Optical Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 10-6 or below" );break ;case SFF8636_ETHERNET_200G_ACC2 : -printf ("%s Active Copper Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 2.6x10-4 for ACC, 10-5 for AUI, or below\n" , - pfx); +sprintf (value,"%s" , +"Active Copper Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 2.6x10-4 for ACC, 10-5 for AUI, or below" );break ;case SFF8636_ETHERNET_200G_A0C2 : -printf ("%s Active Optical Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 2.6x10-4 for ACC, 10-5 for AUI, or below\n" , - pfx); +sprintf (value,"%s" , +"Active Optical Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 2.6x10-4 for ACC, 10-5 for AUI, or below" );break ;case SFF8636_ETHERNET_200G_CR4 : -printf ("%s 50GBASE-CR, 100GBASE-CR2, or 200GBASE-CR4\n" , pfx); +sprintf (value,"%s" , +"50GBASE-CR, 100GBASE-CR2, or 200GBASE-CR4" );break ;case SFF8636_ETHERNET_200G_SR4 : -printf ("%s 50GBASE-SR, 100GBASE-SR2, or 200GBASE-SR4\n" , pfx); +sprintf (value,"%s" , +"50GBASE-SR, 100GBASE-SR2, or 200GBASE-SR4" );break ;case SFF8636_ETHERNET_200G_DR4 : -printf ("%s 50GBASE-FR or 200GBASE-DR4\n" , pfx); +sprintf (value,"%s" ,"50GBASE-FR or 200GBASE-DR4" );break ;case SFF8636_ETHERNET_200G_FR4 : -printf ("%s 200GBASE-FR4\n" , pfx); +sprintf (value,"%s" ,"200GBASE-FR4" );break ;case SFF8636_ETHERNET_200G_PSM4 : -printf ("%s 200G 1550 nm PSM4\n" , pfx); +sprintf (value,"%s" ,"200G 1550 nm PSM4" );break ;case SFF8636_ETHERNET_50G_LR : -printf ("%s 50GBASE-LR\n" , pfx); +sprintf (value,"%s" ,"50GBASE-LR" );break ;case SFF8636_ETHERNET_200G_LR4 : -printf ("%s 200GBASE-LR4\n" , pfx); +sprintf (value,"%s" ,"200GBASE-LR4" );break ;case SFF8636_ETHERNET_64G_EA : -printf ("%s 64GFC EA\n" , pfx); +sprintf (value,"%s" ,"64GFC EA" );break ;case SFF8636_ETHERNET_64G_SW : -printf ("%s 64GFC SW\n" , pfx); +sprintf (value,"%s" ,"64GFC SW" );break ;case SFF8636_ETHERNET_64G_LW : -printf ("%s 64GFC LW\n" , pfx); +sprintf (value,"%s" ,"64GFC LW" );break ;case SFF8636_ETHERNET_128FC_EA : -printf ("%s 128GFC EA\n" , pfx); +sprintf (value,"%s" ,"128GFC EA" );break ;case SFF8636_ETHERNET_128FC_SW : -printf ("%s 128GFC SW\n" , pfx); +sprintf (value,"%s" ,"128GFC SW" );break ;case SFF8636_ETHERNET_128FC_LW : -printf ("%s 128GFC LW\n" , pfx); +sprintf (value,"%s" ,"128GFC LW" );break ;default : -printf ("%s (reserved or unknown)\n" , pfx); +sprintf (value,"%s" ,"(reserved or unknown)" );break ; } }
@@ -382,96 +442,98 @@ static void sff8636_show_transceiver(const struct sff8636_memory_map *map)/* SONET Compliance Codes */ if (map->page_00h[SFF8636_SONET_COMP_OFFSET ] & (SFF8636_SONET_40G_OTN )) -printf ("%s 40G OTN (OTU3B/OTU3C)\n" , pfx); +sprintf (value,"%s" ,"40G OTN (OTU3B/OTU3C)" );if (map->page_00h[SFF8636_SONET_COMP_OFFSET ] & (SFF8636_SONET_OC48_LR )) -printf ("%s SONET: OC-48, long reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-48, long reach" );if (map->page_00h[SFF8636_SONET_COMP_OFFSET ] & (SFF8636_SONET_OC48_IR )) -printf ("%s SONET: OC-48, intermediate reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-48, intermediate reach" );if (map->page_00h[SFF8636_SONET_COMP_OFFSET ] & (SFF8636_SONET_OC48_SR )) -printf ("%s SONET: OC-48, short reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-48, short reach" );/* SAS/SATA Compliance Codes */ if (map->page_00h[SFF8636_SAS_COMP_OFFSET ] & (SFF8636_SAS_6G )) -printf ("%s SAS 6.0G\n" , pfx); +sprintf (value,"%s" ,"SAS 6.0G" );if (map->page_00h[SFF8636_SAS_COMP_OFFSET ] & (SFF8636_SAS_3G )) -printf ("%s SAS 3.0G\n" , pfx); +sprintf (value,"%s" ,"SAS 3.0G" );/* Ethernet Compliance Codes */ if (map->page_00h[SFF8636_GIGE_COMP_OFFSET ] &SFF8636_GIGE_1000_BASE_T ) -printf ("%s Ethernet: 1000BASE-T\n" , pfx); +sprintf (value,"%s" ,"Ethernet: 1000BASE-T" );if (map->page_00h[SFF8636_GIGE_COMP_OFFSET ] &SFF8636_GIGE_1000_BASE_CX ) -printf ("%s Ethernet: 1000BASE-CX\n" , pfx); +sprintf (value,"%s" ,"Ethernet: 1000BASE-CX" );if (map->page_00h[SFF8636_GIGE_COMP_OFFSET ] &SFF8636_GIGE_1000_BASE_LX ) -printf ("%s Ethernet: 1000BASE-LX\n" , pfx); +sprintf (value,"%s" ,"Ethernet: 1000BASE-LX" );if (map->page_00h[SFF8636_GIGE_COMP_OFFSET ] &SFF8636_GIGE_1000_BASE_SX ) -printf ("%s Ethernet: 1000BASE-SX\n" , pfx); +sprintf (value,"%s" ,"Ethernet: 1000BASE-SX" );/* Fibre Channel link length */ if (map->page_00h[SFF8636_FC_LEN_OFFSET ] &SFF8636_FC_LEN_VERY_LONG ) -printf ("%s FC: very long distance (V)\n" , pfx); +sprintf (value,"%s" ,"FC: very long distance (V)" );if (map->page_00h[SFF8636_FC_LEN_OFFSET ] &SFF8636_FC_LEN_SHORT ) -printf ("%s FC: short distance (S)\n" , pfx); +sprintf (value,"%s" ,"FC: short distance (S)" );if (map->page_00h[SFF8636_FC_LEN_OFFSET ] &SFF8636_FC_LEN_INT ) -printf ("%s FC: intermediate distance (I)\n" , pfx); +sprintf (value,"%s" ,"FC: intermediate distance (I)" );if (map->page_00h[SFF8636_FC_LEN_OFFSET ] &SFF8636_FC_LEN_LONG ) -printf ("%s FC: long distance (L)\n" , pfx); +sprintf (value,"%s" ,"FC: long distance (L)" );if (map->page_00h[SFF8636_FC_LEN_OFFSET ] &SFF8636_FC_LEN_MED ) -printf ("%s FC: medium distance (M)\n" , pfx); +sprintf (value,"%s" ,"FC: medium distance (M)" );/* Fibre Channel transmitter technology */ if (map->page_00h[SFF8636_FC_LEN_OFFSET ] &SFF8636_FC_TECH_LONG_LC ) -printf ("%s FC: Longwave laser (LC)\n" , pfx); +sprintf (value,"%s" ,"FC: Longwave laser (LC)" );if (map->page_00h[SFF8636_FC_LEN_OFFSET ] &SFF8636_FC_TECH_ELEC_INTER ) -printf ("%s FC: Electrical inter-enclosure (EL)\n" , pfx); +sprintf (value,"%s" ,"FC: Electrical inter-enclosure (EL)" );if (map->page_00h[SFF8636_FC_TECH_OFFSET ] &SFF8636_FC_TECH_ELEC_INTRA ) -printf ("%s FC: Electrical intra-enclosure (EL)\n" , pfx); +sprintf (value,"%s" ,"FC: Electrical intra-enclosure (EL)" );if (map->page_00h[SFF8636_FC_TECH_OFFSET ] &SFF8636_FC_TECH_SHORT_WO_OFC ) -printf ("%s FC: Shortwave laser w/o OFC (SN)\n" , pfx); +sprintf (value,"%s" ,"FC: Shortwave laser w/o OFC (SN)" );if (map->page_00h[SFF8636_FC_TECH_OFFSET ] &SFF8636_FC_TECH_SHORT_W_OFC ) -printf ("%s FC: Shortwave laser with OFC (SL)\n" , pfx); +sprintf (value,"%s" ,"FC: Shortwave laser with OFC (SL)" );if (map->page_00h[SFF8636_FC_TECH_OFFSET ] &SFF8636_FC_TECH_LONG_LL ) -printf ("%s FC: Longwave laser (LL)\n" , pfx); +sprintf (value,"%s" ,"FC: Longwave laser (LL)" );/* Fibre Channel transmission media */ if (map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ] &SFF8636_FC_TRANS_MEDIA_TW ) -printf ("%s FC: Twin Axial Pair (TW)\n" , pfx); +sprintf (value,"%s" ,"FC: Twin Axial Pair (TW)" );if (map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ] &SFF8636_FC_TRANS_MEDIA_TP ) -printf ("%s FC: Twisted Pair (TP)\n" , pfx); +sprintf (value,"%s" ,"FC: Twisted Pair (TP)" );if (map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ] &SFF8636_FC_TRANS_MEDIA_MI ) -printf ("%s FC: Miniature Coax (MI)\n" , pfx); +sprintf (value,"%s" ,"FC: Miniature Coax (MI)" );if (map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ] &SFF8636_FC_TRANS_MEDIA_TV ) -printf ("%s FC: Video Coax (TV)\n" , pfx); +sprintf (value,"%s" ,"FC: Video Coax (TV)" );if (map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ] &SFF8636_FC_TRANS_MEDIA_M6 ) -printf ("%s FC: Multimode, 62.5m (M6)\n" , pfx); +sprintf (value,"%s" ,"FC: Multimode, 62.5m (M6)" );if (map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ] &SFF8636_FC_TRANS_MEDIA_M5 ) -printf ("%s FC: Multimode, 50m (M5)\n" , pfx); +sprintf (value,"%s" ,"FC: Multimode, 50m (M5)" );if (map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ] &SFF8636_FC_TRANS_MEDIA_OM3 ) -printf ("%s FC: Multimode, 50um (OM3)\n" , pfx); +sprintf (value,"%s" ,"FC: Multimode, 50um (OM3)" );if (map->page_00h[SFF8636_FC_TRANS_MEDIA_OFFSET ] &SFF8636_FC_TRANS_MEDIA_SM ) -printf ("%s FC: Single Mode (SM)\n" , pfx); +sprintf (value,"%s" ,"FC: Single Mode (SM)" );/* Fibre Channel speed */ if (map->page_00h[SFF8636_FC_SPEED_OFFSET ] &SFF8636_FC_SPEED_1200_MBPS ) -printf ("%s FC: 1200 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 1200 MBytes/sec" );if (map->page_00h[SFF8636_FC_SPEED_OFFSET ] &SFF8636_FC_SPEED_800_MBPS ) -printf ("%s FC: 800 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 800 MBytes/sec" );if (map->page_00h[SFF8636_FC_SPEED_OFFSET ] &SFF8636_FC_SPEED_1600_MBPS ) -printf ("%s FC: 1600 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 1600 MBytes/sec" );if (map->page_00h[SFF8636_FC_SPEED_OFFSET ] &SFF8636_FC_SPEED_400_MBPS ) -printf ("%s FC: 400 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 400 MBytes/sec" );if (map->page_00h[SFF8636_FC_SPEED_OFFSET ] &SFF8636_FC_SPEED_200_MBPS ) -printf ("%s FC: 200 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 200 MBytes/sec" );if (map->page_00h[SFF8636_FC_SPEED_OFFSET ] &SFF8636_FC_SPEED_100_MBPS ) -printf ("%s FC: 100 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 100 MBytes/sec" ); + +module_print_any_string (pfx, value); }static void sff8636_show_encoding (const struct sff8636_memory_map *map)
@@ -483,8 +545,10 @@ static void sff8636_show_encoding(const struct sff8636_memory_map *map)static void sff8636_show_rate_identifier (const struct sff8636_memory_map *map) {/* TODO: Need to fix rate select logic */ -printf ("\t%-41s : 0x%02x\n" ,"Rate identifier" , - map->page_00h[SFF8636_EXT_RS_OFFSET ]); +sff_print_any_hex_field ("Rate identifier" ,"rate_identifier" , + map->page_00h[SFF8636_EXT_RS_OFFSET ],NULL ); + + } static void
@@ -496,58 +560,65 @@ sff8636_show_wavelength_or_copper_compliance(const struct sff8636_memory_map *mamodule_show_mit_compliance (value);if (value >=SFF8636_TRANS_COPPER_PAS_UNEQUAL ) { -printf ("\t%-41s : %udb\n" ,"Attenuation at 2.5GHz" , - map->page_00h[SFF8636_WAVELEN_HIGH_BYTE_OFFSET ]); -printf ("\t%-41s : %udb\n" ,"Attenuation at 5.0GHz" , - map->page_00h[SFF8636_WAVELEN_LOW_BYTE_OFFSET ]); -printf ("\t%-41s : %udb\n" ,"Attenuation at 7.0GHz" , - map->page_00h[SFF8636_WAVE_TOL_HIGH_BYTE_OFFSET ]); -printf ("\t%-41s : %udb\n" ,"Attenuation at 12.9GHz" , - map->page_00h[SFF8636_WAVE_TOL_LOW_BYTE_OFFSET ]); +module_print_any_uint ("Attenuation at 2.5GHz" , + map->page_00h[SFF8636_WAVELEN_HIGH_BYTE_OFFSET ], +"db" ); +module_print_any_uint ("Attenuation at 5.0GHz" , + map->page_00h[SFF8636_WAVELEN_LOW_BYTE_OFFSET ], +"db" ); +module_print_any_uint ("Attenuation at 7.0GHz" , + map->page_00h[SFF8636_WAVELEN_HIGH_BYTE_OFFSET ], +"db" ); +module_print_any_uint ("Attenuation at 12.9GHz" , + map->page_00h[SFF8636_WAVELEN_LOW_BYTE_OFFSET ], +"db" ); }else { -printf ("\t%-41s : %.3lfnm\n" ,"Laser wavelength" , - (((map->page_00h[SFF8636_WAVELEN_HIGH_BYTE_OFFSET ] <<8 ) | - map->page_00h[SFF8636_WAVELEN_LOW_BYTE_OFFSET ]) *0.05 )); -printf ("\t%-41s : %.3lfnm\n" ,"Laser wavelength tolerance" , - (((map->page_00h[SFF8636_WAVE_TOL_HIGH_BYTE_OFFSET ] <<8 ) | - map->page_00h[SFF8636_WAVE_TOL_LOW_BYTE_OFFSET ]) *0.005 )); +module_print_any_float ("Laser wavelength" , + (((map->page_00h[SFF8636_WAVELEN_HIGH_BYTE_OFFSET ] <<8 ) | + map->page_00h[SFF8636_WAVELEN_LOW_BYTE_OFFSET ]) *0.05 ), +"nm" ); +module_print_any_float ("Laser wavelength tolerance" , + (((map->page_00h[SFF8636_WAVE_TOL_HIGH_BYTE_OFFSET ] <<8 ) | + map->page_00h[SFF8636_WAVE_TOL_LOW_BYTE_OFFSET ]) *0.05 ), +"nm" ); } }static void sff8636_show_revision_compliance (const __u8 *id,int rev_offset) { -static const char *pfx = -"\tRevision Compliance :" ; +const char *pfx ="Revision Compliance" ; +char value[64 ] ="" ;switch (id[rev_offset]) {case SFF8636_REV_UNSPECIFIED : -printf ("%s Revision not specified\n" , pfx); +sprintf (value,"%s" ,"Revision not specified" );break ;case SFF8636_REV_8436_48 : -printf ("%s SFF-8436 Rev 4.8 or earlier\n" , pfx); +sprintf (value,"%s" ,"SFF-8436 Rev 4.8 or earlier" );break ;case SFF8636_REV_8436_8636 : -printf ("%s SFF-8436 Rev 4.8 or earlier\n" , pfx); +sprintf (value,"%s" ,"SFF-8436 Rev 4.8 or earlier" );break ;case SFF8636_REV_8636_13 : -printf ("%s SFF-8636 Rev 1.3 or earlier\n" , pfx); +sprintf (value,"%s" ,"SFF-8636 Rev 1.3 or earlier" );break ;case SFF8636_REV_8636_14 : -printf ("%s SFF-8636 Rev 1.4\n" , pfx); +sprintf (value,"%s" ,"SFF-8636 Rev 1.4" );break ;case SFF8636_REV_8636_15 : -printf ("%s SFF-8636 Rev 1.5\n" , pfx); +sprintf (value,"%s" ,"SFF-8636 Rev 1.5" );break ;case SFF8636_REV_8636_20 : -printf ("%s SFF-8636 Rev 2.0\n" , pfx); +sprintf (value,"%s" ,"SFF-8636 Rev 2.0" );break ;case SFF8636_REV_8636_27 : -printf ("%s SFF-8636 Rev 2.5/2.6/2.7\n" , pfx); +sprintf (value,"%s" ,"SFF-8636 Rev 2.5/2.6/2.7" );break ;default : -printf ("%s Unallocated\n" , pfx); +sprintf (value,"%s" ,"Unallocated" );break ; } +module_print_any_string (pfx, value); }/*
@@ -654,11 +725,18 @@ static void sff8636_show_dom_chan_lvl_tx_bias(const struct sff_diags *sd)char power_string[MAX_DESC_SIZE ];int i; +open_json_array ("laser_tx_bias_current" ,"" );for (i =0 ; i <SFF8636_MAX_CHANNEL_NUM ; i++) { -snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , -"Laser tx bias current" , i+1 ); -PRINT_BIAS (power_string, sd->scd[i].bias_cur); +if (is_json_context ()) { +print_float (PRINT_JSON ,NULL ,"%.3f" , + (double )sd->scd[i].bias_cur /500. ); + }else { +snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , +"Laser tx bias current" , i+1 ); +PRINT_BIAS (power_string, sd->scd[i].bias_cur); + } } +close_json_array ("" ); }static void sff8636_show_dom_chan_lvl_tx_power (const struct sff_diags *sd)
@@ -666,29 +744,49 @@ static void sff8636_show_dom_chan_lvl_tx_power(const struct sff_diags *sd)char power_string[MAX_DESC_SIZE ];int i; +open_json_array ("transmit_avg_optical_power" ,"" );for (i =0 ; i <SFF8636_MAX_CHANNEL_NUM ; i++) { -snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , -"Transmit avg optical power" , i+1 ); -PRINT_xX_PWR (power_string, sd->scd[i].tx_power); +if (is_json_context ()) { +print_float (PRINT_JSON ,NULL ,"%.4f" , + (double )sd->scd[i].tx_power /10000. ); + }else { +snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , +"Transmit avg optical power" , i+1 ); +PRINT_xX_PWR (power_string, sd->scd[i].tx_power); + } } +close_json_array ("" ); }static void sff8636_show_dom_chan_lvl_rx_power (const struct sff_diags *sd) { +char *rx_power_type_string =NULL ;char power_string[MAX_DESC_SIZE ]; -char *rx_power_string =NULL ;int i;if (!sd->rx_power_type) - rx_power_string ="Receiver signal OMA" ; + rx_power_type_string ="Receiver signal OMA" ;else - rx_power_string ="Rcvr signal avg optical power" ; + rx_power_type_string ="Rcvr signal avg optical power" ; +open_json_object ("rx_power" ); + +open_json_array ("values" ,"" );for (i =0 ; i <SFF8636_MAX_CHANNEL_NUM ; i++) { -snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , - rx_power_string, i+1 ); -PRINT_xX_PWR (power_string, sd->scd[i].rx_power); +if (is_json_context ()) { +print_float (PRINT_JSON ,NULL ,"%.4f" , + (double )sd->scd[i].rx_power /10000. ); + }else { +snprintf (power_string,MAX_DESC_SIZE ,"%s (Channel %d)" , + rx_power_type_string, i+1 ); +PRINT_xX_PWR (power_string, sd->scd[i].rx_power); + } } +close_json_array ("" ); + +if (is_json_context ()) +module_print_any_string ("type" , rx_power_type_string); +close_json_object (); } static void
@@ -698,29 +796,53 @@ sff8636_show_dom_chan_lvl_flags(const struct sff8636_memory_map *map)int i;for (i =0 ; module_aw_chan_flags[i].fmt_str; ++i) { +bool is_start = (i %SFF8636_MAX_CHANNEL_NUM ==0 ); +bool is_end = (i %SFF8636_MAX_CHANNEL_NUM == +SFF8636_MAX_CHANNEL_NUM -1 ); +char json_str[80 ] = {}; +char str[80 ] = {}; +if (module_aw_chan_flags[i].type !=MODULE_TYPE_SFF8636 )continue ; +convert_json_field_name (module_aw_chan_flags[i].fmt_str, + json_str); + value = map->lower_memory[module_aw_chan_flags[i].offset] & module_aw_chan_flags[i].adver_value; -printf ("\t%-41s (Chan %d) : %s\n" , - module_aw_chan_flags[i].fmt_str, - (i %SFF8636_MAX_CHANNEL_NUM ) +1 , - value ?"On" :"Off" ); +if (is_json_context ()) { +if (is_start) +open_json_array (json_str,"" ); + +print_bool (PRINT_JSON ,NULL ,NULL , value); + +if (is_end) +close_json_array ("" ); + }else { +snprintf (str,80 ,"%s (Chan %d)" , + module_aw_chan_flags[i].fmt_str, + (i %SFF8636_MAX_CHANNEL_NUM ) +1 ); +printf ("\t%-41s : %s\n" , str,ONOFF (value)); + } + } }static void sff8636_show_dom_mod_lvl_flags (const struct sff8636_memory_map *map) { +bool value;int i;for (i =0 ; module_aw_mod_flags[i].str; ++i) { -if (module_aw_mod_flags[i].type ==MODULE_TYPE_SFF8636 ) -printf ("\t%-41s : %s\n" , - module_aw_mod_flags[i].str, -ONOFF (map->lower_memory[module_aw_mod_flags[i].offset] - & module_aw_mod_flags[i].value)); +if (module_aw_mod_flags[i].type !=MODULE_TYPE_SFF8636 ) +continue ; + + value = map->lower_memory[module_aw_mod_flags[i].offset] & + module_aw_mod_flags[i].value; + +module_print_any_bool (module_aw_mod_flags[i].str,NULL , + value,ONOFF (value)); } }
@@ -756,8 +878,9 @@ static void sff8636_show_dom(const struct sff8636_memory_map *map) (sd.sfp_temp[MCURR] == (__s16)0xFFFF))return ; -printf ("\t%-41s : %s\n" ,"Alarm/warning flags implemented" , - (sd.supports_alarms ?"Yes" :"No" )); +module_print_any_bool ("Alarm/warning flags implemented" , +"alarm/warning_flags_implemented" , + sd.supports_alarms,YESNO (sd.supports_alarms));sff8636_show_dom_chan_lvl_tx_bias (&sd);sff8636_show_dom_chan_lvl_tx_power (&sd);
@@ -767,7 +890,10 @@ static void sff8636_show_dom(const struct sff8636_memory_map *map)sff8636_show_dom_chan_lvl_flags (map);sff8636_show_dom_mod_lvl_flags (map); -sff_show_thresholds (sd); +if (is_json_context ()) +sff_show_thresholds_json (sd); +else +sff_show_thresholds (sd); } }
@@ -808,7 +934,7 @@ static void sff8636_show_page_zero(const struct sff8636_memory_map *map)sff8636_show_transceiver (map);sff8636_show_encoding (map);module_show_value_with_unit (map->page_00h,SFF8636_BR_NOMINAL_OFFSET , -"BR, Nominal" ,100 ,"Mbps" ); +"BR Nominal" ,100 ,"Mbps" );sff8636_show_rate_identifier (map);module_show_value_with_unit (map->page_00h,SFF8636_SM_LEN_OFFSET ,"Length (SMF)" ,1 ,"km" );
Signature · 1 line
2.47.0
PATCH v4 11/16 qsfp: Enable JSON output support for SFF8636 modules
In reply to Danielle RatsonA sample output:
$ ethtool --json -m swp13
[ {
"identifier": 17,
"identifier_description": "QSFP28",
"extended_identifier": {
"value": 207,
"description": "3.5W max. Power consumption",
"description": "CDR present in TX, CDR present in RX",
"description": "5.0W max. Power consumption, High Power
Class (> 3.5 W) enabled"
},
"power_set": false,
"power_override": true,
"connector": 35,
"connector_description": "No separable connector",
"transceiver_codes": [ 128,0,0,0,0,0,0,0 ],
"transceiver_type": "Active Optical Cable with 50GAUI, 100GAUI-2
or 200GAUI-4 C2M. Providing a worst BER of 10-6 or below",
"encoding": 8,
"encoding_description": "PAM4",
"br_nominal": 25500,
"rate_identifier": 2,
"length_(smf)": 0,
"length_(om3)": 0,
"length_(om2)": 0,
"length_(om1)": 0,
"length_(copper_or_active_cable)": 3,
"transmitter_technology": 0,
"transmitter_technology_description": "850 nm VCSEL",
"laser_wavelength": 850,
"laser_wavelength_tolerance": 150,
"vendor_name": "Mellanox",
"vendor_oui": [ 0,2,201 ],
"vendor_pn": "MFS1S00-V003E",
"vendor_rev": "A6",
"vendor_sn": "MT1915FT03913",
"date_code": "190412",
"revision_compliance": "Unallocated",
"rx_loss_of_signal": [ "Yes","Yes","Yes","Yes" ],
"tx_loss_of_signal": false,
"rx_loss_of_lock": [ "Yes","Yes","Yes","Yes" ],
"tx_loss_of_lock": false,
"tx_adaptive_eq_fault": false,
"module_temperature": 56.9805,
"module_voltage": 3.259,
"alarm/warning_flags_implemented": true,
"laser_tx_bias_current": [ 0,0,0,0 ],
"transmit_avg_optical_power": [ 0,0,0,0 ],
"rx_power": {
"values": [ 0.0449,0.0475,0.042,0.0394 ],
"type": "Rcvr signal avg optical power"
},
"laser_bias_current_high_alarm": [ false,false,false,false ],
"laser_bias_current_low_alarm": [ false,false,false,false ],
"laser_bias_current_high_warning": [ false,false,false,false ],
"laser_bias_current_low_warning": [ false,false,false,false ],
"laser_tx_power_high_alarm": [ false,false,false,false ],
"laser_tx_power_low_alarm": [ false,false,false,false ],
"laser_tx_power_high_warning": [ false,false,false,false ],
"laser_tx_power_low_warning": [ false,false,false,false ],
"laser_rx_power_high_alarm": [ false,false,false,false ],
"laser_rx_power_low_alarm": [ true,true,true,true ],
"laser_rx_power_high_warning": [ false,false,false,false ],
"laser_rx_power_low_warning": [ true,true,true,true ],
"module_temperature_high_alarm": false,
"module_temperature_low_alarm": false,
"module_temperature_high_warning": false,
"module_temperature_low_warning": false,
"module_voltage_high_alarm": false,
"module_voltage_low_alarm": false,
"module_voltage_high_warning": false,
"module_voltage_low_warning": false,
"laser_bias_current": {
"high_alarm_threshold": 8.5,
"low_alarm_threshold": 5.492,
"high_warning_threshold": 8,
"low_warning_threshold": 6
},
"laser_output_power": {
"high_alarm_threshold": 3.4673,
"low_alarm_threshold": 0.0724,
"high_warning_threshold": 1.7378,
"low_warning_threshold": 0.1445
},
"module_temperature": {
"high_alarm_threshold": 80,
"low_alarm_threshold": -10,
"high_warning_threshold": 70,
"low_warning_threshold": 0
},
"module_voltage": {
"high_alarm_threshold": 3.5,
"low_alarm_threshold": 3.1,
"high_warning_threshold": 3.465,
"low_warning_threshold": 3.135
},
"laser_rx_power": {
"high_alarm_threshold": 3.4673,
"low_alarm_threshold": 0.0467,
"high_warning_threshold": 1.7378,
"low_warning_threshold": 0.0933
}
} ]---
Notes:
v3:
* Reword commit message.
qsfp.c | 6 ++++++ 1 file changed, 6 insertions(+)
qsfp.c +6 -0
@@ -1083,10 +1083,16 @@ int sff8636_show_all_nl(struct cmd_context *ctx)struct sff8636_memory_map map = {};int ret; +new_json_obj (ctx->json); +open_json_object (NULL ); + ret =sff8636_memory_map_init_pages (ctx, &map);if (ret <0 )return ret;sff8636_show_all_common (&map); +close_json_object (); +delete_json_obj (); +return 0 ; }
Signature · 1 line
2.47.0
Jakub Kicinski
maintainerRe: [PATCH ethtool-next v4 11/16] qsfp: Enable JSON output support for SFF8636 modules
Quoted 7 lines · On Wed, 5 Feb 2025 17:54:31 +0200 Danielle Ratson wrote:
"
extended_identifier": {
"value": 207,
"description": "3.5W max. Power consumption", "description": "CDR present in TX, CDR present in RX", "description": "5.0W max. Power consumption, High Power
Class (> 3.5 W) enabled"},
Commit message needs updatin', code looks good.
PATCH v4 12/16 sfpid: Add JSON output handling to --module-info in SFF8079 modules
In reply to Danielle RatsonAdd JSON output handling for 'ethtool -m' / --module-info, following the guideline below:
1. Fields with description, will have a separate description field.
2. Units will be documented in a separate module-info.json file.
3. ASCII fields will be presented as strings.
4. On/Off is rendered as true/false.
5. Yes/no is rendered as true/false.
6. Per-channel fields will be presented as array, when each element represents a channel.
7. Fields that hold version, will be split to major and minor sub fields.
---
Notes:
v3:
* Remove unit fields.
* Reword commit message.
* Remove printings from fields that might be empty strings.
v2:
* Use uint instead of hexa fields in JSON context.
sfpid.c | 381 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 222 insertions(+), 159 deletions(-)
sfpid.c +222 -159
@@ -24,15 +24,22 @@ static void sff8079_show_identifier(const __u8 *id)static void sff8079_show_ext_identifier (const __u8 *id) { -printf ("\t%-41s : 0x%02x" ,"Extended identifier" , id[1 ]); +char description[SFF_MAX_DESC_LEN ]; +if (id[1 ] ==0x00 ) -printf (" (GBIC not specified / not MOD_DEF compliant)\n" ); +sprintf (description,"%s" , +"GBIC not specified / not MOD_DEF compliant" );else if (id[1 ] ==0x04 ) -printf (" (GBIC/SFP defined by 2-wire interface ID)\n" ); +sprintf (description,"%s" , +"GBIC/SFP defined by 2-wire interface ID" );else if (id[1 ] <=0x07 ) -printf (" (GBIC compliant with MOD_DEF %u)\n" , id[1 ]); +sprintf (description,"%s %u" ,"GBIC compliant with MOD_DEF" , + id[1 ]);else -printf (" (unknown)\n" ); +sprintf (description,"%s" ,"unknown" ); + +sff_print_any_hex_field ("Extended identifier" ,"extended_identifier" , + id[1 ], description); }static void sff8079_show_connector (const __u8 *id)
@@ -42,231 +49,259 @@ static void sff8079_show_connector(const __u8 *id)static void sff8079_show_transceiver (const __u8 *id) { -static const char *pfx = -"\tTransceiver type :" ; - -printf ("\t%-41s : 0x%02x 0x%02x 0x%02x " \ -"0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n" , -"Transceiver codes" , - id[3 ], id[4 ], id[5 ], id[6 ], - id[7 ], id[8 ], id[9 ], id[10 ], id[36 ]); +static const char *pfx ="Transceiver type" ; +char value[140 ] ="" ; + +if (is_json_context ()) { +open_json_array ("transceiver_codes" ,"" ); +print_uint (PRINT_JSON ,NULL ,"%u" , id[3 ]); +print_uint (PRINT_JSON ,NULL ,"%u" , id[4 ]); +print_uint (PRINT_JSON ,NULL ,"%u" , id[5 ]); +print_uint (PRINT_JSON ,NULL ,"%u" , id[6 ]); +print_uint (PRINT_JSON ,NULL ,"%u" , id[7 ]); +print_uint (PRINT_JSON ,NULL ,"%u" , id[8 ]); +print_uint (PRINT_JSON ,NULL ,"%u" , id[9 ]); +print_uint (PRINT_JSON ,NULL ,"%u" , id[10 ]); +print_uint (PRINT_JSON ,NULL ,"%u" , id[36 ]); +close_json_array ("" ); + }else { +printf ("\t%-41s : 0x%02x 0x%02x 0x%02x " \ +"0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n" , +"Transceiver codes" , id[3 ], id[4 ], id[5 ], id[6 ], + id[7 ], id[8 ], id[9 ], id[10 ], id[36 ]); + }/* 10G Ethernet Compliance Codes */ if (id[3 ] & (1 <<7 )) -printf ("%s 10G Ethernet: 10G Base-ER" \ -" [SFF-8472 rev10.4 onwards]\n" , pfx); +sprintf (value,"%s" , +"10G Ethernet: 10G Base-LRM [SFF-8472 rev10.4 onwards]" );if (id[3 ] & (1 <<6 )) -printf ("%s 10G Ethernet: 10G Base-LRM\n" , pfx); +sprintf (value,"%s" ,"10G Ethernet: 10G Base-LRM" );if (id[3 ] & (1 <<5 )) -printf ("%s 10G Ethernet: 10G Base-LR\n" , pfx); +sprintf (value,"%s" ,"10G Ethernet: 10G Base-LR" );if (id[3 ] & (1 <<4 )) -printf ("%s 10G Ethernet: 10G Base-SR\n" , pfx); +sprintf (value,"%s" ,"10G Ethernet: 10G Base-SR" );/* Infiniband Compliance Codes */ if (id[3 ] & (1 <<3 )) -printf ("%s Infiniband: 1X SX\n" , pfx); +sprintf (value,"%s" ,"Infiniband: 1X SX" );if (id[3 ] & (1 <<2 )) -printf ("%s Infiniband: 1X LX\n" , pfx); +sprintf (value,"%s" ,"Infiniband: 1X LX" );if (id[3 ] & (1 <<1 )) -printf ("%s Infiniband: 1X Copper Active\n" , pfx); +sprintf (value,"%s" ,"Infiniband: 1X Copper Active" );if (id[3 ] & (1 <<0 )) -printf ("%s Infiniband: 1X Copper Passive\n" , pfx); +sprintf (value,"%s" ,"Infiniband: 1X Copper Passive" );/* ESCON Compliance Codes */ if (id[4 ] & (1 <<7 )) -printf ("%s ESCON: ESCON MMF, 1310nm LED\n" , pfx); +sprintf (value,"%s" ,"ESCON: ESCON MMF, 1310nm LED" );if (id[4 ] & (1 <<6 )) -printf ("%s ESCON: ESCON SMF, 1310nm Laser\n" , pfx); +sprintf (value,"%s" ,"ESCON: ESCON SMF, 1310nm Laser" );/* SONET Compliance Codes */ if (id[4 ] & (1 <<5 )) -printf ("%s SONET: OC-192, short reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-192, short reach" );if (id[4 ] & (1 <<4 )) -printf ("%s SONET: SONET reach specifier bit 1\n" , pfx); +sprintf (value,"%s" ,"SONET: SONET reach specifier bit 1" );if (id[4 ] & (1 <<3 )) -printf ("%s SONET: SONET reach specifier bit 2\n" , pfx); +sprintf (value,"%s" ,"SONET: SONET reach specifier bit 2" );if (id[4 ] & (1 <<2 )) -printf ("%s SONET: OC-48, long reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-48, long reach" );if (id[4 ] & (1 <<1 )) -printf ("%s SONET: OC-48, intermediate reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-48, intermediate reach" );if (id[4 ] & (1 <<0 )) -printf ("%s SONET: OC-48, short reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-48, short reach" );if (id[5 ] & (1 <<6 )) -printf ("%s SONET: OC-12, single mode, long reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-12, single mode, long reach" );if (id[5 ] & (1 <<5 )) -printf ("%s SONET: OC-12, single mode, inter. reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-12, single mode, inter. reach" );if (id[5 ] & (1 <<4 )) -printf ("%s SONET: OC-12, short reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-12, short reach" );if (id[5 ] & (1 <<2 )) -printf ("%s SONET: OC-3, single mode, long reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-3, single mode, long reach" );if (id[5 ] & (1 <<1 )) -printf ("%s SONET: OC-3, single mode, inter. reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-3, single mode, inter. reach" );if (id[5 ] & (1 <<0 )) -printf ("%s SONET: OC-3, short reach\n" , pfx); +sprintf (value,"%s" ,"SONET: OC-3, short reach" );/* Ethernet Compliance Codes */ if (id[6 ] & (1 <<7 )) -printf ("%s Ethernet: BASE-PX\n" , pfx); +sprintf (value,"%s" ,"Ethernet: BASE-PX" );if (id[6 ] & (1 <<6 )) -printf ("%s Ethernet: BASE-BX10\n" , pfx); +sprintf (value,"%s" ,"Ethernet: BASE-BX10" );if (id[6 ] & (1 <<5 )) -printf ("%s Ethernet: 100BASE-FX\n" , pfx); +sprintf (value,"%s" ,"Ethernet: 100BASE-FX" );if (id[6 ] & (1 <<4 )) -printf ("%s Ethernet: 100BASE-LX/LX10\n" , pfx); +sprintf (value,"%s" ,"Ethernet: 100BASE-LX/LX10" );if (id[6 ] & (1 <<3 )) -printf ("%s Ethernet: 1000BASE-T\n" , pfx); +sprintf (value,"%s" ,"Ethernet: 1000BASE-T" );if (id[6 ] & (1 <<2 )) -printf ("%s Ethernet: 1000BASE-CX\n" , pfx); +sprintf (value,"%s" ,"Ethernet: 1000BASE-CX" );if (id[6 ] & (1 <<1 )) -printf ("%s Ethernet: 1000BASE-LX\n" , pfx); +sprintf (value,"%s" ,"Ethernet: 1000BASE-LX" );if (id[6 ] & (1 <<0 )) -printf ("%s Ethernet: 1000BASE-SX\n" , pfx); +sprintf (value,"%s" ,"Ethernet: 1000BASE-SX" );/* Fibre Channel link length */ if (id[7 ] & (1 <<7 )) -printf ("%s FC: very long distance (V)\n" , pfx); +sprintf (value,"%s" ,"FC: very long distance (V)" );if (id[7 ] & (1 <<6 )) -printf ("%s FC: short distance (S)\n" , pfx); +sprintf (value,"%s" ,"FC: short distance (S)" );if (id[7 ] & (1 <<5 )) -printf ("%s FC: intermediate distance (I)\n" , pfx); +sprintf (value,"%s" ,"FC: intermediate distance (I)" );if (id[7 ] & (1 <<4 )) -printf ("%s FC: long distance (L)\n" , pfx); +sprintf (value,"%s" ,"FC: long distance (L)" );if (id[7 ] & (1 <<3 )) -printf ("%s FC: medium distance (M)\n" , pfx); +sprintf (value,"%s" ,"FC: medium distance (M)" );/* Fibre Channel transmitter technology */ if (id[7 ] & (1 <<2 )) -printf ("%s FC: Shortwave laser, linear Rx (SA)\n" , pfx); +sprintf (value,"%s" ,"FC: Shortwave laser, linear Rx (SA)" );if (id[7 ] & (1 <<1 )) -printf ("%s FC: Longwave laser (LC)\n" , pfx); +sprintf (value,"%s" ,"FC: Longwave laser (LC)" );if (id[7 ] & (1 <<0 )) -printf ("%s FC: Electrical inter-enclosure (EL)\n" , pfx); +sprintf (value,"%s" ,"FC: Electrical inter-enclosure (EL)" );if (id[8 ] & (1 <<7 )) -printf ("%s FC: Electrical intra-enclosure (EL)\n" , pfx); +sprintf (value,"%s" ,"FC: Electrical intra-enclosure (EL)" );if (id[8 ] & (1 <<6 )) -printf ("%s FC: Shortwave laser w/o OFC (SN)\n" , pfx); +sprintf (value,"%s" ,"FC: Shortwave laser w/o OFC (SN)" );if (id[8 ] & (1 <<5 )) -printf ("%s FC: Shortwave laser with OFC (SL)\n" , pfx); +sprintf (value,"%s" ,"FC: Shortwave laser with OFC (SL)" );if (id[8 ] & (1 <<4 )) -printf ("%s FC: Longwave laser (LL)\n" , pfx); +sprintf (value,"%s" ,"FC: Longwave laser (LL)" );if (id[8 ] & (1 <<3 )) -printf ("%s Active Cable\n" , pfx); +sprintf (value,"%s" ,"Active Cable" );if (id[8 ] & (1 <<2 )) -printf ("%s Passive Cable\n" , pfx); +sprintf (value,"%s" ,"Passive Cable" );if (id[8 ] & (1 <<1 )) -printf ("%s FC: Copper FC-BaseT\n" , pfx); +sprintf (value,"%s" ,"FC: Copper FC-BaseT" );/* Fibre Channel transmission media */ if (id[9 ] & (1 <<7 )) -printf ("%s FC: Twin Axial Pair (TW)\n" , pfx); +sprintf (value,"%s" ,"FC: Twin Axial Pair (TW)" );if (id[9 ] & (1 <<6 )) -printf ("%s FC: Twisted Pair (TP)\n" , pfx); +sprintf (value,"%s" ,"FC: Twisted Pair (TP)" );if (id[9 ] & (1 <<5 )) -printf ("%s FC: Miniature Coax (MI)\n" , pfx); +sprintf (value,"%s" ,"FC: Miniature Coax (MI)" );if (id[9 ] & (1 <<4 )) -printf ("%s FC: Video Coax (TV)\n" , pfx); +sprintf (value,"%s" ,"FC: Video Coax (TV)" );if (id[9 ] & (1 <<3 )) -printf ("%s FC: Multimode, 62.5um (M6)\n" , pfx); +sprintf (value,"%s" ,"FC: Multimode, 62.5um (M6)" );if (id[9 ] & (1 <<2 )) -printf ("%s FC: Multimode, 50um (M5)\n" , pfx); +sprintf (value,"%s" ,"FC: Multimode, 50um (M5)" );if (id[9 ] & (1 <<0 )) -printf ("%s FC: Single Mode (SM)\n" , pfx); +sprintf (value,"%s" ,"FC: Single Mode (SM)" );/* Fibre Channel speed */ if (id[10 ] & (1 <<7 )) -printf ("%s FC: 1200 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 1200 MBytes/sec" );if (id[10 ] & (1 <<6 )) -printf ("%s FC: 800 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 800 MBytes/sec" );if (id[10 ] & (1 <<4 )) -printf ("%s FC: 400 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 400 MBytes/sec" );if (id[10 ] & (1 <<2 )) -printf ("%s FC: 200 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 200 MBytes/sec" );if (id[10 ] & (1 <<0 )) -printf ("%s FC: 100 MBytes/sec\n" , pfx); +sprintf (value,"%s" ,"FC: 100 MBytes/sec" );/* Extended Specification Compliance Codes from SFF-8024 */ if (id[36 ] ==0x1 ) -printf ("%s Extended: 100G AOC or 25GAUI C2M AOC with worst BER of 5x10^(-5)\n" , pfx); +sprintf (value,"%s" , +"Extended: 100G AOC or 25GAUI C2M AOC with worst BER of 5x10^(-5)" );if (id[36 ] ==0x2 ) -printf ("%s Extended: 100G Base-SR4 or 25GBase-SR\n" , pfx); +sprintf (value,"%s" ,"Extended: 100G Base-SR4 or 25GBase-SR" );if (id[36 ] ==0x3 ) -printf ("%s Extended: 100G Base-LR4 or 25GBase-LR\n" , pfx); +sprintf (value,"%s" ,"Extended: 100G Base-LR4 or 25GBase-LR" );if (id[36 ] ==0x4 ) -printf ("%s Extended: 100G Base-ER4 or 25GBase-ER\n" , pfx); +sprintf (value,"%s" ,"Extended: 100G Base-ER4 or 25GBase-ER" );if (id[36 ] ==0x8 ) -printf ("%s Extended: 100G ACC or 25GAUI C2M ACC with worst BER of 5x10^(-5)\n" , pfx); +sprintf (value,"%s" , +"Extended: 100G ACC or 25GAUI C2M ACC with worst BER of 5x10^(-5)" );if (id[36 ] ==0xb ) -printf ("%s Extended: 100G Base-CR4 or 25G Base-CR CA-L\n" , pfx); +sprintf (value,"%s" , +"Extended: 100G Base-CR4 or 25G Base-CR CA-L" );if (id[36 ] ==0xc ) -printf ("%s Extended: 25G Base-CR CA-S\n" , pfx); +sprintf (value,"%s" ,"Extended: 25G Base-CR CA-S" );if (id[36 ] ==0xd ) -printf ("%s Extended: 25G Base-CR CA-N\n" , pfx); +sprintf (value,"%s" ,"Extended: 25G Base-CR CA-N" );if (id[36 ] ==0x16 ) -printf ("%s Extended: 10Gbase-T with SFI electrical interface\n" , pfx); +sprintf (value,"%s" , +"Extended: 10Gbase-T with SFI electrical interface" );if (id[36 ] ==0x18 ) -printf ("%s Extended: 100G AOC or 25GAUI C2M AOC with worst BER of 10^(-12)\n" , pfx); +sprintf (value,"%s" , +"Extended: 100G AOC or 25GAUI C2M AOC with worst BER of 10^(-12)" );if (id[36 ] ==0x19 ) -printf ("%s Extended: 100G ACC or 25GAUI C2M ACC with worst BER of 10^(-12)\n" , pfx); +sprintf (value,"%s" , +"Extended: 100G ACC or 25GAUI C2M ACC with worst BER of 10^(-12)" );if (id[36 ] ==0x1a ) -printf ("%s Extended: 100GE-DWDM2 (DWDM transceiver using 2 wavelengths on a 1550 nm DWDM grid with a reach up to 80 km)\n" , - pfx); +sprintf (value,"%s" , +"Extended: 100GE-DWDM2 (DWDM transceiver using 2 wavelengths on a 1550 nm DWDM grid with a reach up to 80 km)" );if (id[36 ] ==0x1b ) -printf ("%s Extended: 100G 1550nm WDM (4 wavelengths)\n" , pfx); +sprintf (value,"%s" , +"Extended: 100G 1550nm WDM (4 wavelengths)" );if (id[36 ] ==0x1c ) -printf ("%s Extended: 10Gbase-T Short Reach\n" , pfx); +sprintf (value,"%s" ,"Extended: 10Gbase-T Short Reach" );if (id[36 ] ==0x1d ) -printf ("%s Extended: 5GBASE-T\n" , pfx); +sprintf (value,"%s" ,"Extended: 5GBASE-T" );if (id[36 ] ==0x1e ) -printf ("%s Extended: 2.5GBASE-T\n" , pfx); +sprintf (value,"%s" ,"Extended: 2.5GBASE-T" );if (id[36 ] ==0x1f ) -printf ("%s Extended: 40G SWDM4\n" , pfx); +sprintf (value,"%s" ,"Extended: 40G SWDM4" );if (id[36 ] ==0x20 ) -printf ("%s Extended: 100G SWDM4\n" , pfx); +sprintf (value,"%s" ,"Extended: 100G SWDM4" );if (id[36 ] ==0x21 ) -printf ("%s Extended: 100G PAM4 BiDi\n" , pfx); +sprintf (value,"%s" ,"Extended: 100G PAM4 BiDi" );if (id[36 ] ==0x22 ) -printf ("%s Extended: 4WDM-10 MSA (10km version of 100G CWDM4 with same RS(528,514) FEC in host system)\n" , - pfx); +sprintf (value,"%s" , +"Extended: 4WDM-10 MSA (10km version of 100G CWDM4 with same RS(528,514) FEC in host system)" );if (id[36 ] ==0x23 ) -printf ("%s Extended: 4WDM-20 MSA (20km version of 100GBASE-LR4 with RS(528,514) FEC in host system)\n" , - pfx); +sprintf (value,"%s" , +"Extended: 4WDM-20 MSA (20km version of 100GBASE-LR4 with RS(528,514) FEC in host system)" );if (id[36 ] ==0x24 ) -printf ("%s Extended: 4WDM-40 MSA (40km reach with APD receiver and RS(528,514) FEC in host system)\n" , - pfx); +sprintf (value,"%s" , +"Extended: 4WDM-40 MSA (40km reach with APD receiver and RS(528,514) FEC in host system)" );if (id[36 ] ==0x25 ) -printf ("%s Extended: 100GBASE-DR (clause 140), CAUI-4 (no FEC)\n" , pfx); +sprintf (value,"%s" , +"Extended: 100GBASE-DR (clause 140), CAUI-4 (no FEC)" );if (id[36 ] ==0x26 ) -printf ("%s Extended: 100G-FR or 100GBASE-FR1 (clause 140), CAUI-4 (no FEC)\n" , pfx); +sprintf (value,"%s" , +"Extended: 100G-FR or 100GBASE-FR1 (clause 140), CAUI-4 (no FEC)" );if (id[36 ] ==0x27 ) -printf ("%s Extended: 100G-LR or 100GBASE-LR1 (clause 140), CAUI-4 (no FEC)\n" , pfx); +sprintf (value,"%s" , +"Extended: 100G-LR or 100GBASE-LR1 (clause 140), CAUI-4 (no FEC)" );if (id[36 ] ==0x30 ) -printf ("%s Extended: Active Copper Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 10-6 or below\n" , - pfx); +sprintf (value,"%s" , +"Extended: Active Copper Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 10-6 or below" );if (id[36 ] ==0x31 ) -printf ("%s Extended: Active Optical Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 10-6 or below\n" , - pfx); +sprintf (value,"%s" , +"Extended: Active Optical Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 10-6 or below" );if (id[36 ] ==0x32 ) -printf ("%s Extended: Active Copper Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 2.6x10-4 for ACC, 10-5 for AUI, or below\n" , - pfx); +sprintf (value,"%s" , +"Extended: Active Copper Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 2.6x10-4 for ACC, 10-5 for AUI, or below" );if (id[36 ] ==0x33 ) -printf ("%s Extended: Active Optical Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 2.6x10-4 for ACC, 10-5 for AUI, or below\n" , - pfx); +sprintf (value,"%s" , +"Extended: Active Optical Cable with 50GAUI, 100GAUI-2 or 200GAUI-4 C2M. Providing a worst BER of 2.6x10-4 for ACC, 10-5 for AUI, or below" );if (id[36 ] ==0x40 ) -printf ("%s Extended: 50GBASE-CR, 100GBASE-CR2, or 200GBASE-CR4\n" , pfx); +sprintf (value,"%s" , +"Extended: 50GBASE-CR, 100GBASE-CR2, or 200GBASE-CR4" );if (id[36 ] ==0x41 ) -printf ("%s Extended: 50GBASE-SR, 100GBASE-SR2, or 200GBASE-SR4\n" , pfx); +sprintf (value,"%s" , +"Extended: 50GBASE-SR, 100GBASE-SR2, or 200GBASE-SR4" );if (id[36 ] ==0x42 ) -printf ("%s Extended: 50GBASE-FR or 200GBASE-DR4\n" , pfx); +sprintf (value,"%s" ,"Extended: 50GBASE-FR or 200GBASE-DR4" );if (id[36 ] ==0x43 ) -printf ("%s Extended: 200GBASE-FR4\n" , pfx); +sprintf (value,"%s" ,"Extended: 200GBASE-FR4" );if (id[36 ] ==0x44 ) -printf ("%s Extended: 200G 1550 nm PSM4\n" , pfx); +sprintf (value,"%s" ,"Extended: 200G 1550 nm PSM4" );if (id[36 ] ==0x45 ) -printf ("%s Extended: 50GBASE-LR\n" , pfx); +sprintf (value,"%s" ,"Extended: 50GBASE-LR" );if (id[36 ] ==0x46 ) -printf ("%s Extended: 200GBASE-LR4\n" , pfx); +sprintf (value,"%s" ,"Extended: 200GBASE-LR4" );if (id[36 ] ==0x50 ) -printf ("%s Extended: 64GFC EA\n" , pfx); +sprintf (value,"%s" ,"Extended: 64GFC EA" );if (id[36 ] ==0x51 ) -printf ("%s Extended: 64GFC SW\n" , pfx); +sprintf (value,"%s" ,"Extended: 64GFC SW" );if (id[36 ] ==0x52 ) -printf ("%s Extended: 64GFC LW\n" , pfx); +sprintf (value,"%s" ,"Extended: 64GFC LW" );if (id[36 ] ==0x53 ) -printf ("%s Extended: 128GFC EA\n" , pfx); +sprintf (value,"%s" ,"Extended: 128GFC EA" );if (id[36 ] ==0x54 ) -printf ("%s Extended: 128GFC SW\n" , pfx); +sprintf (value,"%s" ,"Extended: 128GFC SW" );if (id[36 ] ==0x55 ) -printf ("%s Extended: 128GFC LW\n" , pfx); +sprintf (value,"%s" ,"Extended: 128GFC LW" ); + +if (value[0 ] !='\0' ) +module_print_any_string (pfx, value); }static void sff8079_show_encoding (const __u8 *id)
@@ -276,100 +311,128 @@ static void sff8079_show_encoding(const __u8 *id)static void sff8079_show_rate_identifier (const __u8 *id) { -printf ("\t%-41s : 0x%02x" ,"Rate identifier" , id[13 ]); +char description[SFF_MAX_DESC_LEN ]; +switch (id[13 ]) {case 0x00 : -printf (" (unspecified)\n" ); +sprintf (description,"%s" ,"unspecified" );break ;case 0x01 : -printf (" (4/2/1G Rate_Select & AS0/AS1)\n" ); +sprintf (description,"%s" ,"4/2/1G Rate_Select & AS0/AS1" );break ;case 0x02 : -printf (" (8/4/2G Rx Rate_Select only)\n" ); +sprintf (description,"%s" ,"8/4/2G Rx Rate_Select only" );break ;case 0x03 : -printf (" (8/4/2G Independent Rx & Tx Rate_Select)\n" ); +sprintf (description,"%s" , +"8/4/2G Independent Rx & Tx Rate_Select" );break ;case 0x04 : -printf (" (8/4/2G Tx Rate_Select only)\n" ); +sprintf (description,"%s" ,"8/4/2G Tx Rate_Select only" );break ;default : -printf (" (reserved or unknown)\n" ); +sprintf (description,"%s" ,"reserved or unknown" );break ; } + +sff_print_any_hex_field ("Rate identifier" ,"rate_identifier" , id[13 ], + description); }static void sff8079_show_wavelength_or_copper_compliance (const __u8 *id) { +char description[SFF_MAX_DESC_LEN ]; +if (id[8 ] & (1 <<2 )) { -printf ("\t%-41s : 0x%02x" ,"Passive Cu cmplnce." , id[60 ]);switch (id[60 ]) {case 0x00 : -printf (" (unspecified)" ); +strncpy (description,"unspecified" , +SFF_MAX_DESC_LEN );break ;case 0x01 : -printf (" (SFF-8431 appendix E)" ); +strncpy (description,"SFF-8431 appendix E" , +SFF_MAX_DESC_LEN );break ;default : -printf (" (unknown)" ); +strncpy (description,"unknown" ,SFF_MAX_DESC_LEN );break ; } -printf (" [SFF-8472 rev10.4 only]\n" ); +strcat (description," [SFF-8472 rev10.4 only]" ); +sff_print_any_hex_field ("Passive Cu cmplnce." , +"passive_cu_cmplnce." , + id[60 ], description); }else if (id[8 ] & (1 <<3 )) {printf ("\t%-41s : 0x%02x" ,"Active Cu cmplnce." , id[60 ]);switch (id[60 ]) {case 0x00 : -printf (" (unspecified)" ); +strncpy (description,"unspecified" , +SFF_MAX_DESC_LEN );break ;case 0x01 : -printf (" (SFF-8431 appendix E)" ); +strncpy (description,"SFF-8431 appendix E" , +SFF_MAX_DESC_LEN );break ;case 0x04 : -printf (" (SFF-8431 limiting)" ); +strncpy (description,"SFF-8431 limiting" , +SFF_MAX_DESC_LEN );break ;default : -printf (" (unknown)" ); +strncpy (description,"unknown" ,SFF_MAX_DESC_LEN );break ; } -printf (" [SFF-8472 rev10.4 only]\n" ); +strcat (description," [SFF-8472 rev10.4 only]" ); +sff_print_any_hex_field ("Active Cu cmplnce." , +"active_cu_cmplnce." , + id[60 ], description); }else { -printf ("\t%-41s : %unm\n" ,"Laser wavelength" , - (id[60 ] <<8 ) | id[61 ]); +module_print_any_uint ("Laser wavelength" , + (id[60 ] <<8 ) | id[61 ],"nm" ); } }static void sff8079_show_options (const __u8 *id) { -static const char *pfx = -"\tOption :" ; +static const char *pfx ="Option" ; +char value[64 ] ="" ; -printf ("\t%-41s : 0x%02x 0x%02x\n" ,"Option values" , id[64 ], id[65 ]); +if (is_json_context ()) { +open_json_array ("option_values" ,"" ); +print_uint (PRINT_JSON ,NULL ,"%u" , id[64 ]); +print_uint (PRINT_JSON ,NULL ,"%u" , id[65 ]); +close_json_array ("" ); + }else { +printf ("\t%-41s : 0x%02x 0x%02x\n" ,"Option values" , id[64 ], + id[65 ]); + }if (id[65 ] & (1 <<1 )) -printf ("%s RX_LOS implemented\n" , pfx); +sprintf (value,"%s" ,"RX_LOS implemented" );if (id[65 ] & (1 <<2 )) -printf ("%s RX_LOS implemented, inverted\n" , pfx); +sprintf (value,"%s" ,"RX_LOS implemented, inverted" );if (id[65 ] & (1 <<3 )) -printf ("%s TX_FAULT implemented\n" , pfx); +sprintf (value,"%s" ,"TX_FAULT implemented" );if (id[65 ] & (1 <<4 )) -printf ("%s TX_DISABLE implemented\n" , pfx); +sprintf (value,"%s" ,"TX_DISABLE implemented" );if (id[65 ] & (1 <<5 )) -printf ("%s RATE_SELECT implemented\n" , pfx); +sprintf (value,"%s" ,"RATE_SELECT implemented" );if (id[65 ] & (1 <<6 )) -printf ("%s Tunable transmitter technology\n" , pfx); +sprintf (value,"%s" ,"Tunable transmitter technology" );if (id[65 ] & (1 <<7 )) -printf ("%s Receiver decision threshold implemented\n" , pfx); +sprintf (value,"%s" ,"Receiver decision threshold implemented" );if (id[64 ] & (1 <<0 )) -printf ("%s Linear receiver output implemented\n" , pfx); +sprintf (value,"%s" ,"Linear receiver output implemented" );if (id[64 ] & (1 <<1 )) -printf ("%s Power level 2 requirement\n" , pfx); +sprintf (value,"%s" ,"Power level 2 requirement" );if (id[64 ] & (1 <<2 )) -printf ("%s Cooled transceiver implemented\n" , pfx); +sprintf (value,"%s" ,"Cooled transceiver implemented" );if (id[64 ] & (1 <<3 )) -printf ("%s Retimer or CDR implemented\n" , pfx); +sprintf (value,"%s" ,"Retimer or CDR implemented" );if (id[64 ] & (1 <<4 )) -printf ("%s Paging implemented\n" , pfx); +sprintf (value,"%s" ,"Paging implemented" );if (id[64 ] & (1 <<5 )) -printf ("%s Power level 3 requirement\n" , pfx); +sprintf (value,"%s" ,"Power level 3 requirement" ); + +if (value[0 ] !='\0' ) +module_print_any_string (pfx, value); }static void sff8079_show_all_common (const __u8 *id)
@@ -393,7 +456,7 @@ static void sff8079_show_all_common(const __u8 *id)sff8079_show_connector (id);sff8079_show_transceiver (id);sff8079_show_encoding (id); -printf ("\t%-41s : %u%s\n" ,"BR, Nominal" , br_nom,"MBd" ); +module_print_any_uint ("BR Nominal" , br_nom,"MBd" );sff8079_show_rate_identifier (id);module_show_value_with_unit (id,14 ,"Length (SMF)" ,1 ,"km" );module_show_value_with_unit (id,16 ,"Length (OM2)" ,10 ,"m" );
@@ -408,8 +471,8 @@ static void sff8079_show_all_common(const __u8 *id)module_show_ascii (id,40 ,55 ,"Vendor PN" );module_show_ascii (id,56 ,59 ,"Vendor rev" );sff8079_show_options (id); -printf ("\t%-41s : %u%s\n" ,"BR margin, max" , br_max,"%" ); -printf ("\t%-41s : %u%s\n" ,"BR margin, min" , br_min,"%" ); +module_print_any_uint ("BR margin max" , br_max,"%" ); +module_print_any_uint ("BR margin min" , br_min,"%" );module_show_ascii (id,68 ,83 ,"Vendor SN" );module_show_ascii (id,84 ,91 ,"Date code" ); }
Signature · 1 line
2.47.0
PATCH v4 13/16 sfpdiag: Add JSON output handling to --module-info in SFF8472 modules
In reply to Danielle RatsonAdd JSON output handling for 'ethtool -m' / --module-info, following the guideline below:
1. Fields with description, will have a separate description field.
2. Units will be documented in a separate module-info.json file.
3. ASCII fields will be presented as strings.
4. On/Off is rendered as true/false.
5. Yes/no is rendered as true/false.
6. Per-channel fields will be presented as array, when each element represents a channel.
7. Fields that hold version, will be split to major and minor sub fields.
---
Notes:
v3:
* Remove unit fields.
* Reword commit message.
v2:
* In rx_power JSON field, add a type field to let the user know what type is printed in "value".
sfpdiag.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-)
sfpdiag.c +31 -16
@@ -241,40 +241,55 @@ static void sff8472_parse_eeprom(const __u8 *id, struct sff_diags *sd)void sff8472_show_all (const __u8 *id) { +char *rx_power_type_string =NULL ;struct sff_diags sd = {0 }; -char *rx_power_string =NULL ;int i;sff8472_parse_eeprom (id, &sd); -if (!sd.supports_dom) { -printf ("\t%-41s : No\n" ,"Optical diagnostics support" ); +module_print_any_bool ("Optical diagnostics support" , +"optical_diagnostics_support" , + sd.supports_dom,YESNO (sd.supports_dom)); + +if (!sd.supports_dom)return ; - } -printf ("\t%-41s : Yes\n" ,"Optical diagnostics support" ); -PRINT_BIAS ("Laser bias current" , sd.bias_cur[MCURR ]); -PRINT_xX_PWR ("Laser output power" , sd.tx_power[MCURR ]); +PRINT_BIAS_ALL ("Laser bias current" ,"laser_bias_current" , + sd.bias_cur[MCURR ]); +PRINT_xX_PWR_ALL ("Laser output power" ,"laser_output_power" , + sd.tx_power[MCURR ]);if (!sd.rx_power_type) - rx_power_string ="Receiver signal OMA" ; + rx_power_type_string ="Receiver signal OMA" ;else - rx_power_string ="Receiver signal average optical power" ; + rx_power_type_string ="Receiver signal average optical power" ; -PRINT_xX_PWR (rx_power_string, sd.rx_power[MCURR ]); +open_json_object ("rx_power" ); +PRINT_xX_PWR_ALL (rx_power_type_string,"value" , sd.rx_power[MCURR ]); +if (is_json_context ()) +module_print_any_string ("type" , rx_power_type_string); +close_json_object ();module_show_dom_mod_lvl_monitors (&sd); -printf ("\t%-41s : %s\n" ,"Alarm/warning flags implemented" , - (sd.supports_alarms ?"Yes" :"No" )); +module_print_any_bool ("Alarm/warning flags implemented" , +"alarm/warning_flags_implemented" , + sd.supports_alarms,YESNO (sd.supports_alarms)); +if (sd.supports_alarms) {for (i =0 ; sff8472_aw_flags[i].str; ++i) { -printf ("\t%-41s : %s\n" , sff8472_aw_flags[i].str, - id[SFF_A2_BASE + sff8472_aw_flags[i].offset] - & sff8472_aw_flags[i].value ?"On" :"Off" ); +bool value; + + value = id[SFF_A2_BASE + sff8472_aw_flags[i].offset] & + sff8472_aw_flags[i].value; +module_print_any_bool (sff8472_aw_flags[i].str,NULL , + value,ONOFF (value)); } -sff_show_thresholds (sd); +if (is_json_context ()) +sff_show_thresholds_json (sd); +else +sff_show_thresholds (sd); } }
Signature · 1 line
2.47.0
PATCH v4 14/16 ethtool: Enable JSON output support for SFF8079 and SFF8472 modules
In reply to Danielle RatsonA sample output:
$ ethtool --json -m swp1
[ {
"identifier": 3,
"identifier_description": "SFP",
"extended_identifier": 4,
"extended_identifier_description": "GBIC/SFP defined by 2-wire
interface ID",
"connector": 33,
"connector_description": "Copper pigtail",
"transceiver_codes": [ 1,0,0,4,0,4,128,213,0 ],
"transceiver_type": "FC: 100 MBytes/sec",
"encoding": 0,
"encoding_description": "unspecified",
"br_nominal": 10300,
"rate_identifier": 0,
"rate_identifier_description": "unspecified",
"length_(smf)": 0,
"length_(om2)": 0,
"length_(om1)": 0,
"length_(copper_or_active_cable)": 2,
"length_(om3)": 0,
"passive_cu_cmplnce.": 1,
"passive_cu_cmplnce._description": "SFF-8431 appendix E
[SFF-8472 rev10.4 only]",
"vendor_name": "Mellanox",
"vendor_oui": [ 0,2,201 ],
"vendor_pn": "MC2309130-002",
"vendor_rev": "A2",
"option_values": [ 0,0 ],
"br_margin_max": 0,
"br_margin_min": 0,
"vendor_sn": "MT1146VS00060",
"date_code": "111110"
} ]---
Notes:
v3:
* Enable JSON output support for SFF8079.
* Reword commit message.
ethtool.c | 4 ++++ sfpid.c | 4 ++++ 2 files changed, 8 insertions(+)
ethtool.c +4 -0
@@ -5007,6 +5007,8 @@ static int do_getmodule(struct cmd_context *ctx) (eeprom->len != modinfo.eeprom_len)) { geeprom_dump_hex =1 ; } else if (!geeprom_dump_hex) { +new_json_obj (ctx->json); +open_json_object (NULL );switch (modinfo.type) {#ifdef ETHTOOL_ENABLE_PRETTY_DUMP case ETH_MODULE_SFF_8079 :
@@ -5026,6 +5028,8 @@ static int do_getmodule(struct cmd_context *ctx) geeprom_dump_hex =1 ;break ; } +close_json_object (); +delete_json_obj (); }if (geeprom_dump_hex) dump_hex(stdout, eeprom->data,
sfpid.c +4 -0
@@ -517,7 +517,11 @@ int sff8079_show_all_nl(struct cmd_context *ctx)if (ret) goto out; +new_json_obj (ctx->json); +open_json_object (NULL );sff8079_show_all_common (buf); +close_json_object (); +delete_json_obj ();/* Finish if A2h page is not present */ if (!(buf[92 ] & (1 <<6 )))
Signature · 1 line
2.47.0
PATCH v4 15/16 module_info: Add a new JSON file for units documentation
In reply to Danielle RatsonThe JSON output dump will not contain explicit unit indicators in the output fields.
Instead, document those units in a separate schema JSON file so a JSON consumer will be able to track this information.
---
Notes:
v3:
* New patch.
module_info.json | 191 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 module_info.json
module_info.json new file +191 -0
@@ -0,0 +1,191 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Ethtool module-info JSON Output", + "description": "Units documentation for various fields in the output.", + "type": "array", + "items": { + "type": "object", + "properties": { + "br_nominal": { + "type": "integer", + "description": "Unit: Mbps" + }, + "length_(smf)": { + "type": "integer", + "description": "Unit: km" + }, + "length_(om5)": { + "type": "integer", + "description": "Unit: m" + }, + "length_(om4)": { + "type": "integer", + "description": "Unit: m" + }, + "length_(om3)": { + "type": "integer", + "description": "Unit: m" + }, + "length_(om2)": { + "type": "integer", + "description": "Unit: m" + }, + "length_(om1)": { + "type": "integer", + "description": "Unit: m" + }, + "length_(copper_or_active_cable)": + { + "type": "integer", + "description": "Unit: m" + }, + "laser_wavelength": { + "type": "integer", + "description": "Unit: nm" + }, + "laser_wavelength_tolerance": { + "type": "integer", + "description": "Unit: nm" + }, + "module_temperature": { + "type": "number", + "description": "Unit: degrees C" + }, + "module_voltage": { + "type": "number", + "description": "Unit: V" + }, + "laser_tx_bias_current": { + "type": "array", + "items": { + "type": "number" + }, + "description": "Unit: mA" + }, + "transmit_avg_optical_power": { + "type": "array", + "items": { + "type": "number" + }, + "description": "Unit: mW" + }, + "rx_power": { + "type": "object", + "properties": { + "values": { + "type": "array", + "items": { + "type": "number" + }, + "description": "Unit: mW" + } + } + }, + "laser_bias_current": { + "type": "object", + "properties": { + "high_alarm_threshold": { + "type": "number", + "description": "Unit: mA" + }, + "low_alarm_threshold": { + "type": "number", + "description": "Unit: mA" + }, + "high_warning_threshold": { + "type": "number", + "description": "Unit: mA" + }, + "low_warning_threshold": { + "type": "number", + "description": "Unit: mA" + } + } + }, + "laser_output_power": { + "type": "object", + "properties": { + "high_alarm_threshold": { + "type": "number", + "description": "Unit: mW" + }, + "low_alarm_threshold": { + "type": "number", + "description": "Unit: mW" + }, + "high_warning_threshold": { + "type": "number", + "description": "Unit: mW" + }, + "low_warning_threshold": { + "type": "number", + "description": "Unit: mW" + } + } + }, + "module_temperature": { + "type": "object", + "properties": { + "high_alarm_threshold": { + "type": "number", + "description": "Unit: degrees C" + }, + "low_alarm_threshold": { + "type": "number", + "description": "Unit: degrees C" + }, + "high_warning_threshold": { + "type": "number", + "description": "Unit: degrees C" + }, + "low_warning_threshold": { + "type": "number", + "description": "Unit: degrees C" + } + } + }, + "module_voltage": { + "type": "object", + "properties": { + "high_alarm_threshold": { + "type": "number", + "description": "Unit: V" + }, + "low_alarm_threshold": { + "type": "number", + "description": "Unit: V" + }, + "high_warning_threshold": { + "type": "number", + "description": "Unit: V" + }, + "low_warning_threshold": { + "type": "number", + "description": "Unit: V" + } + } + }, + "laser_rx_power": { + "type": "object", + "properties": { + "high_alarm_threshold": { + "type": "number", + "description": "Unit: mW" + }, + "low_alarm_threshold": { + "type": "number", + "description": "Unit: mW" + }, + "high_warning_threshold": { + "type": "number", + "description": "Unit: mW" + }, + "low_warning_threshold": { + "type": "number", + "description": "Unit: mW" + } + } + } + } + } +}
Signature · 1 line
2.47.0
PATCH v4 16/16 ethtool: Add '-j' support to ethtool
In reply to Danielle RatsonCurrently, only '--json' flag is supported for JSON output in the ethtool commands.
Add support for the shorter '-j' flag also.
--- ethtool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
ethtool.c +3 -2
@@ -6303,7 +6303,7 @@ static int show_usage(struct cmd_context *ctx __maybe_unused)fprintf (stdout,"\n" );fprintf (stdout,"FLAGS:\n" );fprintf (stdout," --debug MASK turn on debugging messages\n" ); -fprintf (stdout," --json enable JSON output format (not supported by all commands)\n" ); +fprintf (stdout," -j|--json enable JSON output format (not supported by all commands)\n" );fprintf (stdout," -I|--include-statistics request device statistics related to the command (not supported by all commands)\n" );return 0 ;
@@ -6565,7 +6565,8 @@ int main(int argc, char **argp) argc -=1 ;continue ; } -if (*argp && !strcmp (*argp,"--json" )) { +if (*argp && (!strcmp (*argp,"--json" ) || + !strcmp (*argp,"-j" ))) { ctx.json = true; argp +=1 ; argc -=1 ;
Signature · 1 line
2.47.0
Quoted 15 lines · On Wed, 5 Feb 2025 17:54:20 +0200 Danielle Ratson wrote:
Add JSON output for 'ethtool -m' / --module-info, following the guideline below:
1. Fields with description, will have a separate description field.
2. Units will be documented in a separate module-info.json file.
3. ASCII fields will be presented as strings.
4. On/Off is rendered as true/false.
5. Yes/no is rendered as true/false.
6. Per-channel fields will be presented as array, when each element represents a channel.
7. Fields that hold version, will be split to major and minor sub fields.This patchset suppose to extend [1] to cover all types of modules.
Quoted 7 lines
Patchset overview:
Patches #1-#7: Preparations.
Patches #8-#9: Add JSON output support for CMIS compliant modules. Patches #10-#11: Add JSON output support for SFF8636 modules. Patches #12-#14: Add JSON output support for SFF8079 and SFF8472 modules. Patch #15: Add a new schema JSON file for units documentation. Patches #16: Add '-j' support to ethtool
Thanks a lot for doing this work!