Skip to content

[action] [PR:4020] Fix show int transceiver EEPROM crash for for Backplane cartridge + enhance EEPROM CLI output#4032

Merged
mssonicbld merged 1 commit intosonic-net:202505from
mssonicbld:cherry/202505/4020
Aug 18, 2025
Merged

[action] [PR:4020] Fix show int transceiver EEPROM crash for for Backplane cartridge + enhance EEPROM CLI output#4032
mssonicbld merged 1 commit intosonic-net:202505from
mssonicbld:cherry/202505/4020

Conversation

@mssonicbld
Copy link
Collaborator

Summary

This PR fixes a crash in the show interface transceiver eeprom command when dealing with Backplane cartridge modules and enhances the overall EEPROM CLI (show + sfputil) output consistency and organization.

This change should be merged along with sonic-net/sonic-platform-common#590

Following traceback is seen with the Backplane cartridge cables. Hence, we need to resolve the traceback.

root@admin:/home/admin# show int transceiver info Ethernet128
Traceback (most recent call last):
  File "/usr/local/bin/sfpshow", line 824, in <module>
    cli()
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/sfpshow", line 764, in info
    sfp.get_eeprom()
  File "/usr/local/lib/python3.11/dist-packages/utilities_common/multi_asic.py", line 156, in wrapped_run_on_all_asics
    func(self,  *args, **kwargs)
  File "/usr/local/bin/sfpshow", line 641, in get_eeprom
    self.intf_eeprom[self.intf_name] = self.convert_interface_sfp_info_to_cli_output_string(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/sfpshow", line 473, in convert_interface_sfp_info_to_cli_output_string
    sfp_info_output = self.convert_sfp_info_to_output_string(sfp_info_dict, sfp_firmware_info_dict)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/sfpshow", line 354, in convert_sfp_info_to_output_string
    output += '{}{}: {}\n'.format(indent, data_map[key], sfp_info_dict[key])
                                                         ~~~~~~~~~~~~~^^^^^
KeyError: 'active_apsel_hostlane1'

🐛 Primary Bug Fix

  • Fixed crash for Backplane cartridge modules: Resolved issue where show interface transceiver eeprom command would crash when processing Backplane cartridge transceivers
    • Using the sfp_info_dict rather than a pre-defined dictionary (CMIS_DATA_MAP, C_CMIS_DATA_MAP, QSFP_DATA_MAP, QSFP_DD_DATA_MAP, QSFP_DATA_MAP) to display the EEPROM fields. This helps to avoid modifying the pre-defined dictionary upon introducing new fields in sfp_info_dict for a new transceiver

🚀 EEPROM CLI Enhancements

Code Refactoring & Shared Utilities

  • Created shared utility functions in utilities_common/sfp_helper.py:
    • get_data_map_sort_key(): Provides consistent sorting logic for SFP info keys
    • get_transceiver_data_map(): Automatically selects appropriate data map based on transceiver type

Improved Field Organization

  • Consistent Field Ordering: Both sfputil and sfpshow now display transceiver fields in logical, sorted order

Code Quality Improvements

  • Removed Code Duplication: Eliminated redundant sorting and display logic between utilities
  • Better Maintainability: Shared functions make future updates and bug fixes easier

🧪 Testing

  • Verified fix resolves Backplane cartridge crash issue
  • Confirmed consistent field ordering across both CLIs

Field differences between nightly (left) and current changes (right) for CLI output of different types of transceivers
(the red and greyed out portion depict differences)

  1. CMIS transceiver
    show int transceiver info CLI
image

sfputil show eeprom CLI
image

image
  1. CMIS transceiver with flat memory
    show int transceiver info CLI
image

sfputil show eeprom CLI
image

image
  1. C-CMIS transceiver
    show int transceiver info CLI
image

sfputil show eeprom CLI
image

image
  1. SFF-8636 with non-flat memory
    show int transceiver info CLI
image

sfputil show eeprom CLI
image

  1. SFF-8636 with flat memory
    show int transceiver info CLI
image

sfputil show eeprom CLI
image

  1. SFF-8436 with flat memory (DAC)
    show int transceiver info CLI
image

sfputil show eeprom CLI
image

  1. SFF-8472 transceiver
    show int transceiver info CLI
image

sfputil show eeprom CLI
image

…nhance EEPROM CLI output

## Summary
This PR fixes a crash in the `show interface transceiver eeprom` command when dealing with Backplane cartridge modules and enhances the overall EEPROM CLI (show + sfputil) output consistency and organization.

This change should be merged along with sonic-net/sonic-platform-common#590

Following traceback is seen with the Backplane cartridge cables. Hence, we need to resolve the traceback.
```
root@admin:/home/admin# show int transceiver info Ethernet128
Traceback (most recent call last):
  File "/usr/local/bin/sfpshow", line 824, in <module>
    cli()
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/sfpshow", line 764, in info
    sfp.get_eeprom()
  File "/usr/local/lib/python3.11/dist-packages/utilities_common/multi_asic.py", line 156, in wrapped_run_on_all_asics
    func(self,  *args, **kwargs)
  File "/usr/local/bin/sfpshow", line 641, in get_eeprom
    self.intf_eeprom[self.intf_name] = self.convert_interface_sfp_info_to_cli_output_string(
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/sfpshow", line 473, in convert_interface_sfp_info_to_cli_output_string
    sfp_info_output = self.convert_sfp_info_to_output_string(sfp_info_dict, sfp_firmware_info_dict)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/sfpshow", line 354, in convert_sfp_info_to_output_string
    output += '{}{}: {}\n'.format(indent, data_map[key], sfp_info_dict[key])
                                                         ~~~~~~~~~~~~~^^^^^
KeyError: 'active_apsel_hostlane1'
```

## 🐛 Primary Bug Fix
- **Fixed crash for Backplane cartridge modules**: Resolved issue where `show interface transceiver eeprom` command would crash when processing Backplane cartridge transceivers
  - Using the sfp_info_dict rather than a pre-defined dictionary (CMIS_DATA_MAP, C_CMIS_DATA_MAP, QSFP_DATA_MAP, QSFP_DD_DATA_MAP, QSFP_DATA_MAP) to display the EEPROM fields. This helps to avoid modifying the pre-defined dictionary upon introducing new fields in sfp_info_dict for a new transceiver

## 🚀 EEPROM CLI Enhancements

### Code Refactoring & Shared Utilities
- **Created shared utility functions** in `utilities_common/sfp_helper.py`:
  - `get_data_map_sort_key()`: Provides consistent sorting logic for SFP info keys
  - `get_transceiver_data_map()`: Automatically selects appropriate data map based on transceiver type

### Improved Field Organization
- **Consistent Field Ordering**: Both `sfputil` and `sfpshow` now display transceiver fields in logical, sorted order

### Code Quality Improvements
- **Removed Code Duplication**: Eliminated redundant sorting and display logic between utilities
- **Better Maintainability**: Shared functions make future updates and bug fixes easier

## 🧪 Testing
- Verified fix resolves Backplane cartridge crash issue
- Confirmed consistent field ordering across both CLIs

Field differences between nightly (left) and current changes (right) for CLI output of different types of transceivers
 (the red and greyed out portion depict differences)
1. CMIS transceiver
show int transceiver info CLI
<img width="1720" height="71" alt="image" src="https://github.com/user-attachments/assets/23a7c597-b4ce-42a6-8849-77f95cfc9d5a" />

sfputil show eeprom CLI
<img width="2110" height="191" alt="image" src="https://github.com/user-attachments/assets/db2e41b2-8e47-4dca-be06-6d13411f9d91" />

<img width="1622" height="51" alt="image" src="https://github.com/user-attachments/assets/97a622d1-227b-4dd7-abc6-bad6bed786cf" />

2. CMIS transceiver with flat memory
show int transceiver info CLI
<img width="1599" height="66" alt="image" src="https://github.com/user-attachments/assets/67ee2ac9-aa61-4c9f-a20a-d28e5145b1cc" />

sfputil show eeprom CLI
<img width="2044" height="191" alt="image" src="https://github.com/user-attachments/assets/938fdbb7-63f4-43a8-b333-79b195889361" />

<img width="1606" height="52" alt="image" src="https://github.com/user-attachments/assets/8e685314-ad70-4cff-ac3b-1bcb78b8314a" />

3. C-CMIS transceiver
show int transceiver info CLI
<img width="1605" height="70" alt="image" src="https://github.com/user-attachments/assets/f72895b5-5d31-47ed-81b5-6108690d4120" />

sfputil show eeprom CLI
<img width="2019" height="192" alt="image" src="https://github.com/user-attachments/assets/b7ab5a3d-8f9c-4cf7-9400-427c8ccfbafc" />

<img width="1614" height="45" alt="image" src="https://github.com/user-attachments/assets/1c620c51-344e-4155-9773-7500d2fab241" />

4. SFF-8636 with non-flat memory
show int transceiver info CLI
<img width="1574" height="46" alt="image" src="https://github.com/user-attachments/assets/d1b8ad6b-f084-4eb4-9d80-076c39c8ef99" />

sfputil show eeprom CLI
<img width="1621" height="26" alt="image" src="https://github.com/user-attachments/assets/31e7b807-4fbd-4077-91a0-d22ef9b18e9a" />

5. SFF-8636 with flat memory
show int transceiver info CLI
<img width="1559" height="43" alt="image" src="https://github.com/user-attachments/assets/217416ea-fd10-4ca4-a830-6ac50cb6fa6a" />

sfputil show eeprom CLI
<img width="1594" height="21" alt="image" src="https://github.com/user-attachments/assets/0f6ca552-b771-44e6-95d2-c36341b97b7e" />

6. SFF-8436 with flat memory (DAC)
show int transceiver info CLI
<img width="1559" height="50" alt="image" src="https://github.com/user-attachments/assets/be524f6b-24e6-4cfd-9125-d631db88081a" />

sfputil show eeprom CLI
<img width="1583" height="24" alt="image" src="https://github.com/user-attachments/assets/69d8ed26-1b5e-4e4d-bb59-8f453f6cf630" />

7. SFF-8472 transceiver
show int transceiver info CLI
<img width="1568" height="46" alt="image" src="https://github.com/user-attachments/assets/75a113d0-207f-43cd-88ba-00c192a4c04a" />

sfputil show eeprom CLI
<img width="1567" height="23" alt="image" src="https://github.com/user-attachments/assets/f2a942f5-fcc9-461f-8194-bad42c55e550" />
@mssonicbld
Copy link
Collaborator Author

Original PR: #4020

@mssonicbld
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yejianquan
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yejianquan
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yejianquan
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yejianquan yejianquan closed this Aug 18, 2025
@yejianquan yejianquan reopened this Aug 18, 2025
@mssonicbld
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld mssonicbld merged commit 5a3608d into sonic-net:202505 Aug 18, 2025
8 of 9 checks passed
kktheballer pushed a commit to kktheballer/sonic-utilities that referenced this pull request Jan 14, 2026
```<br>* 0682dbf - (HEAD -> 202506) Merge branch '202505' of https://github.com/sonic-net/sonic-utilities into 202506 (2025-08-18) [Sonic Automation]
* 5a3608d - (origin/202505) Fix show int transceiver EEPROM crash for for Backplane cartridge + enhance EEPROM CLI output (sonic-net#4032) (2025-08-18) [mssonicbld]<br>```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants