Skip to content

Allow sfputil page parsing to accept decimal, hex and octals#4444

Open
maheeppartap-nexthop wants to merge 2 commits intosonic-net:masterfrom
nexthop-ai:update-conversion-and-validation
Open

Allow sfputil page parsing to accept decimal, hex and octals#4444
maheeppartap-nexthop wants to merge 2 commits intosonic-net:masterfrom
nexthop-ai:update-conversion-and-validation

Conversation

@maheeppartap-nexthop
Copy link
Copy Markdown

@maheeppartap-nexthop maheeppartap-nexthop commented Apr 10, 2026

Fixes sonic-net/sonic-platform-common#648

What I did

Passing page number to sfputil currently assumes all inputs are hex values.
sudo sfputil read-eeprom -p Ethernet92 -n 17 -o 128 -s 128 would use page 23, instead of 17.

This PR aims to make the user's intent more clean, and is now able to clearly distinguish between hex, int, octal values.
sudo sfputil read-eeprom -p Ethernet92 -n 17 -o 128 -s 128 would should use page 17
sudo sfputil read-eeprom -p Ethernet92 -n 0x17 -o 128 -s 128 would should use page 23
sudo sfputil read-eeprom -p Ethernet92 -n 0o17 -o 128 -s 128 would should use page 15

How I did it

inside validatre_eeprom_page, I changed the base from 16 to 0. I also updated the help messages and error messages to make the new behaviour more clear.

How to verify it

You can try running the same command with other types.

Previous command output (if the output of a command-line utility has changed)

sudo sfputil read-eeprom -p Ethernet12 -n 10 -o 128 -s 128
        00000080 00 00 01 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
        00000090 00 10 10 10 10 10 10 10  10 ff 00 00 66 66 66 66 |............ffff|
        000000a0 ff ff 66 66 66 66 66 66  66 66 33 33 33 33 00 00 |..ffffffff3333..|
        000000b0 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
        000000c0 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
        000000d0 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
        000000e0 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
        000000f0 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|

New command output (if the output of a command-line utility has changed)

sudo sfputil read-eeprom -p Ethernet12 -n 10 -o 128 -s 128
        00000080 18 41 63 61 63 69 61 20  43 6f 6d 6d 20 49 6e 63 |<VENDOR NAME>|
        00000090 2e 7c b2 5c 44 50 30 34  51 53 44 44 2d 45 32 30 |.|.\<SOME MORE INFO>|
        000000a0 2d 30 30 31 41 20 32 35  31 33 35 30 30 37 30 20 |-001A 251350070 |
        000000b0 20 20 20 20 20 20 32 35  30 33 32 38 20 20 00 00 |      250328  ..|
        000000c0 00 00 00 00 00 00 00 00  e0 50 00 07 00 00 00 00 |.........P......|
        000000d0 00 00 fe 00 05 00 00 00  00 00 00 00 00 00 54 00 |..............T.|
        000000e0 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
        000000f0 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@maheeppartap-nexthop maheeppartap-nexthop changed the title Update conversion and validation Allow sfputil page parsing to accept decimal, hex and octals Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sfputil: clarify and extend page number parsing for EEPROM commands

2 participants