Skip to content

Updated STATE_DB tables for c-cmis pm#856

Open
nkanchi-nexthop wants to merge 2 commits into
sonic-net:masterfrom
nexthop-ai:nkanchi.c-cmis-pm-table-updates
Open

Updated STATE_DB tables for c-cmis pm#856
nkanchi-nexthop wants to merge 2 commits into
sonic-net:masterfrom
nexthop-ai:nkanchi.c-cmis-pm-table-updates

Conversation

@nkanchi-nexthop

@nkanchi-nexthop nkanchi-nexthop commented Jul 16, 2026

Copy link
Copy Markdown

Description

  • Adds a new TRANSCEIVER_PM_COUNTERS STATE_DB table and routes raw FEC counter fields (page 34h counters and page 3Ah counters) from get_transceiver_pm() into it, while calculated ratios and metrics stay in TRANSCEIVER_PM.
  • Adds the table constant, per-asic Table handle, and accessor to xcvr_table_helper.py.
  • Splits the PM dict by a PM_COUNTER_FIELDS set in post_port_pm_info_to_db (dom_mgr.py), updates the caller to pass both table handles, and adds cleanup of the new table on logical port removal.

Motivation and Context

TRANSCEIVER_PM was only accumulating derived analog PM metrics (BER ratios, optical power/OSNR/etc.) from page 34h counters. Adding raw counters into their own table gives consumers a distinction between processed diagnostics and raw counters. Also, the new table gives a location for the new host counters from C-CMIS 1.4 page 3Ah.

How Has This Been Tested?

  • Ran the xcvrd unit tests (tests/test_xcvrd.py), focusing on test_post_port_pm_info_to_db (asserts non-counter fields land in TRANSCEIVER_PM and counter fields land in TRANSCEIVER_PM_COUNTERS).
  • Verified on a DUT with changes from following PRS: C-CMIS PM API/Memory Maps, C-CMIS PM STATE_DB, C-CMIS PM CLI.

Signed-off-by: nkanchi-nexthop <nkanchi@nexthop.ai>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

Signed-off-by: Nikhil Kanchi <nkanchi@nexthop.ai>
@nkanchi-nexthop
nkanchi-nexthop force-pushed the nkanchi.c-cmis-pm-table-updates branch from df23e1d to 958f0b4 Compare July 16, 2026 22:44
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 856 in repo sonic-net/sonic-platform-daemons

1 similar comment
@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 856 in repo sonic-net/sonic-platform-daemons

@nkanchi-nexthop
nkanchi-nexthop marked this pull request as ready for review July 16, 2026 23:15
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks!

---Powered by SONiC BuildBot

# Raw FEC counter fields from get_transceiver_pm() that are published to the
# TRANSCEIVER_PM_COUNTERS table instead of TRANSCEIVER_PM. This is a positive list:
# any field not named here (calculated ratios, optical metrics) stays in TRANSCEIVER_PM.
PM_COUNTER_FIELDS = frozenset({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkanchi-nexthop there are streaming telemetry applications already using these counters from TRANSCEIVER_PM so this change will break those. To maintain backward compatibility, I would suggest to not remove these fields from old PM table

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the sonic-xcvrd transceiver daemon’s STATE_DB publishing to split transceiver PM output into two tables: derived/processed PM metrics remain in TRANSCEIVER_PM, while raw FEC counter fields from get_transceiver_pm() are routed into a new TRANSCEIVER_PM_COUNTERS table. This aligns the DB schema with newer C-CMIS PM counter exposure while keeping the existing PM table focused on calculated metrics.

Changes:

  • Add TRANSCEIVER_PM_COUNTERS table support in XcvrTableHelper (per-ASIC table handle + accessor).
  • Split PM publishing in DomInfoUpdateTask.post_port_pm_info_to_db() into metrics vs. raw counters, and pass both table handles from the caller.
  • Extend unit test coverage to validate PM vs. PM_COUNTERS routing behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
sonic-xcvrd/xcvrd/xcvrd_utilities/xcvr_table_helper.py Adds a new PM counters table constant/handle and a getter used by DOM publishing paths.
sonic-xcvrd/xcvrd/dom/dom_mgr.py Splits PM dict publishing into two tables and updates call sites / removal cleanup list accordingly.
sonic-xcvrd/tests/test_xcvrd.py Updates unit test to assert raw counter fields land in TRANSCEIVER_PM_COUNTERS while derived fields remain in TRANSCEIVER_PM.

Comment on lines 47 to 50
TRANSCEIVER_PM_TABLE = 'TRANSCEIVER_PM'
TRANSCEIVER_PM_COUNTERS_TABLE = 'TRANSCEIVER_PM_COUNTERS'
TRANSCEIVER_CMIS_STATE_TIMESTAMPS_TABLE = 'TRANSCEIVER_CMIS_STATE_TIMESTAMPS'

Comment on lines 73 to +75
self.status_sw_tbl = {}
self.cmis_state_timestamps_tbl = {}
self.pm_counters_tbl = {}
Comment on lines +255 to 258
def post_port_pm_info_to_db(self, logical_port_name, port_mapping, pm_table, pm_counters_table, stop_event=threading.Event(), pm_info_cache=None):
for physical_port, physical_port_name in common.get_physical_port_name_dict(logical_port_name, port_mapping).items():
if stop_event.is_set():
break
Comment on lines 542 to +546
self.xcvr_table_helper.get_status_flag_change_count_tbl(port_change_event.asic_id),
self.xcvr_table_helper.get_status_flag_set_time_tbl(port_change_event.asic_id),
self.xcvr_table_helper.get_status_flag_clear_time_tbl(port_change_event.asic_id),
self.xcvr_table_helper.get_pm_tbl(port_change_event.asic_id),
self.xcvr_table_helper.get_pm_counters_tbl(port_change_event.asic_id),
Comment on lines +1402 to +1406
pm_counters_tbl = Table("STATE_DB", TRANSCEIVER_PM_COUNTERS_TABLE)
assert pm_tbl.get_size() == 0
dom_info_update.post_port_pm_info_to_db(logical_port_name, port_mapping, pm_tbl, stop_event)
assert pm_counters_tbl.get_size() == 0
dom_info_update.post_port_pm_info_to_db(logical_port_name, port_mapping, pm_tbl, pm_counters_tbl, stop_event)
# Non-counter fields (6 preFEC ratios) go to TRANSCEIVER_PM.
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.

4 participants