[cmis] Fix enter_password to include standard password entry method - #724
[cmis] Fix enter_password to include standard password entry method#724Junchao-Mellanox wants to merge 1 commit into
Conversation
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Hi @prgeor , @mihirpat1 , could you please help review this? Thanks! |
600270d to
b6282d6
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
8676fb0 to
2abdcf0
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
59eeec7 to
2d17bd7
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR extends the SONiC CMIS transceiver support to enter the host password using the CMIS-standard Password Entry Area (page 00h bytes 122–125, MSB-first) and to optionally confirm acceptance via the PasswordCmdResult register (CMIS 5.3+). It also wires this capability into the CDB handler path and updates unit tests accordingly.
Changes:
- Added CMIS-side password entry via Password Entry Area with optional polling of PasswordCmdResult (CMIS 5.3+).
- Extended the CMIS page00 lower memory map and field constants to expose Password Entry Area and PasswordCmdResult.
- Updated CDB/CDB-FW handler construction and tests to support delegating password entry to CMIS as a fallback path.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/sonic_xcvr/test_cmis.py | Adds unit tests for CMIS password-entry support checks and polling behavior. |
| tests/sonic_xcvr/test_cdb.py | Updates CDB handler tests to include CMIS fallback behavior and weakref semantics. |
| tests/sonic_xcvr/test_cdb_fw.py | Updates firmware handler tests for the new handler constructor signature. |
| sonic_platform_base/sonic_xcvr/mem_maps/public/cmis/pages/page00_lower.py | Adds CMIS page00 mappings for Password Entry Area and PasswordCmdResult. |
| sonic_platform_base/sonic_xcvr/fields/consts.py | Introduces constants for password entry/result registers and polling parameters. |
| sonic_platform_base/sonic_xcvr/cdb/cdb.py | Adds CMIS API weakref and password-entry fallback wiring in CdbCmdHandler. |
| sonic_platform_base/sonic_xcvr/cdb/cdb_fw.py | Updates firmware handler to pass through CMIS API reference. |
| sonic_platform_base/sonic_xcvr/api/public/cmis.py | Implements Password Entry Area write + PasswordCmdResult polling and CMIS revision gating. |
| sonic_platform_base/sonic_xcvr/api/public/cdb_fw.py | Passes cmis_api=self into the CDB firmware handler factory. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
e1574c1 to
0b965c7
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
`CdbCmdHandler.enter_password()` previously delivered the CMIS host password only via CDB command `0001h`. This is not the standard mechanism defined by the CMIS spec and is not honored by all modules — the standard, universally-supported way to unlock password-protected CDB/EEPROM access is to write the 4-byte host password (MSB first) to the Password Entry Area at page 00h bytes 122-125. As a result, password entry would fail on modules that only unlock via the Password Entry Area, blocking protected CDB/EEPROM operations (e.g. firmware/SED-protected access) on those modules. - `cdb.py` — Reworked `enter_password()` to first write the password to the Password Entry Area (page 00h bytes 122-125, MSB first) using `write_raw`, which is the standard method honored by all CMIS modules. If that write fails, it falls back to the original CDB command `0001h` path for modules that rely on it. Input validation (integer in range `0..0xFFFFFFFF`) is preserved, and `struct` is used to pack the 32-bit password big-endian. - `cdb_consts.py` — Added `CDB_HOST_PASSWORD_ENTRY_OFFSET = 122` and `CDB_HOST_PASSWORD_ENTRY_SIZE = 4` with documentation describing the Password Entry Area register layout. - `test_cdb.py` — Updated existing tests to assert the password is now written MSB-first to the Password Entry Area (and that no CDB command is sent when the register write succeeds), and added `test_enter_password_fallback_to_cdb_command` to cover the fallback path when the register write fails. Ran the updated unit tests in `tests/sonic_xcvr/test_cdb.py`, covering: - `test_enter_password_valid` — password written MSB-first to the Password Entry Area, no CDB command issued. - `test_enter_password_default` — default password (`0x00001011`) written to the Password Entry Area. - `test_enter_password_fallback_to_cdb_command` — CDB command `0001h` used as fallback when the register write returns `False`. Signed-off-by: Junchao Chen <junchao@mellanox.com>
0b965c7 to
8557319
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
| self._init_cdb_fw_handler = False | ||
| return None | ||
|
|
||
| def _enter_password(self, password=cdb_consts.CDB_DEFAULT_PASSWORD): |
There was a problem hiding this comment.
@Junchao-Mellanox how does password access via EEPROM relates to the CDB firmware handler. this file is for cdb_fw handling.
There was a problem hiding this comment.
As we discussed, it needs to fallback to standard memory way if CDB password way does not work. This file is the place to call enter_password, so it should handle the logic like this:
- Try CDB password way first; otherwise
- Fall back to EEPROM write password
There was a problem hiding this comment.
@Junchao-Mellanox see my comments below. A new options in the cli can avoid this.
There was a problem hiding this comment.
@prgeor , there is a auto flow in xcvrd, which cannot rely on the CLI option.
| """ | ||
| Enter host password via CDB command 0001h. | ||
| Returns True if password accepted, False/None otherwise. | ||
| Enter the host password via CDB command 0001h. This path is synchronous: |
There was a problem hiding this comment.
@Junchao-Mellanox keep this file changes limited to CDB protocol
There was a problem hiding this comment.
There is no code logic change in this file. I will revert this.
There was a problem hiding this comment.
Hi @prgeor , I am fine to add a new CLI option. However, the auto fallback logic is for xcvrd who might periodically call CmisApi.get_transceiver_info_firmware_versions which in turn calls api.get_module_fw_info(). In this flow, it might require entering password. As this is an auto flow, CLI option could not help here.
| cmis_rev = [str(num) for num in [cmis_major, cmis_minor]] | ||
| return '.'.join(cmis_rev) | ||
|
|
||
| def _supports_password_cmd_result(self): |
There was a problem hiding this comment.
@Junchao-Mellanox to maintain backward compatibility, I would suggest to add a new option in the CLI where user can exercise the password via eeprom write. keep the default password to CDB.
There was a problem hiding this comment.
Currently, there is automatically fallback. Do you think we still need to add an extra option in CLI?
There was a problem hiding this comment.
@Junchao-Mellanox yes, lets add new option. As mentioned earlier, the EEPROM approach is not reliable compared to the CDB approach. Let the user decide which option to choose.
Why I did it
CMIS defines two ways to deliver the host password that unlocks protected CDB/EEPROM access:
CDB command 0001h is not honored by all CMIS modules. On modules that unlock only via the Password Entry Area, password entry silently fails, which blocks every password-protected CDB/EEPROM operation — firmware download/run/commit and SED-protected access among them. This change makes password entry work across both module families without changing behavior for modules that already unlock via CDB.
How I did it
cdb.py— Reworkedenter_password()to first write the password to the Password Entry Area (page 00h bytes - api/public/cmis.py — New CmisApi.enter_password_via_memory(password), which writes the password to the Password Entry Area and then interprets the result:How to verify it
Unit tests in tests/sonic_xcvr/test_cmis.py and tests/sonic_xcvr/test_cdb.py: