Skip to content

Add complete bank support for CMIS transceivers#640

Open
bobby-nexthop wants to merge 1 commit intosonic-net:masterfrom
nexthop-ai:bank-support-cmis
Open

Add complete bank support for CMIS transceivers#640
bobby-nexthop wants to merge 1 commit intosonic-net:masterfrom
nexthop-ai:bank-support-cmis

Conversation

@bobby-nexthop
Copy link
Copy Markdown
Contributor

@bobby-nexthop bobby-nexthop commented Mar 24, 2026

Description

This PR extends the bank parameter support introduced in PR #632 to fully enable multi-bank CMIS transceiver support throughout the stack.

Changes include:

  1. Memory Map Bank Awareness:

    • Updated CmisFlatMemMap, CmisMemMap, and CCmisMemMap to accept bank parameter
    • Implemented bank-aware getaddr() method in CmisFlatMemMap that correctly calculates linear offsets using the formula from sonic-linux-kernel PR
    • Added bank property to CmisFlatMemMap for read-only access
    • Added constants: CMIS_EEPROM_PAGE_SIZE, CMIS_NUM_NON_BANKED_PAGES, CMIS_NUM_BANKED_PAGES, CMIS_ARCH_PAGES
    • Uses unified formula: linear_offset = (bank * CMIS_ARCH_PAGES + page) * page_size + offset
    • Each bank is treated as a full 256-page (32KB) architectural block for proper alignment
  2. API Factory Updates:

    • Added bank parameter to create_xcvr_api() and _create_cmis_api()
    • Updated CMIS API instantiation to pass bank parameter to memory maps
    • Modified id_mapping to pass bank parameter for all CMIS module types (0x18, 0x19, 0x1b, 0x1e)
  3. SfpBase Integration:

    • Updated refresh_xcvr_api() to pass bank parameter when creating xcvr_api
  4. Field Definitions:

    • Added BANKS_SUPPORTED_FIELD constant to consts.py
    • Added BanksSupported field to MODULE_CHAR_ADVT in CmisMemMap

This enables proper support for CMIS modules with multiple memory banks, allowing correct EEPROM access across all banks as defined in the CMIS specification. The offset calculation formula matches the optoe kernel driver implementation in sonic-linux-kernel PR #473.

Motivation and Context

We are implementing banking support as allowed by the CMIS spec. Our HLD is available at sonic-net/SONiC#2183

How Has This Been Tested?

I don't have banked hardware yet to test on, have confirmed that these changes are backwards compatible and don't break existing systems

Additional Information (Optional)

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bobby-nexthop bobby-nexthop marked this pull request as ready for review March 27, 2026 22:18
This PR extends the bank parameter support introduced in PR sonic-net#632 to
fully enable multi-bank CMIS transceiver support throughout the stack.

Changes include:

1. **Memory Map Bank Awareness**:
   - Updated CmisFlatMemMap, CmisMemMap, and CCmisMemMap to accept bank parameter
   - Implemented bank-aware getaddr() method in CmisFlatMemMap that correctly
     calculates linear offsets using the formula from sonic-linux-kernel PR sonic-net#473
   - Added bank property to CmisFlatMemMap for read-only access
   - Added constants: CMIS_EEPROM_PAGE_SIZE, CMIS_NUM_NON_BANKED_PAGES,
     CMIS_NUM_BANKED_PAGES, CMIS_ARCH_PAGES
   - Uses unified formula: linear_offset = (bank * CMIS_ARCH_PAGES + page) * page_size + offset
   - Each bank is treated as a full 256-page (32KB) architectural block for proper alignment

2. **API Factory Updates**:
   - Added bank parameter to create_xcvr_api() and _create_cmis_api()
   - Updated CMIS API instantiation to pass bank parameter to memory maps
   - Modified id_mapping to pass bank parameter for all CMIS module types
     (0x18, 0x19, 0x1b, 0x1e)

3. **SfpBase Integration**:
   - Updated refresh_xcvr_api() to pass bank parameter when creating xcvr_api

4. **Field Definitions**:
   - Added BANKS_SUPPORTED_FIELD constant to consts.py
   - Added BanksSupported field to MODULE_CHAR_ADVT in CmisMemMap

This enables proper support for CMIS modules with multiple memory banks,
allowing correct EEPROM access across all banks as defined in the CMIS
specification. The offset calculation formula matches the optoe kernel
driver implementation in sonic-linux-kernel PR sonic-net#473.

Signed-off-by: Bobby McGonigle <bobby@nexthop.ai>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants