I2csfp - sfp debugging via i2c

I will release my tool, it can do some debugging stuff from userspace on sfp modules via i2c.

USE WITH CAUTION!!!

Features:

  1. i2cdump
  2. eeprom dump, showing different pages
  3. edit eeprom data
  4. read/write using protocols: byte, c22m, c22r, c45, rollball
  5. Extract rollball password
  6. Brute force attack eeprom

It can edit eeprom data of the OEM modules so it can match another string, so you do not need to add another quirk if the same hardware already has a quirk but uses different id string.

I’ve only briefly tested it:

ericwoud/i2csfp (github.com)

It is still in beta-stage.

I have added pre-build static executables to the release page here. https://github.com/ericwoud/i2csfp/releases/tag/0.1

One could do:

i2csfp sfp-X eepromfix -V Turris -N RTSFP-2.5G -E 0x1e

For example, to use the OEM module, using the newly added patch for the Turris module, although I still have to try the result myself :wink:

Because of this code in linux kernel,

bool sfp_may_have_phy(struct sfp_bus *bus, const struct sfp_eeprom_id *id)
{
	if (id->base.e1000_base_t)
		return true;

	if (id->base.phys_id != SFF8024_ID_DWDM_SFP) {
		switch (id->base.extended_cc) {
		case SFF8024_ECC_10GBASE_T_SFI:
		case SFF8024_ECC_10GBASE_T_SR:
		case SFF8024_ECC_5GBASE_T:
		case SFF8024_ECC_2_5GBASE_T:
			return true;
		}
	}

	return false;
}

We need to set extended_cc to 0x1e for 2.5G module phy to be recognised.

5 Likes

The tool can now run with exclusive access to the i2c bus.

See readme

Todo:

Control/readout sfp gpio pins.

AWESOME ! This tool should be added as a package in openwrt :sweat_smile:

I had a good experience here. Many thanks to the author!

https://forum.banana-pi.org/t/bpi-r4-and-sfp/16945/26?u=vasya

Added control/readout of gpio lines.

Is it possible to add temperature limits? I have one module with the wrong minimum temperature limit. It issues an alarm because the minimum temperature limit is set at 127 degrees Celsius.

Is this value possible to change without password? Is so, then you can simply use byte access to change it.

I tried to change via byte, the value is not write.

I’ve just pushed newest version, where you can specify a password for byte operations. So first get it with rbpassword and use it with byte write.

Be careful.

Oh, and need to fix checksum if it is in the checksum range.

1 Like

Oh that’s very good I’ll try it!

Fix checksum with eepromfix, without options.

1 Like

Yes it worked, you need a password to change the limits.

Thanks to the author!

Here’s the broken limit

root@OpenWrt:/tmp# ethtool -m eth2
        Identifier                                : 0x03 (SFP)
        Extended identifier                       : 0x04 (GBIC/SFP defined by 2-wire interface ID)
        Connector                                 : 0x07 (LC)
        Transceiver codes                         : 0x10 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        Transceiver type                          : 10G Ethernet: 10G Base-SR
        Encoding                                  : 0x06 (64B/66B)
        BR, Nominal                               : 10300MBd
        Rate identifier                           : 0x00 (unspecified)
        Length (SMF,km)                           : 0km
        Length (SMF)                              : 0m
        Length (50um)                             : 80m
        Length (62.5um)                           : 20m
        Length (Copper)                           : 0m
        Length (OM3)                              : 300m
        Laser wavelength                          : 850nm
        Vendor name                               : OEM
        Vendor OUI                                : 00:00:00
        Vendor PN                                 : SFP-10G-T
        Vendor rev                                : 1
        Option values                             : 0x00 0x1a
        Option                                    : RX_LOS implemented
        Option                                    : TX_FAULT implemented
        Option                                    : TX_DISABLE implemented
        BR margin, max                            : 0%
        BR margin, min                            : 0%
        Vendor SN                                 : C2312180141
        Date code                                 : 231218
        Optical diagnostics support               : Yes
        Laser bias current                        : 6.000 mA
        Laser output power                        : 0.5000 mW / -3.01 dBm
        Receiver signal average optical power     : 0.0000 mW / -inf dBm
        Module temperature                        : 35.53 degrees C / 95.95 degrees F
        Module voltage                            : 3.3345 V
        Alarm/warning flags implemented           : Yes
        Laser bias current high alarm             : Off
        Laser bias current low alarm              : Off
        Laser bias current high warning           : Off
        Laser bias current low warning            : Off
        Laser output power high alarm             : Off
        Laser output power low alarm              : Off
        Laser output power high warning           : Off
        Laser output power low warning            : Off
        Module temperature high alarm             : Off
        Module temperature low alarm              : On
        Module temperature high warning           : Off
        Module temperature low warning            : Off
        Module voltage high alarm                 : Off
        Module voltage low alarm                  : Off
        Module voltage high warning               : Off
        Module voltage low warning                : Off
        Laser rx power high alarm                 : Off
        Laser rx power low alarm                  : On
        Laser rx power high warning               : Off
        Laser rx power low warning                : On
        Laser bias current high alarm threshold   : 15.000 mA
        Laser bias current low alarm threshold    : 1.000 mA
        Laser bias current high warning threshold : 13.000 mA
        Laser bias current low warning threshold  : 2.000 mA
        Laser output power high alarm threshold   : 1.9952 mW / 3.00 dBm
        Laser output power low alarm threshold    : 0.1584 mW / -8.00 dBm
        Laser output power high warning threshold : 1.5848 mW / 2.00 dBm
        Laser output power low warning threshold  : 0.1778 mW / -7.50 dBm
        Module temperature high alarm threshold   : 95.00 degrees C / 203.00 degrees F
        Module temperature low alarm threshold    : 127.01 degrees C / 260.62 degrees F
        Module temperature high warning threshold : 90.00 degrees C / 194.00 degrees F
        Module temperature low warning threshold  : -45.00 degrees C / -49.00 degrees F
        Module voltage high alarm threshold       : 3.6000 V
        Module voltage low alarm threshold        : 3.0000 V
        Module voltage high warning threshold     : 3.5000 V
        Module voltage low warning threshold      : 3.1000 V
        Laser rx power high alarm threshold       : 1.1220 mW / 0.50 dBm
        Laser rx power low alarm threshold        : 0.0199 mW / -17.01 dBm
        Laser rx power high warning threshold     : 1.0000 mW / 0.00 dBm
        Laser rx power low warning threshold      : 0.0223 mW / -16.52 dBm

