Skip to content

[xcvr]: Support 150GHz grid in get_laser_config_freq/set_laser_freq#718

Open
gs1571 wants to merge 2 commits into
sonic-net:masterfrom
gs1571:fix/ccmis-150ghz-laser-tuning
Open

[xcvr]: Support 150GHz grid in get_laser_config_freq/set_laser_freq#718
gs1571 wants to merge 2 commits into
sonic-net:masterfrom
gs1571:fix/ccmis-150ghz-laser-tuning

Conversation

@gs1571

@gs1571 gs1571 commented Jul 16, 2026

Copy link
Copy Markdown

Description

get_freq_grid() already maps GridSpacing code 8 to 150 (GHz), but the
two functions that actually use the frequency grid for laser tuning were never
updated to match:

  • get_laser_config_freq() fell through to the generic else branch and
    computed channel * 150 instead of channel * 25 — producing a frequency
    up to several hundred GHz off, and sometimes outside the module's own
    supported range.
  • set_laser_freq() had no grid == 150 branch at all and unconditionally
    returned False for any request on a 150GHz-only module.

Fixed both: get_laser_config_freq() now treats grid 150 the same as grid 75
(channel step is 25GHz for both — a 150GHz channel is simply every 6th 25GHz
step). set_laser_freq() gained a grid == 150 branch (GridSpacingTx1 code
0x80, channel number required to be a multiple of 6).

Motivation and Context

Found bringing up an 800G ZR+ coherent module (CMIS 5.3) that only supports
the 150GHz DWDM grid. Without this fix such a module can never be tuned to a
target frequency — set_laser_freq() always fails, and even reading back the
configured frequency is wrong.

* get_freq_grid() already maps GridSpacing code 8 to 150GHz, but
  get_laser_config_freq() and set_laser_freq() were never updated to
  match: get_laser_config_freq() fell through to the generic branch
  and computed channel * 150 instead of channel * 25, and
  set_laser_freq() had no grid==150 case at all and returned False
  for any 150GHz-only module.
* get_laser_config_freq(): treat grid 150 like grid 75 (channel step
  is 25GHz for both; 150GHz channels are simply every 6th 25GHz step).
* set_laser_freq(): add a grid==150 branch, GridSpacingTx1 code 0x80,
  channel number required to be a multiple of 6.

Signed-off-by: Grigory Solovyev <gs1571@gmail.com>
@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

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

channel_number = int(round((freq - 193100)/100))
elif grid == 150:
freq_grid = 0x80
channel_number = int(round((freq - 193100)/25))

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.

Not sure, but both here and here:

        if freq_grid in (75, 150):
            config_freq = 193100 + channel * 25

we haven't accounted for the +3 in the spec:

Image

@gs1571 gs1571 Jul 18, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

My bad, missed the offset entirely — should have checked the spec table more carefully before submitting. Fixed both directions: get_laser_config_freq() adds 3 to the channel before scaling, set_laser_freq() subtracts 3 before the % 6 check and the write.

One thing worth flagging: this shifts which frequencies are valid on the 150GHz grid — 193175/193325/193475/... instead of 193100/193250/193400/.... Any config targeting the old values will now correctly fail the channel_number % 6 == 0 check, since those were never real grid points; the old code just silently accepted them at the wrong frequency.

Pushed the fix with updated/added tests in test_ccmis.py, including an explicit assertion on the channel number actually written.

* OIF-CMIS 5.3 Table 8-66 defines the 150GHz grid as
  Frequency = 193.1 + (n+3) x 0.025 THz, unlike the 75GHz grid
  (Frequency = 193.1 + n x 0.025 THz) which has no additive offset.
  get_laser_config_freq()/set_laser_freq() treated both grids identically,
  so every 150GHz frequency was off by exactly +75GHz (3 channels x 25GHz)
  from what was requested.
* get_laser_config_freq() now adds 3 to the channel before scaling for
  grid 150; set_laser_freq() subtracts 3 from the computed channel number
  before the "multiple of 6" validation and before writing it to the
  module.
* Add/update tests in test_ccmis.py covering the corrected 150GHz
  formula and asserting the exact channel number written to the module.

Signed-off-by: Grigory Solovyev <gs1571@gmail.com>
@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.

3 participants