[xcvr]: Fix appl_advt dict-lookup for non-sequential AppSel indices#713
[xcvr]: Fix appl_advt dict-lookup for non-sequential AppSel indices#713gs1571 wants to merge 2 commits into
Conversation
* get_host_lane_count(), get_media_lane_count() and get_media_lane_assignment_option() used `len(appl_advt) >= appl` to guard a dict lookup into the application advertisement. This assumes appl_advt keys are a contiguous 1..N range, which does not hold for modules that advertise applications from CMIS 5.x NAD (Page 01h), where an App index (e.g. 9) can be present in a dict with fewer than `appl` total entries. * Change the guard to `appl in appl_advt`, matching the pattern already used by get_host_lane_assignment_option() in the same file. Signed-off-by: Grigory Solovyev <gs1571@gmail.com>
|
|
|
/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, 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
|
|
Thinking further: a module that advertises only a single application, and it is not the first application descriptor (app sel code 1) is not compliant with the CMIS spec: "A module advertises at least one supported Application as its power-up default Application in the first Application Descriptor (identified by AppSel code 1), and it advertises any additionally supported types of Applications consecutively..." Looking at the code for I don't think it seems likely that the current fix addresses the root cause as result. It seems like either one of the two is the root cause:
|
bgallagher-nexthop
left a comment
There was a problem hiding this comment.
(Marking request changes to dismiss my approval based on above comment)
aditya-nexthop
left a comment
There was a problem hiding this comment.
Found while bringing up an 800G ZR+ coherent module (CMIS 5.3) whose only
advertised Lower-Memory Application is at a non-1 index
Please can you explain how a module does this? If the only advertised Lower-Memory Application is at a non-1 index, what's in the application advertisements prior (1 to n) to this application?
It would help if you can post either an EEPROM dump of the advertising region or a list of applications this module advertises.
|
@bgallagher-nexthop @aditya-nexthop Went back and tried to reproduce this on the actual module. What I could reproduce is a different, and I think more likely, cause — the one @bgallagher-nexthop suggested: our SFF-8024 table not covering all of the module's MediaIF codes. Setup: an 800G ZR+ coherent module (CMIS 5.3) that, with full SFF-8024 coverage, advertises a clean, contiguous I removed 2 of the 3 SFF-8024 entries this module needs (kept the third), then restarted xcvrd. Result: Apps 1-8 disappeared — xcvrd acted on this dict directly:
So: I can't prove the module itself is non-compliant, and I'm dropping that claim. But an incomplete SFF-8024 table — which is a moving target, given how often new codes get added (#601, #687, #701 alone span about 9 months) — produces the exact same non-contiguous |
| # Regression: appl present but with an index higher than | ||
| # len(appl_advt) (e.g. App index 9 from Page 01h NAD advertised | ||
| # alongside a single App in the Lower Page). A previous | ||
| # `len(appl_advt) >= appl` check incorrectly returned 0 here. |
There was a problem hiding this comment.
please don't leave comments about code that no longer exists. It only confuses readers.
| # Regression: appl present but with an index higher than | ||
| # len(appl_advt). A previous `len(appl_advt) >= appl` check | ||
| # incorrectly returned 0 here even though appl_advt[9] exists. |
There was a problem hiding this comment.
please don't leave comments about code that no longer exists. It only confuses readers.
| # Regression: appl present but with an index higher than | ||
| # len(appl_advt). A previous `len(appl_advt) >= appl` check | ||
| # incorrectly returned 0 here even though appl_advt[9] exists. |
bgallagher-nexthop
left a comment
There was a problem hiding this comment.
The fix makes sense to me when framed as striving for best-effort application advertisement parsing in the presence of an incomplete/outdated SFF-8024 identifier set (software allows a sparse app advertisement dict since it skips applications it could not successfully decode). Please also update the PR description to reflect this reasoning for the fix.
* Describe why the advertisement can be sparse (Apps skipped for undecodable SFF-8024 codes) instead of referring to the removed `len(appl_advt) >= appl` guard, per review feedback. Signed-off-by: Grigory Solovyev <gs1571@gmail.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Thanks for your comments. Addressed both asks from this round: reworded the three sparse- No changes to the fix itself ( |
Description
get_host_lane_count(),get_media_lane_count()andget_media_lane_assignment_option()in
cmis.pyguard their dict lookup into the application advertisement withlen(appl_advt) >= appl. That holds only when the advertised Applications form acontiguous
1..Nrange, and returns0for a valid Application on a sparseadvertisement, where
appl in appl_advtis true butlen(appl_advt) < appl.Changed the guard to
appl in appl_advt, matching the pattern already used byget_host_lane_assignment_option()in the same file.Motivation and Context
get_application_advertisement()is best-effort: it skips any Application whosehost/media interface code cannot be decoded (an unknown SFF-8024 code decodes to
Unknownand is dropped). The advertisement dict is therefore allowed to besparse / non-contiguous, so consumers must look Applications up by key rather
than assume the keys are
1..N. Under the old guard, when a module advertises anApplication at an index higher than the number of decoded entries (e.g.
appl=9with
len(appl_advt) == 4), these getters return0for a valid Application.How Has This Been Tested?
Added regression cases with a sparse
appl_advt(single high-index entry) for allthree affected functions in
tests/sonic_xcvr/test_cmis.py, plus a case confirminga genuinely-absent index still returns
0.