And here is the corrected one

root@OpenWrt:/tmp# ethtool -m eth2
        Identifier                                : 0x03 (SFP)
        Extended identifier                       : 0x04 (GBIC/SFP defined by 2-wire interface ID)
        Connector                                 : 0x07 (LC)
        Transceiver codes                         : 0x10 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        Transceiver type                          : 10G Ethernet: 10G Base-SR
        Encoding                                  : 0x06 (64B/66B)
        BR, Nominal                               : 10300MBd
        Rate identifier                           : 0x00 (unspecified)
        Length (SMF,km)                           : 0km
        Length (SMF)                              : 0m
        Length (50um)                             : 80m
        Length (62.5um)                           : 20m
        Length (Copper)                           : 0m
        Length (OM3)                              : 300m
        Laser wavelength                          : 850nm
        Vendor name                               : OEM
        Vendor OUI                                : 00:00:00
        Vendor PN                                 : SFP-10G-T
        Vendor rev                                : 1
        Option values                             : 0x00 0x1a
        Option                                    : RX_LOS implemented
        Option                                    : TX_FAULT implemented
        Option                                    : TX_DISABLE implemented
        BR margin, max                            : 0%
        BR margin, min                            : 0%
        Vendor SN                                 : C2312180141
        Date code                                 : 231218
        Optical diagnostics support               : Yes
        Laser bias current                        : 6.000 mA
        Laser output power                        : 0.5000 mW / -3.01 dBm
        Receiver signal average optical power     : 0.0000 mW / -inf dBm
        Module temperature                        : 35.98 degrees C / 96.77 degrees F
        Module voltage                            : 3.3300 V
        Alarm/warning flags implemented           : Yes
        Laser bias current high alarm             : Off
        Laser bias current low alarm              : Off
        Laser bias current high warning           : Off
        Laser bias current low warning            : Off
        Laser output power high alarm             : Off
        Laser output power low alarm              : Off
        Laser output power high warning           : Off
        Laser output power low warning            : Off
        Module temperature high alarm             : Off
        Module temperature low alarm              : Off
        Module temperature high warning           : Off
        Module temperature low warning            : Off
        Module voltage high alarm                 : Off
        Module voltage low alarm                  : Off
        Module voltage high warning               : Off
        Module voltage low warning                : Off
        Laser rx power high alarm                 : Off
        Laser rx power low alarm                  : On
        Laser rx power high warning               : Off
        Laser rx power low warning                : On
        Laser bias current high alarm threshold   : 15.000 mA
        Laser bias current low alarm threshold    : 1.000 mA
        Laser bias current high warning threshold : 13.000 mA
        Laser bias current low warning threshold  : 2.000 mA
        Laser output power high alarm threshold   : 1.9952 mW / 3.00 dBm
        Laser output power low alarm threshold    : 0.1584 mW / -8.00 dBm
        Laser output power high warning threshold : 1.5848 mW / 2.00 dBm
        Laser output power low warning threshold  : 0.1778 mW / -7.50 dBm
        Module temperature high alarm threshold   : 95.00 degrees C / 203.00 degrees F
        Module temperature low alarm threshold    : -50.00 degrees C / -58.00 degrees F
        Module temperature high warning threshold : 90.00 degrees C / 194.00 degrees F
        Module temperature low warning threshold  : -45.00 degrees C / -49.00 degrees F
        Module voltage high alarm threshold       : 3.6000 V
        Module voltage low alarm threshold        : 3.0000 V
        Module voltage high warning threshold     : 3.5000 V
        Module voltage low warning threshold      : 3.1000 V
        Laser rx power high alarm threshold       : 1.1220 mW / 0.50 dBm
        Laser rx power low alarm threshold        : 0.0199 mW / -17.01 dBm
        Laser rx power high warning threshold     : 1.0000 mW / 0.00 dBm
        Laser rx power low warning threshold      : 0.0223 mW / -16.52 dBm

If the author does not mind, I will post a binary file for aarch64, I run directly on BPI-R4 from /tmp/ i2csfp.tar.gz (300,2 КБ)

That’s ok, I also had some, for aarch64, armv7h and x86_64. But the code is still changing quite often, so for now, I have removed them, since it is still an alfa/beta version.

Would this tool also be able to show me, why I don’t see that full output from ethtool? Like if there is some issue with the i2c configuration or something?

Because I’m not seeing the power usage and temperature and all the other diagnostics data of my module, even though according to the manufacturer, it supports DOM.

It isn’t a very smart tool. Just send and receive bytes using different protocols.

If you don’t exactly know what you’re writing to the module, then it is more likely to break things then do something usefull with it.

If you are using openwrt you need ethtool not from busybox and it should be Full to check the packages before building.