This repository contains a kernel patch and a user space program to read and write arbitrary Bytes from and into the EEPROM of SFP or QSFP modules.
Kernel patches are for Linux Kernel 6.6 and 6.12 and can be found inside patches/.
The writing is done by implementing a new ethtool netlink message ETHTOOL_MSG_MODULE_EEPROM_SET. Such a message contains the following attributes:
| Field | Type | Description |
|---|---|---|
ETHTOOL_A_MODULE_EEPROM_HEADER |
nested | request header |
ETHTOOL_A_MODULE_EEPROM_OFFSET |
u32 | offset within a page |
ETHTOOL_A_MODULE_EEPROM_LENGTH |
u32 | amount of bytes to write |
ETHTOOL_A_MODULE_EEPROM_PAGE |
u8 | page number |
ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS |
u8 | page I2C address |
ETHTOOL_A_MODULE_EEPROM_BANK |
u8 | bank number (optional) |
ETHTOOL_A_MODULE_EEPROM_DATA |
nested | array of bytes for module EEPROM write |
To compile the user space program, switch to the src/ directory and execute make. The module_eeprom binary will be located inside src/bin/.
cd src/
make
The user space program can be run using the following options:
Usage: ./module_eeprom <iface> [options]
Options:
-a, --address EEPROM I²C address (Default: 0x50)
-l, --length EEPROM byte read length
-o, --offset EEPROM byte offset
-p, --page EEPROM page number
-r, --raw Raw mode, don't convert to hex
-w, --write Bytes to write to EEPROM
If -l is passed, the program will try to read from the EEPROM.
If -w is passed, the program will try to write to the EEPROM.
Both options cannot be passed together.